audit-tools 0.32.68 → 0.33.1

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 (238) hide show
  1. package/README.md +7 -0
  2. package/dist/audit/cli/advanceAuditCommand.d.ts.map +1 -1
  3. package/dist/audit/cli/advanceAuditCommand.js +8 -3
  4. package/dist/audit/cli/advanceAuditCommand.js.map +1 -1
  5. package/dist/audit/cli/args.d.ts +9 -27
  6. package/dist/audit/cli/args.d.ts.map +1 -1
  7. package/dist/audit/cli/args.js +119 -50
  8. package/dist/audit/cli/args.js.map +1 -1
  9. package/dist/audit/cli/auditStep.d.ts +15 -1
  10. package/dist/audit/cli/auditStep.d.ts.map +1 -1
  11. package/dist/audit/cli/auditStep.js +2 -0
  12. package/dist/audit/cli/auditStep.js.map +1 -1
  13. package/dist/audit/cli/dispatch/quotaPool.d.ts +2 -1
  14. package/dist/audit/cli/dispatch/quotaPool.d.ts.map +1 -1
  15. package/dist/audit/cli/dispatch/quotaPool.js +43 -77
  16. package/dist/audit/cli/dispatch/quotaPool.js.map +1 -1
  17. package/dist/audit/cli/dispatch.d.ts.map +1 -1
  18. package/dist/audit/cli/dispatch.js +14 -6
  19. package/dist/audit/cli/dispatch.js.map +1 -1
  20. package/dist/audit/cli/hybridDispatch.d.ts +3 -1
  21. package/dist/audit/cli/hybridDispatch.d.ts.map +1 -1
  22. package/dist/audit/cli/hybridDispatch.js +6 -0
  23. package/dist/audit/cli/hybridDispatch.js.map +1 -1
  24. package/dist/audit/cli/nextStepCommand.d.ts +0 -9
  25. package/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
  26. package/dist/audit/cli/nextStepCommand.js +173 -92
  27. package/dist/audit/cli/nextStepCommand.js.map +1 -1
  28. package/dist/audit/cli/nextStepHelpers.d.ts +11 -2
  29. package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
  30. package/dist/audit/cli/nextStepHelpers.js +56 -8
  31. package/dist/audit/cli/nextStepHelpers.js.map +1 -1
  32. package/dist/audit/cli/prepareDispatchCommand.d.ts.map +1 -1
  33. package/dist/audit/cli/prepareDispatchCommand.js +15 -9
  34. package/dist/audit/cli/prepareDispatchCommand.js.map +1 -1
  35. package/dist/audit/cli/prompts.d.ts +12 -32
  36. package/dist/audit/cli/prompts.d.ts.map +1 -1
  37. package/dist/audit/cli/prompts.js +19 -33
  38. package/dist/audit/cli/prompts.js.map +1 -1
  39. package/dist/audit/cli/providerConfirmationStep.d.ts +13 -5
  40. package/dist/audit/cli/providerConfirmationStep.d.ts.map +1 -1
  41. package/dist/audit/cli/providerConfirmationStep.js +47 -8
  42. package/dist/audit/cli/providerConfirmationStep.js.map +1 -1
  43. package/dist/audit/cli/quotaCommand.d.ts.map +1 -1
  44. package/dist/audit/cli/quotaCommand.js +16 -10
  45. package/dist/audit/cli/quotaCommand.js.map +1 -1
  46. package/dist/audit/cli/rollingAuditDispatch.d.ts.map +1 -1
  47. package/dist/audit/cli/rollingAuditDispatch.js +14 -1
  48. package/dist/audit/cli/rollingAuditDispatch.js.map +1 -1
  49. package/dist/audit/cli/semanticReviewStep.d.ts +11 -1
  50. package/dist/audit/cli/semanticReviewStep.d.ts.map +1 -1
  51. package/dist/audit/cli/semanticReviewStep.js +11 -15
  52. package/dist/audit/cli/semanticReviewStep.js.map +1 -1
  53. package/dist/audit/cli/validateCommand.d.ts.map +1 -1
  54. package/dist/audit/cli/validateCommand.js +3 -3
  55. package/dist/audit/cli/validateCommand.js.map +1 -1
  56. package/dist/audit/cli.js +3 -3
  57. package/dist/audit/cli.js.map +1 -1
  58. package/dist/audit/contracts/wrapperResponse.d.ts +6 -6
  59. package/dist/audit/orchestrator/advance.d.ts.map +1 -1
  60. package/dist/audit/orchestrator/advance.js +39 -7
  61. package/dist/audit/orchestrator/advance.js.map +1 -1
  62. package/dist/audit/orchestrator/advanceTypes.d.ts +52 -1
  63. package/dist/audit/orchestrator/advanceTypes.d.ts.map +1 -1
  64. package/dist/audit/orchestrator/executorRunners.d.ts.map +1 -1
  65. package/dist/audit/orchestrator/executorRunners.js +9 -1
  66. package/dist/audit/orchestrator/executorRunners.js.map +1 -1
  67. package/dist/audit/orchestrator/intakeExecutors.d.ts +27 -3
  68. package/dist/audit/orchestrator/intakeExecutors.d.ts.map +1 -1
  69. package/dist/audit/orchestrator/intakeExecutors.js +119 -19
  70. package/dist/audit/orchestrator/intakeExecutors.js.map +1 -1
  71. package/dist/audit/orchestrator/nextStep.d.ts +7 -0
  72. package/dist/audit/orchestrator/nextStep.d.ts.map +1 -1
  73. package/dist/audit/orchestrator/nextStep.js +3 -0
  74. package/dist/audit/orchestrator/nextStep.js.map +1 -1
  75. package/dist/audit/orchestrator/providerConfirmation.d.ts.map +1 -1
  76. package/dist/audit/orchestrator/providerConfirmation.js +0 -2
  77. package/dist/audit/orchestrator/providerConfirmation.js.map +1 -1
  78. package/dist/audit/orchestrator/rollingDispatch.d.ts.map +1 -1
  79. package/dist/audit/orchestrator/rollingDispatch.js +2 -0
  80. package/dist/audit/orchestrator/rollingDispatch.js.map +1 -1
  81. package/dist/audit/orchestrator/state.d.ts +17 -0
  82. package/dist/audit/orchestrator/state.d.ts.map +1 -1
  83. package/dist/audit/orchestrator/state.js +13 -1
  84. package/dist/audit/orchestrator/state.js.map +1 -1
  85. package/dist/audit/providers/claudeWorkerProvider.d.ts +10 -0
  86. package/dist/audit/providers/claudeWorkerProvider.d.ts.map +1 -0
  87. package/dist/audit/providers/claudeWorkerProvider.js +15 -0
  88. package/dist/audit/providers/claudeWorkerProvider.js.map +1 -0
  89. package/dist/audit/providers/index.d.ts.map +1 -1
  90. package/dist/audit/providers/index.js +2 -0
  91. package/dist/audit/providers/index.js.map +1 -1
  92. package/dist/audit/quota/index.d.ts +133 -128
  93. package/dist/audit/quota/index.d.ts.map +1 -1
  94. package/dist/audit/supervisor/sessionConfig.d.ts +3 -11
  95. package/dist/audit/supervisor/sessionConfig.d.ts.map +1 -1
  96. package/dist/audit/supervisor/sessionConfig.js +3 -25
  97. package/dist/audit/supervisor/sessionConfig.js.map +1 -1
  98. package/dist/audit/types/analyzerCapability.d.ts +6 -6
  99. package/dist/audit/types/externalAnalyzer.d.ts +10 -10
  100. package/dist/remediate/index.d.ts.map +1 -1
  101. package/dist/remediate/index.js +2 -2
  102. package/dist/remediate/index.js.map +1 -1
  103. package/dist/remediate/phases/plan.d.ts.map +1 -1
  104. package/dist/remediate/phases/plan.js +5 -4
  105. package/dist/remediate/phases/plan.js.map +1 -1
  106. package/dist/remediate/providers/claudeWorkerProvider.d.ts +11 -0
  107. package/dist/remediate/providers/claudeWorkerProvider.d.ts.map +1 -0
  108. package/dist/remediate/providers/claudeWorkerProvider.js +16 -0
  109. package/dist/remediate/providers/claudeWorkerProvider.js.map +1 -0
  110. package/dist/remediate/providers/index.d.ts.map +1 -1
  111. package/dist/remediate/providers/index.js +2 -0
  112. package/dist/remediate/providers/index.js.map +1 -1
  113. package/dist/remediate/steps/contractPipeline.d.ts.map +1 -1
  114. package/dist/remediate/steps/contractPipeline.js +9 -3
  115. package/dist/remediate/steps/contractPipeline.js.map +1 -1
  116. package/dist/remediate/steps/dispatch/acceptNode.d.ts +1 -1
  117. package/dist/remediate/steps/dispatch/acceptNode.d.ts.map +1 -1
  118. package/dist/remediate/steps/dispatch/acceptNode.js.map +1 -1
  119. package/dist/remediate/steps/dispatch/marshal.d.ts.map +1 -1
  120. package/dist/remediate/steps/dispatch/marshal.js +5 -4
  121. package/dist/remediate/steps/dispatch/marshal.js.map +1 -1
  122. package/dist/remediate/steps/dispatch/waveScheduling.d.ts +4 -2
  123. package/dist/remediate/steps/dispatch/waveScheduling.d.ts.map +1 -1
  124. package/dist/remediate/steps/dispatch/waveScheduling.js +33 -85
  125. package/dist/remediate/steps/dispatch/waveScheduling.js.map +1 -1
  126. package/dist/remediate/steps/nextStep.d.ts +21 -10
  127. package/dist/remediate/steps/nextStep.d.ts.map +1 -1
  128. package/dist/remediate/steps/nextStep.js +45 -25
  129. package/dist/remediate/steps/nextStep.js.map +1 -1
  130. package/dist/remediate/steps/sessionConfigLoad.d.ts +46 -0
  131. package/dist/remediate/steps/sessionConfigLoad.d.ts.map +1 -0
  132. package/dist/remediate/steps/sessionConfigLoad.js +39 -0
  133. package/dist/remediate/steps/sessionConfigLoad.js.map +1 -0
  134. package/dist/shared/config/resolveSessionConfig.d.ts +75 -0
  135. package/dist/shared/config/resolveSessionConfig.d.ts.map +1 -0
  136. package/dist/shared/config/resolveSessionConfig.js +125 -0
  137. package/dist/shared/config/resolveSessionConfig.js.map +1 -0
  138. package/dist/shared/dispatch/admissionLoop.d.ts +12 -12
  139. package/dist/shared/dispatch/coordinator.d.ts.map +1 -1
  140. package/dist/shared/dispatch/coordinator.js +52 -6
  141. package/dist/shared/dispatch/coordinator.js.map +1 -1
  142. package/dist/shared/dispatch/hybridDispatch.d.ts +6 -0
  143. package/dist/shared/dispatch/hybridDispatch.d.ts.map +1 -1
  144. package/dist/shared/dispatch/hybridDispatch.js +6 -0
  145. package/dist/shared/dispatch/hybridDispatch.js.map +1 -1
  146. package/dist/shared/dispatch/providerLaunchFinalize.d.ts +2 -1
  147. package/dist/shared/dispatch/providerLaunchFinalize.d.ts.map +1 -1
  148. package/dist/shared/dispatch/providerLaunchFinalize.js +123 -68
  149. package/dist/shared/dispatch/providerLaunchFinalize.js.map +1 -1
  150. package/dist/shared/dispatch/rollingDispatch.d.ts +69 -2
  151. package/dist/shared/dispatch/rollingDispatch.d.ts.map +1 -1
  152. package/dist/shared/dispatch/rollingDispatch.js +177 -7
  153. package/dist/shared/dispatch/rollingDispatch.js.map +1 -1
  154. package/dist/shared/dispatch/unifiedRolling.d.ts +23 -0
  155. package/dist/shared/dispatch/unifiedRolling.d.ts.map +1 -1
  156. package/dist/shared/dispatch/unifiedRolling.js +2 -0
  157. package/dist/shared/dispatch/unifiedRolling.js.map +1 -1
  158. package/dist/shared/friction/stepBoundaryCapture.d.ts +52 -1
  159. package/dist/shared/friction/stepBoundaryCapture.d.ts.map +1 -1
  160. package/dist/shared/friction/stepBoundaryCapture.js +87 -0
  161. package/dist/shared/friction/stepBoundaryCapture.js.map +1 -1
  162. package/dist/shared/index.d.ts +20 -10
  163. package/dist/shared/index.d.ts.map +1 -1
  164. package/dist/shared/index.js +20 -6
  165. package/dist/shared/index.js.map +1 -1
  166. package/dist/shared/io/stateDir.d.ts +27 -0
  167. package/dist/shared/io/stateDir.d.ts.map +1 -0
  168. package/dist/shared/io/stateDir.js +40 -0
  169. package/dist/shared/io/stateDir.js.map +1 -0
  170. package/dist/shared/providers/auditorSources.d.ts +169 -0
  171. package/dist/shared/providers/auditorSources.d.ts.map +1 -0
  172. package/dist/shared/providers/auditorSources.js +453 -0
  173. package/dist/shared/providers/auditorSources.js.map +1 -0
  174. package/dist/shared/providers/claudeWorkerProvider.d.ts +71 -0
  175. package/dist/shared/providers/claudeWorkerProvider.d.ts.map +1 -0
  176. package/dist/shared/providers/claudeWorkerProvider.js +133 -0
  177. package/dist/shared/providers/claudeWorkerProvider.js.map +1 -0
  178. package/dist/shared/providers/providerConfirmation.d.ts +3 -20
  179. package/dist/shared/providers/providerConfirmation.d.ts.map +1 -1
  180. package/dist/shared/providers/providerConfirmation.js +27 -40
  181. package/dist/shared/providers/providerConfirmation.js.map +1 -1
  182. package/dist/shared/providers/providerFactory.d.ts +13 -1
  183. package/dist/shared/providers/providerFactory.d.ts.map +1 -1
  184. package/dist/shared/providers/providerFactory.js +12 -0
  185. package/dist/shared/providers/providerFactory.js.map +1 -1
  186. package/dist/shared/providers/proxyCatalog.d.ts +95 -0
  187. package/dist/shared/providers/proxyCatalog.d.ts.map +1 -0
  188. package/dist/shared/providers/proxyCatalog.js +426 -0
  189. package/dist/shared/providers/proxyCatalog.js.map +1 -0
  190. package/dist/shared/providers/sharedProviderConfirmation.d.ts +264 -75
  191. package/dist/shared/providers/sharedProviderConfirmation.d.ts.map +1 -1
  192. package/dist/shared/providers/sharedProviderConfirmation.js +534 -113
  193. package/dist/shared/providers/sharedProviderConfirmation.js.map +1 -1
  194. package/dist/shared/quota/apiPool.d.ts +34 -11
  195. package/dist/shared/quota/apiPool.d.ts.map +1 -1
  196. package/dist/shared/quota/apiPool.js +52 -23
  197. package/dist/shared/quota/apiPool.js.map +1 -1
  198. package/dist/shared/quota/capacity.d.ts +79 -50
  199. package/dist/shared/quota/capacity.d.ts.map +1 -1
  200. package/dist/shared/quota/capacity.js +40 -5
  201. package/dist/shared/quota/capacity.js.map +1 -1
  202. package/dist/shared/quota/errorParsing.d.ts +39 -0
  203. package/dist/shared/quota/errorParsing.d.ts.map +1 -1
  204. package/dist/shared/quota/errorParsing.js +76 -0
  205. package/dist/shared/quota/errorParsing.js.map +1 -1
  206. package/dist/shared/quota/hostPool.d.ts +107 -0
  207. package/dist/shared/quota/hostPool.d.ts.map +1 -0
  208. package/dist/shared/quota/hostPool.js +103 -0
  209. package/dist/shared/quota/hostPool.js.map +1 -0
  210. package/dist/shared/quota/quotaSource.d.ts +2 -2
  211. package/dist/shared/types/auditorDescriptor.d.ts +120 -0
  212. package/dist/shared/types/auditorDescriptor.d.ts.map +1 -0
  213. package/dist/shared/types/auditorDescriptor.js +28 -0
  214. package/dist/shared/types/auditorDescriptor.js.map +1 -0
  215. package/dist/shared/types/providerConfirmation.d.ts +64 -6
  216. package/dist/shared/types/providerConfirmation.d.ts.map +1 -1
  217. package/dist/shared/types/providerConfirmation.js +1 -1
  218. package/dist/shared/types/rollingDispatch.d.ts +45 -1
  219. package/dist/shared/types/rollingDispatch.d.ts.map +1 -1
  220. package/dist/shared/types/sessionConfig.d.ts +149 -67
  221. package/dist/shared/types/sessionConfig.d.ts.map +1 -1
  222. package/dist/shared/types/sessionConfig.js +87 -2
  223. package/dist/shared/types/sessionConfig.js.map +1 -1
  224. package/dist/shared/validation/sessionConfig.d.ts +26 -14
  225. package/dist/shared/validation/sessionConfig.d.ts.map +1 -1
  226. package/dist/shared/validation/sessionConfig.js +95 -69
  227. package/dist/shared/validation/sessionConfig.js.map +1 -1
  228. package/docs/audit-pkg/contracts.md +4 -4
  229. package/docs/audit-pkg/operator-guide.md +43 -24
  230. package/package.json +1 -1
  231. package/skills/audit-code/SKILL.md +17 -14
  232. package/skills/audit-code/audit-code.prompt.md +17 -16
  233. package/wrapper/audit-code-wrapper-install-hosts.mjs +6 -10
  234. package/wrapper/remediate-code-wrapper-install-hosts.mjs +4 -8
  235. package/dist/shared/quota/repairProxyRegistry.d.ts +0 -84
  236. package/dist/shared/quota/repairProxyRegistry.d.ts.map +0 -1
  237. package/dist/shared/quota/repairProxyRegistry.js +0 -144
  238. package/dist/shared/quota/repairProxyRegistry.js.map +0 -1
