@loucompanion/forge-bridge 0.1.4-dev.bfa11ebe98c6 → 0.1.4-dev.c03d3c89ec4a

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 (174) hide show
  1. package/README.md +45 -3
  2. package/dist/bridge/bridge.base.d.ts +9 -0
  3. package/dist/bridge/bridge.service.d.ts +84 -2
  4. package/dist/bridge/bridge.service.js +358 -12
  5. package/dist/bridge/bridge.types.d.ts +22 -0
  6. package/dist/bridge/dispatch-result-outbox.d.ts +11 -1
  7. package/dist/bridge/dispatch-result-outbox.js +31 -6
  8. package/dist/bridge/local-yield-flag.d.ts +6 -0
  9. package/dist/bridge/local-yield-flag.js +34 -0
  10. package/dist/bridge/runner-host-capabilities.d.ts +2 -0
  11. package/dist/bridge/runner-host-capabilities.js +4 -0
  12. package/dist/bridge/test-postgres-capability.d.ts +14 -0
  13. package/dist/bridge/test-postgres-capability.js +120 -0
  14. package/dist/cleanup/cleanup.service.d.ts +9 -0
  15. package/dist/cleanup/cleanup.service.js +72 -109
  16. package/dist/cleanup/cleanup.types.d.ts +4 -0
  17. package/dist/cleanup/forge-owned-paths.d.ts +9 -0
  18. package/dist/cleanup/forge-owned-paths.js +53 -0
  19. package/dist/cleanup/host-runtime-ledger.d.ts +5 -0
  20. package/dist/cleanup/host-runtime-ledger.js +109 -0
  21. package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
  22. package/dist/cleanup/managed-branch-sweep.js +111 -0
  23. package/dist/cli/cli.help.js +20 -2
  24. package/dist/cli/cli.service.d.ts +16 -0
  25. package/dist/cli/cli.service.js +142 -16
  26. package/dist/cli/local-config.d.ts +4 -0
  27. package/dist/cli/local-config.js +26 -4
  28. package/dist/runtime/aspnet-runtime-prebuild.js +94 -6
  29. package/dist/runtime/attempt-database-broker.d.ts +89 -0
  30. package/dist/runtime/attempt-database-broker.js +390 -0
  31. package/dist/runtime/attempt-process-supervisor.d.ts +24 -0
  32. package/dist/runtime/attempt-process-supervisor.js +77 -3
  33. package/dist/runtime/host-database-capability-boundary.d.ts +1 -1
  34. package/dist/runtime/host-database-capability-boundary.js +1 -0
  35. package/dist/runtime/host-diagnostics.js +4 -3
  36. package/dist/runtime/host-facts.d.ts +35 -0
  37. package/dist/runtime/host-facts.js +95 -0
  38. package/dist/runtime/host-load-admission.d.ts +60 -0
  39. package/dist/runtime/host-load-admission.js +99 -0
  40. package/dist/runtime/host-load-child-environment.d.ts +22 -0
  41. package/dist/runtime/host-load-child-environment.js +67 -0
  42. package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
  43. package/dist/runtime/host-load-forge-cgroups.js +140 -0
  44. package/dist/runtime/host-load-governor-config.d.ts +43 -0
  45. package/dist/runtime/host-load-governor-config.js +76 -0
  46. package/dist/runtime/host-load-governor.d.ts +174 -0
  47. package/dist/runtime/host-load-governor.js +541 -0
  48. package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
  49. package/dist/runtime/host-load-ledger-lock.js +185 -0
  50. package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
  51. package/dist/runtime/host-load-runtime-settings.js +78 -0
  52. package/dist/runtime/host-load-sampler.d.ts +126 -0
  53. package/dist/runtime/host-load-sampler.js +232 -0
  54. package/dist/runtime/host-load-step-class.d.ts +68 -0
  55. package/dist/runtime/host-load-step-class.js +106 -0
  56. package/dist/runtime/host-load-step-reaper.d.ts +27 -0
  57. package/dist/runtime/host-load-step-reaper.js +95 -0
  58. package/dist/runtime/host-load-step-run.d.ts +73 -0
  59. package/dist/runtime/host-load-step-run.js +102 -0
  60. package/dist/runtime/host-load-token-ledger.d.ts +174 -0
  61. package/dist/runtime/host-load-token-ledger.js +421 -0
  62. package/dist/runtime/host-pressure-stall.d.ts +61 -0
  63. package/dist/runtime/host-pressure-stall.js +168 -0
  64. package/dist/runtime/host-runtime-contract.d.ts +4 -0
  65. package/dist/runtime/host-runtime-contract.js +75 -11
  66. package/dist/runtime/host-runtime-lease.d.ts +76 -4
  67. package/dist/runtime/host-runtime-lease.js +386 -32
  68. package/dist/runtime/host-runtime-promotion.d.ts +23 -0
  69. package/dist/runtime/host-runtime-promotion.js +48 -0
  70. package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
  71. package/dist/runtime/host-runtime-requirements-check.js +29 -0
  72. package/dist/runtime/host-runtime-requirements.d.ts +36 -0
  73. package/dist/runtime/host-runtime-requirements.js +117 -0
  74. package/dist/runtime/managed-command-teardown.d.ts +62 -0
  75. package/dist/runtime/managed-command-teardown.js +607 -0
  76. package/dist/runtime/node-host-runtime-adapter.js +5 -4
  77. package/dist/runtime/playwright-browser-cache.d.ts +39 -0
  78. package/dist/runtime/playwright-browser-cache.js +227 -0
  79. package/dist/runtime/playwright-host-runtime-adapter.d.ts +18 -0
  80. package/dist/runtime/playwright-host-runtime-adapter.js +61 -55
  81. package/dist/runtime/runner-settings.d.ts +100 -0
  82. package/dist/runtime/runner-settings.js +214 -0
  83. package/dist/sandbox/host-capacity-broker.d.ts +107 -0
  84. package/dist/sandbox/host-capacity-broker.js +315 -0
  85. package/dist/sandbox/repository-lock.js +3 -2
  86. package/dist/sandbox/runtime.d.ts +10 -1
  87. package/dist/sandbox/runtime.js +50 -6
  88. package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
  89. package/dist/sandbox/sandbox-cgroups.js +42 -0
  90. package/dist/session/managed-attempt-tools.d.ts +27 -0
  91. package/dist/session/managed-attempt-tools.js +366 -45
  92. package/dist/session/managed-build-coordinator.d.ts +1 -1
  93. package/dist/session/managed-build-coordinator.js +8 -4
  94. package/dist/session/managed-command-host-load.d.ts +45 -0
  95. package/dist/session/managed-command-host-load.js +82 -0
  96. package/dist/session/mcp-argument-coercion.d.ts +23 -0
  97. package/dist/session/mcp-argument-coercion.js +121 -0
  98. package/dist/session/phase-completion.artifacts.d.ts +7 -0
  99. package/dist/session/phase-completion.artifacts.js +98 -25
  100. package/dist/session/phase-completion.command-validation.d.ts +7 -0
  101. package/dist/session/phase-completion.command-validation.js +77 -0
  102. package/dist/session/phase-completion.d.ts +4 -0
  103. package/dist/session/phase-completion.helpers.js +13 -12
  104. package/dist/session/phase-completion.js +4 -0
  105. package/dist/session/phase-completion.prompts.js +6 -1
  106. package/dist/session/phase-completion.runtime.d.ts +5 -3
  107. package/dist/session/phase-completion.runtime.js +78 -36
  108. package/dist/session/phase-completion.schema-parts.d.ts +19 -0
  109. package/dist/session/phase-completion.schema-parts.js +188 -0
  110. package/dist/session/phase-completion.schemas.d.ts +3 -3
  111. package/dist/session/phase-completion.schemas.js +206 -221
  112. package/dist/session/phase-completion.validation.d.ts +2 -3
  113. package/dist/session/phase-completion.validation.js +46 -92
  114. package/dist/session/pre-publication-host-load.d.ts +27 -0
  115. package/dist/session/pre-publication-host-load.js +111 -0
  116. package/dist/session/pre-publication-pass.d.ts +60 -0
  117. package/dist/session/pre-publication-pass.js +145 -0
  118. package/dist/session/pre-publication-process.d.ts +23 -0
  119. package/dist/session/pre-publication-process.js +109 -0
  120. package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
  121. package/dist/session/pre-publication-skipped-tests.js +109 -0
  122. package/dist/session/pre-publication-step-execution.d.ts +11 -0
  123. package/dist/session/pre-publication-step-execution.js +49 -0
  124. package/dist/session/pre-publication-validation.d.ts +30 -20
  125. package/dist/session/pre-publication-validation.js +178 -193
  126. package/dist/session/provider-cli/pre-publication-repair.d.ts +40 -0
  127. package/dist/session/provider-cli/pre-publication-repair.js +243 -0
  128. package/dist/session/provider-cli/provider-cli.artifacts.d.ts +2 -1
  129. package/dist/session/provider-cli/provider-cli.artifacts.js +21 -15
  130. package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
  131. package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
  132. package/dist/session/provider-cli/provider-cli.process.d.ts +37 -1
  133. package/dist/session/provider-cli/provider-cli.process.js +299 -25
  134. package/dist/session/provider-cli/provider-cli.prompts.d.ts +7 -0
  135. package/dist/session/provider-cli/provider-cli.prompts.js +62 -9
  136. package/dist/session/provider-cli/provider-cli.runtime.d.ts +6 -0
  137. package/dist/session/provider-cli/provider-cli.runtime.js +14 -0
  138. package/dist/session/provider-cli/provider-cli.service.d.ts +4 -1
  139. package/dist/session/provider-cli/provider-cli.service.js +200 -162
  140. package/dist/session/provider-cli/provider-cli.types.d.ts +30 -0
  141. package/dist/session/provider-cli/provider-in-flight-work.d.ts +6 -0
  142. package/dist/session/provider-cli/provider-in-flight-work.js +47 -0
  143. package/dist/session/provider-cli/provider-output-state.d.ts +6 -0
  144. package/dist/session/provider-cli/provider-output-state.js +9 -0
  145. package/dist/session/provider-cli/provider-usage.d.ts +2 -1
  146. package/dist/session/publishable-worktree-changes.d.ts +54 -0
  147. package/dist/session/publishable-worktree-changes.js +193 -0
  148. package/dist/session/sandbox-host-capacity-gate.d.ts +30 -0
  149. package/dist/session/sandbox-host-capacity-gate.js +229 -0
  150. package/dist/session/session.base.d.ts +9 -1
  151. package/dist/session/session.service.d.ts +9 -2
  152. package/dist/session/session.service.js +120 -5
  153. package/dist/session/session.types.d.ts +3 -0
  154. package/dist/session/session.types.js +15 -3
  155. package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
  156. package/dist/session/workspace-runtime-fingerprint.js +138 -0
  157. package/dist/shared/process/host-process-recovery.js +3 -2
  158. package/dist/shared/process/host-process-supervisor.d.ts +1 -0
  159. package/dist/shared/process/host-process-supervisor.js +6 -5
  160. package/dist/shared/process/process-tree.d.ts +52 -0
  161. package/dist/shared/process/process-tree.js +144 -0
  162. package/dist/shared/process/process.d.ts +67 -0
  163. package/dist/shared/process/process.js +213 -11
  164. package/dist/shared/provider-capabilities.js +5 -6
  165. package/dist/shared/time/monotonic.d.ts +1 -0
  166. package/dist/shared/time/monotonic.js +8 -0
  167. package/dist/version.d.ts +1 -1
  168. package/dist/version.js +1 -1
  169. package/dist/worktree/dependency-warmer.d.ts +25 -0
  170. package/dist/worktree/dependency-warmer.js +120 -10
  171. package/dist/worktree/worktree.service.d.ts +10 -1
  172. package/dist/worktree/worktree.service.js +42 -2
  173. package/dist/worktree/worktree.types.d.ts +7 -0
  174. 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
 
