@loucompanion/forge-bridge 0.1.3-dev.fbe15023cdfe → 0.1.4-dev.03584818ede5

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 (275) hide show
  1. package/README.md +146 -5
  2. package/dist/bridge/bridge-chat-provider-command.d.ts +16 -0
  3. package/dist/bridge/bridge-chat-provider-command.js +137 -0
  4. package/dist/bridge/bridge-chat.types.d.ts +121 -0
  5. package/dist/bridge/bridge-chat.types.js +416 -0
  6. package/dist/bridge/bridge.base.d.ts +13 -1
  7. package/dist/bridge/bridge.service.d.ts +155 -4
  8. package/dist/bridge/bridge.service.js +1805 -155
  9. package/dist/bridge/bridge.types.d.ts +68 -1
  10. package/dist/bridge/dispatch-result-outbox.d.ts +35 -0
  11. package/dist/bridge/dispatch-result-outbox.js +87 -0
  12. package/dist/bridge/dispatch-result-worker.d.ts +2 -0
  13. package/dist/bridge/dispatch-result-worker.js +122 -0
  14. package/dist/bridge/internals.d.ts +2 -0
  15. package/dist/bridge/internals.js +1 -0
  16. package/dist/bridge/local-yield-flag.d.ts +6 -0
  17. package/dist/bridge/local-yield-flag.js +34 -0
  18. package/dist/bridge/readiness-result-outbox.d.ts +21 -0
  19. package/dist/bridge/readiness-result-outbox.js +54 -0
  20. package/dist/bridge/readiness-result-worker.d.ts +2 -0
  21. package/dist/bridge/readiness-result-worker.js +121 -0
  22. package/dist/bridge/runner-host-capabilities.d.ts +20 -0
  23. package/dist/bridge/runner-host-capabilities.js +110 -0
  24. package/dist/bridge/test-postgres-capability.d.ts +14 -0
  25. package/dist/bridge/test-postgres-capability.js +120 -0
  26. package/dist/cleanup/cleanup.service.d.ts +10 -0
  27. package/dist/cleanup/cleanup.service.js +128 -104
  28. package/dist/cleanup/cleanup.types.d.ts +4 -0
  29. package/dist/cleanup/forge-owned-paths.d.ts +9 -0
  30. package/dist/cleanup/forge-owned-paths.js +53 -0
  31. package/dist/cleanup/host-runtime-ledger.d.ts +5 -0
  32. package/dist/cleanup/host-runtime-ledger.js +109 -0
  33. package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
  34. package/dist/cleanup/managed-branch-sweep.js +111 -0
  35. package/dist/cli/cli.help.js +22 -4
  36. package/dist/cli/cli.service.d.ts +30 -6
  37. package/dist/cli/cli.service.js +216 -31
  38. package/dist/cli/local-config.d.ts +5 -0
  39. package/dist/cli/local-config.js +30 -4
  40. package/dist/runtime/aspnet-runtime-prebuild.d.ts +36 -0
  41. package/dist/runtime/aspnet-runtime-prebuild.js +429 -0
  42. package/dist/runtime/attempt-database-broker.d.ts +89 -0
  43. package/dist/runtime/attempt-database-broker.js +390 -0
  44. package/dist/runtime/attempt-node-runtime-launcher.d.ts +2 -1
  45. package/dist/runtime/attempt-node-runtime-launcher.js +57 -18
  46. package/dist/runtime/attempt-path-operation.d.ts +21 -0
  47. package/dist/runtime/attempt-path-operation.js +94 -0
  48. package/dist/runtime/attempt-private-directory.d.ts +6 -0
  49. package/dist/runtime/attempt-private-directory.js +54 -0
  50. package/dist/runtime/attempt-process-supervisor.d.ts +35 -0
  51. package/dist/runtime/attempt-process-supervisor.js +144 -23
  52. package/dist/runtime/canonical-source-file.d.ts +3 -0
  53. package/dist/runtime/canonical-source-file.js +54 -0
  54. package/dist/runtime/docker-engine-probe.d.ts +90 -0
  55. package/dist/runtime/docker-engine-probe.js +333 -0
  56. package/dist/runtime/generated-output-reset.d.ts +10 -0
  57. package/dist/runtime/generated-output-reset.js +62 -8
  58. package/dist/runtime/host-database-capability-boundary.d.ts +16 -0
  59. package/dist/runtime/host-database-capability-boundary.js +63 -0
  60. package/dist/runtime/host-diagnostics.d.ts +11 -0
  61. package/dist/runtime/host-diagnostics.js +192 -0
  62. package/dist/runtime/host-execution-root.d.ts +4 -0
  63. package/dist/runtime/host-execution-root.js +39 -0
  64. package/dist/runtime/host-facts.d.ts +36 -0
  65. package/dist/runtime/host-facts.js +95 -0
  66. package/dist/runtime/host-listener-inspector.d.ts +8 -1
  67. package/dist/runtime/host-listener-inspector.js +121 -60
  68. package/dist/runtime/host-load-admission.d.ts +67 -0
  69. package/dist/runtime/host-load-admission.js +99 -0
  70. package/dist/runtime/host-load-child-environment.d.ts +27 -0
  71. package/dist/runtime/host-load-child-environment.js +76 -0
  72. package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
  73. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  74. package/dist/runtime/host-load-governor-config.d.ts +52 -0
  75. package/dist/runtime/host-load-governor-config.js +83 -0
  76. package/dist/runtime/host-load-governor.d.ts +184 -0
  77. package/dist/runtime/host-load-governor.js +632 -0
  78. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  79. package/dist/runtime/host-load-ledger-lock.js +185 -0
  80. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  81. package/dist/runtime/host-load-runtime-settings.js +78 -0
  82. package/dist/runtime/host-load-sampler.d.ts +149 -0
  83. package/dist/runtime/host-load-sampler.js +291 -0
  84. package/dist/runtime/host-load-step-class.d.ts +70 -0
  85. package/dist/runtime/host-load-step-class.js +161 -0
  86. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  87. package/dist/runtime/host-load-step-reaper.js +95 -0
  88. package/dist/runtime/host-load-step-run.d.ts +73 -0
  89. package/dist/runtime/host-load-step-run.js +102 -0
  90. package/dist/runtime/host-load-test-slot.d.ts +43 -0
  91. package/dist/runtime/host-load-test-slot.js +81 -0
  92. package/dist/runtime/host-load-token-ledger.d.ts +200 -0
  93. package/dist/runtime/host-load-token-ledger.js +453 -0
  94. package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
  95. package/dist/runtime/host-load-windows-cpu.js +85 -0
  96. package/dist/runtime/host-pressure-stall.d.ts +61 -0
  97. package/dist/runtime/host-pressure-stall.js +168 -0
  98. package/dist/runtime/host-runtime-contract.d.ts +16 -1
  99. package/dist/runtime/host-runtime-contract.js +174 -56
  100. package/dist/runtime/host-runtime-lease.d.ts +163 -9
  101. package/dist/runtime/host-runtime-lease.js +1464 -121
  102. package/dist/runtime/host-runtime-promotion.d.ts +35 -3
  103. package/dist/runtime/host-runtime-promotion.js +107 -12
  104. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  105. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  106. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  107. package/dist/runtime/host-runtime-requirements.js +117 -0
  108. package/dist/runtime/managed-command-teardown.d.ts +62 -0
  109. package/dist/runtime/managed-command-teardown.js +607 -0
  110. package/dist/runtime/memory-capacity.d.ts +70 -0
  111. package/dist/runtime/memory-capacity.js +123 -0
  112. package/dist/runtime/native-test-postgres-fallback.d.ts +25 -0
  113. package/dist/runtime/native-test-postgres-fallback.js +91 -0
  114. package/dist/runtime/node-host-runtime-adapter.d.ts +3 -0
  115. package/dist/runtime/node-host-runtime-adapter.js +29 -11
  116. package/dist/runtime/pinned-directory-process.d.ts +9 -0
  117. package/dist/runtime/pinned-directory-process.js +61 -0
  118. package/dist/runtime/pinned-source-directory.d.ts +17 -0
  119. package/dist/runtime/pinned-source-directory.js +94 -0
  120. package/dist/runtime/playwright-browser-cache.d.ts +39 -0
  121. package/dist/runtime/playwright-browser-cache.js +227 -0
  122. package/dist/runtime/playwright-host-runtime-adapter.d.ts +19 -0
  123. package/dist/runtime/playwright-host-runtime-adapter.js +113 -59
  124. package/dist/runtime/prepared-runtime-identity.d.ts +6 -0
  125. package/dist/runtime/prepared-runtime-identity.js +218 -0
  126. package/dist/runtime/prepared-runtime-readiness.d.ts +30 -0
  127. package/dist/runtime/prepared-runtime-readiness.js +285 -0
  128. package/dist/runtime/runner-settings.d.ts +100 -0
  129. package/dist/runtime/runner-settings.js +214 -0
  130. package/dist/runtime/runtime-isolation-lease.js +4 -1
  131. package/dist/runtime/workspace-resource-estimator.d.ts +17 -0
  132. package/dist/runtime/workspace-resource-estimator.js +174 -0
  133. package/dist/sandbox/host-capacity-broker.d.ts +113 -0
  134. package/dist/sandbox/host-capacity-broker.js +334 -0
  135. package/dist/sandbox/preflight.d.ts +31 -1
  136. package/dist/sandbox/preflight.js +237 -51
  137. package/dist/sandbox/repository-lock.d.ts +2 -1
  138. package/dist/sandbox/repository-lock.js +19 -9
  139. package/dist/sandbox/runtime.d.ts +16 -2
  140. package/dist/sandbox/runtime.js +182 -109
  141. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  142. package/dist/sandbox/sandbox-cgroups.js +42 -0
  143. package/dist/sandbox/sandbox.types.d.ts +7 -0
  144. package/dist/sandbox/workspace.service.js +2 -0
  145. package/dist/session/architect-waits.d.ts +2 -0
  146. package/dist/session/architect-waits.js +138 -0
  147. package/dist/session/managed-attempt-tools.d.ts +44 -1
  148. package/dist/session/managed-attempt-tools.js +816 -46
  149. package/dist/session/managed-build-coordinator.d.ts +5 -0
  150. package/dist/session/managed-build-coordinator.js +109 -0
  151. package/dist/session/managed-build-receipt.d.ts +21 -0
  152. package/dist/session/managed-build-receipt.js +337 -0
  153. package/dist/session/managed-command-host-load.d.ts +47 -0
  154. package/dist/session/managed-command-host-load.js +83 -0
  155. package/dist/session/managed-verification-timeouts.d.ts +8 -0
  156. package/dist/session/managed-verification-timeouts.js +17 -0
  157. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  158. package/dist/session/mcp-argument-coercion.js +121 -0
  159. package/dist/session/phase-completion.artifacts.d.ts +24 -0
  160. package/dist/session/phase-completion.artifacts.js +319 -44
  161. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  162. package/dist/session/phase-completion.command-validation.js +77 -0
  163. package/dist/session/phase-completion.d.ts +15 -1
  164. package/dist/session/phase-completion.helpers.d.ts +5 -0
  165. package/dist/session/phase-completion.helpers.js +43 -19
  166. package/dist/session/phase-completion.js +18 -3
  167. package/dist/session/phase-completion.prompts.js +22 -18
  168. package/dist/session/phase-completion.runtime.d.ts +6 -2
  169. package/dist/session/phase-completion.runtime.js +191 -47
  170. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  171. package/dist/session/phase-completion.schema-parts.js +188 -0
  172. package/dist/session/phase-completion.schemas.d.ts +3 -3
  173. package/dist/session/phase-completion.schemas.js +250 -226
  174. package/dist/session/phase-completion.validation.d.ts +3 -3
  175. package/dist/session/phase-completion.validation.js +135 -89
  176. package/dist/session/pre-publication-host-load.d.ts +27 -0
  177. package/dist/session/pre-publication-host-load.js +111 -0
  178. package/dist/session/pre-publication-pass.d.ts +61 -0
  179. package/dist/session/pre-publication-pass.js +148 -0
  180. package/dist/session/pre-publication-process.d.ts +23 -0
  181. package/dist/session/pre-publication-process.js +109 -0
  182. package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
  183. package/dist/session/pre-publication-skipped-tests.js +109 -0
  184. package/dist/session/pre-publication-step-execution.d.ts +11 -0
  185. package/dist/session/pre-publication-step-execution.js +49 -0
  186. package/dist/session/pre-publication-validation.d.ts +87 -0
  187. package/dist/session/pre-publication-validation.js +668 -0
  188. package/dist/session/provider-cli/bridge-cli.conformance-fixtures.d.ts +72 -0
  189. package/dist/session/provider-cli/bridge-cli.conformance-fixtures.js +462 -0
  190. package/dist/session/provider-cli/ci-repair-readiness.d.ts +8 -0
  191. package/dist/session/provider-cli/ci-repair-readiness.js +23 -3
  192. package/dist/session/provider-cli/claude-background-work.d.ts +66 -0
  193. package/dist/session/provider-cli/claude-background-work.js +180 -0
  194. package/dist/session/provider-cli/pre-publication-repair.d.ts +40 -0
  195. package/dist/session/provider-cli/pre-publication-repair.js +243 -0
  196. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +6 -3
  197. package/dist/session/provider-cli/provider-cli.artifacts.js +62 -22
  198. package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
  199. package/dist/session/provider-cli/provider-cli.child-environment.js +73 -0
  200. package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
  201. package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
  202. package/dist/session/provider-cli/provider-cli.deterministic.js +34 -2
  203. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
  204. package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
  205. package/dist/session/provider-cli/provider-cli.process.d.ts +92 -14
  206. package/dist/session/provider-cli/provider-cli.process.js +583 -210
  207. package/dist/session/provider-cli/provider-cli.prompts.d.ts +12 -0
  208. package/dist/session/provider-cli/provider-cli.prompts.js +200 -25
  209. package/dist/session/provider-cli/provider-cli.repair-epoch.d.ts +6 -0
  210. package/dist/session/provider-cli/provider-cli.repair-epoch.js +11 -0
  211. package/dist/session/provider-cli/provider-cli.runtime.d.ts +14 -1
  212. package/dist/session/provider-cli/provider-cli.runtime.js +61 -3
  213. package/dist/session/provider-cli/provider-cli.service.d.ts +33 -5
  214. package/dist/session/provider-cli/provider-cli.service.js +819 -84
  215. package/dist/session/provider-cli/provider-cli.types.d.ts +32 -0
  216. package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
  217. package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
  218. package/dist/session/provider-cli/provider-in-flight-work.d.ts +10 -0
  219. package/dist/session/provider-cli/provider-in-flight-work.js +92 -0
  220. package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
  221. package/dist/session/provider-cli/provider-output-pipes.js +67 -0
  222. package/dist/session/provider-cli/provider-output-state.d.ts +18 -0
  223. package/dist/session/provider-cli/provider-output-state.js +376 -17
  224. package/dist/session/provider-cli/provider-usage.d.ts +9 -1
  225. package/dist/session/provider-cli/provider-usage.js +28 -5
  226. package/dist/session/publishable-worktree-changes.d.ts +54 -0
  227. package/dist/session/publishable-worktree-changes.js +193 -0
  228. package/dist/session/sandbox-host-capacity-gate.d.ts +30 -0
  229. package/dist/session/sandbox-host-capacity-gate.js +238 -0
  230. package/dist/session/session-redaction.js +434 -9
  231. package/dist/session/session.base.d.ts +9 -1
  232. package/dist/session/session.service.d.ts +9 -2
  233. package/dist/session/session.service.js +264 -27
  234. package/dist/session/session.types.d.ts +150 -2
  235. package/dist/session/session.types.js +599 -7
  236. package/dist/session/unreferenced-exports.d.ts +12 -0
  237. package/dist/session/unreferenced-exports.js +59 -0
  238. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  239. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  240. package/dist/shared/format/format-bytes.d.ts +1 -0
  241. package/dist/shared/format/format-bytes.js +9 -0
  242. package/dist/shared/git/git.js +2 -1
  243. package/dist/shared/path/path.d.ts +1 -0
  244. package/dist/shared/path/path.js +18 -0
  245. package/dist/shared/process/dotnet-toolchain.d.ts +17 -0
  246. package/dist/shared/process/dotnet-toolchain.js +307 -0
  247. package/dist/shared/process/host-process-recovery.js +3 -2
  248. package/dist/shared/process/host-process-supervisor.d.ts +3 -0
  249. package/dist/shared/process/host-process-supervisor.js +61 -12
  250. package/dist/shared/process/process-tree.d.ts +52 -0
  251. package/dist/shared/process/process-tree.js +144 -0
  252. package/dist/shared/process/process.d.ts +69 -0
  253. package/dist/shared/process/process.js +223 -16
  254. package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
  255. package/dist/shared/process/windows-app-execution-alias.js +45 -0
  256. package/dist/shared/process/windows-launch.d.ts +18 -0
  257. package/dist/shared/process/windows-launch.js +68 -0
  258. package/dist/shared/provider-capabilities.d.ts +3 -0
  259. package/dist/shared/provider-capabilities.js +84 -0
  260. package/dist/shared/redaction/redaction.d.ts +1 -0
  261. package/dist/shared/redaction/redaction.js +39 -3
  262. package/dist/shared/time/monotonic.d.ts +1 -0
  263. package/dist/shared/time/monotonic.js +8 -0
  264. package/dist/version.d.ts +1 -1
  265. package/dist/version.js +1 -1
  266. package/dist/worktree/dependency-warmer.d.ts +66 -9
  267. package/dist/worktree/dependency-warmer.js +609 -24
  268. package/dist/worktree/index.d.ts +1 -1
  269. package/dist/worktree/story-qa-reference-hydrator.d.ts +4 -0
  270. package/dist/worktree/story-qa-reference-hydrator.js +253 -0
  271. package/dist/worktree/worktree.service.d.ts +17 -1
  272. package/dist/worktree/worktree.service.js +293 -21
  273. package/dist/worktree/worktree.types.d.ts +14 -1
  274. package/package.json +8 -6
  275. package/runtime/windows-job-supervisor.ps1 +380 -14
