forgedock 1.61.1 → 1.62.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 (134) hide show
  1. package/bin/config-schema.mjs +10 -1
  2. package/bin/engine/outcome-codes.mjs +4 -0
  3. package/bin/engine-cli.mjs +160 -18
  4. package/bin/env/env.mjs +6 -4
  5. package/bin/forge-home-check.mjs +91 -0
  6. package/bin/forgedock.mjs +50 -7
  7. package/bin/gc.mjs +2 -0
  8. package/bin/hooks/pre-tool-use.mjs +4 -0
  9. package/bin/journey.mjs +55 -5
  10. package/bin/lean/admission.mjs +16 -5
  11. package/bin/lean/batch-health.mjs +55 -16
  12. package/bin/lean/batch-health.test.mjs +67 -1
  13. package/bin/lean/batch.mjs +8 -0
  14. package/bin/lean/batch.test.mjs +5 -0
  15. package/bin/lean/ceiling.mjs +20 -0
  16. package/bin/lean/ceiling.test.mjs +33 -2
  17. package/bin/lean/ci-gate.mjs +240 -0
  18. package/bin/lean/ci-gate.test.mjs +227 -0
  19. package/bin/lean/ci-precheck.mjs +178 -0
  20. package/bin/lean/ci-precheck.test.mjs +149 -0
  21. package/bin/lean/conformance.mjs +118 -20
  22. package/bin/lean/conformance.test.mjs +193 -3
  23. package/bin/lean/context.test.mjs +7 -6
  24. package/bin/lean/dag.mjs +128 -0
  25. package/bin/lean/dag.test.mjs +131 -0
  26. package/bin/lean/decisions.mjs +5 -4
  27. package/bin/lean/decisions.test.mjs +11 -0
  28. package/bin/lean/delguard.mjs +84 -0
  29. package/bin/lean/delguard.test.mjs +104 -0
  30. package/bin/lean/depcache.mjs +125 -17
  31. package/bin/lean/depcache.test.mjs +111 -0
  32. package/bin/lean/design-gate.mjs +5 -5
  33. package/bin/lean/design-gate.test.mjs +14 -0
  34. package/bin/lean/effects.mjs +81 -7
  35. package/bin/lean/execution.mjs +81 -15
  36. package/bin/lean/execution.test.mjs +156 -3
  37. package/bin/lean/forgedock-lane-workflow.test.mjs +35 -0
  38. package/bin/lean/guardgate.mjs +30 -7
  39. package/bin/lean/guardgate.test.mjs +44 -1
  40. package/bin/lean/guards.test.mjs +1 -1
  41. package/bin/lean/heavy.test.mjs +87 -0
  42. package/bin/lean/hotarea.mjs +73 -0
  43. package/bin/lean/hotarea.test.mjs +73 -0
  44. package/bin/lean/issuewatch-reconcile.mjs +20 -1
  45. package/bin/lean/issuewatch-reconcile.test.mjs +30 -0
  46. package/bin/lean/lanecheck.mjs +27 -3
  47. package/bin/lean/lanecheck.test.mjs +47 -5
  48. package/bin/lean/laneconfine.mjs +83 -0
  49. package/bin/lean/laneconfine.test.mjs +113 -0
  50. package/bin/lean/lean.mjs +398 -91
  51. package/bin/lean/lean.test.mjs +792 -26
  52. package/bin/lean/live-reconcile.mjs +169 -0
  53. package/bin/lean/live-reconcile.test.mjs +176 -0
  54. package/bin/lean/orchestrate-envhold.test.mjs +245 -0
  55. package/bin/lean/orchestrate-hostfallback.test.mjs +39 -0
  56. package/bin/lean/orchestrate.mjs +207 -17
  57. package/bin/lean/outcomeevidence.mjs +104 -0
  58. package/bin/lean/outcomeevidence.test.mjs +78 -0
  59. package/bin/lean/page-capture.mjs +68 -0
  60. package/bin/lean/page-capture.test.mjs +44 -0
  61. package/bin/lean/pagegate.mjs +46 -7
  62. package/bin/lean/pagegate.test.mjs +66 -1
  63. package/bin/lean/postdeploy-check.mjs +18 -4
  64. package/bin/lean/postdeploy-check.test.mjs +32 -1
  65. package/bin/lean/prefilter.mjs +36 -4
  66. package/bin/lean/prefilter.test.mjs +31 -1
  67. package/bin/lean/preflight.mjs +22 -0
  68. package/bin/lean/preflight.test.mjs +19 -1
  69. package/bin/lean/probe.mjs +18 -0
  70. package/bin/lean/probe.test.mjs +40 -0
  71. package/bin/lean/prompts.mjs +41 -4
  72. package/bin/lean/recovery.test.mjs +20 -0
  73. package/bin/lean/recurrence.mjs +133 -0
  74. package/bin/lean/recurrence.test.mjs +99 -0
  75. package/bin/lean/release-config.mjs +2 -1
  76. package/bin/lean/release-config.test.mjs +18 -0
  77. package/bin/lean/release-control.mjs +4 -2
  78. package/bin/lean/release-control.test.mjs +15 -0
  79. package/bin/lean/release-merge-hold.mjs +65 -0
  80. package/bin/lean/release-merge-hold.test.mjs +69 -0
  81. package/bin/lean/release-review.mjs +26 -9
  82. package/bin/lean/release-review.test.mjs +53 -0
  83. package/bin/lean/release-status.mjs +3 -1
  84. package/bin/lean/release-status.test.mjs +11 -0
  85. package/bin/lean/release.test.mjs +26 -1
  86. package/bin/lean/render.mjs +8 -7
  87. package/bin/lean/repro-output.test.mjs +45 -0
  88. package/bin/lean/routing.mjs +49 -0
  89. package/bin/lean/routing.test.mjs +54 -1
  90. package/bin/lean/run-issue-placement.test.mjs +30 -1
  91. package/bin/lean/sandbox-actions.mjs +121 -0
  92. package/bin/lean/sandbox-actions.test.mjs +94 -0
  93. package/bin/lean/sandbox-provider.contract.test.mjs +22 -1
  94. package/bin/lean/sandbox-remote.mjs +3 -1
  95. package/bin/lean/schedd-health.mjs +14 -2
  96. package/bin/lean/schedd-health.test.mjs +13 -0
  97. package/bin/lean/schedd.mjs +43 -17
  98. package/bin/lean/schedd.test.mjs +61 -1
  99. package/bin/lean/toolchain.mjs +16 -6
  100. package/bin/lean/toolplace.mjs +12 -0
  101. package/bin/lean/weakguard.mjs +105 -0
  102. package/bin/lean/weakguard.test.mjs +59 -0
  103. package/bin/lean/winspawn.mjs +61 -0
  104. package/bin/lean/winspawn.test.mjs +45 -0
  105. package/bin/lean/worktree.mjs +3 -1
  106. package/bin/lean/worktree.test.mjs +11 -0
  107. package/bin/pool/agent.mjs +215 -15
  108. package/bin/pool/cache-sweep.mjs +74 -0
  109. package/bin/pool/cli.mjs +11 -3
  110. package/bin/pool/docker.mjs +33 -2
  111. package/bin/pool/health.mjs +38 -0
  112. package/bin/pool/lane-tools.mjs +23 -4
  113. package/bin/pool/lane-tools.test.mjs +12 -1
  114. package/bin/pool/router.mjs +21 -3
  115. package/bin/runner.mjs +37 -0
  116. package/bin/splash-scene.mjs +356 -0
  117. package/bin/win-hide-children.mjs +114 -0
  118. package/commands/orchestrate.md +18 -27
  119. package/commands/review-pr-agents/infra.md +1 -0
  120. package/commands/review-pr-staging.md +2 -2
  121. package/docs/CONFIG.md +60 -3
  122. package/docs/OUTCOME-CODES.md +3 -0
  123. package/package.json +1 -1
  124. package/plugins/forgedock-splash/.claude-plugin/plugin.json +1 -1
  125. package/plugins/forgedock-splash/README.md +1 -1
  126. package/plugins/forgedock-splash/hooks/scene.ts +142 -8
  127. package/pool/README.md +6 -0
  128. package/pool/image/entrypoint.sh +1 -0
  129. package/scripts/acceptance-red-green.sh +8 -3
  130. package/scripts/acceptance-red-green.test.sh +8 -0
  131. package/scripts/check-spec-size.sh +3 -1
  132. package/scripts/gen-splash-scene.mjs +24 -0
  133. package/scripts/review-staging-pre.sh +8 -3
  134. package/scripts/review-staging-pre.test.sh +2 -0
@@ -37,6 +37,8 @@ import { CHECK_ID_RE, e2eCheckFor } from "./postdeploy-check.mjs";
37
37
  import { normaliseDecision, deadAnchors, anchorMatches, parseRequirementDecision } from "./decisions.mjs";
38
38
  import { globToRegex } from "../../scripts/ci-local/lib.mjs";
39
39
  import { contractBriefProblems } from "./pagegate.mjs"; // #5428
40
+ import { counterGrowth } from "./hotarea.mjs"; // #5751
41
+ import { designContractFailures } from "./recurrence.mjs"; // #5751
40
42
  const C = OUTCOME_CODES;
41
43
 
42
44
  /** #4789: folds what a builder retyping a quote changes: unicode punctuation, markdown links/markup, escapes, invisible chars. */
