@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
@@ -36,6 +36,7 @@ import { READINESS_PREREQUISITE_BY_ID } from "../readiness-prerequisites.generat
36
36
  */
37
37
  import { CONSUMER_GUIDE_POINTER, PRINTED_CONNECT_GITHUB_COMMAND } from "../printed-remedy-commands.js";
38
38
  import { MANAGED_HOOK_NAMES } from "./git-hooks.js";
39
+ import { posixShellQuote } from "../platform-escaping.js";
39
40
  import { MCP_PACKAGE_NAME } from "../mcp-identity.js";
40
41
  import { CLAUDE_REVIEW_WORKFLOW_DRIFT_REMEDIATION, summarizeClaudeReviewWorkflowDrift, } from "../claude-review-workflow-drift.js";
41
42
  import { describeNativeLedgerAvailability, GH_ACTIONS_MERGE_AUTH_REMEDIATION, GH_ACTIONS_MERGE_SKIPPED_DETAIL, GH_ACTIONS_MERGE_UNOBSERVABLE_REMEDIATION, WORKER_DATABASE_DOCTOR_OWNER, WORKER_DATABASE_DOCTOR_RUNBOOK_SECTION, } from "./doctor.js";
@@ -48,12 +49,12 @@ export const CONDUCTOR_OPERATOR_RUNBOOK_POINTER = CONSUMER_GUIDE_POINTER;
48
49
  /**
49
50
  * Capability-matrix guidance for the executor leg.
50
51
  *
51
- * Amended by BAPI-779 (R-1): `install conductor` can now write the unit AND
52
+ * Amended by BAPI-779 (R-1): `install epic-implementer` can now write the unit AND
52
53
  * start it, each behind its own consent. What did NOT change is the readiness
53
54
  * rule — `executor_ready` still comes only from a live server observation, so
54
55
  * neither a written unit nor a successful local start may produce that claim.
55
56
  */
56
- export const EXECUTOR_PROVISIONING_GUIDANCE = "`install conductor` writes the unit and starts it, each behind its own consent; " +
57
+ export const EXECUTOR_PROVISIONING_GUIDANCE = "`install epic-implementer` writes the unit and starts it, each behind its own consent; " +
57
58
  "readiness still comes only from a live server observation";
58
59
  /**
59
60
  * The `BRIDGE_MCP_PROFILE` token that makes the 8 Epic Implementer MCP tools visible.
@@ -65,22 +66,22 @@ export const EXECUTOR_PROVISIONING_GUIDANCE = "`install conductor` writes the un
65
66
  export const EPIC_IMPLEMENTER_PROFILE_TOKEN = "epic_implementer";
66
67
  /** Remediation for a host MCP config that carries no Bridge entry at all. */
67
68
  export const CONDUCTOR_PROFILE_TOKEN_NO_ENTRY_REMEDIATION = "no supported host MCP config carries a Bridge entry — run " +
68
- `\`npx ${MCP_PACKAGE_NAME} install\` to register one, then re-run \`install conductor\`.`;
69
+ `\`npx ${MCP_PACKAGE_NAME} install\` to register one, then re-run \`install epic-implementer\`.`;
69
70
  /** Remediation for an entry that exists but lacks the conductor token. */
70
- export const CONDUCTOR_PROFILE_TOKEN_REMEDIATION = "re-run `install conductor` and accept the tool-visibility consent; the Epic Implementer " +
71
+ export const CONDUCTOR_PROFILE_TOKEN_REMEDIATION = "re-run `install epic-implementer` and accept the tool-visibility consent; the Epic Implementer " +
71
72
  "tools become visible after the MCP client is restarted.";
72
73
  /** Remediation surfaced whenever the managed git hooks are not usable. */
73
- export const CONDUCTOR_HOOK_TARGET_REMEDIATION = "re-run `install conductor` and accept the local-observability consent, or run " +
74
+ export const CONDUCTOR_HOOK_TARGET_REMEDIATION = "re-run `install epic-implementer` and accept the local-observability consent, or run " +
74
75
  "`epic-implementer install-git-hooks` directly.";
75
76
  /** Remediation surfaced when the ledger's native binding does not load. */
76
77
  export const CONDUCTOR_LEDGER_LOADABILITY_REMEDIATION = "`better-sqlite3` is an optionalDependency npm silently skips on a build failure — " +
77
78
  "reinstall it for this Node runtime to restore local Epic Implementer observability.";
78
79
  /** Remediation surfaced whenever no healthy generated service unit is detected. */
79
- export const EXECUTOR_INSTALL_SERVICE_REMEDIATION = "generate a persistent unit with `install conductor --executor-id <id> --repo-wide` or " +
80
+ export const EXECUTOR_INSTALL_SERVICE_REMEDIATION = "generate a persistent unit with `install epic-implementer --executor-id <id> --repo-wide` or " +
80
81
  "`executor install-service` (or run the executor by hand) — " +
