Skip to content

ToolAdapterService — 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.ToolDescriptors

Owner: ToolDescriptor

CREATE TABLE [dbo].[ToolDescriptors] (
    [ToolId] nvarchar(128) NOT NULL,
    [Version] nvarchar(32) NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [ReleaseId] nvarchar(256) NOT NULL,
    [Kind] int NOT NULL,
    [SchemaRef] nvarchar(512) NOT NULL,
    [SideEffectClass] nvarchar(16) NOT NULL,
    [RiskClass] int NOT NULL,
    [AuthorizationJson] nvarchar(2000) NOT NULL,
    [SecretDependenciesJson] nvarchar(2000) NOT NULL,
    [TimeoutSeconds] int NOT NULL,
    [RetryPolicyJson] nvarchar(512) NOT NULL,
    [RateLimitsJson] nvarchar(512) NOT NULL,
    [AuditRequirementsJson] nvarchar(1024) NOT NULL,
    [SandboxKind] int NOT NULL,
    [McpServerId] nvarchar(128) NULL,
    [Healthy] bit NOT NULL DEFAULT (1),
    [Active] bit NOT NULL DEFAULT (1),
    CONSTRAINT [PK_ToolDescriptors] PRIMARY KEY ([ToolId], [Version])
);
CREATE INDEX [IX_ToolDescriptors_Tenant_Active] ON [dbo].[ToolDescriptors] ([TenantId], [Active], [Kind]);
Column Type Null Key Description
ToolId nvarchar(128) no PK
Version nvarchar(32) no PK
TenantId nvarchar(64) no
ReleaseId nvarchar(256) no
Kind int no
SchemaRef nvarchar(512) no
SideEffectClass nvarchar(16) no
RiskClass int no
AuthorizationJson nvarchar(2000) no
SecretDependenciesJson nvarchar(2000) no
TimeoutSeconds int no
RetryPolicyJson nvarchar(512) no
RateLimitsJson nvarchar(512) no
AuditRequirementsJson nvarchar(1024) no
SandboxKind int no
McpServerId nvarchar(128) yes
Healthy bit no
Active bit no

dbo.ToolInvocations

Owner: ToolInvocation · Retention: 1 year by default (D31); receipts referenced by audit evidence 7 years

CREATE TABLE [dbo].[ToolInvocations] (
    [InvocationId] uniqueidentifier NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [ProjectId] nvarchar(64) NOT NULL,
    [EnvironmentId] nvarchar(64) NULL,
    [RunId] uniqueidentifier NULL,
    [AttemptId] uniqueidentifier NULL,
    [FencingToken] bigint NULL,
    [CallerKind] nvarchar(16) NOT NULL,
    [ToolId] nvarchar(128) NOT NULL,
    [ToolVersion] nvarchar(32) NOT NULL,
    [RequestHash] nvarchar(128) NOT NULL,
    [IdempotencyKey] nvarchar(128) NOT NULL,
    [DeclaredClass] nvarchar(16) NOT NULL,
    [EffectiveClass] nvarchar(16) NOT NULL,
    [PolicyDecisionId] uniqueidentifier NULL,
    [ApprovalId] uniqueidentifier NULL,
    [State] int NOT NULL,
    [SandboxLeaseId] uniqueidentifier NULL,
    [ResultRef] nvarchar(512) NULL,
    [ResultHash] nvarchar(128) NULL,
    [ReceiptRef] nvarchar(512) NULL,
    [AuditRef] nvarchar(512) NULL,
    [FailureClass] nvarchar(16) NULL,
    [StartedAt] datetimeoffset NOT NULL,
    [EndedAt] datetimeoffset NULL,
    CONSTRAINT [PK_ToolInvocations] PRIMARY KEY ([InvocationId])
);
CREATE UNIQUE INDEX [UX_Invocations_Scope_Idempotency] ON [dbo].[ToolInvocations] ([TenantId], [ProjectId], [IdempotencyKey]);
CREATE INDEX [IX_Invocations_Run_Attempt] ON [dbo].[ToolInvocations] ([RunId], [AttemptId]);
CREATE INDEX [IX_Invocations_Tenant_State] ON [dbo].[ToolInvocations] ([TenantId], [State]);
Column Type Null Key Description
InvocationId uniqueidentifier no PK
TenantId nvarchar(64) no
ProjectId nvarchar(64) no
EnvironmentId nvarchar(64) yes
RunId uniqueidentifier yes
AttemptId uniqueidentifier yes
FencingToken bigint yes
CallerKind nvarchar(16) no
ToolId nvarchar(128) no
ToolVersion nvarchar(32) no
RequestHash nvarchar(128) no
IdempotencyKey nvarchar(128) no
DeclaredClass nvarchar(16) no
EffectiveClass nvarchar(16) no
PolicyDecisionId uniqueidentifier yes
ApprovalId uniqueidentifier yes
State int no
SandboxLeaseId uniqueidentifier yes
ResultRef nvarchar(512) yes
ResultHash nvarchar(128) yes
ReceiptRef nvarchar(512) yes
AuditRef nvarchar(512) yes
FailureClass nvarchar(16) yes
StartedAt datetimeoffset no
EndedAt datetimeoffset yes

dbo.SandboxLeases

Owner: SandboxLease

CREATE TABLE [dbo].[SandboxLeases] (
    [LeaseId] uniqueidentifier NOT NULL,
    [InvocationId] uniqueidentifier NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [Kind] int NOT NULL,
    [PoolId] nvarchar(64) NOT NULL,
    [WorkspaceRef] nvarchar(512) NULL,
    [LimitsJson] nvarchar(2000) NOT NULL,
    [CredentialExpiry] datetimeoffset NOT NULL,
    [LeasedAt] datetimeoffset NOT NULL,
    [ReleasedAt] datetimeoffset NULL,
    CONSTRAINT [PK_SandboxLeases] PRIMARY KEY ([LeaseId])
);
ALTER TABLE [dbo].[SandboxLeases] ADD CONSTRAINT [FK_SandboxLeases_ToolInvocations_InvocationId] FOREIGN KEY ([InvocationId]) REFERENCES [dbo].[ToolInvocations] ([InvocationId]);
CREATE INDEX [IX_SandboxLeases_Open] ON [dbo].[SandboxLeases] ([TenantId], [ReleasedAt]);
Column Type Null Key Description
LeaseId uniqueidentifier no PK
InvocationId uniqueidentifier no FK → ToolInvocations.InvocationId
TenantId nvarchar(64) no
Kind int no
PoolId nvarchar(64) no
WorkspaceRef nvarchar(512) yes
LimitsJson nvarchar(2000) no
CredentialExpiry datetimeoffset no
LeasedAt datetimeoffset no
ReleasedAt datetimeoffset yes