@loucompanion/forge-bridge 0.1.4-dev.d2d83bc81b6a → 0.1.4-dev.e3697e9f5c98

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 (153) hide show
  1. package/README.md +44 -2
  2. package/dist/bridge/bridge.base.d.ts +9 -0
  3. package/dist/bridge/bridge.service.d.ts +75 -2
  4. package/dist/bridge/bridge.service.js +317 -9
  5. package/dist/bridge/bridge.types.d.ts +22 -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-database-capability-boundary.d.ts +1 -1
  28. package/dist/runtime/host-database-capability-boundary.js +1 -0
  29. package/dist/runtime/host-facts.d.ts +35 -0
  30. package/dist/runtime/host-facts.js +95 -0
  31. package/dist/runtime/host-load-admission.d.ts +60 -0
  32. package/dist/runtime/host-load-admission.js +99 -0
  33. package/dist/runtime/host-load-child-environment.d.ts +22 -0
  34. package/dist/runtime/host-load-child-environment.js +67 -0
  35. package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
  36. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  37. package/dist/runtime/host-load-governor-config.d.ts +43 -0
  38. package/dist/runtime/host-load-governor-config.js +76 -0
  39. package/dist/runtime/host-load-governor.d.ts +174 -0
  40. package/dist/runtime/host-load-governor.js +541 -0
  41. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  42. package/dist/runtime/host-load-ledger-lock.js +185 -0
  43. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  44. package/dist/runtime/host-load-runtime-settings.js +78 -0
  45. package/dist/runtime/host-load-sampler.d.ts +126 -0
  46. package/dist/runtime/host-load-sampler.js +232 -0
  47. package/dist/runtime/host-load-step-class.d.ts +68 -0
  48. package/dist/runtime/host-load-step-class.js +106 -0
  49. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  50. package/dist/runtime/host-load-step-reaper.js +95 -0
  51. package/dist/runtime/host-load-step-run.d.ts +73 -0
  52. package/dist/runtime/host-load-step-run.js +102 -0
  53. package/dist/runtime/host-load-token-ledger.d.ts +174 -0
  54. package/dist/runtime/host-load-token-ledger.js +421 -0
  55. package/dist/runtime/host-pressure-stall.d.ts +61 -0
  56. package/dist/runtime/host-pressure-stall.js +168 -0
  57. package/dist/runtime/host-runtime-contract.d.ts +4 -0
  58. package/dist/runtime/host-runtime-contract.js +6 -1
  59. package/dist/runtime/host-runtime-lease.d.ts +74 -4
  60. package/dist/runtime/host-runtime-lease.js +281 -11
  61. package/dist/runtime/host-runtime-promotion.d.ts +23 -0
  62. package/dist/runtime/host-runtime-promotion.js +48 -0
  63. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  64. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  65. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  66. package/dist/runtime/host-runtime-requirements.js +117 -0
  67. package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
  68. package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
  69. package/dist/runtime/runner-settings.d.ts +100 -0
  70. package/dist/runtime/runner-settings.js +214 -0
  71. package/dist/sandbox/host-capacity-broker.d.ts +107 -0
  72. package/dist/sandbox/host-capacity-broker.js +315 -0
  73. package/dist/sandbox/runtime.d.ts +10 -1
  74. package/dist/sandbox/runtime.js +45 -2
  75. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  76. package/dist/sandbox/sandbox-cgroups.js +42 -0
  77. package/dist/session/managed-attempt-tools.d.ts +2 -0
  78. package/dist/session/managed-attempt-tools.js +156 -37
  79. package/dist/session/managed-command-host-load.d.ts +45 -0
  80. package/dist/session/managed-command-host-load.js +82 -0
  81. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  82. package/dist/session/mcp-argument-coercion.js +121 -0
  83. package/dist/session/phase-completion.artifacts.d.ts +7 -0
  84. package/dist/session/phase-completion.artifacts.js +98 -25
  85. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  86. package/dist/session/phase-completion.command-validation.js +77 -0
  87. package/dist/session/phase-completion.d.ts +4 -0
  88. package/dist/session/phase-completion.helpers.js +13 -12
  89. package/dist/session/phase-completion.js +4 -0
  90. package/dist/session/phase-completion.prompts.js +6 -1
  91. package/dist/session/phase-completion.runtime.d.ts +5 -3
  92. package/dist/session/phase-completion.runtime.js +49 -19
  93. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  94. package/dist/session/phase-completion.schema-parts.js +188 -0
  95. package/dist/session/phase-completion.schemas.d.ts +3 -3
  96. package/dist/session/phase-completion.schemas.js +184 -209
  97. package/dist/session/phase-completion.validation.d.ts +2 -3
  98. package/dist/session/phase-completion.validation.js +46 -92
  99. package/dist/session/pre-publication-host-load.d.ts +27 -0
  100. package/dist/session/pre-publication-host-load.js +111 -0
  101. package/dist/session/pre-publication-pass.d.ts +60 -0
  102. package/dist/session/pre-publication-pass.js +145 -0
  103. package/dist/session/pre-publication-process.d.ts +3 -0
  104. package/dist/session/pre-publication-process.js +25 -12
  105. package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
  106. package/dist/session/pre-publication-skipped-tests.js +109 -0
  107. package/dist/session/pre-publication-step-execution.d.ts +11 -0
  108. package/dist/session/pre-publication-step-execution.js +49 -0
  109. package/dist/session/pre-publication-validation.d.ts +30 -20
  110. package/dist/session/pre-publication-validation.js +169 -139
  111. package/dist/session/provider-cli/pre-publication-repair.d.ts +40 -0
  112. package/dist/session/provider-cli/pre-publication-repair.js +243 -0
  113. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +2 -1
  114. package/dist/session/provider-cli/provider-cli.artifacts.js +21 -15
  115. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
  116. package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
  117. package/dist/session/provider-cli/provider-cli.process.d.ts +32 -1
  118. package/dist/session/provider-cli/provider-cli.process.js +122 -30
  119. package/dist/session/provider-cli/provider-cli.prompts.d.ts +5 -0
  120. package/dist/session/provider-cli/provider-cli.prompts.js +20 -2
  121. package/dist/session/provider-cli/provider-cli.service.d.ts +4 -1
  122. package/dist/session/provider-cli/provider-cli.service.js +194 -161
  123. package/dist/session/provider-cli/provider-cli.types.d.ts +30 -0
  124. package/dist/session/provider-cli/provider-in-flight-work.d.ts +6 -0
  125. package/dist/session/provider-cli/provider-in-flight-work.js +47 -0
  126. package/dist/session/provider-cli/provider-output-state.d.ts +6 -0
  127. package/dist/session/provider-cli/provider-output-state.js +9 -0
  128. package/dist/session/publishable-worktree-changes.d.ts +54 -0
  129. package/dist/session/publishable-worktree-changes.js +193 -0
  130. package/dist/session/sandbox-host-capacity-gate.d.ts +30 -0
  131. package/dist/session/sandbox-host-capacity-gate.js +229 -0
  132. package/dist/session/session.base.d.ts +9 -1
  133. package/dist/session/session.service.d.ts +9 -2
  134. package/dist/session/session.service.js +120 -5
  135. package/dist/session/session.types.d.ts +3 -0
  136. package/dist/session/session.types.js +15 -3
  137. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  138. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  139. package/dist/shared/process/host-process-supervisor.d.ts +1 -0
  140. package/dist/shared/process/host-process-supervisor.js +1 -1
  141. package/dist/shared/process/process-tree.d.ts +52 -0
  142. package/dist/shared/process/process-tree.js +144 -0
  143. package/dist/shared/process/process.d.ts +67 -0
  144. package/dist/shared/process/process.js +213 -11
  145. package/dist/shared/provider-capabilities.js +5 -6
  146. package/dist/version.d.ts +1 -1
  147. package/dist/version.js +1 -1
  148. package/dist/worktree/dependency-warmer.d.ts +25 -0
  149. package/dist/worktree/dependency-warmer.js +46 -10
  150. package/dist/worktree/worktree.service.d.ts +10 -1
  151. package/dist/worktree/worktree.service.js +42 -2
  152. package/dist/worktree/worktree.types.d.ts +7 -0
  153. package/package.json +2 -2