@@ -358,11 +361,8 @@ ${dependencies}
358
361
 
359
362
  Use this predecessor output as foundation. Do not redesign or recreate predecessor scope. If the expected output is unavailable in the checkout/base branch, stop and report dependency_output_unavailable.`;
360
363
  }
361
- export function designerRefInstruction(dispatch) {
362
- if (!dispatch.designerRefs || dispatch.designerRefs.refs.length === 0) {
363
- return "";
364
- }
365
- const refs = dispatch.designerRefs.refs
364
+ function designerRefList(dispatch) {
365
+ return (dispatch.designerRefs?.refs ?? [])
366
366
  .map((attachment, index) => {
367
367
  const ref = attachment.ref;
368
368
  const anchor = ref.anchor ? `#${ref.anchor}` : "";
@@ -373,13 +373,47 @@ export function designerRefInstruction(dispatch) {
373
373
  - Reason: ${attachment.reason || "No reason recorded."}`;
374
374
  })
375
375
  .join("\n");
376
+ }
377
+ function hasDesignerRefs(dispatch) {
378
+ return (dispatch.designerRefs?.refs.length ?? 0) > 0;
379
+ }
380
+ const designRefUnavailableRule = "If a required Designer ref is missing or cannot be inspected in the pinned commit/worktree, stop and report design_ref_unavailable instead of inventing replacement behavior.";
381
+ export function designerRefInstruction(dispatch) {
382
+ if (!hasDesignerRefs(dispatch)) {
383
+ return "";
384
+ }
376
385
  return `
377
386
  Designer packet context:
378
387
  This ${dispatch.designerRefs.ownerType} inherits approved Designer packet refs. Use these refs as implementation planning constraints and cite the relevant paths in tasks when they shape scope.
379
388
 
380
- ${refs}
389
+ ${designerRefList(dispatch)}
390
+
391
+ Visual acceptance: the delivered UI must match these refs in layout, component set, visible states and copy. Add a qa_plan.final_qa check that opens the affected screens, captures screenshots and compares them against each ref; text-only criteria do not satisfy a design ref.
392
+ ${designRefUnavailableRule}`;
393
+ }
394
+ export function designerRefBuildInstruction(dispatch) {
395
+ if (!hasDesignerRefs(dispatch)) {
396
+ return "";
397
+ }
398
+ return `
399
+ Design target:
400
+ This work builds against approved Designer refs. Open each ref before changing UI, match its layout, component set, visible states and copy, and reuse the components it names instead of inventing new ones. Do not add UI the refs do not show unless the spec requires it.
401
+
402
+ ${designerRefList(dispatch)}
403
+
404
+ ${designRefUnavailableRule}`;
405
+ }
406
+ export function designerRefQaInstruction(dispatch) {
407
+ if (!hasDesignerRefs(dispatch)) {
408
+ return "";
409
+ }
410
+ return `
411
+ Visual acceptance (Designer refs):
412
+ This Story was built against the Designer refs below. For each one, open the affected screen, capture a screenshot and compare it with the ref: layout, component set, visible states and copy. Record each comparison in browser_checks. A visible mismatch the spec does not explain is an in-scope defect, even when every text acceptance criterion passes.
413
+
414
+ ${designerRefList(dispatch)}
381
415
 
382
- If a required Designer ref is missing or cannot be inspected in the pinned commit/worktree, stop and report design_ref_unavailable instead of inventing replacement behavior.`;
416
+ ${designRefUnavailableRule}`;
383
417
  }
