Skip to content

AuditService — DDL appendix

Generated from the architecture model

This page is rendered from model/**/*.yaml by tools/docs_model during mkdocs build. Edit the YAML, not this page; hand-written design lives on the linked service, platform and plane pages.

Dialect shown: SQL Server (nvarchar, uniqueidentifier, datetimeoffset). Migrations are authored as FluentMigrator classes in the service's DatabaseModel.Migrations project; the TenantId column and the NHibernate tenant filter follow canonical ADR-0100 in SharedDb mode.

dbo.AuditEntries

Owner: AuditEntry · Retention: 7 years (D31); mirrored to the immutable store

CREATE TABLE [dbo].[AuditEntries] (
    [EntryId] uniqueidentifier NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [ProjectId] nvarchar(64) NULL,
    [Sequence] bigint NOT NULL,
    [Kind] int NOT NULL,
    [ActorJson] nvarchar(2000) NOT NULL,
    [Action] nvarchar(256) NOT NULL,
    [TargetJson] nvarchar(2000) NOT NULL,
    [Reason] nvarchar(2000) NULL,
    [Outcome] nvarchar(64) NOT NULL,
    [CorrelationId] uniqueidentifier NOT NULL,
    [CausationId] uniqueidentifier NULL,
    [RunId] uniqueidentifier NULL,
    [SourceEvent] nvarchar(128) NOT NULL,
    [PreviousHash] nvarchar(128) NOT NULL,
    [EntryHash] nvarchar(128) NOT NULL,
    [RecordedAt] datetimeoffset NOT NULL,
    CONSTRAINT [PK_AuditEntries] PRIMARY KEY ([EntryId])
);
CREATE UNIQUE INDEX [UX_Audit_Tenant_Sequence] ON [dbo].[AuditEntries] ([TenantId], [Sequence]);
CREATE INDEX [IX_Audit_Run] ON [dbo].[AuditEntries] ([RunId]);
CREATE INDEX [IX_Audit_Tenant_RecordedAt] ON [dbo].[AuditEntries] ([TenantId], [RecordedAt]);
Column Type Null Key Description
EntryId uniqueidentifier no PK
TenantId nvarchar(64) no
ProjectId nvarchar(64) yes
Sequence bigint no
Kind int no
ActorJson nvarchar(2000) no
Action nvarchar(256) no
TargetJson nvarchar(2000) no
Reason nvarchar(2000) yes
Outcome nvarchar(64) no
CorrelationId uniqueidentifier no
CausationId uniqueidentifier yes
RunId uniqueidentifier yes
SourceEvent nvarchar(128) no
PreviousHash nvarchar(128) no
EntryHash nvarchar(128) no
RecordedAt datetimeoffset no

dbo.ChainHeads

Owner: AuditEntry

CREATE TABLE [dbo].[ChainHeads] (
    [TenantId] nvarchar(64) NOT NULL,
    [HeadSequence] bigint NOT NULL,
    [HeadHash] nvarchar(128) NOT NULL,
    [SignedAt] datetimeoffset NOT NULL,
    [Signature] nvarchar(512) NOT NULL,
    CONSTRAINT [PK_ChainHeads] PRIMARY KEY ([TenantId])
);
Column Type Null Key Description
TenantId nvarchar(64) no PK
HeadSequence bigint no
HeadHash nvarchar(128) no
SignedAt datetimeoffset no
Signature nvarchar(512) no

dbo.Classifications

Owner: ClassificationLabel

CREATE TABLE [dbo].[Classifications] (
    [LabelId] uniqueidentifier NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [ResourceType] nvarchar(64) NOT NULL,
    [ResourceId] nvarchar(256) NULL,
    [DataClass] int NOT NULL,
    [RetentionDays] int NOT NULL,
    [RedactionRuleIdsJson] nvarchar(1024) NOT NULL,
    [Residency] nvarchar(32) NOT NULL,
    [SetBy] nvarchar(256) NOT NULL,
    [SetAt] datetimeoffset NOT NULL,
    CONSTRAINT [PK_Classifications] PRIMARY KEY ([LabelId])
);
CREATE UNIQUE INDEX [UX_Classifications_Resource] ON [dbo].[Classifications] ([TenantId], [ResourceType], [ResourceId]);
Column Type Null Key Description
LabelId uniqueidentifier no PK
TenantId nvarchar(64) no
ResourceType nvarchar(64) no
ResourceId nvarchar(256) yes
DataClass int no
RetentionDays int no
RedactionRuleIdsJson nvarchar(1024) no
Residency nvarchar(32) no
SetBy nvarchar(256) no
SetAt datetimeoffset no

dbo.RedactionRules

Owner: RedactionRule

CREATE TABLE [dbo].[RedactionRules] (
    [RuleId] nvarchar(128) NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [Detector] nvarchar(32) NOT NULL,
    [Action] nvarchar(16) NOT NULL,
    [AppliesToJson] nvarchar(256) NOT NULL,
    CONSTRAINT [PK_RedactionRules] PRIMARY KEY ([RuleId])
);
Column Type Null Key Description
RuleId nvarchar(128) no PK
TenantId nvarchar(64) no
Detector nvarchar(32) no
Action nvarchar(16) no
AppliesToJson nvarchar(256) no

dbo.Findings

Owner: Finding

CREATE TABLE [dbo].[Findings] (
    [FindingId] uniqueidentifier NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [Severity] int NOT NULL,
    [Category] nvarchar(64) NOT NULL,
    [EvidenceEntryIdsJson] nvarchar(max) NOT NULL,
    [Owner] nvarchar(256) NULL,
    [State] nvarchar(16) NOT NULL,
    [RaisedAt] datetimeoffset NOT NULL,
    [ResolvedAt] datetimeoffset NULL,
    CONSTRAINT [PK_Findings] PRIMARY KEY ([FindingId])
);
CREATE INDEX [IX_Findings_Tenant_State] ON [dbo].[Findings] ([TenantId], [State], [Severity]);
Column Type Null Key Description
FindingId uniqueidentifier no PK
TenantId nvarchar(64) no
Severity int no
Category nvarchar(64) no
EvidenceEntryIdsJson nvarchar(max) no
Owner nvarchar(256) yes
State nvarchar(16) no
RaisedAt datetimeoffset no
ResolvedAt datetimeoffset yes