@loucompanion/forge-bridge 0.1.4-dev.f22f5e3d01fe → 0.2.1-dev.0f07274d438b

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 (260) hide show
  1. package/README.md +128 -4
  2. package/dist/bridge/bridge-chat-giphy-look.d.ts +48 -0
  3. package/dist/bridge/bridge-chat-giphy-look.js +55 -0
  4. package/dist/bridge/bridge-chat-provider-command.d.ts +27 -3
  5. package/dist/bridge/bridge-chat-provider-command.js +131 -26
  6. package/dist/bridge/bridge-chat.types.d.ts +20 -0
  7. package/dist/bridge/bridge-chat.types.js +28 -1
  8. package/dist/bridge/bridge-state-file.d.ts +161 -0
  9. package/dist/bridge/bridge-state-file.js +376 -0
  10. package/dist/bridge/bridge-state-io.d.ts +15 -0
  11. package/dist/bridge/bridge-state-io.js +68 -0
  12. package/dist/bridge/bridge-state-lock.d.ts +11 -0
  13. package/dist/bridge/bridge-state-lock.js +102 -0
  14. package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
  15. package/dist/bridge/bridge-state-unpublished.js +111 -0
  16. package/dist/bridge/bridge.service.d.ts +29 -12
  17. package/dist/bridge/bridge.service.js +215 -380
  18. package/dist/bridge/bridge.types.d.ts +21 -0
  19. package/dist/bridge/bridge.types.js +2 -1
  20. package/dist/bridge/default-session-service.d.ts +13 -0
  21. package/dist/bridge/default-session-service.js +22 -0
  22. package/dist/bridge/dispatch-offer-policy.d.ts +22 -0
  23. package/dist/bridge/dispatch-offer-policy.js +58 -0
  24. package/dist/bridge/in-flight-registry.d.ts +62 -0
  25. package/dist/bridge/in-flight-registry.js +207 -0
  26. package/dist/bridge/readiness-result-outbox.d.ts +5 -1
  27. package/dist/bridge/readiness-result-outbox.js +20 -0
  28. package/dist/bridge/runner-host-capabilities.js +14 -1
  29. package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
  30. package/dist/bridge/sandbox-resource-accounting.js +150 -0
  31. package/dist/bridge/windows-bash-resolution.d.ts +31 -0
  32. package/dist/bridge/windows-bash-resolution.js +153 -0
  33. package/dist/cleanup/cleanup-wip.d.ts +12 -0
  34. package/dist/cleanup/cleanup-wip.js +66 -0
  35. package/dist/cleanup/cleanup.service.d.ts +11 -1
  36. package/dist/cleanup/cleanup.service.js +80 -62
  37. package/dist/cleanup/cleanup.types.d.ts +2 -0
  38. package/dist/cleanup/forge-owned-paths.d.ts +2 -0
  39. package/dist/cleanup/forge-owned-paths.js +9 -0
  40. package/dist/cleanup/host-runtime-ledger.d.ts +2 -0
  41. package/dist/cleanup/host-runtime-ledger.js +30 -9
  42. package/dist/cli/cli.help.js +57 -13
  43. package/dist/cli/cli.service.d.ts +3 -10
  44. package/dist/cli/cli.service.js +20 -213
  45. package/dist/cli/idle-status.d.ts +84 -0
  46. package/dist/cli/idle-status.js +181 -0
  47. package/dist/cli/local-config.d.ts +14 -1
  48. package/dist/cli/local-config.js +42 -2
  49. package/dist/cli/provider-cli-advertising.d.ts +24 -0
  50. package/dist/cli/provider-cli-advertising.js +88 -0
  51. package/dist/cli/provider-cli-detection.d.ts +10 -0
  52. package/dist/cli/provider-cli-detection.js +160 -0
  53. package/dist/runtime/aspnet-runtime-prebuild.d.ts +20 -0
  54. package/dist/runtime/aspnet-runtime-prebuild.js +104 -26
  55. package/dist/runtime/attempt-database-broker.d.ts +1 -1
  56. package/dist/runtime/attempt-node-runtime-launcher.d.ts +36 -0
  57. package/dist/runtime/attempt-node-runtime-launcher.js +169 -0
  58. package/dist/runtime/attempt-process-supervisor.d.ts +2 -0
  59. package/dist/runtime/attempt-process-supervisor.js +12 -6
  60. package/dist/runtime/docker-engine-probe.d.ts +5 -0
  61. package/dist/runtime/docker-engine-probe.js +7 -0
  62. package/dist/runtime/dotnet-build-outputs.d.ts +107 -0
  63. package/dist/runtime/dotnet-build-outputs.js +402 -0
  64. package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
  65. package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
  66. package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
  67. package/dist/runtime/ephemeral-test-postgres.js +303 -0
  68. package/dist/runtime/host-listener-inspector.d.ts +26 -0
  69. package/dist/runtime/host-listener-inspector.js +84 -3
  70. package/dist/runtime/host-load-admission.d.ts +5 -0
  71. package/dist/runtime/host-load-capacity.d.ts +198 -0
  72. package/dist/runtime/host-load-capacity.js +353 -0
  73. package/dist/runtime/host-load-child-environment.d.ts +13 -0
  74. package/dist/runtime/host-load-child-environment.js +35 -1
  75. package/dist/runtime/host-load-governor-config.d.ts +33 -3
  76. package/dist/runtime/host-load-governor-config.js +24 -3
  77. package/dist/runtime/host-load-governor.d.ts +91 -2
  78. package/dist/runtime/host-load-governor.js +217 -18
  79. package/dist/runtime/host-load-ledger-lock.js +6 -4
  80. package/dist/runtime/host-load-live-test-slots.d.ts +61 -0
  81. package/dist/runtime/host-load-live-test-slots.js +193 -0
  82. package/dist/runtime/host-load-runtime-settings.js +4 -2
  83. package/dist/runtime/host-load-sampler.d.ts +25 -1
  84. package/dist/runtime/host-load-sampler.js +38 -7
  85. package/dist/runtime/host-load-step-run.d.ts +37 -3
  86. package/dist/runtime/host-load-step-run.js +63 -7
  87. package/dist/runtime/host-load-test-slot.d.ts +3 -0
  88. package/dist/runtime/host-load-test-slot.js +26 -7
  89. package/dist/runtime/host-runtime-contract.d.ts +12 -0
  90. package/dist/runtime/host-runtime-contract.js +35 -5
  91. package/dist/runtime/host-runtime-lease.d.ts +28 -3
  92. package/dist/runtime/host-runtime-lease.js +140 -296
  93. package/dist/runtime/host-runtime-ledger-recovery.d.ts +20 -0
  94. package/dist/runtime/host-runtime-ledger-recovery.js +134 -0
  95. package/dist/runtime/host-runtime-promotion.d.ts +78 -2
  96. package/dist/runtime/host-runtime-promotion.js +307 -14
  97. package/dist/runtime/managed-command-teardown.js +5 -16
  98. package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
  99. package/dist/runtime/native-test-postgres-fallback.js +60 -8
  100. package/dist/runtime/prepared-runtime-identity.d.ts +4 -0
  101. package/dist/runtime/prepared-runtime-identity.js +130 -9
  102. package/dist/runtime/prepared-runtime-readiness.d.ts +23 -1
  103. package/dist/runtime/prepared-runtime-readiness.js +89 -18
  104. package/dist/runtime/runner-settings.d.ts +4 -0
  105. package/dist/runtime/runner-settings.js +22 -0
  106. package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
  107. package/dist/runtime/supervised-runtime-build-guard.js +112 -0
  108. package/dist/sandbox/host-capacity-broker.d.ts +3 -1
  109. package/dist/sandbox/host-capacity-broker.js +4 -2
  110. package/dist/sandbox/managed-branch.d.ts +13 -0
  111. package/dist/sandbox/managed-branch.js +90 -0
  112. package/dist/sandbox/provider-auth/codex.js +11 -11
  113. package/dist/sandbox/runtime.d.ts +1 -2
  114. package/dist/sandbox/runtime.js +9 -19
  115. package/dist/sandbox/sandbox-input.d.ts +22 -0
  116. package/dist/sandbox/sandbox-input.js +49 -0
  117. package/dist/sandbox/workspace.service.js +15 -2
  118. package/dist/session/managed-attempt-tools.d.ts +0 -7
  119. package/dist/session/managed-attempt-tools.js +54 -109
  120. package/dist/session/managed-build-coordinator.d.ts +16 -0
  121. package/dist/session/managed-build-coordinator.js +10 -0
  122. package/dist/session/managed-build-receipt.d.ts +7 -0
  123. package/dist/session/managed-build-receipt.js +11 -3
  124. package/dist/session/managed-command-environment.d.ts +8 -0
  125. package/dist/session/managed-command-environment.js +28 -0
  126. package/dist/session/managed-command-host-load.d.ts +10 -5
  127. package/dist/session/managed-command-host-load.js +18 -14
  128. package/dist/session/phase-completion.artifact-bundle.d.ts +20 -0
  129. package/dist/session/phase-completion.artifact-bundle.js +167 -0
  130. package/dist/session/phase-completion.artifacts.d.ts +2 -17
  131. package/dist/session/phase-completion.artifacts.js +65 -166
  132. package/dist/session/phase-completion.d.ts +27 -2
  133. package/dist/session/phase-completion.helpers.js +5 -53
  134. package/dist/session/phase-completion.js +15 -32
  135. package/dist/session/phase-completion.mcp-args.d.ts +9 -0
  136. package/dist/session/phase-completion.mcp-args.js +195 -0
  137. package/dist/session/phase-completion.phase-aliases.d.ts +5 -0
  138. package/dist/session/phase-completion.phase-aliases.js +43 -0
  139. package/dist/session/phase-completion.pr-review-schema.d.ts +1 -0
  140. package/dist/session/phase-completion.pr-review-schema.js +75 -0
  141. package/dist/session/phase-completion.pr-review-validation.d.ts +11 -0
  142. package/dist/session/phase-completion.pr-review-validation.js +212 -0
  143. package/dist/session/phase-completion.pr-review.d.ts +36 -0
  144. package/dist/session/phase-completion.pr-review.js +294 -0
  145. package/dist/session/phase-completion.prompts.d.ts +1 -1
  146. package/dist/session/phase-completion.prompts.js +14 -0
  147. package/dist/session/phase-completion.runtime.d.ts +8 -9
  148. package/dist/session/phase-completion.runtime.js +65 -196
  149. package/dist/session/phase-completion.schemas.js +12 -2
  150. package/dist/session/phase-completion.validation.d.ts +1 -0
  151. package/dist/session/phase-completion.validation.js +9 -1
  152. package/dist/session/pr-review-diff-base.d.ts +18 -0
  153. package/dist/session/pr-review-diff-base.js +44 -0
  154. package/dist/session/pr-review-placement.d.ts +50 -0
  155. package/dist/session/pr-review-placement.js +91 -0
  156. package/dist/session/pre-publication-change-set.d.ts +62 -0
  157. package/dist/session/pre-publication-change-set.js +166 -0
  158. package/dist/session/pre-publication-host-load.js +6 -5
  159. package/dist/session/pre-publication-native-postgres.d.ts +30 -0
  160. package/dist/session/pre-publication-native-postgres.js +111 -0
  161. package/dist/session/pre-publication-process.js +13 -12
  162. package/dist/session/pre-publication-step-execution.d.ts +2 -1
  163. package/dist/session/pre-publication-step-execution.js +6 -5
  164. package/dist/session/pre-publication-validation.d.ts +9 -4
  165. package/dist/session/pre-publication-validation.js +62 -65
  166. package/dist/session/provider-cli/claude-background-work.d.ts +3 -2
  167. package/dist/session/provider-cli/claude-background-work.js +4 -3
  168. package/dist/session/provider-cli/dispatch-target-branch.d.ts +7 -0
  169. package/dist/session/provider-cli/dispatch-target-branch.js +8 -0
  170. package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
  171. package/dist/session/provider-cli/host-build-lock.js +30 -0
  172. package/dist/session/provider-cli/pr-review-credential-isolation.d.ts +83 -0
  173. package/dist/session/provider-cli/pr-review-credential-isolation.js +144 -0
  174. package/dist/session/provider-cli/pr-review-guardrails.d.ts +70 -0
  175. package/dist/session/provider-cli/pr-review-guardrails.js +360 -0
  176. package/dist/session/provider-cli/pr-review-prompt.d.ts +2 -0
  177. package/dist/session/provider-cli/pr-review-prompt.js +119 -0
  178. package/dist/session/provider-cli/pre-publication-repair.d.ts +16 -0
  179. package/dist/session/provider-cli/pre-publication-repair.js +41 -3
  180. package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
  181. package/dist/session/provider-cli/provider-cli.child-environment.js +4 -2
  182. package/dist/session/provider-cli/provider-cli.deterministic.d.ts +1 -0
  183. package/dist/session/provider-cli/provider-cli.deterministic.js +5 -0
  184. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +6 -3
  185. package/dist/session/provider-cli/provider-cli.merge-integrity.js +29 -10
  186. package/dist/session/provider-cli/provider-cli.pr-review.d.ts +23 -0
  187. package/dist/session/provider-cli/provider-cli.pr-review.js +213 -0
  188. package/dist/session/provider-cli/provider-cli.process.d.ts +2 -14
  189. package/dist/session/provider-cli/provider-cli.process.js +4 -94
  190. package/dist/session/provider-cli/provider-cli.prompts.d.ts +13 -3
  191. package/dist/session/provider-cli/provider-cli.prompts.js +137 -84
  192. package/dist/session/provider-cli/provider-cli.reapply-conflicts.d.ts +10 -0
  193. package/dist/session/provider-cli/provider-cli.reapply-conflicts.js +37 -0
  194. package/dist/session/provider-cli/provider-cli.runtime.d.ts +15 -0
  195. package/dist/session/provider-cli/provider-cli.runtime.js +37 -2
  196. package/dist/session/provider-cli/provider-cli.service-support.d.ts +37 -0
  197. package/dist/session/provider-cli/provider-cli.service-support.js +146 -0
  198. package/dist/session/provider-cli/provider-cli.service.d.ts +15 -18
  199. package/dist/session/provider-cli/provider-cli.service.js +59 -190
  200. package/dist/session/provider-cli/provider-cli.types.d.ts +7 -2
  201. package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
  202. package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
  203. package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
  204. package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
  205. package/dist/session/qa-sidecar-validation.d.ts +6 -0
  206. package/dist/session/qa-sidecar-validation.js +28 -0
  207. package/dist/session/sandbox-host-capacity-gate.d.ts +22 -1
  208. package/dist/session/sandbox-host-capacity-gate.js +63 -22
  209. package/dist/session/session-host-project.d.ts +22 -0
  210. package/dist/session/session-host-project.js +98 -0
  211. package/dist/session/session-redaction.js +31 -181
  212. package/dist/session/session.parse-helpers.d.ts +10 -0
  213. package/dist/session/session.parse-helpers.js +84 -0
  214. package/dist/session/session.runtime-refresh.d.ts +46 -0
  215. package/dist/session/session.runtime-refresh.js +116 -0
  216. package/dist/session/session.service.d.ts +8 -1
  217. package/dist/session/session.service.js +177 -239
  218. package/dist/session/session.types.d.ts +5 -0
  219. package/dist/session/session.types.js +9 -79
  220. package/dist/session/session.types.pr-review.d.ts +48 -0
  221. package/dist/session/session.types.pr-review.js +51 -0
  222. package/dist/session/sidecar-json-shape.d.ts +31 -0
  223. package/dist/session/sidecar-json-shape.js +217 -0
  224. package/dist/shared/fs/file-identity.d.ts +10 -0
  225. package/dist/shared/fs/file-identity.js +15 -0
  226. package/dist/shared/fs/replace-file.d.ts +7 -0
  227. package/dist/shared/fs/replace-file.js +33 -0
  228. package/dist/shared/process/host-process-recovery.d.ts +14 -3
  229. package/dist/shared/process/host-process-recovery.js +23 -3
  230. package/dist/shared/process/host-process-supervisor.d.ts +13 -1
  231. package/dist/shared/process/host-process-supervisor.js +66 -14
  232. package/dist/shared/provider-capabilities.d.ts +2 -0
  233. package/dist/shared/provider-capabilities.js +18 -1
  234. package/dist/version.d.ts +1 -1
  235. package/dist/version.js +1 -1
  236. package/dist/worktree/artifact-injector.js +24 -0
  237. package/dist/worktree/orphan-relink.d.ts +19 -0
  238. package/dist/worktree/orphan-relink.js +106 -0
  239. package/dist/worktree/wip-git.d.ts +58 -0
  240. package/dist/worktree/wip-git.js +182 -0
  241. package/dist/worktree/wip-refs.d.ts +85 -0
  242. package/dist/worktree/wip-refs.js +169 -0
  243. package/dist/worktree/wip-restore.d.ts +51 -0
  244. package/dist/worktree/wip-restore.js +324 -0
  245. package/dist/worktree/wip-snapshot.d.ts +53 -0
  246. package/dist/worktree/wip-snapshot.js +270 -0
  247. package/dist/worktree/worktree-inputs.d.ts +8 -0
  248. package/dist/worktree/worktree-inputs.js +134 -0
  249. package/dist/worktree/worktree-origin-sync.d.ts +35 -0
  250. package/dist/worktree/worktree-origin-sync.js +128 -0
  251. package/dist/worktree/worktree-wip-events.d.ts +20 -0
  252. package/dist/worktree/worktree-wip-events.js +148 -0
  253. package/dist/worktree/worktree-wip.d.ts +57 -0
  254. package/dist/worktree/worktree-wip.js +200 -0
  255. package/dist/worktree/worktree.base.d.ts +7 -1
  256. package/dist/worktree/worktree.service.d.ts +49 -5
  257. package/dist/worktree/worktree.service.js +223 -187
  258. package/dist/worktree/worktree.types.d.ts +47 -0
  259. package/package.json +1 -1
  260. package/runtime/windows-listener-owner.ps1 +12 -1
