@loucompanion/forge-bridge 0.1.4-dev.494233aa2e50 → 0.1.4-dev.60e18c3cfec6

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 (141) hide show
  1. package/README.md +35 -2
  2. package/dist/bridge/bridge.base.d.ts +9 -0
  3. package/dist/bridge/bridge.service.d.ts +72 -1
  4. package/dist/bridge/bridge.service.js +308 -9
  5. package/dist/bridge/bridge.types.d.ts +16 -0
  6. package/dist/bridge/local-yield-flag.d.ts +6 -0
  7. package/dist/bridge/local-yield-flag.js +34 -0
  8. package/dist/bridge/runner-host-capabilities.d.ts +2 -0
  9. package/dist/bridge/runner-host-capabilities.js +4 -0
  10. package/dist/bridge/test-postgres-capability.d.ts +14 -0
  11. package/dist/bridge/test-postgres-capability.js +120 -0
  12. package/dist/cleanup/cleanup.service.d.ts +9 -0
  13. package/dist/cleanup/cleanup.service.js +72 -109
  14. package/dist/cleanup/cleanup.types.d.ts +4 -0
  15. package/dist/cleanup/forge-owned-paths.d.ts +9 -0
  16. package/dist/cleanup/forge-owned-paths.js +53 -0
  17. package/dist/cleanup/host-runtime-ledger.d.ts +5 -0
  18. package/dist/cleanup/host-runtime-ledger.js +109 -0
  19. package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
  20. package/dist/cleanup/managed-branch-sweep.js +111 -0
  21. package/dist/cli/cli.help.js +18 -0
  22. package/dist/cli/cli.service.d.ts +16 -0
  23. package/dist/cli/cli.service.js +142 -16
  24. package/dist/cli/local-config.d.ts +4 -0
  25. package/dist/cli/local-config.js +26 -4
  26. package/dist/runtime/aspnet-runtime-prebuild.js +94 -6
  27. package/dist/runtime/host-load-admission.d.ts +60 -0
  28. package/dist/runtime/host-load-admission.js +99 -0
  29. package/dist/runtime/host-load-child-environment.d.ts +22 -0
  30. package/dist/runtime/host-load-child-environment.js +67 -0
  31. package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
  32. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  33. package/dist/runtime/host-load-governor-config.d.ts +43 -0
  34. package/dist/runtime/host-load-governor-config.js +76 -0
  35. package/dist/runtime/host-load-governor.d.ts +174 -0
  36. package/dist/runtime/host-load-governor.js +541 -0
  37. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  38. package/dist/runtime/host-load-ledger-lock.js +185 -0
  39. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  40. package/dist/runtime/host-load-runtime-settings.js +78 -0
  41. package/dist/runtime/host-load-sampler.d.ts +43 -0
  42. package/dist/runtime/host-load-sampler.js +74 -6
  43. package/dist/runtime/host-load-step-class.d.ts +68 -0
  44. package/dist/runtime/host-load-step-class.js +106 -0
  45. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  46. package/dist/runtime/host-load-step-reaper.js +95 -0
  47. package/dist/runtime/host-load-step-run.d.ts +73 -0
  48. package/dist/runtime/host-load-step-run.js +102 -0
  49. package/dist/runtime/host-load-token-ledger.d.ts +174 -0
  50. package/dist/runtime/host-load-token-ledger.js +421 -0
  51. package/dist/runtime/host-pressure-stall.d.ts +21 -1
  52. package/dist/runtime/host-pressure-stall.js +48 -1
  53. package/dist/runtime/host-runtime-contract.d.ts +3 -0
  54. package/dist/runtime/host-runtime-contract.js +4 -1
  55. package/dist/runtime/host-runtime-lease.d.ts +74 -4
  56. package/dist/runtime/host-runtime-lease.js +279 -10
  57. package/dist/runtime/host-runtime-promotion.js +12 -0
  58. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  59. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  60. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  61. package/dist/runtime/host-runtime-requirements.js +117 -0
  62. package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
  63. package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
  64. package/dist/runtime/runner-settings.d.ts +100 -0
  65. package/dist/runtime/runner-settings.js +214 -0
  66. package/dist/sandbox/host-capacity-broker.d.ts +107 -0
  67. package/dist/sandbox/host-capacity-broker.js +315 -0
  68. package/dist/sandbox/runtime.d.ts +10 -1
  69. package/dist/sandbox/runtime.js +45 -2
  70. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  71. package/dist/sandbox/sandbox-cgroups.js +42 -0
  72. package/dist/session/managed-attempt-tools.d.ts +2 -0
  73. package/dist/session/managed-attempt-tools.js +156 -37
  74. package/dist/session/managed-command-host-load.d.ts +45 -0
  75. package/dist/session/managed-command-host-load.js +82 -0
  76. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  77. package/dist/session/mcp-argument-coercion.js +121 -0
  78. package/dist/session/phase-completion.artifacts.d.ts +7 -0
  79. package/dist/session/phase-completion.artifacts.js +94 -25
  80. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  81. package/dist/session/phase-completion.command-validation.js +77 -0
  82. package/dist/session/phase-completion.d.ts +4 -0
  83. package/dist/session/phase-completion.helpers.js +13 -12
  84. package/dist/session/phase-completion.js +4 -0
  85. package/dist/session/phase-completion.prompts.js +6 -1
  86. package/dist/session/phase-completion.runtime.d.ts +5 -3
  87. package/dist/session/phase-completion.runtime.js +49 -19
  88. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  89. package/dist/session/phase-completion.schema-parts.js +188 -0
  90. package/dist/session/phase-completion.schemas.d.ts +3 -3
  91. package/dist/session/phase-completion.schemas.js +184 -209
  92. package/dist/session/phase-completion.validation.d.ts +2 -3
  93. package/dist/session/phase-completion.validation.js +46 -92
  94. package/dist/session/pre-publication-host-load.d.ts +27 -0
  95. package/dist/session/pre-publication-host-load.js +111 -0
  96. package/dist/session/pre-publication-process.d.ts +3 -0
  97. package/dist/session/pre-publication-process.js +23 -11
  98. package/dist/session/pre-publication-step-execution.d.ts +11 -0
  99. package/dist/session/pre-publication-step-execution.js +49 -0
  100. package/dist/session/pre-publication-validation.d.ts +9 -9
  101. package/dist/session/pre-publication-validation.js +21 -55
  102. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +2 -1
  103. package/dist/session/provider-cli/provider-cli.artifacts.js +20 -7
  104. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
  105. package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
  106. package/dist/session/provider-cli/provider-cli.process.d.ts +32 -1
  107. package/dist/session/provider-cli/provider-cli.process.js +122 -30
  108. package/dist/session/provider-cli/provider-cli.prompts.d.ts +5 -0
  109. package/dist/session/provider-cli/provider-cli.prompts.js +20 -2
  110. package/dist/session/provider-cli/provider-cli.service.d.ts +6 -0
  111. package/dist/session/provider-cli/provider-cli.service.js +183 -26
  112. package/dist/session/provider-cli/provider-cli.types.d.ts +30 -0
  113. package/dist/session/provider-cli/provider-in-flight-work.d.ts +6 -0
  114. package/dist/session/provider-cli/provider-in-flight-work.js +47 -0
  115. package/dist/session/provider-cli/provider-output-state.d.ts +6 -0
  116. package/dist/session/provider-cli/provider-output-state.js +9 -0
  117. package/dist/session/publishable-worktree-changes.d.ts +10 -1
  118. package/dist/session/publishable-worktree-changes.js +21 -5
  119. package/dist/session/sandbox-host-capacity-gate.d.ts +30 -0
  120. package/dist/session/sandbox-host-capacity-gate.js +229 -0
  121. package/dist/session/session.base.d.ts +9 -1
  122. package/dist/session/session.service.d.ts +9 -2
  123. package/dist/session/session.service.js +120 -5
  124. package/dist/session/session.types.d.ts +3 -0
  125. package/dist/session/session.types.js +12 -3
  126. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  127. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  128. package/dist/shared/process/host-process-supervisor.d.ts +1 -0
  129. package/dist/shared/process/host-process-supervisor.js +1 -1
  130. package/dist/shared/process/process-tree.d.ts +52 -0
  131. package/dist/shared/process/process-tree.js +144 -0
  132. package/dist/shared/process/process.d.ts +67 -0
  133. package/dist/shared/process/process.js +213 -11
  134. package/dist/version.d.ts +1 -1
  135. package/dist/version.js +1 -1
  136. package/dist/worktree/dependency-warmer.d.ts +25 -0
  137. package/dist/worktree/dependency-warmer.js +46 -10
  138. package/dist/worktree/worktree.service.d.ts +10 -1
  139. package/dist/worktree/worktree.service.js +42 -2
  140. package/dist/worktree/worktree.types.d.ts +7 -0
  141. package/package.json +1 -1
