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.
Files changed (140) hide show
  1. package/bin/config-schema.mjs +1 -1
  2. package/bin/engine/outcome-codes.mjs +2 -1
  3. package/bin/engine/phases.mjs +4 -3
  4. package/bin/engine-cli.mjs +48 -12
  5. package/bin/forgedock.mjs +52 -3
  6. package/bin/gc.mjs +43 -6
  7. package/bin/help-text.mjs +4 -2
  8. package/bin/lean/batch-health.mjs +5 -1
  9. package/bin/lean/batch-health.test.mjs +7 -1
  10. package/bin/lean/batch.mjs +7 -2
  11. package/bin/lean/batch.test.mjs +45 -0
  12. package/bin/lean/conformance.e2e.test.mjs +3 -2
  13. package/bin/lean/conformance.mjs +118 -20
  14. package/bin/lean/conformance.test.mjs +172 -3
  15. package/bin/lean/decisions.mjs +98 -1
  16. package/bin/lean/decisions.test.mjs +30 -1
  17. package/bin/lean/depcache.mjs +124 -13
  18. package/bin/lean/depcache.test.mjs +121 -3
  19. package/bin/lean/design-gate.mjs +144 -0
  20. package/bin/lean/design-gate.test.mjs +169 -0
  21. package/bin/lean/effects-cap.test.mjs +17 -0
  22. package/bin/lean/effects.mjs +58 -13
  23. package/bin/lean/heavy.mjs +25 -8
  24. package/bin/lean/hostload.test.mjs +28 -0
  25. package/bin/lean/intake.mjs +97 -0
  26. package/bin/lean/intake.test.mjs +105 -0
  27. package/bin/lean/interfaces.mjs +181 -0
  28. package/bin/lean/interfaces.test.mjs +192 -0
  29. package/bin/lean/issuewatch-install.mjs +52 -12
  30. package/bin/lean/issuewatch-install.test.mjs +50 -0
  31. package/bin/lean/issuewatch-parity.mjs +16 -3
  32. package/bin/lean/issuewatch-parity.test.mjs +32 -0
  33. package/bin/lean/issuewatch-reconcile.mjs +29 -1
  34. package/bin/lean/issuewatch-reconcile.test.mjs +21 -0
  35. package/bin/lean/issuewatch.mjs +34 -3
  36. package/bin/lean/issuewatch.test.mjs +49 -1
  37. package/bin/lean/lanecheck.test.mjs +15 -4
  38. package/bin/lean/lean.mjs +110 -24
  39. package/bin/lean/lean.test.mjs +183 -4
  40. package/bin/lean/orchestrate-blocked.test.mjs +18 -2
  41. package/bin/lean/orchestrate-owned.test.mjs +14 -5
  42. package/bin/lean/orchestrate.mjs +26 -4
  43. package/bin/lean/orphan-pr.mjs +3 -2
  44. package/bin/lean/orphan-pr.test.mjs +8 -1
  45. package/bin/lean/pagegate.mjs +35 -12
  46. package/bin/lean/pagegate.test.mjs +39 -1
  47. package/bin/lean/preflight.mjs +35 -1
  48. package/bin/lean/preflight.test.mjs +27 -1
  49. package/bin/lean/prompts.mjs +2 -1
  50. package/bin/lean/reap.test.mjs +39 -0
  51. package/bin/lean/recovery.test.mjs +28 -3
  52. package/bin/lean/release-config.mjs +169 -0
  53. package/bin/lean/release-config.test.mjs +132 -0
  54. package/bin/lean/release-control.mjs +171 -0
  55. package/bin/lean/release-control.test.mjs +167 -0
  56. package/bin/lean/release-deploy.mjs +209 -0
  57. package/bin/lean/release-deploy.test.mjs +217 -0
  58. package/bin/lean/release-fence.mjs +50 -0
  59. package/bin/lean/release-fence.test.mjs +105 -0
  60. package/bin/lean/release-flakes.mjs +139 -0
  61. package/bin/lean/release-flakes.test.mjs +116 -0
  62. package/bin/lean/release-gates.mjs +230 -0
  63. package/bin/lean/release-gates.test.mjs +146 -0
  64. package/bin/lean/release-ledger.mjs +176 -0
  65. package/bin/lean/release-ledger.test.mjs +226 -0
  66. package/bin/lean/release-minutes.mjs +102 -0
  67. package/bin/lean/release-minutes.test.mjs +107 -0
  68. package/bin/lean/release-nightly.mjs +75 -0
  69. package/bin/lean/release-nightly.test.mjs +48 -0
  70. package/bin/lean/release-postmerge.mjs +8 -2
  71. package/bin/lean/release-review.e2e.test.mjs +1 -0
  72. package/bin/lean/release-review.mjs +54 -7
  73. package/bin/lean/release-review.test.mjs +76 -7
  74. package/bin/lean/release-status.mjs +300 -0
  75. package/bin/lean/release-status.test.mjs +220 -0
  76. package/bin/lean/release-unitmap.mjs +35 -0
  77. package/bin/lean/release-unitmap.test.mjs +41 -0
  78. package/bin/lean/release-verify.mjs +221 -0
  79. package/bin/lean/release-verify.test.mjs +176 -0
  80. package/bin/lean/release.mjs +244 -22
  81. package/bin/lean/release.test.mjs +44 -0
  82. package/bin/lean/render.mjs +3 -1
  83. package/bin/lean/run-issue-placement.test.mjs +82 -0
  84. package/bin/lean/sandbox-remote.mjs +16 -0
  85. package/bin/lean/schedd.mjs +1 -1
  86. package/bin/lean/seam.mjs +115 -0
  87. package/bin/lean/seam.test.mjs +118 -0
  88. package/bin/lean/selftest-journey.mjs +40 -2
  89. package/bin/lean/selftest-journey.test.mjs +43 -3
  90. package/bin/lean/statuscomment.mjs +168 -0
  91. package/bin/lean/statuscomment.test.mjs +133 -0
  92. package/bin/lean/ui-quality.mjs +57 -0
  93. package/bin/lean/ui-quality.test.mjs +55 -0
  94. package/bin/lean/visual-gate.test.mjs +63 -0
  95. package/bin/pool/agent.mjs +16 -2
  96. package/bin/pool/router.mjs +5 -1
  97. package/bin/review-staging.mjs +5 -3
  98. package/bin/stats/card.mjs +117 -0
  99. package/bin/stats/card.test.mjs +109 -0
  100. package/bin/stats/conformance-outcomes.test.mjs +2 -1
  101. package/bin/stats/depth.mjs +1 -1
  102. package/bin/stats/gh-retry.test.mjs +152 -0
  103. package/bin/stats/github-source.mjs +147 -14
  104. package/bin/stats/index.mjs +35 -2
  105. package/bin/stats/stats.test.mjs +31 -3
  106. package/bin/vendor/js-yaml/LICENSE +21 -0
  107. package/bin/vendor/js-yaml/PIN.md +7 -0
  108. package/bin/vendor/js-yaml/js-yaml.mjs +3851 -0
  109. package/commands/design-render-critique-loop.md +2 -0
  110. package/commands/design.md +2 -0
  111. package/commands/issue.md +1 -1
  112. package/commands/milestone.md +1 -1
  113. package/commands/review-pr-agents/frontend.md +1 -0
  114. package/commands/review-pr-staging.md +5 -0
  115. package/docs/CONFIG.md +95 -2
  116. package/docs/ISSUE-WATCH.md +7 -0
  117. package/docs/OUTCOME-CODES.md +1 -0
  118. package/docs/STATS.md +10 -0
  119. package/docs/design/visual-gate.md +25 -0
  120. package/docs/eval/adversarial-bench.md +2 -2
  121. package/docs/eval/corpus/adversarial-v1.json +3 -3
  122. package/docs/site/start-a-new-project.md +7 -0
  123. package/docs/spec/forge-protocol-v1.md +31 -0
  124. package/package.json +1 -1
  125. package/pool/README.md +2 -0
  126. package/scripts/acceptance-red-green.sh +15 -1
  127. package/scripts/acceptance-red-green.test.sh +12 -0
  128. package/scripts/bench-adversarial.mjs +4 -0
  129. package/scripts/bench-lightlane.mjs +4 -1
  130. package/scripts/bootstrap-create.mjs +8 -2
  131. package/scripts/ci-local/scoping.mjs +19 -0
  132. package/scripts/ci-local.test.sh +16 -3
  133. package/scripts/fixtures/ci-local/gha-dorny/.github/workflows/ci.yml +4 -0
  134. package/scripts/plan-validate-live.mjs +9 -6
  135. package/scripts/review-prepare.sh +7 -1
  136. package/scripts/review-roster.sh +5 -2
  137. package/scripts/review-roster.test.sh +9 -0
  138. package/scripts/visual-gate.mjs +64 -0
  139. package/templates/bootstrap/technical-spike.md +17 -0
  140. package/templates/contracts/seam-check.mjs +236 -0
