@bridge_gpt/mcp-server 0.2.75 → 0.2.76

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 (64) hide show
  1. package/README.md +5 -5
  2. package/build/agents.generated.js +4 -4
  3. package/build/codex-auto-recovery.js +25 -7
  4. package/build/commands.generated.js +6 -6
  5. package/build/conductor/bridge-api-client.js +141 -6
  6. package/build/conductor/declare-blocked.js +4 -0
  7. package/build/conductor/driver-pass.js +8 -0
  8. package/build/conductor/epic-implementer-cli.js +4 -3
  9. package/build/conductor/epic-server-journal.js +13 -0
  10. package/build/conductor/epic-server-recipe.js +15 -5
  11. package/build/conductor/epic-server-runtime.js +163 -45
  12. package/build/conductor/epic-server.js +13 -6
  13. package/build/conductor/install-doctor.js +30 -2
  14. package/build/conductor/local-merge.js +54 -12
  15. package/build/conductor/pr-ci-producer.js +12 -3
  16. package/build/conductor/readiness-sections.js +46 -13
  17. package/build/conductor/readiness.js +3 -40
  18. package/build/conductor/recovery-cli.js +12 -12
  19. package/build/conductor/repository-workflow-remedy.js +147 -7
  20. package/build/conductor/ui-readiness.js +224 -0
  21. package/build/conductor/wait-run-attention.js +9 -4
  22. package/build/conductor/wait-run-cli.js +9 -2
  23. package/build/docs.generated.js +2 -2
  24. package/build/drive-epic.js +402 -27
  25. package/build/epic-implementer-bin.js +62 -42
  26. package/build/epic-launch-context.js +8 -1
  27. package/build/epic-shared/cut-protocol.js +55 -3
  28. package/build/executor/failure-reason-codes.js +2 -0
  29. package/build/executor/integration-job.js +56 -2
  30. package/build/executor/job-runner.js +4 -1
  31. package/build/executor/merge-job.js +45 -1
  32. package/build/executor/permissions.js +187 -2
  33. package/build/executor/provider-checks.js +28 -5
  34. package/build/executor/reconcile-overlap-job.js +70 -17
  35. package/build/executor/required-work-ledger.js +7 -2
  36. package/build/executor/resume-pre-spawn.js +32 -8
  37. package/build/executor/runner.js +26 -4
  38. package/build/executor/worktree.js +12 -1
  39. package/build/index.js +376 -434
  40. package/build/init.js +16 -0
  41. package/build/install-bridge-conductor-answers.js +4 -0
  42. package/build/install-bridge-conductor-apply.js +10 -0
  43. package/build/install-bridge-conductor-assessment.js +71 -0
  44. package/build/install-bridge-conductor-contracts.js +9 -1
  45. package/build/install-bridge-conductor-setup.js +103 -3
  46. package/build/install-bridge-conductor.js +437 -93
  47. package/build/mcp-host-config.js +54 -37
  48. package/build/phase-context-git-probe.js +16 -0
  49. package/build/pipelines.generated.js +9 -9
  50. package/build/plan-execution-ledger.js +27 -0
  51. package/build/plane/plane-freshness.js +43 -26
  52. package/build/printed-remedy-commands.js +8 -0
  53. package/build/readme.generated.js +1 -1
  54. package/build/secret-redaction.js +3 -0
  55. package/build/setup-epic.js +41 -8
  56. package/build/test-support/create-preview-world.js +232 -0
  57. package/build/ticket-delivery.js +65 -0
  58. package/build/v2-readiness-requirements.js +8 -3
  59. package/build/version.generated.js +3 -3
  60. package/build/worktree-core.js +51 -7
  61. package/docs/EPIC-IMPLEMENTER.md +79 -0
  62. package/docs/epic-implementer/getting-started.md +1 -1
  63. package/package.json +1 -1
  64. package/pipelines/implement-ticket.json +2 -2
@@ -409,8 +409,11 @@ async function runProve(deps, cmd) {
409
409
  }
410
410
  const outcome = await proveRecipe({ paths, repoRoot, epicHead: cmd.head, runId: cmd.epicRunId }, deps.runtime());
411
411
  if (!outcome.ok) {
412
- emit(deps, { outcome: "failed", verb: "prove", reason: outcome.reason });
413
- deps.stderr(`epic-server prove: failed (${outcome.reason}); the run continues with the epic server unavailable`);
412
+ // BAPI-1733: detail is closed-form evidence (a safe recipe field label or a
413
+ // formatted exit), only for these two reasons, and never a raw error or value.
414
+ const detail = (outcome.reason === "recipe_invalid" || outcome.reason === "app_exited") && outcome.detail !== undefined ? outcome.detail : undefined;
415
+ emit(deps, { outcome: "failed", verb: "prove", reason: outcome.reason, ...(detail !== undefined ? { detail } : {}) });
416
+ deps.stderr(`epic-server prove: failed (${outcome.reason}${detail !== undefined ? `: ${detail}` : ""}); the run continues with the epic server unavailable`);
414
417
  return 1;
415
418
  }
416
419
  emit(deps, { outcome: "proven", recipe_revision: outcome.proof.recipe_revision, epic_head: outcome.proof.epic_head });
@@ -428,8 +431,9 @@ async function runStart(deps, cmd) {
428
431
  }
429
432
  const outcome = await startEpicServerHelper({ paths, epicKey: cmd.epicKey, runId: cmd.epicRunId, repoName: mode.repoName, repoRoot, epicHead: cmd.head }, { runtime: deps.runtime(), launchHelper: deps.launchHelper });
