audit-tools 0.32.20 → 0.32.22

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 (195) hide show
  1. package/dist/audit/clarification/blastRadius.d.ts +23 -0
  2. package/dist/audit/clarification/blastRadius.d.ts.map +1 -0
  3. package/dist/audit/clarification/blastRadius.js +65 -0
  4. package/dist/audit/clarification/blastRadius.js.map +1 -0
  5. package/dist/audit/clarification/dials.d.ts +28 -0
  6. package/dist/audit/clarification/dials.d.ts.map +1 -0
  7. package/dist/audit/clarification/dials.js +37 -0
  8. package/dist/audit/clarification/dials.js.map +1 -0
  9. package/dist/audit/clarification/partition.d.ts +25 -0
  10. package/dist/audit/clarification/partition.d.ts.map +1 -0
  11. package/dist/audit/clarification/partition.js +77 -0
  12. package/dist/audit/clarification/partition.js.map +1 -0
  13. package/dist/audit/clarification/riskGate.d.ts +24 -0
  14. package/dist/audit/clarification/riskGate.d.ts.map +1 -0
  15. package/dist/audit/clarification/riskGate.js +38 -0
  16. package/dist/audit/clarification/riskGate.js.map +1 -0
  17. package/dist/audit/clarification/voiQueue.d.ts +17 -0
  18. package/dist/audit/clarification/voiQueue.d.ts.map +1 -0
  19. package/dist/audit/clarification/voiQueue.js +37 -0
  20. package/dist/audit/clarification/voiQueue.js.map +1 -0
  21. package/dist/audit/cli/auditStep.d.ts +2 -0
  22. package/dist/audit/cli/auditStep.d.ts.map +1 -1
  23. package/dist/audit/cli/auditStep.js +9 -1
  24. package/dist/audit/cli/auditStep.js.map +1 -1
  25. package/dist/audit/cli/charterClarificationPrompt.d.ts +19 -0
  26. package/dist/audit/cli/charterClarificationPrompt.d.ts.map +1 -0
  27. package/dist/audit/cli/charterClarificationPrompt.js +60 -0
  28. package/dist/audit/cli/charterClarificationPrompt.js.map +1 -0
  29. package/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
  30. package/dist/audit/cli/nextStepCommand.js +74 -0
  31. package/dist/audit/cli/nextStepCommand.js.map +1 -1
  32. package/dist/audit/cli/nextStepHelpers.d.ts +62 -0
  33. package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
  34. package/dist/audit/cli/nextStepHelpers.js +129 -0
  35. package/dist/audit/cli/nextStepHelpers.js.map +1 -1
  36. package/dist/audit/cli/steps.d.ts +4 -4
  37. package/dist/audit/cli/steps.d.ts.map +1 -1
  38. package/dist/audit/cli/steps.js +2 -0
  39. package/dist/audit/cli/steps.js.map +1 -1
  40. package/dist/audit/io/artifacts.d.ts +6 -0
  41. package/dist/audit/io/artifacts.d.ts.map +1 -1
  42. package/dist/audit/io/artifacts.js +2 -0
  43. package/dist/audit/io/artifacts.js.map +1 -1
  44. package/dist/audit/orchestrator/advance.d.ts +23 -0
  45. package/dist/audit/orchestrator/advance.d.ts.map +1 -1
  46. package/dist/audit/orchestrator/advance.js +122 -4
  47. package/dist/audit/orchestrator/advance.js.map +1 -1
  48. package/dist/audit/orchestrator/advanceTypes.d.ts +22 -1
  49. package/dist/audit/orchestrator/advanceTypes.d.ts.map +1 -1
  50. package/dist/audit/orchestrator/charterClarificationExecutor.d.ts +28 -0
  51. package/dist/audit/orchestrator/charterClarificationExecutor.d.ts.map +1 -0
  52. package/dist/audit/orchestrator/charterClarificationExecutor.js +130 -0
  53. package/dist/audit/orchestrator/charterClarificationExecutor.js.map +1 -0
  54. package/dist/audit/orchestrator/dependencyMap.d.ts +2 -0
  55. package/dist/audit/orchestrator/dependencyMap.d.ts.map +1 -1
  56. package/dist/audit/orchestrator/dependencyMap.js +24 -0
  57. package/dist/audit/orchestrator/dependencyMap.js.map +1 -1
  58. package/dist/audit/orchestrator/designReviewPrompt.d.ts +17 -0
  59. package/dist/audit/orchestrator/designReviewPrompt.d.ts.map +1 -1
  60. package/dist/audit/orchestrator/designReviewPrompt.js +50 -0
  61. package/dist/audit/orchestrator/designReviewPrompt.js.map +1 -1
  62. package/dist/audit/orchestrator/executorRunners.d.ts.map +1 -1
  63. package/dist/audit/orchestrator/executorRunners.js +4 -0
  64. package/dist/audit/orchestrator/executorRunners.js.map +1 -1
  65. package/dist/audit/orchestrator/executors.d.ts.map +1 -1
  66. package/dist/audit/orchestrator/executors.js +20 -0
  67. package/dist/audit/orchestrator/executors.js.map +1 -1
  68. package/dist/audit/orchestrator/nextStep.d.ts +11 -1
  69. package/dist/audit/orchestrator/nextStep.d.ts.map +1 -1
  70. package/dist/audit/orchestrator/nextStep.js +6 -2
  71. package/dist/audit/orchestrator/nextStep.js.map +1 -1
  72. package/dist/audit/orchestrator/staleness.d.ts +27 -1
  73. package/dist/audit/orchestrator/staleness.d.ts.map +1 -1
  74. package/dist/audit/orchestrator/staleness.js +33 -16
  75. package/dist/audit/orchestrator/staleness.js.map +1 -1
  76. package/dist/audit/orchestrator/state.d.ts +12 -1
  77. package/dist/audit/orchestrator/state.d.ts.map +1 -1
  78. package/dist/audit/orchestrator/state.js +41 -2
  79. package/dist/audit/orchestrator/state.js.map +1 -1
  80. package/dist/audit/orchestrator/synthesisExecutors.d.ts.map +1 -1
  81. package/dist/audit/orchestrator/synthesisExecutors.js +1 -0
  82. package/dist/audit/orchestrator/synthesisExecutors.js.map +1 -1
  83. package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts +25 -0
  84. package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts.map +1 -0
  85. package/dist/audit/orchestrator/systemicChallengeExecutor.js +107 -0
  86. package/dist/audit/orchestrator/systemicChallengeExecutor.js.map +1 -0
  87. package/dist/audit/reporting/mergeFindings.d.ts +2 -1
  88. package/dist/audit/reporting/mergeFindings.d.ts.map +1 -1
  89. package/dist/audit/reporting/mergeFindings.js +6 -1
  90. package/dist/audit/reporting/mergeFindings.js.map +1 -1
  91. package/dist/audit/reporting/synthesis.d.ts +2 -0
  92. package/dist/audit/reporting/synthesis.d.ts.map +1 -1
  93. package/dist/audit/reporting/synthesis.js +1 -1
  94. package/dist/audit/reporting/synthesis.js.map +1 -1
  95. package/dist/audit/systemic/aggregateMetricsDigest.d.ts +11 -0
  96. package/dist/audit/systemic/aggregateMetricsDigest.d.ts.map +1 -0
  97. package/dist/audit/systemic/aggregateMetricsDigest.js +84 -0
  98. package/dist/audit/systemic/aggregateMetricsDigest.js.map +1 -0
  99. package/dist/audit/systemic/metricsDigestTypes.d.ts +35 -0
  100. package/dist/audit/systemic/metricsDigestTypes.d.ts.map +1 -0
  101. package/dist/audit/systemic/metricsDigestTypes.js +10 -0
  102. package/dist/audit/systemic/metricsDigestTypes.js.map +1 -0
  103. package/dist/audit/systemic/secondOrderAdversaryPrompt.d.ts +16 -0
  104. package/dist/audit/systemic/secondOrderAdversaryPrompt.d.ts.map +1 -0
  105. package/dist/audit/systemic/secondOrderAdversaryPrompt.js +85 -0
  106. package/dist/audit/systemic/secondOrderAdversaryPrompt.js.map +1 -0
  107. package/dist/audit/systemic/systemicChallengeLoop.d.ts +48 -0
  108. package/dist/audit/systemic/systemicChallengeLoop.d.ts.map +1 -0
  109. package/dist/audit/systemic/systemicChallengeLoop.js +107 -0
  110. package/dist/audit/systemic/systemicChallengeLoop.js.map +1 -0
  111. package/dist/audit/types/charterClarification.d.ts +52 -0
  112. package/dist/audit/types/charterClarification.d.ts.map +1 -0
  113. package/dist/audit/types/charterClarification.js +2 -0
  114. package/dist/audit/types/charterClarification.js.map +1 -0
  115. package/dist/audit/types/systemicChallenge.d.ts +69 -0
  116. package/dist/audit/types/systemicChallenge.d.ts.map +1 -0
  117. package/dist/audit/types/systemicChallenge.js +2 -0
  118. package/dist/audit/types/systemicChallenge.js.map +1 -0
  119. package/dist/remediate/steps/dispatch/acceptNode.d.ts +178 -0
  120. package/dist/remediate/steps/dispatch/acceptNode.d.ts.map +1 -0
  121. package/dist/remediate/steps/dispatch/acceptNode.js +351 -0
  122. package/dist/remediate/steps/dispatch/acceptNode.js.map +1 -0
  123. package/dist/remediate/steps/dispatch/common.d.ts +123 -0
  124. package/dist/remediate/steps/dispatch/common.d.ts.map +1 -0
  125. package/dist/remediate/steps/dispatch/common.js +236 -0
  126. package/dist/remediate/steps/dispatch/common.js.map +1 -0
  127. package/dist/remediate/steps/dispatch/dagNodeFields.d.ts +37 -0
  128. package/dist/remediate/steps/dispatch/dagNodeFields.d.ts.map +1 -0
  129. package/dist/remediate/steps/dispatch/dagNodeFields.js +19 -0
  130. package/dist/remediate/steps/dispatch/dagNodeFields.js.map +1 -0
  131. package/dist/remediate/steps/dispatch/implementPrompt.d.ts +70 -0
  132. package/dist/remediate/steps/dispatch/implementPrompt.d.ts.map +1 -0
  133. package/dist/remediate/steps/dispatch/implementPrompt.js +577 -0
  134. package/dist/remediate/steps/dispatch/implementPrompt.js.map +1 -0
  135. package/dist/remediate/steps/dispatch/marshal.d.ts +32 -0
  136. package/dist/remediate/steps/dispatch/marshal.d.ts.map +1 -0
  137. package/dist/remediate/steps/dispatch/marshal.js +935 -0
  138. package/dist/remediate/steps/dispatch/marshal.js.map +1 -0
  139. package/dist/remediate/steps/dispatch/verifyCommands.d.ts +97 -0
  140. package/dist/remediate/steps/dispatch/verifyCommands.d.ts.map +1 -0
  141. package/dist/remediate/steps/dispatch/verifyCommands.js +204 -0
  142. package/dist/remediate/steps/dispatch/verifyCommands.js.map +1 -0
  143. package/dist/remediate/steps/dispatch/waveScheduling.d.ts +90 -0
  144. package/dist/remediate/steps/dispatch/waveScheduling.d.ts.map +1 -0
  145. package/dist/remediate/steps/dispatch/waveScheduling.js +352 -0
  146. package/dist/remediate/steps/dispatch/waveScheduling.js.map +1 -0
  147. package/dist/remediate/steps/dispatch/worktreeLifecycle.d.ts +189 -0
  148. package/dist/remediate/steps/dispatch/worktreeLifecycle.d.ts.map +1 -0
  149. package/dist/remediate/steps/dispatch/worktreeLifecycle.js +643 -0
  150. package/dist/remediate/steps/dispatch/worktreeLifecycle.js.map +1 -0
  151. package/dist/remediate/steps/dispatch/writeScope.d.ts +151 -0
  152. package/dist/remediate/steps/dispatch/writeScope.d.ts.map +1 -0
  153. package/dist/remediate/steps/dispatch/writeScope.js +376 -0
  154. package/dist/remediate/steps/dispatch/writeScope.js.map +1 -0
  155. package/dist/remediate/steps/dispatch.d.ts +16 -871
  156. package/dist/remediate/steps/dispatch.d.ts.map +1 -1
  157. package/dist/remediate/steps/dispatch.js +18 -3623
  158. package/dist/remediate/steps/dispatch.js.map +1 -1
  159. package/dist/shared/decompose/charterClarification.d.ts +80 -0
  160. package/dist/shared/decompose/charterClarification.d.ts.map +1 -0
  161. package/dist/shared/decompose/charterClarification.js +105 -0
  162. package/dist/shared/decompose/charterClarification.js.map +1 -0
  163. package/dist/shared/decompose/systemicChallenge.d.ts +326 -0
  164. package/dist/shared/decompose/systemicChallenge.d.ts.map +1 -0
  165. package/dist/shared/decompose/systemicChallenge.js +30 -0
  166. package/dist/shared/decompose/systemicChallenge.js.map +1 -0
  167. package/dist/shared/index.d.ts +10 -5
  168. package/dist/shared/index.d.ts.map +1 -1
  169. package/dist/shared/index.js +6 -4
  170. package/dist/shared/index.js.map +1 -1
  171. package/dist/shared/opencodePermissions.d.ts +73 -0
  172. package/dist/shared/opencodePermissions.d.ts.map +1 -1
  173. package/dist/shared/opencodePermissions.js +172 -0
  174. package/dist/shared/opencodePermissions.js.map +1 -1
  175. package/dist/shared/tooling/exec.d.ts +10 -1
  176. package/dist/shared/tooling/exec.d.ts.map +1 -1
  177. package/dist/shared/tooling/exec.js +13 -1
  178. package/dist/shared/tooling/exec.js.map +1 -1
  179. package/dist/shared/types/charter.d.ts +89 -0
  180. package/dist/shared/types/charter.d.ts.map +1 -1
  181. package/dist/shared/types/charter.js +68 -0
  182. package/dist/shared/types/charter.js.map +1 -1
  183. package/dist/shared/types/intentCheckpoint.d.ts +15 -0
  184. package/dist/shared/types/intentCheckpoint.d.ts.map +1 -1
  185. package/dist/shared/types/intentCheckpoint.js +11 -0
  186. package/dist/shared/types/intentCheckpoint.js.map +1 -1
  187. package/dist/shared/validation/charterGate.d.ts +20 -1
  188. package/dist/shared/validation/charterGate.d.ts.map +1 -1
  189. package/dist/shared/validation/charterGate.js +23 -0
  190. package/dist/shared/validation/charterGate.js.map +1 -1
  191. package/opencode.json +36 -20
  192. package/package.json +1 -1
  193. package/scripts/postinstall.mjs +2 -1
  194. package/wrapper/audit-code-wrapper-opencode.mjs +38 -12
  195. package/wrapper/remediate-code-wrapper-opencode.mjs +38 -12