384
418
  export function architectRevisionInstruction(dispatch) {
385
419
  if (!dispatch.architectRevision) {
@@ -392,17 +426,26 @@ Architect revision context:
392
426
  - Reviewer feedback: ${dispatch.architectRevision.feedback}
393
427
  Revise the prior plan in response to the feedback. Preserve accepted scope and only change what the feedback requires.`;
394
428
  }
429
+ /**
430
+ * Headless providers must not end a turn to wait: Forge stops the provider shortly after
431
+ * a turn ends, and nothing started in the background reports back.
432
+ */
433
+ export function providerTurnEndRule(completionStep) {
434
+ 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.`;
435
+ }
395
436
  export function buildImplementationPrompt(dispatch, phase = completionPhaseFromDispatch(dispatch)) {
396
437
  return `You are Forge's ${phase.replace(/_/g, " ")} phase runner running locally in a prepared git worktree.
397
438
 
398
439
  Read .forge/work-items/${dispatch.workItem.id}/spec.md and any prior phase artifacts required by this phase.
399
440
  ${phaseWorkInstruction(phase)}
400
441
  ${qaReworkImplementationInstruction(dispatch)}
442
+ ${designerRefBuildInstruction(dispatch)}
401
443
  Use the repository's existing conventions. Run relevant tests when practical.
402
444
  Forge owns protocol files: worktree prep, injected .forge commands/hooks/skills, phase verdict artifacts, reports, and commits.
403
445
  Read Forge-provided context under .forge when needed, but do not edit .forge files or create Forge verdict/report artifacts by hand.
404
446
 
405
447
  ${completionPromptForPhase(phase)}
448
+ ${providerTurnEndRule("call the completion tool")}
406
449
 
407
450
  Finish with a concise summary of changed files and verification after calling the completion tool.`;
408
451
  }
@@ -412,11 +455,13 @@ export function buildDevelopCyclePrompt(dispatch, phase = completionPhaseFromDis
412
455
  Read .forge/work-items/${dispatch.workItem.id}/spec.md, implement the work item, self-review the diff, then validate it in this same provider session.
413
456
  Start in the ${phase.replace(/_/g, " ")} phase. Do not stop after implementation if it passes; continue through self-review and validation using the next instruction returned by each completion tool.
414
457
  ${qaReworkImplementationInstruction(dispatch)}
458
+ ${designerRefBuildInstruction(dispatch)}
415
459
  Use the repository's existing conventions. Run relevant tests when practical.
416
460
  Forge owns protocol files: worktree prep, injected .forge commands/hooks/skills, phase verdict artifacts, reports, and commits.
417
461
  Read Forge-provided context under .forge when needed, but do not edit .forge files or create Forge verdict/report artifacts by hand.
418
462
 
419
463
  ${completionPromptForDevelopCycle(phase)}
464
+ ${providerTurnEndRule("call the current phase's completion tool")}
420
465
 
421
466
  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
467
  }
@@ -426,11 +471,13 @@ export function buildDebugCyclePrompt(dispatch, phase = completionPhaseFromDispa
426
471
  Read .forge/work-items/${dispatch.workItem.id}/spec.md, reproduce or characterize the bug, isolate root cause, apply the smallest safe fix, then prove the regression in this same provider session.
427
472
  Start in the ${phase.replace(/_/g, " ")} gate. Do not stop after a passing Debug gate; continue through the next Debug MCP instruction returned by the tool server until debug_regression is accepted or the current gate records a non-pass blocker.
428
473
  ${debugQaReworkInstruction(dispatch)}
474
+ ${designerRefBuildInstruction(dispatch)}
429
475
  Use the repository's existing conventions. Run focused tests when practical, especially the original repro and required regressions.
430
476
  Forge owns protocol files: worktree prep, injected .forge commands/hooks/skills, Debug verdict artifacts, reports, and commits.
431
477
  Read Forge-provided context under .forge when needed, but do not edit .forge files or create Forge Debug artifacts by hand.
432
478
 
433
479
  ${completionPromptForDebugCycle(isDebugCompletionPhaseForProvider(phase) ? phase : "debug_repro")}
480
+ ${providerTurnEndRule("call the current Debug gate's completion tool")}
434
481
 
435
482
  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
483
  }
@@ -580,6 +627,7 @@ ${dispatch.workItem.systemInfo || "Not provided."}
580
627
  ${storyQaInstruction(dispatch)}
581
628
  Inspect the validated implementation evidence referenced by the dispatch and the owner-scoped QA artifacts under ${artifactRoot}/ when present.
582
629
  ${qaBrowserInstruction(dispatch)}
630
+ ${designerRefQaInstruction(dispatch)}
583
631
  ${qaReworkRetestInstruction(dispatch)}
584
632
  QA is read-mostly: inspect code, run commands, and exercise browser/app flows when available, but do not edit product source or tests.
585
633
  Record concrete evidence. For UI/browser work, include browser_checks with URLs/routes, actions, observed results, screenshots/traces when available, console errors, failed network requests, and responsive checks. Store browser sidecars under ${sidecarRoot}/.
@@ -587,6 +635,7 @@ Report in-scope defects as actionable findings with repro steps, expected/actual
587
635
  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
636
 
589
637
  ${completionPromptForQaCycle("qa_plan", artifactRoot)}
638
+ ${providerTurnEndRule("call the next QA gate's completion tool, through forge.complete_qa_verdict,")}
590
639
 
591
640
  Finish with a concise summary only after forge.complete_qa_verdict accepts the QA bundle.`;
592
641
  }
@@ -607,6 +656,8 @@ export function buildConflictResolvePrompt(dispatch, branchName) {
607
656
  The current branch is the pull request branch ${branchName}. Resolve merge conflicts against ${targetBranch}.
608
657
  Fetch origin, merge ${targetBranch} into ${branchName} with --no-commit, resolve conflicts conservatively, and run relevant validation when practical.
609
658
  Leave every repair change uncommitted and unpushed. Forge Bridge owns the sole final commit and compare-and-swap push after validation passes.
659
+ 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.
660
+ 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
661
  Keep the original work item intent intact:
611
662
  - Work item: ${dispatch.workItem.id}
612
663
  - Title: ${dispatch.workItem.title}
@@ -644,6 +695,7 @@ Forge prepared two required inputs before this agent started:
644
695
  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
696
 
646
697
  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.
698
+ ${providerTurnEndRule("call forge.complete_ci_repair")}
647
699
 
648
700
  Keep the original work item intent intact:
649
701
  - Work item: ${dispatch.workItem.id}
@@ -695,6 +747,7 @@ Before handing a changed diff back for publication:
695
747
  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
748
  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
749
  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.
750
+ ${providerTurnEndRule("call forge.complete_comment_repair")}
698
751
  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
752
  Keep the original work item intent intact:
700
753
  - Work item: ${dispatch.workItem.id}
@@ -3,6 +3,12 @@ import type { ProviderCliRunContext } from "./provider-cli.types.js";
3
3
  import type { ProviderOutputState } from "./provider-output-state.js";
4
4
  import { type ProviderUsage } from "./provider-usage.js";
5
5
  export declare function providerProcessEnv(dispatch: RunOnceDispatchPacket, runtimeEnvironment?: Readonly<Record<string, string>>): Readonly<Record<string, string>>;
6
+ /**
7
+ * Pre-publication validation runs the attempt's own checks, whose E2E fixtures log in to the
8
+ * brokered attempt database. Unlike the provider's shell, it receives that capability; the
9
+ * validator redacts it from every command's output.
10
+ */
11
+ export declare function prePublicationValidationEnv(dispatch: RunOnceDispatchPacket, runtimeEnvironment?: Readonly<Record<string, string>>): Readonly<Record<string, string>>;
6
12
  export declare function providerRuntimeEnvironment(runtimeEnvironment?: Readonly<Record<string, string>>): Readonly<Record<string, string>>;
7
13
  export declare function providerCredentialEnv(dispatch: RunOnceDispatchPacket): Readonly<Record<string, string>>;
8
14
  /**
@@ -1,3 +1,4 @@
1
+ import { attemptDatabaseCapabilityEnvironment } from "../../runtime/attempt-database-broker.js";
1
2
  import { completionRedactionEnv } from "../phase-completion.js";
2
3
  import { addUsage, buildProviderUsageEvent, emptyUsage, hasUsage } from "./provider-usage.js";
3
4
  export function providerProcessEnv(dispatch, runtimeEnvironment) {
@@ -12,6 +13,16 @@ export function providerProcessEnv(dispatch, runtimeEnvironment) {
12
13
  // Bridge environment, including credentials outside the provider contract.
13
14
  return env;
14
15
  }
16
+ /**
17
+ * Pre-publication validation runs the attempt's own checks, whose E2E fixtures log in to the
18
+ * brokered attempt database. Unlike the provider's shell, it receives that capability; the
19
+ * validator redacts it from every command's output.
20
+ */
21
+ export function prePublicationValidationEnv(dispatch, runtimeEnvironment) {
22
+ const env = providerProcessEnv(dispatch, runtimeEnvironment);
23
+ const capability = runtimeEnvironment?.[attemptDatabaseCapabilityEnvironment]?.trim();
24
+ return capability ? { ...env, [attemptDatabaseCapabilityEnvironment]: capability } : env;
25
+ }
15
26
  export function providerRuntimeEnvironment(runtimeEnvironment) {
16
27
  if (!runtimeEnvironment)
17
28
  return {};
@@ -19,6 +30,9 @@ export function providerRuntimeEnvironment(runtimeEnvironment) {
19
30
  const normalized = name.trim().toUpperCase();
20
31
  return normalized !== "FORGE_TEST_POSTGRES_ADMIN_CONNECTION_STRING"
21
32
  && normalized !== "FORGE_TEST_POSTGRES_CONNECTION_STRING"
33
+ // The attempt database login reaches the application runtime, pre-publication checks and
34
+ // managed commands (which redact it); the provider's own shell does not need it.
35
+ && normalized !== "FORGE_ATTEMPT_DATABASE_CAPABILITY"
22
36
  && !normalized.startsWith("CONNECTIONSTRINGS__")
23
37
  && !normalized.startsWith("CONNECTIONSTRINGS:")
24
38
  && !normalized.endsWith("_CONNECTION_STRING");
@@ -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
  }