1import { assert, describe, it } from "@effect/vitest";
2
3import { buildRuntimeInstructions } from "./runtimeInstructions.ts";
4
5describe("buildRuntimeInstructions", () => {
6 it("leaves PR linking to a session that already carries it, and keeps runtime identity", () => {
7 const instructions = buildRuntimeInstructions({
8 harness: "Antigravity",
9 model: "gemini-3.8-flash",
10 pullRequestLinking: false,
11 });
12
13 assert.include(instructions, "through the Antigravity harness, as gemini-3.8-flash.");
14 assert.notInclude(instructions, "<pull_request_linking>");
15 });
16
17 it("links PRs the agent creates, takes over, or pushes to, and no others", () => {
18 const instructions = buildRuntimeInstructions({ harness: "Codex" });
19
20 assert.include(instructions, "Link each PR you create, take over, or push to");
21 assert.include(instructions, "every stack layer");
22 assert.include(instructions, "Skip PRs you only read or review");
23 assert.include(instructions, "If linking fails, say so.");
24 assert.notInclude(instructions, "git log -1");
25 assert.notInclude(instructions, "work on");
26 // Listing linked PRs as an end-of-work check found nothing to add in audited threads.
27 assert.notInclude(instructions, "list_thread_pull_requests");
28 });
29
30 it("waits on a PR only with the watch, never with a poll loop", () => {
31 const instructions = buildRuntimeInstructions({ harness: "Codex" });
32
33 assert.notInclude(instructions, "Creation, pending checks, or a merge ask alone is not enough");
34 assert.include(instructions, "Links and watches persist across pushes.");
35 // The wake message itself carries the do-not-re-watch rule.
36 assert.notInclude(instructions, "On a wake");
37 assert.include(
38 instructions,
39 "Call watch_pull_request when asked to monitor or babysit, or when work you were asked to do, such as a merge, still waits on checks or reviews, even after an earlier unwatch",
40 );
41 assert.notInclude(instructions, "merge it now");
42 assert.include(instructions, "Otherwise act now or hand back.");
43 assert.include(instructions, "then watch and end your turn");
44 assert.include(instructions, "never watch, even if the brief says babysit");
45 assert.include(
46 instructions,
47 "After PR work, a child's last line is: PR <full URL>, head <SHA>, checks and reviews <state>.",
48 );
49 assert.include(
50 instructions,
51 "For PR waits, no sleep, loops, gh --watch, Monitor or ScheduleWakeup.",
52 );
53 assert.include(instructions, "call unwatch_pull_request");
54 });
55});