forgedock 1.56.0 → 1.58.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/bin/config-schema.mjs +1 -1
- package/bin/engine/outcome-codes.mjs +2 -1
- package/bin/engine/phases.mjs +4 -3
- package/bin/engine-cli.mjs +48 -12
- package/bin/forgedock.mjs +52 -3
- package/bin/gc.mjs +43 -6
- package/bin/help-text.mjs +4 -2
- package/bin/lean/batch-health.mjs +5 -1
- package/bin/lean/batch-health.test.mjs +7 -1
- package/bin/lean/batch.mjs +7 -2
- package/bin/lean/batch.test.mjs +45 -0
- package/bin/lean/conformance.e2e.test.mjs +3 -2
- package/bin/lean/conformance.mjs +118 -20
- package/bin/lean/conformance.test.mjs +172 -3
- package/bin/lean/decisions.mjs +98 -1
- package/bin/lean/decisions.test.mjs +30 -1
- package/bin/lean/depcache.mjs +124 -13
- package/bin/lean/depcache.test.mjs +121 -3
- package/bin/lean/design-gate.mjs +144 -0
- package/bin/lean/design-gate.test.mjs +169 -0
- package/bin/lean/effects-cap.test.mjs +17 -0
- package/bin/lean/effects.mjs +58 -13
- package/bin/lean/heavy.mjs +25 -8
- package/bin/lean/hostload.test.mjs +28 -0
- package/bin/lean/intake.mjs +97 -0
- package/bin/lean/intake.test.mjs +105 -0
- package/bin/lean/interfaces.mjs +181 -0
- package/bin/lean/interfaces.test.mjs +192 -0
- package/bin/lean/issuewatch-install.mjs +52 -12
- package/bin/lean/issuewatch-install.test.mjs +50 -0
- package/bin/lean/issuewatch-parity.mjs +16 -3
- package/bin/lean/issuewatch-parity.test.mjs +32 -0
- package/bin/lean/issuewatch-reconcile.mjs +29 -1
- package/bin/lean/issuewatch-reconcile.test.mjs +21 -0
- package/bin/lean/issuewatch.mjs +34 -3
- package/bin/lean/issuewatch.test.mjs +49 -1
- package/bin/lean/lanecheck.test.mjs +15 -4
- package/bin/lean/lean.mjs +110 -24
- package/bin/lean/lean.test.mjs +183 -4
- package/bin/lean/orchestrate-blocked.test.mjs +18 -2
- package/bin/lean/orchestrate-owned.test.mjs +14 -5
- package/bin/lean/orchestrate.mjs +26 -4
- package/bin/lean/orphan-pr.mjs +3 -2
- package/bin/lean/orphan-pr.test.mjs +8 -1
- package/bin/lean/pagegate.mjs +35 -12
- package/bin/lean/pagegate.test.mjs +39 -1
- package/bin/lean/preflight.mjs +35 -1
- package/bin/lean/preflight.test.mjs +27 -1
- package/bin/lean/prompts.mjs +2 -1
- package/bin/lean/reap.test.mjs +39 -0
- package/bin/lean/recovery.test.mjs +28 -3
- package/bin/lean/release-config.mjs +169 -0
- package/bin/lean/release-config.test.mjs +132 -0
- package/bin/lean/release-control.mjs +171 -0
- package/bin/lean/release-control.test.mjs +167 -0
- package/bin/lean/release-deploy.mjs +209 -0
- package/bin/lean/release-deploy.test.mjs +217 -0
- package/bin/lean/release-fence.mjs +50 -0
- package/bin/lean/release-fence.test.mjs +105 -0
- package/bin/lean/release-flakes.mjs +139 -0
- package/bin/lean/release-flakes.test.mjs +116 -0
- package/bin/lean/release-gates.mjs +230 -0
- package/bin/lean/release-gates.test.mjs +146 -0
- package/bin/lean/release-ledger.mjs +176 -0
- package/bin/lean/release-ledger.test.mjs +226 -0
- package/bin/lean/release-minutes.mjs +102 -0
- package/bin/lean/release-minutes.test.mjs +107 -0
- package/bin/lean/release-nightly.mjs +75 -0
- package/bin/lean/release-nightly.test.mjs +48 -0
- package/bin/lean/release-postmerge.mjs +8 -2
- package/bin/lean/release-review.e2e.test.mjs +1 -0
- package/bin/lean/release-review.mjs +54 -7
- package/bin/lean/release-review.test.mjs +76 -7
- package/bin/lean/release-status.mjs +300 -0
- package/bin/lean/release-status.test.mjs +220 -0
- package/bin/lean/release-unitmap.mjs +35 -0
- package/bin/lean/release-unitmap.test.mjs +41 -0
- package/bin/lean/release-verify.mjs +221 -0
- package/bin/lean/release-verify.test.mjs +176 -0
- package/bin/lean/release.mjs +244 -22
- package/bin/lean/release.test.mjs +44 -0
- package/bin/lean/render.mjs +3 -1
- package/bin/lean/run-issue-placement.test.mjs +82 -0
- package/bin/lean/sandbox-remote.mjs +16 -0
- package/bin/lean/schedd.mjs +1 -1
- package/bin/lean/seam.mjs +115 -0
- package/bin/lean/seam.test.mjs +118 -0
- package/bin/lean/selftest-journey.mjs +40 -2
- package/bin/lean/selftest-journey.test.mjs +43 -3
- package/bin/lean/statuscomment.mjs +168 -0
- package/bin/lean/statuscomment.test.mjs +133 -0
- package/bin/lean/ui-quality.mjs +57 -0
- package/bin/lean/ui-quality.test.mjs +55 -0
- package/bin/lean/visual-gate.test.mjs +63 -0
- package/bin/pool/agent.mjs +16 -2
- package/bin/pool/router.mjs +5 -1
- package/bin/review-staging.mjs +5 -3
- package/bin/stats/card.mjs +117 -0
- package/bin/stats/card.test.mjs +109 -0
- package/bin/stats/conformance-outcomes.test.mjs +2 -1
- package/bin/stats/depth.mjs +1 -1
- package/bin/stats/gh-retry.test.mjs +152 -0
- package/bin/stats/github-source.mjs +147 -14
- package/bin/stats/index.mjs +35 -2
- package/bin/stats/stats.test.mjs +31 -3
- package/bin/vendor/js-yaml/LICENSE +21 -0
- package/bin/vendor/js-yaml/PIN.md +7 -0
- package/bin/vendor/js-yaml/js-yaml.mjs +3851 -0
- package/commands/design-render-critique-loop.md +2 -0
- package/commands/design.md +2 -0
- package/commands/issue.md +1 -1
- package/commands/milestone.md +1 -1
- package/commands/review-pr-agents/frontend.md +1 -0
- package/commands/review-pr-staging.md +5 -0
- package/docs/CONFIG.md +95 -2
- package/docs/ISSUE-WATCH.md +7 -0
- package/docs/OUTCOME-CODES.md +1 -0
- package/docs/STATS.md +10 -0
- package/docs/design/visual-gate.md +25 -0
- package/docs/eval/adversarial-bench.md +2 -2
- package/docs/eval/corpus/adversarial-v1.json +3 -3
- package/docs/site/start-a-new-project.md +7 -0
- package/docs/spec/forge-protocol-v1.md +31 -0
- package/package.json +1 -1
- package/pool/README.md +2 -0
- package/scripts/acceptance-red-green.sh +15 -1
- package/scripts/acceptance-red-green.test.sh +12 -0
- package/scripts/bench-adversarial.mjs +4 -0
- package/scripts/bench-lightlane.mjs +4 -1
- package/scripts/bootstrap-create.mjs +8 -2
- package/scripts/ci-local/scoping.mjs +19 -0
- package/scripts/ci-local.test.sh +16 -3
- package/scripts/fixtures/ci-local/gha-dorny/.github/workflows/ci.yml +4 -0
- package/scripts/plan-validate-live.mjs +9 -6
- package/scripts/review-prepare.sh +7 -1
- package/scripts/review-roster.sh +5 -2
- package/scripts/review-roster.test.sh +9 -0
- package/scripts/visual-gate.mjs +64 -0
- package/templates/bootstrap/technical-spike.md +17 -0
- package/templates/contracts/seam-check.mjs +236 -0
package/bin/config-schema.mjs
CHANGED
|
@@ -13,7 +13,7 @@ export const TOP_LEVEL = [
|
|
|
13
13
|
"hygiene", "pipeline", "execution", "engine", "prod_watch", "selftest", "release", "issue_watch", "followups", "rollouts",
|
|
14
14
|
"post_deploy", "events", "lean", "stats", "verify", "ci", "env", "build", "decomposition", "services", "review", "devdocs",
|
|
15
15
|
"verification", "billing", "adaptive_scripts", "branding", "marketing", "acceptance_probe", "attribution", "autopilot",
|
|
16
|
-
"deploy", "gate", "experiment", "learned", "maintenance", "milestones", "pattern_feeds", "topology", "validate",
|
|
16
|
+
"deploy", "design", "gate", "experiment", "learned", "maintenance", "milestones", "pattern_feeds", "topology", "validate",
|
|
17
17
|
];
|
|
18
18
|
|
|
19
19
|
/** Sections whose direct children are a closed set: another child is an unknown key. */
|
|
@@ -68,6 +68,7 @@ export const OUTCOME_CODES = Object.freeze({
|
|
|
68
68
|
SANDBOX_UNREACHABLE: "sandbox.unreachable", // forge#4672: the sandbox provider stayed unreachable past execution.unreachable_window_min; deferred, the sandbox is kept for adopt
|
|
69
69
|
LEASE_HELD: "lease.held",
|
|
70
70
|
DEPENDENCY_OPEN: "dependency.open",
|
|
71
|
+
DESIGN_SPEC_REQUIRED: "design.spec_required", // forge#5330: a page under forge.yaml design.routes has no FORGE:DESIGN_SPEC and design.gate is blocking; needs-human until /design approves a spec
|
|
71
72
|
DESIGN_INVALIDATED: "design.invalidated", // forge#5342: a lane found the plan wrong; one spike amendment filed, siblings held; the rework-share rollup counts it
|
|
72
73
|
DEPENDENCY_UNREADABLE: "dependency.unreadable",
|
|
73
74
|
DEPENDENCY_BLOCKED: "dependency.blocked",
|
|
@@ -235,7 +236,7 @@ function classifyNeedsHumanBase(row) {
|
|
|
235
236
|
if (outcome === "budget-exceeded") return "recoverable";
|
|
236
237
|
if (outcome !== "needs-human") return "terminal";
|
|
237
238
|
if (HUMAN_CODES.includes(row.code)) return "human";
|
|
238
|
-
if (row.code === OUTCOME_CODES.CONTRACT_INVALID) return
|
|
239
|
+
if (row.code === OUTCOME_CODES.CONTRACT_INVALID) return "recoverable"; // #5623: a fresh plan (one recovery requeue) before a person is asked
|
|
239
240
|
return RECOVERABLE_CODES.includes(row.code) ? "recoverable" : "terminal";
|
|
240
241
|
}
|
|
241
242
|
|
package/bin/engine/phases.mjs
CHANGED
|
@@ -15,6 +15,7 @@ import { PHASE_MARKERS } from "../../packages/protocol/src/phases.js";
|
|
|
15
15
|
// forge#3833: closed outcome-code enum; every code below comes from structured evidence, never `detail` prose.
|
|
16
16
|
import { OUTCOME_CODES as OC } from "./outcome-codes.mjs";
|
|
17
17
|
import { parseState } from "./state.mjs";
|
|
18
|
+
import { hasSection } from "../lean/statuscomment.mjs";
|
|
18
19
|
|
|
19
20
|
// forge#2261: "engine-error" is a distinct terminal reason for engine/tool-level
|
|
20
21
|
// failures (e.g. an exhausted retry loop where the runner itself never once
|
|
@@ -254,12 +255,12 @@ function hasPhaseComplete(comments) {
|
|
|
254
255
|
}
|
|
255
256
|
|
|
256
257
|
/**
|
|
257
|
-
* close.md's own idempotency key: a trusted FORGE:TRAJECTORY comment. Shared by close.reconcile
|
|
258
|
+
* close.md's own idempotency key: a trusted FORGE:TRAJECTORY comment (or, #5592, a section of the FORGE:STATUS comment). Shared by close.reconcile
|
|
258
259
|
* and close.detectOutcome so the two cannot drift. Throws on fetch error; callers fail closed.
|
|
259
260
|
*/
|
|
260
261
|
async function hasTrajectory(issue, io) {
|
|
261
262
|
const { comments } = await issueMarkers(issue, io);
|
|
262
|
-
return comments.some((b) =>
|
|
263
|
+
return comments.some((b) => hasSection(b, "FORGE:TRAJECTORY"));
|
|
263
264
|
}
|
|
264
265
|
|
|
265
266
|
/**
|
|
@@ -269,7 +270,7 @@ async function hasTrajectory(issue, io) {
|
|
|
269
270
|
*/
|
|
270
271
|
async function hasInvestigationCloseEvidence(issue, io) {
|
|
271
272
|
const { comments } = await issueMarkers(issue, io);
|
|
272
|
-
return comments.some((b) =>
|
|
273
|
+
return comments.some((b) => hasSection(b, "FORGE:TRAJECTORY"))
|
|
273
274
|
|| hasPhaseComplete(sliceToCurrentCycle(comments));
|
|
274
275
|
}
|
|
275
276
|
|
package/bin/engine-cli.mjs
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
import { validateForgeYaml, formatFinding } from "./config-schema.mjs";
|
|
8
8
|
import { parseDocsConfig } from "./lean/docsgate.mjs";
|
|
9
9
|
import { parsePagesConfig, PAGE_RE, designHold } from "./lean/pagegate.mjs";
|
|
10
|
+
import { parseDesignConfig } from "./lean/design-gate.mjs";
|
|
10
11
|
import { execFileSync } from "node:child_process";
|
|
12
|
+
import { mapLimit } from "./lean/pmap.mjs";
|
|
11
13
|
import { execFile, spawn } from "node:child_process";
|
|
12
14
|
import { promisify } from "node:util";
|
|
13
15
|
import { readdirSync, statSync, readFileSync } from "node:fs";
|
|
@@ -582,9 +584,10 @@ export function readEnvConfig(cwd = process.cwd()) {
|
|
|
582
584
|
let appPages = false; // #5428: default-on trigger: the repo tracks Next app/**/page.* files
|
|
583
585
|
try { appPages = String(execFileSync("git", ["ls-files", "--", "*page.*"], { cwd, encoding: "utf8", timeout: 10000, stdio: ["ignore", "pipe", "ignore"] })).split("\n").some((f) => PAGE_RE.test(f)); } catch { /* not a git checkout: off */ }
|
|
584
586
|
const pg = parsePagesConfig(y?.pages, { hasAppPages: appPages }); // #5428: forge.yaml pages: (off for repos without pages)
|
|
587
|
+
const dg = parseDesignConfig(y?.design); // #5330: forge.yaml design: (system always read; routes/gate opt in the design gate)
|
|
585
588
|
const kb = typeof e.sparse_max_kb === "string" && /^\d+$/.test(e.sparse_max_kb.trim()) ? Number(e.sparse_max_kb) : e.sparse_max_kb;
|
|
586
589
|
return { ...(s(e.toolchain) ? { toolchainOverride: s(e.toolchain) } : {}), ...(s(e.setup) ? { envSetup: s(e.setup) } : {}),
|
|
587
|
-
...(Number.isInteger(kb) && kb >= 0 ? { sparseMaxKb: kb } : {}), ...(Object.keys(runners).length ? { testRunners: runners } : {}), ...(recipes.length ? { validateRecipes: recipes } : {}), ...(cf && Object.keys(cf).length ? { coupledFiles: cf } : {}), ...(rr ? { routeReachability: rr } : {}), ...(dc ? { docsConfig: dc } : {}), ...(pg ? { pagesConfig: pg } : {}), ...(pp && Object.keys(pp).length ? { prodParity: pp } : {}) };
|
|
590
|
+
...(Number.isInteger(kb) && kb >= 0 ? { sparseMaxKb: kb } : {}), ...(Object.keys(runners).length ? { testRunners: runners } : {}), ...(recipes.length ? { validateRecipes: recipes } : {}), ...(cf && Object.keys(cf).length ? { coupledFiles: cf } : {}), ...(rr ? { routeReachability: rr } : {}), ...(dc ? { docsConfig: dc } : {}), ...(pg ? { pagesConfig: pg } : {}), ...(dg ? { designConfig: dg } : {}), ...(pp && Object.keys(pp).length ? { prodParity: pp } : {}) };
|
|
588
591
|
} catch { return {}; }
|
|
589
592
|
}
|
|
590
593
|
export const ENGINE_PATHS = ["core", "full", "lean", "auto"];
|
|
@@ -934,7 +937,7 @@ export function lastLocalRun(dir) {
|
|
|
934
937
|
*/
|
|
935
938
|
export async function runFromCli(argv, deps = {}) {
|
|
936
939
|
const issue = parseInt(argv[0], 10);
|
|
937
|
-
if (!Number.isInteger(issue)) throw new Error("usage: forgedock run-issue <issue-number> [--lane <lane>] [--lane-override] [--path core|full] [--recover <code> [--recover-attempt n] [--recover-nonfinal]] [--retry] [--wait-lease]");
|
|
940
|
+
if (!Number.isInteger(issue)) throw new Error("usage: forgedock run-issue <issue-number> [--lane <lane>] [--lane-override] [--path core|full] [--recover <code> [--recover-attempt n] [--recover-nonfinal]] [--retry] [--wait-lease] [--local]");
|
|
938
941
|
assertOpenCodeNativeRuntime({ operation: "forgedock run-issue" });
|
|
939
942
|
const lane = flag(argv, "--lane");
|
|
940
943
|
if (argv.includes("--lane") && (!lane || lane.startsWith("--"))) throw new Error("--lane requires a value: staging or milestone/<slug>");
|
|
@@ -981,6 +984,26 @@ export async function runFromCli(argv, deps = {}) {
|
|
|
981
984
|
return res;
|
|
982
985
|
}
|
|
983
986
|
await assertLaneNotDefault(io, lane, repo);
|
|
987
|
+
// #5542: placement. A lane already placed (--placement, a batch lane, --adopt, --recover) or forced local runs here; otherwise a
|
|
988
|
+
// remote or hybrid `execution:` hands the single issue to the same batch placement `orchestrate` uses.
|
|
989
|
+
if (enginePath !== "full") {
|
|
990
|
+
const exec = deps.execution !== undefined ? deps.execution : readExecution();
|
|
991
|
+
const placed = placementWhere || argv.includes("--adopt") || recover || (deps.env ?? process.env).FORGEDOCK_BATCH_ID;
|
|
992
|
+
const wantsRemote = exec && (exec.mode === "remote" || (exec.mode === "hybrid" && Number.isInteger(exec.maxRemote) && exec.maxRemote >= 1));
|
|
993
|
+
if (argv.includes("--local")) console.log("placement: local (--local)");
|
|
994
|
+
else if (!placed && wantsRemote) {
|
|
995
|
+
console.log(`placement: ${exec.mode} execution (${exec.provider}); placed by the batch dispatcher`);
|
|
996
|
+
const res = await orchestrateFromCli([String(issue), "--parallel", "1", "--foreground", ...(repo ? ["--repo", repo] : []), ...(lane ? ["--lane", lane] : []),
|
|
997
|
+
...(laneOverride ? ["--lane-override"] : []), ...(model ? ["--model", model] : [])], deps);
|
|
998
|
+
const row = res?.rows?.find((r) => r.issue === issue) ?? res?.rows?.[0] ?? {};
|
|
999
|
+
let laneRes = null; // the lane's own result file carries cost_usd / wall_ms / light* that the benchmarks read
|
|
1000
|
+
try { const bm = await import("./lean/batch.mjs"); laneRes = JSON.parse(readFileSync(bm.openBatch(deps.batchRoot ?? bm.batchRoot(), res.batch).resultFile(issue), "utf8")); } catch { laneRes = null; }
|
|
1001
|
+
const metrics = Object.fromEntries(["cost_usd", "wall_ms", "model_ms", "light", "light_eligibility", "light_upgrade"].filter((k) => row[k] !== undefined).map((k) => [k, row[k]])); // the batch row carries them when no lane file exists (sandbox lanes)
|
|
1002
|
+
const out = { ...metrics, ...(laneRes ?? {}), terminalReason: laneRes?.terminalReason ?? row.outcome ?? "engine-error", ...(row.pr != null && laneRes?.pr == null ? { pr: row.pr } : {}), ...(row.detail && !laneRes?.detail ? { detail: row.detail } : {}), ...(row.code && !laneRes?.code ? { code: row.code } : {}), ...(row.placement ? { placement: row.placement } : {}) };
|
|
1003
|
+
console.log(`issue #${issue} → ${out.terminalReason}`);
|
|
1004
|
+
return report(out);
|
|
1005
|
+
} else if (!placed) console.log(`placement: local (${exec ? `execution mode ${exec.mode}` : "no execution configured"})`);
|
|
1006
|
+
}
|
|
984
1007
|
const runIssueFn = deps.runIssue ?? runIssue;
|
|
985
1008
|
const agentId = `cli_${sanitizeLeaseHost(hostname())}_${process.pid}`;
|
|
986
1009
|
// Injectable for tests (forge#2175) — defaults to the real ~/.forge/runs dir.
|
|
@@ -1039,7 +1062,7 @@ export async function runFromCli(argv, deps = {}) {
|
|
|
1039
1062
|
...(rotatorKind({ execution: readExecution(process.cwd()), env }) ? { accountRotator: rotatorKind({ execution: readExecution(process.cwd()), env }) } : {}), // #5094, #5205: detected
|
|
1040
1063
|
onTeardown: (fn) => { teardown = fn; }, ...(env.FORGEDOCK_BATCH_ID ? { batchId: env.FORGEDOCK_BATCH_ID } : {}), ...(placement ? { placement } : {}), ...(recover ? { recover } : {}),
|
|
1041
1064
|
emitTelemetry: deps.emitTelemetry ?? composeEmit(makeEmitTelemetry({ repo: leanRepo }), makeEventEmitter({ repo: leanRepo, config: readEvents() }).emit),
|
|
1042
|
-
admission: readAdmission(), heavy: readHeavy(), ...readCoreLimits(), ...readEnvConfig(), ...(readMergeWait() ? { mergeWait: readMergeWait() } : {}), ...(readConformanceMode() ? { conformance: readConformanceMode() } : {}), ...(readConformanceKinds() ? { conformanceKinds: readConformanceKinds() } : {}), ...(readConformanceMutation() ? { conformanceMutation: "report" } : {}), ...(readContextPack() ? { contextPack: readContextPack() } : {}), ...(readSequenceVersioned() ? { sequenceVersioned: readSequenceVersioned() } : {}), ...(readSharedSurfaces() ? { sharedSurfaces: readSharedSurfaces() } : {}), ...(readReviewIncomplete() ? { reviewIncomplete: readReviewIncomplete() } : {}), ...(readLaneInstructions() ? { laneInstructions: readLaneInstructions() } : {}), ...(readReproTest() ? { reproTest: readReproTest() } : {}), ...(readReproQuality() ? { reproQuality: readReproQuality() } : {}), ...(readExplore() ? { explore: readExplore() } : {}), ...(readExperiment() ? { experiment: readExperiment() } : {}), light: readLight(), ...(readCloseParent() ? { closeParent: true } : {}), ...(readReviewTrigger() ? { reviewTrigger: readReviewTrigger() } : {}), ...(readVerify() ? { verify: readVerify() } : {}), ...readPrecheckOptions(), ...(model ? { builderModel: model } : {}), ...(readLeanSetting("reviewer_model") ? { reviewerModel: readLeanSetting("reviewer_model") } : {}), ...(readFixModel() ? { fixModel: readFixModel() } : {}), ...(readBuilderRouting() ? { builderRouting: readBuilderRouting() } : {}), ...(readVerifier() ? { verifier: readVerifier() } : {}), ...(readHostCaps() ? { hostCaps: readHostCaps() } : {}), ...readRelayCaps(), ...(readSequenceRegenerate() ? { sequenceRegenerate: readSequenceRegenerate() } : {}), ...(readBaseMerge() ? { baseMerge: readBaseMerge() } : {}), ...(readFollowupsDefaultMilestone() ? { followupsDefaultMilestone: readFollowupsDefaultMilestone() } : {}), ...(readFollowupsRollupLabel() ? { followupsRollupLabel: readFollowupsRollupLabel() } : {}) });
|
|
1065
|
+
admission: readAdmission(), heavy: readHeavy(), ...readCoreLimits(), ...readEnvConfig(), ...(readMergeWait() ? { mergeWait: readMergeWait() } : {}), ...(readConformanceMode() ? { conformance: readConformanceMode() } : {}), ...(readConformanceKinds() ? { conformanceKinds: readConformanceKinds() } : {}), ...(readConformanceMutation() ? { conformanceMutation: "report" } : {}), ...(readContextPack() ? { contextPack: readContextPack() } : {}), ...(readSequenceVersioned() ? { sequenceVersioned: readSequenceVersioned() } : {}), ...(readSharedSurfaces() ? { sharedSurfaces: readSharedSurfaces() } : {}), ...(readReviewIncomplete() ? { reviewIncomplete: readReviewIncomplete() } : {}), ...(readLaneInstructions() ? { laneInstructions: readLaneInstructions() } : {}), ...(readReproTest() ? { reproTest: readReproTest() } : {}), ...(readReproQuality() ? { reproQuality: readReproQuality() } : {}), ...(readExplore() ? { explore: readExplore() } : {}), ...(readExperiment() ? { experiment: readExperiment() } : {}), light: readLight(), ...(readCloseParent() ? { closeParent: true } : {}), ...(readReviewTrigger() ? { reviewTrigger: readReviewTrigger() } : {}), ...(readVerify() ? { verify: readVerify() } : {}), ...readPrecheckOptions(), ...(model ? { builderModel: model } : {}), ...(readLeanSetting("reviewer_model") ? { reviewerModel: readLeanSetting("reviewer_model") } : {}), ...(readFixModel() ? { fixModel: readFixModel() } : {}), ...(readBuilderRouting() ? { builderRouting: readBuilderRouting() } : {}), ...(readVerifier() ? { verifier: readVerifier() } : {}), ...(readHostCaps() ? { hostCaps: readHostCaps() } : {}), ...readRelayCaps(), ...(readSequenceRegenerate() ? { sequenceRegenerate: readSequenceRegenerate() } : {}), ...(readBaseMerge() ? { baseMerge: readBaseMerge() } : {}), ...(readFollowupsDefaultMilestone() ? { followupsDefaultMilestone: readFollowupsDefaultMilestone() } : {}), ...(readFollowupsRollupLabel() ? { followupsRollupLabel: readFollowupsRollupLabel() } : {}), ...(Number.isInteger(Number(readLeanSetting("contract_max_corrections"))) && Number(readLeanSetting("contract_max_corrections")) >= 1 ? { contractMaxCorrections: Number(readLeanSetting("contract_max_corrections")) } : {}) });
|
|
1043
1066
|
} catch (e) { if (!interrupted) report({ terminalReason: "engine-error", detail: String(e?.message ?? e).slice(0, 500) }); throw e; }
|
|
1044
1067
|
finally { if (!interrupted) for (const [sig, f] of Object.entries(handlers)) off(sig, f); }
|
|
1045
1068
|
if (interrupted) return lres; // the signal handler reported and exits
|
|
@@ -1461,7 +1484,13 @@ async function holdBatch({ op, id, tokens, root, viaDaemon = null, takeover = nu
|
|
|
1461
1484
|
if (!res) {
|
|
1462
1485
|
const b = (await import("./lean/batch.mjs")).openBatch(root, id);
|
|
1463
1486
|
if (!b.exists()) throw new Error(`no batch ${id} in ${root}`);
|
|
1464
|
-
res = { changed: op === "hold" ? b.holdIssues(issues, meta) : b.releaseIssues(issues) };
|
|
1487
|
+
res = { changed: op === "hold" ? b.holdIssues(issues, meta) : b.releaseIssues(issues), held: null };
|
|
1488
|
+
}
|
|
1489
|
+
if (op === "hold" && !res.changed?.length) { // #5526: nothing newly held: name the issues that already are
|
|
1490
|
+
let held = res.held;
|
|
1491
|
+
if (!Array.isArray(held)) { try { held = (await import("./lean/batch.mjs")).openBatch(root, id).readHeld(); } catch { held = []; } }
|
|
1492
|
+
const already = issues.filter((n) => held.includes(n));
|
|
1493
|
+
if (already.length) { print(`batch ${id}: already held ${already.map((n) => `#${n}`).join(" ")}`); return { ok: true, batch: id, changed: [], alreadyHeld: already }; }
|
|
1465
1494
|
}
|
|
1466
1495
|
if (op === "release" && takeover) { // #5241: a released issue deferred on a cancelled batch's lease is requeued at once
|
|
1467
1496
|
const batchMod = await import("./lean/batch.mjs"), b = batchMod.openBatch(root, id), st = b.store.load(), repo = b.readPlan()?.repo ?? null;
|
|
@@ -1765,12 +1794,13 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
1765
1794
|
if (argv.includes("--force") && (!force || force.startsWith("--"))) throw new Error("--force requires a reason: --force \"<why the unmet dependencies are acceptable>\"");
|
|
1766
1795
|
{ // #5442: page work waits for an approved design: a design:* issue is never dispatched (--force does not lift it)
|
|
1767
1796
|
const held = new Map();
|
|
1768
|
-
|
|
1797
|
+
// #5592: bounded-concurrency label reads, not one serial gh call per issue (starved admission on a loaded host)
|
|
1798
|
+
const hs = await mapLimit(issues, 6, async (n) => {
|
|
1769
1799
|
let v = null;
|
|
1770
1800
|
try { v = JSON.parse(await io.gh(["issue", "view", String(n), "-R", repo, "--json", "labels"])); } catch { v = null; }
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
}
|
|
1801
|
+
return designHold(v?.labels);
|
|
1802
|
+
});
|
|
1803
|
+
issues.forEach((n, i) => { if (hs[i]) held.set(n, hs[i]); });
|
|
1774
1804
|
for (const [n, h] of held) sink.line(`skipped: #${n} design_pending (${h}); run /design, design:approved lifts the hold`);
|
|
1775
1805
|
if (held.size) {
|
|
1776
1806
|
if (held.size === issues.length) throw new Error(`every issue is design_pending (${[...held.values()].join(", ")}); run /design first`);
|
|
@@ -1885,7 +1915,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
1885
1915
|
lanes = { adopt: null, runOne: (n, ln, ctx = {}) => runCore({ issue: n, repo, lane: ln, deferPostRun: true, // #5437: orchestrate runs result.postRun once the slot is free
|
|
1886
1916
|
laneOverride, ...(ctx.placement ? { placement: { ...ctx.placement, mode: execMode() } } : {}), ...(ctx.recover ? { recover: ctx.recover } : {}), branches, cwd, dir, io: leanIo, agentId: `orch_${process.pid}_${n}`, emitTelemetry, batchId: batch.id,
|
|
1887
1917
|
...(rotatorKind({ execution: readExecution(cwd), env }) ? { accountRotator: rotatorKind({ execution: readExecution(cwd), env }) } : {}), // #5094, #5205: detected
|
|
1888
|
-
admission: readAdmission(cwd), heavy: readHeavy(cwd), ...readCoreLimits(cwd), ...readEnvConfig(cwd), ...(readMergeWait(cwd) ? { mergeWait: readMergeWait(cwd) } : {}), ...(readConformanceMode(cwd) ? { conformance: readConformanceMode(cwd) } : {}), ...(readConformanceKinds(cwd) ? { conformanceKinds: readConformanceKinds(cwd) } : {}), ...(readConformanceMutation(cwd) ? { conformanceMutation: "report" } : {}), ...(readContextPack(cwd) ? { contextPack: readContextPack(cwd) } : {}), ...(readSequenceVersioned(cwd) ? { sequenceVersioned: readSequenceVersioned(cwd) } : {}), ...(readSharedSurfaces(cwd) ? { sharedSurfaces: readSharedSurfaces(cwd) } : {}), ...(readReviewIncomplete(cwd) ? { reviewIncomplete: readReviewIncomplete(cwd) } : {}), ...(readLaneInstructions(cwd) ? { laneInstructions: readLaneInstructions(cwd) } : {}), ...(readReproTest(cwd) ? { reproTest: readReproTest(cwd) } : {}), ...(readReproQuality(cwd) ? { reproQuality: readReproQuality(cwd) } : {}), ...(readExplore(cwd) ? { explore: readExplore(cwd) } : {}), ...(readExperiment(cwd) ? { experiment: readExperiment(cwd) } : {}), light: readLight(cwd), ...(readCloseParent(cwd) ? { closeParent: true } : {}), ...(readReviewTrigger(cwd) ? { reviewTrigger: readReviewTrigger(cwd) } : {}), ...(readVerify(cwd) ? { verify: readVerify(cwd) } : {}), ...readPrecheckOptions(cwd), ...(model ? { builderModel: model } : {}), ...(readLeanSetting("reviewer_model", cwd) ? { reviewerModel: readLeanSetting("reviewer_model", cwd) } : {}), ...(readFixModel(cwd) ? { fixModel: readFixModel(cwd) } : {}), ...(readBuilderRouting(cwd) ? { builderRouting: readBuilderRouting(cwd) } : {}), ...(readVerifier(cwd) ? { verifier: readVerifier(cwd) } : {}), ...(readHostCaps(cwd) ? { hostCaps: readHostCaps(cwd) } : {}), ...readRelayCaps(), ...(readSequenceRegenerate(cwd) ? { sequenceRegenerate: readSequenceRegenerate(cwd) } : {}), ...(readBaseMerge(cwd) ? { baseMerge: readBaseMerge(cwd) } : {}), ...(readFollowupsDefaultMilestone(cwd) ? { followupsDefaultMilestone: readFollowupsDefaultMilestone(cwd) } : {}), ...(readFollowupsRollupLabel(cwd) ? { followupsRollupLabel: readFollowupsRollupLabel(cwd) } : {}) }) };
|
|
1918
|
+
admission: readAdmission(cwd), heavy: readHeavy(cwd), ...readCoreLimits(cwd), ...readEnvConfig(cwd), ...(readMergeWait(cwd) ? { mergeWait: readMergeWait(cwd) } : {}), ...(readConformanceMode(cwd) ? { conformance: readConformanceMode(cwd) } : {}), ...(readConformanceKinds(cwd) ? { conformanceKinds: readConformanceKinds(cwd) } : {}), ...(readConformanceMutation(cwd) ? { conformanceMutation: "report" } : {}), ...(readContextPack(cwd) ? { contextPack: readContextPack(cwd) } : {}), ...(readSequenceVersioned(cwd) ? { sequenceVersioned: readSequenceVersioned(cwd) } : {}), ...(readSharedSurfaces(cwd) ? { sharedSurfaces: readSharedSurfaces(cwd) } : {}), ...(readReviewIncomplete(cwd) ? { reviewIncomplete: readReviewIncomplete(cwd) } : {}), ...(readLaneInstructions(cwd) ? { laneInstructions: readLaneInstructions(cwd) } : {}), ...(readReproTest(cwd) ? { reproTest: readReproTest(cwd) } : {}), ...(readReproQuality(cwd) ? { reproQuality: readReproQuality(cwd) } : {}), ...(readExplore(cwd) ? { explore: readExplore(cwd) } : {}), ...(readExperiment(cwd) ? { experiment: readExperiment(cwd) } : {}), light: readLight(cwd), ...(readCloseParent(cwd) ? { closeParent: true } : {}), ...(readReviewTrigger(cwd) ? { reviewTrigger: readReviewTrigger(cwd) } : {}), ...(readVerify(cwd) ? { verify: readVerify(cwd) } : {}), ...readPrecheckOptions(cwd), ...(model ? { builderModel: model } : {}), ...(readLeanSetting("reviewer_model", cwd) ? { reviewerModel: readLeanSetting("reviewer_model", cwd) } : {}), ...(readFixModel(cwd) ? { fixModel: readFixModel(cwd) } : {}), ...(readBuilderRouting(cwd) ? { builderRouting: readBuilderRouting(cwd) } : {}), ...(readVerifier(cwd) ? { verifier: readVerifier(cwd) } : {}), ...(readHostCaps(cwd) ? { hostCaps: readHostCaps(cwd) } : {}), ...readRelayCaps(), ...(readSequenceRegenerate(cwd) ? { sequenceRegenerate: readSequenceRegenerate(cwd) } : {}), ...(readBaseMerge(cwd) ? { baseMerge: readBaseMerge(cwd) } : {}), ...(readFollowupsDefaultMilestone(cwd) ? { followupsDefaultMilestone: readFollowupsDefaultMilestone(cwd) } : {}), ...(readFollowupsRollupLabel(cwd) ? { followupsRollupLabel: readFollowupsRollupLabel(cwd) } : {}), ...(Number.isInteger(Number(readLeanSetting("contract_max_corrections", cwd))) && Number(readLeanSetting("contract_max_corrections", cwd)) >= 1 ? { contractMaxCorrections: Number(readLeanSetting("contract_max_corrections", cwd)) } : {}) }) };
|
|
1889
1919
|
} else {
|
|
1890
1920
|
const laneScript = deps.laneScript ?? fileURLToPath(new URL("./forgedock.mjs", import.meta.url));
|
|
1891
1921
|
// #4690: lanes learn K (the default MemoryMax is derived from it); one line says so when no scope caps them.
|
|
@@ -2140,8 +2170,9 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
2140
2170
|
...(recoveryOn ? { recovery: orch.recovery } : {}),
|
|
2141
2171
|
decide: deps.decide ?? (async (d) => {
|
|
2142
2172
|
if (d?.issue == null) { sink.line(`decision: ${d?.what} (why: ${d?.why}; alternative: ${d?.alternative})`); return; }
|
|
2143
|
-
const body =
|
|
2144
|
-
|
|
2173
|
+
const body = `## Decision (batch ${batch.id})\n**What**: ${d.what}\n**Why**: ${d.why}\n**Alternative**: ${d.alternative}`;
|
|
2174
|
+
// #5592: runner decisions are a section of the issue's one FORGE:STATUS comment (last 5 kept), not a comment per requeue
|
|
2175
|
+
try { const { postStatusSection } = await import("./lean/statuscomment.mjs"); const { capComment } = await import("./lean/render.mjs"); await postStatusSection({ gh: (a) => leanIo.gh(a), repo, issue: d.issue, markers: ["FORGE:DECISION"], text: body, cap: capComment }); } catch { /* best effort: the batch log keeps the row */ }
|
|
2145
2176
|
}),
|
|
2146
2177
|
// A recovery that ended for good without the lane relabelling it (engine-error, deferred): needs-human back, one comment.
|
|
2147
2178
|
relabelNeedsHuman: deps.relabelNeedsHuman ?? makeRelabelNeedsHuman({ gh: (a) => leanIo.gh(a), repo }),
|
|
@@ -2288,6 +2319,8 @@ export function makeDispatchCheck({ gh, repo, owner: batchOwner = null }) {
|
|
|
2288
2319
|
const reopened = await lastReopen(n);
|
|
2289
2320
|
if (reopened === null || !Number.isFinite(mergedAt) || reopened > mergedAt) return null;
|
|
2290
2321
|
}
|
|
2322
|
+
// #5592: a merged or closed issue keeps no needs-human / parked:* / remediation-queue (a verify reopen returned null above)
|
|
2323
|
+
if (pr !== null || state === "CLOSED") { const { clearPipelineLabels } = await import("./lean/statuscomment.mjs"); await clearPipelineLabels({ gh, repo, issue: n, labels: iss?.labels }); }
|
|
2291
2324
|
if (pr !== null) return { outcome: "merged", pr, detail: `PR #${pr} already merged` };
|
|
2292
2325
|
if (state === "CLOSED") {
|
|
2293
2326
|
// #5152: workflow:merged / a fully closed decomposition is delivered whatever the stateReason; a decomposition still
|
|
@@ -2331,7 +2364,10 @@ export function makeRelabelNeedsHuman({ gh, repo, now = () => Date.now() }) {
|
|
|
2331
2364
|
if (!(await parkedRelabel({ gh, repo, issue, code: parked.code })).ok) return "failed"; // #5466: needs-human stays unless the replacement labels landed
|
|
2332
2365
|
try {
|
|
2333
2366
|
const { capComment } = await import("./lean/render.mjs");
|
|
2334
|
-
|
|
2367
|
+
const { postUpsert } = await import("./lean/statuscomment.mjs");
|
|
2368
|
+
// #5592: one PARKED comment per issue, edited in place (the marker still leads the body)
|
|
2369
|
+
await postUpsert({ gh, repo, issue, markers: ["FORGE:PARKED"], attrs: `code=${parked.code}${parked.pr ? ` pr=${parked.pr}` : ""}`, cap: capComment,
|
|
2370
|
+
body: `## Parked (\`${parked.code}\`)\nCode: \`${parked.code}\`\nPR: ${parked.pr ? `#${parked.pr}` : "none"}\nQueue: \`${REMEDIATION_QUEUE_LABEL}\` (\`/work-on:remediate\`)\n${evidence}` });
|
|
2335
2371
|
} catch { /* best effort */ }
|
|
2336
2372
|
return true;
|
|
2337
2373
|
}
|
package/bin/forgedock.mjs
CHANGED
|
@@ -998,11 +998,12 @@ async function batchHealthSection(c, batchId) {
|
|
|
998
998
|
/** #5465: issue-watch health; a dead watch is flagged and alerted once (events.webhook_url). */
|
|
999
999
|
async function watchHealthSection(c) {
|
|
1000
1000
|
try {
|
|
1001
|
-
const [{ listWatches, alertDeadWatches }, { watchRoot }, { makeEventEmitter }, { readEvents }] = await Promise.all([import("./lean/issuewatch-parity.mjs"), import("./lean/issuewatch.mjs"), import("./engine/events.mjs"), import("./engine-cli.mjs")]);
|
|
1001
|
+
const [{ listWatches, alertDeadWatches, watchEnvWarnings }, { watchRoot }, { makeEventEmitter }, { readEvents }] = await Promise.all([import("./lean/issuewatch-parity.mjs"), import("./lean/issuewatch.mjs"), import("./engine/events.mjs"), import("./engine-cli.mjs")]);
|
|
1002
1002
|
const rows = listWatches(watchRoot());
|
|
1003
1003
|
if (!rows.length) return;
|
|
1004
1004
|
await alertDeadWatches({ root: watchRoot(), emit: (type, data, ctx) => makeEventEmitter({ repo: ctx.repo, config: readEvents(c.cwd) }).emitEvent(type, data, ctx) });
|
|
1005
|
-
|
|
1005
|
+
const envWarn = watchEnvWarnings(rows).map((l) => ` WARNING ${l}`); // #5529
|
|
1006
|
+
c.stdout.write(` issue-watch\n${[...rows.map((w) => ` ${w.name} (${w.repo}): ${w.live.state === "dead" ? "DEAD" : w.live.state}${["dead", "exited"].includes(w.live.state) ? ` - ${w.live.reason}` : ""}`), ...envWarn].join("\n")}\n\n`);
|
|
1006
1007
|
} catch { /* status never fails on watch health */ }
|
|
1007
1008
|
}
|
|
1008
1009
|
|
|
@@ -3162,6 +3163,15 @@ async function doctor(fix = false, verbose = false) {
|
|
|
3162
3163
|
// ── Startup splash plugin (informational, #5312): never a failure ─────────
|
|
3163
3164
|
pass("Startup splash", splashState({ home: HOME }) + ` (${SPLASH_PLUGIN}; install: npx forgedock, skip: --no-splash)`);
|
|
3164
3165
|
|
|
3166
|
+
// ── issue-watch environment (#5529, informational): a running watcher that cannot resolve claude builds nothing ──
|
|
3167
|
+
try {
|
|
3168
|
+
const [{ listWatches, watchEnvWarnings }, { watchRoot }] = await Promise.all([import("./lean/issuewatch-parity.mjs"), import("./lean/issuewatch.mjs")]);
|
|
3169
|
+
const rows = listWatches(watchRoot()), lines = watchEnvWarnings(rows);
|
|
3170
|
+
if (!rows.length) pass("issue-watch environment", "no watches");
|
|
3171
|
+
else if (!lines.length) pass("issue-watch environment", `${rows.length} watch(es); claude resolves where recorded`);
|
|
3172
|
+
else for (const l of lines) warn("issue-watch environment", l);
|
|
3173
|
+
} catch { /* doctor never fails on watch state */ }
|
|
3174
|
+
|
|
3165
3175
|
// ── Check 8: FORGE_HOME environment variable (informational) ──────────────
|
|
3166
3176
|
// The journey-based install never exports FORGE_HOME — it isn't required
|
|
3167
3177
|
// for the pipeline to run. It only affects orchestrate's legacy
|
|
@@ -3370,6 +3380,24 @@ async function doctor(fix = false, verbose = false) {
|
|
|
3370
3380
|
}
|
|
3371
3381
|
}
|
|
3372
3382
|
|
|
3383
|
+
// ── Check 13b: Pool agent free disk (#5535) ─────────────────────────────────
|
|
3384
|
+
// Per agent from the router's GET /agents; warns below hygiene.min_free_gb. Skipped without a pool router; never a failure.
|
|
3385
|
+
{
|
|
3386
|
+
try {
|
|
3387
|
+
const { poolRouterConfig, remoteTransportFor } = await import("./lean/execution.mjs");
|
|
3388
|
+
const endpoint = poolRouterConfig({ env: process.env })?.endpoint;
|
|
3389
|
+
if (endpoint) {
|
|
3390
|
+
const gc = await import("./gc.mjs");
|
|
3391
|
+
const t = remoteTransportFor({ provider: "pool", endpoint }, { env: process.env });
|
|
3392
|
+
const r = gc.poolDiskCheck(await t.agentDisk(), gc.readHygiene(process.cwd()).min_free_gb);
|
|
3393
|
+
if (r.status === "pass") pass("Pool disk", r.detail);
|
|
3394
|
+
else warn("Pool disk", r.detail);
|
|
3395
|
+
}
|
|
3396
|
+
} catch (e) {
|
|
3397
|
+
warn("Pool disk", `could not read pool agent disk: ${String(e?.message ?? e).slice(0, 160)}`);
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
|
|
3373
3401
|
// ── Check 14: Router/schedd restarts (#4673) ───────────────────────────────
|
|
3374
3402
|
// A restart in the last hour usually means an OOM killer or SIGTERM took the coordinator and dropped in-flight lanes. Warn only.
|
|
3375
3403
|
{
|
|
@@ -3954,7 +3982,7 @@ async function watch() {
|
|
|
3954
3982
|
const SPLASH_COMMANDS = new Set(["run", "bootstrap", "run-issue", "orchestrate", "triage", "probe", "gc", "resume-stalled", "demo", "first-run", "doctor", "watch", "help", "--help", "-h"]);
|
|
3955
3983
|
const KNOWN_COMMANDS = new Set([
|
|
3956
3984
|
"install", "init", "enable", "disable", "status", "uninstall", "update",
|
|
3957
|
-
"run", "bootstrap", "backend-check", "run-issue", "orchestrate", "milestone", "milestone-sync", "fix-close-reasons", "guards", "triage", "probe", "acceptance", "docs", "review-staging", "release", "gc", "sandbox", "resume-stalled", "demo", "first-run", "doctor", "auth", "watch", "issue-watch", "prod-watch", "selftest", "labels", "config", "stats", "limits", "decisions", "sched", "schedd", "pool", "check", "guide", "help", "--help", "-h",
|
|
3985
|
+
"run", "bootstrap", "backend-check", "run-issue", "orchestrate", "milestone", "milestone-sync", "fix-close-reasons", "guards", "triage", "probe", "acceptance", "interfaces", "docs", "review-staging", "release", "intake", "gc", "sandbox", "resume-stalled", "demo", "first-run", "doctor", "auth", "watch", "issue-watch", "prod-watch", "selftest", "labels", "config", "stats", "limits", "decisions", "sched", "schedd", "pool", "check", "guide", "help", "--help", "-h",
|
|
3958
3986
|
"version", "--version", "-v",
|
|
3959
3987
|
]);
|
|
3960
3988
|
if (SPLASH_COMMANDS.has(command) || !KNOWN_COMMANDS.has(command)) splash(command);
|
|
@@ -4240,6 +4268,16 @@ switch (command) {
|
|
|
4240
4268
|
}
|
|
4241
4269
|
break;
|
|
4242
4270
|
}
|
|
4271
|
+
case "intake": {
|
|
4272
|
+
const { intakeFromCli } = await import("./lean/intake.mjs");
|
|
4273
|
+
try {
|
|
4274
|
+
await intakeFromCli(restArgs);
|
|
4275
|
+
} catch (err) {
|
|
4276
|
+
process.stderr.write(`${RED}${err.message}${RESET}\n`);
|
|
4277
|
+
exitCode = 1;
|
|
4278
|
+
}
|
|
4279
|
+
break;
|
|
4280
|
+
}
|
|
4243
4281
|
case "issue-watch": {
|
|
4244
4282
|
const { issueWatchFromCli } = await import("./lean/issuewatch.mjs");
|
|
4245
4283
|
try {
|
|
@@ -4388,6 +4426,17 @@ switch (command) {
|
|
|
4388
4426
|
}
|
|
4389
4427
|
break;
|
|
4390
4428
|
}
|
|
4429
|
+
case "interfaces": {
|
|
4430
|
+
// Architecture and interface contracts (#5338): `forgedock interfaces check|register|contract`.
|
|
4431
|
+
const { interfacesFromCli } = await import("./lean/interfaces.mjs");
|
|
4432
|
+
try {
|
|
4433
|
+
exitCode = await interfacesFromCli(restArgs);
|
|
4434
|
+
} catch (err) {
|
|
4435
|
+
process.stderr.write(`${RED}${err.message}${RESET}\n`);
|
|
4436
|
+
exitCode = 1;
|
|
4437
|
+
}
|
|
4438
|
+
break;
|
|
4439
|
+
}
|
|
4391
4440
|
case "acceptance": {
|
|
4392
4441
|
// Feature-level acceptance (#5336): `forgedock acceptance check|run|gate`.
|
|
4393
4442
|
const { acceptanceFromCli } = await import("./lean/acceptance.mjs");
|
package/bin/gc.mjs
CHANGED
|
@@ -21,7 +21,7 @@ import { makeLedger, ledgerRoot as defaultLedgerRoot, LEDGER_TTL_MS } from "./le
|
|
|
21
21
|
import { makeRunTmp, procsInDir, killLedgerPid } from "./lean/effects.mjs";
|
|
22
22
|
import { readBranches } from "./lean/lane.mjs";
|
|
23
23
|
import { makeDepCache } from "./lean/depcache.mjs";
|
|
24
|
-
import { parseExecution, remoteTransportFor } from "./lean/execution.mjs";
|
|
24
|
+
import { parseExecution, remoteTransportFor, poolRouterConfig } from "./lean/execution.mjs";
|
|
25
25
|
import { parseForgeYaml } from "./forge-utils.mjs";
|
|
26
26
|
|
|
27
27
|
const pexec = promisify(execFile);
|
|
@@ -279,6 +279,27 @@ export async function planGc({ probes, scopes = new Set(GC_SCOPES), olderThanMs
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
// ---- 1b. pool sandboxes (#5422): classify stale entries against the router's live list, failing closed ----
|
|
283
|
+
// Same rule as #5496's compose containers: anything tied to a live lane (a live ledger, here by issue) is kept.
|
|
284
|
+
const poolItems = items.filter((i) => i.type === "sandbox" && i.provider === "pool" && i.action === "reclaim");
|
|
285
|
+
if (poolItems.length) {
|
|
286
|
+
let live = null, why = "", diskMb = new Map();
|
|
287
|
+
try {
|
|
288
|
+
const l = await (P.poolInventory ?? (() => remoteTransport(P, true)?.inventory?.()))();
|
|
289
|
+
if (Array.isArray(l)) live = new Map(l.map((x) => [String(x?.id ?? x), x?.issue ?? null])), diskMb = new Map(l.map((x) => [String(x?.id ?? x), x?.disk_used_mb ?? null]));
|
|
290
|
+
else why = "no inventory from the pool router";
|
|
291
|
+
} catch (e) { why = errText(e); }
|
|
292
|
+
if (!live) notes.push(`pool live sandbox list unavailable: ${why}; pool sandboxes left as report`);
|
|
293
|
+
for (const it of poolItems) {
|
|
294
|
+
it.diskUsedMb = diskMb.get(it.id) ?? null; // #5535: null = the agent did not report it (printed as unknown)
|
|
295
|
+
if (!live) { it.action = "report"; it.reason = "pool live list unavailable (cannot verify)"; continue; }
|
|
296
|
+
if (!live.has(it.id)) { it.gone = true; it.reason += ", already gone at the pool router"; continue; }
|
|
297
|
+
const issue = String(live.get(it.id) ?? it.handle?.issue ?? "");
|
|
298
|
+
if (issue && liveLaneIssues.has(issue)) { it.action = "report"; it.reason = `live lane (issue ${issue} has a live ledger)`; }
|
|
299
|
+
else it.reason += ", orphaned at the pool router";
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
282
303
|
// ---- 2. docker: labelled forgedock.owner=1 is owned; everything else is "not owned" ----
|
|
283
304
|
if (want("container") || want("volume")) {
|
|
284
305
|
let psOut = null, psErr = null;
|
|
@@ -494,11 +515,18 @@ export async function planGc({ probes, scopes = new Set(GC_SCOPES), olderThanMs
|
|
|
494
515
|
* forge.yaml `execution` of the checkout and its remote transport (#4254): `P.sandboxTransport` when injected, else the
|
|
495
516
|
* HTTP transport with the credential from the env or keychain. null when unconfigured or refused (never throws).
|
|
496
517
|
*/
|
|
497
|
-
const remoteTransport = (P) => {
|
|
518
|
+
const remoteTransport = (P, pool = false) => {
|
|
498
519
|
if (P.sandboxTransport) return P.sandboxTransport;
|
|
499
520
|
try {
|
|
500
|
-
const
|
|
501
|
-
|
|
521
|
+
const env = P.env ?? process.env;
|
|
522
|
+
let sec; try { sec = parseForgeYaml(nodeFs.readFileSync(join(P.cwd, "forge.yaml"), "utf8"))?.execution; } catch { sec = undefined; }
|
|
523
|
+
const exec = parseExecution(sec && typeof sec === "object" ? sec : {});
|
|
524
|
+
// #5422: `pool` is `remote` with the endpoint and token defaulted to the local router (execution.mjs providerByName).
|
|
525
|
+
if (pool) {
|
|
526
|
+
const endpoint = exec.endpoint ?? poolRouterConfig({ env })?.endpoint;
|
|
527
|
+
return endpoint ? remoteTransportFor({ ...exec, provider: "pool", endpoint }, { env }) : null;
|
|
528
|
+
}
|
|
529
|
+
return remoteTransportFor(exec, { env });
|
|
502
530
|
} catch { return null; }
|
|
503
531
|
};
|
|
504
532
|
|
|
@@ -506,6 +534,7 @@ const remoteTransport = (P) => {
|
|
|
506
534
|
const SANDBOX_TEARDOWN = {
|
|
507
535
|
container: async (P, h) => { try { await P.docker(["rm", "-f", h.id]); return true; } catch (e) { return /no such container/i.test(errText(e)); } },
|
|
508
536
|
local: async () => true,
|
|
537
|
+
pool: async (P, h) => { const t = remoteTransport(P, true); if (!t) return false; try { return (await t.destroy(h.id)) !== false; } catch { return false; } }, // #5422: 404 = gone = reclaimed (httpTransport.destroy)
|
|
509
538
|
remote: async (P, h) => { const t = remoteTransport(P); if (!t) return false; try { return (await t.destroy(h.id)) !== false; } catch { return false; } },
|
|
510
539
|
};
|
|
511
540
|
const defaultSandboxTeardown = (P) => async (provider, handle) => (SANDBOX_TEARDOWN[provider] ? SANDBOX_TEARDOWN[provider](P, handle) : false);
|
|
@@ -531,7 +560,7 @@ export async function applyGc(plan, probes, { deadline = null, now = () => Date.
|
|
|
531
560
|
switch (it.type) {
|
|
532
561
|
case "container": await P.docker(["rm", "-f", it.id]); break;
|
|
533
562
|
case "volume": await P.docker(["volume", "rm", it.id]); break;
|
|
534
|
-
case "sandbox": if (!(await (P.sandboxTeardown ?? defaultSandboxTeardown(P))(it.provider, it.handle))) throw new Error("sandbox teardown failed"); break;
|
|
563
|
+
case "sandbox": if (!it.gone && !(await (P.sandboxTeardown ?? defaultSandboxTeardown(P))(it.provider, it.handle))) throw new Error("sandbox teardown failed"); break;
|
|
535
564
|
case "process": if (P.alive(Number(it.id)) && !(await P.killPid(Number(it.id), it.marker))) throw new Error("kill refused"); break;
|
|
536
565
|
case "tmp":
|
|
537
566
|
if (!isInside(P.forgeTmpRoot, it.id)) throw new Error("outside ForgeDock tmp");
|
|
@@ -599,7 +628,8 @@ export function formatGcReport(plan, { applied = null } = {}) {
|
|
|
599
628
|
}
|
|
600
629
|
for (const it of plan.items) {
|
|
601
630
|
const tag = !it.owned ? "not owned" : it.action === "reclaim" ? (applied ? (applied.failed.some((f) => f.type === it.type && f.id === it.id) ? "FAILED" : "reclaimed") : "reclaim") : "report";
|
|
602
|
-
|
|
631
|
+
const size = it.provider === "pool" ? (Number.isFinite(it.diskUsedMb) ? fmtSize(it.diskUsedMb * 1048576) : "unknown") : fmtSize(it.sizeBytes); // #5535
|
|
632
|
+
L.push(` ${tag.padEnd(9)} ${it.type.padEnd(9)} ${size.padStart(7)} ${fmtAge(it.ageMs).padStart(5)} ${it.id} (${it.reason})`);
|
|
603
633
|
}
|
|
604
634
|
for (const n of plan.notes) L.push(` note: ${n}`);
|
|
605
635
|
for (const f of applied?.failed ?? []) L.push(` failed: ${f.type} ${f.id}: ${f.error}`);
|
|
@@ -669,3 +699,10 @@ export function hygieneCheck(plan, { applied = null, ttlMs = plan?.ttlMs ?? hygi
|
|
|
669
699
|
if (!applied && reclaimable > 0) detail += ". Run: npx forgedock doctor --fix (or: npx forgedock gc --apply)";
|
|
670
700
|
return { status, detail, reclaimable, stale, lowDisk: low, ownedBytes };
|
|
671
701
|
}
|
|
702
|
+
|
|
703
|
+
/** #5535: doctor's pool agent disk lines. `agents` is [{name, disk_free_gb|null}]; warns when any is below minFreeGb (> 0). */
|
|
704
|
+
export function poolDiskCheck(agents, minFreeGb) {
|
|
705
|
+
const low = (a) => Number.isFinite(a.disk_free_gb) && Number.isFinite(minFreeGb) && minFreeGb > 0 && a.disk_free_gb < minFreeGb;
|
|
706
|
+
const detail = agents.map((a) => `${a.name} ${Number.isFinite(a.disk_free_gb) ? `${a.disk_free_gb.toFixed(1)} GB free${low(a) ? ` < ${minFreeGb} GB (hygiene.min_free_gb)` : ""}` : "free disk unknown"}`).join("; ");
|
|
707
|
+
return { status: agents.some(low) ? "warn" : "pass", detail: detail || "no pool agents" };
|
|
708
|
+
}
|
package/bin/help-text.mjs
CHANGED
|
@@ -64,12 +64,13 @@ export const FULL_COMMAND_GROUPS = [
|
|
|
64
64
|
["Run work", [
|
|
65
65
|
["npx forgedock run <cmd> [args]", "Run a command headlessly (local claude CLI or Anthropic API)"],
|
|
66
66
|
["npx forgedock bootstrap <idea|docs> [--dry-run] [--spike <path>] | --plan <plan.json> [--dry-run]", "Headless /bootstrap: idea to orchestrate-ready backlog (--dry-run previews milestones, titles, DAG and estimated agent cost without GitHub writes); --plan validates and creates (or previews) a plan, and re-running resumes from GitHub"],
|
|
67
|
-
["npx forgedock run-issue <issue> [--lane <lane>] [--lane-override] [--path core|full] [--retry] [--wait-lease]", "Work one issue from claim to merge (the lane comes from the issue: its milestone, else staging; --lane only asserts it). --retry reopens a failed run, or one needing a human once the label is cleared; --wait-lease waits for another holder of the issue; exit status 75 means deferred, nothing was lost"],
|
|
67
|
+
["npx forgedock run-issue <issue> [--lane <lane>] [--lane-override] [--path core|full] [--retry] [--wait-lease] [--local]", "Work one issue from claim to merge (the lane comes from the issue: its milestone, else staging; --lane only asserts it). Follows forge.yaml execution: like orchestrate (remote or hybrid places the lane on the pool, with fallback_local); --local forces this host and the placement is printed. --retry reopens a failed run, or one needing a human once the label is cleared; --wait-lease waits for another holder of the issue; exit status 75 means deferred, nothing was lost"],
|
|
68
68
|
["npx forgedock plan validate --live [--repo owner/repo] [--json]", "Re-run the bootstrap dependency-order rules on live GitHub state: each cross-milestone Depends-on edge is ok, held or invalid (fails on invalid)"],
|
|
69
69
|
["npx forgedock orchestrate <issue...> [--parallel K] [--lane L]", "Work on several issues with bounded concurrency and Depends-on ordering; each issue on its own lane, cross-lane dependencies reported"],
|
|
70
70
|
["npx forgedock orchestrate --resume <id> [N...] | --set-parallel <id> K | --set-max-remote <id> N | --set-placement <id> remote|hybrid|local | --add <id> N... | --requeue <id> N... [--reason \"...\"] | --cancel <id> | --hold <id> N... [--for 4h] [--reason \"...\"] | --adopt <issue> | --gc-orphans | --release <id> N... | --show-env <id> | --set-env <id> KEY=VAL | --unset-env <id> KEY", "Reattach to a running or finished batch (a finished one replays its report, an interrupted one resumes), change its concurrency or placement live, add, requeue, hold (with an owner and an optional expiry, --for) or release single issues, adopt an open hand-built PR, cancel orphaned batches (--gc-orphans), stop one batch without stopping the background scheduler, or print, set or unset the batch environment (secrets redacted; applies to newly started lanes)"],
|
|
71
71
|
["npx forgedock triage <issue...> [--lane L] [--dry-run]", "Already-fixed pre-filter: close issues a merged PR or green CI already resolved; print the rest"],
|
|
72
72
|
["npx forgedock probe [issue...] [--dry-run]", "Run declared acceptance probes for closed issues whose fix is on the default branch; a fail reopens the issue"],
|
|
73
|
+
["npx forgedock interfaces check|register|contract", "Interface contracts: require an Interfaces section on a spike/epic with 2+ slices, register its rows in the decision register, generate seam contract tests"],
|
|
73
74
|
["npx forgedock acceptance check|run|gate", "Feature-level acceptance: validate an epic's journeys, run them on the milestone branch, gate ship/close on a green run"],
|
|
74
75
|
["npx forgedock check [--base REF] [--json]", "Run the lane's frozen validate commands and change-scoped pre-PR checks locally in this worktree, as the engine will (no GitHub, no Actions)"],
|
|
75
76
|
["npx forgedock milestone train <slug...> [--parallel-milestones N] | --resume <id> | --insert <id> <slug> [--before s|--after s] | --show <id>", "Unattended multi-milestone train: one durable state file (order, active set, lifecycle), typed STOP reasons, resumable; never edits forge.yaml"],
|
|
@@ -99,7 +100,8 @@ export const FULL_COMMAND_GROUPS = [
|
|
|
99
100
|
["npx forgedock review-staging [<PR>] [--thorough] [--json]", "Staging->main review pre-dispatch: route marker, open-finding gate, scope, prepare, roster; writes one reviewer brief per domain"],
|
|
100
101
|
["npx forgedock review-staging [<PR>] --finalize --test-gate-output <file>", "Staging->main review post-dispatch: delivery, test-gate verdict, extract/classify/file-prepare; prints the findings to file"],
|
|
101
102
|
["npx forgedock review-staging [<PR>] --summary [--filed <N>]...", "Staging->main review Phase 8: verdict and summary comment with the FORGE:GATE_PASS / FORGE:GATE_FAILURE marker"],
|
|
102
|
-
["npx forgedock
|
|
103
|
+
["npx forgedock intake pause|resume|status [--reason \"...\"] [--tracker <issue>] [--release <id>] [--repo owner/repo]", "Managed releases (release.managed): write _active.intake and the forge:intake-paused label on the tracker; the issue watch reads it from GitHub, so every host stops claiming (also while a release/*, train/* or hotfix/* PR is open or a ledger entry is active); freeze.intake_auto_resume resumes when the named release ends"],
|
|
104
|
+
["npx forgedock release [--repo owner/repo] [--merge] [--watch] [--resume <id>] | release verify <sha> [--repo owner/repo] | release status [<id>] [--watch] [--interval s] [--json] | release explain <id | #issue | PR> [--json]", "Staging->default release as one resumable job: preflight, release PR, review, fixes, promotion (stops at GATE_PASS unless --merge or release.auto_merge), post-merge; release.mode: snapshot cuts release/<id> from staging (lanes keep merging, fixes are cherry-picked, FORGE:RELEASE records them); verify checks a release head against that record; status/explain are read-only views of the ledger plus GitHub (--watch re-polls, printing on change, until a terminal state) (JSON schema forgedock.release.*/v1 with next_actions)"],
|
|
103
105
|
]],
|
|
104
106
|
["Maintenance and hosting", [
|
|
105
107
|
["npx forgedock fix-close-reasons <owner/repo> [--milestone <m>] [--apply]", "Re-close issues that were closed not planned but carry workflow:merged or workflow:decomposed (delivered, not dropped) as completed, with a comment; dry run unless --apply; workflow:invalid issues are never touched"],
|
|
@@ -254,8 +254,12 @@ export function statelessNeedsHuman(issues) {
|
|
|
254
254
|
/** #5466: the batch's open issues that GitHub shows stateless (see `statelessNeedsHuman`). A read failure skips the issue. */
|
|
255
255
|
export async function statelessOnGithub(state, gh, repo) {
|
|
256
256
|
const run = new Set(Object.keys(state?.running ?? {}).map(Number));
|
|
257
|
+
// #5592: the label is only expected where the batch's own row ended parked: a requeued (pending) issue had its pipeline labels
|
|
258
|
+
// cleared on purpose, and a merged/invalid/decomposed row keeps an old NEEDS_HUMAN comment that no longer describes it.
|
|
259
|
+
const pend = new Set((state?.pending ?? []).map(Number));
|
|
260
|
+
const ended = (x) => state?.results?.[x]?.outcome !== undefined && !GOOD_END.has(state.results[x].outcome) && !pend.has(x);
|
|
257
261
|
const rows = [];
|
|
258
|
-
for (const n of (state?.order ?? []).map(Number).filter((x) => !run.has(x))) {
|
|
262
|
+
for (const n of (state?.order ?? []).map(Number).filter((x) => !run.has(x) && ended(x))) {
|
|
259
263
|
try {
|
|
260
264
|
const v = JSON.parse(await gh(["issue", "view", String(n), "-R", repo, "--json", "number,state,labels,comments"]));
|
|
261
265
|
rows.push({ number: n, state: v.state, labels: (v.labels ?? []).map((l) => l.name), comments: (v.comments ?? []).map((c) => c.body) });
|
|
@@ -260,7 +260,13 @@ describe("#5466 stateless issues surface in the batch health check", () => {
|
|
|
260
260
|
assert.equal(h.healthy, false);
|
|
261
261
|
assert.equal(h.causes[0].code, "stateless");
|
|
262
262
|
const gh = async (a) => JSON.stringify(a[2] === "1" ? { state: "OPEN", labels: [], comments: [{ body: "<!-- FORGE:NEEDS_HUMAN -->" }] } : { state: "OPEN", labels: [{ name: "needs-human" }], comments: [{ body: "<!-- FORGE:NEEDS_HUMAN -->" }] });
|
|
263
|
-
|
|
263
|
+
const ended = { 1: { outcome: "needs-human" }, 2: { outcome: "needs-human" } };
|
|
264
|
+
assert.deepEqual(await statelessOnGithub({ order: [1, 2], results: ended }, gh, "o/r"), [1]);
|
|
265
|
+
});
|
|
266
|
+
it("#5592: a requeued (pending), running, merged or result-less issue is not stateless: its labels were cleared on purpose", async () => {
|
|
267
|
+
const gh = async () => JSON.stringify({ state: "OPEN", labels: [], comments: [{ body: "<!-- FORGE:NEEDS_HUMAN -->\nold run" }] });
|
|
268
|
+
const st = { order: [1, 2, 3, 4, 5], results: { 1: { outcome: "needs-human" }, 2: { outcome: "needs-human" }, 3: { outcome: "needs-human" }, 4: { outcome: "merged" } }, pending: [2], running: { 3: {} } };
|
|
269
|
+
assert.deepEqual(await statelessOnGithub(st, gh, "o/r"), [1], "only the row that ended parked, with no label, is flagged");
|
|
264
270
|
});
|
|
265
271
|
});
|
|
266
272
|
|
package/bin/lean/batch.mjs
CHANGED
|
@@ -138,7 +138,8 @@ export function batchesOwning(root, repo, issue, { exceptId = null, now = Date.n
|
|
|
138
138
|
if (b.readCancel()) { out.push({ id, cancelled: true, running }); continue; }
|
|
139
139
|
const last = b.lastProgressMs();
|
|
140
140
|
const live = !b.readReport() && last !== null && now - last <= staleMs;
|
|
141
|
-
|
|
141
|
+
// #5592: a batch that only HOLDS the issue (pending but held) does not run it, so it is not an owner: the batch that now runs it is.
|
|
142
|
+
if (live && (running || (Array.isArray(st.pending) && st.pending.includes(issue) && !b.readHeld().includes(issue)))) out.push({ id, cancelled: false, running });
|
|
142
143
|
}
|
|
143
144
|
return out;
|
|
144
145
|
}
|
|
@@ -245,7 +246,11 @@ export function openBatch(root, id) {
|
|
|
245
246
|
if (!Number.isSafeInteger(n) || n < 1) refused.push({ issue: x, reason: "not an integer" });
|
|
246
247
|
else if (!order.has(n)) refused.push({ issue: n, reason: "not in batch" });
|
|
247
248
|
else if (pend.has(n)) refused.push({ issue: n, reason: "already requeued" });
|
|
248
|
-
else if (!REQUEUABLE(st.results?.[n]?.outcome) && !quotaPaused(n) && !leaseOrphaned(n))
|
|
249
|
+
else if (!REQUEUABLE(st.results?.[n]?.outcome) && !quotaPaused(n) && !leaseOrphaned(n)) {
|
|
250
|
+
// #5592: held here while another batch runs it: say so, and release the hold here (`--release`) or requeue in that batch
|
|
251
|
+
const other = st.results?.[n] === undefined && self.readHeld().includes(n) ? activeBatchOf(dirname(dir), readJson(f("plan.json"))?.repo, n, { exceptId: id }) : null;
|
|
252
|
+
refused.push({ issue: n, reason: other ? `not terminal: held here, run by ${other}; requeue it there` : "not terminal" });
|
|
253
|
+
}
|
|
249
254
|
else { pend.add(n); requeued.push(n); }
|
|
250
255
|
}
|
|
251
256
|
if (requeued.length) {
|
package/bin/lean/batch.test.mjs
CHANGED
|
@@ -1339,6 +1339,51 @@ describe("#4592: forgedock orchestrate --hold / --release", () => {
|
|
|
1339
1339
|
assert.deepEqual((await done).map((r) => [r.issue, r.outcome]), [[1, "merged"], [2, "merged"]]);
|
|
1340
1340
|
});
|
|
1341
1341
|
|
|
1342
|
+
it("a hold placed while a lane runs skips its recovery lane", async () => {
|
|
1343
|
+
let held = [], free, saved = null;
|
|
1344
|
+
const gate = new Promise((r) => { free = r; });
|
|
1345
|
+
const store = { load: () => saved, save: (s) => { saved = s; }, log: () => {} };
|
|
1346
|
+
const started = [], log = [];
|
|
1347
|
+
const done = orchestrate({ issues: [1], parallel: 1, pollMs: 5, readBody: async () => "", store, getHeld: () => held, recovery: { maxAttempts: 1 },
|
|
1348
|
+
onUpdate: (r) => log.push(r), decide: () => {},
|
|
1349
|
+
runOne: async (n) => { started.push(n); await gate; return { terminalReason: "needs-human", code: "conformance.omission", detail: "omitted" }; } });
|
|
1350
|
+
await until(() => started.includes(1));
|
|
1351
|
+
held = [1];
|
|
1352
|
+
free();
|
|
1353
|
+
const rows = await done;
|
|
1354
|
+
assert.deepEqual(started, [1], "no recovery lane launched");
|
|
1355
|
+
assert.equal(rows[0].outcome, "needs-human");
|
|
1356
|
+
assert.ok(!log.some((r) => r.outcome === "recovering"), "no recovering row");
|
|
1357
|
+
});
|
|
1358
|
+
|
|
1359
|
+
it("a hold placed while a lane runs is reported held after launch", async () => {
|
|
1360
|
+
let held = [], free;
|
|
1361
|
+
const gate = new Promise((r) => { free = r; });
|
|
1362
|
+
const store = { load: () => null, save: () => {}, log: () => {} };
|
|
1363
|
+
const started = [], log = [];
|
|
1364
|
+
const done = orchestrate({ issues: [1, 2], parallel: 2, pollMs: 5, readBody: async () => "", store, getHeld: () => held, onUpdate: (r) => log.push(r),
|
|
1365
|
+
runOne: async (n) => { started.push(n); if (n === 1) await gate; return { terminalReason: "merged" }; } });
|
|
1366
|
+
await until(() => started.includes(1));
|
|
1367
|
+
await until(() => started.includes(2));
|
|
1368
|
+
held = [1];
|
|
1369
|
+
await until(() => log.some((r) => /held after launch: lane still running/.test(r.detail ?? "")));
|
|
1370
|
+
free();
|
|
1371
|
+
await done;
|
|
1372
|
+
});
|
|
1373
|
+
|
|
1374
|
+
it("a second hold names the already held issues", async () => {
|
|
1375
|
+
const root = tmpDir("batch-hold-twice-");
|
|
1376
|
+
const b = openBatch(root, "b1");
|
|
1377
|
+
b.writePlan({ argv: [], repo: "o/r" });
|
|
1378
|
+
b.store.save({ order: [1, 2] });
|
|
1379
|
+
const io = { gh: async () => JSON.stringify({ state: "OPEN" }) };
|
|
1380
|
+
await quiet(() => orchestrateFromCli(["--hold", "b1", "1"], { batchRoot: root, io }));
|
|
1381
|
+
const lines = []; const l = console.log; console.log = (x) => lines.push(String(x));
|
|
1382
|
+
try { await orchestrateFromCli(["--hold", "b1", "1"], { batchRoot: root, io }); } finally { console.log = l; }
|
|
1383
|
+
assert.ok(lines.some((x) => /already held #1/.test(x)), lines.join("\n"));
|
|
1384
|
+
assert.ok(!lines.some((x) => /held \(none\)/.test(x)));
|
|
1385
|
+
});
|
|
1386
|
+
|
|
1342
1387
|
it("through the CLI: --hold / --release write the hold file (usage and unknown batch reject); --resume <id> N releases N", async () => {
|
|
1343
1388
|
const root = tmpDir("batch-hold-cli-");
|
|
1344
1389
|
const b = openBatch(root, "b1");
|
|
@@ -80,11 +80,12 @@ function makeWorld(dir, script) {
|
|
|
80
80
|
const io = {
|
|
81
81
|
gh: async (a) => {
|
|
82
82
|
const k = a.slice(0, 2).join(" "), n = Number(a[2]), val = (f) => a[a.indexOf(f) + 1];
|
|
83
|
+
if (a[0] === "api" && a.includes("PATCH")) { const m = /issues\/comments\/(\d+)$/.exec(a.find((x) => /issues\/comments\//.test(x)) ?? ""); const body = a[a.indexOf("-f") + 1].replace(/^body=/, ""); for (const i of Object.values(gh.issues)) if (m && i.comments[m[1] - 1] !== undefined && i.comments[m[1] - 1].startsWith("<!-- FORGE:STATUS -->")) { i.comments[m[1] - 1] = body; return "{}"; } throw new Error("no such comment"); } // #5592: the one FORGE:STATUS comment is edited in place
|
|
83
84
|
if (a[0] === "api") return "";
|
|
84
85
|
if (k === "repo view") return "main\n";
|
|
85
86
|
if (k === "issue view" && a.includes("milestone")) return JSON.stringify({ milestone: null });
|
|
86
87
|
if (k === "issue view") { const i = gh.issues[n]; return JSON.stringify({ number: i.number, title: i.title, body: i.body, state: i.state, comments: [] }); }
|
|
87
|
-
if (k === "issue comment") { gh.issues[n].comments.push(val("--body")); return `https://github.com/o/r/issues/${n}#
|
|
88
|
+
if (k === "issue comment") { gh.issues[n].comments.push(val("--body")); return `https://github.com/o/r/issues/${n}#issuecomment-${gh.issues[n].comments.length}\n`; }
|
|
88
89
|
if (k === "issue edit") { for (let i = 0; i < a.length; i++) { if (a[i] === "--add-label") a[i + 1].split(",").forEach((l) => gh.issues[n].labels.add(l)); if (a[i] === "--remove-label") a[i + 1].split(",").forEach((l) => gh.issues[n].labels.delete(l)); } return ""; }
|
|
89
90
|
if (k === "issue close") { Object.assign(gh.issues[n], { state: "CLOSED", reason: val("--reason") }); return ""; }
|
|
90
91
|
if (k === "pr list") return "[]";
|
|
@@ -189,7 +190,7 @@ describe("conformance gate end-to-end (real git, disposable repo)", { skip: !HAV
|
|
|
189
190
|
const o = await runCase({ contract: FULL, impl: (t) => fix(t, ["scrape", "search", "export"]) });
|
|
190
191
|
merged(o); assert.ok(o.staging.search && o.staging.export && !o.staging.billingChanged);
|
|
191
192
|
assert.deepEqual([o.counts.builder, o.counts.reviewer], [2, 1]);
|
|
192
|
-
assert.deepEqual(o.markers, ["FORGE:
|
|
193
|
+
assert.deepEqual(o.markers, ["FORGE:STATUS", "FORGE:INVESTIGATION", "FORGE:CONTRACT", "FORGE:IMPLEMENTATION", "FORGE:REVIEW", "FORGE:FACTS"]); // #5592: STARTED and TRAJECTORY are sections of the one status comment
|
|
193
194
|
});
|
|
194
195
|
it("2 omission: the contract silently drops requirement 3; review catches it; issue stays open, nothing merged", async () => {
|
|
195
196
|
const o = await runCase({ contract: OMIT, impl: (t) => fix(t, ["scrape", "search"]) });
|