audit-tools 0.30.49 → 0.30.51

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 (117) hide show
  1. package/dist/audit/cli/advanceAuditCommand.d.ts.map +1 -1
  2. package/dist/audit/cli/advanceAuditCommand.js +8 -4
  3. package/dist/audit/cli/advanceAuditCommand.js.map +1 -1
  4. package/dist/audit/cli/args.d.ts.map +1 -1
  5. package/dist/audit/cli/args.js +9 -2
  6. package/dist/audit/cli/args.js.map +1 -1
  7. package/dist/audit/cli/mergeAndIngestCommand.d.ts.map +1 -1
  8. package/dist/audit/cli/mergeAndIngestCommand.js +6 -22
  9. package/dist/audit/cli/mergeAndIngestCommand.js.map +1 -1
  10. package/dist/audit/cli/validateResultCommand.d.ts.map +1 -1
  11. package/dist/audit/cli/validateResultCommand.js +19 -6
  12. package/dist/audit/cli/validateResultCommand.js.map +1 -1
  13. package/dist/audit/cli/workerRunCommand.d.ts.map +1 -1
  14. package/dist/audit/cli/workerRunCommand.js +6 -21
  15. package/dist/audit/cli/workerRunCommand.js.map +1 -1
  16. package/dist/audit/contracts/workerSchemas.d.ts +27 -3
  17. package/dist/audit/contracts/workerSchemas.d.ts.map +1 -1
  18. package/dist/audit/contracts/workerSchemas.js +5 -1
  19. package/dist/audit/contracts/workerSchemas.js.map +1 -1
  20. package/dist/audit/extractors/analyzers/html.d.ts +1 -0
  21. package/dist/audit/extractors/analyzers/html.d.ts.map +1 -1
  22. package/dist/audit/extractors/analyzers/html.js +5 -3
  23. package/dist/audit/extractors/analyzers/html.js.map +1 -1
  24. package/dist/audit/extractors/browserExtension.d.ts.map +1 -1
  25. package/dist/audit/extractors/browserExtension.js +1 -8
  26. package/dist/audit/extractors/browserExtension.js.map +1 -1
  27. package/dist/audit/extractors/graphRoutes.d.ts.map +1 -1
  28. package/dist/audit/extractors/graphRoutes.js +4 -1
  29. package/dist/audit/extractors/graphRoutes.js.map +1 -1
  30. package/dist/audit/orchestrator/autoFixExecutor.d.ts +8 -0
  31. package/dist/audit/orchestrator/autoFixExecutor.d.ts.map +1 -1
  32. package/dist/audit/orchestrator/autoFixExecutor.js +68 -35
  33. package/dist/audit/orchestrator/autoFixExecutor.js.map +1 -1
  34. package/dist/audit/orchestrator/runtimeCommand.d.ts.map +1 -1
  35. package/dist/audit/orchestrator/runtimeCommand.js +7 -1
  36. package/dist/audit/orchestrator/runtimeCommand.js.map +1 -1
  37. package/dist/audit/orchestrator/selectiveDeepening/index.d.ts.map +1 -1
  38. package/dist/audit/orchestrator/selectiveDeepening/index.js +12 -8
  39. package/dist/audit/orchestrator/selectiveDeepening/index.js.map +1 -1
  40. package/dist/audit/orchestrator/taskBuilder.d.ts.map +1 -1
  41. package/dist/audit/orchestrator/taskBuilder.js +0 -32
  42. package/dist/audit/orchestrator/taskBuilder.js.map +1 -1
  43. package/dist/audit/quota/discoveredLimits.d.ts +12 -0
  44. package/dist/audit/quota/discoveredLimits.d.ts.map +1 -1
  45. package/dist/audit/quota/discoveredLimits.js +30 -25
  46. package/dist/audit/quota/discoveredLimits.js.map +1 -1
  47. package/dist/audit/validation/auditResults.d.ts +16 -0
  48. package/dist/audit/validation/auditResults.d.ts.map +1 -1
  49. package/dist/audit/validation/auditResults.js +35 -1
  50. package/dist/audit/validation/auditResults.js.map +1 -1
  51. package/dist/remediate/phases/close.d.ts.map +1 -1
  52. package/dist/remediate/phases/close.js +16 -6
  53. package/dist/remediate/phases/close.js.map +1 -1
  54. package/dist/remediate/steps/contractPipeline.d.ts +4 -1
  55. package/dist/remediate/steps/contractPipeline.d.ts.map +1 -1
  56. package/dist/remediate/steps/contractPipeline.js +63 -47
  57. package/dist/remediate/steps/contractPipeline.js.map +1 -1
  58. package/dist/remediate/steps/contractPipelinePrompts.d.ts +12 -1
  59. package/dist/remediate/steps/contractPipelinePrompts.d.ts.map +1 -1
  60. package/dist/remediate/steps/contractPipelinePrompts.js +29 -18
  61. package/dist/remediate/steps/contractPipelinePrompts.js.map +1 -1
  62. package/dist/remediate/steps/dispatch.d.ts +20 -3
  63. package/dist/remediate/steps/dispatch.d.ts.map +1 -1
  64. package/dist/remediate/steps/dispatch.js +193 -116
  65. package/dist/remediate/steps/dispatch.js.map +1 -1
  66. package/dist/remediate/steps/finalGate.d.ts +88 -0
  67. package/dist/remediate/steps/finalGate.d.ts.map +1 -0
  68. package/dist/remediate/steps/finalGate.js +171 -0
  69. package/dist/remediate/steps/finalGate.js.map +1 -0
  70. package/dist/remediate/steps/leanFastPath.d.ts.map +1 -1
  71. package/dist/remediate/steps/leanFastPath.js +12 -0
  72. package/dist/remediate/steps/leanFastPath.js.map +1 -1
  73. package/dist/remediate/steps/nextStep.d.ts +3 -81
  74. package/dist/remediate/steps/nextStep.d.ts.map +1 -1
  75. package/dist/remediate/steps/nextStep.js +36 -169
  76. package/dist/remediate/steps/nextStep.js.map +1 -1
  77. package/dist/remediate/validation/contractPipeline.d.ts.map +1 -1
  78. package/dist/remediate/validation/contractPipeline.js +17 -3
  79. package/dist/remediate/validation/contractPipeline.js.map +1 -1
  80. package/dist/shared/index.d.ts +1 -0
  81. package/dist/shared/index.d.ts.map +1 -1
  82. package/dist/shared/index.js +1 -0
  83. package/dist/shared/index.js.map +1 -1
  84. package/dist/shared/io/frictionCapture.d.ts +14 -1
  85. package/dist/shared/io/frictionCapture.d.ts.map +1 -1
  86. package/dist/shared/io/frictionCapture.js +28 -3
  87. package/dist/shared/io/frictionCapture.js.map +1 -1
  88. package/dist/shared/observability/runLog.d.ts +1 -1
  89. package/dist/shared/observability/runLog.d.ts.map +1 -1
  90. package/dist/shared/observability/runLog.js.map +1 -1
  91. package/dist/shared/providers/providerConfirmation.d.ts +16 -1
  92. package/dist/shared/providers/providerConfirmation.d.ts.map +1 -1
  93. package/dist/shared/providers/providerConfirmation.js +13 -13
  94. package/dist/shared/providers/providerConfirmation.js.map +1 -1
  95. package/dist/shared/providers/providerFactory.d.ts.map +1 -1
  96. package/dist/shared/providers/providerFactory.js +10 -14
  97. package/dist/shared/providers/providerFactory.js.map +1 -1
  98. package/dist/shared/providers/providerPathGuard.d.ts +21 -0
  99. package/dist/shared/providers/providerPathGuard.d.ts.map +1 -0
  100. package/dist/shared/providers/providerPathGuard.js +69 -0
  101. package/dist/shared/providers/providerPathGuard.js.map +1 -0
  102. package/dist/shared/providers/sharedProviderConfirmation.d.ts +14 -2
  103. package/dist/shared/providers/sharedProviderConfirmation.d.ts.map +1 -1
  104. package/dist/shared/providers/sharedProviderConfirmation.js +26 -5
  105. package/dist/shared/providers/sharedProviderConfirmation.js.map +1 -1
  106. package/dist/shared/quota/apiPool.d.ts +6 -1
  107. package/dist/shared/quota/apiPool.d.ts.map +1 -1
  108. package/dist/shared/quota/apiPool.js +13 -2
  109. package/dist/shared/quota/apiPool.js.map +1 -1
  110. package/dist/shared/quota/fileLock.d.ts +17 -2
  111. package/dist/shared/quota/fileLock.d.ts.map +1 -1
  112. package/dist/shared/quota/fileLock.js +21 -19
  113. package/dist/shared/quota/fileLock.js.map +1 -1
  114. package/dist/shared/types/providerConfirmation.d.ts +9 -0
  115. package/dist/shared/types/providerConfirmation.d.ts.map +1 -1
  116. package/package.json +2 -2
  117. package/scripts/audit/postinstall.mjs +22 -14
