Add thread audit replay controls

This commit is contained in:
ZacharyZhang-NY committed 2026-05-23 18:48:14 -04:00
1 parent bbf90a1a62
commit 6768d19239
19 files changed
+299 -3

No files matched your search

@@ -0,0 +1,18 @@
export const auditReplaySchema = `
create table if not exists audit_replay_runs (
id text primary key,
org_id text not null references organizations(id) on delete cascade,
thread_id text not null references chat_threads(id) on delete cascade,
event_count integer not null,
event_digest text not null,
replay_json text not null,
created_by_employee_id text references employees(id) on delete set null,
created_at text not null
);
create index if not exists idx_audit_replay_runs_org_created on audit_replay_runs(org_id, created_at);
create index if not exists idx_audit_replay_runs_thread on audit_replay_runs(thread_id, created_at);
insert into schema_migrations(version, name, applied_at)
values (19, 'audit_replay', datetime('now'));
`;
@@ -17,6 +17,7 @@ import { identityAccessSchema } from "./migrations/015-identity-access";
import { orgGovernanceSchema } from "./migrations/016-org-governance";
import { operationsControlsSchema } from "./migrations/017-operations-controls";
import { sdlcControlsSchema } from "./migrations/018-sdlc-controls";
import { auditReplaySchema } from "./migrations/019-audit-replay";
interface Migration {
version: number;
@@ -43,6 +44,7 @@ const MIGRATIONS: Migration[] = [
{ version: 16, name: "org_governance", sql: orgGovernanceSchema },
{ version: 17, name: "operations_controls", sql: operationsControlsSchema },
{ version: 18, name: "sdlc_controls", sql: sdlcControlsSchema },
{ version: 19, name: "audit_replay", sql: auditReplaySchema },
];
const SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1].version;