@@ -3,19 +3,18 @@ import fs from "node:fs/promises";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
5
  import { resetGeneratedOutputs } from "../runtime/generated-output-reset.js";
6
- import { DockerEngineProbe } from "../runtime/docker-engine-probe.js";
7
6
  import { attemptDatabaseCapabilityEnvironment, attemptDatabaseCapabilitySecrets, } from "../runtime/attempt-database-broker.js";
8
7
  import { assertHostDatabaseCapabilityBoundary } from "../runtime/host-database-capability-boundary.js";
9
- import { nativeTestPostgresFallbackConfigEnvironment, nativeTestPostgresFallbackDatabaseMode, nativeTestPostgresFallbackEnvironment, readNativeTestPostgresFallback, } from "../runtime/native-test-postgres-fallback.js";
8
+ import { managedVerificationDatabase, noManagedVerificationDatabase, releaseManagedVerificationDatabase, setUpWithManagedVerificationDatabase } from "../runtime/ephemeral-test-postgres-grant.js";
10
9
  import { redactText } from "../shared/redaction/redaction.js";
11
10
  import { emptyToolInputHint, isEmptyToolInput } from "./mcp-argument-coercion.js";
12
- import { ManagedBuildCoordinator } from "./managed-build-coordinator.js";
11
+ import { assertManagedBuildSparesSupervisedRuntimes, ManagedBuildCoordinator } from "./managed-build-coordinator.js";
13
12
  import { attachManagedCommandProcess, ManagedCommandHostCapacity, } from "./managed-command-host-load.js";
