forgedock 1.52.0 → 1.54.0
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 +256 -0
- package/bin/auth/app-token.test.mjs +232 -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 +9 -3
- package/bin/engine/telemetry-seam.mjs +11 -3
- package/bin/engine/telemetry-seam.test.mjs +17 -0
- package/bin/engine-cli.mjs +110 -36
- package/bin/experiment.mjs +58 -6
- package/bin/first-run.mjs +122 -0
- package/bin/forge-utils.mjs +6 -2
- package/bin/forgedock.mjs +138 -142
- 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/account-watch.mjs +28 -0
- package/bin/lean/account-watch.test.mjs +30 -0
- package/bin/lean/activation.mjs +38 -0
- package/bin/lean/activation.test.mjs +36 -1
- package/bin/lean/basered.mjs +115 -0
- package/bin/lean/basered.test.mjs +66 -0
- package/bin/lean/batch-health.mjs +114 -7
- package/bin/lean/batch-health.test.mjs +87 -1
- package/bin/lean/batch.mjs +41 -2
- package/bin/lean/batch.test.mjs +115 -11
- 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/checkpoint-reconcile.mjs +43 -0
- package/bin/lean/checkpoint-reconcile.test.mjs +95 -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 +8 -1
- package/bin/lean/conformance.mjs +269 -38
- package/bin/lean/conformance.test.mjs +280 -7
- 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 +47 -14
- package/bin/lean/execution.mjs +19 -3
- package/bin/lean/execution.test.mjs +63 -0
- package/bin/lean/facts.mjs +3 -3
- package/bin/lean/facts.test.mjs +5 -0
- package/bin/lean/findinglabel.mjs +16 -0
- package/bin/lean/findinglabel.test.mjs +39 -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.mjs +6 -2
- package/bin/lean/issuewatch-release.test.mjs +17 -1
- package/bin/lean/issuewatch.mjs +45 -6
- package/bin/lean/issuewatch.test.mjs +3 -2
- package/bin/lean/lanelock.mjs +14 -0
- package/bin/lean/lean.mjs +473 -100
- package/bin/lean/lean.test.mjs +686 -33
- package/bin/lean/light.mjs +48 -7
- package/bin/lean/light.test.mjs +37 -3
- package/bin/lean/limits.test.mjs +142 -9
- package/bin/lean/mechfix.mjs +124 -0
- package/bin/lean/mechfix.test.mjs +75 -0
- package/bin/lean/orchestrate-cancel.test.mjs +143 -0
- package/bin/lean/orchestrate.mjs +116 -28
- package/bin/lean/phaseledger.mjs +47 -5
- package/bin/lean/phaseledger.test.mjs +30 -1
- package/bin/lean/postdeploy-check.test.mjs +39 -0
- 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 +77 -19
- package/bin/lean/quota.mjs +39 -0
- package/bin/lean/recovery.test.mjs +11 -1
- package/bin/lean/relaxation.mjs +73 -0
- package/bin/lean/relaxation.test.mjs +54 -0
- package/bin/lean/release-io.test.mjs +42 -0
- package/bin/lean/release-postmerge.mjs +125 -0
- package/bin/lean/release-preflight.mjs +58 -0
- package/bin/lean/release-preflight.test.mjs +114 -0
- package/bin/lean/release-rehearsal.mjs +64 -0
- package/bin/lean/release-rehearsal.test.mjs +93 -0
- package/bin/lean/release-review.e2e.test.mjs +77 -0
- package/bin/lean/release-review.mjs +254 -0
- package/bin/lean/release-review.test.mjs +307 -0
- package/bin/lean/release-snapshot.mjs +188 -0
- package/bin/lean/release-snapshot.test.mjs +190 -0
- package/bin/lean/release.mjs +296 -0
- package/bin/lean/release.test.mjs +387 -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/rotator.mjs +150 -31
- package/bin/lean/rotator.test.mjs +105 -2
- package/bin/lean/sandbox-remote.mjs +9 -2
- package/bin/lean/schedd.mjs +83 -5
- package/bin/lean/schedd.test.mjs +108 -7
- 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/lean/verifier.mjs +3 -2
- package/bin/lean/verify.mjs +2 -1
- package/bin/lean/verify.test.mjs +6 -0
- package/bin/pool/agent.mjs +27 -4
- package/bin/pool/docker.mjs +5 -0
- package/bin/pool/router.mjs +74 -28
- package/bin/prereqs.mjs +111 -0
- package/bin/replay-timelapse.mjs +149 -0
- package/bin/review-staging.mjs +123 -16
- package/bin/review-staging.test.mjs +18 -0
- package/bin/runner.mjs +43 -6
- package/bin/splash-install.mjs +157 -0
- package/bin/stats/aggregate.mjs +8 -1
- package/bin/stats/conformance-outcomes.mjs +289 -0
- package/bin/stats/conformance-outcomes.test.mjs +274 -0
- package/bin/stats/depth.mjs +275 -0
- package/bin/stats/depth.test.mjs +158 -0
- package/bin/stats/efficiency.mjs +26 -5
- package/bin/stats/efficiency.test.mjs +45 -1
- package/bin/stats/experiment.mjs +7 -5
- 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 +53 -15
- package/bin/stats/index.mjs +147 -9
- package/bin/stats/local-source.mjs +12 -0
- package/bin/stats/origin.mjs +80 -0
- package/bin/stats/origin.test.mjs +58 -0
- package/bin/stats/query.mjs +69 -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/selffiled.mjs +52 -0
- package/bin/stats/selffiled.test.mjs +71 -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/orchestrate.md +1 -1
- package/commands/replay.md +2 -0
- package/commands/review-pr-agents/security.md +4 -0
- package/commands/review-pr-staging.md +6 -1
- package/commands/work-on/build.md +4 -6
- package/commands/work-on/close.md +8 -0
- package/docs/CONFIG.md +170 -18
- package/docs/ISSUE-WATCH.md +25 -0
- package/docs/OUTCOME-CODES.md +4 -0
- package/docs/REPLAY.md +9 -0
- package/docs/SELFTEST.md +11 -0
- package/docs/STATS.md +61 -0
- package/docs/TELEMETRY.md +1 -1
- 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/pool/README.md +1 -1
- package/pool/image/cs-cred +14 -1
- package/scripts/backfill-finding-labels.mjs +50 -0
- package/scripts/backfill-finding-labels.test.mjs +36 -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/doctor-pipeline-state.sh +21 -6
- package/scripts/file-deferred-followups.sh +59 -251
- package/scripts/file-deferred-followups.test.sh +85 -206
- package/scripts/followup-route.mjs +12 -0
- package/scripts/owner-route-parity.test.sh +17 -1
- package/scripts/plan-validate-live.mjs +40 -6
- package/scripts/review-pr-side-effects.test.sh +40 -0
- 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/e2e.mjs
CHANGED
|
@@ -34,19 +34,35 @@ export function parseE2e(sec = {}) {
|
|
|
34
34
|
|
|
35
35
|
/** Changed files (minus the engine's hand-off files) that are e2e specs per `cfg.paths`. */
|
|
36
36
|
export const e2eSpecs = (files, cfg = parseE2e({})) => verifiableFiles(files).filter((f) => (cfg.paths ?? []).some((g) => matchesGlob(f, g)));
|
|
37
|
-
/** True when a contract requirement quote carries a `[type:e2e]` criterion. */
|
|
38
|
-
export const contractWantsE2e = (contract) => (Array.isArray(contract?.requirements) ? contract.requirements : []).some((r) => /\[type:e2e\]/i.test(String(r?.quote ?? "")));
|
|
37
|
+
/** True when a contract requirement quote carries a `[type:e2e]` or `[type:manual]` criterion (#5339). */
|
|
38
|
+
export const contractWantsE2e = (contract) => (Array.isArray(contract?.requirements) ? contract.requirements : []).some((r) => /\[type:(?:e2e|manual)\]/i.test(String(r?.quote ?? "")));
|
|
39
|
+
|
|
40
|
+
/** #5339: markers of a test that fakes the thing it claims to prove (mocked modules, patched I/O, fake/stub fixtures). */
|
|
41
|
+
const FAKE_RE = /\b(?:vi|jest)\.(?:mock|fn|spyOn)\(|\bmonkeypatch\b|\bunittest\.mock\b|\bmock\.patch\b|\bMagicMock\b|\bsinon\.stub\b|\b(?:fake|mock|stub)[_-]?[a-z]\w*|\b(?:Fake|Mock|Stub)[A-Z]\w*/i;
|
|
42
|
+
/** #5339: the `paths` whose content (via `read`) carries a fake marker; an unreadable path is not faked. Deterministic, no model call. */
|
|
43
|
+
export function fakedPaths(paths, read) {
|
|
44
|
+
const out = [];
|
|
45
|
+
for (const p of paths ?? []) { let t = null; try { t = read(p); } catch { /* unreadable */ } if (typeof t === "string" && FAKE_RE.test(t)) out.push(p); }
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const UI_FILE_RE = /\.(?:tsx|jsx|vue|svelte)$/i;
|
|
50
|
+
const UI_INTERACTIVE_RE = /(?:dialog|modal|popover|drawer|cta|button|menu|trigger|layout|hero|header|nav)/i;
|
|
51
|
+
/** #5285: changed non-test UI component files that alter interactive elements (dialogs, CTAs, layout containers); jsdom cannot see layout or clicks. */
|
|
52
|
+
export const uiInteractiveChanged = (files) => verifiableFiles(files).filter((f) => UI_FILE_RE.test(f) && UI_INTERACTIVE_RE.test(f) && !/\.(?:test|spec|stories)\./i.test(f));
|
|
39
53
|
|
|
40
54
|
/** Whether this lane runs the e2e gate: {run, reason, specs}. */
|
|
41
55
|
export function e2eWanted({ cfg, files, contract } = {}) {
|
|
42
56
|
const c = cfg ?? parseE2e({});
|
|
43
57
|
const specs = e2eSpecs(files, c);
|
|
58
|
+
const ui = uiInteractiveChanged(files);
|
|
44
59
|
if (c.mode === "never") return { run: false, reason: "verify.e2e: never", specs };
|
|
45
60
|
if (!c.label && !c.workflow) return { run: false, reason: NO_TRIGGER, specs };
|
|
46
61
|
if (c.mode === "always") {
|
|
47
62
|
return skipsCi(files, DEFAULT_SKIP_PATHS) ? { run: false, reason: "docs-only change", specs } : { run: true, reason: "verify.e2e: always", specs };
|
|
48
63
|
}
|
|
49
64
|
if (specs.length) return { run: true, reason: `${specs.length} e2e spec(s) changed`, specs };
|
|
65
|
+
if (ui.length) return { run: true, reason: `interactive UI changed (${ui.slice(0, 3).join(", ")}): real-browser check`, specs, ui };
|
|
50
66
|
if (contractWantsE2e(contract)) return { run: true, reason: "contract has [type:e2e] criteria", specs };
|
|
51
67
|
return { run: false, reason: "no e2e spec changed and no [type:e2e] criteria", specs };
|
|
52
68
|
}
|
package/bin/lean/e2e.test.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
3
|
import { describe, it } from "node:test";
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
|
-
import { parseE2e, e2eSpecs, contractWantsE2e, e2eWanted, ownFailures, runE2eGate, E2E_DEFAULT_PATHS, NO_TRIGGER } from "./e2e.mjs";
|
|
5
|
+
import { parseE2e, e2eSpecs, contractWantsE2e, e2eWanted, uiInteractiveChanged, ownFailures, runE2eGate, fakedPaths, E2E_DEFAULT_PATHS, NO_TRIGGER } from "./e2e.mjs";
|
|
6
6
|
import { VERIFY_CHECK_NAME } from "./verify.mjs";
|
|
7
7
|
|
|
8
8
|
const HEAD = "abc123abc123abc123";
|
|
@@ -84,3 +84,28 @@ describe("runE2eGate (#4403)", () => {
|
|
|
84
84
|
assert.deepEqual(f.dispatched, [{ workflow: "e2e.yml", ref: "feat/issue-7-lean", inputs: { specs: "e2e/a.spec.ts" } }]);
|
|
85
85
|
});
|
|
86
86
|
});
|
|
87
|
+
|
|
88
|
+
describe("interactive UI real-browser check (#5285)", () => {
|
|
89
|
+
const cfg = { ...parseE2e({ e2e_label: "e2e" }) };
|
|
90
|
+
it("flags dialog/CTA/layout components, not tests or plain logic", () => {
|
|
91
|
+
assert.deepEqual(uiInteractiveChanged(["web/components/SignupDialog.tsx", "web/components/SignupDialog.test.tsx", "web/lib/price.ts"]), ["web/components/SignupDialog.tsx"]);
|
|
92
|
+
});
|
|
93
|
+
it("e2eWanted runs the gate for an interactive UI change when a trigger is configured; skips with a reason otherwise", () => {
|
|
94
|
+
const w = e2eWanted({ cfg, files: ["web/components/HeroCta.tsx"] });
|
|
95
|
+
assert.equal(w.run, true);
|
|
96
|
+
assert.match(w.reason, /real-browser/);
|
|
97
|
+
assert.equal(e2eWanted({ cfg: parseE2e({}), files: ["web/components/HeroCta.tsx"] }).run, false);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe("fakedPaths and [type:manual] (#5339)", () => {
|
|
102
|
+
it("flags test files that fake or mock the real path, not clean ones or unreadable ones", () => {
|
|
103
|
+
const files = { "a.test.mjs": "const depts = fake_departments();", "b.test.mjs": "vi.mock('./render')", "c.e2e.mjs": "await page.goto(url); expect(film).toExist()", "d.py": "def test(monkeypatch): ..." };
|
|
104
|
+
const read = (p) => { if (!(p in files)) throw new Error("ENOENT"); return files[p]; };
|
|
105
|
+
assert.deepEqual(fakedPaths(["a.test.mjs", "b.test.mjs", "c.e2e.mjs", "d.py", "gone.mjs"], read), ["a.test.mjs", "b.test.mjs", "d.py"]);
|
|
106
|
+
});
|
|
107
|
+
it("contractWantsE2e covers manual", () => {
|
|
108
|
+
assert.equal(contractWantsE2e({ requirements: [{ quote: "Restore works [type:manual]" }] }), true);
|
|
109
|
+
assert.equal(contractWantsE2e({ requirements: [{ quote: "Restore works [type:unit]" }] }), false);
|
|
110
|
+
});
|
|
111
|
+
});
|
package/bin/lean/effects.mjs
CHANGED
|
@@ -23,6 +23,8 @@ import { duplicateExports } from "./postmerge.mjs";
|
|
|
23
23
|
import { englishCopies } from "./i18n.mjs";
|
|
24
24
|
import { scopedChecks } from "./checks.mjs";
|
|
25
25
|
import { makeSequenceLeaseIo } from "./seqlease.mjs";
|
|
26
|
+
import { reserveForBuild } from "./seqreserve.mjs";
|
|
27
|
+
import { parseVersioned } from "./seqversioned.mjs";
|
|
26
28
|
import { followupMap } from "./conformance.mjs";
|
|
27
29
|
import { toolStats } from "./toolstats.mjs";
|
|
28
30
|
import { detectApiShape } from "./apishape.mjs";
|
|
@@ -110,8 +112,9 @@ export const leanSettingsFlags = ({ subagentModel = null, reread = false, guard
|
|
|
110
112
|
};
|
|
111
113
|
|
|
112
114
|
export function makeLeanRunner({ runCli = runCliBackendAsync, probe = systemdRunAvailable, subagentModel = null, sandboxed = inSandbox() } = {}) {
|
|
113
|
-
return async ({ role, issue, cwd, model, resume, system, prompt, readOnly = false, noTools = false, rereadNudge = false, maxTurns = null, agents = null, env = null, idleMs = 0, maxMs = 0, laneLimits = null, control = null, onSpawn = null, contextMax = 0, turnMax = 0, busy = null, busyMs = 0, onIdleExtend = null }) => {
|
|
114
|
-
|
|
115
|
+
return async ({ role, issue, cwd, model, resume, system, prompt, readOnly = false, noTools = false, rereadNudge = false, maxTurns = null, agents = null, env = null, idleMs = 0, maxMs = 0, laneLimits = null, control = null, onSpawn = null, session = null, contextMax = 0, turnMax = 0, busy = null, busyMs = 0, onIdleExtend = null, bin: pinnedBin = null }) => {
|
|
116
|
+
// #5205: a rotation relaunch pins the real claude past the tokenbaton shim; absent, the usual resolution
|
|
117
|
+
const bin = pinnedBin || resolveClaudeCliBinary(cwd) || "claude";
|
|
115
118
|
const caps = getClaudeCliCapabilities(cwd);
|
|
116
119
|
// #4391: custom subagents (the explorer) for the builder session; null leaves argv unchanged
|
|
117
120
|
const flags = [...buildLeanSessionFlags(caps), ...(noTools ? noToolFlags(caps) : readOnly ? buildReadOnlyToolFlags(caps) : []), ...(agents ? ["--agents", JSON.stringify(agents)] : [])];
|
|
@@ -121,7 +124,7 @@ export function makeLeanRunner({ runCli = runCliBackendAsync, probe = systemdRun
|
|
|
121
124
|
const r = await runCli({ spec: { name: `core-${role}` }, userMessage: prompt, systemPrompt: resume ? "" : system,
|
|
122
125
|
args: [String(issue)], cwd, bin, model, maxTurns: caps?.maxTurns ? maxTurns : null, env, sessionFlags: flags, extraArgs: [...(resume ? ["--resume", resume] : []), ...settings],
|
|
123
126
|
logger: { log() {} },
|
|
124
|
-
idleMs, maxMs, stream: idleMs > 0, control, onSpawn, busy, busyMs, onIdleExtend, ...(contextMax > 0 ? { contextMax } : {}), ...(turnMax > 0 ? { turnMax } : {}), wrap: probe() ? (b, a) => wrapLaneLimits(b, a, laneLimits) : null });
|
|
127
|
+
idleMs, maxMs, stream: idleMs > 0, control, onSpawn, session, busy, busyMs, onIdleExtend, ...(contextMax > 0 ? { contextMax } : {}), ...(turnMax > 0 ? { turnMax } : {}), wrap: probe() ? (b, a) => wrapLaneLimits(b, a, laneLimits) : null });
|
|
125
128
|
// #4395: a resumed session's first turn carries the prior history, so only a fresh session reports a baseline.
|
|
126
129
|
return { text: r.text, sessionId: r.sessionId, usage: r.usage, costUsd: r.costUsd, durationMs: r.durationMs, turns: r.turns, model: r.cliModel ?? "default",
|
|
127
130
|
baselineTokens: resume ? null : (r.baselineTokens ?? null), tools: toolStats(r.toolUses) }; // #4410: tool calls per turn, re-reads
|
|
@@ -240,9 +243,10 @@ export function makeHostProbe() {
|
|
|
240
243
|
/**
|
|
241
244
|
* Required status checks for `lane` (#4158): the union of classic branch protection (contexts + checks) and the
|
|
242
245
|
* repository rulesets that apply to the branch (`rules/branches/{lane}`, type required_status_checks). Each source
|
|
243
|
-
* fails independently to [] (
|
|
246
|
+
* fails independently to [] (so one never hides the other); `unreadable` is set when a source failed for a reason other than a 404 (#5382).
|
|
247
|
+
* `requiredChecksFor` is the names only.
|
|
244
248
|
*/
|
|
245
|
-
export async function
|
|
249
|
+
export async function requiredChecksRead({ gh, repo, lane }) {
|
|
246
250
|
const classic = async () => {
|
|
247
251
|
const j = JSON.parse(String(await gh(["api", `repos/${repo}/branches/${lane}/protection/required_status_checks`])));
|
|
248
252
|
return [...(j.contexts ?? []), ...(j.checks ?? []).map((c) => c?.context)];
|
|
@@ -253,11 +257,15 @@ export async function requiredChecksFor({ gh, repo, lane }) {
|
|
|
253
257
|
"--jq", '.[] | select(.type == "required_status_checks") | .parameters.required_status_checks[]?.context']));
|
|
254
258
|
return out.split("\n").map((x) => x.trim());
|
|
255
259
|
};
|
|
256
|
-
|
|
260
|
+
// A 404 is an answer (no protection, no rulesets); any other failure (403 for a non-admin token, network) is an unreadable source.
|
|
261
|
+
let unreadable = false;
|
|
262
|
+
const safe = async (f) => { try { const v = await f(); return Array.isArray(v) ? v : []; } catch (e) { if (!/\b404\b|not found|not protected/i.test(String(e?.message ?? e))) unreadable = true; return []; } };
|
|
257
263
|
const all = [...(await safe(classic)), ...(await safe(rulesets))];
|
|
258
|
-
return [...new Set(all.filter((x) => typeof x === "string" && x))];
|
|
264
|
+
return { checks: [...new Set(all.filter((x) => typeof x === "string" && x))], unreadable };
|
|
259
265
|
}
|
|
260
266
|
|
|
267
|
+
export const requiredChecksFor = async (opts) => (await requiredChecksRead(opts)).checks;
|
|
268
|
+
|
|
261
269
|
/** Combined stdout+stderr kept per declared check command (tail). */
|
|
262
270
|
const CHECK_OUTPUT_CAP = 64000;
|
|
263
271
|
/** #4240: run a forge.yaml declared check command locally (no gh, no Actions); {rc, output}, rc 124 on timeout. `env` (#4323) is merged over process.env. */
|
|
@@ -306,7 +314,16 @@ export function makeGhCache({ root = null, tmp = tmpdir() } = {}) {
|
|
|
306
314
|
|
|
307
315
|
export function makeLeanIo({ repo, subagentModel = readSubagentModel() }) {
|
|
308
316
|
const base = makeIo();
|
|
317
|
+
const seqLeaseIo = makeSequenceLeaseIo(); // #5340: one instance: sequence leases, surface leases and declarations
|
|
309
318
|
const run = (bin) => async (args, opts = {}) => (await pexec(bin, args, { cwd: opts.cwd, maxBuffer: 100 * 1024 * 1024, timeout: 120000, ...(opts.env ? { env: { ...process.env, ...opts.env } } : {}) })).stdout;
|
|
319
|
+
/** #5235: paths the other open PRs on `lane` carry (gh only, no fetch); [] on any failure. */
|
|
320
|
+
const openPrFiles = async (cwd, lane) => {
|
|
321
|
+
try {
|
|
322
|
+
const me = String(await run("git")(["rev-parse", "--abbrev-ref", "HEAD"], { cwd })).trim();
|
|
323
|
+
const prs = JSON.parse(await run("gh")(["pr", "list", "--state", "open", "--base", lane, "--limit", "100", "--json", "headRefName,files"], { cwd }));
|
|
324
|
+
return prs.filter((p) => p?.headRefName !== me).flatMap((p) => (p?.files ?? []).map((f) => String(f?.path ?? "")));
|
|
325
|
+
} catch { return []; }
|
|
326
|
+
};
|
|
310
327
|
return {
|
|
311
328
|
ghCache: (root) => makeGhCache({ root }),
|
|
312
329
|
gh: run("gh"), git: run("git"), docker: run("docker"), killGroup: async (pid, marker) => killLedgerPid(pid, marker), ledger: (opts) => makeLedger(opts), runTmp: makeRunTmp(), host: makeHostProbe(), heavy: makeHeavyIo({ host: makeHostProbe() }), projector: makeProjector({ gh: base.gh }, { repo }), runner: makeLeanRunner({ subagentModel }), waitCiGreen: base.waitCiGreen,
|
|
@@ -366,9 +383,12 @@ export function makeLeanIo({ repo, subagentModel = readSubagentModel() }) {
|
|
|
366
383
|
try { const out = String(await run("gh")(["run", "view", String(runId), "-R", repo, "--log-failed"])); return out.length > 64000 ? out.slice(-64000) : out; } catch { return ""; }
|
|
367
384
|
},
|
|
368
385
|
async transitionLabel(issue, state) { await pexec("bash", [script("transition-label.sh"), String(issue), "-R", repo, state], { timeout: 60000 }); },
|
|
386
|
+
/** Finding lifecycle (#5254): needs-validation to validated / false-positive. */
|
|
387
|
+
async validateLabel(issue, verdict) { await pexec("bash", [script("transition-label.sh"), "--validate", verdict, String(issue), "-R", repo], { timeout: 60000 }); },
|
|
369
388
|
/**
|
|
370
|
-
*
|
|
371
|
-
*
|
|
389
|
+
* Append the parent's deferred items to the aggregates only (scripts/file-deferred-followups.sh: trusted lookup, append,
|
|
390
|
+
* create, duplicate re-check): the release rollup, the batch external aggregate and the batch host aggregate; never a
|
|
391
|
+
* per-parent issue, and an engineering item is rejected (exit 2, #5207). items: [{key, why, class?}]; the key is the
|
|
372
392
|
* item's identity (column 5, column 1 is `-`). milestone / defaultMilestone: the parent's and forge.yaml followups.default_milestone; lane: the release lane of the post-deploy rollup (#4724).
|
|
373
393
|
* batchId: the external aggregate's batch (FORGE_BATCH_ID); rollupLabel: forge.yaml followups.rollup_issue_label (FORGE_ROLLUP_LABEL) (#5078).
|
|
374
394
|
* Returns {key: issueNumber}; throws on exit 2/3/4.
|
|
@@ -405,7 +425,7 @@ export function makeLeanIo({ repo, subagentModel = readSubagentModel() }) {
|
|
|
405
425
|
/** #4375: the repo's learned-pitfall ledger, local only (~/.forge/pitfalls, FORGE_PITFALLS_DIR). */
|
|
406
426
|
pitfalls: makePitfallStore(),
|
|
407
427
|
/** forge#4275: the context pack's facts for one issue (bin/lean/context.mjs), from gh and git only; sources fail independently. */
|
|
408
|
-
contextFacts: (args) => gatherContextFacts({ ...args, io: { gh: run("gh"), git: run("git"), exists: async (p) => existsSync(p) } }),
|
|
428
|
+
contextFacts: (args) => gatherContextFacts({ ...args, io: { gh: run("gh"), git: run("git"), exists: async (p) => existsSync(p), declared: (a) => seqLeaseIo.declared(a) } }), // #5340: in-flight sibling declarations
|
|
409
429
|
/** forge#4195: scripts/hotspots.sh facts for `paths` in cwd (growth since base when given; config = the host forge.yaml, #5163); null on any failure. */
|
|
410
430
|
async hotspots({ cwd, base = null, paths = [], config = null }) {
|
|
411
431
|
const args = [script("hotspots.sh"), ...(config ? ["--config", config] : []), ...(base ? ["--base", base] : []), "--", ...paths];
|
|
@@ -415,11 +435,24 @@ export function makeLeanIo({ repo, subagentModel = readSubagentModel() }) {
|
|
|
415
435
|
enumeratingTests: ({ cwd, paths = [] }) => enumeratingTests({ git: (a) => run("git")(a, { cwd }), cwd, paths }),
|
|
416
436
|
enumeratingMissing: ({ cwd, base }) => missingEntries({ git: (a) => run("git")(a, { cwd }), cwd, base }),
|
|
417
437
|
/** #4322: sequence-numbered files the lane shares with the base (bin/lean/sequence.mjs); snapshot before, verify after a renumber. */
|
|
418
|
-
|
|
438
|
+
// #5340: also against the default branch(es) in `extraBases`, which a milestone lane would otherwise not see
|
|
439
|
+
sequenceCheck: async ({ cwd, base, extraBases = [], versioned }) => {
|
|
440
|
+
const git = (a) => run("git")(a, { cwd });
|
|
441
|
+
const out = [...(await sequenceCollisions({ git, base, versioned }))];
|
|
442
|
+
for (const b of extraBases) { try { out.push(...(await sequenceCollisions({ git, base: b, versioned }))); } catch { /* fail-open */ } }
|
|
443
|
+
return out;
|
|
444
|
+
},
|
|
419
445
|
sequenceSnapshot: ({ cwd, base }) => snapshotLane({ git: (a) => run("git")(a, { cwd }), base }),
|
|
420
|
-
sequenceVerify: ({ cwd, base, before, moves }) => verifyRenumber({ git: (a) => run("git")(a, { cwd }), base, before, moves }),
|
|
446
|
+
sequenceVerify: ({ cwd, base, before, moves, versioned }) => verifyRenumber({ git: (a) => run("git")(a, { cwd }), base, before, moves: moves?.filter((m) => !m.versioned), versioned }),
|
|
421
447
|
/** #4386: the deterministic renumber, sequence-only base-sync resolution, and the host sequence lease at the merge gate. */
|
|
422
|
-
sequenceRenumber: ({ cwd, base, laneRef, regenerate, reserve, openNumbers }) => renumberLane({ git: (a) => run("git")(a, { cwd }), base, cwd, laneRef, regenerate, reserve, openNumbers }),
|
|
448
|
+
sequenceRenumber: ({ cwd, base, laneRef, regenerate, reserve, openNumbers, versioned }) => renumberLane({ git: (a) => run("git")(a, { cwd }), base, cwd, laneRef, regenerate, reserve, openNumbers, versioned }),
|
|
449
|
+
/** #5235: reserve the numbers / versions the frozen contract's deliverables need before the build (bin/lean/seqreserve.mjs); [] on failure. */
|
|
450
|
+
sequenceReserveBuild: ({ cwd, base, lane, repo, issue, deliverables, versioned }) => reserveForBuild({
|
|
451
|
+
git: (a) => run("git")(a, { cwd }), base, deliverables, versioned,
|
|
452
|
+
reserve: (x) => seqLeaseIo.reserve({ repo, lane, issue, ...x }),
|
|
453
|
+
openNumbers: async ({ dir }) => (await openPrFiles(cwd, lane)).filter((f) => dirname(f) === dir).map((f) => Number(seqNumber(f))).filter(Number.isFinite),
|
|
454
|
+
openVersions: async ({ cls }) => { const [c] = parseVersioned([cls]); return (await openPrFiles(cwd, lane)).map((f) => c.re.exec(dirname(f).slice(c.dir ? c.dir.length + 1 : 0).split("/")[0])?.[1]).filter(Boolean).map(Number); },
|
|
455
|
+
}),
|
|
423
456
|
sequenceResolve: ({ cwd, files, partial }) => resolveSequenceConflicts({ git: (a) => run("git")(a, { cwd }), files, partial }),
|
|
424
457
|
/** #4732: numbers the other open PRs on `lane` already carry in `dir` (gh only, no fetch); [] on any failure. */
|
|
425
458
|
async sequenceOpenNumbers({ cwd, lane, dir }) {
|
|
@@ -431,7 +464,7 @@ export function makeLeanIo({ repo, subagentModel = readSubagentModel() }) {
|
|
|
431
464
|
},
|
|
432
465
|
/** #4588: deterministic base-merge resolution of union / JSON-map / generated files (bin/lean/conflictres.mjs). */
|
|
433
466
|
conflictResolve: ({ cwd, files, cfg }) => resolveBaseConflicts({ git: (a) => run("git")(a, { cwd }), cwd, files, cfg }),
|
|
434
|
-
sequenceLease:
|
|
467
|
+
sequenceLease: seqLeaseIo,
|
|
435
468
|
/** #4591: lane-added migrations the repo's generator did not produce (no journal entry or snapshot); [] on failure. */
|
|
436
469
|
/** #4661: plus journal `when` stamps not above the base max (newest-only migrators skip them). */
|
|
437
470
|
migrationGenerator: async ({ cwd, base }) => { const git = (a) => run("git")(a, { cwd }); return [...await generatorProblems({ git, base }), ...await journalOrderProblems({ git, base })]; },
|
package/bin/lean/execution.mjs
CHANGED
|
@@ -137,7 +137,8 @@ export function parseExecution(sec = {}) {
|
|
|
137
137
|
const warmSandboxes = str(s.warm_sandboxes) !== "" && Number.isInteger(wsN) && wsN > 0 ? wsN : 0; // #4912: warm sandboxes the pool agent keeps ready; 0 = off
|
|
138
138
|
const relay = Object.fromEntries(Object.entries(parseRelayCommands(s.relay_commands)).filter(([c]) => CAPABILITY_RE.test(c))); // #4778
|
|
139
139
|
const uw = Number(str(s.unreachable_window_min));
|
|
140
|
-
|
|
140
|
+
// #5094: rotator.mjs reads its per-account quota state; #5205: off/none/false disables auto-detection, anything else is unset (auto)
|
|
141
|
+
const rot = str(s.account_rotator).toLowerCase(), accountRotator = rot === "tokenbaton" ? "tokenbaton" : ["off", "none", "false"].includes(rot) ? "off" : null;
|
|
141
142
|
const unreachableWindowMin = str(s.unreachable_window_min) !== "" && Number.isFinite(uw) && uw >= 0 ? uw : null; // unset: providerLanes defaults to 5
|
|
142
143
|
return { mode, maxRemote, provider, image, secrets, budget, ...(hostCapabilities.length ? { hostCapabilities } : {}), ...(hostCapabilityPatterns.length ? { hostCapabilityPatterns } : {}), ...(endpoint ? { endpoint } : {}), ...(tokenEnv ? { tokenEnv } : {}), ...(tokenFile ? { tokenFile } : {}), ...(cacheStore ? { cacheStore } : {}), ...(allowActions ? { allowActions } : {}), ...(fallbackLocal ? { fallbackLocal } : {}), ...(capacityFallbackAfter !== null ? { capacityFallbackAfter } : {}), ...(heavy !== null ? { heavy } : {}), ...(unreachableWindowMin !== null ? { unreachableWindowMin } : {}), ...(Object.keys(relay).length ? { relay } : {}), ...(warmSandboxes ? { warmSandboxes } : {}), ...(accountRotator ? { accountRotator } : {}) };
|
|
143
144
|
}
|
|
@@ -684,7 +685,16 @@ export function providerLanes({ provider, laneArgs, ledgerFor, env = process.env
|
|
|
684
685
|
: { terminalReason: "needs-human", code: OUTCOME_CODES.SANDBOX_START_FAILED, detail: `sandbox ${id} failed to start: ${errText(e)}` });
|
|
685
686
|
return {
|
|
686
687
|
// #4612: a graceful stop of a live sandbox (the provider's checkpoint stop); false when it has none.
|
|
687
|
-
|
|
688
|
+
// #5241: false leaves its reason on `rec.stopNote`, so the cancel reports a lane it could not stop.
|
|
689
|
+
stopLane: async (n, rec) => {
|
|
690
|
+
const note = (why) => { if (rec && typeof rec === "object") rec.stopNote = why; };
|
|
691
|
+
if (typeof provider.stop !== "function") { note("the provider cannot stop a lane"); return false; }
|
|
692
|
+
if (!rec?.handle) { note("no sandbox handle yet"); return false; }
|
|
693
|
+
let ok = false;
|
|
694
|
+
try { ok = (await provider.stop(rec.handle)) === true; } catch (e) { note(`stop failed: ${e?.message ?? e}`); return false; }
|
|
695
|
+
if (!ok) note((typeof provider.stopReason === "function" ? provider.stopReason(rec.handle) : null) ?? "stop not accepted");
|
|
696
|
+
return ok;
|
|
697
|
+
},
|
|
688
698
|
runOne: async (n, lane, ctx = {}) => {
|
|
689
699
|
const led = ledgerFor(n);
|
|
690
700
|
const base = { provider: provider.name, id: provider.idFor(n), issue: n, startedAt: now() };
|
|
@@ -714,7 +724,13 @@ export function providerLanes({ provider, laneArgs, ledgerFor, env = process.env
|
|
|
714
724
|
adopt: (n, rec, ctx = {}) => adoptSaved(n, rec, ctx),
|
|
715
725
|
};
|
|
716
726
|
async function adoptSaved(n, rec, ctx = {}) {
|
|
717
|
-
|
|
727
|
+
let saved = rec?.handle;
|
|
728
|
+
// #5204: a record saved before its handle (the old dispatcher halted first) finds the sandbox through the lane's ledger,
|
|
729
|
+
// which registers it before it exists: a live one is reattached, a gone one reaped below, never orphaned.
|
|
730
|
+
if (!saved?.id) {
|
|
731
|
+
const id = provider.idFor(n);
|
|
732
|
+
saved = (ledgerFor(n)?.entries("sandbox") ?? []).find((e) => e.value === id && (e.provider ?? e.handle?.provider) === provider.name)?.handle;
|
|
733
|
+
}
|
|
718
734
|
if (!saved?.id || saved.provider !== provider.name) return null;
|
|
719
735
|
// Usage runs from the sandbox's real start (persisted on the handle), not from this adopt.
|
|
720
736
|
const h = { ...saved, ...(Number.isFinite(saved.startedAt) ? {} : Number.isFinite(rec?.startedAt) ? { startedAt: rec.startedAt } : {}) };
|
|
@@ -242,6 +242,45 @@ describe("providerLanes: sandbox ledger and teardown on every exit path (#4253)"
|
|
|
242
242
|
});
|
|
243
243
|
});
|
|
244
244
|
|
|
245
|
+
describe("#5204: a remote lane saved without its handle is reattached or reaped through the sandbox ledger", () => {
|
|
246
|
+
const leftBy = (root, n, provider = "fake") => makeLedger({ root, batch: "bt", lane: `sandbox-${n}`, owner: "orch_old", issue: n, host: HOST, pid: 999999 })
|
|
247
|
+
.register("sandbox", `fake-${n}`, { provider, handle: { provider, id: `fake-${n}`, issue: n, startedAt: 500 } });
|
|
248
|
+
it("a live sandbox is reattached (onLive, then its result) and torn down after", async () => {
|
|
249
|
+
const root = tmpDir("exec-5204-live-");
|
|
250
|
+
leftBy(root, 7);
|
|
251
|
+
const ledgerFor = ledgerIn(root);
|
|
252
|
+
const prov = fakeProvider();
|
|
253
|
+
prov.live.add(7);
|
|
254
|
+
let live = 0;
|
|
255
|
+
const lanes = providerLanes({ provider: prov, laneArgs: () => [], ledgerFor, pollMs: 1, now: () => 500, sleep: async () => { prov.results[7] = { terminalReason: "merged", pr: 4 }; prov.live.delete(7); } });
|
|
256
|
+
const r = await lanes.adopt(7, { startedAt: 1, remote: true }, { onLive: () => { live++; } });
|
|
257
|
+
assert.equal(live, 1, "reattached as a live lane");
|
|
258
|
+
assert.equal(r.terminalReason, "merged");
|
|
259
|
+
assert.equal(r.pr, 4);
|
|
260
|
+
assert.ok(prov.calls.some((c) => c[0] === "teardown" && c[1] === "fake-7"));
|
|
261
|
+
assert.equal(ledgerFor(7).read(), null, "the ledger entry is released");
|
|
262
|
+
});
|
|
263
|
+
it("a gone sandbox is reaped (torn down, ledger released) and the adopt returns null so the lane is requeued", async () => {
|
|
264
|
+
const root = tmpDir("exec-5204-gone-");
|
|
265
|
+
leftBy(root, 8);
|
|
266
|
+
const ledgerFor = ledgerIn(root);
|
|
267
|
+
const prov = fakeProvider();
|
|
268
|
+
const r = await providerLanes({ provider: prov, laneArgs: () => [], ledgerFor, pollMs: 1 }).adopt(8, { startedAt: 1, remote: true });
|
|
269
|
+
assert.equal(r, null);
|
|
270
|
+
assert.ok(prov.calls.some((c) => c[0] === "teardown" && c[1] === "fake-8"), "reaped, never orphaned");
|
|
271
|
+
assert.equal(ledgerFor(8).read(), null);
|
|
272
|
+
});
|
|
273
|
+
it("another provider's ledger entry, or no entry, is not adopted", async () => {
|
|
274
|
+
const root = tmpDir("exec-5204-other-");
|
|
275
|
+
leftBy(root, 9, "other");
|
|
276
|
+
const prov = fakeProvider();
|
|
277
|
+
const lanes = providerLanes({ provider: prov, laneArgs: () => [], ledgerFor: ledgerIn(root), pollMs: 1 });
|
|
278
|
+
assert.equal(await lanes.adopt(9, { remote: true }), null);
|
|
279
|
+
assert.equal(await lanes.adopt(10, { remote: true }), null);
|
|
280
|
+
assert.ok(!prov.calls.some((c) => c[0] === "teardown"));
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
|
|
245
284
|
describe("runner kill: a sandbox left by a dead dispatcher is reaped by gc --apply (#4253)", () => {
|
|
246
285
|
it("lists the stale sandbox, removes the container, releases the ledger; a live one is only reported", async () => {
|
|
247
286
|
const home = tmpDir("exec-gc-");
|
|
@@ -852,6 +891,30 @@ describe("host capabilities in placement (#4542)", () => {
|
|
|
852
891
|
assert.equal(rows.find((r) => r.issue === 5).outcome, "merged");
|
|
853
892
|
});
|
|
854
893
|
|
|
894
|
+
it("#5371 orchestrate: a remote env.validate_placement or mechanical failure is requeued on a different placement", async () => {
|
|
895
|
+
for (const code of ["env.validate_placement", "env.repro_unrunnable"]) {
|
|
896
|
+
const calls = [];
|
|
897
|
+
const rows = await orchestrate({ issues: [5], parallel: 2, recovery: { maxAttempts: 1 }, readBody: async () => "",
|
|
898
|
+
remote: { max: 2, isRemote: () => true, place: () => ({ where: "remote", reason: "mode remote" }), admit: () => ({ ok: true }), onBudget: "stop", costPerMinute: 0 },
|
|
899
|
+
runOne: async (n, _l, ctx = {}) => {
|
|
900
|
+
calls.push([ctx.placement?.where, ctx.recover?.code ?? null]);
|
|
901
|
+
return ctx.recover ? { terminalReason: "merged", pr: 9 } : { terminalReason: "needs-human", code, detail: "x" };
|
|
902
|
+
} });
|
|
903
|
+
assert.deepEqual(calls, [["remote", null], ["local", code]], code);
|
|
904
|
+
assert.equal(rows.find((r) => r.issue === 5).outcome, "merged");
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
it("#5331 orchestrate: a lane whose frozen contract names a tool the sandbox lacks is placed locally before it starts", async () => {
|
|
909
|
+
const calls = [];
|
|
910
|
+
const contract = { validate: [{ id: "V3", command: "promtool check rules a.yml" }] };
|
|
911
|
+
const rows = await orchestrate({ issues: [5], parallel: 2, readBody: async () => "",
|
|
912
|
+
remote: { max: 2, isRemote: () => true, lacks: ["promtool"], contractOf: () => contract, place: () => ({ where: "remote", reason: "mode remote" }), admit: () => ({ ok: true }), onBudget: "stop", costPerMinute: 0 },
|
|
913
|
+
runOne: async (n, _l, ctx = {}) => { calls.push([ctx.placement?.where, ctx.placement?.reason]); return { terminalReason: "merged", pr: 9 }; } });
|
|
914
|
+
assert.deepEqual(calls, [["local", "host tool: sandbox lacks promtool"]]);
|
|
915
|
+
assert.equal(rows.find((r) => r.issue === 5).outcome, "merged");
|
|
916
|
+
});
|
|
917
|
+
|
|
855
918
|
it("orchestrate: a remote lane that ends env.capability_remote is relaunched locally once", async () => {
|
|
856
919
|
const calls = [];
|
|
857
920
|
const rows = await orchestrate({ issues: [5], parallel: 2, recovery: { maxAttempts: 1 }, readBody: async () => "",
|
package/bin/lean/facts.mjs
CHANGED
|
@@ -32,7 +32,7 @@ function clean(raw) {
|
|
|
32
32
|
.filter((f) => f && AT_RE.test(f) && !f.startsWith(".forge-lean/") && !f.split("/").includes("..")), (x) => x).slice(0, FACTS_FILES_MAX);
|
|
33
33
|
const rejected = uniqBy(list(r.rejected).map((x) => ({ approach: one(x?.approach), why: one(x?.why) })).filter((x) => x.approach && x.why), (x) => x.approach).slice(0, FACTS_LIST_MAX);
|
|
34
34
|
const hotspots = uniqBy(list(r.hotspots).map((x) => ({ at: one(x?.at, 200), why: one(x?.why) })).filter((x) => x.at && x.why && AT_RE.test(x.at) && !x.at.split("/").includes("..")), (x) => x.at).slice(0, FACTS_LIST_MAX);
|
|
35
|
-
const baselines = uniqBy(list(r.baselines).map((x) => ({ command: one(x?.command, 200), exit: x?.exit })).filter((x) => x.command && Number.isInteger(x.exit)), (x) => x.command).slice(0, FACTS_LIST_MAX);
|
|
35
|
+
const baselines = uniqBy(list(r.baselines).map((x) => ({ command: one(x?.command, 200), exit: x?.exit, ...(typeof x?.head === "string" && /^[0-9a-f]{7,40}$/.test(x.head) ? { head: x.head } : {}) })).filter((x) => x.command && Number.isInteger(x.exit)), (x) => x.command).slice(0, FACTS_LIST_MAX);
|
|
36
36
|
return { v: 1, files, decisions: strs(r.decisions), rejected, hotspots, conventions: strs(r.conventions), baselines };
|
|
37
37
|
}
|
|
38
38
|
const hasContent = (f) => KINDS.some((k) => f[k].length > 0);
|
|
@@ -41,10 +41,10 @@ const hasContent = (f) => KINDS.some((k) => f[k].length > 0);
|
|
|
41
41
|
* The lane's FORGE:FACTS record, or null when it would carry nothing. `result` is result.json (its `facts` and
|
|
42
42
|
* `validation`), `files` the lane's changed files, `contract` the frozen contract (decision fallback).
|
|
43
43
|
*/
|
|
44
|
-
export function normaliseFacts(result, { files = [], contract = null } = {}) {
|
|
44
|
+
export function normaliseFacts(result, { files = [], contract = null, head = "" } = {}) {
|
|
45
45
|
const raw = result?.facts && typeof result.facts === "object" ? result.facts : {};
|
|
46
46
|
const decisions = list(raw.decisions).some((d) => one(d)) ? raw.decisions : list(contract?.decisions).map((d) => d?.choice);
|
|
47
|
-
const baselines = list(result?.validation).map((v) => ({ command: v?.command, exit: v?.exit }));
|
|
47
|
+
const baselines = list(result?.validation).map((v) => ({ command: v?.command, exit: v?.exit, head })); // #5331: the head the result was recorded on
|
|
48
48
|
const f = clean({ ...raw, decisions, baselines, files });
|
|
49
49
|
return hasContent(f) ? f : null;
|
|
50
50
|
}
|
package/bin/lean/facts.test.mjs
CHANGED
|
@@ -63,4 +63,9 @@ describe("FORGE:FACTS record (#4401)", () => {
|
|
|
63
63
|
assert.deepEqual(l.hotspots, ["- hot spot src/a.js:12: retry loop (#33, PR #101)"]);
|
|
64
64
|
assert.deepEqual(l.baselines, ["- baseline: `node --test a.test.mjs` exit 0 (#33, PR #101)"]);
|
|
65
65
|
});
|
|
66
|
+
it("#5331 baselines record the head they were recorded on; a malformed head is dropped", () => {
|
|
67
|
+
const v = [{ id: "V1", command: "node --test a.test.mjs", exit: 0 }];
|
|
68
|
+
assert.equal(normaliseFacts({ validation: v }, { head: "abc1234" }).baselines[0].head, "abc1234");
|
|
69
|
+
assert.equal("head" in normaliseFacts({ validation: v }, { head: "not a sha" }).baselines[0], false);
|
|
70
|
+
});
|
|
66
71
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
/** Finding lifecycle at close: a `review-finding` issue leaves `needs-validation` as `validated` (merged fix) or `false-positive` (INVALID). */
|
|
4
|
+
export const FINDING_LABEL = "review-finding";
|
|
5
|
+
const VERDICTS = { merged: "CONFIRMED", invalid: "INVALID" };
|
|
6
|
+
|
|
7
|
+
const names = (labels) => (labels ?? []).map((l) => l?.name ?? l);
|
|
8
|
+
export const isFinding = (labels) => names(labels).includes(FINDING_LABEL);
|
|
9
|
+
export const findingVerdict = (reason) => VERDICTS[reason] ?? null;
|
|
10
|
+
|
|
11
|
+
/** Best effort: `{ applied, error? }`; non-findings and unmapped reasons are untouched. transition-label.sh --validate is idempotent. */
|
|
12
|
+
export async function resolveFindingLabel({ io, issue, labels, reason }) {
|
|
13
|
+
const verdict = findingVerdict(reason);
|
|
14
|
+
if (!verdict || !isFinding(labels)) return { applied: false };
|
|
15
|
+
try { await io.validateLabel(issue, verdict); return { applied: true, verdict }; } catch (e) { return { applied: false, error: String(e?.message ?? e).slice(0, 160) }; }
|
|
16
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
import { describe, it } from "node:test";
|
|
4
|
+
import assert from "node:assert/strict";
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
import { resolveFindingLabel, isFinding, findingVerdict } from "./findinglabel.mjs";
|
|
7
|
+
|
|
8
|
+
const fake = (fail) => { const calls = []; return { calls, validateLabel: async (n, v) => { calls.push([n, v]); if (fail) throw new Error("gh down"); } }; };
|
|
9
|
+
const F = [{ name: "review-finding" }, { name: "needs-validation" }];
|
|
10
|
+
|
|
11
|
+
describe("finding close resolves needs-validation (#5254)", () => {
|
|
12
|
+
it("finding close resolves needs-validation: merged finding gets CONFIRMED (validated)", async () => {
|
|
13
|
+
const io = fake();
|
|
14
|
+
assert.equal((await resolveFindingLabel({ io, issue: 7, labels: F, reason: "merged" })).applied, true);
|
|
15
|
+
assert.deepEqual(io.calls, [[7, "CONFIRMED"]]);
|
|
16
|
+
});
|
|
17
|
+
it("finding close resolves needs-validation: invalid finding gets INVALID (false-positive)", async () => {
|
|
18
|
+
const io = fake();
|
|
19
|
+
await resolveFindingLabel({ io, issue: 7, labels: ["review-finding"], reason: "invalid" });
|
|
20
|
+
assert.deepEqual(io.calls, [[7, "INVALID"]]);
|
|
21
|
+
});
|
|
22
|
+
it("non-findings and other reasons are untouched", async () => {
|
|
23
|
+
const io = fake();
|
|
24
|
+
await resolveFindingLabel({ io, issue: 7, labels: [{ name: "bug" }], reason: "merged" });
|
|
25
|
+
await resolveFindingLabel({ io, issue: 7, labels: F, reason: "needs-human" });
|
|
26
|
+
assert.deepEqual(io.calls, []);
|
|
27
|
+
assert.equal(isFinding(undefined), false);
|
|
28
|
+
assert.equal(findingVerdict("merged"), "CONFIRMED");
|
|
29
|
+
});
|
|
30
|
+
it("a failing label call is reported, never thrown", async () => {
|
|
31
|
+
const r = await resolveFindingLabel({ io: fake(true), issue: 7, labels: F, reason: "merged" });
|
|
32
|
+
assert.equal(r.applied, false); assert.match(r.error, /gh down/);
|
|
33
|
+
});
|
|
34
|
+
it("lean.mjs wires both close paths; effects runs transition-label.sh --validate", () => {
|
|
35
|
+
const lean = readFileSync(new URL("./lean.mjs", import.meta.url), "utf8");
|
|
36
|
+
assert.match(lean, /reason: "merged" \}\)/); assert.match(lean, /reason: "invalid" \}\)/);
|
|
37
|
+
assert.match(readFileSync(new URL("./effects.mjs", import.meta.url), "utf8"), /"--validate", verdict/);
|
|
38
|
+
});
|
|
39
|
+
});
|
package/bin/lean/fixround.mjs
CHANGED
|
@@ -15,6 +15,20 @@ export const MECHANICAL_KINDS = Object.freeze(["precheck", "ci", "docs", "struct
|
|
|
15
15
|
export const FIX_PROMPT_MAX = 60000;
|
|
16
16
|
export const FIX_CAPS = Object.freeze({ task: 20000, diff: 24000, contract: 8000, summary: 1500 });
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* #5348: the narrow profile (enumerating and duplicate-export fixes): contract excerpt, failing check output and the named
|
|
20
|
+
* files only. A session starts under NARROW_BASELINE_TOKENS; the prompt gets a quarter of that (NARROW_PROMPT_MAX chars at
|
|
21
|
+
* ~4 chars/token), the rest is the fixed system prompt and tool schemas. The budget test pins the cap.
|
|
22
|
+
*/
|
|
23
|
+
export const NARROW_BASELINE_TOKENS = 12000;
|
|
24
|
+
export const NARROW_PROMPT_MAX = 12000;
|
|
25
|
+
export const NARROW_CAPS = Object.freeze({ task: 6000, contract: 2500, files: 1200 });
|
|
26
|
+
|
|
27
|
+
/** One task for every pending narrow fix of a stage: [{title, text}] -> sections, empty ones dropped. */
|
|
28
|
+
export function mergeNarrowTasks(pending) {
|
|
29
|
+
return (pending ?? []).filter((x) => x && String(x.text ?? "").trim()).map((x) => `### ${x.title}\n${String(x.text).trim()}`).join("\n\n");
|
|
30
|
+
}
|
|
31
|
+
|
|
18
32
|
const FILE_LINE_RE = /[\w.@/-]+\.[A-Za-z0-9]+:\d+/;
|
|
19
33
|
|
|
20
34
|
/** True only for a non-empty list whose every failure (a string, or `f.detail`) cites a `path.ext:N`. */
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
3
|
import { describe, it } from "node:test";
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
|
-
import { MECHANICAL_KINDS, FIX_PROMPT_MAX, citesFileLine, freshFix, issueSummary, capText, TRIGGERS, REWORK_TRIGGERS, firstPassOf, formatFirstPassSummary, sessionCostDelta } from "./fixround.mjs";
|
|
6
|
-
import { fixSessionPrompt, ciFailurePrompt } from "./prompts.mjs";
|
|
5
|
+
import { MECHANICAL_KINDS, FIX_PROMPT_MAX, citesFileLine, freshFix, issueSummary, capText, TRIGGERS, REWORK_TRIGGERS, firstPassOf, formatFirstPassSummary, sessionCostDelta, NARROW_PROMPT_MAX, NARROW_BASELINE_TOKENS, mergeNarrowTasks } from "./fixround.mjs";
|
|
6
|
+
import { fixSessionPrompt, ciFailurePrompt, narrowFixPrompt } from "./prompts.mjs";
|
|
7
7
|
|
|
8
8
|
describe("#4363 fresh fix sessions: which rounds, and the prompt caps", () => {
|
|
9
9
|
it("every mechanical kind is fresh; block/contract/conflict kinds are not", () => {
|
|
@@ -123,3 +123,26 @@ describe("#4987 CI fix prompt: unrelated failures", () => {
|
|
|
123
123
|
assert.match(p, /unknown amendment kinds are rejected/);
|
|
124
124
|
});
|
|
125
125
|
});
|
|
126
|
+
|
|
127
|
+
describe("#5348 narrow fix profile: prompt budget", () => {
|
|
128
|
+
const big = "x".repeat(200000);
|
|
129
|
+
const contract = { requirements: [{ id: "R1", quote: big }], deliverables: Array.from({ length: 200 }, (_, i) => ({ id: `D${i}`, path: `p/${i}.mjs`, change: big })), preserve: [{ id: "P1", what: big }], validate: [{ id: "V1", command: big }] };
|
|
130
|
+
it("stays under the cap and the 12k-token baseline on worst-case inputs (4 chars/token, 8k tokens left for system and tools)", () => {
|
|
131
|
+
const p = narrowFixPrompt({ task: big, contract, files: Array.from({ length: 500 }, (_, i) => `dir/file-${i}.test.mjs`) });
|
|
132
|
+
assert.ok(p.length <= NARROW_PROMPT_MAX, `${p.length} chars`);
|
|
133
|
+
assert.ok(Math.ceil(p.length / 4) + 8000 <= NARROW_BASELINE_TOKENS, "prompt tokens plus the fixed system overhead fit the baseline");
|
|
134
|
+
});
|
|
135
|
+
it("carries the contract excerpt, the failure and the files, and none of the diff, summary or lane text", () => {
|
|
136
|
+
const p = narrowFixPrompt({ task: "enumerating test a.test.mjs misses `foo`", contract: { deliverables: [{ id: "D1", path: "bin/x.mjs", change: "add foo" }], requirements: [{ quote: "SECRET-QUOTE" }] }, files: ["a.test.mjs"] });
|
|
137
|
+
assert.match(p, /bin\/x\.mjs/); assert.match(p, /misses `foo`/); assert.match(p, /- a\.test\.mjs/);
|
|
138
|
+
assert.doesNotMatch(p, /SECRET-QUOTE|## Diff|## Issue/);
|
|
139
|
+
});
|
|
140
|
+
it("is far smaller than the diff-carrying fix prompt", () => {
|
|
141
|
+
const diff = "+line\n".repeat(20000);
|
|
142
|
+
assert.ok(narrowFixPrompt({ task: "t", contract, files: ["a"] }).length < fixSessionPrompt({ task: "t", diff, contract }).length / 2);
|
|
143
|
+
});
|
|
144
|
+
it("mergeNarrowTasks: one task, a section per pending fix, empty ones dropped", () => {
|
|
145
|
+
assert.equal(mergeNarrowTasks([{ title: "A", text: "fix a" }, { title: "B", text: " " }, { title: "C", text: "fix c" }]), "### A\nfix a\n\n### C\nfix c");
|
|
146
|
+
assert.equal(mergeNarrowTasks(null), "");
|
|
147
|
+
});
|
|
148
|
+
});
|
|
@@ -25,6 +25,7 @@ const sources = (d) => readdirSync(d).flatMap((f) => {
|
|
|
25
25
|
/** Strict gh: rejects unknown --json fields the way gh does; REST serves the association. */
|
|
26
26
|
const strictGh = (issues) => async (a) => {
|
|
27
27
|
const j = a.indexOf("--json");
|
|
28
|
+
if (a[0] === "pr" && a[1] === "list") return "[]"; // #5313: open PRs and their closing issues (pr fields, not issue fields)
|
|
28
29
|
if (j >= 0) for (const f of a[j + 1].split(",")) if (!ISSUE_JSON_FIELDS.includes(f)) throw new Error(`Unknown JSON field: "${f}"`);
|
|
29
30
|
if (a[0] === "api") {
|
|
30
31
|
const m = /issues\/(\d+)$/.exec(a[1]);
|
|
@@ -68,7 +69,7 @@ test("orchestrate --add adds an open issue on a gh that rejects unknown fields",
|
|
|
68
69
|
const id = newBatchId();
|
|
69
70
|
openBatch(root, id).writePlan({ repo: "o/r" });
|
|
70
71
|
const io = { gh: strictGh({ 5: { assoc: "OWNER", body: "Blocked by #6" }, 6: { assoc: "OWNER" }, 9: { assoc: "NONE", body: "Blocked by #6" } }) };
|
|
71
|
-
const out = await orchestrateFromCli(["--add", id, "5", "6", "9"], { io });
|
|
72
|
+
const out = await orchestrateFromCli(["--add", id, "5", "6", "9"], { io }).catch((e) => { if (e.code === "batch.not-hosted") return e.result; throw e; }); // #5314: unhosted add fails loudly, result rides the error
|
|
72
73
|
assert.ok(!out.skipped.some((s) => s.reason === "unreadable"), JSON.stringify(out.skipped));
|
|
73
74
|
assert.deepEqual(out.added, [5, 6, 9]);
|
|
74
75
|
assert.deepEqual(out.edges, [{ from: 5, to: 6 }]); // the untrusted #9 adds no edge
|