@bridge_gpt/mcp-server 0.2.71 → 0.2.73

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 (198) hide show
  1. package/README.md +55 -17
  2. package/build/agent-launchers/claude-executor-adapter.js +22 -3
  3. package/build/agent-notes.js +171 -95
  4. package/build/agents.generated.js +7 -7
  5. package/build/bridge-permissions.js +31 -0
  6. package/build/bridge-worktree-inspection.js +237 -0
  7. package/build/check-evidence.js +6 -0
  8. package/build/ci-system-detection.js +50 -0
  9. package/build/ci-trigger-adapters.js +631 -0
  10. package/build/ci-trigger-install.js +106 -0
  11. package/build/claude-review-workflow.js +1 -1
  12. package/build/cli-help.js +6 -0
  13. package/build/codex-auto-recovery.js +126 -0
  14. package/build/codex-launcher-pin.js +33 -2
  15. package/build/codex-skill-adapter.js +5 -1
  16. package/build/command-host.js +33 -0
  17. package/build/commands.generated.js +7 -6
  18. package/build/conductor/bridge-api-client.js +1352 -50
  19. package/build/conductor/bring-up-facts.js +18 -5
  20. package/build/conductor/command-drift-production.js +42 -17
  21. package/build/conductor/command-drift.js +47 -0
  22. package/build/conductor/declare-blocked.js +554 -0
  23. package/build/conductor/doctor.js +187 -28
  24. package/build/conductor/driver-commands.js +141 -0
  25. package/build/conductor/driver-guard.js +277 -0
  26. package/build/conductor/driver-lapse.js +321 -0
  27. package/build/conductor/driver-register.js +176 -0
  28. package/build/conductor/driver-release.js +174 -0
  29. package/build/conductor/driver-session-state.js +315 -0
  30. package/build/conductor/epic-branch-ci-inspection.js +222 -29
  31. package/build/conductor/epic-implementer-cli.js +213 -13
  32. package/build/conductor/epic-server-database.js +162 -0
  33. package/build/conductor/epic-server-guidance.js +278 -0
  34. package/build/conductor/epic-server-journal.js +239 -0
  35. package/build/conductor/epic-server-processes.js +324 -0
  36. package/build/conductor/epic-server-recipe.js +397 -0
  37. package/build/conductor/epic-server-runtime.js +1207 -0
  38. package/build/conductor/epic-server-sfcc.js +107 -0
  39. package/build/conductor/epic-server-state.js +427 -0
  40. package/build/conductor/epic-server.js +594 -0
  41. package/build/conductor/gate-discovery.js +281 -10
  42. package/build/conductor/gate-settings-review.js +525 -5
  43. package/build/conductor/git-hooks-uninstall.js +112 -0
  44. package/build/conductor/git-hooks.js +81 -15
  45. package/build/conductor/guided-repair.js +10 -1
  46. package/build/conductor/install-doctor.js +2 -4
  47. package/build/conductor/launch-need-probes.js +6 -53
  48. package/build/conductor/launch-plan.js +318 -121
  49. package/build/conductor/local-merge.js +12 -1
  50. package/build/conductor/merge-execution-contract.js +1 -1
  51. package/build/conductor/merged-child-check.js +2 -1
  52. package/build/conductor/prerequisite-inputs.js +1213 -0
  53. package/build/conductor/readiness-assessment.js +93 -0
  54. package/build/conductor/readiness-cli.js +30 -9
  55. package/build/conductor/readiness-prerequisites.js +77 -5
  56. package/build/conductor/readiness-sections.js +146 -126
  57. package/build/conductor/readiness.js +21 -3
  58. package/build/conductor/recovery-cli.js +236 -15
  59. package/build/conductor/recovery-operations.js +34 -4
  60. package/build/conductor/repair-contract.js +33 -0
  61. package/build/conductor/tools.js +36 -4
  62. package/build/conductor/wait-run-attention.js +115 -0
  63. package/build/conductor/wait-run-cli.js +300 -21
  64. package/build/conductor/worker-database-doctor-inspector.js +34 -2
  65. package/build/conductor/worker-setup-tally.js +27 -0
  66. package/build/credential-store.js +96 -21
  67. package/build/dependency-install-declarations.js +212 -0
  68. package/build/docs.generated.js +4 -4
  69. package/build/doctor.js +91 -8
  70. package/build/drive-epic-help.js +23 -4
  71. package/build/drive-epic.js +1841 -340
  72. package/build/engine-paths.js +20 -0
  73. package/build/epic-branch-ci-summary.js +140 -0
  74. package/build/epic-capability-statement.js +107 -0
  75. package/build/epic-ci-workflow-drift.js +30 -15
  76. package/build/epic-ci-workflow-install.js +110 -42
  77. package/build/epic-ci-workflow-v2.js +274 -0
  78. package/build/epic-ci-workflow.js +38 -12
  79. package/build/epic-implementer-bin.js +2184 -52
  80. package/build/epic-launch-context.js +607 -0
  81. package/build/epic-launch-profile.js +1 -1
  82. package/build/epic-server-record.js +273 -0
  83. package/build/epic-shared/bridge-client.js +11 -3
  84. package/build/escalation-reachability.js +43 -0
  85. package/build/executor/ci-fix-test-runs.js +334 -0
  86. package/build/executor/cli.js +2 -0
  87. package/build/executor/completion-contract.js +24 -1
  88. package/build/executor/credentials.js +1 -1
  89. package/build/executor/delivery-observations.js +113 -0
  90. package/build/executor/delivery-outcome.js +30 -0
  91. package/build/executor/dependency-refresh-runner.js +132 -0
  92. package/build/executor/dependency-refresh.js +530 -0
  93. package/build/executor/deps.js +4 -0
  94. package/build/executor/env.js +119 -17
  95. package/build/executor/epic-server-context.js +141 -0
  96. package/build/executor/gate-qualification-job.js +127 -26
  97. package/build/executor/harness-coverage.js +19 -0
  98. package/build/executor/http-client.js +87 -6
  99. package/build/executor/index.js +2 -1
  100. package/build/executor/install-preflight.js +1 -1
  101. package/build/executor/job-runner.js +659 -87
  102. package/build/executor/likely-tests.js +94 -97
  103. package/build/executor/observation.js +8 -0
  104. package/build/executor/pre-pr-checks.js +363 -0
  105. package/build/executor/prompt-spec.js +127 -5
  106. package/build/executor/reconcile-overlap-job.js +5 -3
  107. package/build/executor/required-verification.js +28 -0
  108. package/build/executor/required-work-diagnostics.js +32 -0
  109. package/build/executor/required-work-ledger.js +955 -39
  110. package/build/executor/results.js +100 -0
  111. package/build/executor/service-discovery.js +42 -0
  112. package/build/executor/service-lifecycle.js +109 -2
  113. package/build/executor/service-uninstall.js +205 -0
  114. package/build/executor/service-unit.js +5 -3
  115. package/build/executor/terminal-mutation.js +8 -0
  116. package/build/executor/test-clock.js +3 -0
  117. package/build/executor/verification-hints.js +179 -0
  118. package/build/executor/worker-command.js +126 -5
  119. package/build/executor/worker-database-config.js +281 -0
  120. package/build/executor/worker-database-target.js +16 -12
  121. package/build/executor/worker-database.js +575 -116
  122. package/build/executor/worker-finalization.js +71 -10
  123. package/build/executor/worker-guard-hook.js +10 -2
  124. package/build/executor/worker-resources.js +25 -3
  125. package/build/executor/worker-verification-guidance.js +55 -5
  126. package/build/executor/worktree-inspection.js +42 -0
  127. package/build/executor/worktree.js +20 -1
  128. package/build/executor-launch.js +54 -2
  129. package/build/generated-assets-catalog.js +2 -2
  130. package/build/github-sign-in.js +1 -1
  131. package/build/index.js +1111 -381
  132. package/build/init.js +29 -14
  133. package/build/install-bridge-conductor-answers.js +465 -0
  134. package/build/install-bridge-conductor-apply.js +259 -0
  135. package/build/install-bridge-conductor-assessment.js +895 -0
  136. package/build/install-bridge-conductor-compact.js +161 -0
  137. package/build/install-bridge-conductor-contracts.js +63 -0
  138. package/build/install-bridge-conductor-gate.js +1383 -188
  139. package/build/install-bridge-conductor-setup.js +637 -92
  140. package/build/install-bridge-conductor.js +3163 -740
  141. package/build/install-bridge.js +601 -128
  142. package/build/install-maintenance.js +127 -0
  143. package/build/install-reexec.js +1 -1
  144. package/build/launcher-config-inspection.js +162 -1
  145. package/build/local-cleanup.js +59 -0
  146. package/build/mcp-grant-candidates.js +767 -0
  147. package/build/mcp-grant-doctor.js +63 -0
  148. package/build/mcp-grant.js +288 -0
  149. package/build/mcp-host-targets.js +8 -0
  150. package/build/mcp-identity.js +23 -0
  151. package/build/mcp-install-state.js +68 -2
  152. package/build/mcp-invoke.js +126 -13
  153. package/build/mcp-presets.js +107 -0
  154. package/build/mcp-provisioning.js +134 -2
  155. package/build/mcp-registration-doctor.js +31 -2
  156. package/build/mcp-server-invocation.js +6 -1
  157. package/build/merge-workflow-install.js +236 -111
  158. package/build/package-script-semantics.js +10 -0
  159. package/build/pipeline-utils.js +1 -1
  160. package/build/pipelines.generated.js +6 -6
  161. package/build/plan-discovery.js +97 -4
  162. package/build/plan-execution-ledger.js +248 -9
  163. package/build/plan-generation-io.js +262 -0
  164. package/build/plan-generation.js +424 -0
  165. package/build/plane/build-freshness.js +6 -1
  166. package/build/plane/cli.js +75 -9
  167. package/build/plane/plane-freshness.js +23 -7
  168. package/build/plane/preflight.js +50 -10
  169. package/build/plane/shutdown.js +19 -0
  170. package/build/plane/terminal-run-cleanup.js +23 -5
  171. package/build/plane/terminal-run-status.js +4 -0
  172. package/build/printed-remedy-commands.js +229 -15
  173. package/build/readiness-check.js +1 -1
  174. package/build/readiness-prerequisites.generated.js +311 -4
  175. package/build/readme.generated.js +1 -1
  176. package/build/repository-state-paths.js +38 -0
  177. package/build/repository-toolchains.js +50 -8
  178. package/build/run-unit-tests-launcher.js +8 -1
  179. package/build/setup-change-policy.js +32 -0
  180. package/build/setup-epic.js +1192 -198
  181. package/build/setup-progress.js +44 -0
  182. package/build/setup-question.js +180 -0
  183. package/build/start-tickets.js +4 -0
  184. package/build/test-command-detection.js +32 -88
  185. package/build/test-support/notes-fs.js +40 -0
  186. package/build/third-party-mcp-targets.js +30 -0
  187. package/build/ticket-delivery-enrollment.js +30 -8
  188. package/build/ticket-delivery-run-scope.js +128 -0
  189. package/build/upgrade-cli.js +85 -2
  190. package/build/v2-readiness-requirements.js +28 -1
  191. package/build/version.generated.js +3 -3
  192. package/build/worker-guard-hook-bin.js +2 -2
  193. package/build/worktrees.js +105 -0
  194. package/docs/EPIC-IMPLEMENTER-INSTALL.md +9 -1
  195. package/docs/EPIC-IMPLEMENTER.md +5 -0
  196. package/docs/epic-implementer/getting-started.md +42 -15
  197. package/docs/epic-implementer/self-hosting.md +14 -1
  198. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { renderWorkerVerificationGuidance, renderWorkerTimeBudgetGuidance } from "./worker-verification-guidance.js";