@@ -0,0 +1,39 @@
1
+ import { join } from "node:path";
2
+ import { readValidatedRepoSessionIntent, resolveSessionConfig, ambientAuditorDescriptor, populateProxyCatalogIfMissing, } from "audit-tools/shared";
3
+ /**
4
+ * The ONE place remediate turns a persisted `RepoSessionIntent` into an effective
5
+ * {@link SessionConfig} — so the descriptor choice cannot drift across call sites.
6
+ *
7
+ * It is ALWAYS the ambient descriptor: remediate has no host handshake (no `--auditor`
8
+ * flag), but it has an environment, so its dispatch pool resolves in-process from
9
+ * `declared ∩ ambient-verifiable`. Host-self-class fields (model/window/roster) stay
10
+ * absent → the host pool sizes to the conservative floor, which is a fidelity
11
+ * degradation, never a block.
12
+ *
13
+ * ⚠ Why this function exists rather than three call sites each choosing: passing `null`
14
+ * FAILS CLOSED to driver-self-only — no pool at all — and that is exactly what happened.
15
+ * Between v0.32.68 and the fix, all three remediate sites hardcoded `null`, so remediate
16
+ * could not dispatch to ANY non-self pool, where v0.32.68 read `sources[]` straight off
17
+ * disk. The mechanism was deliberate; the consequence went unnoticed for four laps.
18
+ * Routing every site through here makes the null choice UNREPRESENTABLE instead of a
19
+ * thing each site must remember — enforce in tooling, never "the next author notices".
20
+ * [[capability-is-per-auditor-not-per-audit]] [[enforce-robustness-in-tooling-not-host-discretion]]
21
+ */
22
+ export async function loadRemediateSessionConfig(params) {
23
+ if (params.override)
24
+ return params.override;
25
+ // Remediate has no Gate-0 build moment (audit's populate trigger), so a declared
26
+ // repair-proxy lane on a remediate-only machine would never expand — the
27
+ // [[silent-fail-closed-on-one-draw]] class. Missing-only populate: after one
28
+ // success this is a cheap cache read, never a per-load fetch. Failure degrades
29
+ // (the resolve half then drops the lane WITH a reason via resolveSessionConfig's
30
+ // dropped-source report); it never blocks the load.
31
+ await populateProxyCatalogIfMissing(params.ambient).catch(() => null);
32
+ const intent = params.artifactsFirst
33
+ ? ((await readValidatedRepoSessionIntent(join(params.root, ".remediation-artifacts", "session-config.json"))) ?? (await readValidatedRepoSessionIntent(join(params.root, "session-config.json"))))
34
+ : await readValidatedRepoSessionIntent(join(params.root, "session-config.json"));
35
+ return intent
36
+ ? resolveSessionConfig(intent, ambientAuditorDescriptor(), params.ambient)
37
+ : undefined;
38
+ }
39
+ //# sourceMappingURL=sessionConfigLoad.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessionConfigLoad.js","sourceRoot":"","sources":["../../../src/remediate/steps/sessionConfigLoad.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,8BAA8B,EAC9B,oBAAoB,EACpB,wBAAwB,EACxB,6BAA6B,GAG9B,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,MAwBhD;IACC,IAAI,MAAM,CAAC,QAAQ;QAAE,OAAO,MAAM,CAAC,QAAQ,CAAC;IAC5C,iFAAiF;IACjF,yEAAyE;IACzE,6EAA6E;IAC7E,+EAA+E;IAC/E,iFAAiF;IACjF,oDAAoD;IACpD,MAAM,6BAA6B,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACtE,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc;QAClC,CAAC,CAAC,CAAC,CAAC,MAAM,8BAA8B,CACpC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,wBAAwB,EAAE,qBAAqB,CAAC,CACnE,CAAC,IAAI,CAAC,MAAM,8BAA8B,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACzF,CAAC,CAAC,MAAM,8BAA8B,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC;IACnF,OAAO,MAAM;QACX,CAAC,CAAC,oBAAoB,CAAC,MAAM,EAAE,wBAAwB,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC;QAC1E,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC"}
@@ -0,0 +1,75 @@
1
+ import type { AuditorDescriptor } from "../types/auditorDescriptor.js";
2
+ import { type RepoSessionIntent, type SessionConfig } from "../types/sessionConfig.js";
3
+ import { type AmbientSourceDeps, type DroppedSource } from "../providers/auditorSources.js";
4
+ /**
5
+ * The ambient probes the G2.5 source resolution reads. Production passes nothing —
6
+ * every probe defaults to the real environment (`process.env`, real PATH, real home
7
+ * dir), which is the point: the reach check must read the SAME env the provider reads
8
+ * at launch. Tests inject. `onDroppedSources` overrides the default stderr report
9
+ * for declared-but-unresolved lanes (the reasons must be loud at every draw).
10
+ */
11
+ export type ResolveSessionConfigOptions = AmbientSourceDeps & {
12
+ onDroppedSources?: (dropped: DroppedSource[]) => void;
13
+ };
14
+ /**
15
+ * Produce the in-memory EFFECTIVE {@link SessionConfig} every dispatch/provider
16
+ * consumer reads, from the persisted {@link RepoSessionIntent} (audit intent +
17
+ * policy, NO dispatch inventory) overlaid with the per-invocation
18
+ * {@link AuditorDescriptor} (the driver's identity + own launch transport +
19
+ * reachable `sources[]`). This is the single seam that replaces the retired
20
+ * `applyDispatchInventory`: the backend/launch set now comes from the per-auditor
21
+ * descriptor, never the repo session-config, and is never inherited across auditors
22
+ * ([[capability-is-per-auditor-not-per-audit]], `spec/unified-dispatch-worker-model.md`, G2).
23
+ *
24
+ * - `descriptor == null` → FAIL CLOSED to driver-self-only: the intent is returned
25
+ * with no resolved backends. The driver is definitionally reachable and
26
+ * self-launches; there is NO stored dispatch value to fall back to. This is the
27
+ * deliberate G2 behavior change from `applyDispatchInventory(cfg, null) ⇒ cfg`.
28
+ * Ambient resolution deliberately does NOT apply here — `null` means "resolve NO
29
+ * pool", which is a stronger statement than "no handshake happened".
30
+ *
31
+ * ⚠ A caller that HAS no handshake but DOES have an environment wants
32
+ * {@link ambientAuditorDescriptor}, NOT `null`. Passing `null` there is a silent
33
+ * capability loss: it short-circuits before {@link resolveAmbientSources}, so a
34
+ * declared + reachable lane never becomes a pool. Remediate did exactly that at all
35
+ * three of its dispatch sites and consequently could not dispatch to any non-self
36
+ * pool; it now routes through `loadRemediateSessionConfig`, which always supplies the
37
+ * ambient descriptor.
38
+ * - `descriptor` present → the driver's `self.provider` becomes the effective
39
+ * provider + conversation-host attribution key; its own host/IDE launch blocks
40
+ * (`claude_code` / `vscode_task` / `antigravity`) overlay; and `sources[]` becomes
41
+ * the effective dispatch pool. When the DRIVER itself is a dispatchable-source
42
+ * backend (headless single-lane), its flat per-backend block is reconstructed from
43
+ * the matching source so `createFreshSessionProvider` can build the primary
44
+ * provider — the pool machinery reads `effective.sources` directly (dedup by
45
+ * source id), so there is no double-count.
46
+ *
47
+ * **Where `sources[]` comes from (G2.5).** The cut is WHO LAUNCHES: `self` is what only
48
+ * the host can know (can-dispatch-subagents, can_proxy, roster, ceilings) and is
49
+ * irreducibly handshake-reported; `sources[]` are the six backends THIS PROCESS spawns
50
+ * (CLI subprocess or HTTP POST), so they are resolved in-process by
51
+ * `resolveAmbientSources` — `declared ∩ ambient-verifiable` over the operator's
52
+ * machine-level declaration — and never routed through the host. An explicit
53
+ * `descriptor.sources` still wins (the operator's escape hatch).
54
+ *
55
+ * Deliberate deviation from `spec/unified-dispatch-worker-model.md`'s G2.5 sketch (a
56
+ * pre-`next-step` shell-out printing `sources[]` for the host to merge): that merge is
57
+ * an LLM hand-composing JSON — the host-discretion anti-pattern the commit exists to
58
+ * kill, whose failure mode is a silently-empty pool indistinguishable from an
59
+ * unreachable machine. The spec's shell-out conflated POPULATE (expensive, network-
60
+ * bound, cacheable) with RESOLVE (local, cheap, must run at the moment of use).
61
+ * G2.5 builds RESOLVE; POPULATE lands later behind this same seam.
62
+ *
63
+ * Every INTENT field (synthesis / analyzers / graph / quota / block_quota /
64
+ * design_review / dispatch fan-out knobs / …) is preserved identically. Never mutates
65
+ * its inputs.
66
+ *
67
+ * NOT pure since G2.5: when a descriptor omits `sources`, this READS the ambient
68
+ * environment (the declaration file, env vars, PATH). That is deliberate and is the
69
+ * whole point — resolving anywhere else would let the reach check and the launch read
70
+ * different environments. It stays cheap (one small JSON read, and only on the
71
+ * descriptor-present path; `descriptor == null` short-circuits before it) and every
72
+ * probe is injectable via {@link ResolveSessionConfigOptions} for tests.
73
+ */
74
+ export declare function resolveSessionConfig(intent: RepoSessionIntent, descriptor: AuditorDescriptor | null | undefined, options?: ResolveSessionConfigOptions): SessionConfig;
75
+ //# sourceMappingURL=resolveSessionConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveSessionConfig.d.ts","sourceRoot":"","sources":["../../../src/shared/config/resolveSessionConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EACnB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAEnB,MAAM,gCAAgC,CAAC;AAExC;;;;;;GAMG;AACH,MAAM,MAAM,2BAA2B,GAAG,iBAAiB,GAAG;IAC5D,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;CACvD,CAAC;AAMF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,iBAAiB,EACzB,UAAU,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,EAChD,OAAO,CAAC,EAAE,2BAA2B,GACpC,aAAa,CAyDf"}
@@ -0,0 +1,125 @@
1
+ import { DISPATCHABLE_SOURCE_PROVIDERS, } from "../types/sessionConfig.js";
2
+ import { sourceProviderConfig } from "../quota/apiPool.js";
3
+ import { resolveAmbientSources, } from "../providers/auditorSources.js";
4
+ const DISPATCHABLE_PROVIDER_SET = new Set(DISPATCHABLE_SOURCE_PROVIDERS);
5
+ /**
6
+ * Produce the in-memory EFFECTIVE {@link SessionConfig} every dispatch/provider
7
+ * consumer reads, from the persisted {@link RepoSessionIntent} (audit intent +
8
+ * policy, NO dispatch inventory) overlaid with the per-invocation
9
+ * {@link AuditorDescriptor} (the driver's identity + own launch transport +
10
+ * reachable `sources[]`). This is the single seam that replaces the retired
11
+ * `applyDispatchInventory`: the backend/launch set now comes from the per-auditor
12
+ * descriptor, never the repo session-config, and is never inherited across auditors
13
+ * ([[capability-is-per-auditor-not-per-audit]], `spec/unified-dispatch-worker-model.md`, G2).
14
+ *
15
+ * - `descriptor == null` → FAIL CLOSED to driver-self-only: the intent is returned
16
+ * with no resolved backends. The driver is definitionally reachable and
17
+ * self-launches; there is NO stored dispatch value to fall back to. This is the
18
+ * deliberate G2 behavior change from `applyDispatchInventory(cfg, null) ⇒ cfg`.
19
+ * Ambient resolution deliberately does NOT apply here — `null` means "resolve NO
20
+ * pool", which is a stronger statement than "no handshake happened".
21
+ *
22
+ * ⚠ A caller that HAS no handshake but DOES have an environment wants
23
+ * {@link ambientAuditorDescriptor}, NOT `null`. Passing `null` there is a silent
24
+ * capability loss: it short-circuits before {@link resolveAmbientSources}, so a
25
+ * declared + reachable lane never becomes a pool. Remediate did exactly that at all
26
+ * three of its dispatch sites and consequently could not dispatch to any non-self
27
+ * pool; it now routes through `loadRemediateSessionConfig`, which always supplies the
28
+ * ambient descriptor.
29
+ * - `descriptor` present → the driver's `self.provider` becomes the effective
30
+ * provider + conversation-host attribution key; its own host/IDE launch blocks
31
+ * (`claude_code` / `vscode_task` / `antigravity`) overlay; and `sources[]` becomes
32
+ * the effective dispatch pool. When the DRIVER itself is a dispatchable-source
33
+ * backend (headless single-lane), its flat per-backend block is reconstructed from
34
+ * the matching source so `createFreshSessionProvider` can build the primary
35
+ * provider — the pool machinery reads `effective.sources` directly (dedup by
36
+ * source id), so there is no double-count.
37
+ *
38
+ * **Where `sources[]` comes from (G2.5).** The cut is WHO LAUNCHES: `self` is what only
39
+ * the host can know (can-dispatch-subagents, can_proxy, roster, ceilings) and is
40
+ * irreducibly handshake-reported; `sources[]` are the six backends THIS PROCESS spawns
41
+ * (CLI subprocess or HTTP POST), so they are resolved in-process by
42
+ * `resolveAmbientSources` — `declared ∩ ambient-verifiable` over the operator's
43
+ * machine-level declaration — and never routed through the host. An explicit
44
+ * `descriptor.sources` still wins (the operator's escape hatch).
45
+ *
46
+ * Deliberate deviation from `spec/unified-dispatch-worker-model.md`'s G2.5 sketch (a
47
+ * pre-`next-step` shell-out printing `sources[]` for the host to merge): that merge is
48
+ * an LLM hand-composing JSON — the host-discretion anti-pattern the commit exists to
49
+ * kill, whose failure mode is a silently-empty pool indistinguishable from an
50
+ * unreachable machine. The spec's shell-out conflated POPULATE (expensive, network-
51
+ * bound, cacheable) with RESOLVE (local, cheap, must run at the moment of use).
52
+ * G2.5 builds RESOLVE; POPULATE lands later behind this same seam.
53
+ *
54
+ * Every INTENT field (synthesis / analyzers / graph / quota / block_quota /
55
+ * design_review / dispatch fan-out knobs / …) is preserved identically. Never mutates
56
+ * its inputs.
57
+ *
58
+ * NOT pure since G2.5: when a descriptor omits `sources`, this READS the ambient
59
+ * environment (the declaration file, env vars, PATH). That is deliberate and is the
60
+ * whole point — resolving anywhere else would let the reach check and the launch read
61
+ * different environments. It stays cheap (one small JSON read, and only on the
62
+ * descriptor-present path; `descriptor == null` short-circuits before it) and every
63
+ * probe is injectable via {@link ResolveSessionConfigOptions} for tests.
64
+ */
65
+ export function resolveSessionConfig(intent, descriptor, options) {
66
+ // The intent carries NO dispatch-inventory fields and no `dispatch.rolling_engine`
67
+ // (RepoDispatchConfig), so the base effective config is the intent verbatim; its
68
+ // narrower `dispatch` is structurally assignable to DispatchConfig.
69
+ const effective = { ...intent };
70
+ if (descriptor == null) {
71
+ return effective;
72
+ }
73
+ const self = descriptor.self ?? {};
74
+ if (self.provider !== undefined) {
75
+ effective.provider = self.provider;
76
+ effective.host_provider = self.provider;
77
+ }
78
+ if (self.claude_code !== undefined)
79
+ effective.claude_code = self.claude_code;
80
+ if (self.vscode_task !== undefined)
81
+ effective.vscode_task = self.vscode_task;
82
+ if (self.antigravity !== undefined)
83
+ effective.antigravity = self.antigravity;
84
+ if (self.parallel_workers !== undefined) {
85
+ effective.parallel_workers = self.parallel_workers;
86
+ }
87
+ // `declared ∩ ambient-verifiable`, resolved IN-PROCESS (G2.5). An explicit
88
+ // hand-authored `--auditor sources[]` still wins — it is the operator's escape
89
+ // hatch and the only way to force a lane this process cannot prove.
90
+ let sources;
91
+ if (descriptor.sources) {
92
+ sources = descriptor.sources;
93
+ }
94
+ else {
95
+ const ambient = resolveAmbientSources(options);
96
+ // A dropped lane must be LOUD at every draw — the reasons existed since G2.5
97
+ // but were discarded here, so a declared-but-unresolvable lane was silently
98
+ // absent (the [[silent-fail-closed-on-one-draw]] class). Default = stderr;
99
+ // callers with a better channel inject `onDroppedSources`.
100
+ if (ambient.dropped.length > 0) {
101
+ const report = options?.onDroppedSources ??
102
+ ((dropped) => {
103
+ for (const d of dropped) {
104
+ process.stderr.write(`[audit-tools] declared source "${d.id}" not resolved: ${d.reason}\n`);
105
+ }
106
+ });
107
+ report(ambient.dropped);
108
+ }
109
+ sources = ambient.sources;
110
+ }
111
+ if (sources.length > 0) {
112
+ effective.sources = sources;
113
+ if (self.provider && DISPATCHABLE_PROVIDER_SET.has(self.provider)) {
114
+ // The FIRST source matching the driver's provider supplies its flat block. With
115
+ // multiple same-provider sources (e.g. two NIM endpoints), the operator orders
116
+ // `sources[]` so the driver's own endpoint is first; the non-primary ones still
117
+ // become their own pools via `effective.sources`.
118
+ const primary = sources.find((s) => s.provider === self.provider);
119
+ if (primary)
120
+ Object.assign(effective, sourceProviderConfig(primary));
121
+ }
122
+ }
123
+ return effective;
124
+ }
125
+ //# sourceMappingURL=resolveSessionConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveSessionConfig.js","sourceRoot":"","sources":["../../../src/shared/config/resolveSessionConfig.ts"],"names":[],"mappings":"AACA,OAAO,EACL,6BAA6B,GAI9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAGL,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AAaxC,MAAM,yBAAyB,GAAwB,IAAI,GAAG,CAC5D,6BAA6B,CAC9B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAyB,EACzB,UAAgD,EAChD,OAAqC;IAErC,mFAAmF;IACnF,iFAAiF;IACjF,oEAAoE;IACpE,MAAM,SAAS,GAAkB,EAAE,GAAG,MAAM,EAAE,CAAC;IAC/C,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC;IACnC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAChC,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QACnC,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC1C,CAAC;IACD,IAAI,IAAI,CAAC,WA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O,GAAG,OAAO,CAAC;QAC5B,IAAI,IAAI,CAAC,QAAQ,IAAI,yBAAyB,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClE,gFAAgF;YAChF,+EAA+E;YAC/E,gFAAgF;YAChF,kDAAkD;YAClD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;YAClE,IAAI,OAAO;gBAAE,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -100,15 +100,15 @@ export declare const AdmissionGrantSchema: z.ZodObject<{
100
100
  lease_id: z.ZodString;
