forgedock 1.67.0 → 1.68.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 -0
  2. package/bin/engine/outcome-codes.mjs +1 -0
  3. package/bin/engine-cli.mjs +99 -12
  4. package/bin/engine.mjs +10 -0
  5. package/bin/forgedock.mjs +17 -1
  6. package/bin/help-text.mjs +1 -0
  7. package/bin/lean/admission.mjs +21 -0
  8. package/bin/lean/admission.test.mjs +30 -0
  9. package/bin/lean/advisory.test.mjs +25 -10
  10. package/bin/lean/amendment-schema.mjs +3 -4
  11. package/bin/lean/attempts.mjs +34 -31
  12. package/bin/lean/attempts.test.mjs +33 -19
  13. package/bin/lean/basered.mjs +26 -0
  14. package/bin/lean/batch-health.mjs +17 -12
  15. package/bin/lean/batch-health.test.mjs +39 -11
  16. package/bin/lean/batch.test.mjs +51 -2
  17. package/bin/lean/ci-gate.mjs +2 -90
  18. package/bin/lean/ci-gate.test.mjs +1 -127
  19. package/bin/lean/ci-precheck.mjs +25 -8
  20. package/bin/lean/ci-precheck.test.mjs +24 -0
  21. package/bin/lean/clear-breaker.test.mjs +4 -3
  22. package/bin/lean/commentstate.mjs +10 -5
  23. package/bin/lean/commentstate.test.mjs +12 -1
  24. package/bin/lean/conformance.e2e.test.mjs +9 -6
  25. package/bin/lean/conformance.mjs +56 -196
  26. package/bin/lean/conformance.test.mjs +40 -376
  27. package/bin/lean/depcache.mjs +100 -10
  28. package/bin/lean/depcache.test.mjs +105 -0
  29. package/bin/lean/docsgate.mjs +0 -32
  30. package/bin/lean/docsgate.test.mjs +2 -23
  31. package/bin/lean/effects-cap.test.mjs +9 -1
  32. package/bin/lean/effects-killtree.test.mjs +35 -0
  33. package/bin/lean/effects.mjs +42 -24
  34. package/bin/lean/engine-readmit.test.mjs +35 -0
  35. package/bin/lean/envgap.mjs +93 -0
  36. package/bin/lean/envgap.test.mjs +53 -0
  37. package/bin/lean/execution.mjs +10 -4
  38. package/bin/lean/execution.test.mjs +12 -0
  39. package/bin/lean/failure-census.mjs +170 -0
  40. package/bin/lean/failure-census.test.mjs +59 -0
  41. package/bin/lean/guardgate.test.mjs +2 -3
  42. package/bin/lean/heavy.mjs +33 -4
  43. package/bin/lean/heavy.test.mjs +38 -6
  44. package/bin/lean/hotarea.mjs +0 -36
  45. package/bin/lean/hotarea.test.mjs +1 -22
  46. package/bin/lean/issuewatch-verify.mjs +19 -4
  47. package/bin/lean/issuewatch.mjs +21 -4
  48. package/bin/lean/issuewatch.test.mjs +48 -1
  49. package/bin/lean/lane-audit-gap.mjs +66 -0
  50. package/bin/lean/lane-audit-gap.test.mjs +59 -0
  51. package/bin/lean/lane-audit-llm.mjs +5 -0
  52. package/bin/lean/lane-audit-query.mjs +47 -0
  53. package/bin/lean/lane-audit-query.test.mjs +44 -0
  54. package/bin/lean/lane-audit-signatures.mjs +33 -0
  55. package/bin/lean/lane-audit.mjs +110 -0
  56. package/bin/lean/lane-audit.test.mjs +97 -0
  57. package/bin/lean/lane-recovery.test.mjs +33 -0
  58. package/bin/lean/lanecheck.mjs +5 -3
  59. package/bin/lean/lanecheck.test.mjs +6 -0
  60. package/bin/lean/lean.mjs +206 -148
  61. package/bin/lean/lean.test.mjs +406 -190
  62. package/bin/lean/limits.mjs +17 -0
  63. package/bin/lean/limits.test.mjs +15 -1
  64. package/bin/lean/live-execution.mjs +21 -2
  65. package/bin/lean/live-execution.test.mjs +39 -0
  66. package/bin/lean/orchestrate-attempts.test.mjs +17 -9
  67. package/bin/lean/orchestrate-envhold.test.mjs +47 -0
  68. package/bin/lean/orchestrate-heldroot.test.mjs +72 -0
  69. package/bin/lean/orchestrate-hostfallback.test.mjs +59 -1
  70. package/bin/lean/orchestrate-overload-recovery.test.mjs +37 -0
  71. package/bin/lean/orchestrate-pause.test.mjs +53 -1
  72. package/bin/lean/orchestrate-reconcile.test.mjs +17 -0
  73. package/bin/lean/orchestrate-relaunch-gates.test.mjs +57 -0
  74. package/bin/lean/orchestrate-stacking.test.mjs +10 -0
  75. package/bin/lean/orchestrate.mjs +188 -33
  76. package/bin/lean/postdeploy-check.test.mjs +1 -3
  77. package/bin/lean/precheck.mjs +20 -0
  78. package/bin/lean/preflight.mjs +100 -11
  79. package/bin/lean/preflight.test.mjs +44 -4
  80. package/bin/lean/prompts.mjs +10 -21
  81. package/bin/lean/recurrence.mjs +6 -148
  82. package/bin/lean/recurrence.test.mjs +11 -147
  83. package/bin/lean/release-flakes.mjs +14 -2
  84. package/bin/lean/release-flakes.test.mjs +17 -1
  85. package/bin/lean/release-ledger.mjs +19 -1
  86. package/bin/lean/release-ledger.test.mjs +23 -0
  87. package/bin/lean/release-preflight.mjs +28 -0
  88. package/bin/lean/release-preflight.test.mjs +42 -1
  89. package/bin/lean/release-review.mjs +40 -5
  90. package/bin/lean/release-review.test.mjs +43 -2
  91. package/bin/lean/release.mjs +43 -14
  92. package/bin/lean/release.test.mjs +32 -0
  93. package/bin/lean/retry.mjs +1 -1
  94. package/bin/lean/retry.test.mjs +6 -1
  95. package/bin/lean/rotator.mjs +9 -0
  96. package/bin/lean/rotator.test.mjs +11 -1
  97. package/bin/lean/sandbox-remote.mjs +16 -9
  98. package/bin/lean/schedd.mjs +11 -6
  99. package/bin/lean/schedd.test.mjs +65 -5
  100. package/bin/lean/selfreview.mjs +1 -1
  101. package/bin/lean/statuscomment.mjs +4 -1
  102. package/bin/lean/validate-catalog.mjs +108 -0
  103. package/bin/lean/validate-catalog.test.mjs +46 -1
  104. package/bin/lean/verify.mjs +1 -1
  105. package/bin/pool/affinity.test.mjs +91 -0
  106. package/bin/pool/agent.mjs +143 -9
  107. package/bin/pool/cache-sweep.mjs +31 -10
  108. package/bin/pool/ci-autoscale.mjs +160 -0
  109. package/bin/pool/cli.mjs +37 -8
  110. package/bin/pool/docker.mjs +3 -0
  111. package/bin/pool/engine-placement.test.mjs +94 -0
  112. package/bin/pool/lane-target.mjs +41 -0
  113. package/bin/pool/lane-tools.mjs +7 -2
  114. package/bin/pool/lane-tools.test.mjs +9 -0
  115. package/bin/pool/mirror-seed.mjs +15 -11
  116. package/bin/pool/router.mjs +88 -32
  117. package/bin/pool/version.mjs +29 -2
  118. package/bin/review-staging.mjs +11 -3
  119. package/bin/runner.mjs +59 -11
  120. package/bin/stats/release.mjs +7 -0
  121. package/bin/stats/release.test.mjs +20 -0
  122. package/bin/stats/scorecard.mjs +187 -0
  123. package/bin/stats/scorecard.test.mjs +89 -0
  124. package/docs/CONFIG.md +41 -0
  125. package/docs/OUTCOME-CODES.md +1 -0
  126. package/docs/STATS.md +17 -0
  127. package/package.json +1 -1
  128. package/pool/image/Dockerfile +14 -2
  129. package/pool/image/manifest.json +25 -0
  130. package/pool/image/mirror.sh +11 -2
  131. package/pool/install/install-agent.ps1 +11 -4
  132. package/scripts/ci-local/adapters/github-actions.mjs +8 -0
  133. package/scripts/ci-local/cli.mjs +1 -1
  134. package/scripts/ci-local/plan.mjs +3 -2
  135. package/scripts/ci-local.test.sh +11 -0
  136. package/scripts/failure-census.mjs +67 -0
  137. package/scripts/review-finalize.sh +5 -5
  138. package/scripts/review-finalize.test.sh +8 -1
  139. package/scripts/verify-phase-trail.sh +11 -0
  140. package/scripts/verify-phase-trail.test.sh +9 -0