14
13
  import { HostCapacityLedgerUnavailableError } from "../runtime/host-load-ledger-lock.js";
15
14
  import { isProcessTreeTerminationUnproven } from "../shared/process/process.js";
16
15
  import { HostCapacityTokenFencedError } from "../runtime/host-load-token-ledger.js";
17
- import { withoutHostLoadGovernorVariables } from "../runtime/host-load-child-environment.js";
18
- import { managedBuildConfiguration, publishManagedBuildReceipt, verifyManagedBuildReceipt, } from "./managed-build-receipt.js";
16
+ import { inheritedManagedCommandEnvironment } from "./managed-command-environment.js";
17
+ import { managedBuildConfiguration, persistJsonAtomically, publishManagedBuildReceipt, verifyManagedBuildReceipt, } from "./managed-build-receipt.js";
19
18
  import { managedLongTierTimeoutMs, managedMaximumCommandTimeoutMs, managedVerificationTierTimeoutMs, } from "./managed-verification-timeouts.js";
20
19
  import { resolveWindowsCommandFromPath, StreamingProviderProcessRunner } from "./provider-cli/provider-cli.process.js";
21
20
  import { monotonicNowMs } from "../shared/time/monotonic.js";
@@ -38,8 +37,6 @@ const managedCommandRetryAfterMs = 60_000;
38
37
  const managedCommandLaunchTimeoutMs = 60_000;