@@ -278,7 +278,10 @@ function buildRuntimeContextPrompt(dispatch, prompt, runtimeEnvironment) {
278
278
  ? "- `FORGE_HOST_CONCURRENCY=host_parallel_safe` means Forge verified this contract's assigned-port probe and gave this attempt independent ports, paths, and process supervisors. Do not share or discover another attempt's runtime resources."
279
279
  : "- `FORGE_HOST_CONCURRENCY=host_serial_only` means Forge holds the runner-local project singleton named by `FORGE_SINGLETON_KEYS`; do not bypass or release it yourself.";
280
280
  const playwright = runtimeEnvironment?.FORGE_PLAYWRIGHT_CONFIG
281
- ? "\n- For Playwright, use the generated `FORGE_PLAYWRIGHT_CONFIG`; it targets this attempt's verified `FORGE_PLAYWRIGHT_BASE_URL`, disables project `webServer` startup/reuse, and writes under `FORGE_TEST_OUTPUT_DIR`. Do not invoke the project Playwright config directly."
281
+ ? "\n- For Playwright, use the generated `FORGE_PLAYWRIGHT_CONFIG`; it targets this attempt's verified `FORGE_PLAYWRIGHT_BASE_URL`, disables project `webServer` startup/reuse, and writes under `FORGE_TEST_OUTPUT_DIR`. Do not invoke the project Playwright config directly. Run `playwright test --config <absolute value of FORGE_PLAYWRIGHT_CONFIG>` from the Playwright project directory through `forge.start_managed_command` (in Forge: command `pnpm`, args `[\"--dir\", \"tests/e2e\", \"exec\", \"playwright\", \"test\", \"--config\", \"<path>\"]`), and append spec file paths such as `specs/<name>.spec.ts` to run only the specs you are working on. Repository wrappers that start their own disposable stack, such as Forge's `pnpm --dir tests/e2e test`, refuse to run inside a managed attempt; Forge-owned pre-publication still runs the full suite."
282
+ : "";
283
+ const stackUnavailable = runtimeEnvironment?.FORGE_RUNTIME_STACK === "unavailable"
284
+ ? "\n- `FORGE_RUNTIME_STACK=unavailable` means Forge's restart of this attempt's application stack failed, so no attempt-owned API, web, or Playwright URLs are supplied for this turn. Do not reuse URLs or ports from an earlier turn or start the stack yourself; fix the source so the restart succeeds. Forge restarts the stack and reruns validation after this turn."
282
285
  : "";
283
286
  return `${prompt.trimEnd()}
284
287
 
@@ -292,7 +295,7 @@ ${concurrency}
292
295
  - If a tool creates \`TestResults\`, \`test-results\`, or \`playwright-report\` beneath source, use \`forge.reset_generated_outputs\` to quarantine only those untracked generated directories. Do not issue a recursive delete.
293
296
  - Use the attempt-scoped \`FORGE_TMPDIR\`, \`FORGE_LOG_DIR\`, \`FORGE_CACHE_DIR\`, \`FORGE_BROWSER_PROFILE_DIR\`, and \`FORGE_TEST_OUTPUT_DIR\` paths instead of shared host paths.
294
297
  - Use supplied \`FORGE_*\` URLs, ports, and paths. Do not search for a free port, kill a process occupying one, or reuse an existing dev server, browser profile, database, container, network, or volume.
295
- - Never run broad process or Docker cleanup. Stop only resources you created for this resource lease.${playwright}`;
298
+ - Never run broad process or Docker cleanup. Stop only resources you created for this resource lease.${playwright}${stackUnavailable}`;
296
299
  }
297
300
  return `${prompt.trimEnd()}
298
301
 
@@ -392,6 +395,13 @@ Architect revision context:
392
395
  - Reviewer feedback: ${dispatch.architectRevision.feedback}
393
396
  Revise the prior plan in response to the feedback. Preserve accepted scope and only change what the feedback requires.`;
394
397
  }
398
+ /**
399
+ * Headless providers must not end a turn to wait: Forge stops the provider shortly after
400
+ * a turn ends, and nothing started in the background reports back.
401
+ */
402
+ export function providerTurnEndRule(completionStep) {
403
+ return `Ending your turn ends this run. Forge runs you headless and stops the provider process shortly after a turn ends, together with any managed command it is still running. Background tasks, Monitor, \`run_in_background\` shells and other watchers never report back after that. Do not end your turn to wait for anything: block on \`forge.wait_managed_command\` until it returns a terminal receipt (call it again while \`command_continues=true\`), then ${completionStep} in the same turn.`;
404
+ }
395
405
  export function buildImplementationPrompt(dispatch, phase = completionPhaseFromDispatch(dispatch)) {
396
406
  return `You are Forge's ${phase.replace(/_/g, " ")} phase runner running locally in a prepared git worktree.
397
407
 
@@ -403,6 +413,7 @@ Forge owns protocol files: worktree prep, injected .forge commands/hooks/skills,
403
413
  Read Forge-provided context under .forge when needed, but do not edit .forge files or create Forge verdict/report artifacts by hand.
404
414
 
405
415
  ${completionPromptForPhase(phase)}
416
+ ${providerTurnEndRule("call the completion tool")}
406
417
 
407
418
  Finish with a concise summary of changed files and verification after calling the completion tool.`;
408
419
  }