@@ -10,7 +10,7 @@
10
10
  import { spawnSync } from "node:child_process";
11
11
  import { OUTCOME_CODES, ENV_VALIDATE_TIMEOUT } from "../engine/outcome-codes.mjs";
12
12
  import { noComments } from "./context.mjs";
13
- import { equivalentRuns, isDriftFailure } from "./validate-catalog.mjs";
13
+ import { isDriftFailure } from "./validate-catalog.mjs";
14
14
  import { seqNumber } from "./sequence.mjs";
15
15
  import { activationFailures } from "./activation.mjs";
16
16
  import * as nodeFs from "node:fs";
@@ -48,8 +48,6 @@ import { CHECK_ID_RE, e2eCheckFor } from "./postdeploy-check.mjs";
48
48
  import { normaliseDecision, deadAnchors, anchorMatches, parseRequirementDecision } from "./decisions.mjs";
49
49
  import { globToRegex } from "../../scripts/ci-local/lib.mjs";
50
50
  import { contractBriefProblems } from "./pagegate.mjs"; // #5428
51
- import { counterGrowth } from "./hotarea.mjs"; // #5751
52
- import { designContractFailures } from "./recurrence.mjs"; // #5751
53
51
  import { AMEND_KINDS } from "./amendment-schema.mjs"; // #5979
54
52
  const C = OUTCOME_CODES;
55
53
 
@@ -233,22 +231,6 @@ export function authorizationOf(contract, f) {
233
231
  if (COUPLED_PATHS.some((c) => c.also.some((g) => pathCovers(g, f)) && (contract.deliverables ?? []).some((x) => pathCovers(x.path, c.when) || pathCovers(c.when, x.path)))) return "coupled";
234
232
  return null;
235
233
  }
236
- // A doc a freshness rule can demand: a prose file under a docs directory. Build and dependency files (`requirements.txt`,
237
- // `CMakeLists.txt`) and agent-instruction or workflow-spec files outside a docs directory (`CLAUDE.md`, `commands/*.md`) never
238
- // match, so the exemption cannot carry them past scope_creep.
239
- const DOC_FILE_RE = /(?:^|\/)(?:docs?|devdocs|documentation)\/(?:[^/]+\/)*[^/]+\.(?:md|mdx|rst|adoc)$/i;
240
- /**
241
- * The docs-freshness rule demands a doc edit the frozen contract cannot name: add-deliverable amendments (why "docs freshness
242
- * rule") for doc files (`DOC_FILE_RE`) that `after` has and `before` lacked and no deliverable, test or incidental rule authorizes.
243
- * Only when the freshness check failed before the round (`wasFailing`) and passes after it (`nowOk`); code files stay scope creep.
244
- */
245
- export function impliedDocDeliverables({ before = [], after = [], contract, wasFailing = false, nowOk = false }) {
246
- if (!wasFailing || !nowOk) return [];
247
- const had = new Set(before.map(cleanPath));
248
- return [...new Set(after.map(cleanPath))]
249
- .filter((f) => !had.has(f) && DOC_FILE_RE.test(f) && !authorizationOf(contract ?? {}, f))
250
- .map((path) => ({ kind: "add-deliverable", path, why: "docs freshness rule" }));
251
- }
252
234
  const blank = (s) => !String(s ?? "").trim() || /^none$/i.test(String(s).trim());
253
235
 
254
236
  /** forge.yaml lean.repro_test (#4271): "prefer" (default) asks a bug lane for a red-green repro test; "off" is today's contract. */