1
+ import { renderPreexistingAtBaseGuidance, renderWorkerVerificationGuidance, renderWorkerTimeBudgetGuidance, } from "./worker-verification-guidance.js";
2
2
  /**
3
3
  * Executor-side structured prompt-spec renderer (BAPI-550, TDD §6/§7).
4
4
  *
@@ -20,6 +20,97 @@ import { renderWorkerVerificationGuidance, renderWorkerTimeBudgetGuidance } from
20
20
  */
21
21
  import { CiFixContext, ExecutorNamedError } from "./job-errors.js";
22
22
  import { EPIC_WORKAROUNDS_DIR, epicWorkaroundRecordPath } from "../epic-workarounds-path.js";
23
+ import { WORKER_BACKGROUND_WORK_RULE } from "./required-work-diagnostics.js";
24
+ import { validateEpicCapabilityStatement } from "../epic-capability-statement.js";
25
+ import { epicServerAcquireCommandSeconds } from "./epic-server-context.js";
26
+ import { EPIC_SERVER_DEFAULT_TIMING } from "../conductor/epic-server-recipe.js";
27
+ import { buildSfccWorkerPolicyText } from "../conductor/epic-server-sfcc.js";
28
+ /**
29
+ * BAPI-1546: the epic-server turn paragraph, a SEPARATE builder so the
30
+ * workaround contract ({@link buildEpicWorkaroundWorkerInstruction}) stays
31
+ * byte-identical. Appended beside it only when the repository opted in:
32
+ * `disabled` returns null and the caller appends nothing.
33
+ *
34
+ * - local, live: acquire a bounded turn through the own-build launcher, with
35
+ * the running helper's own turn wait (from its proven recipe) and the longest
36
+ * the command can take (that wait plus the rebuild budget), run the
37
+ * check against the printed address with the printed login file, release with
38
+ * the printed lease, and bind the served SHA and generation in the evidence.
39
+ * A lost lease discards the observation. The spawn env raises the harness
40
+ * command ceiling to that same number (`withEpicServerEnv`).
41
+ * - local, unavailable: one bounded acquire attempt; its output is the
42
+ * `no_live_server` observation under the hand-off rules.
43
+ * - SFCC: own-branch uploads onto the shared active version, one fresh upload
44
+ * before the single retry, upload intervals, and the evidence label.
45
+ *
46
+ * Single-line and free of `;`, quotes, and apostrophes, like the paragraph it
47
+ * follows. A missing server is a hand-off; a check that ran and failed is a real
48
+ * failure.
49
+ */
50
+ export function buildEpicServerWorkerInstruction(context, ticketKey) {
51
+ if (context.kind === "disabled")
52
+ return null;
53
+ if (context.kind === "sfcc") {
54
+ const sfcc = buildSfccWorkerPolicyText(context.origin);
55
+ return /[;'"\r\n]/.test(sfcc) ? null : sfcc;
56
+ }
57
+ const ticket = ticketKey && /^[A-Z][A-Z0-9_]{0,19}-\d{1,9}$/.test(ticketKey) ? ticketKey : "<TICKET>";
58
+ const wait = context.kind === "local_live" ? context.turnWaitSeconds : EPIC_SERVER_DEFAULT_TIMING.acquire_wait_seconds;
59
+ const acquire = "epic-implementer epic-server turn acquire --ticket " + ticket + " --head <your full head SHA> --wait " + wait +
60
+ " (it can take up to " + epicServerAcquireCommandSeconds(context) + " seconds before it prints, so run it in the foreground " +
61
+ "with a command timeout at least that long)";
62
+ const handoff = "If acquire prints outcome unavailable with cause no_live_server, rerun the same command once as the corrected " +
63
+ "invocation. If that also fails, record the step escalated with a hand-off whose cause is no_live_server, quoting " +
64
+ "the command, its output, and your head SHA, and naming the next human step. Nothing parks for this. A failed " +
65
+ "assertion or an application error from a check that did run is a real verification failure, never a hand-off.";
66
+ const turnRules = "On success it prints url, served_sha, generation, login_file, and lease. Run the check against that url only, " +
67
+ "sign in with the KEY=VALUE pairs in login_file, and never print, log, or commit them. Then run " +
68
+ "epic-implementer epic-server turn release --lease <the printed lease>. Write served_sha and generation into the " +
69
+ "step evidence. If release reports outcome lost, the turn expired or a newer generation fenced it: discard that " +
70
+ "observation, then acquire again and rerun, or record the hand-off below. Never record a lost observation as " +
71
+ "executed, and do not poll the lease in the background.";
72
+ let line;
73
+ if (context.kind === "local_live") {
74
+ line =
75
+ "Epic server: this run has one local epic server for e2e_tests and rendered_ui_review steps, shared by turns. " +
76
+ "Before each such check, take a bounded turn at your own head with " + acquire + " through the epic-implementer " +
77
+ "launcher on your PATH. " + turnRules + " " + handoff;
78
+ }
79
+ else {
80
+ line =
81
+ "Epic server: this run opted in to a local epic server, but it was not running when this worker started. For an " +
82
+ "e2e_tests or rendered_ui_review step, make one bounded attempt with " + acquire + " through the epic-implementer " +
83
+ "launcher on your PATH. If it is granted, follow the turn rules. " + turnRules + " Otherwise its output is the " +
84
+ "observation. " + handoff;
85
+ }
86
+ return /[;'"\r\n]/.test(line) ? null : line;
87
+ }
88
+ /**
89
+ * BAPI-1545: one advisory line telling an implement worker what the repository
90
+ * owner configured: the approved extra MCP servers, the epic-server mode, and
91
+ * the epic-server recipe state. Appended right after
92
+ * {@link buildEpicWorkaroundWorkerInstruction}, which stays byte-identical.
93
+ *
94
+ * The statement is revalidated here. Anything malformed returns `null`, and the
95
+ * caller then appends nothing, so the prompt is byte-identical to a repository
96
+ * with no statement. The line is SINGLE-LINE and free of `;`, quotes, and
97
+ * apostrophes, like the instruction it follows. It describes configuration, not
98
+ * runtime proof: a capability that fails at runtime still goes through the
99
+ * workaround and verification hand-off rules, never a claimed pass.
100
+ */
101
+ export function buildEpicCapabilityStatementWorkerInstruction(statement) {
102
+ const valid = validateEpicCapabilityStatement(statement);
103
+ if (valid === null)
104
+ return null;
105
+ const servers = valid.approved_servers.length > 0 ? valid.approved_servers.join(", ") : "none";
106
+ const line = "Capability statement from the repository owner setup, advisory configuration only and not proof " +
107
+ "that anything works at runtime: approved extra MCP servers are " + servers + ". The MCP grant is " +
108
+ valid.grant_state + ". The epic server mode is " + valid.epic_server_mode + " and its recipe is " +
109
+ valid.recipe + ". Treat anything listed as none, absent, unusable, or unknown as unavailable. If a " +
110
+ "check needs an unavailable or failing capability, follow the workaround and verification hand-off " +
111
+ "rules above and never report that check as passed.";
112
+ return /[;'"\r\n]/.test(line) ? null : line;
113
+ }
23
114
  /**
24
115
  * BAPI-1399 — the workaround contract for a PR-producing Epic Implementer worker.
25
116
  *
@@ -50,6 +141,12 @@ import { EPIC_WORKAROUNDS_DIR, epicWorkaroundRecordPath } from "../epic-workarou
50
141
  * failure. Review steps always run and are recorded executed. The server alone
51
142
  * decides whether a hand-off counts, from persisted run state.
52
143
  *
144
+ * BAPI-1609 adds `not_applicable` for a pre-PR step, review steps included, with
145
+ * genuinely nothing to verify (optional `rule_hint` and `target_path`). It is never
146
+ * admitted as a hand-off: the run carries it and the server labels the claim. The
147
+ * guidance also separates `no_database` (none provided or reachable) from a
148
+ * provided-but-broken database, and says a database nudge never rejects the record.
149
+ *
53
150
  * BAPI-1533 puts a test invocation rule ahead of that order: a selector that
54
151
  * collects zero tests is an invocation error (never a pass, never a missing
55
152
  * capability), every affected test-running step is rerun from the repository
@@ -59,6 +156,12 @@ import { EPIC_WORKAROUNDS_DIR, epicWorkaroundRecordPath } from "../epic-workarou
59
156
  * classes, the persisted run policy, and a genuine pre-result missing
60
157
  * capability. Nothing converts an ordinary escalation into a hand-off.
61
158
  *
159
+ * BAPI-1552 appends one exception, only when `handoffEnabled === true`: a step
160
+ * that ran and failed may use `preexisting_at_base` when the same tests also fail
161
+ * at the base commit, with the base reproduction collected at the final head (see
162
+ * `renderPreexistingAtBaseGuidance`). Without that flag the text is byte-for-byte
163
+ * the BAPI-1544 instruction.
164
+ *
62
165
  * The worker decides from the ticket and the code alone; no supervisor scan
63
166
  * result is injected here. Kept SINGLE-LINE and free of `;`, quotes, and
64
167
  * apostrophes, like `buildPrBaseContractLaunchInstruction`, because it travels
@@ -100,6 +203,9 @@ export function buildEpicWorkaroundWorkerInstruction(ticketKey, handoffEnabled)
100
203
  "check before it produced any result, both on your first invocation and on the corrected rerun" + allowsClause +
101
204
  ", record the step escalated with a handoff object of exactly six fields. The cause is one of " +
102
205
  "no_live_server, no_database, toolchain_unavailable, credential_unavailable, or mcp_unavailable. " +
206
+ "no_database means no database was provided or reachable for the job. A database that was provided " +
207
+ "but is broken (a missing extension, a failed migration, a refused connection) is a verification " +
208
+ "failure, not that cause. " +
103
209
  "The criterion is the affected acceptance criterion. The observation names the command you first " +
104
210
  "ran and the missing capability it hit. The corrected_invocation names the corrected rerun and the " +
105
211
  "missing capability it hit. The observed_head_sha is the full head SHA both ran against, and it must " +
@@ -109,13 +215,27 @@ export function buildEpicWorkaroundWorkerInstruction(ticketKey, handoffEnabled)
109
215
  "A failed assertion, an " +
110
216
  "application error from a check that did run, and unfinished implementation or test authoring stay " +
111
217
  "blockers, and an unclear failure stays an ordinary escalation. Only those three step classes may be " +
112
- "handed off. Neither you nor the server turns an ordinary escalation into a hand-off, and you never " +
218
+ "handed off with a missing-capability cause. Neither you nor the server turns an ordinary escalation into a hand-off, and you never " +
113
219
  "invent a missing capability observation. Review steps (test_gap_review, " +
114
220
  "final_plan_review, and combined_review_test) always run, acknowledge the handed-off criterion from " +
115
221
  "that escalated record and the workaround record written in the same job, and are recorded executed, " +
116
- "never handed off. A hand-off counts only at the head it observed, so a new head needs a fresh " +
222
+ "never handed off with a capability cause. The one exception is not_applicable, described next. " +
223
+ "Nothing to verify: for any pre-PR step, review steps included, that has genuinely nothing to check " +
224
+ "for this ticket (a rendered-UI review when no rendered file changes, a named test target that does " +
225
+ "not exist and that no step creates, or zero tests collected after your corrected rerun), record it " +
226
+ "escalated with a handoff of the same six fields and cause not_applicable. You may add rule_hint " +
227
+ "(no_rendered_surface, target_absent, or zero_tests) and, with target_absent, target_path (the " +
228
+ "repository-relative path). Not applicable is never for unfinished implementation or a check you " +
229
+ "could not run, and a step that already failed keeps its plain escalation. Recording a step you cannot " +
230
+ "do, honestly, keeps the run moving: this run carries it to the integration pull request list instead " +
231
+ "of parking the ticket, and the server labels the claim afterwards. A not_applicable record never " +
232
+ "counts as a hand-off. If the reply advises that the executor provisioned a job database after you " +
233
+ "claimed no_database, the record is still accepted and need not be withdrawn. Check the database " +
234
+ "settings in your own environment and run the step if the database works. " +
235
+ "A hand-off counts only at the head it observed, so a new head needs a fresh " +
117
236
  "observation. A step that already failed at one head can be handed off only from a new head, " +
118
- "never at the head where it failed.");
237
+ "never at the head where it failed." +
238
+ (handoffEnabled === true ? " " + renderPreexistingAtBaseGuidance(record) : ""));
119
239
  }
120
240
  /** Stable named-error kind used for every prompt-spec contract failure. */
121
241
  const PROMPT_CONTRACT_ERROR = "ContractError.Prompt";
@@ -779,7 +899,9 @@ export async function renderPromptSpecPrompt(job, context) {
779
899
  const values = await buildPromptSpecPlaceholderValues(job, spec, context);
780
900
  const systemPrompt = buildPromptSpecSystemPrompt(spec, values);
781
901
  const userPrompt = buildPromptSpecUserPrompt(spec, values);
782
- return `${systemPrompt}\n\n${userPrompt}` +
902
+ // BAPI-1554: every worker harness, not only the Claude held-stdin one, is told
903
+ // not to report a final result while its own background work is still running.
904
+ return `${systemPrompt}\n\n${userPrompt}\n\n${WORKER_BACKGROUND_WORK_RULE}` +
783
905
  (!context.deferComparisonGuidance && ["implement", "resume", "ci_fix"].includes(job.job_type)
784
906
  ? "\n\n" + renderWorkerVerificationGuidance(context.comparisonSha) : "") +
785
907
  (!context.deferComparisonGuidance && job.job_type === "ci_fix"
@@ -52,6 +52,7 @@ import { classifyMergeTree } from "./merge-tree-classifier.js";
52
52
  import { RECONCILE_OVERLAP_PAYLOAD_SCHEMA_VERSION, } from "./reconcile-overlap-types.js";
53
53
  import { runRequiredVerificationCommands } from "./required-verification.js";
54
54
  import { validateWorkerFinalization } from "./worker-finalization.js";
55
+ import { payloadWorkerDatabaseConfigOption } from "./worker-database-config.js";
55
56
  export const RECONCILE_OVERLAP_JOB_TYPE = "reconcile_overlap";
56
57
  /** Result-envelope bounds, mirrored from the server's result model. */
57
58
  export const RECONCILE_EDITED_PATHS_MAX = 40;
@@ -256,9 +257,10 @@ export function validateReconcileOverlapPayload(job) {
256
257
  conflictReportPath,
257
258
  prompt,
258
259
  reconcileGeneration: generation,
259
- workerEnvOption: Object.prototype.hasOwnProperty.call(payload, "worker_env")
260
- ? { workerEnv: payload.worker_env }
261
- : {},
260
+ workerEnvOption: {
261
+ ...(Object.prototype.hasOwnProperty.call(payload, "worker_env") ? { workerEnv: payload.worker_env } : {}),
262
+ ...payloadWorkerDatabaseConfigOption(payload),
263
+ },
262
264
  },
263
265
  };
264
266
  }
@@ -151,6 +151,34 @@ export function toCompletionCheckFact(fact) {
151
151
  duration_ms: Math.min(Math.max(0, Math.floor(fact.durationMs)), 2 * 60 * 60 * 1000),
152
152
  };
153
153
  }
154
+ /**
155
+ * Supplementary observation causes derived from declared-check facts. A timed-out
156
+ * check reports `check_timed_out`; a check that could not be started or never ran
157
+ * because of an interruption reports `check_not_runnable`. A check that exited
158
+ * zero, or exited non-zero (a real failure, not a capability shortfall), reports
159
+ * nothing: this function can never turn a failed or unrun check into a pass, and
160
+ * it does not decide anything about one.
161
+ */
162
+ export function observationsFromVerificationFacts(facts) {
163
+ if (!facts)
164
+ return [];
165
+ const out = [];
166
+ for (const command of facts.commands) {
167
+ let cause = null;
168
+ if (command.outcome === "timed_out" || command.reason === "declared_timeout") {
169
+ cause = "check_timed_out";
170
+ }
171
+ else if (command.outcome === "launch_error" ||
172
+ command.reason === "spawn_failed" ||
173
+ (command.outcome === "not_run" &&
174
+ (command.reason === "reservation_exhausted" || command.reason === "stopped_after_interruption"))) {
175
+ cause = "check_not_runnable";
176
+ }
177
+ if (cause !== null)
178
+ out.push({ check_identity: command.identity, cause });
179
+ }
180
+ return out;
181
+ }
154
182
  const FULL_SHA_RE = /^[0-9a-f]{40}$/;
155
183
  /**
156
184
  * Read full HEAD and the tracked tree/index state. Untracked files are not
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Exhaustive over {@link TaskKind}: a new task kind fails to compile here until
3
+ * it is given a token, so a diagnostic can never silently drop a kind.
4
+ */
5
+ export const TASK_KIND_TO_DIAGNOSTIC_TOKEN = {
6
+ delegate: "background_agent",
7
+ delegate_bg: "background_agent",
8
+ bash_bg: "background_bash",
9
+ bash_task: "background_bash",
10
+ subagent_bash: "background_bash",
11
+ monitor: "monitor",
12
+ task: "required_task",
13
+ };
14
+ /** Sorted, de-duplicated diagnostic tokens for the given task kinds. */
15
+ export function requiredWorkKindTokens(kinds) {
16
+ const tokens = new Set();
17
+ for (const kind of kinds)
18
+ tokens.add(TASK_KIND_TO_DIAGNOSTIC_TOKEN[kind]);
19
+ return [...tokens].sort();
20
+ }
21
+ /** The closed diagnostic recorded when the completion window closed over running required work. */
22
+ export const COMPLETION_WINDOW_CLOSED_ON_LIVE_AGENT = "completion_window_closed_on_live_agent";
23
+ /**
24
+ * The completion-ordering rule every worker prompt carries (BAPI-1554). It is a
25
+ * rule about WHEN to report, not a demand to cancel productive background work:
26
+ * the worker either waits for what it started or stops it, then reports. Shared
27
+ * by the generic prompt assembly and the Claude held-stdin guidance, which
28
+ * composes it at most once. It is guidance only: it adds no diagnostic and no
29
+ * completion gate.
30
+ */
31
+ export const WORKER_BACKGROUND_WORK_RULE = "Before you write `.conductor/result.json`, post a final result, or end the turn, wait for or stop every " +
32
+ "background task and sub-agent you started in this session. Never end your job with your own task still running.";