@@ -561,7 +563,7 @@ export function testPlanProblems(c, { required = false } = {}) {
561
563
 
562
564
  /** #5448: a requirement that starts as an imperative build verb is development work, not a prod-only measurement. */
563
565
  const DEV_WORK_RE = /^\W*(?:\w+\s+){0,2}?(?:find|fix|implement|develop|build|write|patch|add|change)\b/i;
564
- export function validateContract(c, issueText, { repro = false, pages = null, testPlan = false, readFile = null, checkIds = null, baseFiles = null } = {}) {
566
+ export function validateContract(c, issueText, { repro = false, pages = null, testPlan = false, readFile = null, checkIds = null, baseFiles = null, reproRecipe = false } = {}) {
565
567
  const problems = [];
566
568
  if (!c || typeof c !== "object" || Array.isArray(c)) return { ok: false, problems: ["contract.json is missing or not a JSON object"] };
567
569
  const reqs = Array.isArray(c.requirements) ? c.requirements : [];
@@ -628,6 +630,8 @@ export function validateContract(c, issueText, { repro = false, pages = null, te
628
630
  else {
629
631
  for (const p of tmpdirInputs(t.command)) problems.push(tmpInputProblem("repro_test", p));
630
632
  if (guessedUvEnv(t.command)) problems.push(guessedUvProblem("repro_test"));
633
+ const prov = reproRecipe ? null : envProvisioningCommand(t.command); // #5732: a forge.yaml validate.recipes rewrite may set the env up
634
+ if (prov) problems.push(`repro_test: the command provisions its own environment (\`${prov}\`); the engine prepares dependencies, so it is host-specific and fails where that interpreter or install is missing (env.repro_unrunnable); use the bare test invocation (e.g. \`poetry run pytest <file>::<test>\`) or a forge.yaml validate.recipes entry`);
631
635
  const pdr = projectDirPathMiss(t.command);
632
636
  if (pdr) problems.push(projectDirProblem("repro_test", pdr));
633
637
  if (vitestQuietFlag(t.command)) problems.push("repro_test: vitest 3 rejects -q/--quiet; use --reporter=dot");
@@ -691,7 +695,7 @@ function splitRequirementRefs(ref) {
691
695
  function amendmentProblem(a, tag) {
692
696
  const kind = a?.kind;
693
697
  const need = kind === "add-deliverable" ? "needs a path" : kind === "add-requirement" ? "needs requirement {id, quote}"
694
- : kind === "supersedes" ? "needs guard: \"#N\" (the guarded issue)" : TRACKED.includes(kind) ? "needs requirement: \"R#\"" : kind === "amend-requirement" ? "needs requirement: \"R#\" and text (the revised wording)"
698
+ : kind === "supersedes" ? "needs guard: \"#N\" (the guarded issue) or mechanism: \"<name>\" (#5752: retires the guards whose tests the lane deletes)" : TRACKED.includes(kind) ? "needs requirement: \"R#\"" : kind === "amend-requirement" ? "needs requirement: \"R#\" and text (the revised wording)"
695
699
  : kind === "substitute-validate" ? "needs validate: \"V#\" and command" : kind === "out-of-band" ? "needs requirement: \"R#\" and evidence (the job or workflow that measures it)"
696
700
  : kind === "decision" ? "needs decision {choice, anchors: [paths or globs], symbols?, supersedes?: decision id}" : null;
697
701
  const why = need ? `amendment kind '${kind}' ${need}` : `unknown kind '${kind ?? ""}'; valid kinds are ${AMEND_KINDS.join(", ")}`;
@@ -797,6 +801,12 @@ export function applyAmendments(frozen, amendments, issueText = null, { generate
797
801
  if (tagsOutOfBand(r)) r.verify = "out_of_band"; // #4404: same freeze-time tag as the planned requirements
798
802
  c.requirements.push(r);
799
803
  if (TRACKED.includes(r.disposition)) toTrack.push(r);
804
+ } else if (a.kind === "supersedes" && blank(a.guard) && typeof a.mechanism === "string" && !blank(a.mechanism)) {
805
+ // #5752: one decision removes a named mechanism; precheck retires every guard_broken whose test file the lane deleted
806
+ const mechanism = a.mechanism.trim().slice(0, 120);
807
+ c.mechanisms = [...(c.mechanisms ?? []).filter((m) => m.mechanism !== mechanism), { mechanism, why: String(a.why).trim() }];
808
+ applied.push({ kind: a.kind, target: `mechanism ${mechanism}`, why: String(a.why).trim() });
809
+ continue;
800
810
  } else if (a.kind === "supersedes" && GUARD_ID_RE.test(String(a.guard ?? "").trim())) {
801
811
  // #4693: retires one guard's guard_broken for this lane; the reviewer judges it, the engine tells the guarded issue after merge
802
812
  const guard = `#${String(a.guard).trim().replace(/^#/, "")}`;
@@ -862,6 +872,8 @@ const ENV_SIGNATURES = [
862
872
  [/invalid mount config for type "bind"|bind source path does not exist|error while creating mount source path|mounts denied/i, "Docker bind-mount source"],
863
873
  [/Executable doesn't exist at|npx playwright install|browserType\.launch: Executable/i, "Playwright browser"],
864
874
  [/\bENOTFOUND\b|\bEAI_AGAIN\b|npm (?:ERR!|error) network|getaddrinfo (?:ENOTFOUND|EAI_AGAIN)/i, "network access for npm"],
875
+ // #5732: the command picks an interpreter the host does not have (`poetry env use python3.11` on a python3.12-only sandbox)
876
+ [/Could not find the python executable|poetry env use\b[^\n]*(?:not found|error|failed)|\bpython\d(?:\.\d+)?:? not found|No interpreter found|pyenv: version `[^`]+' is not installed/i, "Python interpreter"],
865
877
  ];
866
878
  const envSignature = (out) => { const hit = ENV_SIGNATURES.find(([re]) => re.test(out)); return hit ? { tool: hit[1], kind: "environment" } : null; };
867
879
  export const SECRET_PAIR_RE = /\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|API_?KEY|CREDENTIAL)[A-Za-z0-9_]*\s*[=:]\s*)\S+/gi;
@@ -921,6 +933,19 @@ export function applyValidateRecipes(contract, recipes) {
921
933
  if (Array.isArray(contract.test_plan)) out.test_plan = contract.test_plan.map((r) => (r && typeof r === "object" ? { ...r, command: rewrite(`test_plan ${r.requirement}`, r.command) } : r)); // #5445
922
934
  return { contract: applied.length ? out : contract, applied };
923
935
  }
936
+ /**
937
+ * #5732: the first env-provisioning step of a repro command (`poetry env use`, `poetry install`, `pip install`, `uv venv`,
938
+ * `uv sync`, `uv pip install`), or null. The engine prepares dependencies (DEPS_PREPARED); the repro command is the bare test run.
939
+ */
940
+ const ENV_PROVISION_RE = /\b(poetry\s+env\s+use|poetry\s+install|(?:python3?\s+-m\s+)?pip3?\s+install|uv\s+venv|uv\s+sync|uv\s+pip\s+install)\b/;
941
+ export function envProvisioningCommand(command) {
942
+ return ENV_PROVISION_RE.exec(String(command ?? ""))?.[1].replace(/\s+/g, " ") ?? null;
943
+ }
944
+ /** #5732: true when a failed run's output carries test-failure text (an assertion, a runner's failed-test mark), not only an environment error. */
945
+ const ASSERTION_RE = /AssertionError|\bassert(?:ion)?\b[^\n]*(?:==|!=|failed|error)|^FAILED\s+\S+::|^\s*E\s+(?:assert|Expected)|\bExpected\b[^\n]*\b(?:Received|got|to (?:be|equal))|expect\(|^not ok \d+|^\s*[✗×✖]\s|^\s*● |\bTests?:\s+\d+ failed/m;
946
+ export function assertionFailure(output) {
947
+ return ASSERTION_RE.test(String(output ?? ""));
948
+ }
924
949
  /** #5020: the env.* verdict for a repro command that failed on head because a tool is missing (e.g. an uninstalled Poetry env); null when the failure is the test's own. */
925
950
  export function reproEnvMiss(run, opts) {
926
951
  return run && run.rc !== 0 && run.rc !== 124 ? missingTool(run, opts) : null;
@@ -1027,6 +1052,9 @@ export function cliUsageError({ rc, output } = {}) {
1027
1052
  }
1028
1053
  const FORGEDOCK_ENTRY_RE = /^\/.*\/forgedock\/bin\/(?:lean\/checks|forgedock)\.mjs$/;
1029
1054
  const FORGEDOCK_TOKEN_RE = /(?<![\w./-])\/[^\s'"`;&|()]*\/forgedock\/bin\/(lean\/checks|forgedock)\.mjs/g;
1055
+ /** #5727: the portable placeholders a frozen command names forgedock's entry points by (the lane env exports both). */
1056
+ export const FORGEDOCK_CHECKS_VAR = "FORGEDOCK_CHECKS_CLI", FORGEDOCK_ENTRY_VAR = "FORGEDOCK_ENTRY_CLI";
1057
+ const FORGEDOCK_PLACEHOLDER_RE = /\$(?:\{FORGEDOCK_(CHECKS|ENTRY)_CLI\}|FORGEDOCK_(CHECKS|ENTRY)_CLI(?!\w))/g;
1030
1058
  /**
1031
1059
  * #5005: a frozen validate command names forgedock's own entry point by the absolute path of the install that wrote it; on
1032
1060
  * the host that runs it that path may not exist. Rewrites each such token whose file is missing to this install's path.
@@ -1035,9 +1063,33 @@ export function resolveForgedockPaths(command, { exists = () => true, checksCli,
1035
1063
  return String(command ?? "").replace(FORGEDOCK_TOKEN_RE, (tok, which) => {
1036
1064
  const here = which === "forgedock" ? forgedockCli : checksCli;
1037
1065
  return here && !exists(tok) ? here : tok;
1066
+ }).replace(FORGEDOCK_PLACEHOLDER_RE, (tok, a, b) => { // #5727: the portable frozen form always names this install
1067
+ const here = (a ?? b) === "ENTRY" ? forgedockCli : checksCli;
1068
+ return here || tok;
1069
+ });
1070
+ }
1071
+ /** #5727: every absolute forgedock entry-point token becomes its portable placeholder, so a frozen contract names no install path. Pure. */
1072
+ export function portableForgedockPaths(command) {
1073
+ return String(command ?? "").replace(FORGEDOCK_TOKEN_RE, (tok, which) => `$${which === "forgedock" ? FORGEDOCK_ENTRY_VAR : FORGEDOCK_CHECKS_VAR}`);
1074
+ }
1075
+ const RESOLVED_RUNNERS = ["runCommand", "probeCommand", "preflightRun", "redGreen"];
1076
+ /**
1077
+ * #5727: `io` with its command runners (runCommand, probeCommand, preflightRun, redGreen) resolving `command` through
1078
+ * resolveForgedockPaths before the call, so no execution site runs a frozen forgedock path of another install. Other members untouched.
1079
+ */
1080
+ export function resolvingIo(io, opts = {}) {
1081
+ if (!io || typeof io !== "object") return io;
1082
+ const wrapped = new Map(); // live view: a member set on io later is seen; a runner is wrapped per function
1083
+ return new Proxy(io, {
1084
+ get(t, k, r) {
1085
+ const fn = Reflect.get(t, k, r);
1086
+ if (!RESOLVED_RUNNERS.includes(k) || typeof fn !== "function") return fn;
1087
+ if (!wrapped.has(fn)) wrapped.set(fn, (a, ...rest) => fn.call(t, a && typeof a === "object" && typeof a.command === "string" ? { ...a, command: resolveForgedockPaths(a.command, opts) } : a, ...rest));
1088
+ return wrapped.get(fn);
1089
+ },
1038
1090
  });
1039
1091
  }
1040
- const KIND_NAME = { command: "command", "python-module": "Python module", "node-module": "Node package", environment: "environment service" };
1092
+ const KIND_NAME = { "forgedock-path": "forgedock install path", command: "command", "python-module": "Python module", "node-module": "Node package", environment: "environment service" };
1041
1093
  /**
1042
1094
  * forge#4323: the host tool or module a failed command could not find, from its {rc, output}: bash/sh "X: command not found"
1043
1095
  * (or rc 127), python "No module named x" (top-level package), node "Cannot find module|package 'x'" (bare specifiers only).
@@ -1050,7 +1102,7 @@ export function missingTool({ rc, output } = {}, { repoHas = () => false, comman
1050
1102
  const py = PY_MISSING_RE.exec(out);
1051
1103
  if (py) { const tool = String(py[1] ?? py[2]).split(".")[0]; return local(tool) ? null : { tool, kind: "python-module" }; }
1052
1104
  const js = NODE_MISSING_RE.exec(out);
1053
- if (js && FORGEDOCK_ENTRY_RE.test(js[1])) return { tool: "forgedock", kind: "command" }; // #5005: the host's forgedock install is not at the frozen path
1105
+ if (js && FORGEDOCK_ENTRY_RE.test(js[1])) return { tool: "forgedock", kind: "forgedock-path" }; // #5005, #5727: an install-path mismatch, never a lane_tools candidate (not a TOOL_KIND)
1054
1106
  if (js) {
1055
1107
  const spec = js[1], scoped = spec.startsWith("@");
1056
1108
  if (!scoped && spec.includes("/")) return null;
@@ -1094,7 +1146,7 @@ export function interfaceDecisionFailures(contract, result, changedFiles) {
1094
1146
  * `kind` (scope_creep, validate_missing, validate_failed, validate_env, requirement_unimplemented, untracked_deferral, hotspot_growth, repro_red_green, repro_env) so callers can
1095
1147
  * tell the builder's own failed checks apart from bookkeeping gaps. `ciVerified` (#4167): the current head passed the
1096
1148
  * engine's CI verification, so a validate id left to CI is not missing; a recorded non-zero exit still fails. `repro` (#4271): the repro_test red-green words, checked when given.
1097
- * `validateRuns` (#4323): the engine's rerun {[id]: {rc, output}} of validate commands recorded as failed. A rerun that passes
1149
+ * `validateRuns` (#4323): the engine's rerun {[id]: {rc, output}} of validate commands recorded as failed, or (#5728) with no result at all (not CI-covered). A rerun that passes
1098
1150
  * counts as passed; one that could not find a host tool or module (missingTool, with `repoHas`) is kind validate_env, code
1099
1151
  * env.tool_missing (skipped on a CI-verified head), not a conformance failure.
1100
1152
  * `frozen` (#4350): the contract before typed amendments. A failed scope-check validate (isScopeCheck) whose only files
@@ -1103,7 +1155,7 @@ export function interfaceDecisionFailures(contract, result, changedFiles) {
1103
1155
  * `ciCovered` (#4527): the validate ids accepted only because the head is CI-verified (no local result, or a missing host
1104
1156
  * tool), for the trajectory; always an array.
1105
1157
  */
1106
- 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 }) {
1158
+ 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 }) {
1107
1159
  const failures = [], superseded = [], ciCovered = [], equivalent = [];
1108
1160
  // #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)
1109
1161
  if (checkIds) for (const r of contract.requirements ?? []) {
@@ -1138,8 +1190,10 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
1138
1190
  // #4167: a head the engine verified on CI covers validate ids the builder left to CI (no result, or ci:true without an exit)
1139
1191
  const leftToCi = !r || (r.ci === true && r.exit === undefined);
1140
1192
  if (ciVerified && leftToCi) { ciCovered.push(v.id); continue; }
1141
- if (leftToCi) failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "validate_missing", detail: `validate ${v.id} (\`${v.command}\`) has no recorded result` });
1142
- else if (r.exit !== 0) {
1193
+ // #5728: a row with no recorded result that the engine ran itself is judged like a rerun of a failed row; validate_missing only when nothing ran it
1194
+ const engineRun = leftToCi && validateRuns?.[v.id] ? validateRuns[v.id] : null;
1195
+ if (leftToCi && !engineRun) failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "validate_missing", detail: `validate ${v.id} (\`${v.command}\`) has no recorded result` });
1196
+ else if (engineRun || r.exit !== 0) {
1143
1197
  const rerun = validateRuns?.[v.id];
1144
1198
  if (rerun?.rc === 0) continue;
1145
1199
  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; }
@@ -1155,7 +1209,7 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
1155
1209
  if (miss) failures.push({ code: C.ENV_TOOL_MISSING, kind: "validate_env", tool: miss.tool, detail: `validate ${v.id} (\`${v.command}\`) could not run: the host is missing ${KIND_NAME[miss.kind]} '${miss.tool}' (environment, not the change)${outputTail(rerun.output)}` });
1156
1210
  else if (amendedOnly && isScopeCheck(v.command)) superseded.push({ id: v.id, files: amendedOnly });
1157
1211
  else if (rerun && isDriftFailure(rerun.output)) failures.push({ code: C.BASE_CONFLICT, kind: "validate_drift", detail: `validate ${v.id} (\`${v.command}\`) failed on a stale generated artifact (base drift, not the change): base-sync, regenerate the artifact (forge.yaml validate.regenerate) and rerun${outputTail(rerun.output)}` }); // #5653: a mechanical base-sync recovery, not unimplemented work
1158
- else failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "validate_failed", detail: `validate ${v.id} (\`${v.command}\`) failed (exit ${r.exit})${outputTail(rerun?.output)}` });
1212
+ else failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "validate_failed", detail: `validate ${v.id} (\`${v.command}\`) failed (exit ${engineRun ? rerun.rc : r.exit}${engineRun ? ", run by the engine: no recorded result" : ""})${outputTail(rerun?.output)}` });
1159
1213
  }
1160
1214
  }
1161
1215
  const st = Array.isArray(result?.requirements) ? result.requirements : [];
@@ -1173,15 +1227,21 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
1173
1227
  }
1174
1228
  for (const f of baselineFailures ?? []) failures.push({ code: C.CONFORMANCE_REGRESSION, ...f }); // #5448
1175
1229
  failures.push(...hotspotGrowth({ contract, result, hotspots, changedFiles }));
1230
+ failures.push(...counterGrowth({ before: counters?.before, after: counters?.after, contract, result })); // #5751: forge.yaml recurrence.counters, measured at base and lane head
1231
+ failures.push(...designContractFailures(contract, recurrence)); // #5751: a recurring issue's design lane contract
1176
1232
  if (repro) failures.push(...reproFailures(contract, repro), ...reproQualityFailures(repro));
1177
1233
  failures.push(...sourceDeliverableFailures(contract, changedFiles, ignore));
1178
1234
  // #4693: a broken guard fails unless the contract carries a supersedes amendment for it
1179
1235
  const retired = new Set((contract.supersedes ?? []).map((s) => s.guard));
1180
- for (const f of guardFailures ?? []) if (!retired.has(f.guard)) failures.push(f);
1236
+ // #5752: a mechanism supersedes retires a guard whose test file the lane deleted; a surviving test still needs its own supersedes
1237
+ const deleted = contract.mechanisms?.length && Array.isArray(removedPaths) ? new Set(removedPaths) : null;
1238
+ for (const f of guardFailures ?? []) if (!retired.has(f.guard) && !(deleted && f.test && deleted.has(f.test))) failures.push(f);
1181
1239
  for (const f of coupledFailures ?? []) failures.push(f); // #5079
1182
1240
  for (const f of relaxationFailures ?? []) failures.push(f); // #5237
1183
1241
  failures.push(...(routeFailures ?? [])); // #5087: topology.route_reachability, blocking when declared
1184
1242
  failures.push(...(docsFailures ?? [])); // #5419: forge.yaml docs
1243
+ failures.push(...(outcomeEvidenceFailures ?? [])); // #5752: forge.yaml outcome_evidence
1244
+ failures.push(...(ciBudgetFailures ?? [])); // #5760: CI additions need a FORGE:CI_BUDGET annotation or the shared job, scoped hygiene, max counts
1185
1245
  failures.push(...(pageFailures ?? [])); // #5428: forge.yaml pages
1186
1246
  failures.push(...(prodParityFailures ?? [])); // #5284: topology.prod_parity
1187
1247
  failures.push(...interfaceDecisionFailures(contract, result, changedFiles)); // #5338
@@ -1208,28 +1268,31 @@ function frozenAmendedFiles(frozen, contract, outside, creep) {
1208
1268
  * #4334: HEAD=UNRUNNABLE or no words (the harness could not run the test) is env.repro_unrunnable, kind repro_env: an
1209
1269
  * environment error, never a builder resume. So is BASE=UNRUNNABLE with HEAD=RAN (the base checkout could not run it).
1210
1270
  */
1211
- export function reproFailures(contract, { base, head, pristine } = {}) {
1271
+ export function reproFailures(contract, { base, head, pristine, headOutput, baseOutput } = {}) {
1212
1272
  if (head === "RAN" && base === "FAILED") return [];
1273
+ // #5732: the last 20 lines of each run's output, so a failing test reads differently from a broken environment
1274
+ const tail = (label, out) => { const t = outputTail(out, 20); return t ? t.replace("\n output tail", `\n ${label} output tail`) : ""; };
1275
+ const tails = `${tail("head", headOutput)}${tail("base", baseOutput)}`;
1213
1276
  // #5544: head's test passes on base source but the base's own version of it fails: a test-only fix, not already fixed
1214
1277
  if (head === "RAN" && base === "RAN" && pristine === "FAILED") return [];
1215
1278
  const t = contract?.repro_test ?? {};
1216
1279
  const name = [t.path, t.id].filter((x) => !blank(x)).join(" ") || "repro_test";
1217
1280
  if (!head || head === "UNRUNNABLE") {
1218
1281
  return [{ code: C.ENV_REPRO_UNRUNNABLE, kind: "repro_env",
1219
- detail: `repro test ${name} (\`${t.command ?? ""}\`): the harness could not run the test on head (environment, not the change); got BASE=${base ?? "UNRUNNABLE"} HEAD=${head ?? "UNRUNNABLE"}` }];
1282
+ detail: `repro test ${name} (\`${t.command ?? ""}\`): the harness could not run the test on head (environment, not the change); got BASE=${base ?? "UNRUNNABLE"} HEAD=${head ?? "UNRUNNABLE"}${tails}` }];
1220
1283
  }
1221
1284
  // A head that ran but a base the harness could not run (e.g. a missing dependency tree in the base checkout) is the
1222
1285
  // environment too: the change cannot fix it, so it is never a builder resume (AlterLab 40652/40665, BASE=UNRUNNABLE HEAD=RAN).
1223
1286
  if (head === "RAN" && base === "UNRUNNABLE") {
1224
1287
  return [{ code: C.ENV_REPRO_UNRUNNABLE, kind: "repro_env",
1225
- detail: `repro test ${name} (\`${t.command ?? ""}\`): the harness could not run the test on the base (environment, not the change); got BASE=UNRUNNABLE HEAD=RAN` }];
1288
+ detail: `repro test ${name} (\`${t.command ?? ""}\`): the harness could not run the test on the base (environment, not the change); got BASE=UNRUNNABLE HEAD=RAN${tails}` }];
1226
1289
  }