package/bin/lean/lean.mjs CHANGED
@@ -21,14 +21,15 @@ import { createHash, randomBytes } from "node:crypto";
21
21
  import { otherLaneOwner } from "./lanelock.mjs";
22
22
  import { stampText, checkStamp } from "./stagestamp.mjs";
23
23
  import { acquireBranchLock, waitPidsExit } from "./branchlock.mjs";
24
- import { isTestPath, applyValidateRecipes, rewriteProjectDirCommand, deferChecklessPostDeploy, autoPostDeployE2e, loneE2eRows, reproEnvMiss, resolveForgedockPaths, describesUnrunnableCommand, removedPathsOf, TRACKED, normalizeKindModes, blockingFailures, unverifiedRequirements, mutationTargets, mutationFailures, runMutationCheck, MUTATION_SURVIVED, isBugIssue, scopeText, explainFailures, inIssue, validateContract, snapQuotes, cliUsageError, normalizeRunnerCommand, applyAmendments, amendmentKindProblems, precheck, alreadyFixedOnBase, READONLY_PROD_RE, EXTERNAL_NEED_RE, intakeHostWork, repoTracks, dropScopeValidates, tagOutOfBand, parseReview, decide, mergeReviewRows, reaskable, criterionLines, closePlan, followupItems, renderPendingFollowups, bucketTally, pendingTracking, unnamedEdges, structureNote, impliedDocDeliverables, convertDelivered } from "./conformance.mjs";
24
+ import { contractRuleCounts, onlyTestPlanProblems, isTestPath, applyValidateRecipes, rewriteProjectDirCommand, deferChecklessPostDeploy, autoPostDeployE2e, applyRequirementDecisions, loneE2eRows, reproEnvMiss, resolveForgedockPaths, describesUnrunnableCommand, removedPathsOf, TRACKED, normalizeKindModes, blockingFailures, unverifiedRequirements, mutationTargets, mutationFailures, runMutationCheck, MUTATION_SURVIVED, isBugIssue, scopeText, explainFailures, inIssue, validateContract, snapQuotes, cliUsageError, normalizeRunnerCommand, applyAmendments, amendmentKindProblems, precheck, alreadyFixedOnBase, READONLY_PROD_RE, EXTERNAL_NEED_RE, intakeHostWork, repoTracks, dropScopeValidates, tagOutOfBand, parseReview, decide, mergeReviewRows, reaskable, criterionLines, closePlan, followupItems, renderPendingFollowups, bucketTally, pendingTracking, unnamedEdges, structureNote, impliedDocDeliverables, convertDelivered } from "./conformance.mjs";
25
25
  import { checkAdmission, hostParallelism, ADMISSION_RETRY_SECONDS } from "./admission.mjs";
26
26
  import { namedPaths, isTrustedIssueComment } from "./prefilter.mjs";
27
+ import { writeStatus, postUpsert, isStatusPost, isUpsertPost, hasSection, clearPipelineLabels } from "./statuscomment.mjs";
27
28
  import { checksAt, mergeCheckEntries, CHECKS_FILE } from "./postdeploy-check.mjs";
28
29
  import { matchBaselines, baselineFailures, foldRegression } from "./baselines.mjs";
29
30
  import { readRollouts, detectNewOffKeys, rolloutModes, liveDeferralBlocks } from "./activation.mjs";
30
31
  import { toolMisses } from "./toolplace.mjs";
31
- import { testRunnerProblems, preflightProbes, preflightProblems, unsetEnvVars, runPreflight, knownToContract, declaredEnv, depInstallFailures, testRunSummary } from "./preflight.mjs";
32
+ import { testRunnerProblems, preflightProbes, preflightProblems, unsetEnvVars, runPreflight, knownToContract, declaredEnv, depInstallFailures, testRunSummary, projectBinDirs, withLocalBins } from "./preflight.mjs";
32
33
  import { resolveLane, isDefaultLane, isShippedLane, DEFAULT_STAGING_BRANCH } from "./lane.mjs";
33
34
  import { splitGate, rationaleLine } from "./decompose.mjs";
34
35
  import { ceilingFor, predictRestart, handoffFacts, NARROW_NOTE } from "./ceiling.mjs";
@@ -47,6 +48,13 @@ import { hostCapabilityBlock, contractHostNeeds } from "./execution.mjs";
47
48
 
48
49
  const MISSING_TOOL_RE = /command not found|not found in PATH|no such file or directory.*\b(?:docker|promtool)\b|\b(?:docker|promtool)\b[^\n]{0,80}(?:not (?:installed|found|available)|no such file|cannot connect|daemon)|cannot connect to the docker daemon|no docker daemon|no module named|ModuleNotFoundError|\bENOENT\b[^\n]{0,60}spawn/i;
49
50
  /** #4685: true when a builder's block summary names a missing tool or module (environment), not a credential. */
51
+ /** #5623: a contract problem the builder can fix in its own session (shape, typed fields, test-plan rules, check ids), as
52
+ * opposed to one that needs the issue changed (quote not verbatim) or a person. */
53
+ export function contractSelfCorrectable(problems) {
54
+ const list = Array.isArray(problems) ? problems : [];
55
+ return list.length > 0 && !list.every((x) => /: quote is not verbatim/.test(String(x)));
56
+ }
57
+
50
58
  export function missingToolBlock(summary) { return MISSING_TOOL_RE.test(String(summary ?? "")); }
51
59
  import { reserveForBuild, revalidate } from "./seqreserve.mjs";
52
60
  import { patchEcho, mutationsOf, runReproMutations, classifyRepro } from "./reproquality.mjs";
@@ -58,6 +66,8 @@ import { parseProdParity, prodParityFailures as prodParityOf } from "./prodparit
58
66
  import { routePathsFromFiles, routeReachabilityFailures } from "./routecheck.mjs";
59
67
  import { docsFailures } from "./docsgate.mjs";
60
68
  import { pageFailures, designSpecApproved, designLabelApproved } from "./pagegate.mjs"; // #5428
69
+ import { uiBuildRule, uiIssue, uiChanged } from "./ui-quality.mjs"; // #5330
70
+ import { designGate, designGateNote, designFailures, specApproved as designSpecOk } from "./design-gate.mjs"; // #5330
61
71
  import { parseCoupled, coupledFailures } from "./coupled.mjs";