@@ -1,13 +1,13 @@
1
1
  import { type CompletionPhase, type DebugCompletionPhase, type QaCompletionGate } from "./phase-completion.js";
2
+ export { validateQaGatePassingCommands } from "./phase-completion.command-validation.js";
3
+ export declare const qaEvidenceGates: ReadonlySet<QaCompletionGate>;
2
4
  export declare function normalizeCompletionStatus(value: string, phase?: CompletionPhase): string;
3
5
  export declare function normalizeQaGateStatus(value: string): string;
4
6
  export declare function validatePayloadShape(phase: CompletionPhase, payload: Record<string, unknown>): void;
7
+ export declare function validateCommentRepairPayloadShape(payload: Record<string, unknown>): void;
5
8
  export declare function validateCiRepairPayloadShape(payload: Record<string, unknown>): void;
6
9
  export declare function validateDebugPayloadShape(phase: DebugCompletionPhase, payload: Record<string, unknown>): void;
7
10
  export declare function validateQaGatePayloadShape(gate: QaCompletionGate, payload: Record<string, unknown>, status: string): void;
8
- export declare function validateQaGatePassingCommands(commands: readonly unknown[], options?: {
9
- readonly allowClassifiedNonBlockingFailures?: boolean;
10
- }): void;
11
11
  export declare function validateArchitectPayloadShape(payload: Record<string, unknown>, status: string): void;