1227
1290
  const skipped = base === "SKIPPED" ? " (base not run: head did not pass)" : "";
1228
1291
  // #5080: the test already passes on the base: the fix is there (a hotfix or another PR), not missing from this change
1229
1292
  if (base === "RAN") return [{ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "repro_base_green",
1230
- detail: `repro test ${name} (\`${t.command ?? ""}\`) must fail on the base and pass on head; got BASE=RAN HEAD=RAN: it passes on the base already (the fix may already be on the base)` }];
1231
- return [{ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "repro_red_green",
1232
- detail: `repro test ${name} (\`${t.command ?? ""}\`) must fail on the base and pass on head; got BASE=${base ?? "UNRUNNABLE"} HEAD=${head}${skipped}` }];
1293
+ detail: `repro test ${name} (\`${t.command ?? ""}\`) must fail on the base and pass on head; got BASE=RAN HEAD=RAN: it passes on the base already (the fix may already be on the base)${tails}` }];
1294
+ return [{ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "repro_red_green", head, assertion: assertionFailure(headOutput), // #5732: lean.mjs routes a remote head failure with no assertion text to the host
1295
+ detail: `repro test ${name} (\`${t.command ?? ""}\`) must fail on the base and pass on head; got BASE=${base ?? "UNRUNNABLE"} HEAD=${head}${skipped}${tails}` }];
1233
1296
  }
