Files
AgentCompany/tests/integration/autonomous-chain/role-detection.spec.ts
T
ZacharyZhang-NY 0f1b7c0b33 test(integration): split autonomous-chain.spec.ts into per-scenario files
The original tests/integration/autonomous-chain.spec.ts was ~1400 lines
and 50 KB, covering 19 describe blocks across 10 orthogonal scenarios.
Physically extract each describe (or closely related group) into its
own file inside tests/integration/autonomous-chain/ so each file stays
under the project's 500-line ceiling and failures point at the
scenario that regressed.

Shared beforeEach / afterEach / createAgent / buildCtx helpers move to
autonomous-chain/shared-setup.ts, which exposes installSharedSetup() as
a factory that each spec calls at module load. The tests themselves
are moved byte-for-byte; only module-level references (`db`,
`companyId`, `workspaceId`, `tempDirs`) are rewritten to go through
the shared handle. No assertions, it() calls, or behavior are changed.

Split layout:
  role-detection.spec.ts        — Step 1: CEO role detection
  ceo-phased-prompts.spec.ts    — Step 2: phased prompts + approvals
  wakeup-queue.spec.ts          — Step 3: deferred wake queue
  approval-decisions.spec.ts    — Step 4: hire approval decisions
  task-propagation.spec.ts      — Step 5: task/comment wake propagation
  run-failure.spec.ts           — Step 6: run failure escalation
  crash-recovery.spec.ts        — Step 7: worker crash recovery
  wake-reason.spec.ts           — Step 8: wake reason injection
  e2e-flows.spec.ts             — full-chain + review-fix regressions
  automation-messages.spec.ts   — automation/messages/assignment/workflows

Test count stays at 363 passing; typecheck stays at 156 errors.
2026-04-16 23:34:54 -04:00

66 lines
2.3 KiB
TypeScript

/**
* Step 1: CEO role detection fix.
* Physically extracted from autonomous-chain.spec.ts without behavior changes.
*/
import { describe, expect, it } from "vitest";
import { buildSystemPrompt } from "../../../src/main/prompt-builder";
import { installSharedSetup } from "./shared-setup";
const shared = installSharedSetup();
const { createAgent, buildCtx } = shared;
describe("Step 1: CEO role detection", () => {
it("identifies CEO when chainOfCommand is empty, even with no direct reports", () => {
const ceoId = createAgent({ name: "CEO", role: "CEO" });
const ctx = buildCtx({
agentId: ceoId,
directReports: [], // no reports yet!
chainOfCommand: [], // top-level
});
const prompt = buildSystemPrompt(ctx);
// CEO should NOT get IC instructions
expect(prompt).not.toContain("Individual Contributor");
// CEO should get executive instructions (Phase 0: Team Building)
expect(prompt).toContain("CEO");
expect(prompt).toContain("Team Building");
});
it("identifies manager when has reports and has chain of command", () => {
const ceoId = createAgent({ name: "CEO", role: "CEO" });
const managerId = createAgent({ name: "CTO", role: "CTO", reportsTo: ceoId });
const ceo = shared.db.getAgent(ceoId);
const icId = createAgent({ name: "IC", role: "Engineer", reportsTo: managerId });
const ic = shared.db.getAgent(icId);
const ctx = buildCtx({
agentId: managerId,
directReports: [ic],
chainOfCommand: [ceo], // reports to CEO
});
const prompt = buildSystemPrompt(ctx);
expect(prompt).toContain("Operating Instructions (Manager)");
expect(prompt).not.toContain("Individual Contributor");
expect(prompt).not.toContain("Executive / CEO");
});
it("identifies IC when has chain of command and no direct reports", () => {
const ceoId = createAgent({ name: "CEO", role: "CEO" });
const ceo = shared.db.getAgent(ceoId);
const icId = createAgent({ name: "Dev", role: "Engineer", reportsTo: ceoId });
const ctx = buildCtx({
agentId: icId,
directReports: [],
chainOfCommand: [ceo],
});
const prompt = buildSystemPrompt(ctx);
expect(prompt).toContain("Individual Contributor");
expect(prompt).not.toContain("Operating Instructions (Manager)");
});
});