12
12
  export declare function validateArchitectTaskDevelopScope(task: Record<string, unknown>, taskId: string): void;
13
13
  export declare function validateArchitectVerificationScope(task: Record<string, unknown>, taskId: string): void;
@@ -1,4 +1,9 @@
1
- import { qaBlockerReasons, qaCandidateBugActions, qaFindingScopes, qaFindingSeverities, qaGateToolNames, qaScopeAuthorities, qaScopeConfidence, qaScopeEvidence, qaScopeFields, qaScopeSources, qaScopeSurfaces } from "./phase-completion.js";
1
+ import { qaBlockerReasons, qaCandidateBugActions, qaFindingScopes, qaFindingSeverities, qaGateToolNames, qaScopeAuthorities, qaScopeCapabilities, qaScopeConfidence, qaScopeEvidence, qaScopeFields, qaScopeSources, qaScopeSurfaces } from "./phase-completion.js";
2
+ import { structuredTypeHint } from "./mcp-argument-coercion.js";
3
+ import { validateArchitectWaits } from "./architect-waits.js";
4
+ import { validateQaGatePassingCommands } from "./phase-completion.command-validation.js";
5
+ export { validateQaGatePassingCommands } from "./phase-completion.command-validation.js";
6
+ export const qaEvidenceGates = new Set(["qa_regression", "qa_api", "qa_manual_web", "qa_bug_repro"]);
2
7
  export function normalizeCompletionStatus(value, phase) {
3
8
  const normalized = value.trim().toLowerCase().replace(/-/g, "_");
4
9
  if (phase === "qa") {
@@ -55,6 +60,10 @@ export function validatePayloadShape(phase, payload) {
55
60
  validateCiRepairPayloadShape(payload);
56
61
  return;
57
62
  }
63
+ if (phase === "comment_repair") {
64
+ validateCommentRepairPayloadShape(payload);
65
+ return;
66
+ }
58
67
  if (isDebugCompletionPhase(phase)) {
59
68
  validateDebugPayloadShape(phase, payload);
60
69
  return;
@@ -101,6 +110,65 @@ export function validatePayloadShape(phase, payload) {
101
110
  requirePassingCommands(payload);
102
111
  requireSatisfiedAcceptanceCriteria(payload);
103
112
  }
113
+ export function validateCommentRepairPayloadShape(payload) {
114
+ requireNonEmptyStringRecord(payload, "repair_head_sha", "");
115
+ requireNonEmptyStringRecord(payload, "repair_issue_key", "");
116
+ requireArray(payload, "dispositions");
117
+ requireNonEmptyArray(payload, "dispositions");
118
+ const seen = new Set();
119
+ let hasFixed = false;
120
+ for (const [index, entry] of payload.dispositions.entries()) {
121
+ requireEvidenceRecord(entry, `dispositions[${index}]`);
122
+ const record = entry;
123
+ for (const key of ["claim_id", "kind", "body_sha256", "disposition", "evidence"]) {
124
+ requireNonEmptyStringRecord(record, key, `dispositions[${index}].`);
125
+ }
126
+ requireKnownStringRecord(record, "kind", new Set(["review_thread", "review_body", "issue_comment"]), `dispositions[${index}].`);
127
+ requireKnownStringRecord(record, "disposition", new Set(["fixed", "rejected", "already_addressed", "needs_decision", "accepted_transfer", "owned_elsewhere"]), `dispositions[${index}].`);
128
+ if (record.disposition === "owned_elsewhere") {
129
+ const receipt = record.owned_elsewhere;
130
+ if (!receipt || typeof receipt !== "object" || Array.isArray(receipt))
131
+ throw new Error("owned_elsewhere requires the owning Story and its quoted obligation; server verification remains mandatory.");
132
+ const owner = receipt;
133
+ if (typeof owner.target_work_item_id !== "string" || !owner.target_work_item_id.trim())
134
+ throw new Error("owned_elsewhere.target_work_item_id is required.");
135
+ if (typeof owner.quoted_obligation !== "string" || owner.quoted_obligation.trim().length < 40)
136
+ throw new Error("owned_elsewhere.quoted_obligation must quote at least 40 characters of the owning Story's acceptance criteria.");
137
+ }
138
+ if (record.disposition === "accepted_transfer") {
139
+ const receipt = record.accepted_transfer;
140
+ if (!receipt || typeof receipt !== "object" || Array.isArray(receipt))
141
+ throw new Error("accepted_transfer requires an approved amendment receipt; server verification remains mandatory.");
142
+ const transfer = receipt;
143
+ for (const key of ["amendment_id", "content_hash", "target_work_item_id", "obligation_reference"]) {
144
+ if (typeof transfer[key] !== "string" || !transfer[key].trim())
145
+ throw new Error(`accepted_transfer.${key} is required.`);
146
+ }
147
+ if (!Number.isInteger(transfer.version) || Number(transfer.version) < 1)
148
+ throw new Error("accepted_transfer.version must be positive.");
149
+ }
150
+ const identity = `${normalizedString(optionalString(record, "kind"))}:${optionalString(record, "claim_id")}:${normalizedString(optionalString(record, "body_sha256"))}`;
151
+ if (seen.has(identity))
152
+ throw new Error(`dispositions[${index}] duplicates finding ${identity}.`);
153
+ seen.add(identity);
154
+ hasFixed ||= normalizedString(optionalString(record, "disposition")) === "fixed";
155
+ }
156
+ requireArray(payload, "changed_files");
157
+ requireArray(payload, "validation");
158
+ for (const [index, changedFile] of payload.changed_files.entries()) {
159
+ requireEvidenceRecord(changedFile, `changed_files[${index}]`);
160
+ const record = changedFile;
161
+ requireNonEmptyStringRecord(record, "path", `changed_files[${index}].`);
162
+ requireNonEmptyStringRecord(record, "summary", `changed_files[${index}].`);
163
+ }
164
+ if (hasFixed && arrayLength(payload, "changed_files") === 0) {
165
+ throw new Error("changed_files must include at least one entry when any disposition is fixed.");
166
+ }
167
+ if (arrayLength(payload, "changed_files") > 0) {
168
+ requireNonEmptyArray(payload, "validation");
169
+ validateQaGatePassingCommands(payload.validation, { label: "validation", context: "status is pass" });
170
+ }
171
+ }
104
172
  export function validateCiRepairPayloadShape(payload) {
105
173
  requireArray(payload, "failed_checks");
106
174
  requireNonEmptyArray(payload, "failed_checks");
@@ -133,7 +201,7 @@ export function validateCiRepairPayloadShape(payload) {
133
201
  for (const key of ["narrow_validation", "broader_validation"]) {
134
202
  requireArray(payload, key);
135
203
  requireNonEmptyArray(payload, key);
136
- validateQaGatePassingCommands(payload[key]);
204
+ validateQaGatePassingCommands(payload[key], { label: key, context: "status is pass" });
137
205
  }
138
206
  requireArray(payload, "workflow_validation");
139
207
  requireNonEmptyArray(payload, "workflow_validation");
@@ -213,6 +281,34 @@ export function validateDebugPayloadShape(phase, payload) {
213
281
  requireNonEmptyArray(payload, "required_regressions");
214
282
  requirePassingCommands(payload);
215
283
  }
284
+ // Shared by the QA evidence gates and the final verdict: gate evidence is inherited into the
285
+ // verdict, so a gate must reject what the verdict would reject.
286
+ function validateQaBrowserCheckEntries(browserChecks, status) {
287
+ for (const [index, browserCheck] of browserChecks.entries()) {
288
+ requireEvidenceRecord(browserCheck, `browser_checks[${index}]`);
289
+ const record = browserCheck;
290
+ requireNonEmptyStringRecord(record, "summary", `browser_checks[${index}].`);
291
+ requireNonEmptyStringRecord(record, "status", `browser_checks[${index}].`);
292
+ const checkStatus = optionalString(record, "status");
293
+ if (status === "pass" && checkStatus && normalizedString(checkStatus) !== "pass") {
294
+ throw new Error(`browser_checks[${index}].status must be pass when QA status is pass.`);
295
+ }
296
+ if (!optionalString(record, "url") && !optionalString(record, "route")) {
297
+ throw new Error(`browser_checks[${index}].url is required unless browser_checks[${index}].route is given.`);
298
+ }
299
+ }
300
+ }
301
+ function validateQaSidecarEntries(sidecars) {
302
+ for (const [index, sidecar] of sidecars.entries()) {
303
+ requireEvidenceRecord(sidecar, `sidecars[${index}]`);
304
+ const record = sidecar;
305
+ requireNonEmptyStringRecord(record, "path", `sidecars[${index}].`);
306
+ requireNonEmptyStringRecord(record, "content_hash", `sidecars[${index}].`);
307
+ if (typeof record.bytes !== "number" || !Number.isFinite(record.bytes) || record.bytes <= 0) {
308
+ throw new Error(`sidecars[${index}].bytes must be greater than 0.`);
309
+ }
310
+ }
311
+ }
216
312
  export function validateQaGatePayloadShape(gate, payload, status) {
217
313
  requireField(payload, "summary");
218
314
  if (status === "skipped") {
@@ -230,6 +326,12 @@ export function validateQaGatePayloadShape(gate, payload, status) {
230
326
  throw new Error("complete_qa_plan pass requires checklist with at least one entry.");
231
327
  }
232
328
  }
329
+ if (qaEvidenceGates.has(gate)) {
330
+ // Every evidence gate's sidecars are merged into the final verdict, so a
331
+ // malformed value must be rejected here, not when the verdict is assembled.
332
+ validateQaSidecarEntries(qaArray(payload, "sidecars", qaEvidenceSource(payload)));
333
+ validateQaBrowserCheckEntries(qaArray(payload, "browser_checks"), status);
334
+ }
233
335
  if (gate === "qa_findings" && status !== "blocked") {
234
336
  qaObjectArray(payload, "findings");
235
337
  qaObjectArray(payload, "candidate_bugs");
@@ -251,57 +353,8 @@ export function validateQaGatePayloadShape(gate, payload, status) {
251
353
  }
252
354
  }
253
355
  }
254
- export function validateQaGatePassingCommands(commands, options = {}) {
255
- for (const [index, command] of commands.entries()) {
256
- requireEvidenceRecord(command, `commands[${index}]`);
257
- const record = command;
258
- requireNonEmptyStringRecord(record, "command", `commands[${index}].`);
259
- requireNonEmptyStringRecord(record, "status", `commands[${index}].`);
260
- requireNonEmptyStringRecord(record, "summary", `commands[${index}].`);
261
- if (typeof record.exit_code !== "number" || !Number.isFinite(record.exit_code)) {
262
- throw new Error(`commands[${index}].exit_code is required.`);
263
- }
264
- const passed = record.exit_code === 0 && normalizedString(record.status) === "pass";
265
- if (!passed
266
- && options.allowClassifiedNonBlockingFailures
267
- && optionalString(record, "classification")) {
268
- validateClassifiedNonBlockingQaFailure(record, index);
269
- continue;
270
- }
271
- if (record.exit_code !== 0) {
272
- throw new Error(`commands[${index}].exit_code must be 0 when QA gate status is pass.`);
273
- }
274
- if (normalizedString(record.status) !== "pass") {
275
- throw new Error(`commands[${index}].status must be pass when QA gate status is pass.`);
276
- }
277
- }
278
- }
279
- function validateClassifiedNonBlockingQaFailure(record, index) {
280
- const classification = normalizedString(optionalString(record, "classification"));
281
- if (classification !== "out_of_scope_failure" && classification !== "baseline_failure") {
282
- throw new Error(`commands[${index}] is non-passing; QA regression pass requires classification out_of_scope_failure or baseline_failure with corroborating evidence.`);
283
- }
284
- requireNonEmptyStringRecord(record, "candidate_bug_id", `commands[${index}].`);
285
- requireNonEmptyStringRecord(record, "scope_evidence", `commands[${index}].`);
286
- if (record.acceptance_criteria_independent !== true) {
287
- throw new Error(`commands[${index}].acceptance_criteria_independent must be true for a non-blocking QA regression failure.`);
288
- }
289
- if (classification === "out_of_scope_failure") {
290
- requireNonEmptyStringRecord(record, "repro_command", `commands[${index}].`);
291
- if (typeof record.repro_exit_code !== "number" || !Number.isFinite(record.repro_exit_code) || record.repro_exit_code === 0) {
292
- throw new Error(`commands[${index}].repro_exit_code must be a non-zero number for an out-of-scope failure.`);
293
- }
294
- return;
295
- }
296
- requireNonEmptyStringRecord(record, "baseline_ref", `commands[${index}].`);
297
- if (typeof record.baseline_exit_code !== "number" || !Number.isFinite(record.baseline_exit_code) || record.baseline_exit_code === 0) {
298
- throw new Error(`commands[${index}].baseline_exit_code must be a non-zero number for a baseline failure.`);
299
- }
300
- if (record.failure_signature_match !== true) {
301
- throw new Error(`commands[${index}].failure_signature_match must be true for a baseline failure.`);
302
- }
303
- }
304
356
  export function validateArchitectPayloadShape(payload, status) {
357
+ validateArchitectWaits(payload, status);
305
358
  if (status !== "pass") {
306
359
  requireArchitectNonPassEvidence(payload);
307
360
  return;
@@ -318,18 +371,22 @@ export function validateArchitectPayloadShape(payload, status) {
318
371
  throw new Error("implementation_plan.tasks: expected non-empty array; correction: include at least one task with id and tests.");
319
372
  }
320
373
  const taskIds = new Set();
321
- for (const task of implementationPlan.tasks) {
374
+ const taskIndexById = new Map();
375
+ for (const [taskIndex, task] of implementationPlan.tasks.entries()) {
322
376
  if (!task || typeof task !== "object" || Array.isArray(task)) {
323
377
  throw new Error("implementation_plan.tasks[]: expected object entries; correction: each task must be an object with id and tests.");
324
378
  }
325
379
  const taskRecord = task;
326
380
  requireNonEmptyStringRecord(taskRecord, "id", "implementation_plan.tasks[].");
327
381
  const taskId = optionalString(taskRecord, "id") ?? "";
328
- if (taskIds.has(taskId)) {
329
- throw new Error(`implementation_plan.tasks: duplicate task id '${taskId}'.`);
382
+ const firstTaskIndex = taskIndexById.get(taskId);
383
+ if (firstTaskIndex !== undefined) {
384
+ throw new Error(`implementation_plan.tasks[${taskIndex}].id duplicates implementation_plan.tasks[${firstTaskIndex}].id '${taskId}'; correction: assign the duplicate a unique stable task id, update every phase/dependency reference to that task, and resubmit forge.complete_architect_plan.`);
330
385
  }
331
386
  taskIds.add(taskId);
387
+ taskIndexById.set(taskId, taskIndex);
332
388
  validateArchitectTaskDevelopScope(taskRecord, taskId);
389
+ requireNonEmptyStringArrayRecord(taskRecord, "acceptance_criteria", `implementation_plan.tasks[${taskId}].`);
333
390
  validateArchitectVerificationScope(taskRecord, taskId);
334
391
  requireArchitectArray(taskRecord, "tests", payload, { path: `implementation_plan.tasks[${optionalString(taskRecord, "id") ?? "?"}].tests` });
335
392
  if (arrayLength(taskRecord, "tests") === 0) {
@@ -373,6 +430,7 @@ export function validateQaScopeRecord(scope, pathLabel) {
373
430
  }
374
431
  const surface = qaScopeStringArray(scope, "surface", pathLabel, qaScopeSurfaces);
375
432
  const requiredEvidence = qaScopeStringArray(scope, "required_evidence", pathLabel, qaScopeEvidence);
433
+ qaScopeStringArray(scope, "required_capabilities", pathLabel, qaScopeCapabilities);
376
434
  const notApplicable = qaScopeStringArray(scope, "not_applicable", pathLabel, qaScopeEvidence);
377
435
  const requiredSet = new Set(requiredEvidence);
378
436
  for (const evidence of notApplicable) {
@@ -650,7 +708,7 @@ export function hasArchitectDependencyCycle(edges) {
650
708
  return false;
651
709
  }
652
710
  export function requireArchitectNonPassEvidence(payload) {
653
- const evidenceKeys = ["blockers", "revision_questions", "revision_reasons", "known_gaps", "findings", "remaining_risks", "failures"];
711
+ const evidenceKeys = ["blockers", "revision_questions", "revision_reasons", "waits_on", "owner_decision", "known_gaps", "findings", "remaining_risks", "failures"];
654
712
  const hasEvidence = evidenceKeys.some((key) => {
655
713
  const value = payload[key];
656
714
  if (typeof value === "string") {
@@ -712,47 +770,35 @@ export function validateQaPayloadShape(payload, status) {
712
770
  throw new Error("QA pass/needs_rework requires tested_acceptance_criteria with at least one criterion.");
713
771
  }
714
772
  if (commands.length === 0 && browserChecks.length === 0 && notes.length === 0) {
715
- throw new Error("QA pass/needs_rework requires at least one command, browser check, or evidence note.");
773
+ throw new Error("QA pass/needs_rework requires at least one entry in commands or browser_checks, or a non-empty notes string.");
716
774
  }
717
775
  }
776
+ const commandIssues = [];
718
777
  for (const [index, command] of commands.entries()) {
719
- requireEvidenceRecord(command, `commands[${index}]`);
778
+ if (!command || typeof command !== "object" || Array.isArray(command)) {
779
+ commandIssues.push(`commands[${index}] must be an object${structuredTypeHint(command, "object")}.`);
780
+ continue;
781
+ }
720
782
  const record = command;
721
- requireNonEmptyStringRecord(record, "command", `commands[${index}].`);
722
- requireNonEmptyStringRecord(record, "status", `commands[${index}].`);
723
- requireNonEmptyStringRecord(record, "summary", `commands[${index}].`);
783
+ if (!optionalString(record, "command"))
784
+ commandIssues.push(`commands[${index}].command is required.`);
785
+ if (!optionalString(record, "status"))
786
+ commandIssues.push(`commands[${index}].status is required.`);
787
+ if (!optionalString(record, "summary"))
788
+ commandIssues.push(`commands[${index}].summary is required.`);
724
789
  if (typeof record.exit_code !== "number" || !Number.isFinite(record.exit_code)) {
725
- throw new Error(`commands[${index}].exit_code is required.`);
790
+ commandIssues.push(`commands[${index}].exit_code is required.`);
726
791
  }
727
- if (status === "pass" && record.exit_code !== 0) {
728
- throw new Error(`commands[${index}].exit_code must be 0 when QA status is pass.`);
792
+ else if (status === "pass" && record.exit_code !== 0) {
793
+ commandIssues.push(`commands[${index}].exit_code must be 0 when QA status is pass.`);
729
794
  }
730
795
  if (status === "pass" && normalizedString(record.status) !== "pass") {
731
- throw new Error(`commands[${index}].status must be pass when QA status is pass.`);
732
- }
733
- }
734
- for (const [index, browserCheck] of browserChecks.entries()) {
735
- requireEvidenceRecord(browserCheck, `browser_checks[${index}]`);
736
- const record = browserCheck;
737
- requireNonEmptyStringRecord(record, "summary", `browser_checks[${index}].`);
738
- requireNonEmptyStringRecord(record, "status", `browser_checks[${index}].`);
739
- const checkStatus = optionalString(record, "status");
740
- if (status === "pass" && checkStatus && normalizedString(checkStatus) !== "pass") {
741
- throw new Error(`browser_checks[${index}].status must be pass when QA status is pass.`);
742
- }
743
- if (!optionalString(record, "url") && !optionalString(record, "route")) {
744
- throw new Error(`browser_checks[${index}] must include url or route.`);
745
- }
746
- }
747
- for (const [index, sidecar] of sidecars.entries()) {
748
- requireEvidenceRecord(sidecar, `sidecars[${index}]`);
749
- const record = sidecar;
750
- requireNonEmptyStringRecord(record, "path", `sidecars[${index}].`);
751
- requireNonEmptyStringRecord(record, "content_hash", `sidecars[${index}].`);
752
- if (typeof record.bytes !== "number" || !Number.isFinite(record.bytes) || record.bytes <= 0) {
753
- throw new Error(`sidecars[${index}].bytes must be greater than 0.`);
796
+ commandIssues.push(`commands[${index}].status must be pass when QA status is pass.`);
754
797
  }
755
798
  }
799
+ throwCompletionPayloadIssues(commandIssues);
800
+ validateQaBrowserCheckEntries(browserChecks, status);
801
+ validateQaSidecarEntries(sidecars);
756
802
  for (const [index, finding] of findings.entries()) {
757
803
  requireNonEmptyStringRecord(finding, "id", `findings[${index}].`);
758
804
  requireNonEmptyStringRecord(finding, "title", `findings[${index}].`);
@@ -794,7 +840,7 @@ export function validateQaPayloadShape(payload, status) {
794
840
  }
795
841
  if (status === "needs_rework") {
796
842
  if (inScopeFindingIds.length === 0) {
797
- throw new Error("QA needs_rework requires at least one actionable in-scope finding.");
843
+ throw new Error("QA needs_rework requires at least one actionable in-scope finding: add an entry to findings with scope: in_scope.");
798
844
  }
799
845
  if (optionalString(payload, "blocker_reason")) {
800
846
  throw new Error("QA needs_rework must not include blocker_reason.");
@@ -824,5 +870,5 @@ export function validateOptionalWorkItemId(payload, expectedWorkItemId) {
824
870
  throw new Error(`completion payload work item ${actual} does not match dispatch work item ${expectedWorkItemId}.`);
825
871
  }
826
872
  }
827
- import { requireField, requireNonPassEvidence, requireImplementationEvidence, requirePassingCommands, requireArray, requireNonEmptyArray, arrayLength, requireAllowedStatus, requireObject, requiredRecord, requireBoolean, requireNumericOne, requireSatisfiedAcceptanceCriteria, validateResolvedFindings, isDebugCompletionPhase, qaEvidenceSource, qaArray, qaObjectArray, qaPolicyWarnings, qaStringArray, requireEvidenceRecord, requireNonEmptyStringRecord, requireKnownStringRecord, requireNonEmptyStringArrayRecord, requireSubstantiveEvidenceRecord, normalizedString, requiredString, optionalString, stripUndefined, } from "./phase-completion.helpers.js";
873
+ import { requireField, requireNonPassEvidence, requireImplementationEvidence, requirePassingCommands, requireArray, requireNonEmptyArray, arrayLength, requireAllowedStatus, requireObject, requiredRecord, requireBoolean, requireNumericOne, requireSatisfiedAcceptanceCriteria, validateResolvedFindings, isDebugCompletionPhase, qaEvidenceSource, qaArray, qaObjectArray, qaPolicyWarnings, qaStringArray, requireEvidenceRecord, requireNonEmptyStringRecord, requireKnownStringRecord, requireNonEmptyStringArrayRecord, requireSubstantiveEvidenceRecord, normalizedString, requiredString, optionalString, stripUndefined, throwCompletionPayloadIssues, } from "./phase-completion.helpers.js";
828
874
  export * from "./phase-completion.helpers.js";
@@ -0,0 +1,27 @@
1
+ import { type HostLoadStepGate } from "../runtime/host-load-governor.js";
2
+ import { type HostLoadTokenPriority } from "../runtime/host-load-token-ledger.js";
3
+ import type { RunnerDispatchEvent } from "./session.types.js";
4
+ /** Which attempt a governed validation step belongs to, and its queue class. */
5
+ export interface PrePublicationHostLoadOwner {
6
+ readonly dispatchAttemptId: string | null;
7
+ readonly priority: HostLoadTokenPriority;
8
+ }
9
+ export interface GovernedValidationStep {
10
+ readonly checkId: string;
11
+ readonly command: string;
12
+ readonly args: readonly string[];
13
+ readonly owner?: PrePublicationHostLoadOwner;
14
+ readonly signal?: AbortSignal;
15
+ readonly emit?: (event: RunnerDispatchEvent) => Promise<void>;
16
+ }
17
+ /**
18
+ * Runs one pre-publication step behind the host load governor (decision 0013).
19
+ * With the governor off this is a direct call, so behavior is unchanged. With
20
+ * it on, the step waits for admission first; queue time is reported as
21
+ * `host_load_wait_ms` with status `waiting_for_host_capacity`, and the step's
22
+ * own clock (`elapsed_ms`) starts only once it is admitted. `run` gets the
23
+ * signal to launch with: it also aborts when the step's reservation is lost
24
+ * (token fenced, or not renewable for a lease), and the step then fails with
25
+ * that error instead of running on unaccounted.
26
+ */
27
+ export declare function runHostGovernedValidationStep<T>(gate: HostLoadStepGate | undefined, step: GovernedValidationStep, run: (signal: AbortSignal | undefined) => Promise<T>): Promise<T>;
@@ -0,0 +1,111 @@
1
+ import { monotonicNowMs } from "../shared/time/monotonic.js";
2
+ import { HostCapacityTimeoutError } from "../runtime/host-load-governor.js";
3
+ import { HostCapacityLedgerUnavailableError } from "../runtime/host-load-ledger-lock.js";
4
+ import { retentionFor, returnHostLoadToken } from "../runtime/host-load-step-run.js";
5
+ import { classifyValidationStep } from "../runtime/host-load-step-class.js";
6
+ import { HostCapacityTokenFencedError } from "../runtime/host-load-token-ledger.js";
7
+ /**
8
+ * Runs one pre-publication step behind the host load governor (decision 0013).
9
+ * With the governor off this is a direct call, so behavior is unchanged. With
10
+ * it on, the step waits for admission first; queue time is reported as
11
+ * `host_load_wait_ms` with status `waiting_for_host_capacity`, and the step's
12
+ * own clock (`elapsed_ms`) starts only once it is admitted. `run` gets the
13
+ * signal to launch with: it also aborts when the step's reservation is lost
14
+ * (token fenced, or not renewable for a lease), and the step then fails with
15
+ * that error instead of running on unaccounted.
16
+ */
17
+ export async function runHostGovernedValidationStep(gate, step, run) {
18
+ if (!gate?.enabled)
19
+ return await run(step.signal);
20
+ const { stepClass, cost } = classifyValidationStep(step.checkId, step.command, step.args);
21
+ const base = { checkId: step.checkId, contractId: "forge-ci-parity-v1", stepClass };
22
+ const emit = async (eventType, content, data, kind = "checkpoint") => {
23
+ await step.emit?.({ role: "runner", kind, content, eventType, data: JSON.stringify({ ...base, ...data }) })
24
+ .catch(() => undefined);
25
+ };
26
+ let admission;
27
+ try {
28
+ admission = await gate.acquire({
29
+ stepClass,
30
+ label: step.checkId,
31
+ cost,
32
+ dispatchAttemptId: step.owner?.dispatchAttemptId ?? null,
33
+ priority: step.owner?.priority ?? "foreground",
34
+ }, {
35
+ signal: step.signal,
36
+ onWaiting: async (decision) => await emit("prepublication_host_capacity_waiting", `Pre-publication step '${step.checkId}' (${stepClass}) is waiting for host capacity: ${decision.detail}`, { status: "waiting_for_host_capacity", reason: decision.reason, cpuCores: cost.cpuCores, memoryBytes: cost.memoryBytes }),
37
+ });
38
+ }
39
+ catch (error) {
40
+ if (error instanceof HostCapacityTimeoutError) {
41
+ await emit("prepublication_host_capacity_timeout", error.message, { status: "host_capacity_timeout", host_load_wait_ms: Math.round(error.waitMs) }, "error");
42
+ }
43
+ else if (error instanceof HostCapacityLedgerUnavailableError) {
44
+ await emit("prepublication_host_capacity_ledger_unavailable", error.message, { status: "host_capacity_ledger_unavailable" }, "error");
45
+ }
46
+ throw error;
47
+ }
48
+ const waitMs = Math.round(admission.waitMs);
49
+ await emit("prepublication_host_capacity_admitted", `Pre-publication step '${step.checkId}' (${stepClass}) was admitted after ${waitMs}ms waiting for host capacity.`, { status: "running", reason: admission.decision.reason, host_load_wait_ms: waitMs });
50
+ // Step timers start here, after admission: a step can never time out because it waited.
51
+ const startedAtMs = monotonicNowMs();
52
+ const runSignal = step.signal ? AbortSignal.any([step.signal, admission.fenced]) : admission.fenced;
53
+ const reservationLost = async () => {
54
+ const reason = admission.fenced.reason;
55
+ await emit("prepublication_host_capacity_lost", `Pre-publication step '${step.checkId}' (${stepClass}) was stopped because its host capacity reservation was lost: ${reason instanceof Error ? reason.message : String(reason)}`, { status: "host_capacity_lost" }, "error");
56
+ throw reason;
57
+ };
58
+ let unstopped = null;
59
+ try {
60
+ let result;
61
+ try {
62
+ result = await run(runSignal);
63
+ }
64
+ catch (error) {
65
+ // Part of the step may still run: that, not a fence, is what it failed with.
66
+ // Also a supervised runner's failed proof, which arrives sanitized and wrapped.
67
+ const retention = retentionFor(error);
68
+ if (retention) {
69
+ unstopped = retention;
70
+ throw error;
71
+ }
72
+ if (admission.fenced.aborted)
73
+ return await reservationLost();
74
+ throw error;
75
+ }
76
+ // A result produced after the reservation was lost is not trusted either.
77
+ if (admission.fenced.aborted)
78
+ return await reservationLost();
79
+ return result;
80
+ }
81
+ finally {
82
+ const elapsedMs = Math.round(monotonicNowMs() - startedAtMs);
83
+ // Assigned in the catch above; widened, since control-flow narrowing does not see it here.
84
+ const treeLeft = unstopped;
85
+ const returned = {
86
+ failure: treeLeft ? { kind: "retained", message: treeLeft.reason.message } : null,
87
+ };
88
+ // The token is kept, with its cost, while part of the step's tree may still run.
89
+ await returnHostLoadToken(admission, treeLeft, error => {
90
+ returned.failure = {
91
+ kind: error instanceof HostCapacityTokenFencedError ? "fenced" : "ledger_unavailable",
92
+ message: error instanceof Error ? error.message : String(error),
93
+ };
94
+ });
95
+ const failure = returned.failure;
96
+ await emit("prepublication_host_capacity_released", failure?.kind === "retained"
97
+ ? `Pre-publication step '${step.checkId}' ended, but part of its process tree did not stop; its host capacity stays reserved until it is gone: ${failure.message}`
98
+ : failure?.kind === "fenced"
99
+ ? `Pre-publication step '${step.checkId}' finished, but its host capacity token had been reclaimed: ${failure.message}`
100
+ : failure
101
+ ? `Pre-publication step '${step.checkId}' finished, but its host capacity token could not be returned yet (the governor keeps retrying): ${failure.message}`
102
+ : `Pre-publication step '${step.checkId}' (${stepClass}) ran ${elapsedMs}ms after waiting ${waitMs}ms for host capacity.`, {
103
+ status: "completed",
104
+ host_load_wait_ms: waitMs,
105
+ elapsed_ms: elapsedMs,
106
+ tokenFenced: failure?.kind === "fenced",
107
+ releaseFailed: failure?.kind === "ledger_unavailable",
108
+ tokenRetained: failure?.kind === "retained",
109
+ });
110
+ }
111
+ }
@@ -0,0 +1,61 @@
1
+ import type { ValidationStep } from "./pre-publication-step-execution.js";
2
+ import { ForgeFailureError, type RunnerDispatchEvent } from "./session.types.js";
3
+ /** The check id a failed restart of the attempt's runtime stack before the pass is reported under. */
4
+ export declare const runtimeRestartCheckId = "host-runtime-restart";
5
+ /** One check that failed in a pass: the step that failed and its clipped diagnostics. */
6
+ export interface PrePublicationCheckFailure {
7
+ readonly checkId: string;
8
+ readonly exitCode: number;
9
+ readonly command: string;
10
+ readonly args: readonly string[];
11
+ readonly detail: string;
12
+ }
13
+ /**
14
+ * A failed validation pass. The single-check fields name the first failure, as they always have;
15
+ * `failures` lists every check that failed in the pass, in the order the checks ran.
16
+ */
17
+ export declare class PrePublicationValidationError extends ForgeFailureError {
18
+ readonly checkId: string;
19
+ readonly exitCode: number;
20
+ readonly command: string;
21
+ readonly args: readonly string[];
22
+ readonly detail: string;
23
+ readonly code = "prepublication_validation_failed";
24
+ readonly failures: readonly PrePublicationCheckFailure[];
25
+ constructor(checkId: string, exitCode: number, command: string, args: readonly string[], detail: string, additionalFailures?: readonly PrePublicationCheckFailure[]);
26
+ /** Every failed check's id, first failure first. */
27
+ get checkIds(): readonly string[];
28
+ }
29
+ export declare class PrePublicationPass {
30
+ private readonly runtimeRestartFailure?;
31
+ private readonly failures;
32
+ /** The check whose .NET build failed to compile in this pass, if any. */
33
+ private dotnetCompileFailedIn;
34
+ /** A failed runtime restart before the pass is its first failure. */
35
+ constructor(runtimeRestartFailure?: PrePublicationValidationError | undefined);
36
+ record(failure: PrePublicationCheckFailure, failedStep?: ValidationStep): void;
37
+ /** The failed checks that keep this check from running meaningfully in this pass. */
38
+ blockers(checkId: string): readonly string[];
39
+ /**
40
+ * Whether an error ends the pass with the failures it already found. Only a classified retryable
41
+ * failure (a resource hold, lost infrastructure, a supervisor that did not start) does, once the
42
+ * pass has found a failure: the repair turn can fix those failures now, and the next pass meets
43
+ * the condition again. Any other error, or cancellation, still ends the attempt as it did.
44
+ */
45
+ stopsAt(error: unknown, signal?: AbortSignal): error is ForgeFailureError;
46
+ stoppedEvent(checkId: string, error: ForgeFailureError): RunnerDispatchEvent;
47
+ /** Throws every failure the pass found as one validation failure. */
48
+ throwIfFailed(): void;
49
+ }
50
+ export declare function skippedCheckEvent(checkId: string, blockedBy: readonly string[]): RunnerDispatchEvent;
51
+ /** The tests a check's steps skipped, so a check that passed with skips says so with each reason. */
52
+ export declare class SkippedTestTally {
53
+ private readonly worktreePath;
54
+ private readonly environment?;
55
+ private summary;
56
+ constructor(worktreePath: string, environment?: Readonly<Record<string, string>> | undefined);
57
+ /** The invocation's own arguments: a managed attempt may direct results to its test-output root. */
58
+ add(args: readonly string[], stepStartedMs: number): Promise<void>;
59
+ passedEvent(checkId: string, secrets: readonly string[]): RunnerDispatchEvent;
60
+ }
61
+ export declare function validationEvent(eventType: string, checkId: string, content: string, detail?: Readonly<Record<string, unknown>>): RunnerDispatchEvent;