Q131: remove review agents and eval suites whose pass only counted configuration rows

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:33:03 -04:00
1 parent 074a1fc8e3
commit fe45cd4d46
20 files changed
+32 -476

No files matched your search

+1 -49
View File
@@ -1,12 +1,6 @@
import { randomUUID } from "node:crypto";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { describe, expect, test } from "vitest";
import { DatabaseConnection } from "../../src/main/database/connection";
import { OrganizationService } from "../../src/main/services/organization-service";
import { providerAdapters } from "../../src/main/services/provider-adapters";
import { SdlcService } from "../../src/main/services/sdlc-service";
import { EVAL_SUITE_KEY, PROVIDER_AUTH_TYPE, SDLC_RUN_STATE } from "../../src/shared/domain";
import { PROVIDER_AUTH_TYPE } from "../../src/shared/domain";
import { PROVIDER_CATALOG } from "../../src/shared/provider-catalog";
const PROVIDER_SECRET_SAMPLES: Record<string, string> = {
@@ -42,19 +36,6 @@ const PROVIDER_SECRET_SAMPLES: Record<string, string> = {
"custom-anthropic": JSON.stringify({ baseUrl: "https://llm.example.com", secret: "sk-custom" }),
};
function createConnection(): DatabaseConnection {
return new DatabaseConnection(join(tmpdir(), `agentcompany-new-contract-${randomUUID()}.db`));
}
function createOrganization(organization: OrganizationService): string {
return organization.createOrganization({
organizationName: "Acme Operations",
employeeName: "Dana Lee",
mission: "Coordinate agents with auditable approvals.",
goal: "Ship a verified control plane.",
});
}
describe("provider contracts", () => {
test("keeps provider catalog and adapters aligned", () => {
expect(Object.keys(providerAdapters).sort()).toEqual(PROVIDER_CATALOG.map((provider) => provider.key).sort());
@@ -139,33 +120,4 @@ describe("provider contracts", () => {
await expect(adapter.refresh({ authProfile: profile })).rejects.toThrow("does not support token refresh");
}
});
test("runs the seeded contract eval suite", () => {
const connection = createConnection();
const organization = new OrganizationService(connection.db);
const sdlc = new SdlcService(connection.db);
let orgId = "";
let suiteId = "";
let runId = "";
connection.transaction(() => {
orgId = createOrganization(organization);
suiteId = (connection.db.prepare("select id from eval_suites where org_id = ? and key = ?")
.get(orgId, EVAL_SUITE_KEY.CONTRACT) as { id: string }).id;
runId = sdlc.runEvalSuite({ orgId, suiteId });
});
const run = connection.db.prepare("select state, failed_count, result_json from eval_runs where id = ?")
.get(runId) as { state: string; failed_count: number; result_json: string };
const result = JSON.parse(run.result_json) as { checks: Array<{ key: string; passed: boolean }> };
expect(run).toMatchObject({ state: SDLC_RUN_STATE.PASSED, failed_count: 0 });
expect(result.checks.map((check) => check.key).sort()).toEqual([
"provider_adapter_coverage",
"provider_rate_limit_registry",
"provider_runtime_contract",
"schema_version",
]);
expect(result.checks.every((check) => check.passed)).toBe(true);
connection.close();
});
});
+2 -11
View File
@@ -7,9 +7,8 @@ import { AuditService } from "../../src/main/services/audit-service";
import { ChatService } from "../../src/main/services/chat-service";
import { OperationsService } from "../../src/main/services/operations-service";
import { OrganizationService } from "../../src/main/services/organization-service";
import { SdlcService } from "../../src/main/services/sdlc-service";
import { SnapshotService } from "../../src/main/services/snapshot-service";
import { EVAL_SUITE_KEY, SDLC_RUN_STATE, SLO_SIGNAL_KEY } from "../../src/shared/domain";
import { SLO_SIGNAL_KEY } from "../../src/shared/domain";
function createConnection(): DatabaseConnection {
return new DatabaseConnection(join(tmpdir(), `agentcompany-new-replay-${randomUUID()}.db`));
@@ -25,19 +24,17 @@ function createOrganization(organization: OrganizationService): string {
}
describe("replay eval", () => {
test("creates deterministic thread replay evidence and runs replay eval suite", () => {
test("creates deterministic thread replay evidence and records the replay digest", () => {
const connection = createConnection();
const organization = new OrganizationService(connection.db);
const chat = new ChatService(connection.db);
const audit = new AuditService(connection.db);
const operations = new OperationsService(connection.db);
const sdlc = new SdlcService(connection.db);
const snapshot = new SnapshotService(connection.db);
let orgId = "";
let employeeId = "";
let threadId = "";
let replayRunId = "";
let evalRunId = "";
connection.transaction(() => {
orgId = createOrganization(organization);
@@ -68,23 +65,17 @@ describe("replay eval", () => {
durationMs: 12,
detail: { threadId, replayRunId },
});
const suiteId = (connection.db.prepare("select id from eval_suites where org_id = ? and key = ?")
.get(orgId, EVAL_SUITE_KEY.REPLAY) as { id: string }).id;
evalRunId = sdlc.runEvalSuite({ orgId, suiteId });
});
const state = snapshot.load();
const replayRun = state.auditReplayRuns.find((run) => run.id === replayRunId);
const evalRun = state.evalRuns.find((run) => run.id === evalRunId);
if (!replayRun) throw new Error("Audit replay run was not created.");
if (!evalRun) throw new Error("Replay eval run was not created.");
const replay = JSON.parse(replayRun.replayJson) as { events: Array<{ entityType: string; action: string }> };
expect(replayRun.threadId).toBe(threadId);
expect(replayRun.eventDigest).toBe(createHash("sha256").update(replayRun.replayJson).digest("hex"));
expect(replayRun.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(evalRun).toMatchObject({ state: SDLC_RUN_STATE.PASSED, failedCount: 0 });
connection.close();
});
});
+1 -11
View File
@@ -7,10 +7,9 @@ import { DatabaseConnection } from "../../src/main/database/connection";
import { ApprovalService } from "../../src/main/services/approval-service";
import { ChatService } from "../../src/main/services/chat-service";
import { OrganizationService } from "../../src/main/services/organization-service";
import { SdlcService } from "../../src/main/services/sdlc-service";
import { SkillService } from "../../src/main/services/skill-service";
import { SnapshotService } from "../../src/main/services/snapshot-service";
import { APPROVAL_STATE, EVAL_SUITE_KEY, SDLC_RUN_STATE } from "../../src/shared/domain";
import { APPROVAL_STATE } from "../../src/shared/domain";
function createConnection(): DatabaseConnection {
return new DatabaseConnection(join(tmpdir(), `agentcompany-new-integration-${randomUUID()}.db`));
@@ -52,7 +51,6 @@ describe("collaboration integration flow", () => {
const approvals = new ApprovalService(connection.db);
const chat = new ChatService(connection.db);
const skills = new SkillService(connection.db, join(tmpdir(), `agentcompany-new-artifacts-${randomUUID()}`));
const sdlc = new SdlcService(connection.db);
const snapshot = new SnapshotService(connection.db);
let orgId = "";
let employeeId = "";
@@ -60,8 +58,6 @@ describe("collaboration integration flow", () => {
let approvalId = "";
let skillId = "";
let revisionId = "";
let suiteId = "";
let evalRunId = "";
connection.transaction(() => {
orgId = createOrganization(organization);
@@ -99,23 +95,17 @@ describe("collaboration integration flow", () => {
skillId = (connection.db.prepare("select skill_id from skill_revisions where id = ?").get(revisionId) as { skill_id: string }).skill_id;
skills.bind({ orgId, agentId, skillId, revisionId });
skills.resolveRuntimeSnapshot({ orgId, agentId, runId: `run_${randomUUID().replaceAll("-", "")}`, maxTokens: 44_800, taskText: "", runModel: { providerKey: "openai", model: "gpt-5.4" }, houseStyle: true });
suiteId = (connection.db.prepare("select id from eval_suites where org_id = ? and key = ?")
.get(orgId, EVAL_SUITE_KEY.INTEGRATION) as { id: string }).id;
evalRunId = sdlc.runEvalSuite({ orgId, suiteId });
});
const state = snapshot.load();
const evalRun = state.evalRuns.find((run) => run.id === evalRunId);
// Compiled runtime snapshots live in the database only - the renderer
// snapshot must not carry per-run compiled prompts.
const snapshotRecord = connection.db.prepare("select compiled_prompt from skill_runtime_snapshots limit 1")
.get() as { compiled_prompt: string } | undefined;
if (!evalRun) throw new Error("Integration eval run was not created.");
if (!snapshotRecord) throw new Error("Skill runtime snapshot was not created.");
expect(state.approvals.find((approval) => approval.id === approvalId)?.state).toBe(APPROVAL_STATE.APPROVED);
expect(state.approvalAssignments.some((assignment) => assignment.approvalId === approvalId)).toBe(true);
expect(snapshotRecord.compiled_prompt).toContain("Release Gate");
expect(evalRun).toMatchObject({ state: SDLC_RUN_STATE.PASSED, failedCount: 0 });
expect(state.operationalEvents.some((event) => event.signalKey === "skill_resolve_success")).toBe(true);
connection.close();
});
+1 -3
View File
@@ -35,7 +35,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, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93]);
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, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94]);
connection.close();
});
@@ -63,8 +63,6 @@ describe("domain services", () => {
expect(state.featureFlags.map((flag) => flag.key)).toContain("chaos_drills");
expect(state.sloTargets.map((target) => target.signalKey)).toContain("provider_request_success");
expect(state.chaosDrills.map((drill) => drill.scenarioKey)).toContain("approval_backlog_gate");
expect(state.sdlcReviewAgents.map((agent) => agent.key)).toContain("code_reviewer");
expect(state.evalSuites.map((suite) => suite.key)).toContain("contract");
expect(state.prBotGates.map((gate) => gate.key)).toContain("static_checks");
expect(state.chatSpaces.map((space) => space.name)).toContain("board");
expect(state.policyRules[0]?.action).toBe("task_create");
-14
View File
@@ -132,11 +132,6 @@ describe("migration service", () => {
create table operational_events(id text primary key, org_id text);
create table chaos_drills(id text primary key, org_id text);
create table chaos_drill_runs(id text primary key, org_id text, drill_id text);
create table sdlc_review_agents(id text primary key, org_id text);
create table sdlc_review_runs(id text primary key, org_id text, review_agent_id text);
create table eval_suites(id text primary key, org_id text);
create table eval_cases(id text primary key, org_id text, suite_id text);
create table eval_runs(id text primary key, org_id text, suite_id text);
create table pr_bot_gates(id text primary key, org_id text);
create table chat_spaces(id text primary key, org_id text);
create table chat_messages(id text primary key, org_id text, space_id text, thread_id text);
@@ -210,11 +205,6 @@ describe("migration service", () => {
insert into operational_events(id, org_id) values ('op-1', 'org-1');
insert into chaos_drills(id, org_id) values ('drill-1', 'org-1');
insert into chaos_drill_runs(id, org_id, drill_id) values ('drill-run-1', 'org-1', 'drill-1');
insert into sdlc_review_agents(id, org_id) values ('reviewer-1', 'org-1');
insert into sdlc_review_runs(id, org_id, review_agent_id) values ('review-run-1', 'org-1', 'reviewer-1');
insert into eval_suites(id, org_id) values ('suite-1', 'org-1');
insert into eval_cases(id, org_id, suite_id) values ('case-1', 'org-1', 'suite-1');
insert into eval_runs(id, org_id, suite_id) values ('eval-run-1', 'org-1', 'suite-1');
insert into pr_bot_gates(id, org_id) values ('gate-1', 'org-1');
insert into chat_threads(id, org_id, space_id, root_message_id) values ('thread-1', 'org-1', 'space-1', null);
insert into chat_messages(id, org_id, space_id, thread_id) values ('msg-1', 'org-1', 'space-1', 'thread-1');
@@ -282,8 +272,6 @@ describe("migration service", () => {
expect(body.tableCounts.hiring_policies).toBe(1);
expect(body.tableCounts.feature_flags).toBe(1);
expect(body.tableCounts.chaos_drill_runs).toBe(1);
expect(body.tableCounts.sdlc_review_runs).toBe(1);
expect(body.tableCounts.eval_cases).toBe(1);
expect(body.tableCounts.role_grants).toBe(1);
expect(body.tableCounts.skill_artifacts).toBe(1);
expect(body.tableCounts.chat_read_state).toBe(1);
@@ -312,8 +300,6 @@ describe("migration service", () => {
expect(body.idMaps.approval_assignments).toEqual(["assign-1"]);
expect(body.idMaps.operational_events).toEqual(["op-1"]);
expect(body.idMaps.chaos_drill_runs).toEqual(["drill-run-1"]);
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"]);
+10 -39
View File
@@ -6,7 +6,7 @@ import { DatabaseConnection } from "../../src/main/database/connection";
import { OrganizationService } from "../../src/main/services/organization-service";
import { SdlcService } from "../../src/main/services/sdlc-service";
import { SnapshotService } from "../../src/main/services/snapshot-service";
import { SDLC_REVIEW_TARGET_TYPE } from "../../src/shared/domain";
import { IPC_CHANNELS } from "../../src/shared/ipc";
function createConnection(): DatabaseConnection {
return new DatabaseConnection(join(tmpdir(), `agentcompany-new-sdlc-${randomUUID()}.db`));
@@ -22,65 +22,36 @@ function createOrganization(organization: OrganizationService): string {
}
describe("SDLC service", () => {
test("seeds review agents, eval suites, eval cases, and PR bot gates", () => {
test("offers no review or eval whose pass only counts configuration rows", () => {
const connection = createConnection();
const organization = new OrganizationService(connection.db);
const snapshot = new SnapshotService(connection.db);
connection.transaction(() => {
createOrganization(organization);
createOrganization(new OrganizationService(connection.db));
});
const state = snapshot.load();
expect(state.sdlcReviewAgents.map((agent) => agent.key).sort()).toEqual(["code_reviewer", "migration_reviewer", "policy_reviewer"]);
expect(state.evalSuites.map((suite) => suite.key).sort()).toEqual(["contract", "integration", "replay"]);
expect(state.evalCases).toHaveLength(6);
expect(state.prBotGates.map((gate) => gate.key).sort()).toEqual(["human_approval", "migration_diff", "policy_diff", "static_checks"]);
const tables = connection.db.prepare(`
select name from sqlite_master where type = 'table' and name in ('sdlc_review_agents', 'sdlc_review_runs', 'eval_suites', 'eval_cases', 'eval_runs')
`).all();
expect(tables).toEqual([]);
expect(Object.keys(IPC_CHANNELS).filter((name) => name === "runSdlcReview" || name === "runEvalSuite")).toEqual([]);
connection.close();
});
test("runs review agents against validated workspace targets", () => {
test("seeds PR bot gates and toggles them", () => {
const connection = createConnection();
const organization = new OrganizationService(connection.db);
const sdlc = new SdlcService(connection.db);
const snapshot = new SnapshotService(connection.db);
let orgId = "";
let reviewAgentId = "";
connection.transaction(() => {
orgId = createOrganization(organization);
reviewAgentId = (connection.db.prepare("select id from sdlc_review_agents where org_id = ? and key = ?")
.get(orgId, "code_reviewer") as { id: string }).id;
sdlc.runReview({ orgId, reviewAgentId, targetType: SDLC_REVIEW_TARGET_TYPE.WORKSPACE, targetRef: orgId });
});
const state = snapshot.load();
expect(state.sdlcReviewRuns[0]).toMatchObject({ orgId, reviewAgentId, targetType: SDLC_REVIEW_TARGET_TYPE.WORKSPACE, state: "passed" });
expect(state.auditEvents.some((event) => event.entityType === "sdlc_review_run" && event.action === "created")).toBe(true);
connection.close();
});
test("runs contract eval suites and toggles PR bot gates", () => {
const connection = createConnection();
const organization = new OrganizationService(connection.db);
const sdlc = new SdlcService(connection.db);
const snapshot = new SnapshotService(connection.db);
let orgId = "";
let suiteId = "";
let gateId = "";
connection.transaction(() => {
orgId = createOrganization(organization);
suiteId = (connection.db.prepare("select id from eval_suites where org_id = ? and key = ?")
.get(orgId, "contract") as { id: string }).id;
gateId = (connection.db.prepare("select id from pr_bot_gates where org_id = ? and key = ?")
.get(orgId, "static_checks") as { id: string }).id;
sdlc.runEvalSuite({ orgId, suiteId });
sdlc.setPrBotGate({ orgId, gateId, enabled: false });
});
const state = snapshot.load();
expect(state.evalRuns[0]).toMatchObject({ orgId, suiteId, state: "passed", failedCount: 0 });
expect(state.prBotGates.map((gate) => gate.key).sort()).toEqual(["human_approval", "migration_diff", "policy_diff", "static_checks"]);
expect(state.prBotGates.find((gate) => gate.id === gateId)?.enabled).toBe(false);
expect(state.auditEvents.some((event) => event.entityType === "pr_bot_gate" && event.action === "updated")).toBe(true);
connection.close();