@@ -8,7 +8,13 @@ import { attemptDatabaseCapabilityEnvironment, attemptDatabaseCapabilitySecrets,
8
8
  import { assertHostDatabaseCapabilityBoundary } from "../runtime/host-database-capability-boundary.js";
9
9
  import { nativeTestPostgresFallbackConfigEnvironment, nativeTestPostgresFallbackDatabaseMode, nativeTestPostgresFallbackEnvironment, readNativeTestPostgresFallback, } from "../runtime/native-test-postgres-fallback.js";
10
10
  import { redactText } from "../shared/redaction/redaction.js";
11
+ import { emptyToolInputHint, isEmptyToolInput } from "./mcp-argument-coercion.js";
11
12
  import { ManagedBuildCoordinator } from "./managed-build-coordinator.js";
13
+ import { attachManagedCommandProcess, ManagedCommandHostCapacity, } from "./managed-command-host-load.js";
14
+ import { HostCapacityLedgerUnavailableError } from "../runtime/host-load-ledger-lock.js";
15
+ import { isProcessTreeTerminationUnproven } from "../shared/process/process.js";
16
+ import { HostCapacityTokenFencedError } from "../runtime/host-load-token-ledger.js";
17
+ import { hostLoadGovernorEnvironment, hostLoadStateRootEnvironment } from "../runtime/host-load-child-environment.js";
12
18
  import { managedBuildConfiguration, publishManagedBuildReceipt, verifyManagedBuildReceipt, } from "./managed-build-receipt.js";
13
19
  import { managedLongTierTimeoutMs, managedMaximumCommandTimeoutMs, managedVerificationTierTimeoutMs, } from "./managed-verification-timeouts.js";
14
20
  import { resolveWindowsCommandFromPath, StreamingProviderProcessRunner } from "./provider-cli/provider-cli.process.js";
@@ -143,11 +149,17 @@ export function isManagedAttemptTool(name) {
143
149
  || startManagedVerificationNames.has(name)
144
150
  || resetGeneratedOutputNames.has(name);
145
151
  }
152
+ const managedVerificationProfiles = ["dotnet_unit", "dotnet_contract", "dotnet_api_component", "dotnet_orchestration", "dotnet_infrastructure", "dotnet_solution", "dotnet_affected"];
153
+ const managedVerificationProfileHint = `Use one of: ${managedVerificationProfiles.join(", ")}. These are .NET test profiles only; run client, bridge, or Playwright e2e checks with forge.start_managed_command.`;
154
+ /** The input schema a managed-attempt tool advertises; also the shape its arguments are coerced to. */
155
+ export function managedAttemptToolInputSchema(name) {
156
+ return managedAttemptToolDefinition(name).inputSchema;
157
+ }
146
158
  export function managedAttemptToolDefinition(name) {
147
159
  if (startManagedVerificationNames.has(name)) {
148
160
  return {
149
161
  name,
150
- description: "Start a canonical Forge verification profile with runner-owned cwd, arguments, attempt output, timeout, and process supervision. Prefer this over reconstructing broad .NET commands. Continue independent work, then use forge.wait_managed_command for a transport-safe terminal receipt.",
162
+ description: "Start a canonical Forge .NET verification profile with runner-owned cwd, arguments, attempt output, timeout, and process supervision. Prefer this over reconstructing broad .NET commands. Continue independent work, then use forge.wait_managed_command for a transport-safe terminal receipt. To run every shard of a tier in one call, set run_all_shards: true with shard_count 2 or more and without no_build.",
151
163
  inputSchema: {
152
164
  type: "object",
153
165
  additionalProperties: false,
@@ -155,13 +167,14 @@ export function managedAttemptToolDefinition(name) {
155
167
  properties: {
156
168
  profile: {
157
169
  type: "string",
158
- enum: ["dotnet_unit", "dotnet_contract", "dotnet_api_component", "dotnet_orchestration", "dotnet_infrastructure", "dotnet_solution", "dotnet_affected"],
170
+ enum: [...managedVerificationProfiles],
171
+ description: "Required .NET test profile. dotnet_affected selects its own tests and owns its build: it takes no shard or no_build options. dotnet_solution takes no shard options. Client, bridge, and e2e checks are not profiles; use forge.start_managed_command for them.",
159
172
  },
160
- shard_count: { type: "integer", minimum: 1, maximum: 32, default: 1 },
161
- shard_index: { type: "integer", minimum: 0, maximum: 31, default: 0 },
162
- run_all_shards: { type: "boolean", default: false },
173
+ shard_count: { type: "integer", minimum: 1, maximum: 32, default: 1, description: "Number of shards to split the tier into. Must be at least 2 when run_all_shards is true." },
174
+ shard_index: { type: "integer", minimum: 0, maximum: 31, default: 0, description: "Which single shard to run; must be less than shard_count, and 0 when run_all_shards is true." },
175
+ run_all_shards: { type: "boolean", default: false, description: "Run every shard of the tier after one shared build. Requires shard_count of at least 2 and shard_index 0, cannot be combined with no_build, and is not supported for dotnet_solution or dotnet_affected." },
163
176
  max_parallelism: { type: "integer", minimum: 1, maximum: 4, default: 2 },
164
- no_build: { type: "boolean", default: false },
177
+ no_build: { type: "boolean", default: false, description: "Reuse the verified build from an earlier managed build instead of building. Not allowed with run_all_shards or dotnet_affected." },
165
178
  timeout_ms: { type: "integer", minimum: 1000, maximum: 7200000 },
166
179
  },
167
180
  },
@@ -178,8 +191,8 @@ export function managedAttemptToolDefinition(name) {
178
191
  additionalProperties: false,
179
192
  required: ["command", "args"],
180
193
  properties: {
181
- command: { type: "string", minLength: 1 },
182
- args: { type: "array", items: { type: "string" } },
194
+ command: { type: "string", minLength: 1, description: "Required executable only, for example pnpm, node, npm, or dotnet. Not a shell command line: shell syntax such as cd, &&, or pipes is not interpreted." },
195
+ args: { type: "array", items: { type: "string" }, description: "Required argument list, each argument its own string, for example [\"--dir\", \"client\", \"lint\"]. Send [] when there are none. Use cwd instead of cd." },
183
196
  cwd: { type: "string", description: "Worktree-relative directory; defaults to the worktree root." },
184
197
  timeout_ms: { type: "integer", minimum: 1000, maximum: 7200000, default: 2700000 },
185
198
  },
@@ -342,13 +355,13 @@ async function startManagedVerification(input, worktreePath) {
342
355
  const runAllShards = optionalBoolean(record.run_all_shards, "run_all_shards", false);
343
356
  const maxParallelism = optionalBoundedInteger(record.max_parallelism, "max_parallelism", 1, 4, 2);
344
357
  if (runAllShards && shardCount < 2) {
345
- throw new Error("managed_verification_invalid: run_all_shards requires shard_count of at least 2.");
358
+ throw new Error("managed_verification_invalid: run_all_shards requires shard_count of at least 2. Set shard_count to 2 or more to run every shard, or omit run_all_shards to run a single shard.");
346
359
  }
347
360
  if (runAllShards && shardIndex !== 0) {
348
361
  throw new Error("managed_verification_invalid: shard_index must be 0 when run_all_shards is enabled.");
349
362
  }
350
363
  if (runAllShards && noBuild) {
351
- throw new Error("managed_verification_invalid: run_all_shards owns the single prerequisite build and cannot be combined with no_build.");
364
+ throw new Error("managed_verification_invalid: run_all_shards owns the single prerequisite build and cannot be combined with no_build. Omit no_build when run_all_shards is true.");
352
365
  }
353
366
  const outputDirectory = requiredAttemptEnvironment("FORGE_TEST_OUTPUT_DIR");
354
367
  const profileCommand = buildManagedVerificationCommand(profile, outputDirectory, shardCount, shardIndex, noBuild, runAllShards, maxParallelism);
@@ -405,7 +418,7 @@ export function buildManagedVerificationCommand(profile, outputDirectory, shardC
405
418
  };
406
419
  const tier = tiers[profile];
407
420
  if (!tier)
408
- throw new Error(`managed_verification_invalid: unsupported profile ${profile}.`);
421
+ throw new Error(`managed_verification_invalid: unsupported profile ${profile}. ${managedVerificationProfileHint}`);
409
422
  const command = preferredPowerShellExecutable();
410
423
  if (runAllShards) {
411
424
  return {
@@ -488,15 +501,66 @@ function optionValue(args, name) {
488
501
  const index = args.indexOf(name);
489
502
  return index >= 0 ? args[index + 1]?.trim() || null : null;
490
503
  }
504
+ function hostCapacityLossReason(reason) {
505
+ if (reason instanceof HostCapacityTokenFencedError)
506
+ return "host_capacity_token_fenced";
507
+ if (reason instanceof HostCapacityLedgerUnavailableError)
508
+ return "host_capacity_ledger_unavailable";
509
+ return null;
510
+ }
491
511
  async function executeManagedCommand(invocation) {
492
- if (!invocation.buildProducing)
493
- return await executeManagedCommandProcess(invocation);
494
512
  let processStarted = false;
513
+ // The per-worktree build slot is taken first: holding a host token while
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({
516
+ ...invocation,
517
+ hostLoad,
518
+ timedOut: false,
519
+ status: "waiting_for_host_capacity",
520
+ exitCode: null,
521
+ stdout: "",
522
+ stderr: "",
523
+ launchRequested: false,
524
+ }).structuredContent));
525
+ const launch = async (buildQueueWaitMs) => await hostCapacity.run(invocation.controller.signal, async (hostLoad, control) => {
526
+ processStarted = true;
527
+ // A reclaimed token means this command's capacity is gone: it stops. A fence that
528
+ // landed between admission and here stops it too (a listener added now never fires).
529
+ const stopOnFence = () => invocation.controller.abort(control.fenced.reason);
530
+ if (control.fenced?.aborted)
531
+ stopOnFence();
532
+ else
533
+ control.fenced?.addEventListener("abort", stopOnFence, { once: true });
534
+ try {
535
+ return await executeManagedCommandProcess({
536
+ ...invocation,
537
+ buildQueueWaitMs,
538
+ hostLoad,
539
+ // Recording the tree is part of holding the token: if it fails (the token was
540
+ // fenced meanwhile, or the ledger refused), the command stops instead of
541
+ // running on without a reservation the host can account for.
542
+ // Checked against the tree recorded on the token at launch (null: the governor's own).
543
+ holdHostCapacityUntilStopped: reason => control.holdUntilStopped?.(null, reason),
544
+ onProcessStarted: async () => await attachManagedCommandProcess(control, invocation.metadataPath)
545
+ .catch((error) => {
546
+ invocation.controller.abort(error instanceof HostCapacityTokenFencedError || error instanceof HostCapacityLedgerUnavailableError
547
+ ? error
548
+ : new HostCapacityLedgerUnavailableError(`the managed command's process tree could not be recorded on its host load token: ${error instanceof Error ? error.message : String(error)}`, { cause: error }));
549
+ }),
550
+ });
551
+ }
552
+ finally {
553
+ control.fenced?.removeEventListener("abort", stopOnFence);
554
+ }
555
+ },
556
+ // A fenced release is already the receipt's termination reason; only a ledger fault is noted.
557
+ async (error) => error instanceof HostCapacityTokenFencedError ? undefined : await annotateManagedCommandReceipt(invocation.receiptPath, {
558
+ host_capacity_release_error: redactText(error instanceof Error ? error.message : String(error), []),
559
+ }));
495
560
  try {
496
- return await new ManagedBuildCoordinator().withBuildSlot(invocation.worktreePath, async (buildQueueWaitMs) => {
497
- processStarted = true;
498
- return await executeManagedCommandProcess({ ...invocation, buildQueueWaitMs });
499
- }, async () => {
561
+ if (!invocation.buildProducing)
562
+ return await launch();
563
+ return await new ManagedBuildCoordinator().withBuildSlot(invocation.worktreePath, launch, async () => {
500
564
  const waiting = managedCommandResult({
501
565
  ...invocation,
502
566
  timedOut: false,
@@ -512,11 +576,12 @@ async function executeManagedCommand(invocation) {
512
576
  catch (error) {
513
577
  if (processStarted)
514
578
  throw error;
515
- // The command never started (its build-slot wait failed or was stopped). Its receipt
516
- // must still become terminal, or a waiting agent sees it queued forever.
579
+ // The command never started (its build-slot or host-capacity wait failed or was
580
+ // stopped). Its receipt must still become terminal, or a waiting agent sees it queued forever.
517
581
  const ownerExited = ownerExitStoppedCommands.has(invocation.commandId);
518
582
  const receipt = managedCommandResult({
519
583
  ...invocation,
584
+ hostLoad: await hostCapacity.unadmittedFields(error),
520
585
  timedOut: false,
521
586
  status: "runner_error",
522
587
  exitCode: null,
@@ -642,6 +707,8 @@ async function executeManagedCommandProcess(invocation) {
642
707
  }, {
643
708
  onStarted: async () => {
644
709
  clearTimeout(launchTimer);
710
+ // onProcessStarted stops the command itself when its token cannot be held.
711
+ await invocation.onProcessStarted?.();
645
712
  const running = managedCommandResult({
646
713
  ...invocation,
647
714
  timedOut: false,
@@ -688,13 +755,17 @@ async function executeManagedCommandProcess(invocation) {
688
755
  // Only a stop that interrupted the process relabels it. A command that exited on its own
689
756
  // just before its owner asked for the stop keeps its real result.
690
757
  const ownerExited = !timedOut && result.cancelled === true && ownerExitStoppedCommands.has(invocation.commandId);
691
- if (ownerExited) {
692
- stderr = appendBounded(stderr, managedCommandOwnerExitMessage);
758
+ const hostCapacityLoss = !timedOut && !ownerExited && result.cancelled === true
759
+ ? hostCapacityLossReason(controller.signal.reason)
760
+ : null;
761
+ const fenced = hostCapacityLoss !== null;
762
+ if (ownerExited || fenced) {
763
+ stderr = appendBounded(stderr, ownerExited ? managedCommandOwnerExitMessage : controller.signal.reason.message);
693
764
  outputRevision += 1;
694
765
  lastOutputAt = Date.now();
695
766
  lastOutputStream = "stderr";
696
767
  }
697
- const status = timedOut ? "timed_out" : ownerExited ? "runner_error" : result.exitCode === 0 ? "pass" : "fail";
768
+ const status = timedOut ? "timed_out" : ownerExited || fenced ? "runner_error" : result.exitCode === 0 ? "pass" : "fail";
698
769
  const receiptCoverage = managedBuildReceiptCoverage(invocation);
699
770
  const buildReceipt = status === "pass" && receiptCoverage
700
771
  ? await publishManagedBuildReceipt({
@@ -717,9 +788,9 @@ async function executeManagedCommandProcess(invocation) {
717
788
  lastOutputStream,
718
789
  buildReceipt,
719
790
  buildReceiptReused: invocation.buildReceiptReuse !== undefined,
720
- terminationReason: ownerExited ? "owner_exited" : undefined,
791
+ terminationReason: ownerExited ? "owner_exited" : hostCapacityLoss ?? undefined,
721
792
  // The runner resolves only after the stopped tree is proven gone.
722
- processTreeTerminated: ownerExited ? true : undefined,
793
+ processTreeTerminated: ownerExited || fenced ? true : undefined,
723
794
  });
724
795
  await persistManagedCommandReceipt(invocation.receiptPath, receipt.structuredContent);
725
796
  return managedCommandPublicResult(receipt);
@@ -745,11 +816,17 @@ async function executeManagedCommandProcess(invocation) {
745
816
  outputRevision,
746
817
  lastOutputAt,
747
818
  lastOutputStream,
748
- terminationReason: ownerExited ? "owner_exited" : undefined,
819
+ // A host capacity loss before launch (a fence that landed while it was admitted) is named too.
820
+ terminationReason: ownerExited ? "owner_exited" : hostCapacityLossReason(controller.signal.reason) ?? undefined,
749
821
  // The runner rejected, so its tree was not proven stopped; teardown still stops it.
750
822
  processTreeTerminated: false,
751
823
  });
752
824
  await persistManagedCommandReceipt(invocation.receiptPath, receipt.structuredContent);
825
+ // The runner stops the tree before it rejects; only a failed termination proof means
826
+ // part of it may still run. Its token is then kept, never returned with this receipt.
827
+ if (isProcessTreeTerminationUnproven(error)) {
828
+ invocation.holdHostCapacityUntilStopped?.(error instanceof Error ? error : new Error(String(error)));
829
+ }
753
830
  return managedCommandPublicResult(receipt);
754
831
  }
755
832
  finally {
@@ -773,6 +850,11 @@ async function readManagedCommand(input) {
773
850
  }
774
851
  throw error;
775
852
  }
853
+ // A queued receipt is written once; its wait so far is computed when it is read.
854
+ const hostLoadWaitStartedAt = Date.parse(String(receipt.host_load_wait_started_at));
855
+ if (receipt.status === "waiting_for_host_capacity" && Number.isFinite(hostLoadWaitStartedAt)) {
856
+ receipt = { ...receipt, host_load_wait_ms: Math.max(0, Date.now() - hostLoadWaitStartedAt) };
857
+ }
776
858
  const status = typeof receipt.status === "string" ? receipt.status : "unknown";
777
859
  const stdout = typeof receipt.stdout === "string" ? receipt.stdout : "";
778
860
  const stderr = typeof receipt.stderr === "string" ? receipt.stderr : "";
@@ -823,15 +905,18 @@ async function waitManagedCommand(input) {
823
905
  const elapsedMs = receipt.structuredContent.elapsed_ms;
824
906
  const timeoutMs = receipt.structuredContent.timeout_ms;
825
907
  const lastOutputAt = Date.parse(String(receipt.structuredContent.last_output_at));
826
- const progress = receipt.structuredContent.status === "running" && typeof elapsedMs === "number"
827
- ? ` It has run for ${Math.round(elapsedMs / 1000)}s`
828
- + (Number.isFinite(lastOutputAt) ? `, last output ${Math.max(0, Math.round((Date.now() - lastOutputAt) / 1000))}s ago` : ", with no output yet")
829
- + `. Forge refreshes this receipt every ${managedCommandProgressPersistIntervalMs / 1000}s, so a rising elapsed time means the command is still alive even when it is quiet.`
830
- // Agents otherwise abandon long verification tiers and record a blocker that is not one.
831
- + (typeof timeoutMs === "number"
832
- ? ` Forge itself ends it at its ${Math.round(timeoutMs / 60_000)}-minute limit if it hangs, so keep waiting; a running command is not a blocker.`
833
- : "")
834
- : "";
908
+ const hostLoadWaitMs = receipt.structuredContent.host_load_wait_ms;
909
+ const progress = receipt.structuredContent.status === "waiting_for_host_capacity" && typeof hostLoadWaitMs === "number"
910
+ ? ` It has waited ${Math.round(hostLoadWaitMs / 1000)}s for host capacity and has not started yet; its timeout starts only once it is admitted, so queue time never counts against it. Keep waiting; a queued command is not a blocker.`
911
+ : receipt.structuredContent.status === "running" && typeof elapsedMs === "number"
912
+ ? ` It has run for ${Math.round(elapsedMs / 1000)}s`
913
+ + (Number.isFinite(lastOutputAt) ? `, last output ${Math.max(0, Math.round((Date.now() - lastOutputAt) / 1000))}s ago` : ", with no output yet")
914
+ + `. Forge refreshes this receipt every ${managedCommandProgressPersistIntervalMs / 1000}s, so a rising elapsed time means the command is still alive even when it is quiet.`
915
+ // Agents otherwise abandon long verification tiers and record a blocker that is not one.
916
+ + (typeof timeoutMs === "number"
917
+ ? ` Forge itself ends it at its ${Math.round(timeoutMs / 60_000)}-minute limit if it hangs, so keep waiting; a running command is not a blocker.`
918
+ : "")
919
+ : "";
835
920
  return {
836
921
  ...receipt,
837
922
  content: [{
@@ -876,7 +961,9 @@ async function persistManagedCommandReceipt(receiptPath, receipt) {
876
961
  }
877
962
  }
878
963
  function managedCommandResult(values) {
879
- const elapsedMs = Date.now() - values.startedAt;
964
+ // Governed commands count elapsed time from admission: queue time is host_load_wait_ms.
965
+ const hostLoad = values.hostLoad;
966
+ const elapsedMs = Date.now() - (hostLoad ? hostLoad.executionStartedAt ?? Date.now() : values.startedAt);
880
967
  const isTerminal = terminalManagedCommandStatuses.has(values.status);
881
968
  const diagnostics = isTerminal
882
969
  ? managedCommandDiagnostics(values.stdout, values.stderr)
@@ -921,6 +1008,7 @@ function managedCommandResult(values) {
921
1008
  build_coordination: values.buildProducing ? "per_worktree_exclusive" : null,
922
1009
  build_queue_wait_ms: values.buildQueueWaitMs ?? 0,
923
1010
  build_receipt_reused: values.buildReceiptReused ?? false,
1011
+ ...(hostLoad ? managedCommandHostLoadReceipt(hostLoad) : {}),
924
1012
  build_receipt: values.buildReceipt ? {
925
1013
  fingerprint: values.buildReceipt.fingerprint,
926
1014
  receipt_path: values.buildReceipt.receiptPath,
@@ -940,6 +1028,18 @@ function managedCommandResult(values) {
940
1028
  isError: isTerminal && values.status !== "pass",
941
1029
  };
942
1030
  }
1031
+ function managedCommandHostLoadReceipt(hostLoad) {
1032
+ const waiting = hostLoad.waitStartedAt !== undefined;
1033
+ return {
1034
+ host_load_step_class: hostLoad.stepClass,
1035
+ host_load_wait_ms: waiting ? Math.max(0, Date.now() - hostLoad.waitStartedAt) : hostLoad.waitMs,
1036
+ ...(waiting ? { host_load_wait_started_at: new Date(hostLoad.waitStartedAt).toISOString() } : {}),
1037
+ };
1038
+ }
1039
+ async function annotateManagedCommandReceipt(receiptPath, fields) {
1040
+ const receipt = JSON.parse(await fs.readFile(receiptPath, "utf8"));
1041
+ await persistManagedCommandReceipt(receiptPath, { ...receipt, ...fields });
1042
+ }
943
1043
  /** This server's birth identity, so a reissued PID is never mistaken for a live owner. */
944
1044
  function managedCommandOwnerIdentity() {
945
1045
  // Windows identity capture starts PowerShell; the PID check alone is used there.
@@ -1016,6 +1116,10 @@ async function containedWorkingDirectory(worktreePath, input) {
1016
1116
  function inheritedEnvironment(overrides) {
1017
1117
  const env = {};
1018
1118
  for (const [key, value] of Object.entries(process.env)) {
1119
+ // A nested Forge process must not join the host ledger: it would queue behind the
1120
+ // token this command already holds.
1121
+ if (key === hostLoadGovernorEnvironment || key === hostLoadStateRootEnvironment)
1122
+ continue;
1019
1123
  if (typeof value === "string" && !looksSensitiveEnvironmentName(key))
1020
1124
  env[key] = value;
1021
1125
  }
@@ -1104,8 +1208,17 @@ function asRecord(value) {
1104
1208
  throw new Error("managed_command_invalid: input must be an object.");
1105
1209
  return value;
1106
1210
  }
1211
+ const requiredInputExamples = {
1212
+ command: "Send the executable as command and each argument as its own string in args, for example {\"command\": \"pnpm\", \"args\": [\"--dir\", \"client\", \"lint\"]}.",
1213
+ profile: managedVerificationProfileHint,
1214
+ command_id: "Send the command_id returned by forge.start_managed_command or forge.start_managed_verification.",
1215
+ };
1107
1216
  function requiredInputString(record, name) {
1108
- return requiredStandaloneString(record[name], name);
1217
+ const value = record[name];
1218
+ if (typeof value === "string" && value.trim())
1219
+ return value.trim();
1220
+ const hints = [requiredInputExamples[name], isEmptyToolInput(record) ? emptyToolInputHint : undefined].filter(Boolean);
1221
+ throw new Error(`managed_command_invalid: ${name} is required.${hints.length > 0 ? ` ${hints.join(" ")}` : ""}`);
1109
1222
  }
1110
1223
  function validatedCommandId(record) {
1111
1224
  const commandId = requiredInputString(record, "command_id");
@@ -1122,7 +1235,13 @@ function requiredStandaloneString(value, name) {
1122
1235
  function requiredStringArray(record, name) {
1123
1236
  const value = record[name];
1124
1237
  if (!Array.isArray(value) || value.some(entry => typeof entry !== "string")) {
1125
- throw new Error(`managed_command_invalid: ${name} must be a string array.`);
1238
+ const shellLine = typeof record.command === "string" && /\s/u.test(record.command.trim());
1239
+ const hint = typeof value === "string"
1240
+ ? " (received a string). Put each argument in its own string, for example [\"--dir\", \"client\", \"test\"]."
1241
+ : value === undefined
1242
+ ? ` (it was omitted). Send [] when there are no arguments.${shellLine ? " command holds only the executable, so move its arguments into args; shell syntax such as cd, &&, or pipes is not interpreted, so set cwd instead of cd." : ""}`
1243
+ : " Every argument must be a string.";
1244
+ throw new Error(`managed_command_invalid: ${name} must be a string array${hint}`);
1126
1245
  }
1127
1246
  return value;
1128
1247
  }
@@ -0,0 +1,45 @@
1
+ import { type HostLoadStepGate } from "../runtime/host-load-governor.js";
2
+ import { type HostLoadStepClassification, type ManagedCommandStepInput } from "../runtime/host-load-step-class.js";
3
+ import { type HostLoadStepControl } from "../runtime/host-load-step-run.js";
4
+ /** Host-load facts a managed command receipt carries; absent while the governor is off. */
5
+ export interface ManagedCommandHostLoadFields {
6
+ readonly stepClass: string;
7
+ /** Queue time before admission; never part of elapsed_ms. */
8
+ readonly waitMs: number;
9
+ /** Set while the command is still queued: the receipt reports the wait so far. */
10
+ readonly waitStartedAt?: number;
11
+ /** When the command was admitted; elapsed_ms counts from here. */
12
+ readonly executionStartedAt?: number;
13
+ }
14
+ /** This MCP server's governor, built once from the environment the bridge handed it. */
15
+ export declare function managedCommandHostLoadGate(): HostLoadStepGate | undefined;
16
+ /** Test support: installs a gate (undefined disables it; null rebuilds from the environment). */
17
+ export declare function setManagedCommandHostLoadGateForTesting(value: HostLoadStepGate | undefined | null): void;
18
+ /**
19
+ * Admits one managed command. The waiting receipt is written while the command
20
+ * is queued and always lands before the launch receipts, so a stale "waiting"
21
+ * write can never replace a later status.
22
+ */
23
+ export declare class ManagedCommandHostCapacity {
24
+ private readonly persistWaiting;
25
+ private readonly gateFor;
26
+ readonly classification: HostLoadStepClassification;
27
+ private readonly label;
28
+ private requestedAtMs;
29
+ private waitingWrite;
30
+ constructor(input: ManagedCommandStepInput & {
31
+ readonly label: string;
32
+ }, persistWaiting: (fields: ManagedCommandHostLoadFields) => Promise<void>, gateFor?: () => HostLoadStepGate | undefined);
33
+ /** Runs `launch` once admitted; `fields` is undefined with the governor off. */
34
+ run<T>(signal: AbortSignal, launch: (fields: ManagedCommandHostLoadFields | undefined, control: HostLoadStepControl) => Promise<T>, onReleaseFailed?: (error: unknown) => Promise<void>): Promise<T>;
35
+ /**
36
+ * Host-load facts for a command that was never admitted (it timed out in
37
+ * the queue or was stopped while waiting), once its waiting receipt landed.
38
+ */
39
+ unadmittedFields(error: unknown): Promise<ManagedCommandHostLoadFields | undefined>;
40
+ }
41
+ /**
42
+ * The managed command's process tree as its supervisor recorded it, for its
43
+ * host load token: a reclaim then stops exactly this tree before reuse.
44
+ */
45
+ export declare function attachManagedCommandProcess(control: HostLoadStepControl, metadataPath: string): Promise<void>;
@@ -0,0 +1,82 @@
1
+ import { hostLoadGovernorFromChildEnvironment } from "../runtime/host-load-child-environment.js";
2
+ import { HostCapacityTimeoutError } from "../runtime/host-load-governor.js";
3
+ import { classifyManagedCommand } from "../runtime/host-load-step-class.js";
4
+ import { attachSupervisedStepProcess, runHostGovernedStep } from "../runtime/host-load-step-run.js";
5
+ let gate = null;
6
+ /** This MCP server's governor, built once from the environment the bridge handed it. */
7
+ export function managedCommandHostLoadGate() {
8
+ if (gate === null)
9
+ gate = hostLoadGovernorFromChildEnvironment();
10
+ return gate;
11
+ }
12
+ /** Test support: installs a gate (undefined disables it; null rebuilds from the environment). */
13
+ export function setManagedCommandHostLoadGateForTesting(value) {
14
+ gate = value;
15
+ }
16
+ /**
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.
20
+ */
21
+ export class ManagedCommandHostCapacity {
22
+ persistWaiting;
23
+ gateFor;
24
+ classification;
25
+ label;
26
+ requestedAtMs = null;
27
+ waitingWrite = Promise.resolve();
28
+ constructor(input, persistWaiting, gateFor = managedCommandHostLoadGate) {
29
+ this.persistWaiting = persistWaiting;
30
+ this.gateFor = gateFor;
31
+ this.classification = classifyManagedCommand(input);
32
+ this.label = input.label;
33
+ }
34
+ /** Runs `launch` once admitted; `fields` is undefined with the governor off. */
35
+ async run(signal, launch, onReleaseFailed) {
36
+ const current = this.gateFor();
37
+ if (current?.enabled)
38
+ this.requestedAtMs = Date.now();
39
+ return await runHostGovernedStep(current, {
40
+ classification: this.classification,
41
+ label: this.label,
42
+ dispatchAttemptId: process.env.FORGE_DISPATCH_ATTEMPT_ID?.trim() || null,
43
+ // An agent waits on its managed commands; readiness probes never start one.
44
+ priority: "foreground",
45
+ signal,
46
+ // The receipt says host_capacity_token_fenced itself (termination_reason).
47
+ reportsOwnFence: true,
48
+ onWaiting: () => {
49
+ this.waitingWrite = this.persistWaiting({
50
+ stepClass: this.classification.stepClass,
51
+ waitMs: 0,
52
+ waitStartedAt: this.requestedAtMs ?? Date.now(),
53
+ }).catch(() => undefined);
54
+ },
55
+ onReleaseFailed,
56
+ }, async (waitMs, control) => {
57
+ await this.waitingWrite;
58
+ // The launch timer and timeout_ms start inside `launch`, after admission.
59
+ return await launch(waitMs === null
60
+ ? undefined
61
+ : { stepClass: this.classification.stepClass, waitMs, executionStartedAt: Date.now() }, control);
62
+ });
63
+ }
64
+ /**
65
+ * Host-load facts for a command that was never admitted (it timed out in
66
+ * the queue or was stopped while waiting), once its waiting receipt landed.
67
+ */
68
+ async unadmittedFields(error) {
69
+ await this.waitingWrite;
70
+ if (this.requestedAtMs === null)
71
+ return undefined;
72
+ const waitMs = error instanceof HostCapacityTimeoutError ? error.waitMs : Date.now() - this.requestedAtMs;
73
+ return { stepClass: this.classification.stepClass, waitMs: Math.round(waitMs), executionStartedAt: Date.now() };
74
+ }
75
+ }
76
+ /**
77
+ * The managed command's process tree as its supervisor recorded it, for its
78
+ * host load token: a reclaim then stops exactly this tree before reuse.
79
+ */
80
+ export async function attachManagedCommandProcess(control, metadataPath) {
81
+ await attachSupervisedStepProcess(control, metadataPath);
82
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * MCP clients sometimes send a structured tool argument as its JSON text, for
3
+ * example `sidecars: "[{...}]"` instead of `sidecars: [{...}]`. At the tool-call
4
+ * boundary, before any validation, this replaces such a string with its parsed
5
+ * value, but only where the tool's declared input schema says the value is an
6
+ * array or an object and the string parses to exactly that kind of value.
7
+ *
8
+ * Nothing else is coerced: a string field that happens to contain JSON stays a
9
+ * string, an undeclared field is left alone, and a malformed string is passed
10
+ * through unchanged so the validator reports it.
11
+ */
12
+ export declare function coerceJsonStringArguments(value: unknown, schema: unknown): unknown;
13
+ type StructuredKind = "array" | "object";
14
+ /**
15
+ * Explains why a value is not the expected array or object, for validator
16
+ * messages. A string gets an explicit instruction because that is the usual
17
+ * client mistake; the hint never echoes the value itself.
18
+ */
19
+ export declare function structuredTypeHint(value: unknown, expected: StructuredKind): string;
20
+ /** True when a tool call arrived with no usable arguments at all. */
21
+ export declare function isEmptyToolInput(input: unknown): boolean;
22
+ export declare const emptyToolInputHint: string;
23
+ export {};
@@ -0,0 +1,121 @@
1
+ /**
2
+ * MCP clients sometimes send a structured tool argument as its JSON text, for
3
+ * example `sidecars: "[{...}]"` instead of `sidecars: [{...}]`. At the tool-call
4
+ * boundary, before any validation, this replaces such a string with its parsed
5
+ * value, but only where the tool's declared input schema says the value is an
6
+ * array or an object and the string parses to exactly that kind of value.
7
+ *
8
+ * Nothing else is coerced: a string field that happens to contain JSON stays a
9
+ * string, an undeclared field is left alone, and a malformed string is passed
10
+ * through unchanged so the validator reports it.
11
+ */
12
+ export function coerceJsonStringArguments(value, schema) {
13
+ const node = schemaNode(schema);
14
+ if (!node)
15
+ return value;
16
+ const expected = structuredKind(node);
17
+ let current = value;
18
+ if (typeof current === "string" && expected) {
19
+ const parsed = parseStructured(current, expected);
20
+ if (parsed !== undefined)
21
+ current = parsed;
22
+ }
23
+ if (Array.isArray(current)) {
24
+ const items = schemaNode(node.items);
25
+ if (!items || !acceptsKind(node, "array"))
26
+ return current;
27
+ let changed = current !== value;
28
+ const next = current.map((entry) => {
29
+ const coerced = coerceJsonStringArguments(entry, items);
30
+ if (coerced !== entry)
31
+ changed = true;
32
+ return coerced;
33
+ });
34
+ return changed ? next : current;
35
+ }
36
+ if (isPlainRecord(current)) {
37
+ const properties = schemaNode(node.properties);
38
+ if (!properties || !acceptsKind(node, "object"))
39
+ return current;
40
+ let next = current !== value ? { ...current } : null;
41
+ for (const [key, propertySchema] of Object.entries(properties)) {
42
+ if (!Object.prototype.hasOwnProperty.call(current, key))
43
+ continue;
44
+ const original = current[key];
45
+ const coerced = coerceJsonStringArguments(original, propertySchema);
46
+ if (coerced !== original) {
47
+ next ??= { ...current };
48
+ next[key] = coerced;
49
+ }
50
+ }
51
+ return next ?? current;
52
+ }
53
+ return current;
54
+ }
55
+ function structuredKind(node) {
56
+ const type = node.type;
57
+ if (type === "array" || type === "object")
58
+ return type;
59
+ if (Array.isArray(type)) {
60
+ // A schema that also admits a string must keep the string as sent.
61
+ if (type.includes("string"))
62
+ return null;
63
+ if (type.includes("array") && !type.includes("object"))
64
+ return "array";
65
+ if (type.includes("object") && !type.includes("array"))
66
+ return "object";
67
+ }
68
+ return null;
69
+ }
70
+ function acceptsKind(node, kind) {
71
+ const type = node.type;
72
+ if (type === undefined)
73
+ return true;
74
+ return type === kind || (Array.isArray(type) && type.includes(kind));
75
+ }
76
+ function parseStructured(text, expected) {
77
+ const trimmed = text.trim();
78
+ if (!trimmed.startsWith(expected === "array" ? "[" : "{"))
79
+ return undefined;
80
+ try {
81
+ const parsed = JSON.parse(trimmed);
82
+ if (expected === "array" ? Array.isArray(parsed) : isPlainRecord(parsed))
83
+ return parsed;
84
+ }
85
+ catch {
86
+ // Leave malformed JSON text in place; the validator reports it with a hint.
87
+ }
88
+ return undefined;
89
+ }
90
+ function schemaNode(value) {
91
+ return isPlainRecord(value) ? value : null;
92
+ }
93
+ function isPlainRecord(value) {
94
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
95
+ }
96
+ /**
97
+ * Explains why a value is not the expected array or object, for validator
98
+ * messages. A string gets an explicit instruction because that is the usual
99
+ * client mistake; the hint never echoes the value itself.
100
+ */
101
+ export function structuredTypeHint(value, expected) {
102
+ if (value === undefined || value === null) {
103
+ return " (it was omitted)";
104
+ }
105
+ if (typeof value === "string") {
106
+ return expected === "array"
107
+ ? " (received a string; pass a JSON array value, not a quoted string)"
108
+ : " (received a string; pass a JSON object value, not a quoted string)";
109
+ }
110
+ if (Array.isArray(value))
111
+ return " (received an array)";
112
+ return typeof value === "object" ? " (received an object)" : ` (received a ${typeof value})`;
113
+ }
114
+ /** True when a tool call arrived with no usable arguments at all. */
115
+ export function isEmptyToolInput(input) {
116
+ return input === undefined
117
+ || input === null
118
+ || (isPlainRecord(input) && Object.keys(input).length === 0);
119
+ }
120
+ export const emptyToolInputHint = "No arguments were received: the call arrived as an empty object. "
121
+ + "If the call was large it was probably cut off before it was sent; resend it with every required field.";
@@ -2,6 +2,13 @@ import { type CompletionArtifactReference, type CompletionPhase, type Completion
2
2
  import type { RunnerDispatchArtifact } from "./session.types.js";
3
3
  export declare function writeDecomposeGateCompletionArtifact(config: CompletionToolServerConfig, gate: DecomposeCompletionGate, toolName: string, input: unknown): Promise<CompletionArtifactReference>;
4
4
  export declare function writeDraftGateCompletionArtifact(config: CompletionToolServerConfig, gate: DraftCompletionGate, toolName: string, input: unknown): Promise<CompletionArtifactReference>;
5
+ /**
6
+ * Judges a Decompose gate call before anything is written and returns its status. The gate's
7
+ * input schema advertises exactly these rules (see the completion tool schema contract test).
8
+ */
9
+ export declare function validateDecomposeGatePayload(gate: DecomposeCompletionGate, payload: Record<string, unknown>): string;
10
+ /** Judges a Draft gate call before anything is written and returns its status. */
11
+ export declare function validateDraftGatePayload(gate: DraftCompletionGate, payload: Record<string, unknown>): string;
5
12
  export declare function writeCompletionArtifact(config: CompletionToolServerConfig, toolName: string, input: unknown): Promise<CompletionArtifactReference>;
6
13
  export declare function writeArchitectCompletionArtifact(config: CompletionToolServerConfig, payload: Record<string, unknown>, status: string, producedBy: string): Promise<CompletionArtifactReference>;
7
14
  export declare function writeQaGateCompletionArtifact(config: CompletionToolServerConfig, gate: QaCompletionGate, input: unknown): Promise<CompletionArtifactReference>;