39
38
  const managedCommandProgressPersistIntervalMs = 5_000;
40
39
  const managedCommandReceiptPollIntervalMs = 1_000;
41
- const managedCommandReceiptReplaceAttempts = 40;
42
- const managedCommandReceiptReplaceRetryMs = 25;
43
40
  const terminalManagedCommandStatuses = new Set([
44
41
  "pass",
45
42
  "fail",
@@ -295,6 +292,9 @@ async function launchManagedCommand(record, worktreePath, forceAsync, verificati
295
292
  buildReceiptReuse,
296
293
  controller: new AbortController(),
297
294
  };
295
+ // A build aimed at the output a running supervised runtime executes from fails here, naming
296
+ // that runtime, instead of failing on its locked files after the build-slot and capacity waits.
297
+ await assertManagedBuildSparesSupervisedRuntimes(invocation);
298
298
  if (forceAsync || timeoutMs > maximumSynchronousWaitMs) {
299
299
  const started = managedCommandResult({
300
300
  ...invocation,
@@ -512,7 +512,7 @@ async function executeManagedCommand(invocation) {
512
512
  let processStarted = false;
513
513
  // The per-worktree build slot is taken first: holding a host token while
514
514
  // queued behind this worktree's own build would waste host capacity.
515
- const hostCapacity = new ManagedCommandHostCapacity({ ...invocation, label: invocation.verificationProfile ?? invocation.commandId }, async (hostLoad) => await persistManagedCommandReceipt(invocation.receiptPath, managedCommandResult({
515
+ const hostCapacity = new ManagedCommandHostCapacity({ ...invocation, label: invocation.verificationProfile ?? invocation.commandId }, async (hostLoad, fence) => await persistManagedCommandReceipt(invocation.receiptPath, managedCommandResult({
516
516
  ...invocation,
517
517
  hostLoad,
518
518
  timedOut: false,
@@ -521,7 +521,7 @@ async function executeManagedCommand(invocation) {
521
521
  stdout: "",
522
522
  stderr: "",
523
523
  launchRequested: false,
524
- }).structuredContent));
524
+ }).structuredContent, async (replace) => await fence.commit(replace)));
525
525
  const launch = async (buildQueueWaitMs) => await hostCapacity.run(invocation.controller.signal, async (hostLoad, control) => {
526
526
  processStarted = true;
527
527
  // A reclaimed token means this command's capacity is gone: it stops. A fence that
@@ -594,41 +594,48 @@ async function executeManagedCommand(invocation) {
594
594
  return managedCommandPublicResult(receipt);
595
595
  }
596
596
  }
597
+ /** A command's environment and redaction list; a setup that throws releases the database it started. */
597
598
  async function managedCommandProcessEnvironment(invocation) {
598
599
  assertHostDatabaseCapabilityBoundary();
599
- const databaseEnvironment = invocation.verificationProfile
600
- ? await managedVerificationDatabaseEnvironment()
601
- : {};
602
- const exactSecrets = [
603
- ...Object.values(databaseEnvironment).filter(value => value !== nativeTestPostgresFallbackDatabaseMode),
604
- // The attempt's brokered database login reaches managed commands; their output never shows it.
605
- ...attemptDatabaseCapabilitySecrets(process.env[attemptDatabaseCapabilityEnvironment]),
606
- ];
607
- const environment = inheritedEnvironment({
608
- FORGE_RUNTIME_MODE: "host",
609
- FORGE_RESOURCE_LEASE_ID: requiredAttemptEnvironment("FORGE_RESOURCE_LEASE_ID"),
610
- FORGE_DISPATCH_ATTEMPT_ID: requiredAttemptEnvironment("FORGE_DISPATCH_ATTEMPT_ID"),
611
- // This nested command owns a distinct supervisor identity. A command-local
612
- // fence avoids exposing the parent attempt's fencing capability to Codex's
613
- // MCP subprocess configuration while preserving exact-tree cleanup proof.
614
- FORGE_FENCING_TOKEN: randomUUID(),
615
- FORGE_LOG_DIR: invocation.logDirectory,
616
- FORGE_TEST_OUTPUT_DIR: requiredAttemptEnvironment("FORGE_TEST_OUTPUT_DIR"),
617
- FORGE_PROCESS_SUPERVISOR_ID: `managed-${invocation.commandId.replaceAll("-", "")}`,
618
- FORGE_PROCESS_SUPERVISOR_METADATA_PATH: invocation.metadataPath,
619
- ...(invocation.verificationProfile
620
- ? {
621
- FORGE_MANAGED_VERIFICATION_PROFILE: invocation.verificationProfile,
622
- // Managed verification executes mutable worktree scripts, SDK targets,
623
- // and test assemblies. It uses an attempt-owned container, or the
624
- // dedicated native test cluster while Docker is unavailable; it never
625
- // receives a capability for a server that holds real data.
626
- FORGE_MANAGED_VERIFICATION_DATABASE_MODE: "container_only",
627
- ...databaseEnvironment,
628
- }
629
- : {}),
600
+ const database = invocation.verificationProfile ? await managedVerificationDatabase() : noManagedVerificationDatabase;
601
+ return await setUpWithManagedVerificationDatabase(database, () => {
602
+ const exactSecrets = [
603
+ ...database.secrets,
604
+ // The attempt's brokered database login reaches managed commands; their output never shows it.
605
+ ...attemptDatabaseCapabilitySecrets(process.env[attemptDatabaseCapabilityEnvironment]),
606
+ ];
607
+ const environment = inheritedManagedCommandEnvironment({
608
+ FORGE_RUNTIME_MODE: "host",
609
+ FORGE_RESOURCE_LEASE_ID: requiredAttemptEnvironment("FORGE_RESOURCE_LEASE_ID"),
610
+ FORGE_DISPATCH_ATTEMPT_ID: requiredAttemptEnvironment("FORGE_DISPATCH_ATTEMPT_ID"),
611
+ // This nested command owns a distinct supervisor identity. A command-local
612
+ // fence avoids exposing the parent attempt's fencing capability to Codex's
613
+ // MCP subprocess configuration while preserving exact-tree cleanup proof.
614
+ FORGE_FENCING_TOKEN: randomUUID(),
615
+ FORGE_LOG_DIR: invocation.logDirectory,
616
+ FORGE_TEST_OUTPUT_DIR: requiredAttemptEnvironment("FORGE_TEST_OUTPUT_DIR"),
617
+ FORGE_PROCESS_SUPERVISOR_ID: `managed-${invocation.commandId.replaceAll("-", "")}`,
618
+ FORGE_PROCESS_SUPERVISOR_METADATA_PATH: invocation.metadataPath,
619
+ ...(invocation.verificationProfile
620
+ ? {
621
+ FORGE_MANAGED_VERIFICATION_PROFILE: invocation.verificationProfile,
622
+ // Managed verification executes mutable worktree scripts, SDK targets,
623
+ // and test assemblies. It uses an attempt-owned container, or the
624
+ // dedicated native test cluster while Docker is unavailable; it never
625
+ // receives a capability for a server that holds real data.
626
+ FORGE_MANAGED_VERIFICATION_DATABASE_MODE: "container_only",
627
+ ...database.environment,
628
+ }
629
+ : {}),
630
+ });
631
+ return { environment, exactSecrets, release: database.release };
630
632
  });
631
- return { environment, exactSecrets };
633
+ }
634
+ function clearManagedCommandTimers(...timers) {
635
+ // clearTimeout and clearInterval share one timer table.
636
+ for (const timer of timers)
637
+ if (timer)
638
+ clearTimeout(timer);
632
639
  }
633
640
  async function executeManagedCommandProcess(invocation) {
634
641
  let prepared;
@@ -830,11 +837,9 @@ async function executeManagedCommandProcess(invocation) {
830
837
  return managedCommandPublicResult(receipt);
831
838
  }
832
839
  finally {
833
- clearTimeout(launchTimer);
834
- if (timer)
835
- clearTimeout(timer);
836
- if (progressHeartbeat)
837
- clearInterval(progressHeartbeat);
840
+ clearManagedCommandTimers(launchTimer, timer, progressHeartbeat);
841
+ // An ephemeral verification cluster lives exactly as long as its command; one that would not stop is reaped later and named in the receipt.
842
+ await releaseManagedVerificationDatabase(prepared, async (message) => await annotateManagedCommandReceipt(invocation.receiptPath, { ephemeral_cluster_release_error: redactText(message, exactSecrets) }));
838
843
  }
839
844
  }
840
845
  async function readManagedCommand(input) {
@@ -937,28 +942,8 @@ async function waitManagedCommand(input) {
937
942
  function managedCommandReceiptPath(logDirectory, commandId) {
938
943
  return path.join(logDirectory, "managed-commands", `${commandId}.receipt.json`);
939
944
  }
940
- async function persistManagedCommandReceipt(receiptPath, receipt) {
941
- const temporaryPath = `${receiptPath}.${randomUUID()}.tmp`;
942
- await fs.writeFile(temporaryPath, `${JSON.stringify(receipt, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
943
- try {
944
- for (let attempt = 1;; attempt += 1) {
945
- try {
946
- await fs.rename(temporaryPath, receiptPath);
947
- break;
948
- }
949
- catch (error) {
950
- const code = error.code;
951
- if (attempt >= managedCommandReceiptReplaceAttempts
952
- || (code !== "EPERM" && code !== "EBUSY" && code !== "EACCES")) {
953
- throw error;
954
- }
955
- await delay(managedCommandReceiptReplaceRetryMs);
956
- }
957
- }
958
- }
959
- finally {
960
- await fs.rm(temporaryPath, { force: true }).catch(() => undefined);
961
- }
945
+ async function persistManagedCommandReceipt(receiptPath, receipt, commit) {
946
+ await persistJsonAtomically(receiptPath, receipt, commit);
962
947
  }
963
948
  function managedCommandResult(values) {
964
949
  // Governed commands count elapsed time from admission: queue time is host_load_wait_ms.
@@ -1113,31 +1098,6 @@ async function containedWorkingDirectory(worktreePath, input) {
1113
1098
  }
1114
1099
  return target;
1115
1100
  }
1116
- function inheritedEnvironment(overrides) {
1117
- const env = {};
1118
- // A nested Forge process must not join the host ledger: it would queue behind the
1119
- // token this command already holds. Every FORGE_HOST_LOAD_* variable is dropped,
1120
- // the test slot count too (decision 0018).
1121
- for (const [key, value] of Object.entries(withoutHostLoadGovernorVariables(process.env))) {
1122
- if (typeof value === "string" && !looksSensitiveEnvironmentName(key))
1123
- env[key] = value;
1124
- }
1125
- return { ...env, ...overrides };
1126
- }
1127
- /**
1128
- * Runner-authored verification normally uses its attempt-owned Testcontainers
1129
- * database. Only when the Docker engine is unavailable does it switch to the
1130
- * operator-provisioned native test cluster, which holds no real data.
1131
- */
1132
- export async function managedVerificationDatabaseEnvironment(dockerAvailable = async () => (await new DockerEngineProbe().refresh(true)).available, readFallback = () => {
1133
- const configPath = process.env[nativeTestPostgresFallbackConfigEnvironment]?.trim();
1134
- return configPath ? readNativeTestPostgresFallback(configPath) : null;
1135
- }) {
1136
- const fallback = readFallback();
1137
- if (!fallback || await dockerAvailable())
1138
- return {};
1139
- return nativeTestPostgresFallbackEnvironment(fallback);
1140
- }
1141
1101
  export function isBuildProducingManagedCommand(command, args) {
1142
1102
  const executable = path.basename(command).toLowerCase();
1143
1103
  if (executable === "dotnet" || executable === "dotnet.exe") {
@@ -1149,10 +1109,7 @@ export function isBuildProducingManagedCommand(command, args) {
1149
1109
  if (["powershell", "powershell.exe", "pwsh", "pwsh.exe"].includes(executable)) {
1150
1110
  const fileIndex = args.findIndex(argument => argument.toLowerCase() === "-file");
1151
1111
  const script = fileIndex >= 0 ? path.basename(args[fileIndex + 1] ?? "").toLowerCase() : "";
1152
- if (script === "run-dotnet-test-tier-set.ps1" || script === "run-dotnet-test-suite.ps1") {
1153
- return !args.some(argument => argument.toLowerCase() === "-nobuild");
1154
- }
1155
- if (script === "run-dotnet-test-tier.ps1") {
1112
+ if (["run-dotnet-test-tier.ps1", "run-dotnet-test-tier-set.ps1", "run-dotnet-test-suite.ps1"].includes(script)) {
1156
1113
  return !args.some(argument => argument.toLowerCase() === "-nobuild");
1157
1114
  }
1158
1115
  }
@@ -1184,18 +1141,6 @@ function managedBuildReceiptCoverage(invocation) {
1184
1141
  }
1185
1142
  return null;
1186
1143
  }
1187
- function looksSensitiveEnvironmentName(name) {
1188
- const normalized = name.trim().toUpperCase();
1189
- return normalized.includes("SECRET")
1190
- || normalized.includes("TOKEN")
1191
- || normalized.includes("PASSWORD")
1192
- || normalized.includes("CREDENTIAL")
1193
- || normalized.includes("CONNECTION_STRING")
1194
- || normalized.startsWith("CONNECTIONSTRINGS__")
1195
- || normalized.startsWith("CONNECTIONSTRINGS:")
1196
- || normalized.endsWith("_API_KEY")
1197
- || normalized === "OPENAI_API_KEY";
1198
- }
1199
1144
  function requiredAttemptEnvironment(name) {
1200
1145
  const value = process.env[name]?.trim();
1201
1146
  if (!value)
@@ -1,3 +1,19 @@
1
+ /** The managed command a build check needs: what it runs, where, and for which attempt. */
2
+ export interface ManagedBuildCandidate {
3
+ readonly command: string;
4
+ readonly args: readonly string[];
5
+ readonly cwd: string;
6
+ readonly worktreePath: string;
7
+ readonly logDirectory: string;
8
+ readonly buildProducing: boolean;
9
+ }
10
+ /**
11
+ * Refuses, before launch, a managed command that would build into the output one of the
12
+ * attempt's running supervised runtimes executes from. The build slot below orders builds
13
+ * against each other; a running runtime cannot wait its turn, so the collision fails fast
14
+ * with an error naming the runtime instead of a build stuck on its locked files.
15
+ */
16
+ export declare function assertManagedBuildSparesSupervisedRuntimes(candidate: ManagedBuildCandidate): Promise<void>;
1
17
  export declare class ManagedBuildCoordinator {
2
18
  private readonly stateRoot;
3
19
  constructor(stateRoot?: string);
@@ -3,10 +3,20 @@ import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { defaultWorktreeCoordinatorStateRoot } from "../worktree/worktree-paths.js";
5
5
  import { monotonicNowMs } from "../shared/time/monotonic.js";
6
+ import { assertBuildSparesSupervisedRuntimes } from "../runtime/supervised-runtime-build-guard.js";
6
7
  const heartbeatIntervalMs = 30_000;
7
8
  const staleAfterMs = 2 * 60_000;
8
9
  const acquisitionTimeoutMs = 2 * 60 * 60_000;
9
10
  const pollIntervalMs = 100;
11
+ /**
12
+ * Refuses, before launch, a managed command that would build into the output one of the
13
+ * attempt's running supervised runtimes executes from. The build slot below orders builds
14
+ * against each other; a running runtime cannot wait its turn, so the collision fails fast
15
+ * with an error naming the runtime instead of a build stuck on its locked files.
16
+ */
17
+ export async function assertManagedBuildSparesSupervisedRuntimes(candidate) {
18
+ await assertBuildSparesSupervisedRuntimes({ ...candidate, buildsWorktreeSolution: candidate.buildProducing });
19
+ }
10
20
  export class ManagedBuildCoordinator {
11
21
  stateRoot;
12
22
  constructor(stateRoot = defaultWorktreeCoordinatorStateRoot()) {
@@ -19,3 +19,10 @@ export declare function verifyManagedBuildReceipt(options: {
19
19
  readonly requiredCoverage: string;
20
20
  }): Promise<ManagedBuildReceiptEvidence>;
21
21
  export declare function managedBuildConfiguration(command: string, args: readonly string[]): string;
22
+ /**
23
+ * Writes a JSON receipt by replacing the whole file. Agents and Forge poll receipts, and on
24
+ * Windows a poll that has one open refuses the replace: that delays a write, never fails it.
25
+ * `commit`, when given, runs the final replace and may skip it (a write that went stale while
26
+ * it was being prepared); the receipt is then left as it was.
27
+ */
28
+ export declare function persistJsonAtomically(receiptPath: string, value: unknown, commit?: (replace: () => Promise<void>) => Promise<unknown>): Promise<void>;
@@ -3,6 +3,7 @@ import { spawn } from "node:child_process";
3
3
  import fs from "node:fs/promises";
4
4
  import path from "node:path";
5
5
  import { defaultWorktreeCoordinatorStateRoot } from "../worktree/worktree-paths.js";
6
+ import { replaceFile } from "../shared/fs/replace-file.js";
6
7
  const schemaVersion = 1;
7
8
  const maximumRetainedReceipts = 8;
8
9
  const maximumOutputManifestEntries = 20_000;
@@ -262,7 +263,7 @@ async function persistImmutableReceipt(receiptPath, receipt) {
262
263
  const temporaryPath = `${receiptPath}.${randomUUID()}.tmp`;
263
264
  await fs.writeFile(temporaryPath, `${JSON.stringify(receipt, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
264
265
  try {
265
- await fs.rename(temporaryPath, receiptPath).catch(async (error) => {
266
+ await replaceFile(temporaryPath, receiptPath).catch(async (error) => {
266
267
  if (error.code !== "EEXIST")
267
268
  throw error;
268
269
  });
@@ -271,11 +272,18 @@ async function persistImmutableReceipt(receiptPath, receipt) {
271
272
  await fs.rm(temporaryPath, { force: true }).catch(() => undefined);
272
273
  }
273
274
  }
274
- async function persistJsonAtomically(receiptPath, value) {
275
+ /**
276
+ * Writes a JSON receipt by replacing the whole file. Agents and Forge poll receipts, and on
277
+ * Windows a poll that has one open refuses the replace: that delays a write, never fails it.
278
+ * `commit`, when given, runs the final replace and may skip it (a write that went stale while
279
+ * it was being prepared); the receipt is then left as it was.
280
+ */
281
+ export async function persistJsonAtomically(receiptPath, value, commit) {
275
282
  const temporaryPath = `${receiptPath}.${randomUUID()}.tmp`;
276
283
  await fs.writeFile(temporaryPath, `${JSON.stringify(value, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
277
284
  try {
278
- await fs.rename(temporaryPath, receiptPath);
285
+ const replace = async () => await replaceFile(temporaryPath, receiptPath);
286
+ await (commit ? commit(replace) : replace());
279
287
  }
280
288
  finally {
281
289
  await fs.rm(temporaryPath, { force: true }).catch(() => undefined);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The environment a managed command runs with: the bridge's own, without secrets and without
3
+ * the host load governor, plus the command's overrides. A nested Forge process must not join
4
+ * the host ledger: it would queue behind the token this command already holds, so every
5
+ * FORGE_HOST_LOAD_* variable is dropped, the test slot count too (decision 0018). A heavy
6
+ * command that shares the host with other heavy steps sizes its test parallelism for its share.
7
+ */
8
+ export declare function inheritedManagedCommandEnvironment(overrides: Readonly<Record<string, string>>, source?: Readonly<Record<string, string | undefined>>): Readonly<Record<string, string>>;
@@ -0,0 +1,28 @@
1
+ import { withHostTestParallelism, withoutHostLoadGovernorVariables } from "../runtime/host-load-child-environment.js";
2
+ /**
3
+ * The environment a managed command runs with: the bridge's own, without secrets and without
4
+ * the host load governor, plus the command's overrides. A nested Forge process must not join
5
+ * the host ledger: it would queue behind the token this command already holds, so every
6
+ * FORGE_HOST_LOAD_* variable is dropped, the test slot count too (decision 0018). A heavy
7
+ * command that shares the host with other heavy steps sizes its test parallelism for its share.
8
+ */
9
+ export function inheritedManagedCommandEnvironment(overrides, source = process.env) {
10
+ const env = {};
11
+ for (const [key, value] of Object.entries(withoutHostLoadGovernorVariables(source))) {
12
+ if (typeof value === "string" && !looksSensitiveEnvironmentName(key))
13
+ env[key] = value;
14
+ }
15
+ return withHostTestParallelism({ ...env, ...overrides });
16
+ }
17
+ function looksSensitiveEnvironmentName(name) {
18
+ const normalized = name.trim().toUpperCase();
19
+ return normalized.includes("SECRET")
20
+ || normalized.includes("TOKEN")
21
+ || normalized.includes("PASSWORD")
22
+ || normalized.includes("CREDENTIAL")
23
+ || normalized.includes("CONNECTION_STRING")
24
+ || normalized.startsWith("CONNECTIONSTRINGS__")
25
+ || normalized.startsWith("CONNECTIONSTRINGS:")
26
+ || normalized.endsWith("_API_KEY")
27
+ || normalized === "OPENAI_API_KEY";
28
+ }
@@ -1,6 +1,6 @@
1
1
  import { type HostLoadStepGate } from "../runtime/host-load-governor.js";
2
2
  import { type HostLoadStepClassification, type ManagedCommandStepInput } from "../runtime/host-load-step-class.js";
3
- import { type HostLoadStepControl } from "../runtime/host-load-step-run.js";
3
+ import { type HostLoadStepControl, type WaitReportFence } from "../runtime/host-load-step-run.js";
4
4
  /** Host-load facts a managed command receipt carries; absent while the governor is off. */
5
5
  export interface ManagedCommandHostLoadFields {
6
6
  readonly stepClass: string;
@@ -19,8 +19,13 @@ export declare function managedCommandHostLoadGate(): HostLoadStepGate | undefin
19
19
  export declare function setManagedCommandHostLoadGateForTesting(value: HostLoadStepGate | undefined | null): void;
20
20
  /**
21
21
  * Admits one managed command. The waiting receipt is written while the command
22
- * is queued and always lands before the launch receipts, so a stale "waiting"
23
- * write can never replace a later status.
22
+ * is queued, and rewritten whenever the wait changes (a new slot holder, say).
23
+ * The writes run in order and land before the launch receipts, so a stale
24
+ * "waiting" write can never replace a later status or a newer wait. A write
25
+ * that never settles holds the launch (with its token) or the terminal receipt
26
+ * back only for the governor's drain bound; writes still queued after it are
27
+ * dropped as stale, and one still running can no longer replace the receipt
28
+ * (orderedWaitReports, WaitReportFence).
24
29
  */
25
30
  export declare class ManagedCommandHostCapacity {
26
31
  private readonly persistWaiting;
@@ -28,10 +33,10 @@ export declare class ManagedCommandHostCapacity {
28
33
  readonly classification: HostLoadStepClassification;
29
34
  private readonly label;
30
35
  private requestedAtMs;
31
- private waitingWrite;
36
+ private readonly waitingWrites;
32
37
  constructor(input: ManagedCommandStepInput & {
33
38
  readonly label: string;
34
- }, persistWaiting: (fields: ManagedCommandHostLoadFields) => Promise<void>, gateFor?: () => HostLoadStepGate | undefined);
39
+ }, persistWaiting: (fields: ManagedCommandHostLoadFields, fence: WaitReportFence) => Promise<void>, gateFor?: () => HostLoadStepGate | undefined);
35
40
  /** Runs `launch` once admitted; `fields` is undefined with the governor off. */
36
41
  run<T>(signal: AbortSignal, launch: (fields: ManagedCommandHostLoadFields | undefined, control: HostLoadStepControl) => Promise<T>, onReleaseFailed?: (error: unknown) => Promise<void>): Promise<T>;
37
42
  /**
@@ -1,7 +1,7 @@
1
1
  import { hostLoadGovernorFromChildEnvironment } from "../runtime/host-load-child-environment.js";
2
2
  import { HostCapacityTimeoutError } from "../runtime/host-load-governor.js";
3
3
  import { classifyManagedCommand } from "../runtime/host-load-step-class.js";
4
- import { attachSupervisedStepProcess, runHostGovernedStep } from "../runtime/host-load-step-run.js";
4
+ import { attachSupervisedStepProcess, orderedWaitReports, runHostGovernedStep, } from "../runtime/host-load-step-run.js";
5
5
  let gate = null;
6
6
  /** This MCP server's governor, built once from the environment the bridge handed it. */
7
7
  export function managedCommandHostLoadGate() {
@@ -15,8 +15,13 @@ export function setManagedCommandHostLoadGateForTesting(value) {
15
15
  }
16
16
  /**
17
17
  * Admits one managed command. The waiting receipt is written while the command
18
- * is queued and always lands before the launch receipts, so a stale "waiting"
19
- * write can never replace a later status.
18
+ * is queued, and rewritten whenever the wait changes (a new slot holder, say).
19
+ * The writes run in order and land before the launch receipts, so a stale
20
+ * "waiting" write can never replace a later status or a newer wait. A write
21
+ * that never settles holds the launch (with its token) or the terminal receipt
22
+ * back only for the governor's drain bound; writes still queued after it are
23
+ * dropped as stale, and one still running can no longer replace the receipt
24
+ * (orderedWaitReports, WaitReportFence).
20
25
  */
21
26
  export class ManagedCommandHostCapacity {
22
27
  persistWaiting;
@@ -24,12 +29,18 @@ export class ManagedCommandHostCapacity {
24
29
  classification;
25
30
  label;
26
31
  requestedAtMs = null;
27
- waitingWrite = Promise.resolve();
32
+ waitingWrites;
28
33
  constructor(input, persistWaiting, gateFor = managedCommandHostLoadGate) {
29
34
  this.persistWaiting = persistWaiting;
30
35
  this.gateFor = gateFor;
31
36
  this.classification = classifyManagedCommand(input);
32
37
  this.label = input.label;
38
+ this.waitingWrites = orderedWaitReports(async (decision, fence) => await this.persistWaiting({
39
+ stepClass: this.classification.stepClass,
40
+ waitMs: 0,
41
+ waitStartedAt: this.requestedAtMs ?? Date.now(),
42
+ waitDetail: decision.detail,
43
+ }, fence));
33
44
  }
34
45
  /** Runs `launch` once admitted; `fields` is undefined with the governor off. */
35
46
  async run(signal, launch, onReleaseFailed) {
@@ -45,17 +56,10 @@ export class ManagedCommandHostCapacity {
45
56
  signal,
46
57
  // The receipt says host_capacity_token_fenced itself (termination_reason).
47
58
  reportsOwnFence: true,
48
- onWaiting: decision => {
49
- this.waitingWrite = this.persistWaiting({
50
- stepClass: this.classification.stepClass,
51
- waitMs: 0,
52
- waitStartedAt: this.requestedAtMs ?? Date.now(),
53
- waitDetail: decision.detail,
54
- }).catch(() => undefined);
55
- },
59
+ onWaiting: this.waitingWrites.onWaiting,
56
60
  onReleaseFailed,
57
61
  }, async (waitMs, control) => {
58
- await this.waitingWrite;
62
+ await this.waitingWrites.drained();
59
63
  // The launch timer and timeout_ms start inside `launch`, after admission.
60
64
  return await launch(waitMs === null
61
65
  ? undefined
@@ -67,7 +71,7 @@ export class ManagedCommandHostCapacity {
67
71
  * the queue or was stopped while waiting), once its waiting receipt landed.
68
72
  */
69
73
  async unadmittedFields(error) {
70
- await this.waitingWrite;
74
+ await this.waitingWrites.drained();
71
75
  if (this.requestedAtMs === null)
72
76
  return undefined;
73
77
  const waitMs = error instanceof HostCapacityTimeoutError ? error.waitMs : Date.now() - this.requestedAtMs;
@@ -0,0 +1,20 @@
1
+ export interface ArtifactBundleFile {
2
+ readonly fileName: string;
3
+ readonly content: string;
4
+ }
5
+ export interface ArtifactBundlePublicationOptions {
6
+ readonly signal?: AbortSignal;
7
+ /** Fault-injection hook used by publication tests. */
8
+ readonly beforePublishFile?: (fileName: string, index: number) => void | Promise<void>;
9
+ }
10
+ /**
11
+ * Stages a complete phase bundle outside the live artifact directory, then
12
+ * publishes its canonical verdict/marker last. Consumers treat the marker as
13
+ * the bundle's commit point, so they can observe either the old complete bundle
14
+ * or the new complete bundle, never a partially written set. A failed or
15
+ * cancelled publication rolls every touched file back before rejecting.
16
+ */
17
+ export declare function publishArtifactBundleAtomic(artifactRoot: string, files: readonly ArtifactBundleFile[], commitFileName: string, options?: ArtifactBundlePublicationOptions): Promise<void>;
18
+ export declare function validatePostRedaction(validate: () => void): void;
19
+ export declare function postRedactionValidationError(error: unknown): Error;
20
+ export declare function assertStructuralFieldsUnchanged(original: Record<string, unknown>, redacted: Record<string, unknown>): void;