@@ -0,0 +1,69 @@
1
+ import type { Finding } from "../types.js";
2
+ import type { Ceiling } from "audit-tools/shared";
3
+ import type { AggregateMetricsDigest } from "../systemic/metricsDigestTypes.js";
4
+ /**
5
+ * The `systemic_challenge.json` artifact — Phase E of the conceptual design-review:
6
+ * the SYSTEMIC IMPROVEMENT-SEEKING CHALLENGE LOOP. A second-order adversary (a
7
+ * SEPARATE agent — [[delegate-adversarial-phases-to-separate-agent]]) re-interrogates
8
+ * the whole system with human-grade pressure and folds newly-surfaced improvements
9
+ * back in, LOOP-UNTIL-DRY: the pass is done only when a challenge round yields
10
+ * NOTHING NEW, not when it first has an answer (design of record
11
+ * spec/conceptual-design-review-design.md §"Convergence (loop-until-dry)"; backlog
12
+ * "Systemic reviewers must be pushed adversarially for improvement").
13
+ *
14
+ * The mandate is OPTIMIZATION / BETTER-WAY, not only defect-finding: the pass
15
+ * actively seeks superior alternatives to things that currently WORK — the class no
16
+ * correctness lens flags because nothing is broken (redundant, serial-that-could-be-
17
+ * parallel, duplicated, over-built, an unquestioned assumption, a categorically
18
+ * better approach).
19
+ *
20
+ * It is an OUTPUT artifact seeded from the intent checkpoint (ceiling) and the whole
21
+ * upstream picture (repo_manifest / structure_decomposition / charter register).
22
+ * `status:"omitted"` when the ceiling did not request the systemic layer (shallow —
23
+ * the default), so the obligation is satisfied without a host turn.
24
+ *
25
+ * Each host-delegation round appends to `rounds`; a round that returns zero new
26
+ * findings sets `converged:true` and terminates the loop. `findings` are every
27
+ * distinct improvement surfaced across rounds — carrying their TRUE lens (a
28
+ * test-parallelization finding is `tests`/`performance`, an ops finding is
29
+ * `operability`), NEVER a hardcoded `architecture` tag.
30
+ */
31
+ export interface SystemicChallengeRound {
32
+ /** 1-based round ordinal (the Nth loop-until-dry challenge). */
33
+ round: number;
34
+ /** Distinct finding ids this round surfaced that no prior round had. */
35
+ new_finding_ids: string[];
36
+ /** Whether this round yielded nothing new (the loop-until-dry terminator). */
37
+ dry: boolean;
38
+ }
39
+ export interface SystemicChallengeRegister {
40
+ generated_at: string;
41
+ /** The decomposition target — `"systemic_challenge"` at this layer. */
42
+ target: "systemic_challenge";
43
+ /**
44
+ * The ceiling authorized at `intent_checkpoint` — echoed so the register is
45
+ * self-describing about the depth that produced it.
46
+ */
47
+ ceiling: Ceiling;
48
+ /**
49
+ * `"omitted"` when the ceiling did not request the systemic layer (shallow — the
50
+ * default) — the register is written empty so the obligation is satisfied without
51
+ * a host turn (mirrors the charter-extraction / clarification omit).
52
+ */
53
+ status?: "omitted";
54
+ /**
55
+ * The language-neutral aggregate-metrics digest fed to the adversary as NECESSARY
56
+ * supporting evidence — explicitly NOT sufficient alone (the adversary reasons
57
+ * from the whole picture, not the counts). Absent on an omitted register.
58
+ */
59
+ metrics?: AggregateMetricsDigest;
60
+ /** The loop-until-dry challenge rounds, in order; the last one is `dry`. */
61
+ rounds: SystemicChallengeRound[];
62
+ /** True once a challenge round surfaced nothing new (the loop terminated). */
63
+ converged: boolean;
64
+ /** Every distinct improvement finding surfaced, carrying its TRUE lens. */
65
+ findings: Finding[];
66
+ /** Gate/assembly notes (e.g. a round dropped an ungrounded finding) — surfaced. */
67
+ validation_issues: string[];
68
+ }
69
+ //# sourceMappingURL=systemicChallenge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"systemicChallenge.d.ts","sourceRoot":"","sources":["../../../src/audit/types/systemicChallenge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,sBAAsB;IACrC,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,8EAA8E;IAC9E,GAAG,EAAE,OAAO,CAAC;CACd;AAED,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,MAAM,EAAE,oBAAoB,CAAC;IAC7B;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,4EAA4E;IAC5E,MAAM,EAAE,sBAAsB,EAAE,CAAC;IACjC,8EAA8E;IAC9E,SAAS,EAAE,OAAO,CAAC;IACnB,2EAA2E;IAC3E,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,mFAAmF;IACnF,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=systemicChallenge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"systemicChallenge.js","sourceRoot":"","sources":["../../../src/audit/types/systemicChallenge.ts"],"names":[],"mappings":""}
@@ -0,0 +1,178 @@
1
+ import type { RemediationBlock } from "../../state/types.js";
2
+ import type { ProviderSlot, RollingDispatchResult } from "audit-tools/shared";
3
+ /** Worker transport outcome (mirrors shared `RollingDispatchResult["outcome"]`). */
4
+ export type NodeWorkerOutcome = "success" | "error" | "rate_limited" | "timeout";
5
+ export interface AcceptNodeWorktreeParams {
6
+ root: string;
7
+ runId: string;
8
+ blockId: string;
9
+ /** The node's isolated worktree directory. */
10
+ worktreeRoot: string;
11
+ /** The node's worktree branch (`worktreeBranchForBlock`). */
12
+ branch: string;
13
+ /** The worker's transport outcome from the node dispatcher. */
14
+ workerOutcome: NodeWorkerOutcome;
15
+ /**
16
+ * Per-node verify commands. OMIT (leave `undefined`) for the real rolling drivers:
17
+ * the gate then DERIVES the verify from the node's actually-touched test files
18
+ * post-commit ({@link deriveVerifyCommandsFromBranch}) — correct paths/runner by
19
+ * construction, never the whole suite. Pass `[]` to skip the gate (lifecycle unit
20
+ * tests on a minimal temp repo), or an explicit list to force specific commands.
21
+ */
22
+ targetedCommands?: string[];
23
+ /**
24
+ * The node's own `targeted_commands` (the auditor/finding-specified verification),
25
+ * run IN ADDITION to the derived commands — filtered to the build-free subset and
26
+ * deduped against the derive. The derive gives correct-paths-by-construction; these
27
+ * add the fix-specific regression checks the derive misses when a fix touches no test
28
+ * (task_7d35176d). Omit / `[]` → derive-only (the prior behaviour). Ignored when
29
+ * `targetedCommands` is an explicit override (the lifecycle unit-test path).
30
+ */
31
+ additionalVerifyCommands?: string[];
32
+ /**
33
+ * Accept-time write-scope inputs (OBL-DS-06). The write-scope gate runs HERE —
34
+ * after the verify, BEFORE the cherry-pick — so an out-of-scope or seam-conflicting
35
+ * edit is PREVENTED from landing in the main tree rather than reported post-hoc once
36
+ * it is already merged. REQUIRED (not optional): both rolling drivers always derive
37
+ * it from the plan, so a production caller can never silently skip the gate — that
38
+ * enforcement is the type, not host discretion (E1). A lifecycle test that does not
39
+ * exercise scope passes `{ allBlockScopes: [] }`: an empty registry owns nothing, so
40
+ * every edit is unowned-and-granted → the gate is a sound no-op, never a skip.
41
+ */
42
+ scope: {
43
+ /** Every block's declared write scope, for amendment ownership adjudication. */
44
+ allBlockScopes: Array<{
45
+ block_id: string;
46
+ write_paths: string[];
47
+ }>;
48
+ };
49
+ /**
50
+ * The block's OWN declared write paths (INV-1). Threaded into `commitWorktree`
51
+ * so worker-created new SOURCE files under scope are force-added past
52
+ * `.gitignore` and a generated-artifact / out-of-scope new file fails loudly.
53
+ * Omit (lifecycle unit tests with no scope) → no new-file inclusion.
54
+ */
55
+ writePaths?: string[];
56
+ /**
57
+ * The cross-package check command (argv) run in the MAIN checkout AFTER the
58
+ * cherry-pick lands (INV-2): a RED check rolls the base back to its captured HEAD
59
+ * OID. When omitted, the command is PINNED — derived from the repo via
60
+ * `mergedBaseCheckArgv` (the `check`-layer of the tool-owned gate set), not a
61
+ * hardcoded string — and skipped (`null`) on a non-monorepo target. Tests inject a
62
+ * deterministic pass/fail argv (a `t.mock.module` seam is unusable under tsx/esm).
63
+ * Pass `null` to skip the merged-base check entirely (legacy lifecycle unit tests
64
+ * on a minimal repo with no check script).
65
+ */
66
+ mergedBaseCheckCommand?: string[] | null;
67
+ }
68
+ export interface AcceptNodeWorktreeResult {
69
+ /** The LIFECYCLE outcome (verify/merge applied), distinct from the worker transport outcome. */
70
+ outcome: NodeWorkerOutcome;
71
+ verifyPassed: boolean;
72
+ merged: boolean;
73
+ /**
74
+ * On a failure outcome, the captured failing command + its output — the verify
75
+ * stdout/stderr (`$ <cmd>\n<output>`), or the git commit / cherry-pick error text.
76
+ * Persisted into the accept-outcome sidecar so triage can see the root cause
77
+ * instead of an `outcome:error` with no captured stderr. Absent on success.
78
+ */
79
+ diagnostic?: string;
80
+ }
81
+ /**
82
+ * The shared post-worker "accept node" lifecycle, extracted so BOTH rolling
83
+ * drivers reuse identical correctness: the in-process provider engine
84
+ * (`driveRollingImplementDispatch`) calls it inline once the worker returns; the
85
+ * host-subagent driver calls it from the `accept-node` callback once a host
86
+ * subagent finishes.
87
+ *
88
+ * Given a completed worker run in an isolated worktree, this: (1) TOOL-commits
89
+ * the worker's edits onto the branch (deterministic, never the worker/host) so
90
+ * the branch diff is the write-scope ground truth; (2) runs the per-node verify
91
+ * IN the worktree BEFORE accepting; (3) merges via cherry-pick only on a passing
92
+ * verify; and (4) drops the worktree on any failure so the main tree is never
93
+ * dirtied by an unverified change. It returns the LIFECYCLE outcome (which the
94
+ * caller records for the deterministic merge); the caller still returns the
95
+ * worker's TRANSPORT outcome to the rolling engine (so a `rate_limited` worker
96
+ * re-queues, while a verify-failure is adjudicated by the merge → triage).
97
+ *
98
+ * SAFETY: the main tree is touched only through `mergeWorktree` (cherry-pick of a
99
+ * verified branch, aborts cleanly on conflict). No state mutation here — the
100
+ * caller persists via `mergeImplementResults`.
101
+ */
102
+ export declare function acceptNodeWorktree(params: AcceptNodeWorktreeParams): Promise<AcceptNodeWorktreeResult>;
103
+ /**
104
+ * Sidecar path for a node's tool-owned accept (verify/merge) outcome. Written by
105
+ * BOTH rolling drivers as each node is accepted, read by `mergeImplementResults`.
106
+ * Block ids here follow the same filename-safe convention as the per-node result
107
+ * files in the same dir.
108
+ */
109
+ export declare function nodeAcceptOutcomePath(artifactsDir: string, runId: string, blockId: string): string;
110
+ /**
111
+ * Persist a node's `acceptNodeWorktree` lifecycle outcome so finalization can tell
112
+ * a node whose edits actually LANDED (merged) from one that self-reported "resolved"
113
+ * but failed tool-owned verify / merge (OBL-DS-06: never trust the worker's self
114
+ * report). Both rolling drivers (host-subagent `advanceHostRolling` and in-process
115
+ * `driveRollingImplementDispatch`) call this; the interim main-tree path writes none,
116
+ * so the merge-state gate is inert there.
117
+ */
118
+ export declare function recordNodeAcceptOutcome(artifactsDir: string, runId: string, blockId: string, result: AcceptNodeWorktreeResult): Promise<void>;
119
+ /** Load a node's recorded accept outcome, or null when none was written. */
120
+ export declare function loadNodeAcceptOutcome(artifactsDir: string, runId: string, blockId: string): Promise<AcceptNodeWorktreeResult | null>;
121
+ /**
122
+ * The per-node worktree worker an in-process driver launches: it edits within the
123
+ * node's isolated worktree (cwd-confined), writes its result file, and returns the
124
+ * transport outcome. `makeProviderNodeDispatcher` is the live implementation; tests
125
+ * inject a stub. Structurally identical to `nextStep`'s `ProgrammaticNodeDispatcher`.
126
+ */
127
+ export type WorktreeNodeWorker = (args: {
128
+ block: RemediationBlock;
129
+ slot: ProviderSlot;
130
+ worktreeRoot: string;
131
+ resultPath: string;
132
+ }) => Promise<RollingDispatchResult<{
133
+ block_id: string;
134
+ }>>;
135
+ /** One node's worktree-lifecycle result: the worker transport outcome + the accept lifecycle. */
136
+ export interface NodeWorktreeExecution {
137
+ /** Worker transport outcome the rolling engine consumes (success/error/rate_limited/timeout). */
138
+ result: RollingDispatchResult<{
139
+ block_id: string;
140
+ }>;
141
+ /** Tool-owned accept outcome (commit→verify→merge), already persisted via recordNodeAcceptOutcome. */
142
+ accept: AcceptNodeWorktreeResult;
143
+ }
144
+ /**
145
+ * Run ONE node's full in-process lifecycle in an isolated worktree — shared by BOTH
146
+ * in-process callers (the reactive `driveRollingImplementDispatch` engine and the
147
+ * A-8 hybrid executor) so they create / commit / verify / merge identically:
148
+ *
149
+ * reset + create the node's worktree → link node_modules → seed declared targets →
150
+ * launch the worker (`dispatchNode`) → `acceptNodeWorktree` (tool-commit, rebase,
151
+ * verify, write-scope gate, cherry-pick) → persist the accept outcome.
152
+ *
153
+ * Claim ownership is the CALLER's concern (the reactive engine claims through the
154
+ * shared registry; the hybrid executor is handed a coordinator-minted claim), so
155
+ * this fn neither claims nor releases — it returns the worker transport result AND
156
+ * the accept lifecycle outcome and lets the caller record `nodeOutcomes` / release.
157
+ * Any thrown error degrades to a dropped worktree + a persisted `error` accept
158
+ * outcome, never an unhandled rejection into the engine.
159
+ */
160
+ export declare function executeNodeInWorktree(args: {
161
+ block: RemediationBlock;
162
+ slot: ProviderSlot;
163
+ root: string;
164
+ artifactsDir: string;
165
+ runId: string;
166
+ resultPath: string;
167
+ /** Untracked declared targets to seed into the worktree (the node's write set or write∪read). */
168
+ seedPaths: string[];
169
+ /** Every block's declared write scope, for the accept-time write-scope gate (OBL-DS-06). */
170
+ allBlockScopes: Array<{
171
+ block_id: string;
172
+ write_paths: string[];
173
+ }>;
174
+ /** The node's own targeted_commands, run IN ADDITION to the derived verify (task_7d35176d). */
175
+ additionalVerifyCommands?: string[];
176
+ dispatchNode: WorktreeNodeWorker;
177
+ }): Promise<NodeWorktreeExecution>;
178
+ //# sourceMappingURL=acceptNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acceptNode.d.ts","sourceRoot":"","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,CAAC;IACnB,iGAAiG;IACjG,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,4FAA4F;IAC5F,cAAc,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IACnE,+FAA+F;IAC/F,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;IACpC,YAAY,EAAE,kBAAkB,CAAC;CAClC,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA6CjC"}
@@ -0,0 +1,351 @@
1
+ import { join } from "node:path";
2
+ import { spawnSyncHidden } from "audit-tools/shared";
3
+ import { withFileLock } from "audit-tools/shared";
4
+ import { runCommand } from "../../utils/commands.js";
5
+ import { mergedBaseCheckArgv } from "../gateCommands.js";
6
+ import { writeJsonFile, readOptionalJsonFile } from "audit-tools/shared";
7
+ import { runDir, worktreeBranchForBlock, gitEditedFilesForBranch, } from "./common.js";
8
+ import { removeWorktree, commitWorktree, quarantineUncommittedWorktreeEdits, quarantineFailedNodeCommit, clearQuarantinedCommit, rebaseBranchOntoHead, dirtyMainTreeCollisions, mergeWorktree, baseBranchLockPath, resetNodeWorktreeAndBranch, createWorktree, seedUntrackedDeclaredPaths, worktreePath, verifyNodeInWorktree, } from "./worktreeLifecycle.js";
9
+ import { deriveVerifyCommandsFromBranch, selfContainedVerifyCommands, buildFreeVerifyCommands, } from "./verifyCommands.js";
10
+ import { enforceAcceptWriteScope } from "./writeScope.js";
11
+ /**
12
+ * The shared post-worker "accept node" lifecycle, extracted so BOTH rolling
13
+ * drivers reuse identical correctness: the in-process provider engine
14
+ * (`driveRollingImplementDispatch`) calls it inline once the worker returns; the
15
+ * host-subagent driver calls it from the `accept-node` callback once a host
16
+ * subagent finishes.
17
+ *
18
+ * Given a completed worker run in an isolated worktree, this: (1) TOOL-commits
19
+ * the worker's edits onto the branch (deterministic, never the worker/host) so
20
+ * the branch diff is the write-scope ground truth; (2) runs the per-node verify
21
+ * IN the worktree BEFORE accepting; (3) merges via cherry-pick only on a passing
22
+ * verify; and (4) drops the worktree on any failure so the main tree is never
23
+ * dirtied by an unverified change. It returns the LIFECYCLE outcome (which the
24
+ * caller records for the deterministic merge); the caller still returns the
25
+ * worker's TRANSPORT outcome to the rolling engine (so a `rate_limited` worker
26
+ * re-queues, while a verify-failure is adjudicated by the merge → triage).
27
+ *
28
+ * SAFETY: the main tree is touched only through `mergeWorktree` (cherry-pick of a
29
+ * verified branch, aborts cleanly on conflict). No state mutation here — the
30
+ * caller persists via `mergeImplementResults`.
31
+ */
32
+ export async function acceptNodeWorktree(params) {
33
+ const { root, runId, blockId, worktreeRoot: wt, branch, workerOutcome, targetedCommands, additionalVerifyCommands } = params;
34
+ let verifyPassed = false;
35
+ let merged = false;
36
+ if (workerOutcome === "rate_limited") {
37
+ // Piece D — quota-death worktree preservation: a worker that died on a host
38
+ // session-limit is a RETRYABLE pause, not a failure. Leave its worktree INTACT
39
+ // (do NOT removeWorktree) so nothing is destroyed during the pause; the node
40
+ // redoes clean on resume (the re-entry `resetNodeWorktreeAndBranch` handles the
41
+ // clean redo). Nothing to land now — return the outcome so the rolling engine
42
+ // records the pause + strands the node pending.
43
+ return { outcome: workerOutcome, verifyPassed, merged };
44
+ }
45
+ if (workerOutcome !== "success") {
46
+ // Real worker failure (error / timeout): nothing to land; drop the worktree so
47
+ // the main tree is never dirtied by an unverified change, preserve the outcome.
48
+ removeWorktree(root, wt);
49
+ return { outcome: workerOutcome, verifyPassed, merged };
50
+ }
51
+ const commit = commitWorktree(wt, `remediate ${blockId} (${runId})`, params.writePaths);
52
+ if (commit.error) {
53
+ // Could not commit the worker's edits (e.g. a generated-artifact-under-scope
54
+ // fail-loud) → cannot safely LAND it, but the worker's real source edits are
55
+ // still uncommitted in the worktree. Preserve them under a durable quarantine
56
+ // ref BEFORE removing the worktree (P0 data-loss: a guard must not destroy the
57
+ // good work alongside the offending artifact), mirroring the verify/scope/
58
+ // merge-fail quarantine paths below.
59
+ quarantineUncommittedWorktreeEdits(root, wt, branch, runId, blockId);
60
+ removeWorktree(root, wt);
61
+ return { outcome: "error", verifyPassed, merged, diagnostic: commit.error };
62
+ }
63
+ if (!commit.committed) {
64
+ // Worker reported success but made no tracked edits — nothing to verify or merge.
65
+ // The deterministic merge adjudicates the result file (resolved_no_change needs evidence).
66
+ removeWorktree(root, wt);
67
+ return { outcome: "success", verifyPassed, merged };
68
+ }
69
+ // Base-mutating critical section (INV-2/INV-3/CE-001/CE-002/CE-005) under a DISTINCT
70
+ // base-branch lock — NOT the per-run rolling-session.lock `advanceHostRolling` holds
71
+ // (withFileLock is non-reentrant, so a same-path nested acquire would self-deadlock).
72
+ // Acquired exactly ONCE here so BOTH rolling drivers serialize the rebase →
73
+ // cherry-pick → cross-package check → reset sequence through one lock. The base HEAD
74
+ // OID is captured before the cherry-pick so a RED merged-base check rolls the base
75
+ // back bit-identically. The lock is released on EVERY exit path (success, verify
76
+ // fail, scope fail, check fail, subprocess fail) by withFileLock's finally.
77
+ return withFileLock(baseBranchLockPath(root, runId), async () => {
78
+ // Rebase the node's branch onto the current remediation HEAD BEFORE verify, so a
79
+ // sibling that merged after this worktree was created is folded in. Verify, the
80
+ // write-scope gate, and the cherry-pick then all operate on the FINAL to-be-merged
81
+ // content (green-at-merge; the later cherry-pick can no longer conflict). A true
82
+ // hunk conflict here is a genuine seam — preserve the work and route to triage
83
+ // rather than land a broken merge.
84
+ const rebase = rebaseBranchOntoHead(root, wt, branch);
85
+ if (!rebase.ok) {
86
+ quarantineFailedNodeCommit(root, branch, runId, blockId);
87
+ removeWorktree(root, wt);
88
+ return { outcome: "error", verifyPassed, merged, diagnostic: rebase.error };
89
+ }
90
+ // Pre-flight: a dirty tracked file in the MAIN checkout that collides with a
91
+ // path this node edits makes the later cherry-pick abort with an opaque
92
+ // "local changes would be overwritten by merge" — a condition the node cannot
93
+ // fix and that re-fails identically on every auto-retry. Detect it up front
94
+ // (before the expensive verify) and surface the actionable cause; preserve the
95
+ // committed work under quarantine like every sibling error path so nothing is
96
+ // lost while the host commits/stashes the unrelated WIP.
97
+ const collisions = dirtyMainTreeCollisions(root, branch);
98
+ if (collisions.length > 0) {
99
+ quarantineFailedNodeCommit(root, branch, runId, blockId);
100
+ removeWorktree(root, wt);
101
+ const paths = collisions.map((c) => `\`${c}\``).join(", ");
102
+ const it = collisions.length > 1 ? "them" : "it";
103
+ return {
104
+ outcome: "error",
105
+ verifyPassed,
106
+ merged,
107
+ diagnostic: `main tree has uncommitted changes to ${paths} — commit or stash ${it} ` +
108
+ `before merging this node (the cherry-pick would otherwise abort with ` +
109
+ `"local changes would be overwritten by merge"). This is unrelated to the ` +
110
+ `node's own fix; the node's work is preserved under its quarantine ref.`,
111
+ };
112
+ }
113
+ // Verify commands: when the host omits them (real rolling drivers), DERIVE them
114
+ // from the just-committed branch's touched test files — correct paths/runner by
115
+ // construction, only this node's own tests, never the whole suite. An explicit
116
+ // list (or `[]` to skip) overrides; both used by lifecycle unit tests. task_7d35176d:
117
+ // run the derive AND the node's own build-free `targeted_commands` (deduped) — the
118
+ // auditor's fix-specific regression checks the derive misses when a fix touches no
119
+ // test. `additionalVerifyCommands` is ignored on the explicit-override path.
120
+ const baseCommands = targetedCommands === undefined
121
+ ? deriveVerifyCommandsFromBranch(root, branch)
122
+ : targetedCommands;
123
+ let verifyCommands;
124
+ if (targetedCommands === undefined) {
125
+ // Self-contained per-node verify (2026-07-03): the derived `baseCommands` come
126
+ // from this node's ACTUAL branch edits (self-contained by construction), but the
127
+ // node's host/auditor-authored `additionalVerifyCommands` can reference a sibling
128
+ // node's not-yet-created deliverable → a guaranteed-fail deadlock. Drop any such
129
+ // cross-node command (deferred to the integration/close gate). Own paths = the
130
+ // node's declared write set ∪ the files it actually edited on its branch.
131
+ const edited = gitEditedFilesForBranch(root, branch);
132
+ const ownPaths = [
133
+ ...(params.writePaths ?? []),
134
+ ...(edited.available ? edited.files : []),
135
+ ];
136
+ const additional = selfContainedVerifyCommands(buildFreeVerifyCommands(additionalVerifyCommands), ownPaths, wt);
137
+ verifyCommands = [...new Set([...baseCommands, ...additional])];
138
+ }
139
+ else {
140
+ verifyCommands = baseCommands;
141
+ }
142
+ const verify = verifyCommands.length > 0
143
+ ? verifyNodeInWorktree(wt, verifyCommands)
144
+ : { passed: true, output: "" };
145
+ verifyPassed = verify.passed;
146
+ if (!verify.passed) {
147
+ // Verify failed: do not merge; drop the worktree so the main tree stays clean.
148
+ // The node DID commit real edits, so preserve them under a durable quarantine
149
+ // ref before the worktree/branch go away — a tool-verify false-negative must
150
+ // not destroy a good fix (the dogfood lost one this way). Carry the failing
151
+ // command + output so triage isn't blind on outcome:error.
152
+ quarantineFailedNodeCommit(root, branch, runId, blockId);
153
+ removeWorktree(root, wt);
154
+ return { outcome: "error", verifyPassed, merged, diagnostic: verify.output };
155
+ }
156
+ // Write-scope gate (OBL-DS-06), BEFORE the cherry-pick: an out-of-scope or
157
+ // seam-conflicting edit must never land in the main tree, so it is adjudicated
158
+ // against the branch's git diff (the ground truth) here rather than reported
159
+ // after `mergeWorktree` already merged it. The gate routes the node's ACTUAL
160
+ // out-of-declared edits (git diff, never a self-report): an edit to a file no
161
+ // sibling block owns widens the effective scope, while one owned by another
162
+ // block blocks as a seam conflict.
163
+ const decision = enforceAcceptWriteScope({
164
+ root,
165
+ branch,
166
+ blockId,
167
+ allBlockScopes: params.scope.allBlockScopes,
168
+ });
169
+ if (decision.blocked) {
170
+ // Scope-blocked but the node committed real work — preserve it for recovery.
171
+ quarantineFailedNodeCommit(root, branch, runId, blockId);
172
+ removeWorktree(root, wt);
173
+ return { outcome: "error", verifyPassed, merged: false, diagnostic: decision.reason };
174
+ }
175
+ // Capture the base HEAD OID BEFORE the cherry-pick so a RED merged-base check can
176
+ // roll the base back to a bit-identical state.
177
+ const baseHeadBefore = spawnSyncHidden("git", ["rev-parse", "HEAD"], {
178
+ cwd: root,
179
+ encoding: "utf8",
180
+ shell: false,
181
+ });
182
+ if (baseHeadBefore.error || baseHeadBefore.status !== 0) {
183
+ quarantineFailedNodeCommit(root, branch, runId, blockId);
184
+ removeWorktree(root, wt);
185
+ return {
186
+ outcome: "error",
187
+ verifyPassed,
188
+ merged,
189
+ diagnostic: `could not capture base HEAD before merge: ${(baseHeadBefore.stderr ?? baseHeadBefore.error?.message ?? "").toString().trim()}`,
190
+ };
191
+ }
192
+ const baseOid = baseHeadBefore.stdout.trim();
193
+ // mergeWorktree cherry-picks the verified branch and removes the worktree (on
194
+ // success AND on conflict-abort), so no explicit cleanup is needed afterwards.
195
+ const mergeRes = mergeWorktree(root, wt, branch);
196
+ merged = mergeRes.success;
197
+ if (!mergeRes.success) {
198
+ // Cherry-pick conflict: the committed work would otherwise be orphaned — preserve it.
199
+ quarantineFailedNodeCommit(root, branch, runId, blockId);
200
+ return { outcome: "error", verifyPassed, merged, diagnostic: mergeRes.error };
201
+ }
202
+ // Merged-base-green (INV-2): the cherry-pick landed in the MAIN checkout, where
203
+ // node_modules is faithful (the worktree's @audit-tools junction resolves to main
204
+ // and is unfaithful, so the per-node worktree verify cannot catch a cross-package
205
+ // break). Run the REAL cross-package check in the main tree. On RED, roll the base
206
+ // back to its captured OID bit-identically, scoped-clean the cherry-pick's emitted
207
+ // untracked files, quarantine, and fail — never leave a broken base for the sibling.
208
+ const checkArgv = params.mergedBaseCheckCommand === undefined
209
+ ? mergedBaseCheckArgv(root)
210
+ : params.mergedBaseCheckCommand;
211
+ if (checkArgv !== null) {
212
+ // Paths the just-landed pick touched, so the scoped clean nukes only those
213
+ // (never unrelated untracked state). Resolved BEFORE the check runs.
214
+ const pickedFiles = gitEditedFilesForBranch(root, branch);
215
+ // argv via runCommand → runTracked scrubs CLAUDECODE / CLAUDE_CODE_* and applies
216
+ // the shared Windows `.cmd` wrapping — never `shell: true`.
217
+ const [checkCmd, ...checkArgs] = checkArgv;
218
+ const check = runCommand(checkCmd, checkArgs, { cwd: root, encoding: "utf8" });
219
+ const checkFailed = !!check.error || check.status !== 0;
220
+ if (checkFailed) {
221
+ const detail = check.error
222
+ ? check.error.message
223
+ : [check.stdout ?? "", check.stderr ?? ""].filter(Boolean).join("\n");
224
+ // Roll the base back to its pre-pick OID, bit-identical.
225
+ spawnSyncHidden("git", ["reset", "--hard", baseOid], { cwd: root, shell: false });
226
+ // Scoped clean: remove only the cherry-pick / check-emitted untracked files
227
+ // under the paths the pick touched — never a blanket `git clean` that could
228
+ // nuke unrelated untracked state.
229
+ if (pickedFiles.available && pickedFiles.files.size > 0) {
230
+ spawnSyncHidden("git", ["clean", "-fdq", "--", ...[...pickedFiles.files]], { cwd: root, shell: false });
231
+ }
232
+ quarantineFailedNodeCommit(root, branch, runId, blockId);
233
+ return {
234
+ outcome: "error",
235
+ verifyPassed,
236
+ merged: false,
237
+ diagnostic: `$ ${checkArgv.join(" ")}\n${detail}`,
238
+ };
239
+ }
240
+ }
241
+ // Landed successfully and the merged base is green: clear any quarantine ref left
242
+ // by a prior failed attempt for this node so the recovery report lists only
243
+ // genuinely-unrecovered work.
244
+ clearQuarantinedCommit(root, runId, blockId);
245
+ return { outcome: "success", verifyPassed, merged };
246
+ });
247
+ }
248
+ /**
249
+ * Sidecar path for a node's tool-owned accept (verify/merge) outcome. Written by
250
+ * BOTH rolling drivers as each node is accepted, read by `mergeImplementResults`.
251
+ * Block ids here follow the same filename-safe convention as the per-node result
252
+ * files in the same dir.
253
+ */
254
+ export function nodeAcceptOutcomePath(artifactsDir, runId, blockId) {
255
+ return join(runDir(artifactsDir, runId, "implement"), `accept-outcome-${blockId}.json`);
256
+ }
257
+ /**
258
+ * Persist a node's `acceptNodeWorktree` lifecycle outcome so finalization can tell
259
+ * a node whose edits actually LANDED (merged) from one that self-reported "resolved"
260
+ * but failed tool-owned verify / merge (OBL-DS-06: never trust the worker's self
261
+ * report). Both rolling drivers (host-subagent `advanceHostRolling` and in-process
262
+ * `driveRollingImplementDispatch`) call this; the interim main-tree path writes none,
263
+ * so the merge-state gate is inert there.
264
+ */
265
+ export async function recordNodeAcceptOutcome(artifactsDir, runId, blockId, result) {
266
+ await writeJsonFile(nodeAcceptOutcomePath(artifactsDir, runId, blockId), {
267
+ schema_version: "remediate-code-implement/node-accept-outcome/v1alpha1",
268
+ block_id: blockId,
269
+ outcome: result.outcome,
270
+ verify_passed: result.verifyPassed,
271
+ merged: result.merged,
272
+ // Only present on a failure outcome; gives triage the failing command + output.
273
+ ...(result.diagnostic !== undefined ? { diagnostic: result.diagnostic } : {}),
274
+ });
275
+ }
276
+ /** Load a node's recorded accept outcome, or null when none was written. */
277
+ export async function loadNodeAcceptOutcome(artifactsDir, runId, blockId) {
278
+ const raw = await readOptionalJsonFile(nodeAcceptOutcomePath(artifactsDir, runId, blockId));
279
+ if (!raw)
280
+ return null;
281
+ return {
282
+ outcome: raw.outcome,
283
+ verifyPassed: raw.verify_passed,
284
+ merged: raw.merged,
285
+ ...(raw.diagnostic !== undefined ? { diagnostic: raw.diagnostic } : {}),
286
+ };
287
+ }
288
+ /**
289
+ * Run ONE node's full in-process lifecycle in an isolated worktree — shared by BOTH
290
+ * in-process callers (the reactive `driveRollingImplementDispatch` engine and the
291
+ * A-8 hybrid executor) so they create / commit / verify / merge identically:
292
+ *
293
+ * reset + create the node's worktree → link node_modules → seed declared targets →
294
+ * launch the worker (`dispatchNode`) → `acceptNodeWorktree` (tool-commit, rebase,
295
+ * verify, write-scope gate, cherry-pick) → persist the accept outcome.
296
+ *
297
+ * Claim ownership is the CALLER's concern (the reactive engine claims through the
298
+ * shared registry; the hybrid executor is handed a coordinator-minted claim), so
299
+ * this fn neither claims nor releases — it returns the worker transport result AND
300
+ * the accept lifecycle outcome and lets the caller record `nodeOutcomes` / release.
301
+ * Any thrown error degrades to a dropped worktree + a persisted `error` accept
302
+ * outcome, never an unhandled rejection into the engine.
303
+ */
304
+ export async function executeNodeInWorktree(args) {
305
+ const { block, slot, root, artifactsDir, runId, resultPath, seedPaths, allBlockScopes, additionalVerifyCommands, dispatchNode } = args;
306
+ const branch = worktreeBranchForBlock(block.block_id, runId);
307
+ const wt = worktreePath(root, block.block_id, runId);
308
+ try {
309
+ // Idempotent reset of any worktree dir AND leftover branch from a prior attempt
310
+ // (a `rate_limited` re-queue re-enters for the same block with its branch still
311
+ // present), then create this node's isolated worktree (createWorktree also links
312
+ // the main checkout's node_modules so verify can resolve deps), and seed
313
+ // untracked declared targets a committed-files-only worktree can't see.
314
+ resetNodeWorktreeAndBranch(root, wt, branch);
315
+ createWorktree(root, wt, branch);
316
+ seedUntrackedDeclaredPaths(root, wt, seedPaths);
317
+ const result = await dispatchNode({ block, slot, worktreeRoot: wt, resultPath });
318
+ // Shared post-worker lifecycle. Verify commands are DERIVED from the node's
319
+ // actually-touched tests inside acceptNodeWorktree (post-commit) — omit them so a
320
+ // host-authored path can't mis-verify. The write-scope gate adjudicates the node's
321
+ // ACTUAL git edits against every block's declared scope.
322
+ const accept = await acceptNodeWorktree({
323
+ root,
324
+ runId,
325
+ blockId: block.block_id,
326
+ worktreeRoot: wt,
327
+ branch,
328
+ workerOutcome: result.outcome,
329
+ additionalVerifyCommands,
330
+ scope: { allBlockScopes },
331
+ // The block's OWN declared write paths (INV-1 new-file inclusion).
332
+ writePaths: allBlockScopes.find((b) => b.block_id === block.block_id)?.write_paths ?? [],
333
+ });
334
+ await recordNodeAcceptOutcome(artifactsDir, runId, block.block_id, accept);
335
+ return { result, accept };
336
+ }
337
+ catch (err) {
338
+ removeWorktree(root, wt);
339
+ const accept = { outcome: "error", verifyPassed: false, merged: false };
340
+ await recordNodeAcceptOutcome(artifactsDir, runId, block.block_id, accept);
341
+ return {
342
+ result: {
343
+ packet: { id: block.block_id, payload: { block_id: block.block_id }, estimatedTokens: 0, complexity: 0.5 },
344
+ outcome: "error",
345
+ error: err,
346
+ },
347
+ accept,
348
+ };
349
+ }
350
+ }
351
+ //# sourceMappingURL=acceptNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acceptNode.js","sourceRoot":"","sources":["../../../../src/remediate/steps/dispatch/acceptNode.ts"],"names":[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