@@ -575,7 +557,7 @@ export function testPlanProblems(c, { required = false } = {}) {
575
557
 
576
558
  /** #5448: a requirement that starts as an imperative build verb is development work, not a prod-only measurement. */
577
559
  const DEV_WORK_RE = /^\W*(?:\w+\s+){0,2}?(?:find|fix|implement|develop|build|write|patch|add|change)\b/i;
578
- export function validateContract(c, issueText, { repro = false, pages = null, testPlan = false, readFile = null, checkIds = null, baseFiles = null, reproRecipe = false } = {}) {
560
+ export function validateContract(c, issueText, { repro = false, pages = null, testPlan = false, readFile = null, baseFiles = null, reproRecipe = false } = {}) {
579
561
  const problems = [];
580
562
  if (!c || typeof c !== "object" || Array.isArray(c)) return { ok: false, problems: ["contract.json is missing or not a JSON object"] };
581
563
  const reqs = Array.isArray(c.requirements) ? c.requirements : [];
@@ -589,11 +571,6 @@ export function validateContract(c, issueText, { repro = false, pages = null, te
589
571
  if (!inIssue(r?.quote, issueText)) problems.push(quoteMiss(id, r?.quote, issueText));
590
572
  if (TRACKED.includes(r?.disposition) && blank(r?.why)) problems.push(`${id}: ${r.disposition} needs a why`);
591
573
  if (r?.disposition === "post-deploy" && !CHECK_ID_RE.test(String(r?.check ?? ""))) problems.push(`${id}: post-deploy needs a check id (\`check\`, e.g. "login-smoke") naming an entry of .forge/post-deploy-checks.json on the default branch`);
592
- if (r?.disposition === "post-deploy" && !r?.e2e_tracked && !r?.engine_check && CHECK_ID_RE.test(String(r?.check ?? "")) && checkIds) { // first-pass: an unregistered check id fails at freeze, not after the build (precheck check_unknown); checkIds = the base's check ids, as precheck reads them
593
- const known = [...checkIds];
594
- const delivers = (Array.isArray(c.deliverables) ? c.deliverables : []).some((d) => String(d?.path ?? "").replace(/^\.\//, "") === ".forge/post-deploy-checks.json");
595
- if (!known.includes(r.check) && !delivers) problems.push(`${id}: post-deploy check '${r.check}' is not registered in .forge/post-deploy-checks.json; either add a deliverable {"path":".forge/post-deploy-checks.json","change":"register check ${r.check} (run, pass, timeout)"} or use an existing id${known.length ? ` (${known.slice(0, 8).join(", ")}${known.length > 8 ? ", ..." : ""})` : ""}`);
596
- }
597
574
  if (r?.disposition === "post-deploy" && blank(r?.local_infeasible_why)) problems.push(`${id}: post-deploy needs local_infeasible_why: why a fixture or recorded response cannot check this locally (#5448)`);
598
575
  if (r?.disposition === "post-deploy" && (inLaneDeferral(r) || (bucketKind(r?.bucket) !== "owner" && bucketKind(r?.bucket) !== "host" && DEV_WORK_RE.test(String(r?.quote ?? ""))))) problems.push(`${id}: development work (finding or fixing the signal) is delivered in-lane, never deferred as prod-only; deliver it and keep only the measurement post-deploy (#5448)`);
599
576
  if (r?.disposition === "not-applicable" && blank(r?.evidence)) problems.push(`${id}: not-applicable needs file:line evidence`);
@@ -665,7 +642,7 @@ const shellGlobRe = (g) => new RegExp(`^${String(g).replace(/[.+^${}()|[\]\\]/g,
665
642
 
666
643
  const UNRELATED_CI_KIND = "unrelated-ci-failure";
667
644
  const GUARD_ID_RE = /^#?\d+$/;
668
- const AMEND_SLIPS = { "amend-requirement": "defer", limitation: "defer", deferred: "defer", deferral: "defer", "scope-deferral": "defer", "verification-substitution": "substitute-validate", "out-of-band-verification": "out-of-band" };
645
+ const AMEND_SLIPS = { "amend-requirement": "defer", limitation: "defer", deferred: "defer", deferral: "defer", "scope-deferral": "defer", "out-of-band-verification": "out-of-band" };
669
646
  // #5036: annotation-only kinds change no requirement: recorded for the reviewer, never a problem (like UNRELATED_CI_KIND)
670
647
  const INFO_KINDS = ["scope-note", "scope", "scope-clarification", "interpretation", "environment", "validation-unavailable"];
671
648
  // #5036: deferral-shaped kinds (scope narrowing/reduction, defer-*, deferred-*) are `defer` once they name a requirement
@@ -705,37 +682,10 @@ function splitRequirementRefs(ref) {
705
682
  return ids.length > 1 ? ids : [ref];
706
683
  }
707
684
 
708
- /** The rejection reason, naming the valid kinds or the missing field so the builder's correction round can fix it. */
709
- function amendmentProblem(a, tag) {
710
- const kind = a?.kind;
711
- const need = kind === "add-deliverable" ? "needs a path" : kind === "add-requirement" ? "needs requirement {id, quote}"
712
- : kind === "supersedes" ? "needs guard: \"#N\" (the guarded issue) or mechanism: \"<name>\" (#5752: retires the guards whose tests the lane deletes); a validate row id such as G2 is not a guard: use substitute-validate {validate, command, why}" : TRACKED.includes(kind) ? "needs requirement: \"R#\"" : kind === "amend-requirement" ? "needs requirement: \"R#\" and text (the revised wording)"
713
- : kind === "substitute-validate" ? "needs validate: \"V#\" and command" : kind === "out-of-band" ? "needs requirement: \"R#\" and evidence (the job or workflow that measures it)"
714
- : kind === "decision" ? "needs decision {choice, anchors: [paths or globs], symbols?, supersedes?: decision id}" : null;
715
- const why = need ? `amendment kind '${kind}' ${need}` : `unknown kind '${kind ?? ""}'; valid kinds are ${AMEND_KINDS.join(", ")}`;
716
- return `unknown or incomplete amendment: ${why}: ${tag}`;
717
- }
718
-
685
+ /** A short reason an amendment was not applied (#6083: the engine only skips it; the reason is never a gate). */
686
+ const amendmentProblem = (a, tag) => `amendment not applied (${a?.kind ? `kind '${a.kind}'` : "no kind"}): ${tag}`;
719
687
  /** #5979: a supersedes whose guard is a frozen validate-row id (G2, V1), not a #N guard issue. */
720
688
  const isValidateRowGuard = (a, ids) => !blank(a.guard) && !GUARD_ID_RE.test(String(a.guard).trim()) && (ids ?? []).includes(String(a.guard).trim());
721
- const validateRowProblem = (id, tag) => `supersedes guard '${String(id).trim()}' is a validate row of the contract, not a guard issue; use {"kind":"substitute-validate","validate":"${String(id).trim()}","command":"<runnable equivalent>","why":"..."}: ${tag}`;
722
-
723
- /** #5089: shape-only check of the builder's amendments (unknown kind, missing path or requirement), run before the gate so one in-lane correction can fix them. Returns the rejection strings; [] when valid. */
724
- export function amendmentKindProblems(amendments, validateIds = []) {
725
- const out = [];
726
- for (const raw of Array.isArray(amendments) ? amendments : []) {
727
- const a = normalizeAmendment(raw);
728
- if (a?.kind === UNRELATED_CI_KIND || INFO_KINDS.includes(a?.kind)) continue;
729
- const tag = JSON.stringify(raw ?? null).slice(0, 400);
730
- const known = AMEND_KINDS.includes(a?.kind);
731
- const missing = a?.kind === "add-deliverable" ? blank(a.path)
732
- : TRACKED.includes(a?.kind) || a?.kind === "amend-requirement" ? blank(a.requirement) : false;
733
- const validateRow = known && a.kind === "supersedes" && isValidateRowGuard(a, validateIds);
734
- if (!known || missing) out.push(amendmentProblem(a, tag));
735
- else if (validateRow) out.push(validateRowProblem(a.guard, tag));
736
- }
737
- return out;
738
- }
739
689
 
740
690
  /**
741
691
  * Apply result.json amendments to the frozen contract. Kinds: add-deliverable {path}, add-requirement {requirement},
@@ -749,7 +699,7 @@ export function amendmentKindProblems(amendments, validateIds = []) {
749
699
  export function applyAmendments(frozen, amendments, issueText = null, { generatedPaths = [], baseFiles = null, addedPaths = [], defaultWhy = null } = {}) {
750
700
  const c = structuredClone(frozen);
751
701
  c.deliverables = c.deliverables ?? [];
752
- for (const v of c.validate ?? []) if (v && typeof v === "object") delete v.substituted; // SEC-21: only a substitute-validate amendment sets it, never the frozen contract
702
+ for (const v of c.validate ?? []) if (v && typeof v === "object") delete v.substituted; // a frozen contract never carries a substitute (#6083: substitute-validate is gone)
753
703
  const applied = [], toTrack = [], problems = [], decisions = [];
754
704
  const genRes = (Array.isArray(generatedPaths) ? generatedPaths : []).filter((g) => typeof g === "string" && g).map(shellGlobRe);
755
705
  const rows = [];
@@ -785,16 +735,6 @@ export function applyAmendments(frozen, amendments, issueText = null, { generate
785
735
  // package.json declares the edge (forge#4159); before, it was reported as applied but changed nothing.
786
736
  if (have) { have.change = have.change ? `${have.change}; ${a.why}` : a.why; have.amended = true; }
787
737
  else c.deliverables.push({ id: a.id ?? `A${c.deliverables.length + 1}`, path: a.path, change: a.why, amended: true });
788
- } else if (a.kind === "substitute-validate" && !blank(a.validate)) {
789
- // #4857: a runnable equivalent of an unrunnable frozen validate command; same id, same checks as a planned command
790
- const v = (c.validate ?? []).find((x) => x.id === a.validate);
791
- if (!v) { problems.push(`substitute-validate names unknown validate ${a.validate}`); continue; }
792
- const bad = blank(a.command) ? "no command" : substituteShellProblem(a.command) ? "not valid shell (bash -n)" : noopCommand(a.command) ? "runs no check (true, :, exit 0, echo)" : movingBaseDiff(a.command) ? "diffs against a moving base tip" : tmpdirInputs(a.command).length ? "reads a $TMPDIR file it did not create" : null;
793
- if (bad) { problems.push(`substitute-validate ${a.validate}: ${bad}`); continue; }
794
- // SEC-11: a second substitute of the same id keeps the frozen command as `from`, so the engine always reruns the original
795
- v.substituted = { from: v.substituted?.from ?? v.command, why: String(a.why).trim() }; v.command = String(a.command).trim();
796
- applied.push({ kind: a.kind, target: a.validate, why: String(a.why).trim() });
797
- continue;
798
738
  } else if (a.kind === "out-of-band" && !blank(a.requirement) && !blank(a.evidence ?? a.job)) {
799
739
  // #5036: the existing out_of_band path for a deliver requirement; evidence names the job that measures it
800
740
  const r = c.requirements.find((x) => x.id === a.requirement);
@@ -829,7 +769,7 @@ export function applyAmendments(frozen, amendments, issueText = null, { generate
829
769
  applied.push({ kind: a.kind, target: `mechanism ${mechanism}`, why: String(a.why).trim() });
830
770
  continue;
831
771
  } else if (a.kind === "supersedes" && isValidateRowGuard(a, [...(c.validate ?? []), ...(c.regression ?? [])].map((v) => v?.id))) {
832
- problems.push(validateRowProblem(a.guard, tag)); continue;
772
+ continue; // a validate-row id is not a guard issue: not applied (#6083)
833
773
  } else if (a.kind === "supersedes" && GUARD_ID_RE.test(String(a.guard ?? "").trim())) {
834
774
  // #4693: retires one guard's guard_broken for this lane; the reviewer judges it, the engine tells the guarded issue after merge
835
775
  const guard = `#${String(a.guard).trim().replace(/^#/, "")}`;
@@ -914,12 +854,6 @@ export function shellSyntaxError(command) {
914
854
  if (r.error || r.status === 0 || r.status == null) return null;
915
855
  return String(r.stderr || "syntax error").trim().split("\n")[0].replace(/^bash: (?:line \d+: )?/, "").slice(0, 160);
916
856
  }
917
- /** #5020: like shellSyntaxError, but fails closed: when bash cannot run the check the command is not shown to parse. */
918
- export function substituteShellProblem(command) {
919
- const r = spawnSync("bash", ["-n", "-c", String(command ?? "")], { encoding: "utf8", timeout: 5000 });
920
- if (r.error || r.status == null) return "bash -n could not run, so the command is unverified";
921
- return r.status === 0 ? null : shellSyntaxError(command) ?? "syntax error";
922
- }
923
857
  export const ORCHESTRATOR_BUCKET = "owner:orchestrator";
924
858
  /**
925
859
  * #5020: a post-deploy requirement that names no check id (a manual or production-credential action) becomes a `defer` with an
@@ -983,63 +917,6 @@ export function assertionFailure(output) {
983
917
  export function reproEnvMiss(run, opts) {
984
918
  return run && run.rc !== 0 && run.rc !== 124 ? missingTool(run, opts) : null;
985
919
  }
986
- const NOOP_SEGMENT_RE = /^(?:true|false|:|exit(?:\s+\d+)?|echo(?:\s.*)?|printf(?:\s.*)?|sleep(?:\s+[\d.]+)?|test\s+-?\w+|\[\s+-?\w+\s+\]|fi|done|node\s+-e\s+['"]?[\d;\s]*['"]?|python3?\s+-c\s+['"]?(?:pass|0|None)?['"]?)$/;
987
- const KEYWORD_RE = /^(if|then|else|elif|do|while|until)(?:\s+|$)/;
988
- const CONST_FALSE_RE = /^(?:false|\[\s+0\s+=\s+1\s+\]|\[\s+1\s+=\s+0\s+\]|test\s+0\s+=\s+1|test\s+-n\s+(?:""|'')|\[\s+-n\s+(?:""|'')\s+\])$/;
989
- /**
990
- * #4979 SPEC-2: a command every segment of which is a no-op (true, :, exit N, echo, printf, sleep, a constant test,
991
- * shell keywords, `node -e 0`, `python -c pass`) checks nothing. A best-effort denylist: the engine's rerun of the
992
- * frozen command (`substituteVerdict`) is the real gate.
993
- */
994
- export function noopCommand(command) {
995
- // SEC-22: a leading shell keyword is stripped and the rest judged, so `if [ -f x ]; then pytest; fi` is a real check
996
- const segs = String(command ?? "").split(/&&|\|\||;|\||\n/).map((s) => s.trim()).filter(Boolean);
997
- const live = [];
998
- let dead = false; // #4995: inside the body of an if/elif/while whose condition is a constant false
999
- for (const raw of segs) {
1000
- let s = raw, cond = false, m;
1001
- while ((m = KEYWORD_RE.exec(s))) {
1002
- s = s.slice(m[0].length);
1003
- if (m[1] === "else" || m[1] === "elif") dead = false;
1004
- cond = m[1] === "if" || m[1] === "elif" || m[1] === "while";
1005
- }
1006
- if (s === "fi" || s === "done") dead = false;
1007
- if (cond) { if (CONST_FALSE_RE.test(s)) dead = true; else if (!dead && s) live.push(s); continue; }
1008
- if (!dead && s) live.push(s);
1009
- }
1010
- return segs.length > 0 && live.every((s) => NOOP_SEGMENT_RE.test(s));
1011
- }
1012
- /**
1013
- * #4979 SPEC-2: a substitute-validate stands only when the frozen command it replaced cannot run (died before any test,
1014
- * a runner usage error, a missing host tool, exit 127) or passes anyway. A frozen command that runs and fails is a real
1015
- * failure the substitute may not hide. `run` is the engine's rerun of the frozen command; null when none was made.
1016
- */
1017
- export function substituteVerdict(run, { repoHas = () => false, command = "" } = {}) {
1018
- if (!run) return "unverified";
1019
- if (run.rc === 0 || run.rc === 127 || unrunnableValidate(run, command) || cliUsageError(run) || missingTool(run, { repoHas, command })) return "ok";
1020
- return run.rc === 124 ? "timeout" : "runs";
1021
- }
1022
- /**
1023
- * #4990 SEC-13: the paths of `removed` (deleted, or the old side of a rename, in the diff) that a frozen command names:
1024
- * a whitespace token equal to the path, or a directory token above it. A builder that removes the target of its frozen
1025
- * validate makes the engine's rerun read "unrunnable", so the substitute is judged on the diff instead.
1026
- */
1027
- const TEST_FILE_RE = /\.(?:test|spec)\.[a-z0-9]+$|^test_[^/]+\.[a-z0-9]+$|_test\.[a-z0-9]+$|Tests?\.(?:java|kt|kts|cs|php|scala|swift)$|_spec\.rb$|^tests\.rs$|^conftest\.py$|\.bats$/;
1028
- /** #5003: a runnable test FILE (by basename), unlike `isTestPath`, which also matches fixtures under tests/. */
1029
- const isTestFile = (p) => TEST_FILE_RE.test(String(p).split("/").pop());
1030
- /**
1031
- * #4990 SEC-13: the paths of `removed` (deleted, or the old side of a rename, in the diff) that a frozen command names.
1032
- * #5003: a token is stripped of quotes, a `--flag=` prefix and a pytest `::node` suffix; a glob is expanded against
1033
- * `baseFiles`; an exact path matches itself; a directory or bare-word token matches only a removed test file under it.
1034
- */
1035
- export function removedNamedPaths(command, removed = [], baseFiles = []) {
1036
- const toks = String(command ?? "").split(/\s+/).map((t) => t.replace(/^['"`(]+|['"`);]+$/g, "").replace(/^-[^=\/]*=/, "").replace(/::.*$/, "").replace(/^['"`]+|['"`]+$/g, "").replace(/^\.\//, "").replace(/\/+$/, "")).filter((t) => t && t !== ".");
1037
- const files = new Set(baseFiles);
1038
- return removed.filter((p) => toks.some((t) => {
1039
- if (/[*?]/.test(t)) return globRe(t).test(p) && (files.size === 0 || files.has(p));
1040
- return p === t || (p.startsWith(`${t}/`) && isTestFile(p));
1041
- }));
1042
- }
1043
920
  /** #4990: paths the lane's diff deletes or renames away from (the old side). #5003: `-z` (unquoted), null on a git error (fail closed). */
1044
921
  export async function removedPathsOf(git, base) {
1045
922
  let out;
@@ -1190,12 +1067,8 @@ const wantsE2e = (r) => /\[type:(?:e2e|manual)\]/i.test(tagText(r?.quote));
1190
1067
  * `ciCovered` (#4527): the validate ids accepted only because the head is CI-verified (no local result, or a missing host
1191
1068
  * tool), for the trajectory; always an array.
1192
1069
  */
1193
- export function precheck({ contract, result, changedFiles, ignore = [], ciVerified = false, hotspots = null, repro = null, validateRuns = null, repoHas = () => false, frozen = null, checkIds = null, baselineFailures = null, guardFailures = null, coupledFailures = null, relaxationFailures = null, routeFailures = null, docsFailures = null, pageFailures = null, docsPaths = null, prodParityFailures = null, seamFailures = null, newOffKeys = null, substitutedRuns = null, removedPaths = [], baseFiles = [], uiBrowser = null, ciBudgetFailures = null, counters = null, recurrence = null, outcomeEvidenceFailures = null }) {
1194
- const failures = [], superseded = [], ciCovered = [], equivalent = [];
1195
- // #4626: a post-deploy check id must be on the default branch or added by this PR (`checkIds`: ids of both checks files; null = not resolved)
1196
- if (checkIds) for (const r of contract.requirements ?? []) {
1197
- if (r.disposition === "post-deploy" && !(r.check && checkIds.has(r.check))) failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "check_unknown", detail: `${r.id} post-deploy check ${r.check ? `'${r.check}'` : "id"} is neither on the default branch nor added by this PR (.forge/post-deploy-checks.json)` });
1198
- }
1070
+ export function precheck({ contract, result, changedFiles, ignore = [], ciVerified = false, repro = null, validateRuns = null, repoHas = () => false, frozen = null, baselineFailures = null, guardFailures = null, coupledFailures = null, relaxationFailures = null, routeFailures = null, pageFailures = null, docsPaths = null, prodParityFailures = null, seamFailures = null, newOffKeys = null, removedPaths = [], uiBrowser = null, outcomeEvidenceFailures = null }) {
1071
+ const failures = [], superseded = [], ciCovered = [];
1199
1072
  // #5754: a deliver [type:e2e]/[type:manual] row whose observable exists only in production (live stack, deploy, prod window) cannot be produced by the placement: fail fast with a typed code instead of spending builder resumes
1200
1073
  for (const r of contract.requirements ?? []) {
1201
1074
  if (r.disposition === "deliver" && wantsE2e(r) && !isOutOfBand(r) && r.verify !== "in_lane" && prodOnlyE2e(r.quote)) failures.push({ code: C.CONFORMANCE_E2E_UNVERIFIED, kind: "e2e_placement", detail: `${r.id} is a [type:e2e]/[type:manual] criterion observable only in production or on the live stack, which this lane cannot produce; mark ${r.id} post-deploy so it is transferred to the epic's acceptance instead of spending builder resumes (#5754)` });
@@ -1210,21 +1083,6 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
1210
1083
  if (creep.length) failures.push({ code: C.CONFORMANCE_SCOPE_CREEP, kind: "scope_creep", detail: `changed outside the contract's deliverables: ${creep.join(", ")}` });
1211
1084
  const runs = Array.isArray(result?.validation) ? result.validation : [];
1212
1085
  for (const v of contract.validate ?? []) {
1213
- // #4979 SPEC-2: a substitute counts only when the frozen command it replaced cannot run (or passes); checked first, never CI-covered
1214
- if (v.substituted) {
1215
- const shellBad = substituteShellProblem(v.command); // #5020: re-checked before the substitute is used
1216
- if (shellBad) { failures.push({ code: C.CONTRACT_INVALID_COMMAND, kind: "validate_command_invalid", detail: `validate ${v.id} substitute \`${v.command}\` is not valid shell (bash -n: ${shellBad})` }); continue; }
1217
- if (removedPaths === null) { failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "substitute_unverified", detail: `validate ${v.id} substituted \`${v.command}\` for the frozen \`${v.substituted.from}\`, but the engine could not read the diff's removed paths to show the frozen command's target survives` }); continue; }
1218
- const gone = removedNamedPaths(v.substituted.from, removedPaths, baseFiles);
1219
- if (gone.length) { failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "substitute_removed_path", detail: `validate ${v.id} substituted \`${v.command}\` for the frozen \`${v.substituted.from}\`, but the diff removes ${gone.map((x) => `\`${x}\``).join(", ")} that the frozen command names: a substitute may not replace a check by deleting its target` }); continue; }
1220
- const verdict = substituteVerdict(substitutedRuns?.[v.id], { repoHas, command: v.substituted.from });
1221
- const from = `validate ${v.id} substituted \`${v.command}\` for the frozen \`${v.substituted.from}\``;
1222
- if (verdict === "unverified") { failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "substitute_unverified", detail: `${from}, but the engine has no rerun of the frozen command to show it cannot run` }); continue; }
1223
- // #5653: the frozen command runs, and the substitute ran the same test ids with the same exit: recorded, not failed
1224
- if (verdict === "runs" && equivalentRuns(substitutedRuns[v.id], substitutedRuns[v.id].sub)) equivalent.push({ id: v.id, from: v.substituted.from, to: v.command });
1225
- else if (verdict === "runs") { failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "validate_failed", output: rawTail(substitutedRuns[v.id].output), detail: `${from}, but the frozen command runs and fails (exit ${substitutedRuns[v.id].rc}): a substitute-validate replaces only a command that cannot run, never a failing check${outputTail(substitutedRuns[v.id].output)}` }); continue; }
1226
- if (verdict === "timeout" && !ciVerified) { failures.push({ code: ENV_VALIDATE_TIMEOUT, kind: "validate_timeout", detail: `${from}, and the frozen command timed out (exit 124) on the engine's rerun, so its substitution cannot be judged: infrastructure (host load)` }); continue; }
1227
- }
1228
1086
  const r = runs.find((x) => x?.id === v.id);
1229
1087
  // #4167: a head the engine verified on CI covers validate ids the builder left to CI (no result, or ci:true without an exit)
1230
1088
  const leftToCi = !r || (r.ci === true && r.exit === undefined);
@@ -1236,7 +1094,7 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
1236
1094
  const rerun = validateRuns?.[v.id];
1237
1095
  if (rerun?.rc === 0) continue;
1238
1096
  if (rerun && cliUsageError(rerun)) { failures.push({ code: C.CONTRACT_INVALID_COMMAND, kind: "validate_command_invalid", detail: `validate ${v.id} (\`${v.command}\`) is a CLI usage error of the runner, a defect of the frozen command rather than of the change` }); continue; }
1239
- if (rerun && unrunnableValidate(rerun, v.command)) { failures.push({ code: C.CONTRACT_INVALID_COMMAND, kind: "validate_command_invalid", detail: `validate ${v.id} (\`${v.command}\`) died before any test ran (no tests selected, no project at its cwd or invalid shell), a defect of the frozen command rather than of the change; substitute a runnable equivalent with a substitute-validate amendment` }); continue; }
1097
+ if (rerun && unrunnableValidate(rerun, v.command)) { failures.push({ code: C.CONTRACT_INVALID_COMMAND, kind: "validate_command_invalid", detail: `validate ${v.id} (\`${v.command}\`) died before any test ran (no tests selected, no project at its cwd or invalid shell), a defect of the frozen command rather than of the change` }); continue; }
1240
1098
  // #4906: the rerun timed out (even after the longer retry): host load, not a verdict on the change. A CI-verified head covers it; else an environment error.
1241
1099
  if (rerun?.rc === 124) {
1242
1100
  if (ciVerified) { ciCovered.push(v.id); continue; }
@@ -1258,16 +1116,13 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
1258
1116
  if (r.disposition === "deliver" && isOutOfBand(r)) {
1259
1117
  // #4404: measured outside the lane; the builder delivers its instrumentation (budget test or bench committed, job configured)
1260
1118
  const row = st.find((x) => x?.id === r.id);
1261
- if (row?.instrumented !== true && s !== "implemented") failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "requirement_unimplemented", detail: `${r.id} is verified out of band${r.evidence ? ` by ${r.evidence}` : ""} but reported "${s ?? "no status"}" without instrumented: true` });
1119
+ if (row?.instrumented !== true && s !== "implemented") failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: s == null ? "requirement_no_status" : "requirement_unimplemented", ...(s == null ? { reqId: r.id, quote: r.quote } : {}), detail: `${r.id} is verified out of band${r.evidence ? ` by ${r.evidence}` : ""} but reported "${s ?? "no status"}" without instrumented: true` });
1262
1120
  } else if (r.disposition === "deliver") {
1263
1121
  if (s === "deferred" || s === "post-deploy") failures.push({ code: C.CONFORMANCE_UNTRACKED_DEFERRAL, kind: "untracked_deferral", detail: `${r.id} was contracted as deliver but reported "${s}" without a typed amendment` });
1264
- else if (s !== "implemented") failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "requirement_unimplemented", detail: `${r.id} reported "${s ?? "no status"}"` });
1122
+ else if (s !== "implemented") failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: s == null ? "requirement_no_status" : "requirement_unimplemented", ...(s == null ? { reqId: r.id, quote: r.quote } : {}), detail: `${r.id} reported "${s ?? "no status"}"` }); // #6058: a missing row is a skipped requirement, not a failed one
1265
1123
  }
