Q135: remove the thread replay that only digested events and reconstructed nothing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-08 21:47:48 -04:00
1 parent 403c57785c
commit f8f852c326
21 files changed
+17 -288

No files matched your search

+4 -51
View File
@@ -3,10 +3,8 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { describe, expect, test } from "vitest";
import { DatabaseConnection } from "../../src/main/database/connection";
import { AuditService } from "../../src/main/services/audit-service";
import { ChatService } from "../../src/main/services/chat-service";
import { OrganizationService } from "../../src/main/services/organization-service";
import { SnapshotService } from "../../src/main/services/snapshot-service";
import { IPC_CHANNELS } from "../../src/shared/ipc";
function createConnection(): DatabaseConnection {
return new DatabaseConnection(join(tmpdir(), `agentcompany-new-audit-${randomUUID()}.db`));
@@ -35,55 +33,10 @@ describe("audit service", () => {
connection.close();
});
test("creates thread scoped replay runs from immutable audit events", () => {
test("offers no thread replay that only digests events and reconstructs nothing", () => {
const connection = createConnection();
const organization = new OrganizationService(connection.db);
const chat = new ChatService(connection.db);
const audit = new AuditService(connection.db);
const snapshot = new SnapshotService(connection.db);
let orgId = "";
let employeeId = "";
let threadId = "";
connection.transaction(() => {
orgId = organization.createOrganization({
organizationName: "Acme Operations",
employeeName: "Dana Lee",
mission: "Coordinate agents with auditable approvals.",
goal: "Ship a verified control plane.",
});
employeeId = (connection.db.prepare("select id from employees where org_id = ?").get(orgId) as { id: string }).id;
const spaceId = chat.createSpace({
orgId,
spaceType: "project",
name: "release",
topic: "Release coordination",
visibility: "workspace",
});
const messageId = chat.sendMessage({
orgId,
spaceId,
threadId: null,
senderType: "employee",
senderId: employeeId,
bodyMd: "/escalate review release plan",
attachmentFileIds: [],
});
threadId = (connection.db.prepare("select thread_id from chat_messages where id = ?").get(messageId) as { thread_id: string }).thread_id;
audit.createThreadReplay({ orgId, threadId, createdByEmployeeId: employeeId });
});
const state = snapshot.load();
const run = state.auditReplayRuns[0];
if (!run) throw new Error("Audit replay run was not created.");
const replay = JSON.parse(run.replayJson) as { events: Array<{ entityType: string; action: string }> };
expect(run.threadId).toBe(threadId);
expect(run.eventDigest).toHaveLength(64);
expect(run.eventCount).toBe(replay.events.length);
expect(replay.events).toContainEqual(expect.objectContaining({ entityType: "chat_message", action: "sent" }));
expect(replay.events).toContainEqual(expect.objectContaining({ entityType: "approval", action: "requested" }));
expect(replay.events.some((event) => event.entityType === "audit_replay_run")).toBe(false);
expect(state.auditEvents.some((event) => event.entityType === "audit_replay_run" && event.action === "created")).toBe(true);
expect(connection.db.prepare("select name from sqlite_master where type = 'table' and name = 'audit_replay_runs'").all()).toEqual([]);
expect(Object.keys(IPC_CHANNELS)).not.toContain("createAuditReplay");
connection.close();
});
});