@@ -417,6 +428,7 @@ Forge owns protocol files: worktree prep, injected .forge commands/hooks/skills,
417
428
  Read Forge-provided context under .forge when needed, but do not edit .forge files or create Forge verdict/report artifacts by hand.
418
429
 
419
430
  ${completionPromptForDevelopCycle(phase)}
431
+ ${providerTurnEndRule("call the current phase's completion tool")}
420
432
 
421
433
  Finish with a concise summary of changed files and verification after the validation completion tool has accepted the work, or after the current phase tool records a non-pass blocker.`;
422
434
  }
@@ -431,6 +443,7 @@ Forge owns protocol files: worktree prep, injected .forge commands/hooks/skills,
431
443
  Read Forge-provided context under .forge when needed, but do not edit .forge files or create Forge Debug artifacts by hand.
432
444
 
433
445
  ${completionPromptForDebugCycle(isDebugCompletionPhaseForProvider(phase) ? phase : "debug_repro")}
446
+ ${providerTurnEndRule("call the current Debug gate's completion tool")}
434
447
 
435
448
  Finish with a concise summary of changed files and verification after the debug_regression completion tool has accepted the work, or after the current Debug gate tool records a non-pass blocker.`;
436
449
  }
@@ -587,6 +600,7 @@ Report in-scope defects as actionable findings with repro steps, expected/actual
587
600
  Out-of-scope or follow-up issues belong in candidate_bugs instead of blocking the current item. If a broad regression command fails only on a surface outside both the current diff and acceptance criteria, reproduce that failure with a focused command. The regression gate may pass only when the current item has independent passing evidence and the failed command is preserved with classification out_of_scope_failure, candidate_bug_id, scope_evidence, acceptance_criteria_independent: true, repro_command, and a non-zero repro_exit_code. Never use this classification for an unexplained failure, a runner/environment failure, or a failure that can affect the current item.