81
82
  `see ${CONDUCTOR_OPERATOR_RUNBOOK_POINTER}.`;
82
83
  /** Remediation for a unit that exists but whose service is not running. */
83
- export const EXECUTOR_SERVICE_START_REMEDIATION = "start the service (re-run `install conductor` and accept the start consent, or run the " +
84
+ export const EXECUTOR_SERVICE_START_REMEDIATION = "start the service (re-run `install epic-implementer` and accept the start consent, or run the " +
84
85
  `printed launchctl/systemctl command by hand) — see ${CONDUCTOR_OPERATOR_RUNBOOK_POINTER}.`;
85
86
  // ---------------------------------------------------------------------------
86
87
  // BAPI-1254 — the ONE required-check presentation
@@ -221,13 +222,104 @@ const GATE_PROFILE_KIND_LABELS = {
221
222
  mixed: "Mixed",
222
223
  none: "None",
223
224
  };
225
+ const GATE_CONSEQUENCE_BY_KIND = Object.freeze({
226
+ provider: "every check must have actually reported on this repository before an unattended run is admitted",
227
+ local: "the executor runs these commands before each auto-merge; they must pass once under the executor " +
228
+ "(qualification) before an unattended run is admitted",
229
+ mixed: "BOTH legs gate every merge: each provider check must report green AND each local command must pass",
230
+ });
231
+ /**
232
+ * The `none` gate's merge consequence, tied to the server's stamp rules in
233
+ * `api/library/db/epic_runs.py` (first-approval gate stamping):
234
+ *
235
+ * - `keeps_auto_merge` is true only for an UNATTENDED run whose policy names a
236
+ * feature (epic) branch, that is not a `repository_policy` review run, and that
237
+ * REQUESTED auto-merge. It then keeps that auto-merge with no required-check
238
+ * protection (reason `epic_branch_auto_merge_kept`); the final merge into the
239
+ * base branch is still human-gated.
240
+ * - Any other `none` run is downgraded and records
241
+ * `STAMP_REASON_NONE_PROFILE_MERGE_APPROVAL` (`none_profile_requires_merge_approval`):
242
+ * each child merge waits for approval.
243
+ * - A feature-branch `repository_policy` run is the one further case: it keeps its
244
+ * declared auto-merge too (`repository_policy_auto_merge_kept_without_ci`),
245
+ * merging under the repository's own rules.
246
+ *
247
+ * It is never claimed that every `none` run waits for approval, and the review
248
+ * mode alone is never used to infer which clause applies. The sentence is kept
249
+ * short on purpose: a readiness row's detail is capped at 400 characters, and a
250
+ * longer line would be cut off in the middle of these conditions. (The base-branch
251
+ * merge staying human-gated is stated in the server's own stamp message instead.)
252
+ *
253
+ * BAPI-1657: the wording is plain for the owner. It names no internal policy
254
+ * token, and the full no-checks readiness row must stay at or below 400 characters
255
+ * (watched-check and epic-branch CI clauses, when present, are appended after it).
256
+ */
257
+ const NONE_GATE_CONSEQUENCE = "no required checks: an unattended epic-branch run that asked for auto-merge merges without check " +
258
+ "protection; a feature-branch run merges under the repository's own rules; every other run waits " +
259
+ "for owner approval before each child merge";
260
+ const WATCHED_CHECK_CONSEQUENCE = "watched checks are reported, not required: a completed red watched check can stop a merge, while a " +
261
+ "missing or unfinished one only warns";
262
+ /**
263
+ * The epic-branch CI consequence, from SERVER facts only. A reason is worded by
264
+ * what the server's producer proves for it, and three different situations stay
265
+ * apart: no trigger coverage (a recorded reason), a declined CI wait (the owner's
266
+ * decision), and unknown coverage (the install could not tell). Nothing here reads
267
+ * a workflow file; a local-only gate alone never claims that no workflow runs.
268
+ */
269
+ function epicBranchCiConsequence(facts) {
270
+ const parts = [];
271
+ for (const reason of facts.no_ci_reasons) {
272
+ switch (reason) {
273
+ case "gate_profile_none":
274
+ parts.push("the server reports that no CI check gates child merges on the epic branch");
275
+ break;
276
+ case "gate_profile_local_only":
277
+ parts.push("the gate is local-only, so on a feature-branch run Bridge requires no provider check on epic-branch PRs");
278
+ break;
279
+ case "triggers_do_not_cover_epic":
280
+ parts.push("the evidence recorded at install says no pull_request trigger covers epic/**, so CI may not run on epic-branch PRs");
281
+ break;
282
+ default:
283
+ parts.push("the server reported an epic-branch CI reason this CLI does not recognize");
284
+ }
285
+ }
286
+ if (facts.decision === "decline") {
287
+ parts.push("you declined epic-branch CI, so child merges do not wait for CI checks on the epic branch");
288
+ }
289
+ if (facts.evidence !== null &&
290
+ facts.evidence.workflow_triggers_cover_epic === null &&
291
+ !facts.no_ci_reasons.includes("triggers_do_not_cover_epic")) {
292
+ parts.push("whether a pull_request trigger covers epic/** could not be told at install");
293
+ }
294
+ return parts.length === 0 ? null : `epic-branch CI: ${parts.join("; ")}`;
295
+ }
296
+ /**
297
+ * BAPI-1637 — the ONE owner of gate-consequence wording, shared by readiness and
298
+ * the setup transcript so the two cannot word the same stored gate apart. Pure: it
299
+ * performs no I/O and reads no workflow. `ciFacts` is the readiness response's
300
+ * `epic_branch_ci` block; without it the line is gate-only, and no negative CI
301
+ * fact is invented. Returns one line, or `""` for a gate of unknown kind.
302
+ */
303
+ export function describeGateConsequence(gate, ciFacts) {
304
+ if (gate.kind === null)
305
+ return "";
306
+ const parts = [gate.kind === "none" ? NONE_GATE_CONSEQUENCE : GATE_CONSEQUENCE_BY_KIND[gate.kind]];
307
+ if (gate.hasWatchedChecks)
308
+ parts.push(WATCHED_CHECK_CONSEQUENCE);
309
+ if (ciFacts !== undefined && ciFacts !== null) {
310
+ const ci = epicBranchCiConsequence(ciFacts);
311
+ if (ci !== null)
312
+ parts.push(ci);
313
+ }
314
+ return parts.join("; ");
315
+ }
224
316
  /**
225
317
  * One line describing a gate profile: kind, source, confirmation, revision,
226
318
  * members, migration guard, and qualification state. Shared with the install
227
319
  * doctor's section so the two surfaces cannot word the same profile apart.
228
320
  * Only validated names are interpolated; everything else is a closed token.
229
321
  */