@@ -0,0 +1,171 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Tool-owned final completion gate (INV-RS-10) + coarse re-block (INV-RS-09)
3
+ // ---------------------------------------------------------------------------
4
+ //
5
+ // Behaviour-preserving extraction from `nextStep.ts` (CP-NODE-1): this is the
6
+ // tool-owned final-gate cluster (the gate runner, its bounded coarse-reblock
7
+ // backstop, and the sidecar counter I/O) lifted into a sibling leaf module so
8
+ // the orchestrator god-module no longer owns it inline. `nextStep.ts` imports
9
+ // and re-exports these symbols, so the public surface and existing test imports
10
+ // are unchanged.
11
+ //
12
+ // INV-RS-10: the final completion gate is a TOOL-OWNED, NON-VACUOUS suite that
13
+ // is INDEPENDENT of any `plan.test_command`. A run can only land green when this
14
+ // suite passes; a vacuous/unset `plan.test_command` can never substitute for it.
15
+ // The suite is executed through the env-scrubbing `runTracked` path
16
+ // (`runCommand`), which strips CLAUDECODE / CLAUDE_CODE_* so the gate runs in a
17
+ // clean environment regardless of the host session.
18
+ //
19
+ // Hard floor (always run, in order — single package, single-flight build — CE-001):
20
+ // 1. npm run build (one tsc build for the whole package)
21
+ // 2. npm run check (typecheck, no emit)
22
+ // 3. BUILD-FREE unit suites at the repo root, each invoked directly so dist is
23
+ // never rebuilt or raced:
24
+ // - shared+audit: node --import tsx/esm --test tests/shared/*.test.mjs tests/audit/*.test.mjs
25
+ // - remediate-code: npx vitest run
26
+ //
27
+ // CE-002: the hard floor is scoped to build + typecheck + unit. The
28
+ // runtime/packaged-bin smoke surface (the `verify:release` smokes) is recorded
29
+ // as a DECLARED RESIDUAL the floor does not gate, rather than run inline — the
30
+ // packaged-bin smokes are the known Windows-flaky / EPERM surface and an in-loop
31
+ // gate must converge deterministically, so they are surfaced for a separate
32
+ // pass instead of being able to strand the run.
33
+ import { join } from "node:path";
34
+ import { readOptionalJsonFile, writeJsonFile } from "audit-tools/shared";
35
+ import { isSkipStatus } from "../state/itemStatus.js";
36
+ import { runCommand } from "../utils/commands.js";
37
+ import { isAuditToolsMonorepo, toolOwnedFinalGateCommands, } from "./gateCommands.js";
38
+ // `FinalGateCommandSpec`, `isAuditToolsMonorepo`, and `toolOwnedFinalGateCommands`
39
+ // are single-sourced in the leaf module `gateCommands.ts` (so `dispatch.ts` can
40
+ // derive the same pinned merged-base check without an import cycle). Imported
41
+ // here for local use and re-exported to preserve the public surface + test imports.
42
+ export { isAuditToolsMonorepo, toolOwnedFinalGateCommands };
43
+ /**
44
+ * Run the tool-owned final gate (INV-RS-10). Each command runs through
45
+ * `runCommand` → shared `runTracked`, which scrubs CLAUDECODE / CLAUDE_CODE_*.
46
+ * The first failing command short-circuits the floor (a broken build makes the
47
+ * later layers meaningless). A `runner` may be injected for tests. When the
48
+ * audit-tools suite does not apply (non-monorepo target), the gate is
49
+ * `scoped_out` (does not block) rather than vacuously passing.
50
+ */
51
+ export async function runToolOwnedFinalGate(root, opts = {}) {
52
+ const runtime_residual = {
53
+ surface: "runtime/packaged-bin smokes (verify:release)",
54
+ commands: [
55
+ "npm run smoke:packaged-audit-code",
56
+ "npm run smoke:packaged-remediate-code",
57
+ ],
58
+ };
59
+ const commands = toolOwnedFinalGateCommands(root);
60
+ if (commands.length === 0) {
61
+ // Audit-tools-specific suite does not apply here — declared scope, not a
62
+ // vacuous pass (it never substitutes for a real gate on the audit-tools repo).
63
+ return { passed: true, results: [], scoped_out: true, runtime_residual };
64
+ }
65
+ const runner = opts.runner ??
66
+ ((argv, cwd, packageDir) => {
67
+ const [command, ...args] = argv;
68
+ // Package-scoped unit suites run with cwd at the package (no `npm -w`); the
69
+ // monorepo-root build/check commands run at the repo root.
70
+ const effectiveCwd = packageDir ? join(root, packageDir) : cwd;
71
+ // runCommand → runTracked strips CLAUDECODE / CLAUDE_CODE_* (INV-RS-10).
72
+ const result = runCommand(command, args, {
73
+ cwd: effectiveCwd,
74
+ stdio: ["ignore", "pipe", "pipe"],
75
+ });
76
+ return { status: result.status };
77
+ });
78
+ const results = [];
79
+ let passed = true;
80
+ for (const spec of commands) {
81
+ const { status } = runner(spec.argv, root, spec.package_dir);
82
+ const cmdPassed = status === 0;
83
+ results.push({
84
+ argv: spec.argv,
85
+ layer: spec.layer,
86
+ ...(spec.package_dir ? { package_dir: spec.package_dir } : {}),
87
+ exit_code: status,
88
+ passed: cmdPassed,
89
+ });
90
+ if (!cmdPassed) {
91
+ passed = false;
92
+ break; // short-circuit: later layers are meaningless on a broken floor
93
+ }
94
+ }
95
+ return { passed, results, scoped_out: false, runtime_residual };
96
+ }
97
+ /**
98
+ * The bound on coarse re-block iterations before the run converges to a terminal
99
+ * `blocked` close (CE-003). Two re-block attempts give a flaky-but-recoverable
100
+ * suite a chance to settle; the third unattributable red terminates
101
+ * deterministically rather than livelocking.
102
+ */
103
+ export const COARSE_REBLOCK_BOUND = 2;
104
+ const FINAL_GATE_STATE_FILENAME = "final-gate.json";
105
+ export async function readFinalGateSidecar(artifactsDir) {
106
+ const sidecar = await readOptionalJsonFile(join(artifactsDir, FINAL_GATE_STATE_FILENAME));
107
+ const n = sidecar?.coarse_reblock_count;
108
+ return {
109
+ count: typeof n === "number" && Number.isFinite(n) && n >= 0 ? n : 0,
110
+ terminated: sidecar?.terminated === true,
111
+ };
112
+ }
113
+ export async function writeFinalGateSidecar(artifactsDir, count, terminated) {
114
+ await writeJsonFile(join(artifactsDir, FINAL_GATE_STATE_FILENAME), {
115
+ schema_version: "remediate-code-final-gate/v1alpha1",
116
+ coarse_reblock_count: count,
117
+ terminated,
118
+ });
119
+ }
120
+ /**
121
+ * Coarse re-block-ALL-non-terminal on an unattributable final-gate red
122
+ * (INV-RS-09) with a bounded, monotonic auto-terminate (CE-003).
123
+ *
124
+ * The tool-owned gate is whole-repo, so a red is inherently unattributable to a
125
+ * single node. Below the bound, EVERY non-skip item (including `resolved` ones —
126
+ * a resolved item's own change may have caused the red) is re-opened to `pending`
127
+ * and the run re-attempts the whole repo through the rolling scheduler
128
+ * (`reattempt_all` → `implementing`). At or above the bound, the run STOPS
129
+ * re-attempting and converges DETERMINISTICALLY: every non-skip item becomes
130
+ * terminal `blocked` and the run advances to `closing`.
131
+ *
132
+ * CE-003 no-human-host guarantee: the loop is owned entirely by the gate + the
133
+ * rolling scheduler — it NEVER routes through the human triage prompt
134
+ * (`waiting_for_triage`) and is bounded by `bound`, so a permanently-red sibling
135
+ * converges to a terminal `blocked` close deterministically: never livelocking,
136
+ * never stranding on a human prompt, and never force-closed to green (a RED gate
137
+ * always leaves `blocked` items, so close.ts's `!anyBlocked` guard keeps the run
138
+ * out of the fully-green path). User SKIP dispositions (ignored /
139
+ * deemed_inappropriate) are settled decisions and are left alone. Pure (the
140
+ * counter is supplied / returned).
141
+ */
142
+ export function applyCoarseReblock(state, currentCount, gateSummary, bound = COARSE_REBLOCK_BOUND) {
143
+ const now = new Date().toISOString();
144
+ if (currentCount >= bound) {
145
+ // Bounded auto-terminate: converge DETERMINISTICALLY to a terminal `blocked`
146
+ // close for a no-human host — never livelock, never a triage prompt, never green.
147
+ for (const it of Object.values(state.items ?? {})) {
148
+ if (isSkipStatus(it.status))
149
+ continue; // settled user decision — never overturn
150
+ it.status = "blocked";
151
+ it.started_at ??= now;
152
+ it.completed_at = now;
153
+ it.failure_reason =
154
+ `Tool-owned final gate failed and the coarse re-block backstop reached its ` +
155
+ `bound (${bound}); converging to a terminal blocked close (no-human host). ${gateSummary}`;
156
+ }
157
+ return { state, action: "terminal_blocked", next_count: currentCount };
158
+ }
159
+ // Below the bound: re-open every non-skip item to `pending` and re-attempt the
160
+ // whole repo via the rolling scheduler (NOT the human triage prompt).
161
+ for (const it of Object.values(state.items ?? {})) {
162
+ if (isSkipStatus(it.status))
163
+ continue;
164
+ it.status = "pending";
165
+ it.failure_context =
166
+ `Re-attempted by the coarse final-gate backstop (unattributable whole-repo red). ${gateSummary}`;
167
+ delete it.completed_at;
168
+ }
169
+ return { state, action: "reattempt_all", next_count: currentCount + 1 };
170
+ }
171
+ //# sourceMappingURL=finalGate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"finalGate.js","sourceRoot":"","sources":["../../../src/remediate/steps/finalGate.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,iBAAiB;AACjB,EAAE;AACF,+EAA+E;AAC/E,iFAAiF;AACjF,iFAAiF;AACjF,oEAAoE;AACpE,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,oFAAoF;AACpF,oFAAoF;AACpF,mEAAmE;AACnE,iFAAiF;AACjF,+BAA+B;AAC/B,sGAAsG;AACtG,0CAA0C;AAC1C,EAAE;AACF,oEAAoE;AACpE,+EAA+E;AAC/E,+EAA+E;AAC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,EAC3C,2CAAoD,CAAC;AAEvD,MAAM,MAAM,0BAA0B,GAAG,OAAO,GAAG,UAAU,CAAC;AAE9D;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,OAAO,GAAG;IAC7D,WAAW,EAAE,0BAA0B,CAAC;IACxC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAmCA;AAED,mEAAmE;AACnE,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,qBAAqB,CAAC;IACrC,yBAAyB,EAAE,MAAM,EAAE,CAAC;CACrC;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,OAAO,EAAE,EACnB,MAAM,EAAE,MAAM,GACb,iBAAiB,CAQnB"}
@@ -153,6 +153,18 @@ export function interpretLeanLightReviewVerdict(raw) {
153
153
  if (!isRecord(raw)) {
154
154
  return { disposition: "escalate", concerns: ["unreadable light-review verdict"] };
155
155
  }
156
+ // Schema-version gate: a verdict that does not carry the exact expected
157
+ // schema_version is not a trustworthy light-review emission (it may be a stale,
158
+ // mis-shaped, or wrong-contract artifact). Fail safe toward escalation rather
159
+ // than trusting an unversioned `clear`.
160
+ if (raw.schema_version !== LEAN_LIGHT_REVIEW_SCHEMA_VERSION) {
161
+ return {
162
+ disposition: "escalate",
163
+ concerns: [
164
+ `light-review verdict schema_version must be "${LEAN_LIGHT_REVIEW_SCHEMA_VERSION}"`,
165
+ ],
166
+ };
167
+ }
156
168
  const concerns = Array.isArray(raw.concerns)
157
169
  ? raw.concerns.filter((c) => typeof c === "string")
158
170
  : [];
@@ -1 +1 @@
1
- {"version":3,"file":"leanFastPath.js","sourceRoot":"","sources":["../../../src/remediate/steps/leanFastPath.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,EAAE;AACF,kEAAkE;AAClE,+EA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,QAAQ,EAAE;gBACR,gDAAgD,gCAAgC,GAAG;aACpF;SACF,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC1C,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;QAChE,CAAC,CAAC,EAAE,CAAC;IACP,IAAI,GAAG,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;QAChC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAChD,CAAC;IACD,IAAI,GAAG,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;QACnC,OAAO;YACL,WAAW,EAAE,UAAU;YACvB,QAAQ,EACN,QAAQ,CAAC,MAAM,GAAG,CAAC;gBACjB,CAAC,CAAC,QAAQ;gBACV,CAAC,CAAC,CAAC,iDAAiD,CAAC;SAC1D,CAAC;IACJ,CAAC;IACD,OAAO;QACL,WAAW,EAAE,UAAU;QACvB,QAAQ,EAAE,CAAC,kDAAkD,CAAC;KAC/D,CAAC;AACJ,CAAC;AAWD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAmB,EACnB,MAAc;IAEd,OAAO;QACL,OAAO,EAAE,MAAM;QACf,QAAQ;QACR,YAAY,EAAE,SAAS;QACvB,MAAM,EAAE,qBAAqB;QAC7B,yBAAyB,EAAE,CAAC,MAAM,CAAC;KACpC,CAAC;AACJ,CAAC"}
@@ -4,7 +4,7 @@ import { type FrictionTriageDecision, type InterpretedIntent, type SessionConfig
4
4
  import { type WorktreeNodeWorker } from "./dispatch.js";
5
5
  import type { RemediationStep, RemediationDispatchPlan } from "./types.js";
6
6
  import { isTerminalStatus, isVerifiedCompleteStatus } from "../state/itemStatus.js";
7
- import { isAuditToolsMonorepo, toolOwnedFinalGateCommands, type FinalGateCommandSpec } from "./gateCommands.js";
7
+ import { type GateRunner } from "./finalGate.js";
8
8
  import type { IntentCheckpoint } from "audit-tools/shared";
9
9
  export interface NextStepOptions {
10
10
  root?: string;
@@ -321,86 +321,8 @@ export declare function executeInProcessPartition(params: {
321
321
  */
322
322
  sourceByPoolId?: Map<string, DispatchableSource>;
323
323
  }): Promise<InProcessPartitionResult>;
324
- export { isAuditToolsMonorepo, toolOwnedFinalGateCommands };
325
- export type { FinalGateCommandSpec };
326
- /** A command's recorded outcome within a gate run. */
327
- export interface FinalGateCommandResult {
328
- argv: string[];
329
- layer: FinalGateCommandSpec["layer"];
330
- package_dir?: string;
331
- exit_code: number | null;
332
- passed: boolean;
333
- }
334
- export interface ToolOwnedFinalGateResult {
335
- passed: boolean;
336
- results: FinalGateCommandResult[];
337
- /**
338
- * True when the audit-tools-specific suite did not apply (target is not the
339
- * audit-tools monorepo). The gate then does not block; it is a declared scope,
340
- * not a vacuous pass.
341
- */
342
- scoped_out: boolean;
343
- /**
344
- * The runtime/packaging surface the hard floor does NOT gate, declared as a
345
- * residual for a separate pass (CE-002). Always present (the floor is scoped
346
- * to build+check+unit by design).
347
- */
348
- runtime_residual: {
349
- surface: string;
350
- commands: string[];
351
- };
352
- }
353
- /** Injectable runner so the gate is unit-testable without spawning a real build. */
354
- export type GateRunner = (argv: string[], cwd: string, packageDir?: string) => {
355
- status: number | null;
356
- };
357
- /**
358
- * Run the tool-owned final gate (INV-RS-10). Each command runs through
359
- * `runCommand` → shared `runTracked`, which scrubs CLAUDECODE / CLAUDE_CODE_*.
360
- * The first failing command short-circuits the floor (a broken build makes the
361
- * later layers meaningless). A `runner` may be injected for tests. When the
362
- * audit-tools suite does not apply (non-monorepo target), the gate is
363
- * `scoped_out` (does not block) rather than vacuously passing.
364
- */
365
- export declare function runToolOwnedFinalGate(root: string, opts?: {
366
- runner?: GateRunner;
367
- }): Promise<ToolOwnedFinalGateResult>;
368
- /**
369
- * The bound on coarse re-block iterations before the run converges to a terminal
370
- * `blocked` close (CE-003). Two re-block attempts give a flaky-but-recoverable
371
- * suite a chance to settle; the third unattributable red terminates
372
- * deterministically rather than livelocking.
373
- */
374
- export declare const COARSE_REBLOCK_BOUND = 2;
375
- export type CoarseReblockAction = "reattempt_all" | "terminal_blocked";
376
- export interface CoarseReblockDecision {
377
- state: RemediationState;
378
- action: CoarseReblockAction;
379
- next_count: number;
380
- }
381
- /**
382
- * Coarse re-block-ALL-non-terminal on an unattributable final-gate red
383
- * (INV-RS-09) with a bounded, monotonic auto-terminate (CE-003).
384
- *
385
- * The tool-owned gate is whole-repo, so a red is inherently unattributable to a
386
- * single node. Below the bound, EVERY non-skip item (including `resolved` ones —
387
- * a resolved item's own change may have caused the red) is re-opened to `pending`
388
- * and the run re-attempts the whole repo through the rolling scheduler
389
- * (`reattempt_all` → `implementing`). At or above the bound, the run STOPS
390
- * re-attempting and converges DETERMINISTICALLY: every non-skip item becomes
391
- * terminal `blocked` and the run advances to `closing`.
392
- *
393
- * CE-003 no-human-host guarantee: the loop is owned entirely by the gate + the
394
- * rolling scheduler — it NEVER routes through the human triage prompt
395
- * (`waiting_for_triage`) and is bounded by `bound`, so a permanently-red sibling
396
- * converges to a terminal `blocked` close deterministically: never livelocking,
397
- * never stranding on a human prompt, and never force-closed to green (a RED gate
398
- * always leaves `blocked` items, so close.ts's `!anyBlocked` guard keeps the run
399
- * out of the fully-green path). User SKIP dispositions (ignored /
400
- * deemed_inappropriate) are settled decisions and are left alone. Pure (the
401
- * counter is supplied / returned).
402
- */
403
- export declare function applyCoarseReblock(state: RemediationState, currentCount: number, gateSummary: string, bound?: number): CoarseReblockDecision;
324
+ export { isAuditToolsMonorepo, toolOwnedFinalGateCommands, runToolOwnedFinalGate, applyCoarseReblock, COARSE_REBLOCK_BOUND, } from "./finalGate.js";
325
+ export type { FinalGateCommandSpec, FinalGateCommandResult, ToolOwnedFinalGateResult, GateRunner, CoarseReblockAction, CoarseReblockDecision, } from "./finalGate.js";
404
326
  /**
405
327
  * The terminal friction-TRIAGE close-out for the remediate half. Thin delegation to
406
328
  * the single-sourced `decideFrictionTriage` (`audit-tools/shared`) — the exact analog
@@ -1 +1 @@
1
- {"version":3,"file":"nextStep.d.ts","sourceRoot":"","sources":["../../../src/remediate/steps/nextStep.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,KAAK,EAGV,gBAAgB,EAGjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAqV,KAAK,sBAAsB,EAA8C,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,KAAK,oBAAoB,EAAE,KAAK,YAAY,EAA8B,KAAK,qBAAqB,EAAE,KAAK,YAAY,EAAqB,KAAK,sBAAsB,EAAE,KAAK,cAAc,EAAiJ,sBAAsB,EAAiF,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAOz7B,OAAO,EASL,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AAMvB,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE3E,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EAEzB,MAAM,wBAAwB,CAAC;AAQhC,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,mBAAmB,CAAC;AAuC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAY3D,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,gBAAgB,CAAC,EAA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tD,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,gBAAgB,GAAG,SAAS,GACvC,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC,CA6B/C"}
@@ -2,7 +2,7 @@ import { existsSync } from "node:fs";
2
2
  import { mkdir, readFile, rename } from "node:fs/promises";
3
3
  import { dirname, join, resolve } from "node:path";
4
4
  import { StateStore } from "../state/store.js";
5
- import { readOptionalJsonFile, writeJsonFile, writeTextFile, buildAuditDeliverablePair, formatValidationIssues, isRecord, withFsRetry, RunLogger, DISPATCH_PROMPT_HANDOFF_NOTE, renderQuotaCoverageNudge, coerceJsonObjectArg, createRollingDispatcher, setQuotaStateDir, interpretFreeFormIntent, advance, decideFrictionTriage, buildFrictionTriageBlock, planHybridDispatch, readSettledPools, addSettledPool, sourceByPoolId, classifyProvider, selectDispatchDriver, renderDispatchDriverInstruction, HostSessionQuotaSource, buildProviderModelKey, captureStepBoundaryFriction } from "audit-tools/shared";
5
+ import { readOptionalJsonFile, writeJsonFile, writeTextFile, buildAuditDeliverablePair, formatValidationIssues, isRecord, withFsRetry, RunLogger, DISPATCH_PROMPT_HANDOFF_NOTE, renderQuotaCoverageNudge, coerceJsonObjectArg, createRollingDispatcher, setQuotaStateDir, interpretFreeFormIntent, advance, decideFrictionTriage, buildFrictionTriageBlock, planHybridDispatch, readSettledPools, addSettledPool, sourceByPoolId, classifyProvider, selectDispatchDriver, renderDispatchDriverInstruction, HostSessionQuotaSource, buildProviderModelKey, captureStepBoundaryFriction, LENSES, SEVERITIES } from "audit-tools/shared";
6
6
  import { applyPlanPipeline, buildCoverageLedger } from "../phases/plan.js";
7
7
  import { groundExtractedFindings } from "../phases/grounding.js";
8
8
  import { runTriagePhase } from "../phases/triage.js";
@@ -14,12 +14,11 @@ import { ownershipSubWaves } from "../dispatch/ownershipScheduler.js";
14
14
  import { prepareHostRollingDispatch, nodeClaimRegistry, nodeSettledPoolsPath } from "./rollingSession.js";
15
15
  import { writeCurrentStep } from "./stepWriter.js";
16
16
  import { dependencyVerifiedComplete } from "./stepUtils.js";
17
- import { isTerminalStatus, isVerifiedCompleteStatus, isSkipStatus, } from "../state/itemStatus.js";
17
+ import { isTerminalStatus, isVerifiedCompleteStatus, } from "../state/itemStatus.js";
18
18
  import { deduplicateCrossLensFindings, fixupBlocksAfterDedup, } from "../dedup/crossLensDedup.js";
19
19
  import { checkAffectedFileIntegrity } from "../utils/fileIntegrity.js";
20
20
  import { resolveIntakeStep } from "./intakeResolver.js";
21
- import { runCommand } from "../utils/commands.js";
22
- import { isAuditToolsMonorepo, toolOwnedFinalGateCommands, } from "./gateCommands.js";
21
+ import { runToolOwnedFinalGate, applyCoarseReblock, readFinalGateSidecar, writeFinalGateSidecar, } from "./finalGate.js";
23
22
  import { buildNextContractPipelineStep, shouldEnterContractPipeline, writePathASeedFromFindings, } from "./contractPipeline.js";
24
23
  import { evaluateFastPath, buildLeanExtractedPlan, distinctAffectedFiles, interpretLeanLightReviewVerdict, LEAN_LIGHT_REVIEW_SCHEMA_VERSION, } from "./leanFastPath.js";
25
24
  import { contractArtifactExists, contractPipelineDir, } from "../contractPipeline/artifactStore.js";
@@ -29,6 +28,26 @@ import { runFindingFilterPass } from "../findingFilter.js";
29
28
  import { intakePaths, isIntakeReady, readIntakeArtifacts, resolveManifestSources, } from "../intake.js";
30
29
  import { ensureIntakeRiskSignal, readIntakeRiskSignal, writeIntakeRiskSignal, escalateRiskSignal, } from "../riskSignal.js";
31
30
  import { ambiguityReviewPrompt, clarificationPrompt, collectIntakeClarificationsPrompt, collectStartingPointPrompt, loaderCommand, reviewApprovalPrompt, synthesizeIntakePrompt, triagePrompt, } from "./prompts.js";
31
+ // Single-sourced prose renders of the canonical lens / severity vocabularies
32
+ // (`audit-tools/shared` `LENSES` / `SEVERITIES`) for the intent-checkpoint
33
+ // prompt copy. Previously these 11-lens / 5-severity lists were hand-copied as
34
+ // backtick-quoted literals in three places in this file and would silently drift
35
+ // from the canonical enum (the very drift `types/lens.ts` exists to prevent).
36
+ const VALID_LENSES_PROSE = LENSES.map((lens) => `\`${lens}\``).join(", ");
37
+ const VALID_SEVERITIES_PROSE = SEVERITIES.map((sev) => `\`${sev}\``).join(", ");
38
+ /**
39
+ * The host's resolved provider identity for quota-key / driver-classification
40
+ * purposes: the configured `sessionConfig.provider`, defaulting to the
41
+ * conversation host (`claude-code`) when unset or `auto`. Single-sourced so the
42
+ * `?? "claude-code"` default and the `auto`-exclusion live in ONE place rather
43
+ * than being re-spelled (with an ad-hoc cast) at each dispatch call site.
44
+ */
45
+ function resolveHostProviderName(sessionConfig) {
46
+ const provider = sessionConfig?.provider;
47
+ if (provider === undefined || provider === "auto")
48
+ return "claude-code";
49
+ return provider;
50
+ }
32
51
  export function resolveHostDispatchCapability(options) {
33
52
  if (options.hostCanDispatchSubagents !== undefined) {
34
53
  return options.hostCanDispatchSubagents;
@@ -599,8 +618,7 @@ export async function driveRollingImplementDispatch(options) {
599
618
  // onEscalation routes to the single step-boundary friction chokepoint with this
600
619
  // driver's artifactsDir/runId, so a bounded account-wall escalation surfaces as
601
620
  // reviewable friction instead of only a stderr line.
602
- const providerName = options.sessionConfig?.provider ??
603
- "claude-code";
621
+ const providerName = resolveHostProviderName(options.sessionConfig);
604
622
  const hostSessionModelKey = buildProviderModelKey(providerName, options.sessionConfig
605
623
  ?.block_quota?.host_model ??
606
624
  options.waveOptions?.hostModelId ??
@@ -821,161 +839,13 @@ export async function executeInProcessPartition(params) {
821
839
  // Tool-owned final completion gate (INV-RS-10) + coarse re-block (INV-RS-09)
822
840
  // ---------------------------------------------------------------------------
823
841
  //
824
- // INV-RS-10: the final completion gate is a TOOL-OWNED, NON-VACUOUS suite that
825
- // is INDEPENDENT of any `plan.test_command`. A run can only land green when this
826
- // suite passes; a vacuous/unset `plan.test_command` can never substitute for it.
827
- // The suite is executed through the env-scrubbing `runTracked` path
828
- // (`runCommand`), which strips CLAUDECODE / CLAUDE_CODE_* so the gate runs in a
829
- // clean environment regardless of the host session.
830
- //
831
- // Hard floor (always run, in order — single package, single-flight build — CE-001):
832
- // 1. npm run build (one tsc build for the whole package)
833
- // 2. npm run check (typecheck, no emit)
834
- // 3. BUILD-FREE unit suites at the repo root, each invoked directly so dist is
835
- // never rebuilt or raced:
836
- // - shared+audit: node --import tsx/esm --test tests/shared/*.test.mjs tests/audit/*.test.mjs
837
- // - remediate-code: npx vitest run
838
- //
839
- // CE-002: the hard floor is scoped to build + typecheck + unit. The
840
- // runtime/packaged-bin smoke surface (the `verify:release` smokes) is recorded
841
- // as a DECLARED RESIDUAL the floor does not gate, rather than run inline — the
842
- // packaged-bin smokes are the known Windows-flaky / EPERM surface and an in-loop
843
- // gate must converge deterministically, so they are surfaced for a separate
844
- // pass instead of being able to strand the run.
845
- // `FinalGateCommandSpec`, `isAuditToolsMonorepo`, and `toolOwnedFinalGateCommands`
846
- // are single-sourced in the leaf module `gateCommands.ts` (so `dispatch.ts` can
847
- // derive the same pinned merged-base check without an import cycle). Imported above
848
- // for local use here and re-exported to preserve this module's public surface +
849
- // test imports.
850
- export { isAuditToolsMonorepo, toolOwnedFinalGateCommands };
851
- /**
852
- * Run the tool-owned final gate (INV-RS-10). Each command runs through
853
- * `runCommand` → shared `runTracked`, which scrubs CLAUDECODE / CLAUDE_CODE_*.
854
- * The first failing command short-circuits the floor (a broken build makes the
855
- * later layers meaningless). A `runner` may be injected for tests. When the
856
- * audit-tools suite does not apply (non-monorepo target), the gate is
857
- * `scoped_out` (does not block) rather than vacuously passing.
858
- */
859
- export async function runToolOwnedFinalGate(root, opts = {}) {
860
- const runtime_residual = {
861
- surface: "runtime/packaged-bin smokes (verify:release)",
862
- commands: [
863
- "npm run smoke:packaged-audit-code",
864
- "npm run smoke:packaged-remediate-code",
865
- ],
866
- };
867
- const commands = toolOwnedFinalGateCommands(root);
868
- if (commands.length === 0) {
869
- // Audit-tools-specific suite does not apply here — declared scope, not a
870
- // vacuous pass (it never substitutes for a real gate on the audit-tools repo).
871
- return { passed: true, results: [], scoped_out: true, runtime_residual };
872
- }
873
- const runner = opts.runner ??
874
- ((argv, cwd, packageDir) => {
875
- const [command, ...args] = argv;
876
- // Package-scoped unit suites run with cwd at the package (no `npm -w`); the
877
- // monorepo-root build/check commands run at the repo root.
878
- const effectiveCwd = packageDir ? join(root, packageDir) : cwd;
879
- // runCommand → runTracked strips CLAUDECODE / CLAUDE_CODE_* (INV-RS-10).
880
- const result = runCommand(command, args, {
881
- cwd: effectiveCwd,
882
- stdio: ["ignore", "pipe", "pipe"],
883
- });
884
- return { status: result.status };
885
- });
886
- const results = [];
887
- let passed = true;
888
- for (const spec of commands) {
889
- const { status } = runner(spec.argv, root, spec.package_dir);
890
- const cmdPassed = status === 0;
891
- results.push({
892
- argv: spec.argv,
893
- layer: spec.layer,
894
- ...(spec.package_dir ? { package_dir: spec.package_dir } : {}),
895
- exit_code: status,
896
- passed: cmdPassed,
897
- });
898
- if (!cmdPassed) {
899
- passed = false;
900
- break; // short-circuit: later layers are meaningless on a broken floor
901
- }
902
- }
903
- return { passed, results, scoped_out: false, runtime_residual };
904
- }
905
- /**
906
- * The bound on coarse re-block iterations before the run converges to a terminal
907
- * `blocked` close (CE-003). Two re-block attempts give a flaky-but-recoverable
908
- * suite a chance to settle; the third unattributable red terminates
909
- * deterministically rather than livelocking.
910
- */
911
- export const COARSE_REBLOCK_BOUND = 2;
912
- const FINAL_GATE_STATE_FILENAME = "final-gate.json";
913
- async function readFinalGateSidecar(artifactsDir) {
914
- const sidecar = await readOptionalJsonFile(join(artifactsDir, FINAL_GATE_STATE_FILENAME));
915
- const n = sidecar?.coarse_reblock_count;
916
- return {
917
- count: typeof n === "number" && Number.isFinite(n) && n >= 0 ? n : 0,
918
- terminated: sidecar?.terminated === true,
919
- };
920
- }
921
- async function writeFinalGateSidecar(artifactsDir, count, terminated) {
922
- await writeJsonFile(join(artifactsDir, FINAL_GATE_STATE_FILENAME), {
923
- schema_version: "remediate-code-final-gate/v1alpha1",
924
- coarse_reblock_count: count,
925
- terminated,
926
- });
927
- }
928
- /**
929
- * Coarse re-block-ALL-non-terminal on an unattributable final-gate red
930
- * (INV-RS-09) with a bounded, monotonic auto-terminate (CE-003).
931
- *
932
- * The tool-owned gate is whole-repo, so a red is inherently unattributable to a
933
- * single node. Below the bound, EVERY non-skip item (including `resolved` ones —
934
- * a resolved item's own change may have caused the red) is re-opened to `pending`
935
- * and the run re-attempts the whole repo through the rolling scheduler
936
- * (`reattempt_all` → `implementing`). At or above the bound, the run STOPS
937
- * re-attempting and converges DETERMINISTICALLY: every non-skip item becomes
938
- * terminal `blocked` and the run advances to `closing`.
939
- *
940
- * CE-003 no-human-host guarantee: the loop is owned entirely by the gate + the
941
- * rolling scheduler — it NEVER routes through the human triage prompt
942
- * (`waiting_for_triage`) and is bounded by `bound`, so a permanently-red sibling
943
- * converges to a terminal `blocked` close deterministically: never livelocking,
944
- * never stranding on a human prompt, and never force-closed to green (a RED gate
945
- * always leaves `blocked` items, so close.ts's `!anyBlocked` guard keeps the run
946
- * out of the fully-green path). User SKIP dispositions (ignored /
947
- * deemed_inappropriate) are settled decisions and are left alone. Pure (the
948
- * counter is supplied / returned).
949
- */
950
- export function applyCoarseReblock(state, currentCount, gateSummary, bound = COARSE_REBLOCK_BOUND) {
951
- const now = new Date().toISOString();
952
- if (currentCount >= bound) {
953
- // Bounded auto-terminate: converge DETERMINISTICALLY to a terminal `blocked`
954
- // close for a no-human host — never livelock, never a triage prompt, never green.
955
- for (const it of Object.values(state.items ?? {})) {
956
- if (isSkipStatus(it.status))
957
- continue; // settled user decision — never overturn
958
- it.status = "blocked";
959
- it.started_at ??= now;
960
- it.completed_at = now;
961
- it.failure_reason =
962
- `Tool-owned final gate failed and the coarse re-block backstop reached its ` +
963
- `bound (${bound}); converging to a terminal blocked close (no-human host). ${gateSummary}`;
964
- }
965
- return { state, action: "terminal_blocked", next_count: currentCount };
966
- }
967
- // Below the bound: re-open every non-skip item to `pending` and re-attempt the
968
- // whole repo via the rolling scheduler (NOT the human triage prompt).
969
- for (const it of Object.values(state.items ?? {})) {
970
- if (isSkipStatus(it.status))
971
- continue;
972
- it.status = "pending";
973
- it.failure_context =
974
- `Re-attempted by the coarse final-gate backstop (unattributable whole-repo red). ${gateSummary}`;
975
- delete it.completed_at;
976
- }
977
- return { state, action: "reattempt_all", next_count: currentCount + 1 };
978
- }
842
+ // The gate runner, its bounded coarse-reblock backstop, and the sidecar counter
843
+ // I/O were extracted behaviour-preservingly into the sibling leaf module
844
+ // `finalGate.ts` (CP-NODE-1). They are imported below for local use in the
845
+ // completion handler and re-exported to preserve this module's public surface +
846
+ // existing test imports. See `finalGate.ts` for the INV-RS-10 / CE-001 / CE-002
847
+ // documentation.
848
+ export { isAuditToolsMonorepo, toolOwnedFinalGateCommands, runToolOwnedFinalGate, applyCoarseReblock, COARSE_REBLOCK_BOUND, } from "./finalGate.js";
979
849
  function resolvedOrTerminalItems(state) {
980
850
  return Object.values(state.items ?? {}).filter((item) => isTerminalStatus(item.status));
981
851
  }
@@ -1378,8 +1248,7 @@ async function buildImplementDispatchStep(ctx) {
1378
1248
  // S-BROKER-WIRING: pick the dispatch DRIVER (delegate the rolling loop to a
1379
1249
  // dedicated dispatcher subagent vs. drive it from the top host) off the
1380
1250
  // single classification + the live frontier/slot count — not host prose.
1381
- const hostProvider = sessionConfigImpl?.provider ??
1382
- "claude-code";
1251
+ const hostProvider = resolveHostProviderName(sessionConfigImpl);
1383
1252
  const driverSelection = selectDispatchDriver({
1384
1253
  classification: classifyProvider(hostProvider),
1385
1254
  eligibleItemCount: rolling.session.frontier.length,
@@ -2216,7 +2085,7 @@ Choose one explicitly and report the choice to the user:
2216
2085
  1. **Resume the existing run** — re-run WITHOUT \`--input\`: \`${loaderCommand("next-step")}\`
2217
2086
  2. **Start fresh from the new input** — first move aside or delete the existing
2218
2087
  \`${artifactsDir}\` directory (and the stale \`remediation-report.md\` /
2219
- \`remediation-report.json\` in \`.audit-tools/\`, which would otherwise be overwritten on completion),
2088
+ \`remediation-outcomes.json\` in \`.audit-tools/\`, which would otherwise be overwritten on completion),
2220
2089
  then re-run \`${loaderCommand("next-step --input <path>")}\`.
2221
2090
 
2222
2091
  Stop after presenting this choice. Do not advance the run until the user decides.
@@ -3021,10 +2890,8 @@ To confirm, write the final checkpoint to:
3021
2890
  \`\`\`
3022
2891
 
3023
2892
  Adjust \`filters\`, \`excluded_scope\`, \`must_not_touch\`, or \`free_form_intent\` to
3024
- narrow scope. Valid severities: \`critical\`, \`high\`, \`medium\`, \`low\`, \`info\`.
3025
- Valid lenses: \`correctness\`, \`architecture\`, \`maintainability\`, \`security\`,
3026
- \`reliability\`, \`performance\`, \`data_integrity\`, \`tests\`, \`operability\`,
3027
- \`config_deployment\`, \`observability\`.
2893
+ narrow scope. Valid severities: ${VALID_SEVERITIES_PROSE}.
2894
+ Valid lenses: ${VALID_LENSES_PROSE}.
3028
2895
 
3029
2896
  Once written with \`"confirmed_by": "host"\`, run:
3030
2897
 
@@ -3061,7 +2928,7 @@ Only \`scope_summary\` and \`intent_summary\` are required; add the optional fie
3061
2928
  }
3062
2929
  \`\`\`
3063
2930
 
3064
- - \`filters\` drop findings that don't match BEFORE planning, so only the work you want is remediated. Valid severities: \`critical\`, \`high\`, \`medium\`, \`low\`, \`info\`. Valid lenses: \`correctness\`, \`architecture\`, \`maintainability\`, \`security\`, \`reliability\`, \`performance\`, \`data_integrity\`, \`tests\`, \`operability\`, \`config_deployment\`, \`observability\`. Draw \`packages\`/\`themes\` from the findings in the audit report.
2931
+ - \`filters\` drop findings that don't match BEFORE planning, so only the work you want is remediated. Valid severities: ${VALID_SEVERITIES_PROSE}. Valid lenses: ${VALID_LENSES_PROSE}. Draw \`packages\`/\`themes\` from the findings in the audit report.
3065
2932
  - \`excluded_scope\` drops findings whose files match a path or directory prefix; \`must_not_touch\` globs are never written.
3066
2933
  - Skipped findings are listed in the final remediation report under "Skipped by Intent Checkpoint".
3067
2934
  - Leave the optional fields out to remediate everything in the report.