1234
1297
 
1235
1298
  /** #5446: a repro_test every targeted mutation of the fix survived. Only under lean.repro_quality: enforce; patch_echo is the reviewer's call. */
@@ -1502,6 +1565,7 @@ export function autoPostDeployE2e(contract, only = null) {
1502
1565
  });
1503
1566
  return { contract: converted.length ? { ...contract, requirements } : contract, converted };
1504
1567
  }
1568
+ const DECISION_WHY = "operator FORGE:DECISION"; // #5773: the why prefix of a decided row (idempotence marker)
1505
1569
  /**
1506
1570
  * #5547: apply trusted structured operator decisions (`<!-- FORGE:DECISION {"requirement":"R2","disposition":"post-deploy"} -->`) to a
1507
1571
  * frozen contract: a deliver/defer row becomes a checkless post-deploy row (deferChecklessPostDeploy then routes it). Only comments after
@@ -1511,15 +1575,49 @@ export function applyRequirementDecisions(contract, comments = []) {
1511
1575
  const list = Array.isArray(comments) ? comments : [];
1512
1576
  const at = list.map((c) => String(c?.body ?? "").trimStart().startsWith("<!-- FORGE:CONTRACT")).lastIndexOf(true);
1513
1577
  const ds = list.slice(at + 1).map((c) => parseRequirementDecision(c?.body)).filter(Boolean);
1578
+ const rows = Array.isArray(contract?.requirements) ? contract.requirements : [];
1579
+ // #5773: a decision's quote wins over its id (a requeue may have renumbered the row); the id is the fallback
1580
+ const nq = (q) => norm(q).replace(/\s+/g, " ").trim();
1581
+ const target = (d) => {
1582
+ const q = d.quote ? nq(d.quote) : "";
1583
+ const byQuote = q ? rows.find((r) => nq(r?.quote) === q) ?? rows.find((r) => nq(r?.quote).includes(q)) : null; // exact before contains
1584
+ return byQuote ?? rows.find((r) => r?.id === d.requirement) ?? null;
1585
+ };
1586
+ const decided = new Map();
1587
+ for (const d of ds) { const r = target(d); if (r && !decided.has(r.id)) decided.set(r.id, d); }
1514
1588
  const applied = [];
1515
- const requirements = (Array.isArray(contract?.requirements) ? contract.requirements : []).map((r) => {
1516
- const d = ds.find((x) => x.requirement === r?.id);
1517
- if (!d || !["deliver", "defer"].includes(r.disposition)) return r;
1589
+ const requirements = rows.map((r) => {
1590
+ const d = decided.get(r?.id);
1591
+ // #5773: a check-less post-deploy row (added by an amendment) is decided too; one with a check id keeps it, the check-id gate judges it
1592
+ const open = ["deliver", "defer"].includes(r?.disposition) || (r?.disposition === "post-deploy" && !CHECK_ID_RE.test(String(r.check ?? "")));
1593
+ if (!d || !open || String(r.why ?? "").startsWith(DECISION_WHY)) return r;
1518
1594
  applied.push(r.id);
1519
- return { ...r, e2e_tracked: true, disposition: "post-deploy", bucket: "post-deploy", local_infeasible_why: "operator decision: the run needs spend or a third-party host outside the lane", why: `operator FORGE:DECISION: tracked post-deploy by the orchestrator, needs spend or a third-party host${d.why ? ` (${d.why})` : ""} (#5547)` };
1595
+ const { check: _check, engine_check: _engine, ...rest } = r; // #5773: a decided row is checkless; a check id it had is dropped
1596
+ return { ...rest, e2e_tracked: true, disposition: "post-deploy", bucket: "post-deploy", local_infeasible_why: "operator decision: the run needs spend or a third-party host outside the lane", why: `${DECISION_WHY}: tracked post-deploy by the orchestrator, needs spend or a third-party host${d.why ? ` (${d.why})` : ""} (#5547)` };
1520
1597
  });
1521
1598
  return { contract: applied.length ? { ...contract, requirements } : contract, applied };
1522
1599
  }
1600
+ /**
1601
+ * #5773: replayed amendments (priorAmendments plus the builder's re-emitted rows) keep one `add-requirement` per quote, the
1602
+ * last, and drop one whose quote is already a row of `contract` (the frozen contract), so a requeue does not renumber the
1603
+ * same row (#5365 renumbering still applies to distinct quotes). Other kinds pass through in order. Pure.
1604
+ */
1605
+ export function dedupeAddRequirements(contract, amendments = []) {
1606
+ const nq = (q) => norm(q).replace(/\s+/g, " ").trim();
1607
+ const list = Array.isArray(amendments) ? amendments : [];
1608
+ const frozenQuotes = new Set((contract?.requirements ?? []).map((r) => nq(r?.quote)).filter(Boolean));
1609
+ const isAdd = (a) => a?.kind === "add-requirement" && typeof a?.requirement?.quote === "string" && nq(a.requirement.quote);
1610
+ const last = new Map();
1611
+ list.forEach((a, i) => { if (isAdd(a)) last.set(nq(a.requirement.quote), i); });
1612
+ const dropped = [];
1613
+ const kept = list.filter((a, i) => {
1614
+ if (!isAdd(a)) return true;
1615
+ const q = nq(a.requirement.quote);
1616
+ if (frozenQuotes.has(q) || last.get(q) !== i) { dropped.push({ id: a.requirement.id, quote: a.requirement.quote }); return false; }
1617
+ return true;
1618
+ });
1619
+ return { amendments: kept, dropped };
1620
+ }
1523
1621
  /** #5468: the row ids named by `e2e_row` failures when every failure is one; null otherwise (anything else blocks as before). */