588
601
 
589
602
  ${completionPromptForQaCycle("qa_plan", artifactRoot)}
603
+ ${providerTurnEndRule("call the next QA gate's completion tool, through forge.complete_qa_verdict,")}
590
604
 
591
605
  Finish with a concise summary only after forge.complete_qa_verdict accepts the QA bundle.`;
592
606
  }
@@ -607,6 +621,8 @@ export function buildConflictResolvePrompt(dispatch, branchName) {
607
621
  The current branch is the pull request branch ${branchName}. Resolve merge conflicts against ${targetBranch}.
608
622
  Fetch origin, merge ${targetBranch} into ${branchName} with --no-commit, resolve conflicts conservatively, and run relevant validation when practical.
609
623
  Leave every repair change uncommitted and unpushed. Forge Bridge owns the sole final commit and compare-and-swap push after validation passes.
624
+ Deletions on ${targetBranch} are part of the merge. Never restore a file that ${targetBranch} deleted and ${branchName} never changed, and never revert ${targetBranch} edits to files ${branchName} never changed, including under .forge/. Forge rejects a resolution that does.
625
+ A modify/delete conflict (one side deleted the file, the other changed it) is a real conflict for you to decide: resolve it explicitly with \`git rm <path>\` to accept the deletion or \`git add <path>\` to keep the changed file, and name each such path and your decision in your final summary. A binary conflict has no markers: put the chosen version on disk and \`git add <path>\`. Forge rejects a merge that leaves any of these unresolved or keeps conflict markers.
610
626
  Keep the original work item intent intact:
611
627
  - Work item: ${dispatch.workItem.id}
612
628
  - Title: ${dispatch.workItem.title}
@@ -644,6 +660,7 @@ Forge prepared two required inputs before this agent started:
644
660
  Read both first. The readiness contract supplies attempt-scoped E2E URLs, Playwright/browser readiness, runnable local preflight commands, and provider-only spec patterns. Run every listed local preflight. Do not override the readiness environment or bypass its provider-only exclusions: those specs require infrastructure unavailable inside this managed attempt. Record each applicable provider-only step and the provider check that supplies its proof, and leave provider CI authoritative without weakening its coverage.
645
661
 
646
662
  After repair and validation, call forge.complete_ci_repair with the complete structured handoff. Forge Bridge will validate it and will not commit, push, or report success until that gate passes. If the tool rejects the payload, correct the exact missing evidence it reports and call it again.
663
+ ${providerTurnEndRule("call forge.complete_ci_repair")}
647
664
 
648
665
  Keep the original work item intent intact:
649
666
  - Work item: ${dispatch.workItem.id}
@@ -695,6 +712,7 @@ Before handing a changed diff back for publication:
695
712
  4. Fix validation failures locally before requesting publication. Preserve acceptance criteria and assertions; do not skip tests, weaken checks, change retry budgets, or edit the trusted validation contract to get green. A tier that is still running has not failed to finish: Forge terminates a hung command at its runner-owned limit, which the receipt reports as timeout_ms (${managedMaximumCommandTimeoutMs / 60_000} minutes for dotnet_affected, ${managedQuickTierTimeoutMs / 60_000} minutes for Unit and Contract, ${managedLongTierTimeoutMs / 60_000} minutes for one shard of another tier, and more for an all-shard run, scaled to its shard waves), and its receipt then reports timed_out. Never stop waiting, or record needs_rework, because a required tier is still running. Record a blocker only when infrastructure is unavailable; when a required check ends with a terminal timed_out, timeout_termination_failed, or runner_error receipt that a rerun cannot clear; when a receipt's elapsed time stops rising across waits; or when a real failure cannot be fixed after diagnosis. Then record the exact blocker and preserve the diff without claiming validation passed.
696
713
  5. Inspect the final diff after all fixes and generated-file changes, run git diff --check, and rerun checks affected by any subsequent edit. Record commands, the affected-test selection it printed, exit statuses, and terminal evidence paths in the completion evidence. Finalize changed_files from that final diff, not an earlier repair draft.
697
714
  Only after applicable local validation passes, call forge.complete_comment_repair with the exact head, issue key, finding identities, and evidence. Legitimate no-code rejection or already-addressed outcomes are successful dispositions and do not require an empty commit or unrelated test suites; provide evidence for each disposition.
715
+ ${providerTurnEndRule("call forge.complete_comment_repair")}
698
716
  Forge Bridge owns any commit and compare-and-swap push after its independent pre-publication gate succeeds, then selectively resolves only review threads dispositioned fixed, already_addressed, or server-verified accepted_transfer while all fences still match. The accepted-transfer receipt remains in durable repair evidence and source/target scope; Forge does not post a provider reply automatically. A local pass is not a GitHub CI pass: provider-only checks remain pending until CI runs on the pushed head. Do not request another review yourself; Forge owns the green-CI-before-review sequence.
699
717
  Keep the original work item intent intact:
700
718
  - Work item: ${dispatch.workItem.id}
@@ -56,7 +56,8 @@ export declare class ProcessBackedProviderCliService implements ProviderCliServi
56
56
  private readonly providerToolHeartbeatIntervalMs;
57
57
  private readonly publicationCoordinator;
58
58
  private readonly prePublicationValidator;
59
- constructor(processRunner?: ProviderProcessRunner, git?: GitClient, providerToolHeartbeatIntervalMs?: number, publicationCoordinator?: WorktreeLifecycleCoordinator, prePublicationValidator?: PrePublicationValidator);
59
+ private readonly prePublicationRepairTurns;
60
+ constructor(processRunner?: ProviderProcessRunner, git?: GitClient, providerToolHeartbeatIntervalMs?: number, publicationCoordinator?: WorktreeLifecycleCoordinator, prePublicationValidator?: PrePublicationValidator, prePublicationRepairTurns?: number);
60
61
  runDraft(context: ProviderCliDraftContext): Promise<ProviderCliRunResult>;
61
62
  runImplementation(context: ProviderCliRunContext): Promise<ProviderCliRunResult>;
62
63
  runArchitect(context: ProviderCliRunContext): Promise<ProviderCliRunResult>;
@@ -67,4 +68,6 @@ export declare class ProcessBackedProviderCliService implements ProviderCliServi
67
68
  private recoverMissingQaCompletion;
68
69
  private recoverMissingCommentRepairCompletion;
69
70
  private validatePrePublicationWithRecovery;
71
+ /** Resumes the provider thread for one in-place repair turn; the turn must leave HEAD where it was. */
72
+ private runPrePublicationRepairTurn;
70
73
  }