1266
1124
  }
1267
1125
  for (const f of baselineFailures ?? []) failures.push({ code: C.CONFORMANCE_REGRESSION, ...f }); // #5448
1268
- failures.push(...hotspotGrowth({ contract, result, hotspots, changedFiles }));
1269
- failures.push(...counterGrowth({ before: counters?.before, after: counters?.after, contract, result })); // #5751: forge.yaml recurrence.counters, measured at base and lane head
1270
- failures.push(...designContractFailures(contract, recurrence)); // #5751: a recurring issue's design lane contract
1271
1126
  if (repro) failures.push(...reproFailures(contract, repro), ...reproQualityFailures(repro));
1272
1127
  failures.push(...sourceDeliverableFailures(contract, changedFiles, ignore));
1273
1128
  // #4693: a broken guard fails unless the contract carries a supersedes amendment for it
@@ -1278,14 +1133,12 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
1278
1133
  for (const f of coupledFailures ?? []) failures.push(f); // #5079
1279
1134
  for (const f of relaxationFailures ?? []) failures.push(f); // #5237
1280
1135
  failures.push(...(routeFailures ?? [])); // #5087: topology.route_reachability, blocking when declared
1281
- failures.push(...(docsFailures ?? [])); // #5419: forge.yaml docs
1282
1136
  failures.push(...(outcomeEvidenceFailures ?? [])); // #5752: forge.yaml outcome_evidence