62
72
  import { analyzeRelaxations, relaxationFailures } from "./relaxation.mjs";
63
73
  import { startSpeculative } from "./overlap.mjs";
@@ -84,6 +94,8 @@ import { applyArmOverrides } from "../experiment.mjs";
84
94
  import { parseExploreConfig, explorerAgents, explorePlanRule, exploreBuildRule } from "./explore.mjs";
85
95
  import { normaliseFacts, renderFactsRecord, FACTS_MARKER } from "./facts.mjs";
86
96
  import { readDecisionIndex, withDecisionRows, recordDecisions } from "./decisions.mjs";
97
+ import { seamFailures } from "./seam.mjs"; // #5338
98
+ import { notifyConsumers } from "./interfaces.mjs"; // #5338
87
99
  import { normaliseInvalidation, epicOf, fileAmendment, REPLAN_MARKER } from "./replan.mjs";
88
100
  import { claimSurfaces, parseSharedSurfaces, generatorNote } from "./surfaces.mjs";
89
101
  import { parseContextPackConfig, resolveContextMode, parentOf, contextArm, contextPackFor, renderContextRecord, laneType, priorAttempts, linkStateStamp, stateOf } from "./context.mjs";
@@ -274,7 +286,7 @@ const defaultCredExec = (args) => {
274
286
  export async function runCore(o) {
275
287
  const armed = applyArmOverrides(o, o.issue); o = armed.options; // #5206: the arm's overrides shape the lane before any config is parsed
276
288
  const { issue, repo, lane: requestedLane = null, laneOverride = false, branches = {}, cwd, dir, io, builderModel = null, reviewerModel = DEFAULT_REVIEWER_MODEL, fixModel = null,
277
- toolchainOverride = null, testRunners = null, coupledFiles = null, validateRecipes = null, routeReachability = null, docsConfig = null, pagesConfig = null, prodParity = null, envSetup = null, ciMaxMinutes = 360, conformance = "shadow", conformanceKinds = null, conformanceMutation = "off", reviewIncomplete = "needs-human", reproTest = "prefer", reproQuality = "shadow", closeParent = false, mergeWait = "required", maxSessionLimitPauses = DEFAULT_MAX_SESSION_LIMIT_PAUSES, cliIdleMinutes = 15, cliMaxMinutes = 180, cliBusyMinutes = 45, contextCeilingTokens = 120000, contextCeilingBySize = null, turnBudgets = null, laneLimits = null, maxMergeRetries = 5, sessionLimitMaxWaitMs = DEFAULT_SESSION_LIMIT_WAIT_MS, contextWaitSeconds = 5, onProgress = () => {}, emitTelemetry = null, random = Math.random } = o;
289
+ toolchainOverride = null, testRunners = null, coupledFiles = null, validateRecipes = null, routeReachability = null, docsConfig = null, pagesConfig = null, designConfig = null, prodParity = null, envSetup = null, ciMaxMinutes = 360, conformance = "shadow", conformanceKinds = null, conformanceMutation = "off", reviewIncomplete = "needs-human", reproTest = "prefer", reproQuality = "shadow", closeParent = false, mergeWait = "required", maxSessionLimitPauses = DEFAULT_MAX_SESSION_LIMIT_PAUSES, cliIdleMinutes = 15, cliMaxMinutes = 180, cliBusyMinutes = 45, contextCeilingTokens = 120000, contextCeilingBySize = null, turnBudgets = null, laneLimits = null, maxMergeRetries = 5, contractMaxCorrections = 3, sessionLimitMaxWaitMs = DEFAULT_SESSION_LIMIT_WAIT_MS, contextWaitSeconds = 5, onProgress = () => {}, emitTelemetry = null, random = Math.random } = o;
278
290
  const now = io.now ?? (() => Date.now());
279
291
  const rotator = io.rotator !== undefined ? io.rotator : openRotator({ kind: o.accountRotator }); // #5094
280
292
  // #5205: a rotator with pick() relaunches a limited phase pinned to another account; lane-level rotations and limited accounts
@@ -350,7 +362,20 @@ export async function runCore(o) {
350
362
  usage.input += u.input_tokens ?? 0; usage.output += u.output_tokens ?? 0;
351
363
  usage.cache += (u.cache_read_input_tokens ?? 0) + (u.cache_creation_input_tokens ?? 0);
352
364
  }
365
+ let statusCache = null; // #5592: {id, sections} of this issue's one FORGE:STATUS comment, edited in place
353
366
  const post = async (marker, body, on = issue) => {
367
+ if (on === issue && isStatusPost(marker)) { // machine-state markers: a section of the one status comment, not a comment of their own
368
+ try {
369
+ const r = await writeStatus({ known: statusCache, comments: iss?.comments, trusted: isTrustedIssueComment, markers: Array.isArray(marker) ? marker : [marker], text: body, cap: capComment,
370
+ create: async (b) => /https?:\/\/\S+/.exec(String(await ghw(["issue", "comment", String(on), "-R", repo, "--body", b])))?.[0] ?? null,
371
+ patch: (id, b) => ghw(["api", "-X", "PATCH", `repos/${repo}/issues/comments/${id}`, "-f", `body=${b}`]) });
372
+ statusCache = { id: r.id, sections: r.sections };
373
+ return r.url;
374
+ } catch (e) { if (e?.deferCode) throw e; /* a failed status edit falls back to a plain comment below */ }
375
+ }
376
+ if (on === issue && isUpsertPost(marker)) { // one comment edited in place across requeues (the marker still leads the body)
377
+ return postUpsert({ gh: ghw, repo, issue: on, markers: marker, body, comments: iss?.comments, cap: capComment });
378
+ }
354
379
  const marks = (Array.isArray(marker) ? marker : [marker]).map((m) => `<!-- ${m} -->`).join("\n");
355
380
  const out = String(await ghw(["issue", "comment", String(on), "-R", repo, "--body", capComment(`${marks}\n${body}`)])).trim();
356
381
  return /https?:\/\/\S+/.exec(out)?.[0] ?? null;
@@ -585,6 +610,7 @@ export async function runCore(o) {
585
610
  if (deferTail) { postRun.add("lane-facts", postLaneFacts); postRun.add("trajectory", postTrajectory); } else await postTrajectory();
586
611
  }
587
612
  if (deferTail) postRun.add("teardown", () => teardown(reason, extra)); // last: the structure delta and guard read the worktree
613
+ if (reason === "merged" || reason === "invalid") await clearPipelineLabels({ gh: ghc, repo, issue }); // #5592: a merged or closed issue keeps no needs-human / parked:* / remediation-queue
588
614
  await releaseLease(reason, code, extra.mergedTo ?? null);
589
615
  done = { terminalReason: reason, detail, branch, worktree: wt, cost_usd: usage.cost_usd, tokens: { input: usage.input, output: usage.output, cache: usage.cache }, wall_ms: now() - t0, model_ms: modelMs, phases: phaseLedger.snapshot(),
590
616
  ...(laneHead && reason !== "merged" ? { laneHead: { ...laneHead } } : {}), light, ...(lightVerdict ? { light_eligibility: lightVerdict } : {}), ...(lightUpgrade ? { light_upgrade: lightUpgrade } : {}), // #4453
@@ -934,7 +960,8 @@ export async function runCore(o) {
934
960
  let decisionsNote = ""; // #4901: trusted FORGE:DECISION comments newer than the frozen contract, "" otherwise
935
961
  let carriedPasses = []; // #5331: validate ids that passed on the resume head (resume digest); carried into the builder result while HEAD is unchanged
936
962
  let resumeNote = ""; // #4400: the resume digest of the last run (resume.mjs), "" on a first run or with context_pack off
937
- const implementRestart = () => builderImplementPrompt(vcfg.mode, tcOpts()) + seqBuildNote + hotspotBuildRule(hotFacts) + enumeratingBuildRule(enumList) + invariantsBuildRule(vcfg.invariants) + exploreBuildRule(exploreCfg) + CONTINUE_NOTE.replace("BASE", lane) + resumeNote;
963
+ let uiOn = false; // #5330: the lane changes user-visible frontend (issue text, then contract deliverables): the design-system and visual self-check rules join its prompts
964
+ const implementRestart = () => builderImplementPrompt(vcfg.mode, tcOpts()) + seqBuildNote + hotspotBuildRule(hotFacts) + enumeratingBuildRule(enumList) + invariantsBuildRule(vcfg.invariants) + exploreBuildRule(exploreCfg) + uiBuildRule(uiOn, designConfig) + CONTINUE_NOTE.replace("BASE", lane) + resumeNote;
938
965
  /** #5334: records a builder session that ended without its result line (kill, signal) as one attempt; `at` = its start. */
939
966
  const killedAttempt = (n, e, opts, at) => attempt("implement", n, { killed: true, usage: e.usage ?? null, turns: e.turns ?? null, tools: toolStats(e.toolUses), costUsd: null, durationMs: now() - at, model: opts.model ?? laneModel() ?? null }, opts.mode, opts.trigger, opts.restartOf);
940
967
  async function flushInflight() {
@@ -1329,6 +1356,8 @@ export async function runCore(o) {
1329
1356
  const fetchP = step("fetch", async () => { try { await io.git(["fetch", "origin", lane], { cwd }); } catch { /* offline: use the local ref */ } });
1330
1357
  await step("claim", async () => {
1331
1358
  await label("investigating");
1359
+ // #5592: a live lane is not parked: needs-human, needs-human:*, parked:* and remediation-queue from an earlier run come off (a later park puts them back)
1360
+ await clearPipelineLabels({ gh: ghc, repo, issue, labels: iss.labels });
1332
1361
  await post("FORGE:STARTED", `Started work on #${issue} (base \`${lane}\`).`);
1333
1362
  if (recover) {
1334
1363
  // #4267: the batch decided to recover this issue itself; the label goes so the issue is live again.
@@ -1537,7 +1566,10 @@ export async function runCore(o) {
1537
1566
  const tH = now();
1538
1567
  if (heavyOn) {
1539
1568
  try {
1540
- const root = runTmp ?? join(wt, LEAN_DIR), binDir = join(root, "heavy", "bin"), path = toolchain?.env?.PATH ?? process.env.PATH ?? "";
1569
+ const root = runTmp ?? join(wt, LEAN_DIR), binDir = join(root, "heavy", "bin"), path0 = toolchain?.env?.PATH ?? process.env.PATH ?? "";
1570
+ // #5592: a tool that only exists in a project's .venv/bin or node_modules/.bin (poetry/uv in-project venv, monorepo service) is shimmed too, so the preflight probe and the shim agree
1571
+ let tracked = []; try { tracked = String(await git(["ls-files"])).split("\n").map((x) => x.trim()).filter(Boolean); } catch { /* no git listing */ }
1572
+ const path = withLocalBins(path0, projectBinDirs(wt, tracked));
1541
1573
  const names = await (io.writeHeavyShims ?? writeHeavyShims)(binDir, { path });
1542
1574
  if (names?.length) {
1543
1575
  heavyWaitsFile = join(root, "heavy-waits.jsonl");
@@ -1694,7 +1726,7 @@ export async function runCore(o) {
1694
1726
  const rec = { event: "CONTEXT_PACK", mode: ctxCfg.mode, ...ctxAb, lane_type: ctxLane, sources: p.sources, found: p.found, bytes: p.bytes, items: p.items, truncated: p.truncated,
1695
1727
  hash: p.hash, cached: r.cached, ...(p.recall ? { recall: p.recall.present ? "present" : "absent" } : {}), ...(r.errors?.length ? { errors: r.errors } : {}) };
1696
1728
  ev({ ...rec, pitfalls: inPack }); await emit(rec);
1697
- const seen = trustedComments.some((c) => String(c?.body ?? "").startsWith("<!-- FORGE:CONTEXT -->") && String(c.body).includes(`hash ${p.hash})`));
1729
+ const seen = trustedComments.some((c) => hasSection(c?.body, "FORGE:CONTEXT") && String(c.body).includes(`hash ${p.hash})`));
1698
1730
  if (p.items && !seen) { try { await post("FORGE:CONTEXT", renderContextRecord(p, { mode: ctxCfg.mode, laneType: ctxLane })); } catch { /* best effort */ } }
1699
1731
  T.decisions.push(`Context pack (${ctxCfg.mode}): ${p.items} item(s), ${p.bytes} bytes${p.truncated ? `, ${p.truncated} dropped` : ""}, ${ctxCfg.mode === "on" ? "given to the builder" : "recorded only"}`);
1700
1732
  return p;
@@ -1809,7 +1841,7 @@ export async function runCore(o) {
1809
1841
  for (const x of r.applied) T.decisions.push(`validate recipe rewrote ${x.id}: \`${x.from}\` -> \`${x.to}\``);
1810
1842
  r.contract = foldRegression(r.contract); // #5448: the blast-radius regression set runs as validate G# entries
1811
1843
  const e = autoPostDeployE2e(r.contract); // #5468: production-only e2e/manual rows become post-deploy with a generated check
1812
- for (const x of e.converted) { genChecks[x.check] = x.entry; T.decisions.push(`Production-only e2e/manual requirement ${x.id} frozen as post-deploy with generated check ${x.check}`); }
1844
+ for (const x of e.converted) { if (x.check) genChecks[x.check] = x.entry; T.decisions.push(`Production-only e2e/manual requirement ${x.id} frozen as post-deploy with ${x.check ? `generated check ${x.check}` : "no check (production observation window)"}`); }
1813
1845
  r.contract = e.contract;
1814
1846
  const d = deferChecklessPostDeploy(r.contract);
1815
1847
  if (d.converted.length) T.decisions.push(`Post-deploy with no registered check deferred to the orchestrator: ${d.converted.join(", ")}`);
@@ -1819,6 +1851,9 @@ export async function runCore(o) {
1819
1851
  if ((!io.probeCommand && !io.preflightRun) || !contract || typeof contract !== "object") return [];
1820
1852
  const files = String(await git(["ls-files"]).catch(() => "")).split("\n").map((x) => x.trim()).filter(Boolean);
1821
1853
  const env = laneEnv(), missing = new Set(), misses = []; // #4325: the env the validate commands run with
1854
+ // #5592: tools resolve where the lane runs them from: project-local .venv/bin and node_modules/.bin (as the heavy shims do)
1855
+ const local = projectBinDirs(wt, files);
1856
+ if (local.length) env.PATH = withLocalBins(env.PATH ?? process.env.PATH ?? "", local);
1822
1857
  if (io.probeCommand) {
1823
1858
  const { probes, dropped } = preflightProbes(contract, { repoHas: repoTracks(files) });
1824
1859
  if (dropped) T.anomalies.push(`Validate preflight probed ${probes.length} tool(s); ${dropped} more not probed`);
@@ -2035,7 +2070,11 @@ export async function runCore(o) {
2035
2070
  if (stale) {
2036
2071
  ev({ event: "CONTRACT_STALE", hash: fc.hash, scope: fc.scope, now: scopeHash, reason: stale });
2037
2072
  T.decisions.push(`Rerun: frozen contract ${fc.hash} is stale (${stale}); re-planning`);
2038
- } else { frozen = fc.contract; hash = fc.hash; priorAmendments = fc.amendments ?? []; T.decisions.push(`Rerun: frozen contract ${hash} recovered from the issue`); }
2073
+ } else {
2074
+ frozen = fc.contract; hash = fc.hash; priorAmendments = fc.amendments ?? []; T.decisions.push(`Rerun: frozen contract ${hash} recovered from the issue`);
2075
+ const ad = applyRequirementDecisions(frozen, trustedComments); // #5547: a structured operator decision amends the frozen row
2076
+ if (ad.applied.length) { frozen = deferChecklessPostDeploy(ad.contract).contract; T.decisions.push(`FORGE:DECISION applied to the frozen contract: ${ad.applied.join(", ")} tracked post-deploy`); }
2077
+ }
2039
2078
  }
2040
2079
  }
2041
2080
  if ((resumed || salvagedRef || recover) && ctxCfg.mode !== "off") {
@@ -2072,7 +2111,7 @@ export async function runCore(o) {
2072
2111
  const tPack = now(); packP = contextPackStep(); ctxPack = await within(packP, waitMs); setupStep("context_pack", tPack);
2073
2112
  if (ctxPack === TIMED_OUT) { ctxPack = null; T.decisions.push(`Context pack not ready in ${waitMs / 1000}s: the plan starts without it`); }
2074
2113
  }
2075
- const planPrompt = () => builderPlanPrompt(issue, tcOpts()) + hotspotPlanNote(hotFacts) + enumeratingPlanNote(enumList) + invariantsPlanNote(vcfg.invariants) + reproPlanNote(reproOn()) + docsPlanNote(docsConfig) + pagePlanNote(pagesConfig) + unrunnableValidateNote(testRunners) + explorePlanRule(exploreCfg) + (ctxCfg.mode === "on" ? contextPackNote(ctxPack) : "");
2114
+ const planPrompt = () => builderPlanPrompt(issue, tcOpts()) + uiBuildRule(uiOn = uiOn || uiIssue(iss ?? {}), designConfig) + hotspotPlanNote(hotFacts) + enumeratingPlanNote(enumList) + invariantsPlanNote(vcfg.invariants) + reproPlanNote(reproOn()) + docsPlanNote(docsConfig) + pagePlanNote(pagesConfig) + unrunnableValidateNote(testRunners) + explorePlanRule(exploreCfg) + (ctxCfg.mode === "on" ? contextPackNote(ctxPack) : "");
2076
2115
  let lightDone = false, lightCommits = false;
2077
2116
  let ffPlan = "full", ffGo = false, lightElig = elig, lightPred = null, ffTriage = null; // #5426: how the plan call runs; ffGo = fast-forward to the light step
2078
2117
  const ffTriageOf = async (raw) => parseTriage(raw, await io.fs.read(`${wt}/${INVESTIGATION_FILE}`).catch(() => ""));
@@ -2142,7 +2181,7 @@ export async function runCore(o) {
2142
2181
  T.plan = "skipped"; T.implement = "skipped"; T.review = "skipped"; T.pr = "none"; T.merge = "n/a";
2143
2182
  T.decisions.push(`Builder verdict: ${result.status}`);
2144
2183
  // #5152: already-fixed is delivered behaviour (`completed`); only invalid is dropped scope (`not planned`)
2145
- await Promise.all([result.status === "already-fixed" && (await closeBlockers("completed")).length ? null : ghw(["issue", "close", String(issue), "-R", repo, "--reason", result.status === "already-fixed" ? "completed" : "not planned"]), label("invalid")]); // #5437: independent calls
2184
+ await Promise.all([result.status === "already-fixed" && (await closeBlockers("completed", resumed?.pr ?? null)).length ? null : ghw(["issue", "close", String(issue), "-R", repo, "--reason", result.status === "already-fixed" ? "completed" : "not planned"]), label("invalid")]); // #5437: independent calls
2146
2185
  if (result.status === "invalid") { const f = await resolveFindingLabel({ io, issue, labels: iss.labels, reason: "invalid" }); if (f.error) T.anomalies.push(`finding label not resolved: ${f.error}`); } // #5254
2147
2186
  return await finish("invalid", result.summary ?? result.status, result.status === "already-fixed" ? { close: "already-fixed" } : {});
2148
2187
  }
@@ -2176,20 +2215,33 @@ export async function runCore(o) {
2176
2215
  return sq.contract;
2177
2216
  };
2178
2217
  contract = snapContract(contract);
2179
- let vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, testPlan: reproOn() });
2218
+ const wtRead = (p) => { try { return readFileSync(join(wt, p), "utf8"); } catch { return ""; } }; // #5585: noindex pages are not public
2219
+ let vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, testPlan: reproOn(), readFile: wtRead });
2180
2220
  const missed = await preflightValidates(contract); // #4328: validate commands the host cannot run share the one correction
2181
2221
  let misses = missed;
2182
- if ((!vc.ok || missed.length || testRunnerProblems(contract, testRunners).length) && sessionId) {
2183
- const problems = [...vc.problems, ...preflightProblems(missed), ...testRunnerProblems(contract, testRunners)];
2184
- T.decisions.push(`Contract rejected (${problems[0]}); resumed once`);
2222
+ const correctContract = async (problems, note) => {
2223
+ T.decisions.push(`Contract rejected (${problems[0]}); ${note}`);
2185
2224
  await builder(++attemptN, contractCorrectionPrompt(problems), sessionId, false, planPrompt, { trigger: "contract_correction" });
2186
2225
  contract = freezeRewrites(dropScope(await readContract()));
2187
2226
  await persistGenChecks();
2188
2227
  await refreshIssue("contract validation");
2189
2228
  contract = snapContract(contract);
2190
- vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, testPlan: reproOn() });
2229
+ vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, testPlan: reproOn(), readFile: wtRead });
2230
+ };
2231
+ if ((!vc.ok || missed.length || testRunnerProblems(contract, testRunners).length) && sessionId) {
2232
+ await correctContract([...vc.problems, ...preflightProblems(missed), ...testRunnerProblems(contract, testRunners)], "resumed once");
2191
2233
  if (missed.length) misses = await preflightValidates(contract);
2192
2234
  }
2235
+ // #5623: builder-correctable contract problems get up to contractMaxCorrections rounds (default 3), each with only the
2236
+ // problems still open; the round ends early when a correction changes nothing (same problem set twice).
2237
+ let rounds = vc.ok ? 0 : 1, lastProblems = null;
2238
+ while (!vc.ok && sessionId && rounds < contractMaxCorrections && contractSelfCorrectable(vc.problems)) {
2239
+ const key = JSON.stringify([...vc.problems].sort());
2240
+ if (key === lastProblems) break;
2241
+ lastProblems = key; rounds++;
2242
+ await correctContract(vc.problems, `${vc.problems.length} problem(s) still open, correction round ${rounds} of ${contractMaxCorrections}`);
2243
+ }
2244
+ if (!vc.ok) ev({ event: "CONTRACT_INVALID_RULES", rules: contractRuleCounts(vc.problems) }), await emit({ event: "CONTRACT_INVALID_RULES", rules: contractRuleCounts(vc.problems) }); // #5587: per-rule counts for the batch false-park rate
2193
2245
  planMisses = misses;
2194
2246
  if (missed.length) {
2195
2247
  ev({ event: "VALIDATE_PREFLIGHT", misses: misses.map((m) => ({ ids: m.ids, tool: m.tool, kind: m.kind, source: m.source })), found: missed.map((m) => ({ ids: m.ids, tool: m.tool, kind: m.kind, source: m.source })), corrected: misses.length === 0 });
@@ -2199,7 +2251,7 @@ export async function runCore(o) {
2199
2251
  }
2200
2252
  }
2201
2253
  await flushStages(result ?? { status: "fixed" }, ["investigation"]); // always posted: FORGE:INVESTIGATION/VALIDATE are read downstream
2202
- if (!vc.ok) return await needsHuman(`The builder's contract is still invalid after one correction:\n${vc.problems.slice(0, 12).map((x) => `- ${x}`).join("\n")}`, OUTCOME_CODES.CONTRACT_INVALID, { ...(issueEdited ? { issueEdited: true } : {}), ...(vc.problems.every((x) => /: quote is not verbatim/.test(x)) ? { quoteMismatch: true } : {}) });
2254
+ if (!vc.ok) return await needsHuman(`The builder's contract is still invalid after ${rounds} correction(s):\n${vc.problems.slice(0, 12).map((x) => `- ${x}`).join("\n")}`, OUTCOME_CODES.CONTRACT_INVALID, { ...(issueEdited ? { issueEdited: true } : {}), ...(vc.problems.every((x) => /: quote is not verbatim/.test(x)) ? { quoteMismatch: true } : {}) });
2203
2255
  frozen = historyRows(contract); // #4694 guards
2204
2256
  frozen = withDecisionRows(frozen, readDecisionIndex(repo)); // #4695: anchored decisions on the deliverable paths; one index read
2205
2257
  const hRows = (frozen.preserve ?? []).filter((p) => p.source === "decision");
@@ -2215,8 +2267,16 @@ export async function runCore(o) {
2215
2267
  } else {
2216
2268
  T.validate = lightDone ? "light lane (no plan session)" : "resumed (existing branch)";
2217
2269
  }
2270
+ const dgFiles = (frozen?.deliverables ?? []).map((d) => d?.path).filter(Boolean);
2271
+ const designComments = (iss?.comments ?? []).filter(isTrustedIssueComment);
2272
+ const designRoute = designGate({ files: dgFiles, cfg: designConfig, comments: designComments, labels: iss?.labels }); // #5330: opt-in (forge.yaml design.routes): a page without a FORGE:DESIGN_SPEC goes to /design
2273
+ if (designRoute.route) {
2274
+ ev({ event: "DESIGN_ROUTED", pages: designRoute.pages, blocked: designRoute.blocked });
2275
+ T.decisions.push(`Design gate: ${designRoute.reason}${designRoute.blocked ? " (design.gate: blocking, lane stopped)" : " (advisory)"}`);
2276
+ if (designRoute.blocked) return await needsHuman(`Design gate (forge.yaml design.gate: blocking): ${designRoute.reason}.\n\nRun /design on #${issue}; a FORGE:DESIGN_SPEC comment or the \`${designConfig.specLabel}\` label lifts the hold.`, OUTCOME_CODES.DESIGN_SPEC_REQUIRED, { ask: `Run /design for #${issue} (${designRoute.pages.slice(0, 3).join(", ")})` });
2277
+ }
2218
2278
  { // #5447: the test plan's declared env is checked on the host the lane runs on before building; a missing runner is provisioned once, else the lane ends env.tool_missing (the orchestrator re-places it on a host that has it)
2219
- const probeEnv = async () => { const miss = []; for (const t of declaredEnv(frozen)) { const r = io.runCommand ? await io.runCommand({ command: t === "pytest" ? "python3 -m pytest --version" : `command -v ${t}`, cwd: wt, timeoutMs: 30000, env: laneEnv() }).catch(() => ({ rc: 1 })) : { rc: 0 }; if ((r?.rc ?? 0) !== 0) miss.push(t); } return miss; };
2279
+ const probeEnv = async () => { const miss = []; for (const t of declaredEnv(frozen)) { const r = io.runCommand ? await io.runCommand({ command: t === "pytest" ? "python3 -m pytest --version" : `command -v ${t} >/dev/null || { test -d node_modules/${t} && ! test -e node_modules/.bin/${t}; } || ls -d .venv/lib/python*/site-packages/${t} >/dev/null 2>&1`, cwd: wt, timeoutMs: 30000, env: laneEnv() }).catch(() => ({ rc: 1 })) : { rc: 0 }; if ((r?.rc ?? 0) !== 0) miss.push(t); } return miss; };
2220
2280
  let envMiss = await probeEnv();
2221
2281
  if (envMiss.length) {
2222
2282
  try {
@@ -2282,7 +2342,7 @@ export async function runCore(o) {
2282
2342
  if (!ctxPack && packP) ctxPack = await packP.catch(() => null); // #5434: a pack that missed the plan wait still reaches the build
2283
2343
  const openPaths = (frozen?.deliverables ?? []).map((d) => d?.path); // #5347: facts for the build's opening batch
2284
2344
  const openMap = io.runCommand ? await readTestMapAtRef(git, base).catch(() => null) : null;
2285
- const implementPrompt = builderImplementPrompt(vcfg.mode, tcOpts()) + seqBuildNote + buildOpeningNote({ paths: openPaths, tests: selectCommands(openMap, openPaths), packFiles: ctxCfg.mode === "on" ? ctxPack?.files : [] }) + hotspotBuildRule(hotFacts) + enumeratingBuildRule(enumList) + invariantsBuildRule(vcfg.invariants) + exploreBuildRule(exploreCfg) + generatorNote(surfaceClaim?.generated) + (planned ? "" : (fromCheckpoint ? CONTINUE_NOTE : RERUN_NOTE).replace("BASE", lane)) + (salvagedRef ? SALVAGE_NOTE.replaceAll("REF", salvagedRef) : "") + recoverNote() + (planned ? "" : resumeNote + decisionsNote);
2345
+ const implementPrompt = builderImplementPrompt(vcfg.mode, tcOpts()) + seqBuildNote + buildOpeningNote({ paths: openPaths, tests: selectCommands(openMap, openPaths), packFiles: ctxCfg.mode === "on" ? ctxPack?.files : [] }) + hotspotBuildRule(hotFacts) + enumeratingBuildRule(enumList) + invariantsBuildRule(vcfg.invariants) + exploreBuildRule(exploreCfg) + uiBuildRule(uiOn = uiOn || uiChanged(dgFiles).length > 0, designConfig) + designGateNote(designRoute) + generatorNote(surfaceClaim?.generated) + (planned ? "" : (fromCheckpoint ? CONTINUE_NOTE : RERUN_NOTE).replace("BASE", lane)) + (salvagedRef ? SALVAGE_NOTE.replaceAll("REF", salvagedRef) : "") + recoverNote() + (planned ? "" : resumeNote + decisionsNote);
2286
2346
  liveKeys = ["implementation"];
2287
2347
  { const f = await gateSetup(); if (f) return f; } // #5434: resumed or frozen lanes skip the plan
2288
2348
  stage = "implement"; phaseLedger.enter("implement");
@@ -3010,9 +3070,15 @@ export async function runCore(o) {
3010
3070
  const docsFail = docsConfig ? await docsFailures({ cfg: docsConfig, files, result, diff: String(await git(["diff", "-U0", `${base}...HEAD`]).catch(() => "")), tracked: String(await git(["ls-files"]).catch(() => "")).split("\n").filter(Boolean), run: io.runCommand ? async ({ command }) => (await io.runCommand({ command, cwd: wt, timeoutMs: vcfg.precheckTimeoutSeconds * 1000, env: laneEnv() }).then((x) => x?.r ?? x)) ?? { rc: 127 } : null }) : [];
3011
3071
  // #5428: forge.yaml pages: a public page needs design, SEO and GEO briefs and passes the deterministic page checks; unset = no check
3012
3072
  const pageFail = pagesConfig ? await pageFailures({ cfg: pagesConfig, files, result, diff: String(await git(["diff", "-U0", `${base}...HEAD`]).catch(() => "")), tracked: String(await git(["ls-files"]).catch(() => "")).split("\n").filter(Boolean), readFile: (p) => { try { return readFileSync(join(wt, p), "utf8"); } catch { return ""; } }, designApproved: designLabelApproved(iss?.labels) || designSpecApproved((iss?.comments ?? []).filter(isTrustedIssueComment)), run: io.runCommand ? async ({ command }) => (await io.runCommand({ command, cwd: wt, timeoutMs: vcfg.precheckTimeoutSeconds * 1000, env: laneEnv() }).then((x) => x?.r ?? x)) ?? { rc: 127 } : null }) : [];
3073
+ // #5330: forge.yaml design.routes (opt-in, blocking only): a user-visible page needs an approved spec and passes the deterministic visual critique
3074
+ const designFail = designFailures({ cfg: designConfig, files, specs: designSpecOk({ comments: (iss?.comments ?? []).filter(isTrustedIssueComment), labels: iss?.labels, cfg: designConfig }), readFile: (p) => { try { return readFileSync(join(wt, p), "utf8"); } catch { return ""; } } });
3013
3075
  // #5284: forge.yaml topology.prod_parity: declared production-only surfaces this diff touches need a check result or a justification
3014
3076
  const parityRules = parseProdParity(prodParity);
3015
3077
  const prodParityFailures = parityRules.length && io.runCommand ? await prodParityOf({ rules: parityRules, changedFiles: files, result, run: async ({ command }) => (await io.runCommand({ command, cwd: wt, timeoutMs: vcfg.precheckTimeoutSeconds * 1000, env: laneEnv() }).then((x) => x?.r ?? x)) ?? { rc: 127 } }) : [];
3078
+ // #5338: a declared interface whose provider and consumer no longer agree (route, signature, payload) is flagged at lane review
3079
+ const seamRecs = [...readDecisionIndex(repo), ...pendingDecisions].filter((r) => r.seam);
3080
+ const ls = seamRecs.length ? String(await git(["ls-files"]).catch(() => "")).split("\n").filter(Boolean) : [];
3081
+ const seamFail = seamRecs.length ? seamFailures({ records: seamRecs, changedFiles: files, read: (p) => { try { return readFileSync(join(wt, p), "utf8"); } catch { return ""; } }, list: () => ls, superseded: pendingDecisions.map((d) => d.supersedes).filter(Boolean) }) : [];
3016
3082
  // #4705: only the part not hidden behind the validate rerun; 0 when the gate errored or skipped
3017
3083
  const guardRunMs = guardEv && !guardEv.error ? Math.max(0, now() - gateT0 - validateMs) : 0;
3018
3084
  guardAddedMs += guardRunMs;
@@ -3029,7 +3095,7 @@ export async function runCore(o) {
3029
3095
  baselineRuns.push({ ...b, rc: Number.isInteger(x?.rc) ? x.rc : 1, output: String(x?.output ?? "") });
3030
3096
  }
3031
3097
  if (baselineRuns.length) ev({ event: "BASELINES_RUN", runs: baselineRuns.map((b) => ({ run: b.run, rc: b.rc })) });
3032
- const pc = precheck({ baselineFailures: baselineFailures(baselineRuns), contract: effective, result, changedFiles: files, ignore: IGNORE, ciVerified, hotspots, repro: (adequacyIn.repro = repro), validateRuns, repoHas, frozen, checkIds, guardFailures, coupledFailures: await coupledOf(files), relaxationFailures: relaxationFailures(rx), routeFailures, docsFailures: docsFail, pageFailures: pageFail, docsPaths: docsConfig ? [...(docsConfig.paths ?? []), ...(docsConfig.registries ?? [])] : null, prodParityFailures, newOffKeys: await newOffKeysOf(), uiBrowser: uiBrowserOf(files), substitutedRuns, removedPaths, baseFiles: subBaseFiles });
3098
+ const pc = precheck({ baselineFailures: baselineFailures(baselineRuns), contract: effective, result, changedFiles: files, ignore: IGNORE, ciVerified, hotspots, repro: (adequacyIn.repro = repro), validateRuns, repoHas, frozen, checkIds, guardFailures, coupledFailures: await coupledOf(files), relaxationFailures: relaxationFailures(rx), routeFailures, docsFailures: docsFail, pageFailures: [...pageFail, ...designFail], seamFailures: seamFail, docsPaths: docsConfig ? [...(docsConfig.paths ?? []), ...(docsConfig.registries ?? [])] : null, prodParityFailures, newOffKeys: await newOffKeysOf(), uiBrowser: uiBrowserOf(files), substitutedRuns, removedPaths, baseFiles: subBaseFiles });
3033
3099
  // #5447: an install failure for a package the changed files import blocks (env.tool_missing); unrelated ones are logged
3034
3100
  const depFail = depInstallFailures({ results: depResults, changedFiles: files });
3035
3101
  for (const l of depFail.logged) if (!T.decisions.includes(l)) T.decisions.push(l);
@@ -3116,10 +3182,10 @@ export async function runCore(o) {
3116
3182
  const ids = d.state === "nonconforming" ? loneE2eRows(d.failures) : null;
3117
3183
  const cv = ids ? autoPostDeployE2e(effective, ids) : null;
3118
3184
  if (cv && cv.converted.length === ids.length) {
3119
- for (const x of cv.converted) genChecks[x.check] = x.entry;
3120
- effective = cv.contract;
3185
+ for (const x of cv.converted) if (x.check) genChecks[x.check] = x.entry;
3186
+ effective = deferChecklessPostDeploy(cv.contract).contract; // #5524: checkless rows route to the orchestrator
3121
3187
  await persistGenChecks();
3122
- T.decisions.push(`FORGE:DECISION e2e_unverified on ${ids.join(", ")} converted to post-deploy checks ${cv.converted.map((x) => x.check).join(", ")}: the observable is production-only`);
3188
+ T.decisions.push(`FORGE:DECISION e2e_unverified on ${ids.join(", ")} converted to post-deploy ${cv.converted.map((x) => x.check ?? "checkless").join(", ")}: the observable is production-only`);
3123
3189
  d = { state: "conforms", failures: [], review: d.review ?? review, by: "review" };
3124
3190
  }
3125
3191
  }
@@ -3218,7 +3284,7 @@ export async function runCore(o) {
3218
3284
  const sha = String(await git(["rev-parse", base]).catch(() => "")).trim().slice(0, 12) || base;
3219
3285
  const note = `Already fixed on the base: the repro test passes on \`${base}\` (${sha}) without this change, and the diff changes no source file. Closing as delivered.\n\n${list}`;
3220
3286
  T.decisions.push(`Already fixed on base ${sha} (repro BASE=RAN HEAD=RAN)`);
3221
- if (!(await closeBlockers("completed")).length) await ghw(["issue", "close", String(issue), "-R", repo, "--reason", "completed", "--comment", note]);
3287
+ if (!(await closeBlockers("completed", resumed?.pr ?? null)).length) await ghw(["issue", "close", String(issue), "-R", repo, "--reason", "completed", "--comment", note]);
3222
3288
  return await finish("invalid", `already fixed on base ${sha}`, { close: "already-fixed" });
3223
3289
  }
3224
3290
  if (outcome.state === "review.unparseable") return await needsHuman(`The conformance reviewer returned no parseable JSON twice; nothing merged.`, OUTCOME_CODES.REVIEW_NO_VERDICT);
@@ -3365,6 +3431,19 @@ export async function runCore(o) {
3365
3431
  };
3366
3432
  let blockStartedAt = null, blockPollIndex = 0;
3367
3433
  const conflictFiles = async () => (await gitOut(["diff", "--name-only", "--diff-filter=U"])).split("\n").map((x) => x.trim()).filter(Boolean);
3434
+ /** #5583 follow-up: the builder resolved a base-sync whose conflicts were all documentation files, and the lane's non-doc
3435
+ * diff against the new base equals its non-doc diff against the old fork point (so no code changed in the resolution). */
3436
+ const DOC_FILE_RE = /\.(md|mdx|markdown|rst|adoc|txt)$/i, DOC_EXCLUDES = ["md", "mdx", "markdown", "rst", "adoc", "txt"].map((e) => `:(exclude)*.${e}`);
3437
+ const docsOnlyConflict = async (conflicted, laneBefore) => {
3438
+ if (!conflicted.length || !conflicted.every((f) => DOC_FILE_RE.test(f))) return false;
3439
+ try {
3440
+ const fork = await gitOut(["merge-base", laneBefore, "HEAD^2"]);
3441
+ if (!/^[0-9a-f]{7,}$/.test(fork)) return false; // gitOut swallows errors as "": never treat that as "unchanged"
3442
+ const was = await gitOut(["diff", fork, laneBefore, "--", ".", ...DOC_EXCLUDES]);
3443
+ const now = await gitOut(["diff", "HEAD^2", "HEAD", "--", ".", ...DOC_EXCLUDES]);
3444
+ return was === now;
3445
+ } catch { return false; }
3446
+ };
3368
3447
  const unresolved = async () => (await conflictFiles()).length > 0 || (await gitOut(["grep", "-n", "-e", "^<<<<<<< ", "-e", "^>>>>>>> "])) !== ""
3369
3448
  || (await gitOut(["diff", "--check"])) !== "" || (await gitOut(["rev-parse", "-q", "--verify", "MERGE_HEAD"])) !== "";
3370
3449
  const syncRow = [];
@@ -3388,7 +3467,7 @@ export async function runCore(o) {
3388
3467
  // #4386: conflicts only in sequence files (numbered, journal, snapshot, their index) resolve without a builder
3389
3468
  // #4588: union / JSON-map / generated files resolve first; only the files left go to the sequence resolver
3390
3469
  const bm = o.baseMerge, cr = !clean && io.conflictResolve && bm && Object.values(bm).some((v) => v?.length) ? await io.conflictResolve({ cwd: wt, files, cfg: bm }).catch(() => null) : null;
3391
- let seqFiles = cr?.resolved?.length ? cr.remaining : files, crDone = false;
3470
+ let seqFiles = cr?.resolved?.length ? cr.remaining : files, crDone = false, docsOnlySync = false;
3392
3471
  if (cr?.resolved?.length && !seqFiles.length) { try { await git(["commit", "--no-edit"]); crDone = true; } catch { /* the builder finishes the merge */ } }
3393
3472
  if (cr?.note) T.decisions.push(`Base-sync ${syncs}: ${cr.note}`);
3394
3473
  const rs = !clean && !crDone && seqFiles.length && io.sequenceResolve ? ((await io.sequenceResolve({ cwd: wt, files: seqFiles }).catch((e) => ({ unsupported: String(e?.message ?? e) }))) ?? {}) : null;
@@ -3416,6 +3495,8 @@ export async function runCore(o) {
3416
3495
  how = `builder resolved ${files.length} conflicted file(s) and committed the merge`;
3417
3496
  const r2 = await readResult();
3418
3497
  tests = Array.isArray(r2?.tests) && r2.tests.length ? r2.tests.map((t) => (typeof t === "string" ? t : `${t.command}: ${t.result}`)).join("; ") : NR_TESTS;
3498
+ docsOnlySync = await docsOnlyConflict(files, before); // #5583 follow-up
3499
+ if (docsOnlySync) { T.decisions.push(`Base-sync ${syncs}: conflicts only in documentation (${files.join(", ")}) and the lane's code diff is unchanged; no re-review`); tests = "not required (documentation-only conflicts; lane code diff unchanged)"; }
3419
3500
  }
3420
3501
  const sq = await sequenceHandoff(`base-sync ${syncs}`, detResolved ? { laneRef: before } : {}); // #4322: a clean text merge can still bring a taken number
3421
3502
  if (sq?.done) return sq.done;
@@ -3442,6 +3523,7 @@ export async function runCore(o) {
3442
3523
  if (remoteVerify && after !== before) { const v = await ciVerify("base-sync"); if (v.done) return v.done; ciFixes = v.fixes; }
3443
3524
  const engineOnly = !ciFixes && !pm.fixed && !dupFixed && (clean || detResolved) && (!sq?.renumbered || sq.deterministic); // #4386: no builder touched the delta
3444
3525
  if (!isSplit && engineOnly && (detResolved || sq?.deterministic)) rereview = "not required (deterministic renumber + base merge)";
3526
+ else if (!isSplit && docsOnlySync && !ciFixes && !pm.fixed && !dupFixed && !sq?.renumbered) rereview = "not required (documentation-only conflicts; lane code diff unchanged)";
3445
3527
  else if (!isSplit && (!clean || sq?.renumbered || ciFixes || pm.fixed || dupFixed)) {
3446
3528
  let rv = await doReview();
3447
3529
  if (rv.env) return await envNeedsHuman(rv.env);
@@ -3776,6 +3858,10 @@ export async function runCore(o) {
3776
3858
  try { // #4695/#4737: FORGE:DECISION records and supersession are persisted only after the merge
3777
3859
  const rec = await recordDecisions(pendingDecisions, { issue, repo, post });
3778
3860
  if (rec.length) T.decisions.push(`FORGE:DECISION: ${rec.map((d) => d.id).join(", ")}`);
3861
+ for (const d of rec.filter((x) => x.supersedes && x.consumers?.length)) { // #5338: a superseded interface reopens/notifies its consumers, or files one issue per named consumer
3862
+ const n = await notifyConsumers({ rec: d, pr, repo, gh: ghw });
3863
+ T.decisions.push(`Interface ${d.supersedes} superseded by ${d.id}: ${n.map((x) => `${x.consumer} ${x.action}${x.issue ? ` #${x.issue}` : ""}`).join(", ")}`);
3864
+ }
3779
3865
  } catch (e) { T.anomalies.push(`decision records not posted: ${String(e?.message ?? e).slice(0, 160)}`); }
3780
3866
  for (const sp of supersededIds(effective, guardSel)) { // #4693: the reviewer accepted the supersedes amendment; tell the guarded issue
3781
3867
  try { await ghw(["issue", "comment", sp.guard.slice(1), "-R", repo, "--body", supersessionComment({ guard: sp.guard, pr, why: sp.why })]); ev({ event: "supersedes_accepted", guard: sp.guard, pr }); T.decisions.push(`Guard ${sp.guard} superseded: ${sp.why}`); } catch (e) { T.anomalies.push(`supersession of ${sp.guard} not posted: ${String(e?.message ?? e).slice(0, 160)}`); }