forgedock 1.53.0 → 1.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +51 -0
- package/README.md +8 -2
- package/bin/auth/app-manifest.mjs +89 -0
- package/bin/auth/app-manifest.test.mjs +75 -0
- package/bin/auth/app-token.mjs +258 -0
- package/bin/auth/app-token.test.mjs +240 -0
- package/bin/brand.mjs +7 -0
- package/bin/config-history.mjs +151 -0
- package/bin/config-schema.mjs +115 -0
- package/bin/demo.mjs +65 -11
- package/bin/engine/outcome-codes.mjs +6 -3
- package/bin/engine/telemetry-seam.mjs +8 -2
- package/bin/engine/telemetry-seam.test.mjs +17 -0
- package/bin/engine-cli.mjs +57 -20
- package/bin/first-run.mjs +122 -0
- package/bin/forgedock.mjs +128 -146
- package/bin/help-text.mjs +144 -0
- package/bin/hooks/pre-tool-use.mjs +7 -0
- package/bin/journey.mjs +82 -83
- package/bin/lean/acceptance.mjs +313 -0
- package/bin/lean/acceptance.test.mjs +215 -0
- package/bin/lean/activation.mjs +18 -0
- package/bin/lean/activation.test.mjs +23 -1
- package/bin/lean/batch-health.mjs +74 -1
- package/bin/lean/batch-health.test.mjs +54 -1
- package/bin/lean/batch.test.mjs +11 -9
- package/bin/lean/branchlock.mjs +54 -0
- package/bin/lean/branchlock.test.mjs +49 -0
- package/bin/lean/ceiling.mjs +72 -0
- package/bin/lean/ceiling.test.mjs +54 -0
- package/bin/lean/ci-budget.mjs +366 -0
- package/bin/lean/ci-budget.test.mjs +167 -0
- package/bin/lean/conformance.e2e.test.mjs +7 -0
- package/bin/lean/conformance.mjs +77 -19
- package/bin/lean/conformance.test.mjs +129 -3
- package/bin/lean/context.mjs +35 -6
- package/bin/lean/context.test.mjs +27 -1
- package/bin/lean/depcache.mjs +25 -1
- package/bin/lean/depcache.test.mjs +26 -0
- package/bin/lean/e2e.mjs +18 -2
- package/bin/lean/e2e.test.mjs +26 -1
- package/bin/lean/effects.mjs +40 -11
- package/bin/lean/execution.test.mjs +24 -0
- package/bin/lean/facts.mjs +3 -3
- package/bin/lean/facts.test.mjs +5 -0
- package/bin/lean/fixround.mjs +14 -0
- package/bin/lean/fixround.test.mjs +25 -2
- package/bin/lean/gh-assoc.test.mjs +2 -1
- package/bin/lean/integration.mjs +100 -9
- package/bin/lean/integration.test.mjs +98 -0
- package/bin/lean/issuewatch-parity.mjs +64 -0
- package/bin/lean/issuewatch-parity.test.mjs +127 -0
- package/bin/lean/issuewatch-release.test.mjs +1 -1
- package/bin/lean/issuewatch.mjs +34 -5
- package/bin/lean/issuewatch.test.mjs +3 -2
- package/bin/lean/lean.mjs +316 -74
- package/bin/lean/lean.test.mjs +397 -24
- package/bin/lean/mechfix.mjs +136 -0
- package/bin/lean/mechfix.test.mjs +95 -0
- package/bin/lean/orchestrate.mjs +20 -2
- package/bin/lean/phaseledger.mjs +47 -5
- package/bin/lean/phaseledger.test.mjs +30 -1
- package/bin/lean/precheck.mjs +23 -4
- package/bin/lean/precheck.test.mjs +14 -1
- package/bin/lean/prereq.mjs +28 -0
- package/bin/lean/prereq.test.mjs +20 -0
- package/bin/lean/probe.mjs +4 -2
- package/bin/lean/prodparity.mjs +52 -0
- package/bin/lean/prodparity.test.mjs +67 -0
- package/bin/lean/prompts.mjs +69 -12
- package/bin/lean/recovery.test.mjs +1 -1
- package/bin/lean/release-io.test.mjs +42 -0
- package/bin/lean/release-postmerge.mjs +6 -0
- package/bin/lean/release-preflight.mjs +58 -0
- package/bin/lean/release-preflight.test.mjs +114 -0
- package/bin/lean/release-rehearsal.mjs +8 -7
- package/bin/lean/release-review.mjs +67 -11
- package/bin/lean/release-review.test.mjs +128 -1
- package/bin/lean/release-snapshot.mjs +188 -0
- package/bin/lean/release-snapshot.test.mjs +190 -0
- package/bin/lean/release.mjs +87 -13
- package/bin/lean/release.test.mjs +104 -0
- package/bin/lean/render.mjs +1 -1
- package/bin/lean/replan.mjs +184 -0
- package/bin/lean/replan.test.mjs +110 -0
- package/bin/lean/resume.mjs +9 -7
- package/bin/lean/resume.test.mjs +16 -0
- package/bin/lean/schedd.mjs +34 -1
- package/bin/lean/schedd.test.mjs +21 -1
- package/bin/lean/selfreview.mjs +94 -0
- package/bin/lean/selfreview.test.mjs +58 -1
- package/bin/lean/selftest-gate.mjs +22 -0
- package/bin/lean/selftest-gate.test.mjs +18 -1
- package/bin/lean/selftest-journey.mjs +234 -0
- package/bin/lean/selftest-journey.test.mjs +130 -0
- package/bin/lean/selftest-live.mjs +2 -1
- package/bin/lean/seqlease.mjs +35 -1
- package/bin/lean/seqlease.test.mjs +15 -0
- package/bin/lean/seqreserve.e2e.test.mjs +135 -0
- package/bin/lean/seqreserve.mjs +73 -0
- package/bin/lean/seqreserve.test.mjs +134 -0
- package/bin/lean/sequence.mjs +35 -6
- package/bin/lean/seqversioned.mjs +147 -0
- package/bin/lean/stagestamp.mjs +28 -0
- package/bin/lean/stagestamp.test.mjs +32 -0
- package/bin/lean/surfaces.mjs +75 -0
- package/bin/lean/surfaces.test.mjs +59 -0
- package/bin/lean/toolplace.mjs +28 -0
- package/bin/lean/toolplace.test.mjs +24 -0
- package/bin/lean/toolstats.mjs +3 -1
- package/bin/lean/toolstats.test.mjs +11 -0
- package/bin/lean/validatebest.mjs +28 -0
- package/bin/lean/validatebest.test.mjs +27 -0
- package/bin/pool/agent.mjs +9 -0
- package/bin/pool/docker.mjs +5 -0
- package/bin/pool/router.mjs +8 -4
- package/bin/prereqs.mjs +111 -0
- package/bin/replay-timelapse.mjs +149 -0
- package/bin/review-staging.mjs +100 -16
- package/bin/review-staging.test.mjs +18 -0
- package/bin/runner.mjs +49 -7
- package/bin/splash-install.mjs +157 -0
- package/bin/stats/aggregate.mjs +8 -1
- package/bin/stats/conformance-outcomes.mjs +100 -19
- package/bin/stats/conformance-outcomes.test.mjs +87 -1
- package/bin/stats/depth.mjs +88 -31
- package/bin/stats/depth.test.mjs +63 -38
- package/bin/stats/efficiency.mjs +26 -5
- package/bin/stats/efficiency.test.mjs +45 -1
- package/bin/stats/first-review.mjs +77 -0
- package/bin/stats/first-review.test.mjs +36 -0
- package/bin/stats/firstmerge.mjs +40 -0
- package/bin/stats/firstmerge.test.mjs +41 -0
- package/bin/stats/github-source.mjs +51 -13
- package/bin/stats/index.mjs +91 -15
- package/bin/stats/local-source.mjs +1 -0
- package/bin/stats/origin.mjs +80 -0
- package/bin/stats/origin.test.mjs +58 -0
- package/bin/stats/render.mjs +3 -1
- package/bin/stats/scoreboard.mjs +137 -0
- package/bin/stats/scoreboard.test.mjs +87 -0
- package/bin/stats/stats.test.mjs +80 -0
- package/bin/tui.mjs +3 -2
- package/commands/bootstrap.md +15 -14
- package/commands/deploy-pr.md +18 -3
- package/commands/forge-stats.md +1 -1
- package/commands/forgedock-ci-setup.md +28 -0
- package/commands/forgedock-init.md +4 -5
- package/commands/issue.md +2 -0
- package/commands/milestone.md +9 -1
- package/commands/replay.md +2 -0
- package/commands/review-pr-staging.md +4 -1
- package/commands/work-on/close.md +8 -0
- package/docs/CI.md +1 -1
- package/docs/CONFIG.md +105 -10
- package/docs/ISSUE-WATCH.md +23 -0
- package/docs/OUTCOME-CODES.md +1 -0
- package/docs/REPLAY.md +9 -0
- package/docs/SELFTEST.md +11 -0
- package/docs/STATS.md +19 -2
- package/docs/eval/README.md +6 -0
- package/docs/eval/adversarial-bench.md +68 -0
- package/docs/eval/corpus/adversarial-v1.json +285 -0
- package/docs/eval/feature-bench.md +42 -0
- package/docs/eval/feature-specs/crud-auth/journeys/notes-crud-isolated.mjs +21 -0
- package/docs/eval/feature-specs/crud-auth/journeys/register-login.mjs +12 -0
- package/docs/eval/feature-specs/crud-auth/spec.md +15 -0
- package/docs/site/start-a-new-project.md +2 -1
- package/package.json +5 -2
- package/plugins/forgedock-splash/.claude-plugin/plugin.json +10 -0
- package/plugins/forgedock-splash/README.md +27 -0
- package/plugins/forgedock-splash/hooks/hooks.json +1 -0
- package/plugins/forgedock-splash/hooks/register.tsx +74 -0
- package/plugins/forgedock-splash/hooks/scene.ts +222 -0
- package/plugins/forgedock-splash/types/index.d.ts +10 -0
- package/scripts/bench-adversarial.mjs +216 -0
- package/scripts/bench-feature.mjs +170 -0
- package/scripts/bench-lightlane.mjs +2 -2
- package/scripts/bootstrap-create.mjs +2 -2
- package/scripts/bootstrap-validate.mjs +35 -2
- package/scripts/check-spec-size.sh +4 -3
- package/scripts/check-spec-size.test.sh +3 -0
- package/scripts/plan-validate-live.mjs +40 -6
- package/scripts/review-pr-staging-scope.test.sh +1 -1
- package/scripts/review-staging-post.sh +23 -0
- package/scripts/review-staging-post.test.sh +8 -0
package/bin/lean/lean.test.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { parseExperiment, assignArm } from "../experiment.mjs";
|
|
|
6
6
|
import assert from "node:assert/strict";
|
|
7
7
|
import { tmpDir } from "../tests/_tmp.mjs";
|
|
8
8
|
import { execFileSync } from "node:child_process";
|
|
9
|
-
import { writeFileSync, existsSync, readFileSync, mkdirSync, symlinkSync, readdirSync } from "node:fs";
|
|
9
|
+
import { writeFileSync, existsSync, readFileSync, mkdirSync, symlinkSync, readdirSync, chmodSync } from "node:fs";
|
|
10
10
|
import { join } from "node:path";
|
|
11
11
|
import { runCore, contractHash, isProtectedLaneBranch, classifyBlock } from "./lean.mjs";
|
|
12
12
|
import { parseFactsComment, normaliseFacts, renderFactsRecord, FACTS_MARKER } from "./facts.mjs";
|
|
@@ -22,10 +22,10 @@ import { mapRecord } from "../engine/telemetry-seam.mjs";
|
|
|
22
22
|
import { readLog as readRepoLog } from "../engine/runlog.mjs";
|
|
23
23
|
// #4432: the run log is keyed by repo + issue; every lane in this file runs in repo o/r.
|
|
24
24
|
const readLog = (dir, issue, repo = "o/r") => readRepoLog(dir, issue, { repo });
|
|
25
|
-
import { makeRunTmp, wrapLaneLimits, laneCapNotice, systemdRunAvailable, makeLeanRunner, requiredChecksFor, procsInDir, makeLeanIo, makeGhCache } from "./effects.mjs";
|
|
25
|
+
import { makeRunTmp, wrapLaneLimits, laneCapNotice, systemdRunAvailable, makeLeanRunner, requiredChecksFor, requiredChecksRead, procsInDir, makeLeanIo, makeGhCache } from "./effects.mjs";
|
|
26
26
|
import { retrying, ghCacheRetry, refreshAuthOnce, GH_AUTH_RE, PUSH_TRANSIENT_RE } from "./retry.mjs";
|
|
27
27
|
import { checkAdmission, hostParallelism } from "./admission.mjs";
|
|
28
|
-
import { OUTCOME_CODES, ENV_VALIDATE_TIMEOUT, classifyNeedsHuman } from "../engine/outcome-codes.mjs";
|
|
28
|
+
import { OUTCOME_CODES, ENV_VALIDATE_TIMEOUT, ENV_VALIDATE_PLACEMENT, classifyNeedsHuman } from "../engine/outcome-codes.mjs";
|
|
29
29
|
import * as refactorMod from "./refactor.mjs";
|
|
30
30
|
import { readAdmission, readConformanceMode, readReviewIncomplete, readEnvConfig, readContextPack } from "../engine-cli.mjs";
|
|
31
31
|
import { prepareToolchain } from "./toolchain.mjs";
|
|
@@ -39,6 +39,8 @@ const approxTokens = (s) => rawTokens(String(s).replaceAll(INSTALL_ROOT, "<root>
|
|
|
39
39
|
process.env.FORGEDOCK_SCHED_DIR = tmpDir("lean-sched-");
|
|
40
40
|
|
|
41
41
|
const WT = "/wt/lean-7";
|
|
42
|
+
/** #5333: the engine appends the stage-stamp rule to every builder prompt; strip it to compare against the bare template. */
|
|
43
|
+
const unstamp = (s) => String(s).replace(/\n\nStage notes: make the first line[^\n]*/, "");
|
|
42
44
|
const STAGE_MD = {
|
|
43
45
|
investigation: "**Verdict**: CONFIRMED\n**Confidence**: high\n**Severity**: medium\n**Task Type**: bug\n\n### What Was Claimed\nfoo breaks\n\n### What We Found\n- src/foo.js:3 derefs null\n\n### Root Cause\nfoo derefs null at src/foo.js:3\n\n### Affected Files\n- src/foo.js: add guard\n\n### Sibling Sweep\n- src/bar.js:8 same guard\n\n### History\nintroduced in abc123\n\n### Recommendation\nguard null\n\n### Related Issues\nnone",
|
|
44
46
|
plan: "### Approach\nguard null in foo\n\n### Deliverables\n| File | Change | Why |\n| --- | --- | --- |\n| src/foo.js | add guard | avoid crash |\n\n### Acceptance Criteria\n- [ ] foo handles null\n\n### Implementation Order\n1. guard\n\n### Out of Scope\nrefactor: later\n\n### Risk Assessment\n| Risk | Severity | Mitigation |\n| --- | --- | --- |\n| none | low | test |",
|
|
@@ -645,6 +647,36 @@ describe("core work-on", () => {
|
|
|
645
647
|
assert.equal(classifyBlock({ summary: "V1 needs the prod key", block: { kind: "human", why: "credentials" } }, 1).kind, "human");
|
|
646
648
|
});
|
|
647
649
|
|
|
650
|
+
it("#5342 classifyBlock: design-invalidated needs a decision and a why; the other kinds are unchanged", () => {
|
|
651
|
+
const ok = classifyBlock({ block: { kind: "design-invalidated", decision: "replay_store is optional", why: "the core loop needs it", epic: "#5", paths: ["src/a.ts"] } }, 7);
|
|
652
|
+
assert.deepEqual([ok.kind, ok.epic, ok.paths], ["design-invalidated", 5, ["src/a.ts"]]);
|
|
653
|
+
assert.equal(classifyBlock({ block: { kind: "design-invalidated", decision: "x" } }, 7).kind, "untyped");
|
|
654
|
+
assert.equal(classifyBlock({ block: { kind: "dependency", issues: [3] } }, 7).kind, "dependency");
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
it("#5342 a design-invalidated block files one amendment, holds the affected open siblings and the lane behind it, and requeues as dependency-open", async () => {
|
|
658
|
+
const w = depWorld({ changed: [], result: { status: "blocked", summary: "the store design is wrong", block: { kind: "design-invalidated", decision: "replay_store is optional", why: "core loop needs it", epic: 5 } } }, {});
|
|
659
|
+
const gh = w.io.gh;
|
|
660
|
+
const kid = (n) => ({ number: n, body: `**Parent**: #5\n`, labels: [], author: { login: "o" } });
|
|
661
|
+
w.io.gh = async (a) => {
|
|
662
|
+
if (a[0] === "issue" && a[1] === "list" && a.includes("--help")) return "JSON FIELDS\n author, body, labels, number\n";
|
|
663
|
+
if (a[0] === "issue" && a[1] === "list") return JSON.stringify([kid(8), kid(9), kid(7)]);
|
|
664
|
+
if (a[0] === "api" && /issues\?state=open/.test(a[1])) return "7\tOWNER\n8\tOWNER\n9\tOWNER\n";
|
|
665
|
+
if (a[0] === "issue" && a[1] === "view" && /^[789]$/.test(a[2]) && a.includes("body")) return JSON.stringify({ body: `**Parent**: #5\n` });
|
|
666
|
+
return gh(a);
|
|
667
|
+
};
|
|
668
|
+
const r = await run(w);
|
|
669
|
+
assert.equal(r.terminalReason, "dependency-open");
|
|
670
|
+
assert.equal(r.code, "design.invalidated");
|
|
671
|
+
assert.equal(w.created.length, 1);
|
|
672
|
+
assert.match(w.created[0][w.created[0].indexOf("--title") + 1], /^spike amendment: replay_store is optional/);
|
|
673
|
+
const held = w.edits.filter((e) => e[1] === "edit" && e.includes("--body")).map((e) => [e[2], e[e.indexOf("--body") + 1]]);
|
|
674
|
+
assert.deepEqual(held.map(([n]) => n).sort(), ["7", "8", "9"]);
|
|
675
|
+
for (const [, body] of held) assert.match(body, /^\*\*Depends on\*\*: #201$/m);
|
|
676
|
+
assert.ok(w.comments.some((c) => /FORGE:REPLAN/.test(c) && /#201/.test(c)));
|
|
677
|
+
noNeedsHuman(w);
|
|
678
|
+
});
|
|
679
|
+
|
|
648
680
|
it("#4385 split siblings that declare a shared hub file are serialised (chained, no duplicate transitive edge); disjoint or undeclared files stay parallel", () => {
|
|
649
681
|
const hub = ["src/domain/index.ts", "./src/domain/events.ts"];
|
|
650
682
|
const BIG = { files: 40, lines: 2000 }; // #4396: shared or undeclared files are admitted only over the size budget
|
|
@@ -822,6 +854,16 @@ describe("core work-on", () => {
|
|
|
822
854
|
assert.equal((await run(world({ contract }), { ...remote, hostCaps: { hostCapabilities: ["sops"] } })).terminalReason, "merged");
|
|
823
855
|
});
|
|
824
856
|
|
|
857
|
+
it("#5331 a remote lane whose sandbox lacks a validate tool ends env.tool_missing before building; local placement is unchanged", async () => {
|
|
858
|
+
const contract = { ...CONTRACT, validate: [...CONTRACT.validate, { id: "V2", command: "promtool test rules r.yml" }] };
|
|
859
|
+
const remote = { placement: { where: "remote", reason: "mode remote" } };
|
|
860
|
+
const w = world({ contract }); w.io.probeCommand = async (a) => ({ rc: /promtool/.test(JSON.stringify(a)) ? 127 : 0, output: "" });
|
|
861
|
+
const r = await run(w, { dir: tmpDir("lean-5331-"), ...remote });
|
|
862
|
+
assert.equal(r.code, "env.tool_missing");
|
|
863
|
+
const l = world({ contract }); l.io.probeCommand = async (a) => ({ rc: /promtool/.test(JSON.stringify(a)) ? 127 : 0, output: "" });
|
|
864
|
+
assert.notEqual((await run(l, { placement: { where: "local", reason: "x" } })).code, "env.tool_missing");
|
|
865
|
+
});
|
|
866
|
+
|
|
825
867
|
it("#4778 a relayed host capability does not end the remote lane before building; a failed relay still recovers locally", async () => {
|
|
826
868
|
const contract = { ...CONTRACT, validate: [...CONTRACT.validate, { id: "V2", command: "promtool test rules r.yml" }] };
|
|
827
869
|
const remote = { placement: { where: "remote", reason: "mode remote" }, hostCaps: { hostCapabilities: ["promtool"] } };
|
|
@@ -1504,6 +1546,22 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
1504
1546
|
assert.ok(ran[0].env && typeof ran[0].env === "object", "the rerun gets the lane env");
|
|
1505
1547
|
}
|
|
1506
1548
|
});
|
|
1549
|
+
it("#5371 a remote lane whose frozen validate fails ends env.validate_placement (output tail kept); the local recovery lane keeps the real failure terminal", async () => {
|
|
1550
|
+
const v = [{ id: "V1", command: "node --test test/foo.test.js", exit: 1 }];
|
|
1551
|
+
const rerun = async () => ({ rc: 1, output: "1 failed\nTOKEN=abcd1234secretvalue\nassertion x" });
|
|
1552
|
+
const w = world({ validation: v }); w.io.runCommand = rerun;
|
|
1553
|
+
const r = await run(w, { conformance: "enforce", placement: { where: "remote", reason: "mode remote" } });
|
|
1554
|
+
assert.equal(r.code, ENV_VALIDATE_PLACEMENT); assert.equal(classifyNeedsHuman(r), "recoverable"); assert.equal(w.merges.length, 0);
|
|
1555
|
+
assert.equal(builders(w).length, 2, "no builder resume");
|
|
1556
|
+
assert.match(nhBody(w), /assertion x/); assert.doesNotMatch(nhBody(w), /abcd1234secretvalue/);
|
|
1557
|
+
const l = world({ validation: v }); l.io.runCommand = rerun;
|
|
1558
|
+
const lr = await run(l, { conformance: "enforce", placement: { where: "local", reason: "x" } });
|
|
1559
|
+
assert.notEqual(lr.code, ENV_VALIDATE_PLACEMENT);
|
|
1560
|
+
const rec = world({ validation: v }); rec.io.runCommand = rerun;
|
|
1561
|
+
assert.notEqual((await run(rec, { conformance: "enforce", placement: { where: "local", reason: "x" }, recover: { code: ENV_VALIDATE_PLACEMENT, attempt: 1, final: true } })).code, ENV_VALIDATE_PLACEMENT);
|
|
1562
|
+
const ok = world({ validation: v }); ok.io.runCommand = async () => ({ rc: 0, output: "" });
|
|
1563
|
+
assert.equal((await run(ok, { conformance: "enforce", placement: { where: "local", reason: "x" }, recover: { code: ENV_VALIDATE_PLACEMENT, attempt: 1, final: true } })).terminalReason, "merged");
|
|
1564
|
+
});
|
|
1507
1565
|
it("#4906 a validate rerun that times out (rc 124) ends env.validate_timeout: recoverable, no builder resume, never conformance.unimplemented", async () => {
|
|
1508
1566
|
const v = [{ id: "V1", command: "node --test test/foo.test.js", exit: 124 }];
|
|
1509
1567
|
for (const conformance of ["shadow", "enforce"]) {
|
|
@@ -1988,9 +2046,9 @@ describe("hotspot prevention (forge#4195): plan facts, build rule, unexempted gr
|
|
|
1988
2046
|
assert.equal(hotspotBuildRule(facts([], { file_lines: 1000, growth_lines: 50 })).trim(), "Don't grow a file over 1000 lines by more than 50 lines. Put new code next to it.");
|
|
1989
2047
|
assert.equal(hotspotBuildRule(null), ""); assert.equal(hotspotBuildRule(facts([], { enabled: false })), "");
|
|
1990
2048
|
const plan = builderPlanPrompt(7) + hotspotPlanNote(facts([HOT, { ...HOT, path: "a/b.py" }, { ...HOT, path: "c/d.py" }]));
|
|
1991
|
-
// 1850: #4404 (verify out_of_band) and #4396 (split size rule) grew the plan prompt to ~1803 tokens on CI paths; 1900: #4589 (check timeout is not a block, one block-rule line). 2050: #4724 (deferred-row bucket rule).
|
|
1992
|
-
assert.ok(approxTokens(plan) <=
|
|
1993
|
-
assert.ok(approxTokens(builderImplementPrompt() + hotspotBuildRule(facts([]))) <=
|
|
2049
|
+
// 1850: #4404 (verify out_of_band) and #4396 (split size rule) grew the plan prompt to ~1803 tokens on CI paths; 1900: #4589 (check timeout is not a block, one block-rule line). 2050: #4724 (deferred-row bucket rule). 1675 (hotspot case): #5284 (rubric prod_parity clause). 2375/1825: #5345 (self-check and pitfall lines).
|
|
2050
|
+
assert.ok(approxTokens(plan) <= 2425, `plan prompt with hotspots is ${approxTokens(plan)} tokens`);
|
|
2051
|
+
assert.ok(approxTokens(builderImplementPrompt() + hotspotBuildRule(facts([]))) <= 1875, `implement prompt with the hotspot rule is ${approxTokens(builderImplementPrompt() + hotspotBuildRule(facts([])))} of 1675 tokens`); // 1600: #4591 (never hand-name migration files) and #4596 (i18n translate rule), one line each; 1650: #4726 (e2e rule)
|
|
1994
2052
|
});
|
|
1995
2053
|
|
|
1996
2054
|
it("#4519 generated_paths: both prompts name the globs (even with the gate off), and an amendment adding one blocks", async () => {
|
|
@@ -2093,7 +2151,7 @@ describe("bug lanes freeze a red-green repro_test (#4271)", () => {
|
|
|
2093
2151
|
const prev = process.env.FORGE_HOST_PARALLELISM; process.env.FORGE_HOST_PARALLELISM = "3";
|
|
2094
2152
|
try { assert.equal((await run(w, { envSetup: "make setup", precheck: { commands: ["npm run lint"] } })).terminalReason, "merged"); }
|
|
2095
2153
|
finally { if (prev === undefined) delete process.env.FORGE_HOST_PARALLELISM; else process.env.FORGE_HOST_PARALLELISM = prev; }
|
|
2096
|
-
const lane = { UV_CACHE_DIR: "/c/uv", TMPDIR: w.envs[0].TMPDIR, FORGE_HOST_PARALLELISM: "3", PATH: "/rt/toolchain/bin:/usr/bin" };
|
|
2154
|
+
const lane = { UV_CACHE_DIR: "/c/uv", TMPDIR: w.envs[0].TMPDIR, FORGE_HOST_PARALLELISM: "3", FORGE_LANE_WORKTREE: "1", PATH: "/rt/toolchain/bin:/usr/bin" };
|
|
2097
2155
|
assert.match(lane.TMPDIR, /\/runs\/7-/, "the builder ran with the run TMPDIR");
|
|
2098
2156
|
assert.deepEqual(w.rgCalls.map((x) => x.env), [lane], "red-green gets the lane env, not the daemon's");
|
|
2099
2157
|
assert.deepEqual(ran.map((a) => [a.command, a.env]), [["npm run lint", lane], ["node --test test/foo.test.js", lane]]);
|
|
@@ -2395,7 +2453,8 @@ describe("comment templates", () => {
|
|
|
2395
2453
|
assert.equal((await run(w)).terminalReason, "merged");
|
|
2396
2454
|
const f = parseFactsComment(w.comments.find((c) => markerOf(c) === "FORGE:FACTS"));
|
|
2397
2455
|
assert.deepEqual(f.rejected, [{ approach: "detection-only guard", why: "hides the cause" }]);
|
|
2398
|
-
assert.deepEqual(f.baselines,
|
|
2456
|
+
assert.equal(f.baselines.length, 1); assert.deepEqual({ ...f.baselines[0], head: undefined }, { command: "node --test test/foo.test.js", exit: 0, head: undefined }); // #5331: the baseline also records the head it ran on
|
|
2457
|
+
assert.match(f.baselines[0].head, /^[0-9a-f]{7,40}$/);
|
|
2399
2458
|
assert.ok(f.files.length > 0 && !f.files.some((x) => x.startsWith(".forge-lean/")), JSON.stringify(f.files));
|
|
2400
2459
|
assert.ok(!scopeText({ title: "t", body: "b" }, [{ body: w.comments.find((c) => markerOf(c) === "FORGE:FACTS") }]).includes("detection-only"));
|
|
2401
2460
|
});
|
|
@@ -2412,7 +2471,7 @@ describe("comment templates", () => {
|
|
|
2412
2471
|
});
|
|
2413
2472
|
|
|
2414
2473
|
it("live posting: stage notes appear while the builder session is still running", async () => {
|
|
2415
|
-
const until = async (wd, marker) => { for (let i = 0; i <
|
|
2474
|
+
const until = async (wd, marker) => { for (let i = 0; i < 1000 && !wd.comments.some((c) => c.includes(`<!-- ${marker} -->`)); i++) await new Promise((r) => setTimeout(r, 10)); return wd.comments.map(markerOf); };
|
|
2416
2475
|
const w = world({ builder: async (wd, put, kind) => {
|
|
2417
2476
|
wd.liveSeen ??= {};
|
|
2418
2477
|
if (kind === "plan") {
|
|
@@ -2448,8 +2507,8 @@ describe("comment templates", () => {
|
|
|
2448
2507
|
|
|
2449
2508
|
it("plan and implement prompts carry the stage templates and the contract schema within budget", () => {
|
|
2450
2509
|
const plan = builderPlanPrompt(7), impl = builderImplementPrompt();
|
|
2451
|
-
assert.ok(approxTokens(plan) <=
|
|
2452
|
-
assert.ok(approxTokens(impl) <=
|
|
2510
|
+
assert.ok(approxTokens(plan) <= 2325, `plan prompt is ${approxTokens(plan)} tokens`); // 2075: #5284 (prod_parity plan line); 2050: #4769 (activation-row rule); 2000: #4730 (owner-step remainder); 1950: #4724 (deferred-row bucket rule) // 2325: #5333 (git stash rule + stage stamp line)
|
|
2511
|
+
assert.ok(approxTokens(impl) <= 1850, `implement prompt is ${approxTokens(impl)} of 1700 tokens`); // 1650: #4726 e2e rule; 1550: #4596 i18n translate rule // 1850: #5333 (git stash rule + stage stamp)
|
|
2453
2512
|
for (const h of ["### What Was Claimed", "### What We Found", "### Root Cause", "### Affected Files", "### Sibling Sweep", "### History", "### Recommendation", "### Related Issues",
|
|
2454
2513
|
"investigation.md", "contract.json", "PLANNING ONLY", '"requirements"', '"deliverables"', '"preserve"', '"validate"', "verbatim", "defer", "post-deploy"]) assert.ok(plan.includes(h), h);
|
|
2455
2514
|
for (const h of ["### Approach", "### Changes", "### Acceptance Criteria Status", "### Verification", "### Notes", "implementation.md", "result.json",
|
|
@@ -2657,7 +2716,7 @@ describe("run-issue routing", () => {
|
|
|
2657
2716
|
|
|
2658
2717
|
it("bad --path errors; --retry is rejected on the core path", async () => {
|
|
2659
2718
|
await assert.rejects(runFromCli(["7", "--lane", "staging", "--path", "bogus"], mk()), /--path must be/);
|
|
2660
|
-
await assert.rejects(runFromCli(["7", "--lane", "staging", "--repo", "o/r", "--retry"], mk()), /
|
|
2719
|
+
await assert.rejects(runFromCli(["7", "--lane", "staging", "--repo", "o/r", "--retry"], mk()), /only works with the legacy pipeline/);
|
|
2661
2720
|
assert.deepEqual(ENGINE_PATHS, ["core", "full", "lean", "auto"]);
|
|
2662
2721
|
});
|
|
2663
2722
|
});
|
|
@@ -3204,6 +3263,12 @@ describe("requiredChecksFor: classic protection + rulesets (#4158)", () => {
|
|
|
3204
3263
|
const { gh } = stub({ classic: new Error("HTTP 404"), rules: new Error("HTTP 404") });
|
|
3205
3264
|
assert.deepEqual(await requiredChecksFor({ gh, repo: "o/r", lane: "staging" }), []);
|
|
3206
3265
|
});
|
|
3266
|
+
it("requiredChecksRead flags a non-404 failure as unreadable and a 404 as an answer (#5382)", async () => {
|
|
3267
|
+
const e403 = stub({ classic: new Error("gh: Resource not accessible (HTTP 403)"), rules: [] });
|
|
3268
|
+
assert.deepEqual(await requiredChecksRead({ gh: e403.gh, repo: "o/r", lane: "staging" }), { checks: [], unreadable: true });
|
|
3269
|
+
const e404 = stub({ classic: new Error("HTTP 404: Branch not protected"), rules: new Error("HTTP 404") });
|
|
3270
|
+
assert.deepEqual(await requiredChecksRead({ gh: e404.gh, repo: "o/r", lane: "staging" }), { checks: [], unreadable: false });
|
|
3271
|
+
});
|
|
3207
3272
|
it("a ruleset-derived required check is polled before the merge", async () => {
|
|
3208
3273
|
const w = world();
|
|
3209
3274
|
const { gh } = stub({ classic: new Error("HTTP 404"), rules: [{ type: "required_status_checks", parameters: { required_status_checks: [{ context: "build" }] } }] });
|
|
@@ -5086,7 +5151,7 @@ describe("verify-by-CI (#4167): ci mode runs the heavy checks on CI and feeds fa
|
|
|
5086
5151
|
const w = withCi(world());
|
|
5087
5152
|
const r = await run(w);
|
|
5088
5153
|
assert.equal(r.terminalReason, "merged"); assert.equal(w.ci.dispatched.length, 0);
|
|
5089
|
-
assert.
|
|
5154
|
+
assert.ok(unstamp(builders(w)[1][4]).startsWith(builderImplementPrompt()), "#5347: only the opening-batch note follows the base prompt");
|
|
5090
5155
|
assert.doesNotMatch(traj(w)[0], /\| Verify \|/);
|
|
5091
5156
|
});
|
|
5092
5157
|
|
|
@@ -5200,6 +5265,28 @@ describe("lane resource ledger + teardown on every exit path (#4179)", () => {
|
|
|
5200
5265
|
assert.equal(existsSync(w.ledgerFile), false, `${label}: ledger cleared`);
|
|
5201
5266
|
};
|
|
5202
5267
|
|
|
5268
|
+
/** #5333: SIGTERM while the builder runs; `proc` decides which pids stay alive after SIGTERM / SIGKILL. */
|
|
5269
|
+
const interruptedWith = async (stubborn) => {
|
|
5270
|
+
let td = null, out = null;
|
|
5271
|
+
const w = ledgered({ dirty: true, during: async (w2, c) => { if (!/PLANNING ONLY/.test(c.prompt) && !out) out = await td("SIGTERM"); } });
|
|
5272
|
+
w.alive = new Set([4242]); w.kills = [];
|
|
5273
|
+
w.io.sleep = async () => {};
|
|
5274
|
+
w.io.proc = { inDir: async () => [], alive: (pid) => w.alive.has(pid), kill: (pid, sig) => { w.kills.push([pid, sig]); w.seq.push(`kill-${sig}`); if (sig === "SIGKILL" && !stubborn) w.alive.delete(pid); } };
|
|
5275
|
+
await run(w, { onTeardown: (fn) => { td = fn; } });
|
|
5276
|
+
return w;
|
|
5277
|
+
};
|
|
5278
|
+
it("#5333 teardown removes the worktree only after the builder process exited (SIGKILL after the grace period)", async () => {
|
|
5279
|
+
const w = await interruptedWith(false);
|
|
5280
|
+
assert.deepEqual(w.kills, [[4242, "SIGKILL"]]);
|
|
5281
|
+
assert.ok(w.seq.indexOf("kill-SIGKILL") < w.seq.lastIndexOf("worktree-remove"), "worktree removed after the builder was gone");
|
|
5282
|
+
tornDown(w, "builder gone");
|
|
5283
|
+
});
|
|
5284
|
+
|
|
5285
|
+
it("#5333 a builder process that survives SIGKILL keeps the worktree (nothing is removed under a running builder)", async () => {
|
|
5286
|
+
const w = await interruptedWith(true);
|
|
5287
|
+
assert.equal(w.calls.filter((c) => c[1] === "worktree" && c[2] === "remove").length, 1, "only the setup remove ran");
|
|
5288
|
+
});
|
|
5289
|
+
|
|
5203
5290
|
it("while the lane runs, the ledger on disk lists worktree, branch, run tmp and builder pid with owner/batch/lane/issue/created/expires (survives a crash)", async () => {
|
|
5204
5291
|
const w = ledgered({ batch: "b1" });
|
|
5205
5292
|
await run(w, { batchId: "b1" });
|
|
@@ -5306,6 +5393,46 @@ describe("lane resource ledger + teardown on every exit path (#4179)", () => {
|
|
|
5306
5393
|
tornDown(w, sig);
|
|
5307
5394
|
}
|
|
5308
5395
|
});
|
|
5396
|
+
|
|
5397
|
+
// ---- #5334: a killed session still records the usage it streamed ----
|
|
5398
|
+
const KILLED = { input_tokens: 1000, output_tokens: 2000, cache_read_input_tokens: 100000, cache_creation_input_tokens: 10000 }; // sonnet tier: $0.1005
|
|
5399
|
+
const attemptsOf = (dir) => readLog(dir, 7).filter((e) => e.event === "PHASE_ATTEMPT_USAGE");
|
|
5400
|
+
it("#5334 SIGTERM mid-attempt: PHASE_ATTEMPT_USAGE with the session's turns and an estimated cost lands before RUN_TERMINAL; no turns 0 / model_ms 0", async () => {
|
|
5401
|
+
let td = null; const dir = tmpDir("core-sig-usage-");
|
|
5402
|
+
const w = ledgered({ dirty: true, during: async (w2, c) => { if (!/PLANNING ONLY/.test(c.prompt) && td) { c.session.snapshot = () => ({ usage: KILLED, turns: 7, toolUses: [] }); await new Promise((r) => setTimeout(r, 5)); await td("SIGTERM"); } } });
|
|
5403
|
+
const r = await run(w, { dir, onTeardown: (fn) => { td = fn; } });
|
|
5404
|
+
assert.equal(r.code, "run.interrupted");
|
|
5405
|
+
const log = readLog(dir, 7), a = attemptsOf(dir).filter((e) => e.turns === 7);
|
|
5406
|
+
assert.equal(a.length, 1, "one attempt for the interrupted session, not double counted by the builder's own catch");
|
|
5407
|
+
assert.equal(a[0].turns, 7); assert.deepEqual(a[0].usage, KILLED);
|
|
5408
|
+
assert.ok(Math.abs(a[0].cost_usd - 0.1005) / 0.1005 < 0.05, String(a[0].cost_usd)); assert.equal(a[0].cost_estimated, true);
|
|
5409
|
+
const term = log.find((e) => e.event === "RUN_TERMINAL");
|
|
5410
|
+
assert.ok(log.indexOf(a[0]) < log.indexOf(term));
|
|
5411
|
+
assert.ok(term.model_ms > 0, "model_ms is the session's time, not 0");
|
|
5412
|
+
});
|
|
5413
|
+
|
|
5414
|
+
it("#5334 a host kill and an idle kill each record the killed session's usage (turns, cost) before the retry", async () => {
|
|
5415
|
+
for (const kill of [{ code: "CLI_BACKEND_FAILED", signal: "SIGTERM", status: null }, { code: "CLI_IDLE", lastTool: null, children: [] }]) {
|
|
5416
|
+
const w = world({ dirty: true }); const dir = tmpDir("core-kill-usage-");
|
|
5417
|
+
const orig = w.io.runner; let n = 0;
|
|
5418
|
+
w.io.runner = async (c) => { if (c.role === "builder" && n++ === 1) throw Object.assign(new Error("killed"), kill, { usage: KILLED, turns: 5 }); return orig(c); };
|
|
5419
|
+
assert.equal((await run(w, { dir })).terminalReason, "merged");
|
|
5420
|
+
const k = attemptsOf(dir).find((e) => e.turns === 5);
|
|
5421
|
+
assert.ok(k, kill.code); assert.deepEqual(k.usage, KILLED);
|
|
5422
|
+
assert.ok(Math.abs(k.cost_usd - 0.1005) / 0.1005 < 0.05, String(k.cost_usd));
|
|
5423
|
+
assert.equal(k.cost_usd_delta, k.cost_usd);
|
|
5424
|
+
}
|
|
5425
|
+
});
|
|
5426
|
+
|
|
5427
|
+
it("#5334 a kill that streamed nothing is marked usage_unknown, never recorded as 0 turns", async () => {
|
|
5428
|
+
const w = world({ dirty: true }); const dir = tmpDir("core-kill-unknown-");
|
|
5429
|
+
const orig = w.io.runner; let n = 0;
|
|
5430
|
+
w.io.runner = async (c) => { if (c.role === "builder" && n++ === 1) throw Object.assign(new Error("idle"), { code: "CLI_IDLE", lastTool: null, children: [] }); return orig(c); };
|
|
5431
|
+
await run(w, { dir });
|
|
5432
|
+
const u = attemptsOf(dir).find((e) => e.usage_unknown === true);
|
|
5433
|
+
assert.ok(u); assert.equal(u.turns, null);
|
|
5434
|
+
assert.equal(readLog(dir, 7).find((e) => e.event === "RUN_TERMINAL").usage_unknown, true);
|
|
5435
|
+
});
|
|
5309
5436
|
});
|
|
5310
5437
|
|
|
5311
5438
|
describe("two repos with the same issue number on one host (#4432)", () => {
|
|
@@ -5550,6 +5677,25 @@ describe("local-mode CI fix rounds at merge and declared pre-PR check commands (
|
|
|
5550
5677
|
assert.ok(log.findIndex((e) => e.event === "PRECHECK_COMMANDS") < log.findIndex((e) => e.event === "PR_OPENED"));
|
|
5551
5678
|
});
|
|
5552
5679
|
|
|
5680
|
+
it("#5332 a precheck round whose only non-zero result is rc 124 does not resume the builder or end ci.red, and is never self_check green", async () => {
|
|
5681
|
+
const w = world(); const dir = tmpDir("core-");
|
|
5682
|
+
w.io.runCommand = async () => ({ rc: 124, output: "(timed out after 1s)" });
|
|
5683
|
+
const r = await run(w, { dir, precheck: { commands: ["make slow"] } });
|
|
5684
|
+
assert.equal(r.terminalReason, "merged");
|
|
5685
|
+
assert.equal(builders(w).filter((b) => /declared check commands failed/.test(b[4])).length, 0, "no builder resume");
|
|
5686
|
+
const pre = readLog(dir, 7).filter((e) => e.event === "PRECHECK_COMMANDS");
|
|
5687
|
+
assert.deepEqual(pre.map((e) => e.results[0].rc), [124]); assert.equal(pre.length, 1);
|
|
5688
|
+
assert.equal(pre[0].self_check, "timed_out");
|
|
5689
|
+
});
|
|
5690
|
+
it("#5332 with verify.precheck_block a timed-out check ends env.validate_timeout (not ci.red) naming the command and limit", async () => {
|
|
5691
|
+
const w = world();
|
|
5692
|
+
w.io.runCommand = async () => ({ rc: 124, output: "(timed out after 1s)" });
|
|
5693
|
+
const r = await run(w, { precheck: { commands: ["make slow"] }, verify: { ...parseVerify({}), precheckBlock: true } });
|
|
5694
|
+
assert.equal(r.code, ENV_VALIDATE_TIMEOUT); assert.equal(r.terminalReason, "needs-human"); assert.equal(w.merges.length, 0);
|
|
5695
|
+
assert.equal(builders(w).filter((b) => /declared check commands failed/.test(b[4])).length, 0);
|
|
5696
|
+
assert.match((w.comments.find((c) => c.includes("FORGE:NEEDS_HUMAN")) ?? ""), /`make slow` \(timed out after 1 s, exit 124\)/);
|
|
5697
|
+
});
|
|
5698
|
+
|
|
5553
5699
|
it("#4585 verify.invariants run in the pre-PR round even with no learned commands, and the prompts carry the checklist", async () => {
|
|
5554
5700
|
const w = world(); const ran = [];
|
|
5555
5701
|
w.io.runCommand = async ({ command }) => { ran.push(command); return { rc: 0, output: "" }; };
|
|
@@ -5723,14 +5869,14 @@ describe("test map and repo facts caches (#4272)", () => {
|
|
|
5723
5869
|
});
|
|
5724
5870
|
|
|
5725
5871
|
it("neither file present: the same commands, events and prompts as without the feature", async () => {
|
|
5726
|
-
const w = world(); const ran = recorder(w); w.io.fs.exists = async () =>
|
|
5872
|
+
const w = world(); const ran = recorder(w); w.io.fs.exists = async (p) => p === WT;
|
|
5727
5873
|
const dir = tmpDir("core-");
|
|
5728
5874
|
assert.equal((await run(w, { dir, precheck: { commands: ["true", "make lint"] } })).terminalReason, "merged");
|
|
5729
5875
|
assert.deepEqual(ran, ["true", "make lint"]);
|
|
5730
5876
|
assert.deepEqual(readLog(dir, 7).filter((e) => e.event === "PRECHECK_COMMANDS").map(({ round, results, ...rest }) => [round, results, Object.keys(rest).filter((k) => k === "source")]),
|
|
5731
5877
|
[[0, [{ command: "true", rc: 0, ms: 0 }, { command: "make lint", rc: 0, ms: 0 }], []]]);
|
|
5732
5878
|
const [plan, impl] = builders(w);
|
|
5733
|
-
assert.equal(plan[4].startsWith(builderPlanPrompt(7)), true); assert.equal(impl[4].startsWith(builderImplementPrompt("local")), true);
|
|
5879
|
+
assert.equal(unstamp(plan[4]).startsWith(builderPlanPrompt(7)), true); assert.equal(unstamp(impl[4]).startsWith(builderImplementPrompt("local")), true);
|
|
5734
5880
|
for (const b of builders(w)) assert.doesNotMatch(b[4], /Repo facts/);
|
|
5735
5881
|
assert.doesNotMatch(traj(w)[0], /test-map/);
|
|
5736
5882
|
});
|
|
@@ -5738,11 +5884,11 @@ describe("test map and repo facts caches (#4272)", () => {
|
|
|
5738
5884
|
it("repo-facts.json present: the builder prompts cite its path, never its content", async () => {
|
|
5739
5885
|
const w = world(); recorder(w);
|
|
5740
5886
|
w.files[FACTSF] = JSON.stringify({ version: 1, toolchain: { pm: { name: "pnpm", version: "9.9.9-SECRET" } } });
|
|
5741
|
-
w.io.fs.exists = async (p) => p in w.files;
|
|
5887
|
+
w.io.fs.exists = async (p) => p === WT || p in w.files;
|
|
5742
5888
|
assert.equal((await run(w)).terminalReason, "merged");
|
|
5743
5889
|
const [plan, impl] = builders(w);
|
|
5744
5890
|
for (const b of [plan, impl]) { assert.ok(b[4].includes(`are cached in ${FACTSF}`)); assert.doesNotMatch(b[4], /9\.9\.9-SECRET/); }
|
|
5745
|
-
const w2 = world(); recorder(w2); w2.files["/repo/.forge/repo-facts.json"] = "{}"; w2.io.fs.exists = async (p) => p in w2.files;
|
|
5891
|
+
const w2 = world(); recorder(w2); w2.files["/repo/.forge/repo-facts.json"] = "{}"; w2.io.fs.exists = async (p) => p === WT || p in w2.files;
|
|
5746
5892
|
assert.equal((await run(w2)).terminalReason, "merged");
|
|
5747
5893
|
assert.ok(builders(w2)[0][4].includes("are cached in /repo/.forge/repo-facts.json"));
|
|
5748
5894
|
});
|
|
@@ -6089,7 +6235,7 @@ describe("context pack modes (forge#4275)", () => {
|
|
|
6089
6235
|
const r = await run(w, { dir, contextPack: { mode: "on" } });
|
|
6090
6236
|
assert.equal(r.terminalReason, "merged");
|
|
6091
6237
|
const plan = builders(w)[0][4];
|
|
6092
|
-
assert.ok(plan.startsWith(builderPlanPrompt(7)));
|
|
6238
|
+
assert.ok(unstamp(plan).startsWith(builderPlanPrompt(7)));
|
|
6093
6239
|
assert.match(plan, /Context pack \(hints, not proof[\s\S]*- #3 \[parent\] OPEN "Epic"[\s\S]*zebra protocol/);
|
|
6094
6240
|
assert.equal(w.packCalls.length, 1);
|
|
6095
6241
|
assert.equal(w.packCalls[0].base, "origin/staging");
|
|
@@ -6295,6 +6441,32 @@ describe("enumerating tests + sequence numbers at hand-off (#4322)", () => {
|
|
|
6295
6441
|
assert.equal(w.dupArgs.cwd, WT);
|
|
6296
6442
|
});
|
|
6297
6443
|
|
|
6444
|
+
it("#5348 an enumerating-test omission and a duplicate export the detectors name are fixed without a model session", async () => {
|
|
6445
|
+
const w = hworld({ missing: [MISS, []] }); const d = [DUP, []]; w.mech = [];
|
|
6446
|
+
w.io.duplicateExports = async () => (d.length > 1 ? d.shift() : d[0]);
|
|
6447
|
+
w.io.mechFix = {
|
|
6448
|
+
applyEnumerating: async ({ missing }) => { w.mech.push(["enum", missing.length]); return { applied: missing, remaining: [] }; },
|
|
6449
|
+
renameDuplicates: async ({ dups }) => { w.mech.push(["dup", dups.length]); return { applied: dups.map((x) => ({ ...x, renamedTo: "FeedUndo" })), remaining: [] }; },
|
|
6450
|
+
};
|
|
6451
|
+
assert.equal((await run(w)).terminalReason, "merged");
|
|
6452
|
+
assert.deepEqual(w.mech, [["enum", 1], ["dup", 1]]);
|
|
6453
|
+
assert.equal(builders(w).length, 2, "plan and build only: no fix session");
|
|
6454
|
+
assert.ok(w.calls.some((c) => c[0] === "git" && c[1] === "commit" && /enumerating fix applied by the engine/.test(c.join(" "))), "the mechanical edit is committed");
|
|
6455
|
+
assert.ok(w.calls.some((c) => c[0] === "git" && c[1] === "commit" && /duplicate fix applied by the engine/.test(c.join(" "))));
|
|
6456
|
+
});
|
|
6457
|
+
|
|
6458
|
+
it("#5348 what the engine cannot place goes to one narrow session that also carries the other pending narrow fix", async () => {
|
|
6459
|
+
const w = hworld({ missing: [MISS, []] }); const d = [DUP, []]; const seen = [];
|
|
6460
|
+
w.io.duplicateExports = async () => (d.length > 1 ? d.shift() : d[0]);
|
|
6461
|
+
w.io.mechFix = { applyEnumerating: async ({ missing }) => ({ applied: [], remaining: missing }), renameDuplicates: async ({ dups }) => ({ applied: [], remaining: dups }) };
|
|
6462
|
+
const inner = w.io.runner; w.io.runner = async (c) => { if (c.role === "builder") seen.push({ profile: c.profile ?? null, prompt: c.prompt }); return inner(c); };
|
|
6463
|
+
assert.equal((await run(w)).terminalReason, "merged");
|
|
6464
|
+
const fix = seen.filter((x) => x.profile === "narrow");
|
|
6465
|
+
assert.equal(fix.length, 1, "one narrow session for both findings");
|
|
6466
|
+
assert.match(fix[0].prompt, /fooNew[\s\S]*undoActivityAction/);
|
|
6467
|
+
assert.doesNotMatch(fix[0].prompt, /## Diff/);
|
|
6468
|
+
});
|
|
6469
|
+
|
|
6298
6470
|
it("#4596 English copies in a locale catalog resume the builder once to translate; a leftover is an anomaly", async () => {
|
|
6299
6471
|
const w = hworld(); const c = [[{ path: "messages/ta.json", key: "calendarView.day", value: "Day view", source: "messages/en.json" }], []]; w.cpCalls = 0;
|
|
6300
6472
|
w.io.englishCopies = async (x) => { w.cpCalls++; w.cpArgs = x; return c.length > 1 ? c.shift() : c[0]; };
|
|
@@ -6427,6 +6599,24 @@ describe("enumerating tests + sequence numbers at hand-off (#4322)", () => {
|
|
|
6427
6599
|
assert.equal(w.resolveArgs.partial, true);
|
|
6428
6600
|
});
|
|
6429
6601
|
|
|
6602
|
+
it("#5340: a full-path lane whose contract touches a declared shared surface takes a reserved slot, released at finish", async () => {
|
|
6603
|
+
const w = dworld({ seq: [[]] }), declared = [];
|
|
6604
|
+
w.io.sequenceLease.declare = async (x) => { declared.push(x); };
|
|
6605
|
+
w.io.sequenceLease.undeclare = async () => {};
|
|
6606
|
+
const r = await run(w, { sharedSurfaces: ["src/foo.js", "src/gen.js => npm run gen"] });
|
|
6607
|
+
assert.equal(r.terminalReason, "merged");
|
|
6608
|
+
const slot = w.leases.acquired.find((a) => a.lane === "*");
|
|
6609
|
+
assert.deepEqual(slot.dirs, ["surface:src/foo.js"]);
|
|
6610
|
+
assert.deepEqual(declared[0].surfaces, ["src/foo.js"]);
|
|
6611
|
+
assert.ok(w.leases.released >= 1, "slot released at teardown");
|
|
6612
|
+
});
|
|
6613
|
+
|
|
6614
|
+
it("#5340: no declared shared surface takes no surface lease", async () => {
|
|
6615
|
+
const w = dworld({ seq: [[]] });
|
|
6616
|
+
await run(w);
|
|
6617
|
+
assert.ok(!w.leases.acquired.some((a) => a.lane === "*"));
|
|
6618
|
+
});
|
|
6619
|
+
|
|
6430
6620
|
it("#4526: the renumber gets a reserve hook bound to (repo, lane, issue), and the run's reservations are dropped at finish", async () => {
|
|
6431
6621
|
const w = dworld({ seq: [COLL, []] }), reserved = [], unreserved = [];
|
|
6432
6622
|
w.io.sequenceLease.reserve = async (x) => { reserved.push(x); return { numbers: [9] }; };
|
|
@@ -6463,6 +6653,31 @@ describe("enumerating tests + sequence numbers at hand-off (#4322)", () => {
|
|
|
6463
6653
|
assert.match(w.comments.find((c) => c.includes("<!-- FORGE:BASE_SYNC -->")), /deterministic: 2 union \/ JSON-map \/ generated file/);
|
|
6464
6654
|
});
|
|
6465
6655
|
|
|
6656
|
+
it("#5235 a hand-off renumber reruns the frozen validates without a spurious failure (no fix round, no anomaly)", async () => {
|
|
6657
|
+
const w = dworld({ seq: [COLL, []] }), ran = [];
|
|
6658
|
+
w.io.runCommand = async (a) => { ran.push(a.command); return { rc: 0, output: "" }; };
|
|
6659
|
+
const r = await run(w);
|
|
6660
|
+
assert.equal(r.terminalReason, "merged");
|
|
6661
|
+
assert.equal(w.renumbers.length, 1);
|
|
6662
|
+
assert.ok(ran.includes("node --test test/foo.test.js"), `validate rerun after hand-off renumber: ${JSON.stringify(ran)}`);
|
|
6663
|
+
assert.equal(builders(w).length, 2, "no fix round");
|
|
6664
|
+
assert.ok(!(r.anomalies ?? []).some((x) => /after the hand-off renumber/.test(x)), JSON.stringify(r.anomalies));
|
|
6665
|
+
});
|
|
6666
|
+
|
|
6667
|
+
it("#5235 a renumber after a base-sync reruns the frozen validates before the merge; no renumber, no extra run", async () => {
|
|
6668
|
+
const w = dworld({ seq: [[], COLL, []], prView: [CONFLICTING, OKSTATE], mergeResults: ["clean"], mine: [] }), ran = [];
|
|
6669
|
+
w.io.runCommand = async (a) => { ran.push(a.command); return { rc: 0, output: "" }; };
|
|
6670
|
+
assert.equal((await run(w)).terminalReason, "merged");
|
|
6671
|
+
assert.ok(w.renumbers.length >= 1, "renumbered at the base-sync");
|
|
6672
|
+
assert.ok(ran.includes("node --test test/foo.test.js"), `frozen validate rerun: ${JSON.stringify(ran)}`);
|
|
6673
|
+
assert.ok(w.merges.length === 1);
|
|
6674
|
+
const n = dworld({ seq: [[], [], []], prView: [CONFLICTING, OKSTATE], mergeResults: ["clean"], mine: [] }), nran = [];
|
|
6675
|
+
n.io.runCommand = async (a) => { nran.push(a.command); return { rc: 0, output: "" }; };
|
|
6676
|
+
await run(n);
|
|
6677
|
+
assert.equal(n.renumbers.length, 0);
|
|
6678
|
+
assert.ok(!nran.includes("node --test test/foo.test.js"), "P2: nothing extra without a renumber");
|
|
6679
|
+
});
|
|
6680
|
+
|
|
6466
6681
|
it("#4588: files the engine cannot resolve go to the sequence resolver, and the builder when that fails; without config nothing changes", async () => {
|
|
6467
6682
|
const w = dworld({ prView: [CONFLICTING, OKSTATE], mergeResults: ["conflict"], conflictFiles: ["src/index.ts", "db/meta/_journal.json"], resolve: { unsupported: "x" } });
|
|
6468
6683
|
w.io.conflictResolve = async () => ({ resolved: ["src/index.ts"], remaining: ["db/meta/_journal.json"] });
|
|
@@ -6658,7 +6873,7 @@ describe("#4362 attempt triggers", () => {
|
|
|
6658
6873
|
w.io.runner = async (c) => { if (c.role === "builder" && n++ === 1) throw Object.assign(new Error("idle"), { code: "CLI_IDLE" }); return orig(c); };
|
|
6659
6874
|
const r = await run(w, { dir });
|
|
6660
6875
|
assert.equal(r.terminalReason, "merged");
|
|
6661
|
-
assert.deepEqual(usage(dir).filter((e) => e.phase === "implement").map((e) => [e.attempt, e.trigger, e.restart_of ?? null]), [[1, "plan", null], [2, "timeout_restart", "build"]]);
|
|
6876
|
+
assert.deepEqual(usage(dir).filter((e) => e.phase === "implement").map((e) => [e.attempt, e.trigger, e.restart_of ?? null]), [[1, "plan", null], [2, "build", null], [2, "timeout_restart", "build"]]); // #5334: the killed session is its own attempt row
|
|
6662
6877
|
assert.equal(r.firstPass, true);
|
|
6663
6878
|
});
|
|
6664
6879
|
|
|
@@ -6709,6 +6924,55 @@ describe("#4362 attempt triggers", () => {
|
|
|
6709
6924
|
assert.equal((await run(off, { dir: tmpDir("core-ctx-"), contextCeilingTokens: 0 })).terminalReason, "merged");
|
|
6710
6925
|
assert.ok(offCaps.every((x) => x === 0));
|
|
6711
6926
|
});
|
|
6927
|
+
|
|
6928
|
+
it("#5346: a lane whose start is at 60% of the ceiling is narrowed before the build; named files alone over the ceiling run uncapped", async () => {
|
|
6929
|
+
const big = (bytes, ceil) => {
|
|
6930
|
+
const w = world({ dirty: true }); const seen = []; const orig = w.io.runner;
|
|
6931
|
+
w.files[`${WT}/src/foo.js`] = "x".repeat(bytes);
|
|
6932
|
+
w.io.runner = async (c) => { if (c.role === "builder") seen.push({ contextMax: c.contextMax ?? 0, prompt: c.prompt }); return orig(c); };
|
|
6933
|
+
return { w, seen, go: () => run(w, { dir: tmpDir("core-pred-"), contextCeilingTokens: ceil }) };
|
|
6934
|
+
};
|
|
6935
|
+
const near = big(500_000, 200000); // about 125000 tokens of named files: over 60% of 200000, under the ceiling
|
|
6936
|
+
assert.equal((await near.go()).terminalReason, "merged");
|
|
6937
|
+
assert.equal(near.seen[1].contextMax, 200000, "predicted, not certain: the ceiling stays");
|
|
6938
|
+
assert.match(near.seen[1].prompt, /Context is tight on this lane/);
|
|
6939
|
+
const certain = big(2_000_000, 120000); // 500000 tokens of named files: a restart is certain
|
|
6940
|
+
const rc = await certain.go();
|
|
6941
|
+
assert.equal(rc.terminalReason, "merged");
|
|
6942
|
+
assert.equal(certain.seen[1].contextMax, 0, "certain restart: the build runs without the ceiling");
|
|
6943
|
+
assert.match(certain.seen[1].prompt, /Context is tight on this lane/);
|
|
6944
|
+
const small = big(400, 120000);
|
|
6945
|
+
await small.go();
|
|
6946
|
+
assert.doesNotMatch(small.seen[1].prompt, /Context is tight on this lane/, "a small lane is untouched");
|
|
6947
|
+
assert.equal(small.seen[1].contextMax, 120000);
|
|
6948
|
+
});
|
|
6949
|
+
|
|
6950
|
+
it("#5346: the restart prompt carries the files the stopped session read and edited, and its last tool", async () => {
|
|
6951
|
+
const w = world({ dirty: true }); const orig = w.io.runner, seen = []; let n = 0;
|
|
6952
|
+
w.io.runner = async (c) => {
|
|
6953
|
+
if (c.role === "builder") seen.push(c.prompt);
|
|
6954
|
+
if (c.role === "builder" && n++ === 1) throw Object.assign(new Error("ctx"), { code: "CLI_CONTEXT", context: 130000, turns: 9, usage: null,
|
|
6955
|
+
toolUses: [{ msg: "m1", name: "Read", path: "src/read-me.js" }, { msg: "m2", name: "Edit", path: "src/foo.js" }], lastTool: { name: "Edit", input: "{\"file_path\":\"src/foo.js\"}" } });
|
|
6956
|
+
return orig(c);
|
|
6957
|
+
};
|
|
6958
|
+
assert.equal((await run(w, { dir: tmpDir("core-hand-"), contextCeilingTokens: 120000 })).terminalReason, "merged");
|
|
6959
|
+
const restart = seen[2];
|
|
6960
|
+
assert.match(restart, /<established>/);
|
|
6961
|
+
assert.match(restart, /Files the previous session edited:\n- src\/foo\.js/);
|
|
6962
|
+
assert.match(restart, /do not re-read them unless you must edit them\):\n- src\/read-me\.js/);
|
|
6963
|
+
assert.match(restart, /Its last tool call: Edit /);
|
|
6964
|
+
});
|
|
6965
|
+
|
|
6966
|
+
it("#5346: engine.context_ceiling_by_size sets the ceiling per lane size (size S here), the global one otherwise", async () => {
|
|
6967
|
+
const w = world({ dirty: true }); const caps = []; const orig = w.io.runner;
|
|
6968
|
+
w.io.runner = async (c) => { if (c.role === "builder") caps.push(c.contextMax ?? 0); return orig(c); };
|
|
6969
|
+
await run(w, { dir: tmpDir("core-size-"), contextCeilingTokens: 120000, contextCeilingBySize: { S: 90000 } });
|
|
6970
|
+
assert.equal(caps[1], 90000);
|
|
6971
|
+
const m = world({ dirty: true }); const mcaps = []; const o2 = m.io.runner;
|
|
6972
|
+
m.io.runner = async (c) => { if (c.role === "builder") mcaps.push(c.contextMax ?? 0); return o2(c); };
|
|
6973
|
+
await run(m, { dir: tmpDir("core-size-"), contextCeilingTokens: 120000, contextCeilingBySize: { L: 90000 } });
|
|
6974
|
+
assert.equal(mcaps[1], 120000, "no entry for the lane's size: the global ceiling");
|
|
6975
|
+
});
|
|
6712
6976
|
});
|
|
6713
6977
|
|
|
6714
6978
|
describe("#4407 per-attempt cost deltas", () => {
|
|
@@ -6899,7 +7163,7 @@ describe("explorer subagent (#4391)", () => {
|
|
|
6899
7163
|
assert.ok(b.length >= 2 && b.every((s) => s.agents?.explorer?.model === "claude-haiku-5-5"));
|
|
6900
7164
|
assert.ok(seen.filter((s) => s.role !== "builder").every((s) => s.agents === null));
|
|
6901
7165
|
const [plan, impl] = builders(w).map((c) => c[4]);
|
|
6902
|
-
assert.ok(plan.startsWith(builderPlanPrompt(7)));
|
|
7166
|
+
assert.ok(unstamp(plan).startsWith(builderPlanPrompt(7)));
|
|
6903
7167
|
assert.match(plan, /subagent_type "explorer"[\s\S]*Open a file yourself only to edit it or to verify a digest claim/);
|
|
6904
7168
|
assert.match(impl, /subagent_type "explorer"/);
|
|
6905
7169
|
assert.equal(readLog(dir, 7).find((e) => e.event === "RUN_TERMINAL").explore, "on");
|
|
@@ -7381,11 +7645,11 @@ describe("#4395 lane profile", () => {
|
|
|
7381
7645
|
|
|
7382
7646
|
it("#4410 both builder prompts ask for same-turn read-only calls and read-once notes (within budget)", () => {
|
|
7383
7647
|
for (const p of [builderPlanPrompt(7), builderImplementPrompt(), builderImplementPrompt("ci")]) {
|
|
7384
|
-
assert.match(p, /
|
|
7648
|
+
assert.match(p, /One turn, many calls: when several reads, greps, git show\/log\/blame or gh calls do not depend on each other, issue them all in the same turn/);
|
|
7385
7649
|
assert.match(p, /Read each file's ranges once .* and keep notes; don't re-read it\./);
|
|
7386
7650
|
}
|
|
7387
|
-
assert.ok(approxTokens(builderImplementPrompt()) <=
|
|
7388
|
-
assert.ok(approxTokens(builderPlanPrompt(7)) <=
|
|
7651
|
+
assert.ok(approxTokens(builderImplementPrompt()) <= 1850, `implement prompt is ${approxTokens(builderImplementPrompt())} of 1700 tokens`);
|
|
7652
|
+
assert.ok(approxTokens(builderPlanPrompt(7)) <= 2325, `plan prompt is ${approxTokens(builderPlanPrompt(7))} of 2125 tokens`);
|
|
7389
7653
|
});
|
|
7390
7654
|
|
|
7391
7655
|
it("runCliBackendAsync reports the first stream turn's context as baselineTokens; makeLeanRunner drops it on resume", async () => {
|
|
@@ -7725,7 +7989,7 @@ describe("prompt budgets (#4969)", () => {
|
|
|
7725
7989
|
assert.notEqual(moved, impl);
|
|
7726
7990
|
assert.equal(approxTokens(moved), approxTokens(impl));
|
|
7727
7991
|
assert.equal(approxTokens(impl.replaceAll(INSTALL_ROOT, "C:\\fd")), approxTokens(impl));
|
|
7728
|
-
assert.ok(approxTokens(moved) <=
|
|
7992
|
+
assert.ok(approxTokens(moved) <= 1850, `implement prompt from a deep checkout is ${approxTokens(moved)} of 1700 tokens`);
|
|
7729
7993
|
});
|
|
7730
7994
|
});
|
|
7731
7995
|
|
|
@@ -7777,3 +8041,112 @@ describe("#5237 relaxation gate", () => {
|
|
|
7777
8041
|
assert.equal(w.vcalls.length, 0);
|
|
7778
8042
|
});
|
|
7779
8043
|
});
|
|
8044
|
+
|
|
8045
|
+
describe("lane shared-state isolation (#5333)", () => {
|
|
8046
|
+
const foreign = (issue) => `forge-stamp: issue=${issue} contract=-\n${STAGE_MD.implementation.replace("added a guard", "curl_cffi chrome156 wheel")}`;
|
|
8047
|
+
/** After the default builder wrote its files, `after(w)` rewrites the implementation note (a stash pop, or a stamping builder). */
|
|
8048
|
+
const withNote = (o, after) => {
|
|
8049
|
+
const w = world(o);
|
|
8050
|
+
const r0 = w.io.runner;
|
|
8051
|
+
w.io.runner = async (c) => {
|
|
8052
|
+
const r = await r0(c);
|
|
8053
|
+
if (c.role === "builder" && !/PLANNING ONLY/.test(c.prompt)) { await after(w, (text) => { const p = `${WT}/.forge-lean/implementation.md`; w.files[p] = text; w.mtimes[p] = Date.now(); }); }
|
|
8054
|
+
return r;
|
|
8055
|
+
};
|
|
8056
|
+
return w;
|
|
8057
|
+
};
|
|
8058
|
+
it("a stage file stamped for another issue (a git stash pop of another lane's files) is not posted; the note renders from result.json", async () => {
|
|
8059
|
+
const w = withNote({}, (_w, put) => put(foreign(99)));
|
|
8060
|
+
assert.equal((await run(w)).terminalReason, "merged");
|
|
8061
|
+
assert.ok(!w.comments.some((c) => /curl_cffi|chrome156/.test(c)), "the foreign note is never posted");
|
|
8062
|
+
assert.ok(w.comments.some((c) => c.includes("FORGE:IMPLEMENTATION")), "an implementation note is still posted, from result.json");
|
|
8063
|
+
assert.match(traj(w)[0], /implementation\.md not posted: stamped for issue #99, run is #7/);
|
|
8064
|
+
});
|
|
8065
|
+
|
|
8066
|
+
it("a note stamped for this issue is posted without the stamp line", async () => {
|
|
8067
|
+
const w = withNote({}, (_w, put) => put(`forge-stamp: issue=7 contract=-\n${STAGE_MD.implementation}`));
|
|
8068
|
+
assert.equal((await run(w)).terminalReason, "merged");
|
|
8069
|
+
const impl = w.comments.find((c) => c.includes("FORGE:IMPLEMENTATION"));
|
|
8070
|
+
assert.match(impl, /added a guard/);
|
|
8071
|
+
assert.doesNotMatch(impl, /forge-stamp/);
|
|
8072
|
+
});
|
|
8073
|
+
|
|
8074
|
+
it("a note posted live that a later stash pop replaces with another lane's file is re-rendered after the builder's final turn", async () => {
|
|
8075
|
+
const w = withNote({}, async (wd, put) => {
|
|
8076
|
+
put(`forge-stamp: issue=7 contract=-\n${STAGE_MD.implementation}`);
|
|
8077
|
+
for (let i = 0; i < 1000 && !wd.comments.some((c) => c.includes("<!-- FORGE:IMPLEMENTATION -->")); i++) await new Promise((r) => setTimeout(r, 10));
|
|
8078
|
+
put(foreign(99));
|
|
8079
|
+
});
|
|
8080
|
+
await run(w, { livePollMs: 10, stableMs: 30 });
|
|
8081
|
+
assert.ok(w.patches.length >= 1, "the posted comment was edited");
|
|
8082
|
+
assert.doesNotMatch(w.patches.at(-1).join(" "), /curl_cffi|chrome156/);
|
|
8083
|
+
assert.ok(!w.comments.some((c) => /curl_cffi|chrome156/.test(c)));
|
|
8084
|
+
});
|
|
8085
|
+
|
|
8086
|
+
it("no builder session starts in a worktree that no longer exists: the lane defers run.interrupted", async () => {
|
|
8087
|
+
const w = world({ wtExists: true });
|
|
8088
|
+
const git0 = w.io.git, fs0 = w.io.fs.exists;
|
|
8089
|
+
let gone = false, builders = 0;
|
|
8090
|
+
w.io.git = async (a, ...r) => { if (a[0] === "worktree" && a[1] === "add") gone = true; return git0(a, ...r); };
|
|
8091
|
+
w.io.fs.exists = async (p) => (gone ? false : fs0(p));
|
|
8092
|
+
const r0 = w.io.runner; w.io.runner = async (c) => { if (c.role === "builder") builders++; return r0(c); };
|
|
8093
|
+
const r = await run(w);
|
|
8094
|
+
assert.equal(r.terminalReason, "deferred");
|
|
8095
|
+
assert.equal(builders, 0);
|
|
8096
|
+
});
|
|
8097
|
+
});
|
|
8098
|
+
|
|
8099
|
+
describe("#5347 builders open with one batch of independent reads", () => {
|
|
8100
|
+
it("the batching rule is its own rule in plan, implement and fix prompts, and the plan asks for the build's reads", async () => {
|
|
8101
|
+
const { fixSessionPrompt, buildOpeningNote } = await import("./prompts.mjs");
|
|
8102
|
+
for (const p of [builderPlanPrompt(7), builderImplementPrompt(), fixSessionPrompt({ task: "t" })]) assert.match(p, /One turn, many calls/);
|
|
8103
|
+
assert.match(builderPlanPrompt(7), /Build reads/);
|
|
8104
|
+
assert.match(buildOpeningNote({ paths: ["a.mjs", "a.mjs", "b.mjs"], tests: ["node --test a.test.mjs"] }), /Deliverables: a\.mjs, b\.mjs\nMapped tests \(test map\): node --test a\.test\.mjs/);
|
|
8105
|
+
assert.equal(buildOpeningNote({}), "");
|
|
8106
|
+
});
|
|
8107
|
+
it("the implement session prompt carries the contract's deliverable paths and the test map's commands", async () => {
|
|
8108
|
+
const { buildOpeningNote } = await import("./prompts.mjs");
|
|
8109
|
+
const { selectCommands, parseTestMap } = await import("./testmap.mjs");
|
|
8110
|
+
const map = parseTestMap(JSON.stringify({ version: 1, entries: [{ globs: ["src/**"], command: "node --test src/x.test.mjs" }] }));
|
|
8111
|
+
const note = buildOpeningNote({ paths: ["src/x.mjs", "docs/y.md"], tests: selectCommands(map, ["src/x.mjs", "docs/y.md"]) });
|
|
8112
|
+
assert.match(note, /src\/x\.mjs, docs\/y\.md/);
|
|
8113
|
+
assert.match(note, /node --test src\/x\.test\.mjs/);
|
|
8114
|
+
});
|
|
8115
|
+
});
|
|
8116
|
+
|
|
8117
|
+
describe("#5347 lane: the build opens with its independent reads in one turn", () => {
|
|
8118
|
+
it("a lane whose contract names two deliverables hands the builder the opening batch; the builder's one-turn reads through the real stream parser record calls/turn >= 2", async () => {
|
|
8119
|
+
const { runCliBackendAsync } = await import("../runner.mjs");
|
|
8120
|
+
const { toolStats } = await import("./toolstats.mjs");
|
|
8121
|
+
const two = { ...CONTRACT, deliverables: [...CONTRACT.deliverables, { id: "D2", path: "src/bar.js", change: "keep callers", requirements: ["R1"] }] };
|
|
8122
|
+
const w = world({ contract: two, changed: ["src/foo.js", "src/bar.js", "test/foo.test.js"] }), dir = tmpDir("core-onebatch-"), orig = w.io.runner;
|
|
8123
|
+
const prompts = [];
|
|
8124
|
+
w.io.runner = async (c) => {
|
|
8125
|
+
const out = await orig(c);
|
|
8126
|
+
if (c.role !== "builder" || /PLANNING ONLY/.test(c.prompt)) return out;
|
|
8127
|
+
prompts.push(c.prompt);
|
|
8128
|
+
// the model's side, stood in by a fake CLI: one assistant message (one id) with a Read per opening-batch path
|
|
8129
|
+
const paths = (/Deliverables: (.*)/.exec(c.prompt)?.[1] ?? "").split(", ").filter(Boolean);
|
|
8130
|
+
const blocks = paths.map((p, i) => ({ type: "tool_use", id: `t${i}`, name: "Read", input: { file_path: p } }));
|
|
8131
|
+
const ev = (o) => JSON.stringify(o).replaceAll("'", "");
|
|
8132
|
+
const script = `#!/bin/sh\necho '${ev({ type: "assistant", message: { id: "m1", content: blocks, usage: { input_tokens: 1, output_tokens: 1 } } })}'\necho '${ev({ type: "result", subtype: "success", is_error: false, result: "ok", session_id: "s", usage: { input_tokens: 2, output_tokens: 2 } })}'\n`;
|
|
8133
|
+
writeFileSync(`${dir}/fake`, script); chmodSync(`${dir}/fake`, 0o755);
|
|
8134
|
+
const r = await runCliBackendAsync({ spec: { name: "t" }, userMessage: "go", args: ["1"], cwd: dir, bin: `${dir}/fake`, logger: { log() {} }, stream: true });
|
|
8135
|
+
return { ...out, tools: toolStats(r.toolUses) };
|
|
8136
|
+
};
|
|
8137
|
+
await run(w, { dir });
|
|
8138
|
+
assert.ok(prompts.length && /Opening batch: .*\nDeliverables: src\/foo\.js, src\/bar\.js/.test(prompts[0]), "the implement prompt carries the opening batch");
|
|
8139
|
+
const u = readLog(dir, 7).find((e) => e.event === "PHASE_ATTEMPT_USAGE" && e.phase === "implement" && e.trigger === "build");
|
|
8140
|
+
assert.equal(u.tools.turns, 1);
|
|
8141
|
+
assert.equal(u.tools.calls, 2);
|
|
8142
|
+
assert.ok(u.tools.per_turn >= 2, `calls/turn ${u.tools.per_turn}`);
|
|
8143
|
+
});
|
|
8144
|
+
it("the context pack's file list joins the opening batch (compileContextPack files from the ledger)", async () => {
|
|
8145
|
+
const { compileContextPack } = await import("./context.mjs");
|
|
8146
|
+
const { buildOpeningNote } = await import("./prompts.mjs");
|
|
8147
|
+
const pack = compileContextPack({ issue: 9, links: [], attempts: [], ledger: [{ pr: 4, sha: "abc", title: "t", revert: false, reverted: null, files: ["src/a.js", "src/b.js"], notes: [] }], facts: [] });
|
|
8148
|
+
assert.deepEqual(pack.files, ["src/a.js", "src/b.js"]);
|
|
8149
|
+
assert.deepEqual(compileContextPack({ issue: 9, links: [], attempts: [], ledger: [], facts: [] }).files, []);
|
|
8150
|
+
assert.match(buildOpeningNote({ paths: ["src/a.js"], packFiles: pack.files }), /Context pack files \(touched by earlier PRs on these symbols\): src\/b\.js/);
|
|
8151
|
+
});
|
|
8152
|
+
});
|