1283
- failures.push(...(ciBudgetFailures ?? [])); // #5760: CI additions need a FORGE:CI_BUDGET annotation or the shared job, scoped hygiene, max counts
1284
1137
  failures.push(...(pageFailures ?? [])); // #5428: forge.yaml pages
1285
1138
  failures.push(...(prodParityFailures ?? [])); // #5284: topology.prod_parity
1286
1139
  failures.push(...interfaceDecisionFailures(contract, result, changedFiles)); // #5338
1287
1140
  failures.push(...(seamFailures ?? [])); // #5338: a declared interface's provider and consumer no longer agree
1288
- return { ok: failures.length === 0, failures, superseded, ciCovered, equivalent };
1141
+ return { ok: failures.length === 0, failures, superseded, ciCovered, equivalent: [] };
1289
1142
  }
1290
1143
 
1291
1144
  /**
@@ -1368,26 +1221,6 @@ export function alreadyFixedOnBase(failures = [], changedFiles = [], ignore = []
1368
1221
  return failures.some((f) => f.kind === "repro_base_green") && failures.every((f) => f.kind === "repro_base_green" || f.kind === "source_deliverable_untouched");
1369
1222
  }
1370
1223
 
1371
- const EXEMPT_RE = /hotspot-exempt:\s*\S/i;
1372
- /**
1373
- * forge#4195: a changed file already over `file_lines` (not generated, vendored or glob-excluded; forge#4519: a
1374
- * `generated` row, from linguist-generated, maintenance.generated_paths or a generated header, never counts) that grew by more
1375
- * than `growth_lines` since the base, with no `hotspot-exempt: <reason>` in a covering deliverable's change or an
1376
- * add-deliverable amendment's why. `hotspots` is scripts/hotspots.sh --base output; null or disabled checks nothing.
1377
- */
1378
- export function hotspotGrowth({ contract, result, hotspots, changedFiles = [] }) {
1379
- if (!hotspots || hotspots.enabled === false || !Array.isArray(hotspots.files)) return [];
1380
- const limit = Number(hotspots.growth_lines) || 0, max = Number(hotspots.file_lines) || 0;
1381
- const changed = new Set(changedFiles.map(cleanPath));
1382
- const amends = Array.isArray(result?.amendments) ? result.amendments : [];
1383
- const exempt = (f) => (contract?.deliverables ?? []).some((d) => pathCovers(d.path, f) && EXEMPT_RE.test(String(d.change ?? "")))
1384
- || amends.some((a) => a?.kind === "add-deliverable" && pathCovers(a.path, f) && EXEMPT_RE.test(String(a.why ?? "")));
1385
- return hotspots.files
1386
- .filter((h) => h?.over && !h.excluded && !h.generated && Number(h.growth) > limit && changed.has(cleanPath(h.path)) && !exempt(h.path))
1387
- .map((h) => ({ code: C.MAINTENANCE_HOTSPOT_GROWTH, kind: "hotspot_growth",
1388
- detail: `${h.path} grew by ${h.growth} lines (now ${h.lines}, limit +${limit} over ${max}) without hotspot-exempt` }));
1389
- }
1390
-
1391
1224
  /** The reviewer's JSON object (a json fence first, then the outermost braces), or null. */