430
433
  if (!outcome.ok) {
431
- emit(deps, { outcome: "failed", verb: "start", reason: outcome.reason });
432
- deps.stderr(`epic-server start: failed (${outcome.reason}); the run continues with the epic server unavailable`);
434
+ const detail = outcome.reason === "recipe_invalid" && outcome.detail !== undefined ? outcome.detail : undefined;
435
+ emit(deps, { outcome: "failed", verb: "start", reason: outcome.reason, ...(detail !== undefined ? { detail } : {}) });
436
+ deps.stderr(`epic-server start: failed (${outcome.reason}${detail !== undefined ? `: ${detail}` : ""}); the run continues with the epic server unavailable`);
433
437
  return 1;
434
438
  }
435
439
  emit(deps, {
@@ -584,9 +588,12 @@ async function runHelper(deps, cmd) {
584
588
  const nonce = deps.env.BRIDGE_EPIC_SERVER_INSTANCE_TAG;
585
589
  if (paths === null || typeof nonce !== "string" || !/^[0-9a-f]{64}$/.test(nonce))
586
590
  return 1;
587
- const recipe = await readRecipe(paths, rt.fs);
591
+ const recipeRead = await readRecipe(paths, rt.fs);
592
+ if (!recipeRead.ok)
593
+ return 1;
594
+ const recipe = recipeRead.recipe;
588
595
  const proof = validateEpicServerProof(await import("./epic-server-state.js").then((m) => m.readPrivateJson(rt.fs, paths.proof)));
589
- if (recipe === null || !proofCoversStart(proof, recipe, cmd.head))
596
+ if (!proofCoversStart(proof, recipe, cmd.head))
590
597
  return 1;
591
598
  const journal = new EpicServerJournal(paths.journal, cmd.epicRunId, rt.fs, rt.now);
592
599
  const helper = new EpicServerHelper({
@@ -30,7 +30,8 @@
30
30
  * workflow scaffold, no schema migration, no hook installation. It is invoked
31
31
  * from a write-capable installer, so that boundary is pinned by tests.
32
32
  */
33
- import { readdir as fsReaddir, readFile as fsReadFile, stat as fsStat } from "node:fs/promises";
33
+ import { readdir as fsReaddir, readFile as fsReadFile, stat as fsStat, lstat as fsLstat } from "node:fs/promises";
34
+ import { readEpicServerRecord } from "../epic-server-record.js";
34
35
  import os from "node:os";
35
36
  import { buildConductorDoctorReport, formatConductorDoctorReport, } from "./doctor.js";
36
37
  import { inspectBridgeApiProfileToken, } from "../mcp-host-config.js";
@@ -56,6 +57,25 @@ async function settle(collect) {
56
57
  return { value: null, failed: true };
57
58
  }
58
59
  }
60
+ /** A usable repository-scoped epic-server record, read through the shared validator. Never throws. */
61
+ async function epicServerRecordUsable(deps) {
62
+ const repoName = deps.access?.repoName;
63
+ if (repoName === undefined || repoName === "")
64
+ return false;
65
+ try {
66
+ const read = deps.readEpicServerRecord ??
67
+ ((name) => readEpicServerRecord(name, {
68
+ env: process.env,
69
+ homedir: os.homedir,
70
+ readFile: (filePath) => fsReadFile(filePath, "utf-8"),
71
+ lstat: (filePath) => fsLstat(filePath),
72
+ }));
73
+ return (await read(repoName)).state === "ok";
74
+ }
75
+ catch {
76
+ return false;
77
+ }
78
+ }
59
79
  /**
60
80
  * Build the unified report. Never throws: every probe failure becomes a section.
61
81
  */
@@ -244,7 +264,15 @@ export async function runConductorInstallDoctor(deps) {
244
264
  // collection gap rather than losing the section.
245
265
  }
246
266
  const conductorContext = detectConductorContext(legacyConductor, profileToken);
247
- sections.push(conductorProfileTokenSection(profileToken, conductorContext));
267
+ // BAPI-1719: the profile section also reads RECORDED setup, because a missing group is exactly
268
+ // what keeps the conductor-context detection above from firing. The hook-target section keeps
269
+ // `conductorContext` unchanged. A usable repository-scoped epic-server record is read only when
270
+ // readiness itself is unavailable; any missing, unusable, or throwing read is "not recorded".
271
+ let setupRecorded = readiness?.supervisor?.setup_present === true;
272
+ if (!setupRecorded && readiness === null)
273
+ setupRecorded = await epicServerRecordUsable(deps);
274
+ const profileContext = conductorContext || setupRecorded;
275
+ sections.push(conductorProfileTokenSection(profileToken, profileContext));
248
276
  sections.push(conductorHookTargetsSection(legacyConductor, conductorContext));
249
277
  sections.push(conductorLedgerLoadabilitySection(legacyConductor));
250
278
  // BAPI-1135 — this HOST's ability to observe the merge capability, beside the
@@ -54,7 +54,7 @@
54
54
  * module answers only the first.
55
55
  */
56
56
  import { spawn } from "child_process";
57
- import { pollCiChecksForCommit, ConductorBridgeApiError, safeDiagnosticMessage, } from "./bridge-api-client.js";
57
+ import { pollCiChecksForCommit, classifyCiPollAvailability, isFallbackWithNoObservedChecks, CiPollTransientUnavailableError, ConductorBridgeApiError, safeDiagnosticMessage, } from "./bridge-api-client.js";
58
58
  import { isLikelyGhMergeConflictOutput, isPrMergeConflict, parseGhPrMergeabilityFields, } from "./github-mergeability.js";
59
59
  import { normalizeSelectorCheckName, selectLatestChecksByName } from "./latest-check-selector.js";
60
60
  const MERGE_METHODS = new Set(["squash", "merge", "rebase"]);
@@ -594,6 +594,20 @@ function isAmbiguousCiPollFailureReason(reason) {
594
594
  * detail on the result. `ci_not_green` is returned only after the budget is exhausted.
595
595
  * Never polls the branch name or PR head alias — only `expectedSha`.
596
596
  *
597
+ * BAPI-1527: every poll carries `requiredChecks`, so a repository whose CI check
598
+ * configuration was never resolved is judged on live provider evidence. Two named
599
+ * outcomes keep that evidence honest, and both are reported only at the budget
600
+ * boundary, exactly when `ci_not_green` would be. `ci_checks_unavailable` replaces
601
+ * `ci_not_green` when the latest poll said the check configuration or provider
602
+ * access could not be read. An unavailable poll is never green evidence: the loop
603
+ * skips the green test for it and keeps waiting, so a read that recovers inside the
604
+ * budget is judged on the evidence it then returns. The server retries a
605
+ * `ci_checks_unavailable` merge through the same re-fire and retry budget as
606
+ * `ci_not_green`, and parks only once that budget is spent.
607
+ * `ci_no_checks_observed` replaces `ci_not_green` at the budget boundary only when
608
+ * the latest poll was a fallback over an empty required list that saw no check at
609
+ * all; failing, pending, or missing named checks still end as `ci_not_green`.
610
+ *
597
611
  * BAPI-572 abort-awareness: the CI-wait loop is the longest-running,
598
612
  * non-`gh`-subprocess phase of a merge. It must short-circuit with `merge_aborted`
599
613
  * as soon as the injected abort signal fires — otherwise a merge job the executor
@@ -602,24 +616,44 @@ function isAmbiguousCiPollFailureReason(reason) {
602
616
  */
603
617
  async function waitForRequiredChecksGreen(pollCi, access, expectedSha, requiredChecks, timeoutMs, pollIntervalMs, sleep, now, signal) {
604
618
  const start = now();
619
+ let lastPollSawNoChecks = false;
620
+ let lastPollUnavailable = false;
605
621
  for (;;) {
606
622
  if (signal?.aborted)
607
623
  return { ok: false, reason: "merge_aborted" };
608
624
  let pollResponse;
609
625
  try {
610
- pollResponse = await pollCi(access, expectedSha);
626
+ pollResponse = await pollCi(access, expectedSha, requiredChecks);
611
627
  }
612
628
  catch (err) {
613
- // Preserve the caught bridge poll error's coarse kind/status instead of
614
- // flattening every failure to an opaque `ci_poll_failed` (BAPI-577 Part A).
615
- // Unknown/non-bridge throws yield `undefined` detail → legacy `ci_poll_failed`.
616
- const pollFailure = ciPollFailureDetailFromError(err);
617
- return { ok: false, reason: ciPollFailureReasonFromDetail(pollFailure), pollFailure };
629
+ if (err instanceof CiPollTransientUnavailableError) {
630
+ // BAPI-1527 decision A: the route's transient envelope is the same
631
+ // provider exception that, before the opt-in, came back as a plain
632
+ // not-green envelope. Keep waiting exactly as before: a null response is
633
+ // never green and ends as `ci_not_green` at the budget boundary.
634
+ pollResponse = null;
635
+ }
636
+ else {
637
+ // Preserve the caught bridge poll error's coarse kind/status instead of
638
+ // flattening every failure to an opaque `ci_poll_failed` (BAPI-577 Part A).
639
+ // Unknown/non-bridge throws yield `undefined` detail → legacy `ci_poll_failed`.
640
+ const pollFailure = ciPollFailureDetailFromError(err);
641
+ return { ok: false, reason: ciPollFailureReasonFromDetail(pollFailure), pollFailure };
642
+ }
618
643
  }
619
- if (allRequiredChecksGreen(pollResponse, requiredChecks))
644
+ // Unreadable configuration is not a failed check and never green evidence:
645
+ // skip the green test (it could read `detail: null` as red CI) and keep waiting
646
+ // like any other not-green poll. The name is reported at the budget boundary.
647
+ lastPollUnavailable = classifyCiPollAvailability(pollResponse) === "configuration_unavailable";
648
+ if (!lastPollUnavailable && allRequiredChecksGreen(pollResponse, requiredChecks))
620
649
  return { ok: true };
621
- if (now() - start >= timeoutMs)
622
- return { ok: false, reason: "ci_not_green" };
650
+ lastPollSawNoChecks =
651
+ !lastPollUnavailable && requiredChecks.length === 0 && isFallbackWithNoObservedChecks(pollResponse);
652
+ if (now() - start >= timeoutMs) {
653
+ if (lastPollUnavailable)
654
+ return { ok: false, reason: "ci_checks_unavailable" };
655
+ return { ok: false, reason: lastPollSawNoChecks ? "ci_no_checks_observed" : "ci_not_green" };
656
+ }
623
657
  await sleep(pollIntervalMs);
624
658
  // Re-check after the sleep so an abort during the interval stops the loop
625
659
  // before the next poll (and, critically, before any provider merge).
@@ -643,7 +677,8 @@ export function makeLocalMergeExecutor(options = {}, deps = {}) {
643
677
  // signal is threaded to the default runner so an overall merge timeout can
644
678
  // cancel in-flight subprocess work.
645
679
  const run = (cmd, args, env) => Promise.resolve(rawRun(cmd, args, env, deps.signal));
646
- const pollCi = deps.pollCi ?? pollCiChecksForCommit;
680
+ const pollCi = deps.pollCi ??
681
+ ((pollAccess, commitRef, checks) => pollCiChecksForCommit(pollAccess, commitRef, undefined, checks));
647
682
  const sleep = deps.sleep ?? defaultSleep;
648
683
  const now = deps.now ?? (() => Date.now());
649
684
  const signal = deps.signal;
@@ -760,7 +795,10 @@ export function makeLocalMergeExecutor(options = {}, deps = {}) {
760
795
  // for transient post-remediation CI to turn green before failing ci_not_green.
761
796
  // Skipped under `skipCiWait` (BAPI-832), where the server's approval tail
762
797
  // revalidated these same checks for this same head moments ago.
763
- if (!options.skipCiWait) {
798
+ // Also skipped (BAPI-1724) for a run that declared no CI gate, with an
799
+ // empty check list; a non-empty list always waits.
800
+ const noCiGateSkip = options.noCiGateDeclared === true && requiredChecks.length === 0;
801
+ if (!options.skipCiWait && !noCiGateSkip) {
764
802
  const ciWait = await waitForRequiredChecksGreen(pollCi, access, expectedSha, requiredChecks, ciWaitTimeoutMs, ciWaitPollIntervalMs, sleep, now, signal);
765
803
  if (!ciWait.ok) {
766
804
  // Any `ci_poll_*` reason (the legacy `ci_poll_failed` plus the distinct
@@ -776,6 +814,8 @@ export function makeLocalMergeExecutor(options = {}, deps = {}) {
776
814
  }
777
815
  return fail(ciWait.reason, ciWait.pollFailure);
778
816
  }
817
+ // 3b/3c rereads protect the CI-wait INTERVAL. A no-wait merge has no such
818
+ // interval: the first PR read above and `--match-head-commit` protect it.
779
819
  // 3b. Re-read PR head/state after the CI wait — the head can drift, the PR can
780
820
  // close, or the merge can already have landed while we waited for CI.
781
821
  const secondRead = await readPrMergeState(run, ghEnv, pr);
@@ -876,6 +916,8 @@ export function makeLocalMergeExecutor(options = {}, deps = {}) {
876
916
  }
877
917
  const succeededDetails = {
878
918
  ...baseDetails,
919
+ // BAPI-1724: success-only. A refusal or failure keeps the plain details.
920
+ ...(noCiGateSkip && !options.skipCiWait ? { ci_wait: "skipped_no_ci_gate_declared" } : {}),
879
921
  ...(mergeCommitSha ? { merge_commit_sha: mergeCommitSha } : {}),
880
922
  };
881
923
  return buildResponse(request, "succeeded", null, true, [
@@ -12,7 +12,7 @@
12
12
  import { GIT_CI_PRODUCER, REVIEW_STATE, } from "./git-ci-types.js";
13
13
  import { evaluateDoneGate, normalizeCiSnapshot, parseDoneGateConfig } from "./done-gate.js";
14
14
  import { observeReviewWithResolved } from "./pr-review-producer.js";
15
- import { fetchEffectiveSupervisorSetup, fetchActiveEpicRuns, fetchEpicRunState, pollCiChecksForCommit, resolveConductorBridgeApiAccess, } from "./bridge-api-client.js";
15
+ import { fetchEffectiveSupervisorSetup, fetchActiveEpicRuns, fetchEpicRunState, pollCiChecksForCommit, classifyCiPollAvailability, resolveConductorBridgeApiAccess, } from "./bridge-api-client.js";
16
16
  /** Default gate-config fetcher: reads done_gate_config from the supervisor setup. */
17
17
  async function _fetchGateConfigDefault(access) {
18
18
  const setup = await fetchEffectiveSupervisorSetup(access);
@@ -138,7 +138,8 @@ async function observeWithResolved(binding, access, gateConfig, deps, expectedBa
138
138
  ((input, dimensions) => emitConductorEventIfNew(input, dimensions, {
139
139
  emitEvent: emitConductorEventFn,
140
140
  }));
141
- const pollCi = deps.pollCi ?? pollCiChecksForCommit;
141
+ const pollCi = deps.pollCi ??
142
+ ((pollAccess, commitRef, requiredChecks) => pollCiChecksForCommit(pollAccess, commitRef, undefined, requiredChecks));
142
143
  const now = deps.now ?? (() => new Date().toISOString());
143
144
  // Resolve run_id/worker_id for attribution. Env takes precedence; fall back
144
145
  // to the injected resolution seam when the env identity is absent.
@@ -191,13 +192,21 @@ async function observeWithResolved(binding, access, gateConfig, deps, expectedBa
191
192
  // 2. Poll CI for the bound head SHA. A poll failure is NOT a CI failure event.
192
193
  let rawPoll;
193
194
  try {
194
- rawPoll = await pollCi(access, binding.head_sha);
195
+ rawPoll = await pollCi(access, binding.head_sha, []);
195
196
  }
196
197
  catch {
197
198
  result.ci_status = "unavailable";
198
199
  result.reason = "ci-poll-failed";
199
200
  return result;
200
201
  }
202
+ // BAPI-1527: unreadable check configuration or provider access is a missing
203
+ // capability, not a CI result. Report it as unavailable BEFORE snapshot
204
+ // normalization, so no CI-failure telemetry and no `gate.met` can follow.
205
+ if (classifyCiPollAvailability(rawPoll) === "configuration_unavailable") {
206
+ result.ci_status = "unavailable";
207
+ result.reason = "ci-checks-unavailable: required-check configuration or provider access could not be read";
208
+ return result;
209
+ }
201
210
  const snapshot = normalizeCiSnapshot(rawPoll);
202
211
  // 3. CI observation telemetry (only for terminal states).
203
212
  const ciEvent = buildCiObservationEventInput(binding, snapshot, run_id, worker_id);
@@ -34,9 +34,11 @@ import { READINESS_PREREQUISITE_BY_ID } from "../readiness-prerequisites.generat
34
34
  * The one exception is {@link inspectWorkflowPresence}, which awaits the
35
35
  * READ-ONLY reader seams its caller injects and never opens a path of its own.
36
36
  */
37
- import { CONSUMER_GUIDE_POINTER, PRINTED_CONNECT_GITHUB_COMMAND } from "../printed-remedy-commands.js";
37
+ import { CONSUMER_GUIDE_POINTER, PRINTED_CONNECT_GITHUB_COMMAND, PRINTED_CONDUCTOR_INSTALL_COMMAND } from "../printed-remedy-commands.js";
38
38
  import { MANAGED_HOOK_NAMES } from "./git-hooks.js";
39
39
  import { posixShellQuote } from "../platform-escaping.js";
40
+ import { profileMergeNeededFrom } from "../mcp-host-config.js";
41
+ import { DUPLICATE_REGISTRATION_GUIDANCE } from "../launcher-config-inspection.js";
40
42
  import { MCP_PACKAGE_NAME } from "../mcp-identity.js";
41
43
  import { CLAUDE_REVIEW_WORKFLOW_DRIFT_REMEDIATION, summarizeClaudeReviewWorkflowDrift, } from "../claude-review-workflow-drift.js";
42
44
  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";
@@ -67,9 +69,16 @@ export const EPIC_IMPLEMENTER_PROFILE_TOKEN = "epic_implementer";
67
69
  /** Remediation for a host MCP config that carries no Bridge entry at all. */
68
70
  export const CONDUCTOR_PROFILE_TOKEN_NO_ENTRY_REMEDIATION = "no supported host MCP config carries a Bridge entry — run " +
69
71
  `\`npx ${MCP_PACKAGE_NAME} install\` to register one, then re-run \`install epic-implementer\`.`;
70
- /** Remediation for an entry that exists but lacks the conductor token. */
71
- export const CONDUCTOR_PROFILE_TOKEN_REMEDIATION = "re-run `install epic-implementer` and accept the tool-visibility consent; the Epic Implementer " +
72
- "tools become visible after the MCP client is restarted.";
72
+ /**
73
+ * Remediation for an entry that exists but lacks the conductor group (BAPI-1719).
74
+ * Names the supported installer command and the manual edit. Either way the group
75
+ * is ADDED to the existing Bridge entry (the other comma-separated groups stay), and
76
+ * the Epic Implementer tools appear only after the MCP client is restarted.
77
+ */
78
+ export const CONDUCTOR_PROFILE_TOKEN_REMEDIATION = `run \`${PRINTED_CONDUCTOR_INSTALL_COMMAND}\` and approve the tool-visibility choice, or add ` +
79
+ "`epic_implementer` to BRIDGE_MCP_PROFILE in the existing Bridge entry of your MCP configuration " +
80
+ "(keep the other comma-separated groups, for example `sfcc,epic_implementer`); " +
81
+ "then restart your MCP client so the Epic Implementer tools become visible.";
73
82
  /** Remediation surfaced whenever the managed git hooks are not usable. */
74
83
  export const CONDUCTOR_HOOK_TARGET_REMEDIATION = "re-run `install epic-implementer` and accept the local-observability consent, or run " +
75
84
  "`epic-implementer install-git-hooks` directly.";
@@ -1221,23 +1230,47 @@ export function conductorProfileTokenSection(profile, conductorContext) {
1221
1230
  const carrying = profile.configs
1222
1231
  .filter((c) => c.state === "token-present")
1223
1232
  .map((c) => c.path);
1233
+ const unreadable = profile.configs.filter((c) => c.state === "unreadable").map((c) => c.path);
1224
1234
  const scope = "inspected .mcp.json, .vscode/mcp.json, .cursor/mcp.json only " +
1225
1235
  "(Codex and Copilot host configuration is not inspected)";
1236
+ const unreadableNote = unreadable.length > 0 ? `; could not read ${unreadable.join(", ")}` : "";
1237
+ // BAPI-1719: overall satisfaction is the shared decision setup uses, never "one config has
1238
+ // it". A satisfied registration does not hide a missing group in another config, nor a
1239
+ // config that registers Bridge under both names.
1240
+ if (profileMergeNeededFrom(profile)) {
1241
+ const missing = profile.configs.filter((c) => c.state === "token-absent").map((c) => c.path);
1242
+ const duplicates = profile.configs.filter((c) => c.duplicateRegistration === true).map((c) => c.path);
1243
+ const parts = [];
1244
+ if (missing.length > 0)
1245
+ parts.push(`the \`${profile.token}\` group is not loaded by the Bridge entry in ${missing.join(", ")}`);
1246
+ if (duplicates.length > 0)
1247
+ parts.push(`${duplicates.join(", ")} registers Bridge under two names`);
1248
+ const detail = `${parts.join("; ")}; ${scope}${unreadableNote}`;
1249
+ const remediation = missing.length > 0
1250
+ ? CONDUCTOR_PROFILE_TOKEN_REMEDIATION
1251
+ : DUPLICATE_REGISTRATION_GUIDANCE;
1252
+ return conductorContext
1253
+ ? { ...base, status: "degraded", detail, remediation }
1254
+ : { ...base, status: "ok", detail: `advisory — ${detail}`, remediation };
1255
+ }
1226
1256
  if (carrying.length > 0) {
1227
1257
  return {
1228
1258
  ...base,
1229
1259
  status: "ok",
1230
- detail: `\`${profile.token}\` present in ${carrying.join(", ")}; ${scope}`,
1260
+ detail: `\`${profile.token}\` loaded by every Bridge entry in ${carrying.join(", ")}; ${scope}${unreadableNote}`,
1231
1261
  };
1232
1262
  }
1233
- // "No entry anywhere" and "an entry without the token" are different findings
1234
- // with different next steps, so they never collapse into one remediation.
1235
- const detail = profile.bridgeEntryPresent
1236
- ? `no supported host config carries the \`${profile.token}\` token; ${scope}`
1237
- : `no supported host config carries a Bridge entry; ${scope}`;
1238
- const remediation = profile.bridgeEntryPresent
1239
- ? CONDUCTOR_PROFILE_TOKEN_REMEDIATION
1240
- : CONDUCTOR_PROFILE_TOKEN_NO_ENTRY_REMEDIATION;
1263
+ // Unreadable evidence is not confirmed absence, and "no entry anywhere" is a third finding.
1264
+ // Each has its own next step, so they never collapse into one remediation.
1265
+ if (unreadable.length > 0 && !profile.bridgeEntryPresent) {
1266
+ const detail = `could not read ${unreadable.join(", ")}, so the \`${profile.token}\` group could not be confirmed; ${scope}`;
1267
+ const remediation = "fix or restore the unreadable MCP configuration, then re-run `doctor`.";
1268
+ return conductorContext
1269
+ ? { ...base, status: "degraded", detail, remediation }
1270
+ : { ...base, status: "ok", detail: `advisory — ${detail}`, remediation };
1271
+ }
1272
+ const detail = `no supported host config carries a Bridge entry; ${scope}`;
1273
+ const remediation = CONDUCTOR_PROFILE_TOKEN_NO_ENTRY_REMEDIATION;
1241
1274
  return conductorContext
1242
1275
  ? { ...base, status: "degraded", detail, remediation }
1243
1276
  : { ...base, status: "ok", detail: `advisory — ${detail}`, remediation };
@@ -97,15 +97,15 @@ import { mergeReadinessPrerequisites, formatReadinessPrerequisites } from "./rea
97
97
  * unrelated additive change look like a breaking one here, or worse, hide a real
98
98
  * one.
99
99
  */
100
- import { CONSUMER_GUIDE_POINTER, PRINTED_CHECK_NAME_INSTRUCTION, PRINTED_CONDUCTOR_EXECUTOR_INSTALL_COMMAND, PRINTED_CONDUCTOR_INSTALL_COMMAND, PRINTED_CONNECT_GITHUB_COMMAND, PRINTED_EXECUTOR_ID_INSTRUCTION, PRINTED_QUALIFY_GATE_COMMAND, } from "../printed-remedy-commands.js";
100
+ import { CONSUMER_GUIDE_POINTER, PRINTED_CHECK_NAME_INSTRUCTION, PRINTED_CONDUCTOR_EXECUTOR_INSTALL_COMMAND, PRINTED_CONDUCTOR_INSTALL_COMMAND, PRINTED_CONNECT_GITHUB_COMMAND, PRINTED_EXECUTOR_ID_INSTRUCTION, } from "../printed-remedy-commands.js";
101
101
  import { mapConductorDoctorReportToReadinessChecks, } from "./doctor.js";
102
102
  import { mapInstallStatusChecksToReadinessChecks, } from "../install-doctor.js";
103
103
  import { mapPlanePreflightToReadinessChecks, } from "../plane/preflight.js";
104
104
  import { runConductorInstallDoctor, } from "./install-doctor.js";
105
- import { BRING_UP_SECTION_LABELS, describeGateProfile, describeGateProfileWarning, effectiveReviewModeIsRepositoryPolicy, EPIC_BRANCH_CI_SECTION_IDS, epicBranchCiSections, presentRequiredChecks, quotedSubject, } from "./readiness-sections.js";
105
+ import { BRING_UP_SECTION_LABELS, describeGateProfile, describeGateProfileWarning, effectiveReviewModeIsRepositoryPolicy, EPIC_BRANCH_CI_SECTION_IDS, epicBranchCiSections, presentRequiredChecks, } from "./readiness-sections.js";
106
106
  import { classifyBringUpFacts } from "./bring-up-facts.js";
107
107
  import { projectReadinessRowBlocking, providerRepositoryCheck, resolvedMergeModeCheck, } from "../v2-readiness-requirements.js";
108
- import { CI_WORKFLOW_PATH, REVIEW_WORKFLOW_PATH, ciWorkflowRemedy, repositoryWorkflowRemedy, } from "./repository-workflow-remedy.js";
108
+ import { CI_WORKFLOW_PATH, REVIEW_WORKFLOW_PATH, ciWorkflowRemedy, gateProfileReasonRemedy, repositoryWorkflowRemedy, } from "./repository-workflow-remedy.js";
109
109
  import { classifyMergeExecutionEligibility, MERGE_EXECUTION_INELIGIBLE_REMEDIATION, MERGE_EXECUTION_UNVERIFIABLE_REMEDIATION, } from "./merge-execution-eligibility.js";
110
110
  import { createReadinessCheck, createReadinessCheckSafely, summarizeReadinessChecks, validateReadinessChecks, } from "../readiness-check.js";
111
111
  import { ADMISSION_EVIDENCE_SCHEMA_VERSION, gateProfileWaivesCiWorkflow, } from "./bridge-api-client.js";
@@ -481,43 +481,6 @@ function admissionReasonRemedy(record, readiness) {
481
481
  return gateProfileReasonRemedy(record.reason, record.verdict, record.subject ?? null);
482
482
  }
483
483
  }
484
- /** The provider-evidence window the server searches, spelled once for the remedies. */
485
- const PROVIDER_EVIDENCE_WINDOW = "the last 12 default-branch commits or 8 merged pull-request heads from the last 90 days";
486
- /**
487
- * BAPI-1390 — fixed remedies for the four gate-profile reasons. Everything is a
488
- * literal except the validated `subject`. `null` for any other reason, so an
489
- * unknown reason falls back to the owner's generic remedy.
490
- */
491
- function gateProfileReasonRemedy(reason, verdict, subject) {
492
- switch (reason) {
493
- case "provider_check_unseen":
494
- return (`a repository administrator confirms that the check ${quotedSubject(subject, "named in the gate profile")} ` +
495
- `reports on the default branch — it was not seen on ${PROVIDER_EVIDENCE_WINDOW} — or edits the gate ` +
496
- "profile; setup never grants it.");
497
- case "provider_evidence_unavailable":
498
- return (`Bridge could not read the provider's check history for ${quotedSubject(subject, "a gate-profile check")} ` +
499
- `(${PROVIDER_EVIDENCE_WINDOW}), so it is unknown, not absent. Re-run readiness; if it persists, ` +
500
- "email info@bridgegpt.ai.");
501
- case "local_command_unqualified":
502
- return verdict === "unable_to_verify"
503
- ? `the qualification of the local gate command ${quotedSubject(subject, "in the gate profile")} could not ` +
504
- "be read, so it is unknown, not qualified. Re-run readiness; if it persists, email info@bridgegpt.ai."
505
- : `the local gate command ${quotedSubject(subject, "in the gate profile")} is not qualified for the current ` +
506
- "gate-profile revision (unqualified or stale). Qualify it with " +
507
- `\`${PRINTED_QUALIFY_GATE_COMMAND}\`, or have a repository administrator ` +
508
- "edit the gate profile.";
509
- case "migration_guard_unset":
510
- return verdict === "unable_to_verify"
511
- ? "Bridge could not confirm whether this repository has alembic.ini on its default branch, so it could " +
512
- "not decide whether the gate profile needs a migration guard. Re-run readiness, or have a repository " +
513
- "administrator set a migration guard in the gate profile."
514
- : "this repository has alembic.ini on its default branch, so its gate profile must name a migration " +
515
- "guard (a provider check or a local command). A repository administrator sets it in the gate " +
516
- "profile; setup never grants it.";
517
- default:
518
- return null;
519
- }
520
- }
521
484
  const GATE_PROFILE_WARNING_REMEDIATION = "no action is needed to launch; confirm the check reports once an epic branch runs CI.";
522
485
  /**
523
486
  * BAPI-1390 — the gate-profile row plus one warn row per warning. Appended
@@ -977,7 +977,7 @@ export function parseRerunCiArgs(argv) {
977
977
  const RERUN_CI_STATUS_TEXT = {
978
978
  enqueued: "re-run requested",
979
979
  deduplicated: "already requested",
980
- deferred: "deferred (not requested; run the verb again after a fresh explain-run)",
980
+ deferred: "deferred (not requested; run the verb again after a fresh read with the explain_run MCP tool)",
981
981
  not_re_runnable: "not re-runnable",
982
982
  };
983
983
  const RERUN_CI_REASON_TEXT = {
@@ -991,11 +991,11 @@ const RERUN_CI_OUTCOME_TEXT = {
991
991
  nothing_to_enqueue: "nothing to enqueue (no failed check could be re-run)",
992
992
  };
993
993
  const RERUN_CI_NEXT_ACTION = {
994
- enqueued: "Wait for the re-runs to finish, then read `epic-implementer explain-run`. When CI is " +
994
+ enqueued: "Wait for the re-runs to finish, then call the `explain_run` MCP tool (input `epic_run_id`). When CI is " +
995
995
  "green use `epic-implementer resume-ci` (a parked ticket); this verb did not mark CI passed.",
996
- partial: "Some runs were not requested. Read `epic-implementer explain-run` and, if still " +
996
+ partial: "Some runs were not requested. Call the `explain_run` MCP tool and, if still " +
997
997
  "offered, re-run the command it renders with its fresh binding.",
998
- nothing_to_enqueue: "No re-run was possible. Read `epic-implementer explain-run`; for a code defect use " +
998
+ nothing_to_enqueue: "No re-run was possible. Call the `explain_run` MCP tool; for a code defect use " +
999
999
  "`dispatch-remediation --context-file`.",
1000
1000
  };
1001
1001
  function rerunCiCheckLine(check) {
@@ -1040,7 +1040,7 @@ export function renderRerunCiOutcome(outcome, parsed, json) {
1040
1040
  ` outcome: ${RERUN_CI_OUTCOME_TEXT[result.outcome] ?? result.outcome}`,
1041
1041
  " failed checks:",
1042
1042
  ...result.checks.map(rerunCiCheckLine),
1043
- ` next action: ${RERUN_CI_NEXT_ACTION[result.outcome] ?? "Read `epic-implementer explain-run`."}`,
1043
+ ` next action: ${RERUN_CI_NEXT_ACTION[result.outcome] ?? "Call the `explain_run` MCP tool (input `epic_run_id`)."}`,
1044
1044
  ` request: ${outcome.requestId}${outcome.referenceReused ? " (re-sent from the local reference)" : ""}`,
1045
1045
  ` event recorded: ${result.event_recorded}`,
1046
1046
  ];
@@ -1279,7 +1279,7 @@ export function renderResolveHandoffOutcome(outcome, parsed, json) {
1279
1279
  }
1280
1280
  else {
1281
1281
  console.error(`Failed: resolve-handoff for ${label} — ${outcome.message}. Whether the decision was ` +
1282
- "recorded is unconfirmed; read `epic-implementer explain-run` before retrying.");
1282
+ "recorded is unconfirmed; call the `explain_run` MCP tool (input `epic_run_id`) before retrying.");
1283
1283
  }
1284
1284
  return RESOLVE_HANDOFF_EXIT_FAILED;
1285
1285
  }
@@ -1328,7 +1328,7 @@ const ACKNOWLEDGE_GAPS_USAGE = [
1328
1328
  "gap, driver merge and out-of-engine merge the run carried forward. The integration PR",
1329
1329
  "stays in draft until the owner acknowledges the list's CURRENT digest; a new entry",
1330
1330
  "changes the digest and holds it again. Read the list on the integration PR report or",
1331
- "with `epic-implementer explain-run` (carried_gap_list) and pass its digest exactly.",
1331
+ "with the `explain_run` MCP tool (input `epic_run_id`; see carried_gap_list) and pass its digest exactly.",
1332
1332
  "",
1333
1333
  "This is the OWNER's step. The /drive-epic-run driver never runs it and workers",
1334
1334
  "cannot. The server records your verified API-key identity as the actor; you cannot",
@@ -1346,7 +1346,7 @@ export function parseAcknowledgeGapsArgs(argv) {
1346
1346
  }
1347
1347
  const digest = requireFlag(values, "--digest");
1348
1348
  if (!/^[0-9a-f]{64}$/.test(digest)) {
1349
- throw new ConductorValidationError("--digest must be the 64-character lowercase hex list digest from the report or explain-run.");
1349
+ throw new ConductorValidationError("--digest must be the 64-character lowercase hex list digest from the report or the explain_run MCP tool.");
1350
1350
  }
1351
1351
  const reason = boundedText(values, "--reason", GAP_ACKNOWLEDGEMENT_REASON_MAX_CHARS);
1352
1352
  if (!reason.trim()) {
@@ -1400,7 +1400,7 @@ export function renderAcknowledgeGapsOutcome(outcome, parsed, json) {
1400
1400
  else if (outcome.code === "GAP_DIGEST_STALE") {
1401
1401
  console.error(`Refused: acknowledge-gaps for ${label} — GAP_DIGEST_STALE: the list changed since ` +
1402
1402
  "you read it. Nothing was written. Re-read the integration PR report or " +
1403
- "`epic-implementer explain-run` (carried_gap_list) and acknowledge the new digest.");
1403
+ "the `explain_run` MCP tool (input `epic_run_id`; see carried_gap_list) and acknowledge the new digest.");
1404
1404
  }
1405
1405
  else {
1406
1406
  console.error(`Refused: acknowledge-gaps for ${label} — ${outcome.code}: ${outcome.message} ` +
@@ -1947,7 +1947,7 @@ const CI_ROUTE_GUIDANCE = {
1947
1947
  ci_route_rerun: "This is an infrastructure CI failure; the server's infrastructure re-run path owns it " +
1948
1948
  "(rerun-ci). No repair was dispatched.",
1949
1949
  ci_route_hold: "CI routing is holding; no widened repair was dispatched. Re-read the run state " +
1950
- "(explain-run) before choosing another action.",
1950
+ "(the `explain_run` MCP tool) before choosing another action.",
1951
1951
  driver_context_not_supported: "This continuation cannot carry --context-file into a worker prompt. Drop --context-file " +
1952
1952
  "and re-run with --reason only. Nothing was written.",
1953
1953
  };
@@ -2304,7 +2304,7 @@ const RESUME_CI_REFUSAL_GUIDANCE = {
2304
2304
  CI_STOP_NOT_ELIGIBLE: "The existing explicit path is `epic-implementer unpark`, which RESETS the CI gate's " +
2305
2305
  "clock and repair allowance. If the park's origin is unclear, ask the run operator " +
2306
2306
  "to assess it first.",
2307
- CI_RESUME_STALE_OPERATION: "Read `epic-implementer explain-run` for the ticket; start a new resume-ci only if " +
2307
+ CI_RESUME_STALE_OPERATION: "Call the `explain_run` MCP tool (inputs `epic_run_id`, `ticket_key`); start a new resume-ci only if " +
2308
2308
  "its current stop independently qualifies.",
2309
2309
  CI_RESUME_CHECKS_NOT_GREEN: "Wait for the required checks to finish green, then retry.",
2310
2310
  CI_RESUME_VERDICT_UNAVAILABLE: "Retry later. If the provider stays unavailable, escalate to the CI-platform operator.",
@@ -2561,7 +2561,7 @@ const REGENERATE_PLAN_REFUSAL_SENTENCES = {
2561
2561
  SPEC_SNAPSHOT_UNAVAILABLE: "the ticket's current specification could not be read",
2562
2562
  CONFLICT: "the ticket kept changing while the request was being applied",
2563
2563
  };
2564
- const REGENERATE_PLAN_GUIDANCE = "Read `epic-implementer explain-run` for the ticket's current park and next action.";
2564
+ const REGENERATE_PLAN_GUIDANCE = "Call the `explain_run` MCP tool (inputs `epic_run_id`, `ticket_key`) for the ticket's current park and next action.";
2565
2565
  const REGENERATE_PLAN_NOT_ELIGIBLE_TEXT = {
2566
2566
  ticket_not_found: "the ticket is not part of this run",
2567
2567
  not_parked: "the ticket is not parked",