Add file handoff audit records
This commit is contained in:
1 parent
babbf07cb2
commit
4dbd8997c0
10 files changed
+298
-100
No files matched your search
@@ -23,7 +23,7 @@ describe("domain services", () => {
|
||||
const connection = createConnection();
|
||||
|
||||
const rows = connection.db.prepare("select version from schema_migrations order by version asc").all() as Array<{ version: number }>;
|
||||
expect(rows.map((row) => row.version)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]);
|
||||
expect(rows.map((row) => row.version)).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]);
|
||||
connection.close();
|
||||
});
|
||||
|
||||
@@ -208,6 +208,7 @@ describe("domain services", () => {
|
||||
const chat = new ChatService(connection.db);
|
||||
const snapshot = new SnapshotService(connection.db);
|
||||
let orgId = "";
|
||||
let fileId = "";
|
||||
|
||||
connection.transaction(() => {
|
||||
orgId = organization.createOrganization({
|
||||
@@ -225,7 +226,7 @@ describe("domain services", () => {
|
||||
});
|
||||
const employee = connection.db.prepare("select id from employees where org_id = ?")
|
||||
.get(orgId) as { id: string };
|
||||
const fileId = createId("file");
|
||||
fileId = createId("file");
|
||||
connection.db.prepare(`
|
||||
insert into file_objects(id, org_id, name, kind, size_bytes, sha256, storage_path, owner_type, owner_id, created_at)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
@@ -249,6 +250,15 @@ describe("domain services", () => {
|
||||
expect(state.chatAttachments).toHaveLength(1);
|
||||
expect(state.files[0]?.scanState).toBe("approved");
|
||||
expect(state.fileAccessGrants[0]).toMatchObject({ grantedToType: "board", grantedToId: orgId, accessLevel: "read" });
|
||||
expect(state.fileHandoffRecords[0]).toMatchObject({
|
||||
fileId,
|
||||
targetPrincipalType: "board",
|
||||
targetPrincipalId: orgId,
|
||||
checksum: "8f3a",
|
||||
scanState: "approved",
|
||||
policyDecision: "approved_for_handoff",
|
||||
objectRef: "artifacts/runbook.md",
|
||||
});
|
||||
expect(state.chatMentions[0]).toMatchObject({ targetType: "board", targetId: orgId });
|
||||
expect(state.chatSlashInvocations[0]).toMatchObject({ command: "handoff" });
|
||||
expect(state.chatPresence).toHaveLength(1);
|
||||
@@ -362,7 +372,20 @@ describe("domain services", () => {
|
||||
const state = snapshot.load();
|
||||
const benGrant = state.fileAccessGrants.find((grant) => grant.fileId === approvedFileId && grant.grantedToId === benId);
|
||||
if (!benGrant) throw new Error("Agent handoff grant was not created.");
|
||||
const benHandoff = state.fileHandoffRecords.find((record) => (
|
||||
record.fileId === approvedFileId && record.sourcePrincipalId === adaId && record.targetPrincipalId === benId
|
||||
));
|
||||
if (!benHandoff) throw new Error("Agent handoff record was not created.");
|
||||
expect(benGrant).toMatchObject({ grantedToType: "agent", accessLevel: "read" });
|
||||
expect(benHandoff).toMatchObject({
|
||||
sourcePrincipalType: "agent",
|
||||
sourcePrincipalId: adaId,
|
||||
targetPrincipalType: "agent",
|
||||
checksum: "sha-approved",
|
||||
objectRef: "artifacts/release-notes.md",
|
||||
scanState: "approved",
|
||||
policyDecision: "approved_for_handoff",
|
||||
});
|
||||
expect(state.chatMessages).toHaveLength(2);
|
||||
expect(state.auditEvents.some((event) => event.entityType === "file_object" && event.action === "access_granted")).toBe(true);
|
||||
connection.close();
|
||||
|
||||
@@ -163,6 +163,7 @@ describe("migration service", () => {
|
||||
create table skill_catalog_tags(skill_id text, tag text, tag_type text);
|
||||
create table file_objects(id text primary key, org_id text, space_id text);
|
||||
create table file_access_grants(id text primary key, org_id text, file_id text, source_message_id text, source_thread_id text);
|
||||
create table file_handoff_records(id text primary key, org_id text, message_id text, file_id text);
|
||||
create table social_accounts(id text primary key, org_id text, authorized_employee_id text);
|
||||
create table social_account_grants(id text primary key, org_id text, social_account_id text, employee_id text);
|
||||
create table browser_session_containers(id text primary key, org_id text, social_account_id text);
|
||||
@@ -218,6 +219,7 @@ describe("migration service", () => {
|
||||
insert into chat_memberships(space_id, principal_type, principal_id) values ('space-1', 'employee', 'emp-1');
|
||||
insert into chat_attachments(message_id, file_id) values ('msg-1', 'file-1');
|
||||
insert into file_access_grants(id, org_id, file_id, source_message_id, source_thread_id) values ('file-grant-1', 'org-1', 'file-1', 'msg-1', 'thread-1');
|
||||
insert into file_handoff_records(id, org_id, message_id, file_id) values ('handoff-1', 'org-1', 'msg-1', 'file-1');
|
||||
insert into chat_mentions(message_id, target_type, target_id) values ('msg-1', 'agent', 'agent-1');
|
||||
insert into chat_slash_invocations(id, message_id) values ('slash-1', 'msg-1');
|
||||
insert into board_interventions(id, org_id, thread_id, message_id, approval_id) values ('bdi-1', 'org-1', 'thread-1', 'msg-1', 'approval-1');
|
||||
@@ -283,6 +285,7 @@ describe("migration service", () => {
|
||||
expect(body.tableCounts.chat_read_state).toBe(1);
|
||||
expect(body.tableCounts.board_interventions).toBe(1);
|
||||
expect(body.tableCounts.file_access_grants).toBe(1);
|
||||
expect(body.tableCounts.file_handoff_records).toBe(1);
|
||||
expect(body.tableCounts.provider_requests).toBe(1);
|
||||
expect(body.tableCounts.provider_usage_windows).toBe(1);
|
||||
expect(body.tableCounts.provider_rate_limit_observations).toBe(1);
|
||||
@@ -306,6 +309,7 @@ describe("migration service", () => {
|
||||
expect(body.idMaps.sdlc_review_runs).toEqual(["review-run-1"]);
|
||||
expect(body.idMaps.eval_runs).toEqual(["eval-run-1"]);
|
||||
expect(body.idMaps.board_interventions).toEqual(["bdi-1"]);
|
||||
expect(body.idMaps.file_handoff_records).toEqual(["handoff-1"]);
|
||||
expect(body.idMaps.retention_freezes).toEqual(["freeze-1"]);
|
||||
expect(body.idMaps.audit_replay_runs).toEqual(["replay-1"]);
|
||||
expect(body.idMaps.rollback_snapshots).toEqual(["rollback-1"]);
|
||||
|
||||
Reference in new issue
Block a user