1524
1622
  export function loneE2eRows(failures) {
1525
1623
  const fs = failures ?? [];
@@ -3,7 +3,8 @@
3
3
  import { readFileSync } from "node:fs";
4
4
  import { describe, it } from "node:test";
5
5
  import assert from "node:assert/strict";
6
- import { testPlanProblems, proofEchoesDeliverable, outputTail, removedNamedPaths, removedPathsOf, shellSyntaxError, unrunnableValidate, noopCommand, substituteVerdict, describesUnrunnableCommand, vitestQuietFlag, normalizeRunnerCommand, cliUsageError, validateContract, applyAmendments, amendmentKindProblems, precheck, hotspotGrowth, reproFailures, reproQualityFailures, isBugIssue, parseReview, checkCompleteness, decide, closePlan, isInvestigation, formatShadowSummary, followupItems, inIssue, snapQuote, snapQuotes, isTestPath, normalizeEvidencePath, mergeReviewRows, reviewSkeleton, missingIds, resolveEvidencePath, movingBaseDiff, scopeText, evidencePathLine, evidencePathOnly, reaskable, matchCriterion, criterionLines, fillEngineRows, explainFailures, resolveForgedockPaths, missingTool, repoTracks, tmpdirInputs, isScopeCheck, isPureScopeCheck, dropScopeValidates, tagOutOfBand, outOfBandRequirements, isOutOfBand, followupMap, renderPendingFollowups, VERIFY_MODES, OUT_OF_BAND_RE, FOLLOWUP_CLASSES, followupClass, inLaneDeferral, pendingTracking, BUCKETS, bucketKind, bucketProblems, bucketTally, isE2eCommand, e2eVerified, impliedDocDeliverables, applyValidateRecipes, deferChecklessPostDeploy, substituteShellProblem, reproEnvMiss, ORCHESTRATOR_BUCKET, ownerRoute, weakenedE2eDecisions, guessedUvEnv, projectDirPathMiss, rewriteProjectDirCommand, convertDelivered, mockedDeliverable, proofEchoDetail, contractRuleCounts, onlyTestPlanProblems } from "./conformance.mjs";
6
+ import { toolMisses } from "./toolplace.mjs";
7
+ import { FORGEDOCK_CHECKS_VAR, FORGEDOCK_ENTRY_VAR, portableForgedockPaths, resolvingIo, testPlanProblems, proofEchoesDeliverable, outputTail, removedNamedPaths, removedPathsOf, shellSyntaxError, unrunnableValidate, noopCommand, substituteVerdict, describesUnrunnableCommand, vitestQuietFlag, normalizeRunnerCommand, cliUsageError, validateContract, applyAmendments, amendmentKindProblems, precheck, hotspotGrowth, reproFailures, reproQualityFailures, isBugIssue, parseReview, checkCompleteness, decide, closePlan, isInvestigation, formatShadowSummary, followupItems, inIssue, snapQuote, snapQuotes, isTestPath, normalizeEvidencePath, mergeReviewRows, reviewSkeleton, missingIds, resolveEvidencePath, movingBaseDiff, scopeText, evidencePathLine, evidencePathOnly, reaskable, matchCriterion, criterionLines, fillEngineRows, explainFailures, resolveForgedockPaths, missingTool, repoTracks, tmpdirInputs, isScopeCheck, isPureScopeCheck, dropScopeValidates, tagOutOfBand, outOfBandRequirements, isOutOfBand, followupMap, renderPendingFollowups, VERIFY_MODES, OUT_OF_BAND_RE, FOLLOWUP_CLASSES, followupClass, inLaneDeferral, pendingTracking, BUCKETS, bucketKind, bucketProblems, bucketTally, isE2eCommand, e2eVerified, impliedDocDeliverables, applyValidateRecipes, deferChecklessPostDeploy, substituteShellProblem, reproEnvMiss, ORCHESTRATOR_BUCKET, ownerRoute, weakenedE2eDecisions, guessedUvEnv, envProvisioningCommand, assertionFailure, projectDirPathMiss, rewriteProjectDirCommand, convertDelivered, mockedDeliverable, proofEchoDetail, contractRuleCounts, onlyTestPlanProblems } from "./conformance.mjs";
7
8
 
8
9
  const ISSUE = "## Requirements\n1. The scrape route must release the spend reservation on 429.\n2. The search route must release the spend reservation on 429.\n\n- [ ] Billing pricing is unchanged.";
9
10
  const Q1 = "The scrape route must release the spend reservation on 429.";
@@ -153,6 +154,12 @@ describe("#4574 amendment slips", () => {
153
154
 
154
155
  describe("precheck (deterministic, no reviewer)", () => {
155
156
  const res = { requirements: [{ id: "R1", status: "implemented" }, { id: "R2", status: "implemented" }], validation: [{ id: "V1", exit: 0 }] };
157
+ it("#5760 ciBudgetFailures surface as precheck failures", () => {
158
+ const f = { code: "conformance.unimplemented", kind: "ci_budget_unannotated", detail: "x" };
159
+ const r = precheck({ contract: C, result: res, changedFiles: files, ciBudgetFailures: [f] });
160
+ assert.equal(r.ok, false);
161
+ assert.deepEqual(r.failures, [f]);
162
+ });
156
163
  it("passes a complete, validated, in-scope change", () => assert.deepEqual(precheck({ contract: C, result: res, changedFiles: files }), { ok: true, failures: [], superseded: [], ciCovered: [], equivalent: [] }));
157
164
  it("unauthorized file -> scope_creep; tests and ignored paths are always allowed", () => {
158
165
  assert.deepEqual(codes(precheck({ contract: C, result: res, changedFiles: [...files, "src/billing.js", ".forge-lean/x", "tests/test_x.py", "pkg/foo_test.go"], ignore: [".forge-lean/"] })), ["conformance.scope_creep"]);
@@ -317,6 +324,18 @@ describe("precheck (deterministic, no reviewer)", () => {
317
324
  const local = precheck({ contract: C, result: failed, changedFiles: files, repoHas: repoTracks(["src/leak/__init__.py"]), validateRuns: { V1: { rc: 1, output: "ModuleNotFoundError: No module named 'leak.core'" } } });
318
325
  assert.deepEqual(codes(local), ["conformance.unimplemented"], "a repo module the change did not create is a code defect");
319
326
  });
327
+ it("#5728 a folded G1 with no recorded result is judged by the engine's rerun", () => {
328
+ const CG = { ...C, validate: [{ id: "V1", command: "node --test a.test.mjs" }, { id: "G1", command: "node --test b.test.mjs", regression: true }] };
329
+ const rs = { requirements: [{ id: "R1", status: "implemented" }, { id: "R2", status: "implemented" }], validation: [{ id: "V1", exit: 0 }] };
330
+ const vk = (o) => precheck({ contract: CG, result: rs, changedFiles: files, ...o }).failures.filter((f) => /^validate_/.test(f.kind));
331
+ assert.deepEqual(vk({ validateRuns: { G1: { rc: 0, output: "", engine: true } } }), [], "a passing engine run counts as passed");
332
+ const bad = vk({ validateRuns: { G1: { rc: 1, output: "AssertionError: boom", engine: true } } });
333
+ assert.deepEqual(bad.map((f) => f.kind), ["validate_failed"]); assert.match(bad[0].detail, /boom/); assert.match(bad[0].detail, /exit 1, run by the engine/);
334
+ assert.deepEqual(vk({}).map((f) => f.kind), ["validate_missing"], "no run at all stays validate_missing");
335
+ assert.deepEqual(vk({ validateRuns: { G1: { rc: 127, output: "pytest: command not found" } } }).map((f) => f.kind), ["validate_env"]);
336
+ const ci = precheck({ contract: CG, result: rs, changedFiles: files, ciVerified: true });
337
+ assert.deepEqual(ci.ciCovered, ["G1"]);
338
+ });
320
339
  it("#4527 a CI-verified head lists the validate ids it accepted without a local result; a ran-and-failed validate still fails", () => {
321
340
  const C2 = { ...C, validate: [{ id: "V1", command: "node --test a.test.mjs" }, { id: "V2", command: "tsc" }, { id: "V3", command: "lint" }] };
322
341
  const pc = precheck({ contract: C2, result: { ...res, validation: [{ id: "V2", ci: true }, { id: "V3", exit: 0 }] }, changedFiles: files, ciVerified: true });
@@ -375,7 +394,7 @@ describe("precheck (deterministic, no reviewer)", () => {
375
394
  });
376
395
  it("#5005 a missing forgedock install is env.tool_missing, not conformance; other absolute paths stay code defects", () => {
377
396
  const out = "node:internal/modules/cjs/loader\nError: Cannot find module '/opt/node/lib/node_modules/forgedock/bin/lean/checks.mjs'\n code: 'MODULE_NOT_FOUND'";
378
- assert.deepEqual(missingTool({ rc: 1, output: out }), { tool: "forgedock", kind: "command" });
397
+ assert.deepEqual(missingTool({ rc: 1, output: out }), { tool: "forgedock", kind: "forgedock-path" }); // #5727: a path mismatch, not a tool
379
398
  assert.equal(missingTool({ rc: 1, output: "Error: Cannot find module '/repo/forgedock/src/x.mjs'" }), null);
380
399
  const contract = { requirements: [], deliverables: [], validate: [{ id: "V2", command: "node /opt/node/lib/node_modules/forgedock/bin/lean/checks.mjs --base origin/staging" }] };
381
400
  const result = { validation: [{ id: "V2", command: "", exit: 1 }] };
@@ -389,6 +408,39 @@ describe("precheck (deterministic, no reviewer)", () => {
389
408
  assert.equal(resolveForgedockPaths(cmd, { ...o, exists: () => true }), cmd);
390
409
  assert.equal(resolveForgedockPaths("node bin/x.mjs", { ...o, exists: () => false }), "node bin/x.mjs");
391
410
  });
411
+ it("#5727 missingTool: a forgedock entry path is not a tool miss", () => {
412
+ const out = "Error: Cannot find module '/home/dev/.local/lib/node_modules/forgedock/bin/lean/checks.mjs'\n code: 'MODULE_NOT_FOUND'";
413
+ const miss = missingTool({ rc: 1, output: out });
414
+ assert.equal(miss.kind, "forgedock-path");
415
+ assert.deepEqual(toolMisses([{ ...miss, ids: ["V5"], source: "run" }]), { tools: [], ids: [] });
416
+ assert.deepEqual(missingTool({ rc: 1, output: "Error: Cannot find module 'left-pad'" }), { tool: "left-pad", kind: "node-module" });
417
+ });
418
+ it("#5727 resolveForgedockPaths expands the portable placeholders", () => {
419
+ const o = { checksCli: "/h/forgedock/bin/lean/checks.mjs", forgedockCli: "/h/forgedock/bin/forgedock.mjs", exists: () => true };
420
+ assert.equal(resolveForgedockPaths('node $FORGEDOCK_CHECKS_CLI --base origin/staging && node "${FORGEDOCK_ENTRY_CLI}" check', o), 'node /h/forgedock/bin/lean/checks.mjs --base origin/staging && node "/h/forgedock/bin/forgedock.mjs" check');
421
+ assert.equal(resolveForgedockPaths("echo $FORGEDOCK_CHECKS_CLIX", o), "echo $FORGEDOCK_CHECKS_CLIX");
422
+ assert.equal(resolveForgedockPaths("node /usr/lib/node_modules/forgedock/bin/lean/checks.mjs", o), "node /usr/lib/node_modules/forgedock/bin/lean/checks.mjs");
423
+ assert.equal(resolveForgedockPaths("node $FORGEDOCK_CHECKS_CLI", {}), "node $FORGEDOCK_CHECKS_CLI");
424
+ });
425
+ it("#5727 portableForgedockPaths rewrites entry tokens to placeholders", () => {
426
+ const cmd = "node /home/dev/.local/lib/node_modules/forgedock/bin/lean/checks.mjs --base origin/staging && node /opt/node/lib/node_modules/forgedock/bin/forgedock.mjs check";
427
+ assert.equal(portableForgedockPaths(cmd), "node $FORGEDOCK_CHECKS_CLI --base origin/staging && node $FORGEDOCK_ENTRY_CLI check");
428
+ assert.ok(portableForgedockPaths(cmd).includes(`$${FORGEDOCK_CHECKS_VAR}`) && portableForgedockPaths(cmd).includes(`$${FORGEDOCK_ENTRY_VAR}`));
429
+ assert.equal(portableForgedockPaths("node bin/lean/checks.mjs && node /repo/src/x.mjs"), "node bin/lean/checks.mjs && node /repo/src/x.mjs");
430
+ assert.equal(resolveForgedockPaths(portableForgedockPaths(cmd), { checksCli: "/c.mjs", forgedockCli: "/f.mjs" }), "node /c.mjs --base origin/staging && node /f.mjs check");
431
+ });
432
+ it("#5727 resolvingIo wraps only the command runners", async () => {
433
+ const seen = [], fs = { read: () => "" };
434
+ const io = { fs, runCommand: async (a) => { seen.push(["run", a.command, a.cwd]); return { rc: 0 }; }, probeCommand: async (a) => { seen.push(["probe", a.command]); return { rc: 0 }; },
435
+ preflightRun: async (a) => { seen.push(["pre", a.command]); return { rc: 0 }; }, redGreen: async (a) => { seen.push(["rg", a.command]); return {}; }, git: async (args) => args };
436
+ const w = resolvingIo(io, { checksCli: "/c.mjs", forgedockCli: "/f.mjs", exists: () => false });
437
+ await w.runCommand({ command: "node /x/forgedock/bin/lean/checks.mjs", cwd: "/wt" }); await w.probeCommand({ command: "node $FORGEDOCK_CHECKS_CLI" });
438
+ await w.preflightRun({ command: "node /x/forgedock/bin/forgedock.mjs check" }); await w.redGreen({ command: "node --test a.mjs" });
439
+ assert.deepEqual(seen, [["run", "node /c.mjs", "/wt"], ["probe", "node /c.mjs"], ["pre", "node /f.mjs check"], ["rg", "node --test a.mjs"]]);
440
+ assert.equal(w.fs, fs); assert.deepEqual(await w.git(["status"]), ["status"]);
441
+ io.later = 1; assert.equal(w.later, 1, "a member set on io later is seen");
442
+ assert.equal(resolvingIo(null), null);
443
+ });
392
444
  it("a deliver requirement reported deferred without an amendment -> untracked_deferral; partial -> unimplemented", () => {
393
445
  const r = { ...res, requirements: [{ id: "R1", status: "deferred" }, { id: "R2", status: "partial" }] };
394
446
  assert.deepEqual(codes(precheck({ contract: C, result: r, changedFiles: files })), ["conformance.untracked_deferral", "conformance.unimplemented"]);
@@ -1459,7 +1511,7 @@ describe("mutation check (#4913)", () => {
1459
1511
  const { tmpDir } = await import("../tests/_tmp.mjs");
1460
1512
  const d = tmpDir("mut-");
1461
1513
  const g = (...a) => execFileSync("git", ["-C", d, "-c", "user.email=t@t", "-c", "user.name=t", ...a], { encoding: "utf8" });
1462
- g("init", "-q", "-b", "main"); writeFileSync(join(d, "a.js"), "a1\n"); writeFileSync(join(d, "b.js"), "b\n"); g("add", "."); g("commit", "-qm", "base");
1514
+ g("init", "-q", "-b", "main"); g("config", "core.autocrlf", "false"); writeFileSync(join(d, "a.js"), "a1\n"); writeFileSync(join(d, "b.js"), "b\n"); g("add", "."); g("commit", "-qm", "base"); // #5751: autocrlf off, else a host autocrlf restores CRLF
1463
1515
  g("checkout", "-qb", "lane"); writeFileSync(join(d, "a.js"), "a2\n"); g("rm", "-q", "b.js"); g("add", "a.js"); g("commit", "-qm", "change");
1464
1516
  const r = await runMutationCheck({ targets: [{ id: "R1", commands: [{ id: "V1", command: "t" }] }], files: ["a.js", "b.js"], base: "main",
1465
1517
  git: async (a) => g(...a), runCommand: async () => ({ rc: 1 }), cwd: d, tmp: d });
@@ -2150,3 +2202,141 @@ describe("first-pass: an unregistered post-deploy check id fails at freeze, not
2150
2202
  assert.ok(!validateContract(row(), issue).problems.some((p) => /is not registered/.test(p)));
2151
2203
  });
2152
2204
  });
2205
+
2206
+ describe("#5732 repro commands and failures", () => {
2207
+ const rt = (command, o = {}) => validateContract({ ...C, repro_test: { path: "t/x.py", id: "t", command } }, ISSUE, { repro: true, ...o }).problems.filter((p) => /provisions its own environment/.test(p));
2208
+ it("#5732 validateContract rejects a repro command that provisions its environment", () => {
2209
+ for (const bad of ["cd services/api && poetry env use python3.11 -q && poetry install --no-root --no-interaction -q && poetry run pytest -q tests/test_a.py::test_b",
2210
+ "poetry env use -q python3.11 && poetry run pytest tests/x.py -m 'not integration'", "pip install -r requirements.txt && pytest tests/x.py", "python3 -m pip install pytest && pytest x.py", "uv venv && uv run pytest x.py"]) assert.equal(rt(bad).length, 1, bad);
2211
+ assert.match(rt("poetry install && poetry run pytest x.py")[0], /`poetry install`/);
2212
+ });
2213
+ it("#5732 a bare test invocation, a validate row or a recipe-rewritten repro command is accepted", () => {
2214
+ for (const ok of ["poetry run pytest tests/x.py::t", "cd services/api && .venv/bin/pytest -q tests/x.py", "uv run pytest tests/x.py"]) assert.deepEqual(rt(ok), [], ok);
2215
+ assert.deepEqual(rt("poetry install && poetry run pytest x.py", { reproRecipe: true }), []);
2216
+ assert.ok(!validateContract({ ...C, validate: [{ id: "V1", command: "poetry install && poetry run pytest x.py" }] }, ISSUE).problems.some((p) => /provisions/.test(p)));
2217
+ });
2218
+ it("#5732 envProvisioningCommand and assertionFailure", () => {
2219
+ assert.equal(envProvisioningCommand("poetry env use python3.11 && pytest"), "poetry env use");
2220
+ assert.equal(envProvisioningCommand("pytest tests/pip_install_test.py"), null);
2221
+ for (const yes of ["E AssertionError: 0.5 != 0.4", "FAILED tests/a.py::t - assert 1 == 2", "not ok 3 - foo", " ● suite › case", "Tests: 1 failed, 4 passed", "expect(received).toBe(expected)"]) assert.equal(assertionFailure(yes), true, yes);
2222
+ for (const no of ["poetry env use: python3.11 not found", "Could not find the python executable python3.11", "bash: pytest: command not found", "", undefined]) assert.equal(assertionFailure(no), false, String(no));
2223
+ });
2224
+ it("#5732 a repro_red_green row says whether head's output had assertion text; the interpreter signature is an env miss for validates too", () => {
2225
+ const t = { repro_test: { path: "t.py", command: "pytest t.py" } };
2226
+ assert.equal(reproFailures(t, { base: "SKIPPED", head: "FAILED", headOutput: "Could not find the python executable python3.11" })[0].assertion, false);
2227
+ assert.equal(reproFailures(t, { base: "SKIPPED", head: "FAILED", headOutput: "E AssertionError" })[0].assertion, true);
2228
+ assert.deepEqual(missingTool({ rc: 1, output: "Could not find the python executable python3.11" }), { tool: "Python interpreter", kind: "environment" });
2229
+ });
2230
+ });
2231
+
2232
+ import { dedupeAddRequirements } from "./conformance.mjs";
2233
+ describe("#5773 operator decisions survive requeue and amendment replay", () => {
2234
+ const Q5 = "Backfill dry-run lists all affected historical charges with counts; the real run creates invoices with no customer emails [type:manual]";
2235
+ const Q = "the real run creates invoices with no customer emails";
2236
+ const Q6 = "Post-deploy: one live quick deposit as the production test identity yields a downloadable invoice in the dashboard";
2237
+ const ISS = `## Acceptance\n- ${Q5}\n- ${Q6}`;
2238
+ const frozen = { requirements: [{ id: "R5", quote: Q5, disposition: "deliver" }, { id: "R6", quote: Q6, disposition: "deliver" }], deliverables: [{ id: "D1", path: "scripts/backfill.py", requirements: ["R5", "R6"] }], preserve: [], validate: [] };
2239
+ const dec = (j) => ({ body: `<!-- FORGE:DECISION ${JSON.stringify(j)} -->\n**tracked post-deploy**` });
2240
+ const BOT = "<!-- FORGE:CONTRACT -->\n{}";
2241
+ it("#5773 a structured decision comment does not change the issue scope (the frozen contract is not stale)", () => {
2242
+ const iss = { title: "t", body: ISS };
2243
+ assert.equal(scopeText(iss, [{ body: BOT }, dec({ requirement: "R5", disposition: "post-deploy" })]), scopeText(iss, [{ body: BOT }]));
2244
+ });
2245
+ it("#5773 a decision matches by quote over a stale id, and the decided row is checkless", () => {
2246
+ const c = { ...frozen, requirements: [...frozen.requirements, { id: "R11", quote: "other row", disposition: "deliver" }, { id: "R12", quote: Q, disposition: "post-deploy", check: "made-up-check" }] };
2247
+ const out = applyRequirementDecisions(c, [{ body: BOT }, dec({ requirement: "R11", disposition: "post-deploy", quote: Q })]);
2248
+ assert.deepEqual(out.applied, [], "a post-deploy row is not a deliver/defer row");
2249
+ const c2 = { ...c, requirements: c.requirements.map((r) => (r.id === "R12" ? { ...r, disposition: "deliver" } : r)) };
2250
+ const out2 = applyRequirementDecisions(c2, [{ body: BOT }, dec({ requirement: "R11", disposition: "post-deploy", quote: Q })]);
2251
+ assert.deepEqual(out2.applied, ["R12"], "the quote wins over the renumbered id");
2252
+ const r12 = out2.contract.requirements.find((r) => r.id === "R12");
2253
+ assert.equal(r12.check, undefined); assert.equal(r12.engine_check, undefined);
2254
+ assert.deepEqual(applyRequirementDecisions(out2.contract, [{ body: BOT }, dec({ requirement: "R11", disposition: "post-deploy", quote: Q })]).applied, [], "idempotent");
2255
+ assert.deepEqual(applyRequirementDecisions(c2, [{ body: BOT }, dec({ requirement: "R11", disposition: "post-deploy", quote: "no such row" })]).applied, ["R11"], "id fallback");
2256
+ });
2257
+ it("#5786 a quote over 400 chars still matches its row by quote, not the renumbered id", () => {
2258
+ const longQ = `${"the real run creates invoices with no customer emails and ".repeat(10)}done`;
2259
+ const c = { requirements: [{ id: "R11", quote: "other row", disposition: "deliver" }, { id: "R12", quote: longQ, disposition: "deliver" }] };
2260
+ const out = applyRequirementDecisions(c, [{ body: BOT }, dec({ requirement: "R11", disposition: "post-deploy", quote: longQ })]);
2261
+ assert.deepEqual(out.applied, ["R12"]);
2262
+ });
2263
+ it("#5773 dedupeAddRequirements keeps the last add per quote and drops one that repeats a frozen row", () => {
2264
+ const add = (id, quote, why) => ({ kind: "add-requirement", requirement: { id, quote, disposition: "post-deploy" }, why });
2265
+ const am = [{ kind: "amend-requirement", requirement: "R5", text: "dry-run only", why: "w" }, add("R11", Q, "a"), add("R11", Q, "b"), add("R12", Q6, "c")];
2266
+ const d = dedupeAddRequirements(frozen, am);
2267
+ assert.deepEqual(d.amendments.map((a) => a.why ?? a.kind), ["w", "b"]);
2268
+ assert.deepEqual(d.dropped.map((x) => x.id), ["R11", "R12"]);
2269
+ });
2270
+ it("#5773 the #41245 replay: decision -> requeue -> rows keep their ids, stay tracked post-deploy and pass the check-id gate", () => {
2271
+ const add = (id, quote, why) => ({ kind: "add-requirement", requirement: { id, quote, disposition: "post-deploy" }, why });
2272
+ const replay = [{ kind: "amend-requirement", requirement: "R5", text: "Backfill dry-run lists all affected historical charges with counts", why: "real run moves to R11" }, add("R11", Q, "live Stripe run"), add("R11", Q, "no-email guarantee in code"), add("R12", Q6, "binding decision R6")];
2273
+ const comments = [{ body: BOT }, dec({ requirement: "R5", disposition: "post-deploy" }), dec({ requirement: "R6", disposition: "post-deploy" }), dec({ requirement: "R12", disposition: "post-deploy", quote: Q })];
2274
+ for (let run = 0; run < 3; run++) {
2275
+ const a = applyAmendments(frozen, dedupeAddRequirements(frozen, replay).amendments, ISS);
2276
+ assert.deepEqual(a.problems, []);
2277
+ const ad = applyRequirementDecisions(a.contract, comments);
2278
+ const eff = deferChecklessPostDeploy(ad.contract).contract;
2279
+ assert.deepEqual(eff.requirements.map((r) => r.id), ["R5", "R6", "R11"], "no renumbered R12+");
2280
+ for (const r of eff.requirements) { assert.equal(r.disposition, "defer", r.id); assert.equal(r.bucket, ORCHESTRATOR_BUCKET, r.id); assert.equal(r.check, undefined, r.id); }
2281
+ const pc = precheck({ contract: eff, result: { requirements: [], validation: [] }, changedFiles: ["scripts/backfill.py"], checkIds: new Set() });
2282
+ assert.ok(!pc.failures.some((f) => f.kind === "check_unknown"), JSON.stringify(pc.failures));
2283
+ }
2284
+ });
2285
+ });
2286
+
2287
+ describe("#5752 mechanism supersedes", () => {
2288
+ const K = { requirements: [], deliverables: [{ id: "D1", path: "src/triage.mjs" }], validate: [] };
2289
+ const broken = (guard, test) => ({ code: "conformance.guard_broken", kind: "guard_broken", guard, test, detail: `guard ${guard} broken` });
2290
+ it("validates {mechanism, why} and stores it as contract.mechanisms; per-guard supersedes keeps working", () => {
2291
+ const a = applyAmendments(K, [{ kind: "supersedes", mechanism: "keyword triage", why: "replaced by the scorer" }, { kind: "supersedes", guard: "#12", why: "own" }]);
2292
+ assert.deepEqual(a.problems, []);
2293
+ assert.deepEqual(a.contract.mechanisms, [{ mechanism: "keyword triage", why: "replaced by the scorer" }]);
2294
+ assert.deepEqual(a.contract.supersedes, [{ guard: "#12", why: "own" }]);
2295
+ assert.deepEqual(a.applied.map((x) => x.target), ["mechanism keyword triage", "#12"]);
2296
+ assert.match(applyAmendments(K, [{ kind: "supersedes", mechanism: " ", why: "x" }]).problems[0], /needs guard: "#N".*or mechanism/);
2297
+ assert.match(applyAmendments(K, [{ kind: "supersedes", mechanism: "m" }]).problems[0], /without why/);
2298
+ });
2299
+ it("one amendment retires every guard_broken whose test the lane deleted; a strong guard with a surviving test still fails", () => {
2300
+ const contract = applyAmendments(K, [{ kind: "supersedes", mechanism: "keyword triage", why: "removed" }]).contract;
2301
+ const guardFailures = [broken("#7", "src/kw.test.mjs"), broken("#8", "src/kw2.test.mjs"), broken("#9", "src/score.test.mjs")];
2302
+ const pc = precheck({ contract, result: {}, changedFiles: ["src/triage.mjs"], guardFailures, removedPaths: ["src/kw.test.mjs", "src/kw2.test.mjs"] });
2303
+ assert.deepEqual(pc.failures.filter((f) => f.kind === "guard_broken").map((f) => f.guard), ["#9"]);
2304
+ const none = precheck({ contract: K, result: {}, changedFiles: ["src/triage.mjs"], guardFailures, removedPaths: ["src/kw.test.mjs", "src/kw2.test.mjs"] });
2305
+ assert.deepEqual(none.failures.filter((f) => f.kind === "guard_broken").map((f) => f.guard), ["#7", "#8", "#9"], "deleting a guard's test without a mechanism amendment retires nothing");
2306
+ const unread = precheck({ contract, result: {}, changedFiles: ["src/triage.mjs"], guardFailures, removedPaths: null });
2307
+ assert.equal(unread.failures.filter((f) => f.kind === "guard_broken").length, 3, "unreadable removed paths fail closed");
2308
+ });
2309
+ it("precheck pushes outcome-evidence failures", () => {
2310
+ const pc = precheck({ contract: K, result: {}, changedFiles: ["src/triage.mjs"], outcomeEvidenceFailures: [{ code: "conformance.unimplemented", kind: "outcome_evidence_missing", detail: "x" }] });
2311
+ assert.equal(pc.ok, false);
2312
+ assert.deepEqual(pc.failures.map((f) => f.kind), ["outcome_evidence_missing"]);
2313
+ });
2314
+ });
2315
+
2316
+ describe("recurrence counters and design lane precheck (#5751)", () => {
2317
+ const result = { validation: [{ id: "V1", exit: 0 }], requirements: [{ id: "R1", status: "implemented" }, { id: "R2", status: "implemented" }] };
2318
+ const run = (extra, contract = C) => precheck({ contract, result, changedFiles: files, ...extra });
2319
+ const rec = { recurs: true, count: 2, threshold: 2, evidence: [], reason: "r" };
2320
+ const design = { why_failed: "#1 and #2 patched the symptom", disposition: "replace", outcome: { metric: "retries per day", target: "0" } };
2321
+
2322
+ it("a counter that grew without a counter-ok decision fails with maintenance.counter_growth", () => {
2323
+ const pc = run({ counters: { before: { exports: 3 }, after: { exports: 4 } } });
2324
+ assert.deepEqual(pc.failures.map((f) => [f.code, f.kind]), [["maintenance.counter_growth", "counter_growth"]]);
2325
+ assert.match(pc.failures[0].detail, /counter exports grew from 3 to 4/);
2326
+ });
2327
+ it("a counter-ok decision, an unchanged or shrinking counter, and no counters all pass", () => {
2328
+ const ok = { ...C, decisions: [{ id: "K1", choice: "counter-ok: exports the new parser needs one entry point", justification: "" }] };
2329
+ assert.equal(run({ counters: { before: { exports: 3 }, after: { exports: 4 } } }, ok).ok, true);
2330
+ assert.equal(run({ counters: { before: { exports: 3 }, after: { exports: 3 } } }).ok, true);
2331
+ assert.equal(run({ counters: { before: { exports: 3 }, after: { exports: 1 } } }).ok, true);
2332
+ assert.equal(run({}).ok, true);
2333
+ });
2334
+ it("a recurring issue's contract without a complete design block fails with recurrence.design_missing", () => {
2335
+ const pc = run({ recurrence: rec });
2336
+ assert.deepEqual(pc.failures.map((f) => [f.code, f.kind]), [["recurrence.design_missing", "design_missing"]]);
2337
+ const partial = run({ recurrence: rec }, { ...C, design: { ...design, disposition: "patch", outcome: { metric: "x" } } });
2338
+ assert.match(partial.failures[0].detail, /disposition.*; design\.outcome needs a metric and a target/);
2339
+ assert.equal(run({ recurrence: rec }, { ...C, design }).ok, true);
2340
+ assert.equal(run({ recurrence: { ...rec, recurs: false } }).ok, true, "no recurrence: no design check");
2341
+ });
2342
+ });
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: AGPL-3.0-or-later
3
3
  import { describe, it } from "node:test";
4
4
  import assert from "node:assert/strict";
5
+ import { join } from "node:path"; // #5751: the cache path uses the host separator
5
6
  import { normaliseFacts, renderFactsRecord, FACTS_MARKER } from "./facts.mjs";
6
7
  import { closedResult, gatherContextFacts, compileContextPack, contextPackFor, contextArm, contextPackCacheKey, linkStateStamp, LINK_STAMP_MAX, parseContextPackConfig, resolveContextMode, laneType, priorAttempts, issueSymbols, bodyLinks, parentOf, renderContextRecord, DEFAULT_CONTEXT_BYTES, noComments, subjectTerms, subjectHistory, MAX_SUBJECT_ITEMS, MAX_SUBJECT_QUERIES } from "./context.mjs";
7
8
 
@@ -123,7 +124,7 @@ describe("context pack (forge#4275)", () => {
123
124
  assert.equal(contextPackCacheKey(50, "abc", cfg, {}), contextPackCacheKey(50, "abc", cfg), "no repo: today's key");
124
125
  await contextPackFor({ cfg, issue: 50, repo: "acme/one", headSha: "abc", cacheDir: "/runs", fs, gather: g });
125
126
  await contextPackFor({ cfg, issue: 50, repo: "acme/two", headSha: "def", cacheDir: "/runs", fs, gather: g });
126
- assert.deepEqual([...store.keys()].map((k) => k.split("-").slice(0, 2).join("-")).sort(), ["/runs/context-acme__one__50", "/runs/context-acme__two__50"]);
127
+ assert.deepEqual([...store.keys()].map((k) => k.split("-").slice(0, 2).join("-")).sort(), [join("/runs", "context-acme__one__50"), join("/runs", "context-acme__two__50")]);
127
128
  const again = await contextPackFor({ cfg, issue: 50, repo: "acme/one", headSha: "abc", cacheDir: "/runs", fs, gather: g });
128
129
  assert.equal(again.cached, true);
129
130
  });
@@ -319,14 +320,14 @@ describe("#4298 context-pack cache and shared names", () => {
319
320
 
320
321
  it("writes through a temp file and a rename, then prunes the issue's other packs only", async () => {
321
322
  const { fs, store, ops } = memFs();
322
- store.set("/runs/context-50-old-aaaaaaaaaaaa.json", "{}");
323
- store.set("/runs/context-500-x-bbbbbbbbbbbb.json", "{}");
324
- store.set("/runs/50-run.jsonl", "");
323
+ store.set(join("/runs", "context-50-old-aaaaaaaaaaaa.json"), "{}");
324
+ store.set(join("/runs", "context-500-x-bbbbbbbbbbbb.json"), "{}");
325
+ store.set(join("/runs", "50-run.jsonl"), "");
325
326
  await contextPackFor({ cfg, issue: 50, headSha: "abc", cacheDir: "/runs", fs, stamp: { scope: "t", attempts: 0 }, gather: async () => facts() });
326
- const file = `/runs/${contextPackCacheKey(50, "abc", cfg, { scope: "t", attempts: 0 })}`;
327
+ const file = join("/runs", contextPackCacheKey(50, "abc", cfg, { scope: "t", attempts: 0 }));
327
328
  assert.equal(ops[0][0], "write"); assert.match(ops[0][1], /\.tmp$/);
328
329
  assert.deepEqual(ops[1], ["rename", ops[0][1], file]);
329
- assert.deepEqual([...store.keys()].sort(), ["/runs/50-run.jsonl", "/runs/context-500-x-bbbbbbbbbbbb.json", file].sort());
330
+ assert.deepEqual([...store.keys()].sort(), [join("/runs", "50-run.jsonl"), join("/runs", "context-500-x-bbbbbbbbbbbb.json"), file].sort());
330
331
  });
331
332
 
332
333
  it("a rename or prune failure is not an error, and a seam without rename still writes", async () => {