101
101
  cost: z.ZodNumber;
102
102
  }, "strict", z.ZodTypeAny, {
103
+ pool_id: string;
103
104
  cost: number;
104
105
  packet_id: string;
105
- pool_id: string;
106
106
  resource_key: string;
107
107
  lease_id: string;
108
108
  }, {
109
+ pool_id: string;
109
110
  cost: number;
110
111
  packet_id: string;
111
- pool_id: string;
112
112
  resource_key: string;
113
113
  lease_id: string;
114
114
  }>;
@@ -126,19 +126,19 @@ export declare const AdmissionExplainSchema: z.ZodObject<{
126
126
  cost: z.ZodNumber;
127
127
  }, "strict", z.ZodTypeAny, {
128
128
  reason: "admitted" | "no_capable_pool" | "budget_exhausted" | "cap_reached";
129
+ pool_id: string | null;
129
130
  cost: number;
130
131
  admitted: boolean;
131
132
  packet_id: string;
132
- pool_id: string | null;
133
133
  resource_key: string | null;
134
134
  headroom_before?: number | undefined;
135
135
  outstanding_before?: number | undefined;
136
136
  }, {
137
137
  reason: "admitted" | "no_capable_pool" | "budget_exhausted" | "cap_reached";
138
+ pool_id: string | null;
138
139
  cost: number;
139
140
  admitted: boolean;
140
141
  packet_id: string;
141
- pool_id: string | null;
142
142
  resource_key: string | null;
143
143
  headroom_before?: number | undefined;
144
144
  outstanding_before?: number | undefined;
@@ -162,15 +162,15 @@ export declare const DispatchAdmissionSchema: z.ZodObject<{
162
162
  lease_id: z.ZodString;
163
163
  cost: z.ZodNumber;
164
164
  }, "strict", z.ZodTypeAny, {
165
+ pool_id: string;
165
166
  cost: number;
166
167
  packet_id: string;
167
- pool_id: string;
168
168
  resource_key: string;
169
169
  lease_id: string;
170
170
  }, {
171
+ pool_id: string;
171
172
  cost: number;
172
173
  packet_id: string;
173
- pool_id: string;
174
174
  resource_key: string;
175
175
  lease_id: string;
176
176
  }>, "many">;
@@ -187,28 +187,28 @@ export declare const DispatchAdmissionSchema: z.ZodObject<{
187
187
  cost: z.ZodNumber;
188
188
  }, "strict", z.ZodTypeAny, {
189
189
  reason: "admitted" | "no_capable_pool" | "budget_exhausted" | "cap_reached";
190
+ pool_id: string | null;
190
191
  cost: number;
191
192
  admitted: boolean;
192
193
  packet_id: string;
193
- pool_id: string | null;
194
194
  resource_key: string | null;
195
195
  headroom_before?: number | undefined;
196
196
  outstanding_before?: number | undefined;
197
197
  }, {
198
198
  reason: "admitted" | "no_capable_pool" | "budget_exhausted" | "cap_reached";
199
+ pool_id: string | null;
199
200
  cost: number;
200
201
  admitted: boolean;
201
202
  packet_id: string;
202
- pool_id: string | null;
203
203
  resource_key: string | null;
204
204
  headroom_before?: number | undefined;
205
205
  outstanding_before?: number | undefined;
206
206
  }>, "many">;
207
207
  }, "strict", z.ZodTypeAny, {
208
208
  leases: {
209
+ pool_id: string;
209
210
  cost: number;
210
211
  packet_id: string;
211
- pool_id: string;
212
212
  resource_key: string;
213
213
  lease_id: string;
214
214
  }[];
@@ -216,19 +216,19 @@ export declare const DispatchAdmissionSchema: z.ZodObject<{
216
216
  declared_cap: number | null;
217
217
  explains: {
218
218
  reason: "admitted" | "no_capable_pool" | "budget_exhausted" | "cap_reached";
219
+ pool_id: string | null;
219
220
  cost: number;
220
221
  admitted: boolean;
221
222
  packet_id: string;
222
- pool_id: string | null;
223
223
  resource_key: string | null;
224
224
  headroom_before?: number | undefined;
225
225
  outstanding_before?: number | undefined;
226
226
  }[];
227
227
  }, {
228
228
  leases: {
229
+ pool_id: string;
229
230
  cost: number;
230
231
  packet_id: string;
231
- pool_id: string;
232
232
  resource_key: string;
233
233
  lease_id: string;
234
234
  }[];
@@ -236,10 +236,10 @@ export declare const DispatchAdmissionSchema: z.ZodObject<{
236
236
  declared_cap: number | null;
237
237
  explains: {
238
238
  reason: "admitted" | "no_capable_pool" | "budget_exhausted" | "cap_reached";
239
+ pool_id: string | null;
239
240
  cost: number;
240
241
  admitted: boolean;
241
242
  packet_id: string;
242
- pool_id: string | null;
243
243
  resource_key: string | null;
244
244
  headroom_before?: number | undefined;
245
245
  outstanding_before?: number | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../../src/shared/dispatch/coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAM/D;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,EAAE,EAAE,MAAM,CAAC;IACX,8EAA8E;IAC9E,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;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,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD;AAiBD,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA4B;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAA2C;gBAEzD,IAAI,EAAE,6BAA6B;IAQ/C,4EAA4E;IAC5E,OAAO,CAAC,WAAW;IAKnB;;;;;;;;;;;;;;;;;;OAkBG;IACG,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAyFvE;;;;;;;;OAQG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/C;;;;;;OAMG;IACG,OAAO,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD;;;;;;OAMG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,yBAAyB;CASjE"}
@@ -43,7 +43,18 @@
43
43
  * provider coupling, so it runs identically on win32 / darwin / linux and under
44
44
  * either driver.
45
45
  */
46
- import { computeDispatchCapacity, buildEmptyPoolTerminal } from "../quota/capacity.js";
46
+ import { computeDispatchCapacity, buildEmptyPoolTerminal, AGENTIC_WORKER_HARNESS_OVERHEAD_TOKENS, } from "../quota/capacity.js";
47
+ /**
48
+ * Whether a node fits a pool's declared per-request/context token cap, including
49
+ * the agentic-harness overhead a CLI worker adds on top of the packet prompt.
50
+ * A pool with no declared cap (null/absent — host pools, undeclared sources) is
51
+ * always admissible: unknown means no fit filtering, the status quo.
52
+ */
53
+ function nodeContextFits(node, pool) {
54
+ if (pool.contextCapTokens == null)
55
+ return true;
56
+ return node.estimatedTokens + AGENTIC_WORKER_HARNESS_OVERHEAD_TOKENS <= pool.contextCapTokens;
57
+ }
47
58
  // ---------------------------------------------------------------------------
48
59
  // HybridSpillCoordinator
49
60
  // ---------------------------------------------------------------------------
@@ -101,7 +112,13 @@ export class HybridSpillCoordinator {
101
112
  });
102
113
  const poolById = new Map(active.map((p) => [p.id, p]));
103
114
  const assignments = [];
104
- let cursor = 0;
115
+ // Per-pool packet-fit gate (U2): the claim walk consumes a shared queue with a
116
+ // FIRST-FIT scan instead of a linear cursor, so a node too large for THIS pool's
117
+ // declared context cap stays available for a later (larger or cap-less) pool in
118
+ // the same walk — the claim itself is the fit guarantee (a node is never claimed
119
+ // to a pool it cannot fit; post-hoc repartitioning would strand the claim on the
120
+ // wrong pool id).
121
+ const unassigned = [...ordered];
105
122
  for (const alloc of capacity.pools) {
106
123
  const pool = poolById.get(alloc.pool_id);
107
124
  // Defensive: the fold echoes the input pools, but never assign to a pool
@@ -109,9 +126,16 @@ export class HybridSpillCoordinator {
109
126
  if (!pool)
110
127
  continue;
111
128
  let placed = 0;
112
- while (placed < alloc.slots && cursor < ordered.length) {
113
- const node = ordered[cursor];
114
- cursor += 1;
129
+ let scan = 0;
130
+ while (placed < alloc.slots && scan < unassigned.length) {
131
+ const node = unassigned[scan];
132
+ if (!nodeContextFits(node, pool)) {
133
+ // Too large for this pool — leave it queued for a later pool this walk
134
+ // (or unclaimed for the next cycle); the slot stays open for the next node.
135
+ scan += 1;
136
+ continue;
137
+ }
138
+ unassigned.splice(scan, 1);
115
139
  // Claim BEFORE returning the node in any assignment (CE-001). A node
116
140
  // another driver already holds is skipped — it is theirs to run — and the
117
141
  // slot is freed for the next node so capacity is not wasted on a contested id.
@@ -127,9 +151,31 @@ export class HybridSpillCoordinator {
127
151
  });
128
152
  placed += 1;
129
153
  }
130
- if (cursor >= ordered.length)
154
+ if (unassigned.length === 0)
131
155
  break;
132
156
  }
157
+ // Loud never-fits surface (spec F1): a node whose size exceeds EVERY active
158
+ // pool's declared cap can never be claimed by this coordinator — re-offering
159
+ // is correct only while a cap-less (host) pool may appear; silent re-offer
160
+ // against a fixed all-capped pool set would look like an idle wedge. One
161
+ // structured line per plan so the caller/operator can see exactly which
162
+ // nodes are unplaceable and why.
163
+ const neverFits = unassigned.filter((n) => active.every((p) => !nodeContextFits(n, p)));
164
+ if (neverFits.length > 0) {
165
+ try {
166
+ process.stderr.write(JSON.stringify({
167
+ ts: new Date().toISOString(),
168
+ kind: "hybrid_dispatch_node_never_fits",
169
+ node_ids: neverFits.map((n) => n.id).sort(),
170
+ active_pool_caps: active
171
+ .map((p) => ({ pool_id: p.id, context_cap_tokens: p.contextCapTokens ?? null }))
172
+ .sort((a, b) => a.pool_id.localeCompare(b.pool_id)),
173
+ }) + "\n");
174
+ }
175
+ catch {
176
+ // Observability must never abort a plan.
177
+ }
178
+ }
133
179
  return assignments;
134
180
  }
135
181
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../../src/shared/dispatch/coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAGH,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AA0EvF,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E,MAAM,OAAO,sBAAsB;IAChB,KAAK,CAAiB;IACtB,aAAa,CAAgB;IAC7B,aAAa,CAAgB;IAC7B,WAAW,CAA4B;IACvC,QAAQ,CAA4C;IAErE,YAAY,IAAmC;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACxC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,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CAAC,GAAG,IAAI,CACV,CAAC;YACJ,CAAC;YAAC,MAAM,CAAC;gBACP,yCAAyC;YAC3C,CAAC;QACH,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,UAAU,CAAC,MAAc;QAC7B,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC;YAAE,OAAO;QAC3C,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,CAAC,UAA0B;QACtC,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;OAMG;IACH,cAAc,CAAC,WAAqB;QAClC,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACzF,IAAI,CAAC,YAAY;YAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;QACnD,OAAO;YACL,IAAI,EAAE,qBAAqB;YAC3B,QAAQ,EAAE,sBAAsB,CAAC,WAAW,CAAC;SAC9C,CAAC;IACJ,CAAC;CACF"}
@@ -61,6 +61,12 @@ export interface HybridDispatchInput {
61
61
  * claiming each node to exactly one pool, and partition the claimed assignments by the
62
62
  * caller's in-process classification.
63
63
  *
64
+ * Per-pool packet-fit gate (U2): fit is enforced INSIDE the coordinator's claim walk
65
+ * (`nodeContextFits` in coordinator.ts) — a node is never CLAIMED to a pool whose
66
+ * declared context cap (plus agentic-harness overhead) it exceeds, so every assignment
67
+ * returned here is fit-guaranteed by construction. Repartitioning after the claim would
68
+ * strand the claim on the wrong pool id; that is why the gate is not here.
69
+ *
64
70
  * Behaviour falls out of the pool set with no special-casing:
65
71
  * - host-only pools → every node lands in `host`; `inProcess` empty.
66
72
  * - backend-only pools → every node lands in `inProcess`; `host` empty.
@@ -1 +1 @@
1
- {"version":3,"file":"hybridDispatch.d.ts","sourceRoot":"","sources":["../../../src/shared/dispatch/hybridDispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,sBAAsB,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,yFAAyF;AACzF,MAAM,WAAW,uBAAuB;IACtC,yEAAyE;IACzE,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,qEAAqE;IACrE,IAAI,EAAE,cAAc,EAAE,CAAC;IACvB;;;;OAIG;IACH,WAAW,EAAE,sBAAsB,CAAC;CACrC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,aAAa,EAAE,aAAa,CAAC;IAC7B,aAAa,EAAE,aAAa,CAAC;IAC7B,gFAAgF;IAChF,WAAW,EAAE,MAAM,mBAAmB,CAAC;IACvC,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD;;;;OAIG;IACH,WAAW,EAAE,CAAC,IAAI,EA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KAAE,KAAK,OAAO,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAerG"}
@@ -26,6 +26,12 @@ import { HybridSpillCoordinator } from "./coordinator.js";
26
26
  * claiming each node to exactly one pool, and partition the claimed assignments by the
27
27
  * caller's in-process classification.
28
28
  *
29
+ * Per-pool packet-fit gate (U2): fit is enforced INSIDE the coordinator's claim walk
30
+ * (`nodeContextFits` in coordinator.ts) — a node is never CLAIMED to a pool whose
31
+ * declared context cap (plus agentic-harness overhead) it exceeds, so every assignment
32
+ * returned here is fit-guaranteed by construction. Repartitioning after the claim would
33
+ * strand the claim on the wrong pool id; that is why the gate is not here.
34
+ *
29
35
  * Behaviour falls out of the pool set with no special-casing:
30
36
  * - host-only pools → every node lands in `host`; `inProcess` empty.
31
37
  * - backend-only pools → every node lands in `inProcess`; `host` empty.
@@ -1 +1 @@
1
- {"version":3,"file":"hybridDispatch.js","sourceRoot":"","sources":["../../../src/shared/dispatch/hybridDispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,sBAAsB,EAA0C,MAAM,kBAAkB,CAAC;AAqClG;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAA0B;IACjE,MAAM,WAAW,GAAG,IAAI,sBAAsB,CAAC;QAC7C,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACtE,MAAM,SAAS,GAA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I,EAAE,WAAW,EAAE,CAAC;AAC1C,CAAC"}
@@ -33,7 +33,8 @@ export interface ProviderLaunchFinalizeContext<TPacket> {
33
33
  * read-only-vs-git-mutating / AuditResult-vs-ImplementWorkerResult divergences.
34
34
  *
35
35
  * In order:
36
- * 1. not-accepted → error;
36
+ * 1. not-accepted → classify the failure text via the shared `classifyFailureChannels`
37
+ * helper (mirrors the accepted-but-no-result-file branch so both cannot drift);
37
38
  * 2. channel-isolated credit-exhaustion (TIER 1) then session-limit (TIER 1)
38
39
  * detection on stderr (CE-003) → credit_exhausted / non-consuming
39
40
  * rate_limited re-queue (the result file is never scanned for these strings);
@@ -1 +1 @@
1
- {"version":3,"file":"providerLaunchFinalize.d.ts","sourceRoot":"","sources":["../../../src/shared/dispatch/providerLaunchFinalize.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAEzF,MAAM,WAAW,6BAA6B,CAAC,OAAO;IACpD,4EAA4E;IAC5E,MAAM,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACvC,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,kFAAkF;IAClF,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,4BAA4B,CAAC,OAAO,EACxD,MAAM,EAAE,wBAAwB,EAChC,GAAG,EAAE,6BAA6B,CAAC,OAAO,CAAC,GAC1C,OAAO,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAsHzC"}
1
+ {"version":3,"file":"providerLaunchFinalize.d.ts","sourceRoot":"","sources":["../../../src/shared/dispatch/providerLaunchFinalize.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAEzF,MAAM,WAAW,6BAA6B,CAAC,OAAO;IACpD,4EAA4E;IAC5E,MAAM,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACvC,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,kFAAkF;IAClF,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAiHD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,4BAA4B,CAAC,OAAO,EACxD,MAAM,EAAE,wBAAwB,EAChC,GAAG,EAAE,6BAA6B,CAAC,OAAO,CAAC,GAC1C,OAAO,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAyEzC"}