230
- export function describeGateProfile(profile) {
322
+ export function describeGateProfile(profile, ciFacts) {
231
323
  const kind = profile.kind === null ? "Unknown" : GATE_PROFILE_KIND_LABELS[profile.kind] ?? "Unknown";
232
324
  const source = profile.source === "legacy"
233
325
  ? "legacy: pre-profile done-gate checks treated as a confirmed provider profile"
@@ -235,10 +327,16 @@ export function describeGateProfile(profile) {
235
327
  const parts = [
236
328
  `${kind} gate profile (${source}, ${profile.confirmed ? "confirmed" : "unconfirmed"}, revision ${profile.revision})`,
237
329
  ];
238
- if (profile.provider_checks.length > 0) {
239
- parts.push(`provider checks: ${profile.provider_checks
240
- .map((c) => `${quotedSubject(c.name, "")} ${c.outcome === "evidence_unavailable" ? "unavailable" : c.outcome ?? "unknown"}`)
241
- .join(", ")}`);
330
+ // BAPI-1606: required and watched provider checks are named separately. A
331
+ // watched check is reported but never required, so it is not gate coverage.
332
+ const describeCheck = (c) => `${quotedSubject(c.name, "")} ${c.outcome === "evidence_unavailable" ? "unavailable" : c.outcome ?? "unknown"}`;
333
+ const requiredChecks = profile.provider_checks.filter((c) => c.watched !== true);
334
+ const watchedChecks = profile.provider_checks.filter((c) => c.watched === true);
335
+ if (requiredChecks.length > 0) {
336
+ parts.push(`provider checks: ${requiredChecks.map(describeCheck).join(", ")}`);
337
+ }
338
+ if (watchedChecks.length > 0) {
339
+ parts.push(`watched checks (reported, not required): ${watchedChecks.map(describeCheck).join(", ")}`);
242
340
  }
243
341
  if (profile.local_commands.length > 0) {
244
342
  parts.push(`local commands: ${profile.local_commands.map((c) => quotedSubject(c.name, "")).join(", ")}`);
@@ -250,9 +348,10 @@ export function describeGateProfile(profile) {
250
348
  : `migration guard: ${profile.migration_guard.kind}${profile.migration_guard.name === null ? "" : ` ${quotedSubject(profile.migration_guard.name, "")}`}`);
251
349
  if (profile.qualification_state !== null)
252
350
  parts.push(`qualification: ${profile.qualification_state}`);
253
- if (profile.kind === "none") {
254
- parts.push("unattended runs proceed, but every child merge waits for approval (`merge-child`)");
255
- }
351
+ // BAPI-1637: the consequence wording lives in one place, shared with setup.
352
+ const consequence = describeGateConsequence({ kind: profile.kind, hasWatchedChecks: watchedChecks.length > 0 }, ciFacts);
353
+ if (consequence !== "")
354
+ parts.push(consequence);
256
355
  return parts.join("; ");
257
356
  }
258
357
  /** Fixed copy for a known warning code. Only the validated name is interpolated. */
@@ -262,6 +361,10 @@ export function describeGateProfileWarning(code, name) {
262
361
  return `the check ${quotedSubject(name, "named in the gate profile")} has not been seen on an epic branch yet — this does not hold a launch`;
263
362
  case "epic_branch_search_unavailable":
264
363
  return "Bridge could not search epic branches for the gate-profile checks — this does not hold a launch";
364
+ case "watched_check_not_seen":
365
+ return `the watched check ${quotedSubject(name, "named in the gate profile")} has not been seen in recent history yet — a watched check is advisory, so this does not hold a launch`;
366
+ case "watched_check_evidence_unavailable":
367
+ return `Bridge could not read the history of the watched check ${quotedSubject(name, "named in the gate profile")} — a watched check is advisory, so this does not hold a launch`;
265
368
  default:
266
369
  return "the gate profile reported a warning this CLI does not recognize — this does not hold a launch";
267
370
  }
@@ -270,6 +373,9 @@ export function describeGateProfileWarning(code, name) {
270
373
  const GATE_PROFILE_WARNING_SECTION_IDS = {
271
374
  provider_check_not_seen_on_epic_branches: "supervisor-gate-profile-epic-branch-unseen",
272
375
  epic_branch_search_unavailable: "supervisor-gate-profile-epic-branch-search",
376
+ // BAPI-1606: warn-only watched-check rows, routed into the same warning section.
377
+ watched_check_not_seen: "supervisor-gate-profile-watched-unseen",
378
+ watched_check_evidence_unavailable: "supervisor-gate-profile-watched-evidence",
273
379
  };
274
380
  /**
275
381
  * BAPI-1390 — the gate-profile section plus its warn-only rows. Emitted ONLY
@@ -279,7 +385,7 @@ const GATE_PROFILE_WARNING_SECTION_IDS = {
279
385
  * not hold a launch, one section per known code (names joined) plus one
280
386
  * generic section for codes this client does not recognize.
281
387
  */
282
- export function gateProfileSections(profile) {
388
+ export function gateProfileSections(profile, epicBranchCi) {
283
389
  if (profile === undefined)
284
390
  return [];
285
391
  if (profile === null) {
@@ -293,7 +399,7 @@ export function gateProfileSections(profile) {
293
399
  },
294
400
  ];
295
401
  }
296
- const detail = describeGateProfile(profile);
402
+ const detail = describeGateProfile(profile, epicBranchCi);
297
403
  const held = profile.read_failed ||
298
404
  profile.stored_malformed ||
299
405
  profile.verdict === "denied" ||
@@ -647,7 +753,7 @@ export function supervisorSection(readiness) {
647
753
  }
648
754
  }
649
755
  // BAPI-1390 — nothing at all when the server did not report a profile.
650
- sections.push(...gateProfileSections(readiness.gate_profile));
756
+ sections.push(...gateProfileSections(readiness.gate_profile, readiness.epic_branch_ci));
651
757
  return sections;
652
758
  }
653
759
  export function githubCredentialsSection(readiness) {
@@ -965,7 +1071,7 @@ export function executorProvisioningSection(diagnostics) {
965
1071
  };
966
1072
  }
967
1073
  const unhealthy = diagnostics.units.filter((unit) => unit.warnings.length > 0 || unit.credentials.some((cred) => !cred.resolved));
968
- const ids = diagnostics.units.map((unit) => unit.executorId).join(", ");
1074
+ const ids = diagnostics.units.map((unit) => `${unit.executorId}; cleanup: npx -y ${MCP_PACKAGE_NAME} executor uninstall-service --executor-id ${posixShellQuote(unit.executorId)}`).join(", ");
969
1075
  if (unhealthy.length === 0 && diagnostics.warnings.length === 0) {
970
1076
  return {
971
1077
  ...base,
@@ -1362,12 +1468,19 @@ export async function inspectWorkflowLocalPresence(readWorkflowFile) {
1362
1468
  return code === "ENOENT" ? "absent" : "unreadable";
1363
1469
  }
1364
1470
  }
1471
+ /**
1472
+ * The worker-database rows a launch shows (BAPI-1594): the worker role and the
1473
+ * `bridgeapi` boundary. The inventory, harness, offline-Alembic and
1474
+ * "unverifiable" rows are `doctor`'s alone — a launch neither runs their probes
1475
+ * nor shows their rows.
1476
+ */
1477
+ export const WORKER_DATABASE_LAUNCH_ROW_IDS = ["worker-db-role", "worker-db-boundary"];
1365
1478
  /**
1366
1479
  * BAPI-1496 — project the advisory worker-database doctor section into launch
1367
1480
  * readiness rows.
1368
1481
  *
1369
- * Only non-healthy rows are projected: each becomes a `warn` with
1370
- * `blocking: false`, its existing `worker-db-*` id, fixed label and fixed
1482
+ * Only non-healthy role and boundary rows are projected: each becomes a `warn`
1483
+ * with `blocking: false`, its existing `worker-db-*` id, fixed label and fixed
1371
1484
  * detail, and the BAPI-1479 runbook as its remedy. A healthy row adds nothing,
1372
1485
  * so a healthy inspection leaves a launch's rows exactly as they were. PURE:
1373
1486
  * it reads an already-collected section and never probes, and it can never
@@ -1376,6 +1489,7 @@ export async function inspectWorkflowLocalPresence(readWorkflowFile) {
1376
1489
  */
1377
1490
  export function workerDatabaseReadinessChecks(section) {
1378
1491
  return section.rows
1492
+ .filter((row) => WORKER_DATABASE_LAUNCH_ROW_IDS.includes(row.id))
1379
1493
  .filter((row) => row.state !== "healthy")
1380
1494
  .map((row) => ({
1381
1495
  id: row.id,
@@ -1393,16 +1507,14 @@ export function workerDatabaseReadinessChecks(section) {
1393
1507
  // BAPI-1506 — launch needs: human-only needs asked about before a run exists
1394
1508
  // ---------------------------------------------------------------------------
1395
1509
  /**
1396
- * The closed set of human-only needs a create preview checks. Four are asked
1397
- * about before `Create this run? (y/N)`; `epic_branch_behind_base` is shown as
1398
- * information only, because integration's `sync_base` reconciles it.
1510
+ * The closed set of launch needs a create preview checks. BAPI-1596 removed the
1511
+ * usage-reset and epic-branch-behind-base needs: neither is harm, and a launch
1512
+ * neither produces nor shows them. The three that remain are evidence only.
1399
1513
  */
1400
1514
  export const LAUNCH_NEEDS = [
1401
1515
  "worker_db_role",
1402
1516
  "self_hosted_runner",
1403
1517
  "host_power",
1404
- "usage_reset_after_run",
1405
- "epic_branch_behind_base",
1406
1518
  ];
1407
1519
  /** `present` = the need exists; `absent` = no need; `unverifiable` = could not tell. */
1408
1520
  export const LAUNCH_NEED_STATES = ["present", "absent", "unverifiable", "not_applicable"];
@@ -1411,15 +1523,11 @@ export const LAUNCH_NEED_ROW_IDS = Object.freeze({
1411
1523
  worker_db_role: "worker-db-role",
1412
1524
  self_hosted_runner: "self-hosted-runner",
1413
1525
  host_power: "host-sleep",
1414
- usage_reset_after_run: "usage-reset-after-run",
1415
- epic_branch_behind_base: "epic-branch-behind-base",
1416
1526
  });
1417
1527
  const LAUNCH_NEED_LABELS = Object.freeze({
1418
1528
  worker_db_role: "Worker DB role",
1419
1529
  self_hosted_runner: "Self-hosted runner for required checks",
1420
1530
  host_power: "Host sleep",
1421
- usage_reset_after_run: "Usage reset after the run",
1422
- epic_branch_behind_base: "Epic branch behind base",
1423
1531
  });
1424
1532
  /** Each need's one-line remedy: the exit for its launch question. */
1425
1533
  export const LAUNCH_NEED_REMEDIES = Object.freeze({
@@ -1427,11 +1535,7 @@ export const LAUNCH_NEED_REMEDIES = Object.freeze({
1427
1535
  self_hosted_runner: "Start the self-hosted runner for the required checks (the machine that runs your CI jobs), " +
1428
1536
  "then run /drive-epic-run again.",
1429
1537
  host_power: PLANE_SLEEP_REMEDY,
1430
- usage_reset_after_run: "Wait for the usage window to reset, or launch fewer tickets, then run /drive-epic-run again.",
1431
- epic_branch_behind_base: "Integration's `sync_base` merges the base into the epic branch; no action is needed.",
1432
1538
  });
1433
- /** The estimate of one ticket's share of a run, for the usage row's likely end. */
1434
- export const LAUNCH_USAGE_PER_TICKET_MINUTES = 120;
1435
1539
  const LAUNCH_NEED_STATUS = Object.freeze({
1436
1540
  present: "warn",
1437
1541
  absent: "pass",
@@ -1442,8 +1546,7 @@ const LAUNCH_NEED_STATUS = Object.freeze({
1442
1546
  * Build one launch-need row. The status follows the state (`present` and
1443
1547
  * `unverifiable` warn, `absent` passes, `not_applicable` skips), `blocking` is
1444
1548
  * always `false`, and every `present` and `unverifiable` row carries the need's
1445
- * remedy. `asked` is `true` for the four human-only needs and `false` for the
1446
- * information-only branch row. `detail` must be fixed prose plus bounded counts
1549
+ * remedy. `asked` is `true` for every remaining need. `detail` must be fixed prose plus bounded counts
1447
1550
  * or normalized times — never subprocess output, a path, a URL or a credential.
1448
1551
  */
1449
1552
  export function buildLaunchNeedRow(need, state, detail, overrides = {}) {
@@ -1455,15 +1558,15 @@ export function buildLaunchNeedRow(need, state, detail, overrides = {}) {
1455
1558
  blocking: false,
1456
1559
  ...(detail !== undefined && detail !== "" ? { detail } : {}),
1457
1560
  ...(needsRemedy ? { remedy: LAUNCH_NEED_REMEDIES[need] } : {}),
1458
- launch_need: { need, state, asked: need !== "epic_branch_behind_base" },
1561
+ launch_need: { need, state, asked: true },
1459
1562
  };
1460
1563
  }
1461
1564
  // --- Worker DB role (local only; reuses BAPI-1496's doctor row) --------------
1462
1565
  /**
1463
1566
  * The `worker-db-role` launch-need state from an already-collected doctor
1464
1567
  * section. `null` section = the inspection did not run (no inspector);
1465
- * a section without the role row = the inspection failed (BAPI-1496 then keeps
1466
- * only `worker-db-unverifiable`). `healthy` → absent; `unsafe` (including
1568
+ * a section without the role row = the inspection failed (a failed launch
1569
+ * inspection supplies no rows at all, and the role stays unverifiable). `healthy` → absent; `unsafe` (including
1467
1570
  * `role_missing`) → present; `unknown` → unverifiable.
1468
1571
  */
1469
1572
  export function workerDbRoleLaunchState(section) {
@@ -1560,91 +1663,8 @@ export function buildHostPowerLaunchRow(fact) {
1560
1663
  return buildLaunchNeedRow("host_power", "unverifiable", `unverifiable — ${HOST_POWER_UNVERIFIABLE_DETAIL[fact.reason] ?? HOST_POWER_UNVERIFIABLE_DETAIL.probe_failed}`);
1561
1664
  }
1562
1665
  }
1563
- // --- Usage resets after the run's likely end ---------------------------------
1564
- /** The warning-state rule the producer applies (`executor/observation.ts`). */
1565
- const LAUNCH_USAGE_WARNING_PERCENT = 75;
1566
- /** Fixed wording for "no stored advisory": information, not a fault. */
1567
- export const LAUNCH_USAGE_NO_ADVISORY_DETAIL = "No usage warning is stored for this repository. Usage was below the warning threshold, or retention removed the record.";
1568
- function isoSeconds(ms) {
1569
- return new Date(ms).toISOString().replace(/\.\d{3}Z$/, "Z");
1570
- }
1571
- /**
1572
- * The usage launch-need row.
1573
- *
1574
- * The likely end is an ESTIMATE: `now + child_count × LAUNCH_USAGE_PER_TICKET_MINUTES`.
1575
- * `present` = a warning-state advisory (utilization ≥ 75% or status not exactly
1576
- * `allowed`) whose reset falls after the likely end. `absent` = an advisory not
1577
- * in its warning state, or one that resets at or before the likely end.
1578
- * Everything that cannot be decided — no reset, an unparseable reset, a
1579
- * malformed or unavailable read, no child count, or no stored advisory at all —
1580
- * is `unverifiable` and only warns.
1581
- */
1582
- export function buildUsageResetAfterRunLaunchRow(input) {
1583
- const { advisory, childCount, nowMs } = input;
1584
- const unverifiable = (why) => buildLaunchNeedRow("usage_reset_after_run", "unverifiable", `unverifiable — ${why}`);
1585
- if (advisory.state === "unavailable")
1586
- return unverifiable("the stored usage advisory could not be read");
1587
- if (advisory.state === "absent")
1588
- return unverifiable("the stored usage advisory is malformed");
1589
- if (advisory.state === "below_warning_threshold") {
1590
- return buildLaunchNeedRow("usage_reset_after_run", "unverifiable", LAUNCH_USAGE_NO_ADVISORY_DETAIL);
1591
- }
1592
- const percent = advisory.utilization_percent;
1593
- const warning = (typeof percent === "number" && percent >= LAUNCH_USAGE_WARNING_PERCENT) || advisory.status !== "allowed";
1594
- const observed = [];
1595
- if (advisory.observed_at !== null) {
1596
- const observedMs = Date.parse(advisory.observed_at);
1597
- if (Number.isFinite(observedMs))
1598
- observed.push(`observed ${isoSeconds(observedMs)}`);
1599
- }
1600
- if (advisory.stale === true)
1601
- observed.push("stale");
1602
- const observedNote = observed.length > 0 ? ` (${observed.join(", ")})` : "";
1603
- const percentText = typeof percent === "number" ? `${percent}%` : "unknown";
1604
- if (!warning) {
1605
- return buildLaunchNeedRow("usage_reset_after_run", "absent", `absent — the last observed usage (${percentText}) is not in its warning state${observedNote}`);
1606
- }
1607
- if (childCount === null ||
1608
- typeof childCount !== "number" ||
1609
- !Number.isSafeInteger(childCount) ||
1610
- childCount <= 0 ||
1611
- !Number.isFinite(nowMs)) {
1612
- return unverifiable(`the run's ticket count is unknown, so its likely end cannot be estimated${observedNote}`);
1613
- }
1614
- const likelyEndMs = nowMs + childCount * LAUNCH_USAGE_PER_TICKET_MINUTES * 60_000;
1615
- if (!Number.isFinite(likelyEndMs) || !Number.isFinite(new Date(likelyEndMs).getTime())) {
1616
- return unverifiable("the run's likely end cannot be estimated");
1617
- }
1618
- const estimate = `estimated likely end ${isoSeconds(likelyEndMs)} ` +
1619
- `(now + ${childCount} × ${LAUNCH_USAGE_PER_TICKET_MINUTES} minutes)`;
1620
- const resetMs = advisory.resets_at !== null ? Date.parse(advisory.resets_at) : Number.NaN;
1621
- if (!Number.isFinite(resetMs)) {
1622
- return unverifiable(`the last observed usage (${percentText}) is in its warning state but has no usable reset time; ${estimate}${observedNote}`);
1623
- }
1624
- if (resetMs > likelyEndMs) {
1625
- return buildLaunchNeedRow("usage_reset_after_run", "present", `present — the last observed usage (${percentText}) is in its warning state and resets ${isoSeconds(resetMs)}, ` +
1626
- `after the ${estimate}${observedNote}`);
1627
- }
1628
- return buildLaunchNeedRow("usage_reset_after_run", "absent", `absent — the last observed usage (${percentText}) resets ${isoSeconds(resetMs)}, at or before the ${estimate}${observedNote}`);
1629
- }
1630
- const BRANCH_NOT_APPLICABLE_DETAIL = Object.freeze({
1631
- no_epic_branch: "not applicable — this run targets the base branch directly",
1632
- branch_not_on_origin: "not applicable — the epic branch does not exist on origin yet; it will be cut fresh",
1633
- });
1634
- const BRANCH_UNVERIFIABLE_DETAIL = Object.freeze({
1635
- no_base_branch: "the base branch the epic branch is cut from is unknown",
1636
- invalid_branch_name: "a branch name failed validation",
1637
- git_failed: "git could not compare the epic branch with its base",
1638
- });
1639
- export function buildEpicBranchBehindBaseLaunchRow(fact) {
1640
- switch (fact.state) {
1641
- case "present":
1642
- return buildLaunchNeedRow("epic_branch_behind_base", "present", `present — the epic branch is ${fact.behind} commit(s) behind its base (information only)`);
1643
- case "absent":
1644
- return buildLaunchNeedRow("epic_branch_behind_base", "absent", "absent — the epic branch is not behind its base");
1645
- case "not_applicable":
1646
- return buildLaunchNeedRow("epic_branch_behind_base", "not_applicable", BRANCH_NOT_APPLICABLE_DETAIL[fact.reason] ?? BRANCH_NOT_APPLICABLE_DETAIL.no_epic_branch);
1647
- default:
1648
- return buildLaunchNeedRow("epic_branch_behind_base", "unverifiable", `unverifiable — ${BRANCH_UNVERIFIABLE_DETAIL[fact.reason] ?? BRANCH_UNVERIFIABLE_DETAIL.git_failed}`);
1649
- }
1666
+ /** Explicit assessment explanations alongside the unchanged legacy sections. */
1667
+ export function assessmentWorkflowExplanations(readiness) {
1668
+ return readiness.assessment?.records.filter(r => r.scope === 'default_branch' || r.scope === 'indexed_commit')
1669
+ .map(r => `${r.id} [${r.scope} @ ${r.inspected_sha ?? 'unknown revision'}]: ${r.applicability} (${r.basis}), ${r.observed_state}`) ?? [];
1650
1670
  }
@@ -1,3 +1,5 @@
1
+ import { composeReadinessAssessment, deriveAdvisoryVerdict } from './readiness-assessment.js';
2
+ import { formatReadinessAssessment } from './readiness-prerequisites.js';
1
3
  import { mergeReadinessPrerequisites, formatReadinessPrerequisites } from "./readiness-prerequisites.js";
2
4
  /**
3
5
  * The consolidated ADVISORY epic-implementer readiness gate (BAPI-1055, AC-6/AC-7).
@@ -437,7 +439,7 @@ const ADMISSION_EVIDENCE_LABELS = {
437
439
  };
438
440
  /** Who acts, in fixed prose. Never a value from the payload. */
439
441
  const ADMISSION_OWNER_REMEDIATION = {
440
- operator: "the operator re-runs guided setup (`install conductor`) and re-observes.",
442
+ operator: "the operator re-runs guided setup (`install epic-implementer`) and re-observes.",
441
443
  repository_admin: "a repository administrator resolves it (unattended consent is the 'Allow unattended Epic Implementer runs' toggle on the repository's Setup page in the Bridge admin panel); setup never grants it.",
442
444
  bridge_operations: "email info@bridgegpt.ai; this is not something an operator command can change.",
443
445
  };
@@ -539,7 +541,7 @@ export function gateProfileChecks(readiness) {
539
541
  }),
540
542
  ];
541
543
  }
542
- const detail = describeGateProfile(profile);
544
+ const detail = describeGateProfile(profile, readiness.epic_branch_ci);
543
545
  let row;
544
546
  if (profile.read_failed || profile.stored_malformed) {
545
547
  row = createReadinessCheckSafely({
@@ -805,7 +807,7 @@ function unattendedOutcomes(readiness) {
805
807
  ? {
806
808
  id: "repository-workflow-readiness",
807
809
  status: "pass",
808
- detail: "the review and epic-implementer-ci workflows are both confirmed",
810
+ detail: readiness.assessment ? readiness.assessment.records.filter(r => r.scope === 'default_branch').map(r => `${r.id}: ${r.applicability} (${r.basis}); ${r.observed_state}`).join('; ') : 'the workflow sections required by effective policy are confirmed',
809
811
  }
810
812
  : {
811
813
  id: "repository-workflow-readiness",
@@ -1309,6 +1311,7 @@ export async function collectConductorReadinessGate(deps) {
1309
1311
  repoName: deps.repoName ?? null,
1310
1312
  unavailableSources,
1311
1313
  checks: validated,
1314
+ ...(installReport?.readiness?.assessmentNegotiation ? { assessmentNegotiation: installReport.readiness.assessmentNegotiation, ...(installReport.readiness.assessment ? { assessment: installReport.readiness.assessment, advisoryVerdict: deriveAdvisoryVerdict(composeReadinessAssessment(installReport.readiness.assessmentNegotiation)) } : {}) } : {}),
1312
1315
  prerequisites: mergeReadinessPrerequisites(validated, installReport?.readiness?.prerequisites),
1313
1316
  is_production: installReport?.readiness?.is_production,
1314
1317
  ...(installReport?.readiness?.diagnostics ? { diagnostics: installReport.readiness.diagnostics } : {}),
@@ -1396,5 +1399,20 @@ function readinessTag(status) {
1396
1399
  * hides. It computes no overall verdict, because there is none to compute.
1397
1400
  */
1398
1401
  export function formatConductorReadinessGateReport(report, options = {}) {
1402
+ if (report.assessmentNegotiation)
1403
+ return formatReadinessAssessment(composeReadinessAssessment(report.assessmentNegotiation, localReadinessFacts(report.checks)), options).join('\n');
1399
1404
  return formatReadinessPrerequisites(report.prerequisites ?? mergeReadinessPrerequisites(report.checks), { all: options.all, isProduction: report.is_production }).join('\n');
1400
1405
  }
1406
+ /** Local facts cannot satisfy a server-owned prerequisite. */
1407
+ export function localReadinessFacts(checks) {
1408
+ const ids = new Map([
1409
+ ['conductor.claude-login', 'local.claude-login'], ['conductor.gh-cli', 'local.github-login'], ['install.identity', 'local.repository-identity'],
1410
+ ]);
1411
+ const facts = checks.flatMap(c => ids.has(c.id) ? [{ id: ids.get(c.id),
1412
+ observed_state: c.status === 'pass' ? 'confirmed' : c.status === 'fail' ? 'deficient' : 'unknown',
1413
+ impact: c.blocking === true ? 'mandatory' : 'advisory' }] : []);
1414
+ for (const c of checks.filter(c => c.id === 'conductor.install-section-executor-provisioning')) {
1415
+ facts.push({ id: 'local.executor-installation', observed_state: c.status === 'pass' ? 'confirmed' : 'unknown', impact: 'optional' });
1416
+ }
1417
+ return facts;
1418
+ }