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

+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();