1392
1225
  export function parseReview(text) {
1393
1226
  const s = String(text ?? "");
@@ -1586,6 +1419,9 @@ export function prodOnlyE2e(quote) {
1586
1419
  const LIVE_INFRA_RE = /\b(?:live|paid|remote)\s+(?:benchmarks?|runs?|infra(?:structure)?|hosts?)\b|\bbench(?:mark)?[\w.-]*\.(?:mjs|js|py|sh)\b|\bre-?run\b[^.]{0,60}\bbench(?:mark)?\b|\b(?:sandbox pool|(?:remote|rented|cloud|gpu) (?:infra|hosts?|runners?|clusters?|boxe?s?|machines?|gpus?|pool)|on (?:a|the) (?:remote|rented|cloud|gpu) \w+)\b|\bsynthetic load\b|\b\d+\s*[×x]\s*(?:nproc|cores?|cpus?)\b|\bCPU hogs?\b|\bhost[- ]level (?:load|run)\b|\b[≤<]=?\s*[\d.]+\s*[×x]\s*(?:the\s+)?(?:control\s+)?cost\b/i;
1587
1420
  /** #5524: production observation windows without a URL: a metric/alert window, "at the next <weekday>", current volume, a prod host. */
1588
1421
  const PROD_WINDOW_RE = /\b(?:over|for|within|across)\s+(?:the\s+(?:last|next)\s+)?\d+\s*(?:h|hrs?|hours?|d|days?|w|weeks?|min|minutes?)\b|\bat the next (?:mon|tues?|wednes|thurs?|fri|sat(?:ur)?|sun)(?:day)?\b|\bat current (?:volume|traffic|load)\b|\bon (?:OVH|prod(?:uction)?)\b|\b\w*Slo\w*Burn\w*\b|\bSLO\b|\b(?:does not|doesn't|did not) fire\b/i;
1422
+ /** #6051: a metric / replay / production-measurement criterion ("Metric: ... stays under X% over a real batch"): measured on real traffic after deploy, not by the lane. */
1423
+ const METRIC_REPLAY_RE = /^\s*(?:\*\*)?metric\b\s*(?:\*\*)?\s*:|\bover (?:a|the) (?:real|production|live) (?:batch|traffic|corpus|sample|inputs?|runs?)\b|\b(?:replay|replays|replayed)\b[^.]{0,80}\b(?:real|recorded|production|prod)\b|\b(?:real|recorded|production|prod)\b[^.]{0,80}\breplay\b/i;
1424
+ export function metricReplayRow(quote) { return METRIC_REPLAY_RE.test(String(quote ?? "")); }
1589
1425
  /**
1590
1426
  * #5468: rewrite production-only e2e/manual rows (deliver or defer; only `only` ids when given) to `post-deploy` with a generated
1591
1427
  * check id. Pure; returns {contract, converted:[{id, check, entry}]}. A row with no probeable URL becomes a checkless post-deploy row (check: null).
@@ -1593,6 +1429,10 @@ const PROD_WINDOW_RE = /\b(?:over|for|within|across)\s+(?:the\s+(?:last|next)\s+
1593
1429
  export function autoPostDeployE2e(contract, only = null) {
1594
1430
  const converted = [];
1595
1431
  const requirements = (Array.isArray(contract?.requirements) ? contract.requirements : []).map((r) => {
1432
+ if (["deliver", "defer"].includes(r?.disposition) && !wantsE2e(r) && !isGuidance(r) && !(only && !only.includes(r.id)) && !isOutOfBand(r) && metricReplayRow(r.quote)) { // #6051: a measurement over real production inputs is a checkless post-deploy row (outcome evidence), as #5524
1433
+ converted.push({ id: r.id, check: null, entry: null });
1434
+ return { ...r, disposition: "post-deploy", bucket: "post-deploy", local_infeasible_why: "the criterion is a metric or replay over real production inputs, measured after deploy", why: "metric/replay/production-measurement criterion: tracked post-deploy as outcome evidence, not a lane deliverable (#6051)" };
1435
+ }
1596
1436
  if (!["deliver", "defer"].includes(r?.disposition) || !wantsE2e(r) || (only && !only.includes(r.id)) || isOutOfBand(r) || !prodOnlyE2e(r.quote)) return r;
1597
1437
  const g = e2eCheckFor(r.id, r.quote);
1598
1438
  if (!g && LIVE_INFRA_RE.test(String(r.quote))) { // #5547: needs a paid/remote/host-level run: a checkless row for the orchestrator (its why names spend and a third-party host so deferChecklessPostDeploy routes it)
@@ -1699,9 +1539,18 @@ export function decide(raw, ctx) {
1699
1539
  if (!comp.complete) return { state: "review.incomplete", failures: comp.problems.map((d) => ({ code: C.REVIEW_INCOMPLETE, detail: d })), missing: comp.missing, review: rv };
1700
1540
  const f = [], converted = [];
1701
1541
  const amendedOf = (ids) => (ctx.contract.requirements ?? []).find((r) => r.amendment?.text && (ids ?? []).includes(r.id));
1702
- const notAccepted = (r) => (r ? `amendment not accepted (${r.id} amended to "${String(r.amendment.text).slice(0, 200)}"): ` : "");
1542
+ // #6051: an amendment citing a frozen decision (D#/K#) is weighed against it, not rejected outright
1543
+ const citedDecision = (r) => (ctx.contract.decisions ?? []).find((d) => d?.id && new RegExp(`\\b${d.id}\\b`).test(`${r.amendment?.text ?? ""} ${r.amendment?.why ?? ""}`));
1544
+ const notAccepted = (r) => { if (!r) return ""; const d = citedDecision(r); return `${d ? `amendment cites frozen decision ${d.id} ("${String(d.choice ?? "").slice(0, 120)}"), judged against it` : "amendment not accepted"} (${r.id} amended to "${String(r.amendment.text).slice(0, 200)}"): `; };
1545
+ const named = (c) => { const ids = Array.isArray(c?.contract_ids) ? c.contract_ids : []; const reqs = ctx.contract.requirements ?? []; return ids.length ? reqs.filter((r) => ids.includes(r.id)) : reqs.filter((r) => r.quote === c?.quote); };
1546
+ const followUps = [], decisionBacked = [];
1703
1547
  for (const c of rv.issue_coverage) if (c.misclassified === true) f.push({ code: C.CONFORMANCE_OMISSION, detail: `guidance row misclassified: "${c.quote}" is a symptom or success criterion, judge it as binding${c.note ? ` (${c.note})` : ""}` });
1704
- else if (c.status !== "covered" && !guidanceCoverage(c, ctx.contract)) f.push({ code: C.CONFORMANCE_OMISSION, detail: `${notAccepted(amendedOf(c.contract_ids))}issue requirement ${c.status}: "${c.quote}"${c.note ? ` (${c.note})` : ""}` });
1548
+ else if (c.status !== "covered" && !guidanceCoverage(c, ctx.contract)) {
1549
+ const rows = named(c);
1550
+ if (rows.length && rows.every((r) => r.disposition === "defer" || r.disposition === "post-deploy")) followUps.push({ quote: c.quote, ids: rows.map((r) => r.id) }); // #6051: a frozen defer/post-deploy row is a tracked follow-up, not an omission
1551
+ else if (c.status === "narrowed" && rows.some((r) => r.amendment?.text && citedDecision(r))) decisionBacked.push({ quote: c.quote, ids: rows.map((r) => r.id), decision: citedDecision(rows.find((r) => r.amendment?.text && citedDecision(r))).id }); // #6051: a narrowing the amendment backs with a frozen decision is weighed against it, not an omission; a missing row still is one
1552
+ else f.push({ code: C.CONFORMANCE_OMISSION, detail: `${notAccepted(amendedOf(c.contract_ids))}issue requirement ${c.status}: "${c.quote}"${c.note ? ` (${c.note})` : ""}` });
1553
+ }
1705
1554
  for (const r of ctx.contract.requirements) {
1706
1555
  if (isGuidance(r)) continue; // #5750: the outcome rows are judged, never whether the proposal was followed
1707
1556
  const row = rv.requirements.find((x) => x.id === r.id);
@@ -1709,7 +1558,7 @@ export function decide(raw, ctx) {
1709
1558
  // #4404: the measured result lives in the named job; only the instrumentation is judged here
1710
1559
  if (row.instrumented !== true) f.push({ code: C.CONFORMANCE_UNIMPLEMENTED, detail: `${r.id} verified out of band${r.evidence ? ` by ${r.evidence}` : ""}: instrumentation missing${row.note ? `: ${row.note}` : ""}${row.evidence ? ` (${row.evidence})` : ""}` });
1711
1560
  } else if (r.disposition === "deliver" && row.status !== "implemented") {
1712
- f.push({ code: ["deferred", "post-deploy"].includes(row.status) ? C.CONFORMANCE_UNTRACKED_DEFERRAL : C.CONFORMANCE_UNIMPLEMENTED, detail: `${r.amendment?.text ? `${r.id} amendment not accepted (amended to "${String(r.amendment.text).slice(0, 200)}"): ` : r.derived_outcome ? `${r.id} derived outcome not met ("${String(r.derived_outcome).slice(0, 200)}"): ` : `${r.id} `}${row.status}${row.note ? `: ${row.note}` : ""}${row.evidence ? ` (${row.evidence})` : ""}` });
1561
+ f.push({ code: ["deferred", "post-deploy"].includes(row.status) ? C.CONFORMANCE_UNTRACKED_DEFERRAL : C.CONFORMANCE_UNIMPLEMENTED, kind: "review_unimplemented", detail: `${r.amendment?.text ? `${r.id} amendment not accepted (amended to "${String(r.amendment.text).slice(0, 200)}"): ` : r.derived_outcome ? `${r.id} derived outcome not met ("${String(r.derived_outcome).slice(0, 200)}"): ` : `${r.id} `}${row.status}${row.note ? `: ${row.note}` : ""}${row.evidence ? ` (${row.evidence})` : ""}` });
1713
1562
  } else if (r.disposition === "deliver" && wantsE2e(r) && !e2eVerified(row, ctx.contract, ctx.e2e)) {
1714
1563
  const faked = (ctx.e2e?.faked ?? []).length ? `; faked or mocked components in ${ctx.e2e.faked.slice(0, 3).join(", ")}` : "";
1715
1564
  f.push({ code: C.CONFORMANCE_E2E_UNVERIFIED, kind: "e2e_row", detail: `${r.id} is a [type:e2e]/[type:manual] criterion but ${row.validated_by || "its validated_by"} is not a real end-to-end check (the repo's e2e set, Playwright/browser/live stack${faked}); run one, or mark ${r.id} post-deploy so it is transferred to the epic's acceptance${ctx.e2e?.sandboxes?.length ? `; it can run pre-merge: declare env: [${ctx.e2e.sandboxes.slice(0, 3).join(", ")}] on its validate to use the test sandbox (#5450), do not defer it` : ""}` });
@@ -1730,10 +1579,10 @@ export function decide(raw, ctx) {
1730
1579
  }
1731
1580
  for (const p of rv.preserve ?? []) if (p.status !== "intact") f.push({ code: C.CONFORMANCE_PRESERVE_VIOLATED, detail: `${p.id} ${p.status}${p.evidence ? ` (${p.evidence})` : ""}${p.note ? `: ${p.note}` : ""}` });
1732
1581
  for (const r of rv.regressions ?? []) f.push({ code: C.CONFORMANCE_REGRESSION, detail: `${r?.at ?? "?"}: ${r?.failure ?? ""}` });
1733
- if (f.length) return { state: "nonconforming", failures: f, inconsistent: rv.verdict === "CONFORMS", review: rv, converted };
1582
+ if (f.length) return { state: "nonconforming", failures: f, inconsistent: rv.verdict === "CONFORMS", review: rv, converted, followUps, decisionBacked };
1734
1583
  // A NONCONFORMING verdict with every row passing gives the builder nothing to fix: re-ask the reviewer.
1735
1584
  if (rv.verdict !== "CONFORMS") return { state: "review.inconsistent", failures: [{ code: C.REVIEW_INCONSISTENT, detail: "verdict NONCONFORMING with no failing row" }], missing: ["verdict"], review: rv };
1736
- return { state: "conforms", failures: [], review: rv, converted };
1585
+ return { state: "conforms", failures: [], review: rv, converted, followUps, decisionBacked };
1737
1586
  }
1738
1587
 
1739
1588
  /** The ids (or sections) a targeted re-ask must fill: requirement ids without a valid row, issue_coverage problems, ...; [] when complete. */
@@ -2036,26 +1885,37 @@ export function normalizeKindModes(raw) {
2036
1885
  * @param {{shadow?: boolean, kinds?: Record<string,string>|null, allow?: string[]}} [o]
2037
1886
  */
2038
1887
  /**
2039
- * Advisory gates (2026-11-26 unclog): rules about the shape of the work (file scope, registries, docs placement,
2040
- * recurrence design, amendment syntax, growth counters) are reported, never blocking. Measured on 102 open FD/AlterLab
2041
- * issues: these rows caused ~30% of needs-human parks, repeated identically across reruns, and forced every lane to edit
2042
- * the same shared files (45 of 67 conflicted base-syncs). A lane still blocks on what shows the change is wrong: failing
2043
- * validate/CI/guard/repro runs, regressions and unimplemented requirements.
1888
+ * Advisory gates (#6083, owner-approved cut of 2026-11-26): everything that is about the shape of the work, the environment,
1889
+ * or a reviewer opinion without a failing assertion is recorded on the trajectory and the PR and never parks a lane. Measured
1890
+ * on 400 issues per repo (inventory on #6083): these rows caused 35-65% of needs-human parks and ~$500 of resume cost, and
1891
+ * the data shows no real defect they caught. What still blocks: a frozen requirement without a passing linked test
1892
+ * (test_missing/test_weak), validate_failed, bug repro red-green, source_deliverable_untouched, conformance.regression,
1893
+ * conformance.omission, ci.red, DCO, builder.blocked/no_commit, base-conflict handling.
1894
+ * forge.yaml engine.conformance_kinds `<code>=enforce` re-promotes a code listed here.
2044
1895
  */
2045
- export const ADVISORY_CODES = Object.freeze([OUTCOME_CODES.CONFORMANCE_SCOPE_CREEP, OUTCOME_CODES.RECURRENCE_DESIGN_MISSING, OUTCOME_CODES.MAINTENANCE_HOTSPOT_GROWTH, OUTCOME_CODES.MAINTENANCE_COUNTER_GROWTH]);
1896
+ export const ADVISORY_CODES = Object.freeze([
1897
+ OUTCOME_CODES.CONFORMANCE_SCOPE_CREEP, OUTCOME_CODES.CONFORMANCE_E2E_UNVERIFIED, OUTCOME_CODES.CONFORMANCE_UNTRACKED_DEFERRAL,
1898
+ OUTCOME_CODES.CONFORMANCE_UNJUSTIFIED_DEFERRAL, OUTCOME_CODES.CONFORMANCE_PRESERVE_VIOLATED, OUTCOME_CODES.CONFORMANCE_GUARD_BROKEN,
1899
+ OUTCOME_CODES.ENV_TOOL_MISSING, OUTCOME_CODES.ENV_REPRO_UNRUNNABLE, ENV_VALIDATE_TIMEOUT, OUTCOME_CODES.CONTRACT_INVALID_COMMAND,
1900
+ ]);
2046
1901
  export const ADVISORY_KINDS = Object.freeze([
2047
- "scope_creep", "check_unknown", "design_missing", "design_missing_repeated", "docs_missing", "docs_link_broken",
2048
- "ci_budget_unannotated", "hotspot_growth", "counter_growth",
2049
- "amendment_invalid",
2050
- "page_metadata_missing", "page_sitemap_missing", "page_canonical_missing", "page_structured_data_missing",
1902
+ "review_unimplemented",
1903
+ "validate_missing", "validate_command_invalid", "validate_timeout", "validate_env", "validate_drift",
1904
+ "repro_env", "repro_mutation_survivor", "mutation_survived", "dep_install",
1905
+ "e2e_row", "e2e_placement", "ui_browser_unverified",
1906
+ "route_unreachable", "relaxation_untested", "coupled_file_missing", "activation_missing", "mode_unreachable",
1907
+ "decision_unsuperseded", "interface_seam",
2051
1908
  ]);
1909
+ /** Kind families (page_*, design_*, outcome_evidence_*, prod_parity_*) that are advisory as a whole. */
1910
+ export const ADVISORY_KIND_PREFIXES = Object.freeze(["page_", "design_", "outcome_evidence_", "prod_parity_"]);
1911
+ const isAdvisory = (f) => ADVISORY_KINDS.includes(f?.kind) || ADVISORY_CODES.includes(f?.code) || ADVISORY_KIND_PREFIXES.some((p) => String(f?.kind ?? "").startsWith(p));
2052
1912
  /**
2053
1913
  * Split failures into {block, advisory}; advisory rows are reported on the issue and never park a lane. `enforce`: codes
2054
1914
  * a repo explicitly set to "enforce" (forge.yaml engine.conformance_kinds), which stay blocking.
2055
1915
  */
2056
1916
  export function splitAdvisory(failures, { enforce = [] } = {}) {
2057
1917
  const block = [], advisory = [];
2058
- for (const f of failures ?? []) (!enforce.includes(f?.code) && (ADVISORY_KINDS.includes(f?.kind) || ADVISORY_CODES.includes(f?.code)) ? advisory : block).push(f);
1918
+ for (const f of failures ?? []) (!enforce.includes(f?.code) && !enforce.includes(f?.kind) && isAdvisory(f) ? advisory : block).push(f);
2059
1919
  return { block, advisory };
2060
1920
  }
2061
1921