@bridge_gpt/mcp-server 0.2.74 → 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 (102) hide show
  1. package/README.md +14 -7
  2. package/build/agent-launchers/prompt.js +9 -21
  3. package/build/agents.generated.js +6 -6
  4. package/build/authored-plan.js +542 -0
  5. package/build/bridge-permissions.js +8 -0
  6. package/build/codex-auto-recovery.js +25 -7
  7. package/build/commands.generated.js +7 -7
  8. package/build/conductor/bridge-api-client.js +807 -52
  9. package/build/conductor/declare-blocked.js +4 -0
  10. package/build/conductor/driver-pass.js +8 -0
  11. package/build/conductor/epic-implementer-cli.js +341 -96
  12. package/build/conductor/epic-server-journal.js +13 -0
  13. package/build/conductor/epic-server-recipe.js +15 -5
  14. package/build/conductor/epic-server-runtime.js +163 -45
  15. package/build/conductor/epic-server.js +13 -6
  16. package/build/conductor/gate-discovery.js +209 -9
  17. package/build/conductor/gate-settings-review.js +7 -11
  18. package/build/conductor/install-doctor.js +30 -2
  19. package/build/conductor/launch-plan.js +58 -12
  20. package/build/conductor/local-merge.js +54 -12
  21. package/build/conductor/open-decision-phrases.js +50 -0
  22. package/build/conductor/pr-ci-producer.js +12 -3
  23. package/build/conductor/prerequisite-inputs.js +181 -14
  24. package/build/conductor/readiness-sections.js +46 -13
  25. package/build/conductor/readiness.js +3 -40
  26. package/build/conductor/recovery-cli.js +12 -12
  27. package/build/conductor/repository-workflow-remedy.js +147 -7
  28. package/build/conductor/ui-readiness.js +224 -0
  29. package/build/conductor/wait-run-attention.js +9 -4
  30. package/build/conductor/wait-run-cli.js +9 -2
  31. package/build/connect-github-api.js +18 -0
  32. package/build/connect-github.js +35 -18
  33. package/build/docs.generated.js +3 -3
  34. package/build/drive-epic.js +787 -37
  35. package/build/epic-ci-workflow.js +3 -2
  36. package/build/epic-implementer-bin.js +200 -66
  37. package/build/epic-implementer-bundle-cli.js +61 -0
  38. package/build/epic-implementer-claude-hook-bin.js +1 -1
  39. package/build/epic-implementer-env.js +3 -4
  40. package/build/epic-integration-pr.js +5 -2
  41. package/build/epic-launch-context.js +8 -1
  42. package/build/epic-shared/cut-protocol.js +55 -3
  43. package/build/executor/completion-contract.js +24 -1
  44. package/build/executor/failure-reason-codes.js +2 -0
  45. package/build/executor/gate-qualification-job.js +193 -23
  46. package/build/executor/gate-qualification-tests-ran.js +232 -0
  47. package/build/executor/integration-job.js +56 -2
  48. package/build/executor/job-runner.js +13 -723
  49. package/build/executor/job-type-wrappers.js +734 -0
  50. package/build/executor/merge-job.js +45 -1
  51. package/build/executor/permissions.js +187 -2
  52. package/build/executor/preflight.js +6 -2
  53. package/build/executor/process-containment.js +8 -1
  54. package/build/executor/provider-checks.js +28 -5
  55. package/build/executor/reconcile-overlap-job.js +70 -17
  56. package/build/executor/required-verification.js +28 -2
  57. package/build/executor/required-work-ledger.js +7 -2
  58. package/build/executor/resume-pre-spawn.js +32 -8
  59. package/build/executor/runner.js +30 -5
  60. package/build/executor/types.js +9 -0
  61. package/build/executor/worker-database.js +6 -1
  62. package/build/executor/worker-guard-hook.js +24 -2
  63. package/build/executor/worktree.js +12 -1
  64. package/build/generated/ticket-status.js +20 -0
  65. package/build/index.js +627 -551
  66. package/build/init.js +16 -0
  67. package/build/install-bridge-conductor-answers.js +32 -1
  68. package/build/install-bridge-conductor-apply.js +21 -3
  69. package/build/install-bridge-conductor-assessment.js +185 -12
  70. package/build/install-bridge-conductor-compact.js +2 -0
  71. package/build/install-bridge-conductor-contracts.js +9 -1
  72. package/build/install-bridge-conductor-gate.js +257 -80
  73. package/build/install-bridge-conductor-setup.js +106 -6
  74. package/build/install-bridge-conductor-trial-report.js +170 -0
  75. package/build/install-bridge-conductor.js +740 -124
  76. package/build/mcp-host-config.js +54 -37
  77. package/build/phase-context-git-probe.js +16 -0
  78. package/build/pipelines.generated.js +15 -15
  79. package/build/plan-execution-ledger.js +27 -0
  80. package/build/plan-generation.js +17 -0
  81. package/build/plane/plane-freshness.js +43 -26
  82. package/build/printed-remedy-commands.js +62 -0
  83. package/build/readme.generated.js +1 -1
  84. package/build/repository-toolchains.js +11 -5
  85. package/build/scripts/saved-commands-config-field-driver.js +65 -0
  86. package/build/secret-redaction.js +3 -0
  87. package/build/setup-epic.js +51 -9
  88. package/build/test-support/create-preview-world.js +232 -0
  89. package/build/test-support/executor-source-files.js +1 -1
  90. package/build/ticket-delivery.js +65 -0
  91. package/build/v2-readiness-requirements.js +13 -4
  92. package/build/version.generated.js +3 -3
  93. package/build/worker-guard-hook-bin.js +2 -2
  94. package/build/worktree-core.js +51 -7
  95. package/docs/EPIC-IMPLEMENTER.md +83 -4
  96. package/docs/epic-implementer/getting-started.md +1 -1
  97. package/docs/install/github-app.md +79 -92
  98. package/package.json +1 -1
  99. package/pipelines/implement-ticket.json +2 -2
  100. package/build/conductor/epic-reconcile.js +0 -603
  101. package/build/conductor/epic-runtime.js +0 -2020
  102. package/build/conductor/epic-state.js +0 -774
@@ -57,6 +57,8 @@ import { AGENTS } from "../agents.generated.js";
57
57
  import { ConductorBridgeApiError, fetchStoredTicket, resolveConductorBridgeApiAccess, } from "./bridge-api-client.js";
58
58
  import { ConductorValidationError } from "./errors.js";
59
59
  import { writeJsonDocument } from "./json-output.js";
60
+ import { findOpenDecisionPhrase } from "./open-decision-phrases.js";
61
+ import { redactSecrets } from "../secret-redaction.js";
60
62
  // ---------------------------------------------------------------------------
61
63
  // Constants
62
64
  // ---------------------------------------------------------------------------
@@ -300,6 +302,25 @@ export function formatPrerequisiteInput(epicKey, epicDescription, childKey, chil
300
302
  function hash12(inputHash) {
301
303
  return inputHash.slice(0, 12);
302
304
  }
305
+ /**
306
+ * BAPI-1704 — display-only protection. Open-decision text is quoted from an
307
+ * untrusted description, so outward JSON copies run it through `redactSecrets`.
308
+ * The validated result (and what is cached) stays raw; only a copy is changed.
309
+ */
310
+ function redactItemForDisplay(item) {
311
+ if ("category" in item && item.category === "open-decision") {
312
+ return { ...item, requirement: redactSecrets(item.requirement), evidence: redactSecrets(item.evidence) };
313
+ }
314
+ return item;
315
+ }
316
+ function redactResultForDisplay(result) {
317
+ return result.status === "cached" ? { ...result, items: result.items.map(redactItemForDisplay) } : result;
318
+ }
319
+ function redactRecordForDisplay(result) {
320
+ if (result.status === "cached")
321
+ return { ...result, items: result.items.map(redactItemForDisplay) };
322
+ return result.items === undefined ? result : { ...result, items: result.items.map(redactItemForDisplay) };
323
+ }
303
324
  /**
304
325
  * The lookup result list. Human output names statuses and short hash prefixes
305
326
  * only: never a requirement, evidence, description, or scanner text. The JSON
@@ -307,7 +328,7 @@ function hash12(inputHash) {
307
328
  */
308
329
  export function formatPrerequisiteInputResults(results, json) {
309
330
  if (json)
310
- return JSON.stringify({ results });
331
+ return JSON.stringify({ results: results.map(redactResultForDisplay) });
311
332
  return results
312
333
  .map((r) => {
313
334
  switch (r.status) {
@@ -326,7 +347,7 @@ export function formatPrerequisiteInputResults(results, json) {
326
347
  /** The one stdout document for a record result. Human output holds no item text. */
327
348
  export function formatPrerequisiteRecordResult(result, json) {
328
349
  if (json)
329
- return JSON.stringify({ results: [result] });
350
+ return JSON.stringify({ results: [redactRecordForDisplay(result)] });
330
351
  if (result.status === "cached") {
331
352
  return `${result.child}: cached (input ${hash12(result.inputHash)}, ${result.items.length} items)`;
332
353
  }
@@ -385,12 +406,54 @@ function resolveAgentVersion(deps) {
385
406
  const CLASSIC_KEYS = ["requirement", "dependents", "class", "env", "uncertain", "evidence"];
386
407
  const NOT_MEASURABLE_KEYS = ["requirement", "dependents", "class", "measurable", "uncertain", "evidence"];
387
408
  const WORKER_RUNTIME_KEYS = ["requirement", "dependents", "category", "uncertain", "evidence"];
409
+ const OPEN_DECISION_KEYS = ["requirement", "dependents", "category", "evidence"];
410
+ /**
411
+ * The child's own text. For a formatted input this is everything after the LAST
412
+ * `\n\nChild: ${child}\n` marker (the real marker is written last, so a marker
413
+ * spoofed inside epic text cannot move the boundary); `undefined` when absent. An
414
+ * isolated source is returned unchanged.
415
+ */
416
+ export function childSegment(source, child) {
417
+ if (source.kind === "isolated")
418
+ return source.text;
419
+ const marker = `\n\nChild: ${child}\n`;
420
+ const at = source.input.lastIndexOf(marker);
421
+ return at < 0 ? undefined : source.input.slice(at + marker.length);
422
+ }
388
423
  function codePointLength(text) {
389
424
  return Array.from(text).length;
390
425
  }
391
426
  function sameKeys(actual, expected) {
392
427
  return actual.length === expected.length && expected.every((key) => actual.includes(key));
393
428
  }
429
+ /**
430
+ * BAPI-1704 — validate an open-decision item: exactly four keys, the usual
431
+ * requirement bounds, this child as the dependent, and evidence that is nonempty,
432
+ * one line, at most 200 code points, and a literal substring of the CHILD's own
433
+ * text (never the epic's).
434
+ */
435
+ function validateOpenDecisionFields(fields, keys, child, input) {
436
+ if (!sameKeys(keys, OPEN_DECISION_KEYS))
437
+ return undefined;
438
+ const { requirement, dependents, evidence } = fields;
439
+ if (typeof requirement !== "string" || typeof dependents !== "string" || typeof evidence !== "string") {
440
+ return undefined;
441
+ }
442
+ if (requirement.length === 0 || codePointLength(requirement) > PREREQUISITE_TEXT_MAX_CHARS)
443
+ return undefined;
444
+ if (requirement.includes("`") || /[\r\n]/.test(requirement))
445
+ return undefined;
446
+ if (dependents !== child)
447
+ return undefined;
448
+ if (evidence.length === 0 || codePointLength(evidence) > PREREQUISITE_TEXT_MAX_CHARS)
449
+ return undefined;
450
+ if (/[\r\n]/.test(evidence))
451
+ return undefined;
452
+ const segment = childSegment({ kind: "formatted", input }, child);
453
+ if (segment === undefined || !segment.includes(evidence))
454
+ return undefined;
455
+ return { requirement, dependents, category: "open-decision", evidence };
456
+ }
394
457
  /**
395
458
  * Validate one item's fields against the child and the exact input. Returns the
396
459
  * typed item, or `undefined` when any constraint fails. Evidence is only checked
@@ -403,6 +466,10 @@ function validateItemFields(fields, child, input) {
403
466
  const value = fields[key];
404
467
  return typeof value === "string" ? value : undefined;
405
468
  };
469
+ if (fields.category === "open-decision") {
470
+ // BAPI-1704: handled before the legacy `uncertain` and worker-runtime branches.
471
+ return validateOpenDecisionFields(fields, keys, child, input);
472
+ }
406
473
  const requirement = text("requirement");
407
474
  const dependents = text("dependents");
408
475
  const uncertain = text("uncertain");
@@ -453,10 +520,13 @@ const FIELD_LINE = /^([a-z]+): ?(.*)$/;
453
520
  *
454
521
  * The reply must be exactly one complete fenced `prerequisites` block and nothing
455
522
  * else. Its body is explicit `none`, one `not verified: <reason>` line, or at most
456
- * twenty items. Any structural defect in any item invalidates the whole child.
457
- * Only after every item is structurally valid are items whose evidence is not a
458
- * literal substring of the input dropped, and the drops are counted, never
459
- * described.
523
+ * twenty items. Any structural defect in any item invalidates the whole child,
524
+ * with one narrow exception (BAPI-1704): a cleanly parsed item whose category is
525
+ * exactly `open-decision` that fails field validation is dropped alone and counted
526
+ * in `openDecisionDropped`. That is distinct from a parse failure (whole block
527
+ * invalid) and from the literal-evidence drop below. Only after every item is
528
+ * structurally valid are items whose evidence is not a literal substring of the
529
+ * input dropped, and those drops are counted in `dropped`, never described.
460
530
  */
461
531
  export function validateScannerBlock(text, child, input) {
462
532
  const normalized = text.replace(/\r\n/g, "\n").trim();
@@ -465,7 +535,7 @@ export function validateScannerBlock(text, child, input) {
465
535
  return { kind: "invalid" };
466
536
  const body = fenced[2];
467
537
  if (body === "none")
468
- return { kind: "items", items: [], dropped: 0 };
538
+ return { kind: "items", items: [], dropped: 0, openDecisionDropped: 0 };
469
539
  const failure = /^not verified: (.{1,200})$/.exec(body);
470
540
  if (failure !== null && !body.includes("\n")) {
471
541
  return {
@@ -499,14 +569,88 @@ export function validateScannerBlock(text, child, input) {
499
569
  if (parsed.length === 0 || parsed.length > PREREQUISITE_MAX_ITEMS)
500
570
  return { kind: "invalid" };
501
571
  const valid = [];
572
+ let openDecisionDropped = 0;
502
573
  for (const fields of parsed) {
503
574
  const item = validateItemFields(fields, child, input);
504
- if (item === undefined)
575
+ if (item === undefined) {
576
+ // BAPI-1704: framing and field parsing already succeeded. Only a cleanly
577
+ // parsed item whose category is exactly `open-decision` is dropped alone;
578
+ // every other invalid item (including `Open-Decision`) invalidates the block.
579
+ if (fields.category === "open-decision") {
580
+ openDecisionDropped += 1;
581
+ continue;
582
+ }
505
583
  return { kind: "invalid" };
584
+ }
506
585
  valid.push(item);
507
586
  }
508
587
  const kept = valid.filter((item) => input.includes(item.evidence));
509
- return { kind: "items", items: kept, dropped: valid.length - kept.length };
588
+ return { kind: "items", items: kept, dropped: valid.length - kept.length, openDecisionDropped };
589
+ }
590
+ // ---------------------------------------------------------------------------
591
+ // Open-decision backstop (BAPI-1704)
592
+ // ---------------------------------------------------------------------------
593
+ /** The most backstop items one child may produce, independent of the agent-item cap. */
594
+ export const OPEN_DECISION_BACKSTOP_MAX_ITEMS = 20;
595
+ const MARKDOWN_FENCE_LINE = /^\s*(```|~~~)/;
596
+ const NOFORMAT_LINE = /\{noformat(?::[^}]*)?\}/i;
597
+ /**
598
+ * Derive advisory open-decision items straight from the child's own text, without
599
+ * a scanner. It is pure and never cached: the caller recomputes it on every read.
600
+ *
601
+ * Fenced code blocks and Jira `{noformat}` regions are skipped (delimiter lines
602
+ * too), following the canonical semantics in `docs/bridge-ticket-authoring.md`.
603
+ * A line already covered by an agent open-decision item's unchanged evidence is
604
+ * suppressed. Each remaining matching line yields one item for its earliest
605
+ * phrase, quoting from the start of the sentence holding the match through the end
606
+ * of the line, bounded to 200 code points and always a literal substring of the
607
+ * source. At most {@link OPEN_DECISION_BACKSTOP_MAX_ITEMS} items are returned.
608
+ */
609
+ export function openDecisionBackstop(source, child, agentItems) {
610
+ const segment = childSegment(source, child);
611
+ if (segment === undefined)
612
+ return [];
613
+ const agentEvidence = agentItems
614
+ .filter((item) => "category" in item && item.category === "open-decision")
615
+ .map((item) => item.evidence);
616
+ const out = [];
617
+ let inFence = false;
618
+ let inNoformat = false;
619
+ for (const line of segment.split("\n")) {
620
+ if (out.length >= OPEN_DECISION_BACKSTOP_MAX_ITEMS)
621
+ break;
622
+ if (!inNoformat && MARKDOWN_FENCE_LINE.test(line)) {
623
+ inFence = !inFence;
624
+ continue;
625
+ }
626
+ if (!inFence && NOFORMAT_LINE.test(line)) {
627
+ inNoformat = !inNoformat;
628
+ continue;
629
+ }
630
+ if (inFence || inNoformat)
631
+ continue;
632
+ if (agentEvidence.some((evidence) => line.includes(evidence)))
633
+ continue;
634
+ const match = findOpenDecisionPhrase(line);
635
+ if (match === undefined)
636
+ continue;
637
+ const sentenceBreak = line.slice(0, match.index).lastIndexOf(". ");
638
+ let start = sentenceBreak < 0 ? 0 : sentenceBreak + 2;
639
+ while (start < match.index && /\s/.test(line[start]))
640
+ start += 1;
641
+ const lineBreak = line.slice(start).search(/[\r\n]/);
642
+ const tail = lineBreak < 0 ? line.slice(start) : line.slice(start, start + lineBreak);
643
+ const evidence = Array.from(tail).slice(0, PREREQUISITE_TEXT_MAX_CHARS).join("");
644
+ if (evidence.length === 0)
645
+ continue;
646
+ out.push({
647
+ requirement: `Ticket text leaves a decision open ("${match.phrase}").`,
648
+ dependents: child,
649
+ category: "open-decision",
650
+ evidence,
651
+ });
652
+ }
653
+ return out;
510
654
  }
511
655
  // ---------------------------------------------------------------------------
512
656
  // Filesystem
@@ -979,6 +1123,9 @@ function notCached(child, inputHash, reason, extra = {}) {
979
1123
  verified: extra.verified ?? false,
980
1124
  ...(extra.items !== undefined ? { items: extra.items } : {}),
981
1125
  ...(extra.dropped !== undefined ? { dropped: extra.dropped } : {}),
1126
+ ...(extra.openDecisionDropped !== undefined && extra.openDecisionDropped > 0
1127
+ ? { openDecisionDropped: extra.openDecisionDropped }
1128
+ : {}),
982
1129
  };
983
1130
  }
984
1131
  /**
@@ -1039,13 +1186,23 @@ async function recordResult(ctx, deps, parsed, stdinText) {
1039
1186
  verified: outcome.items.length > 0,
1040
1187
  ...(outcome.items.length > 0 ? { items: outcome.items } : {}),
1041
1188
  dropped: outcome.dropped,
1189
+ openDecisionDropped: outcome.openDecisionDropped,
1042
1190
  });
1043
1191
  }
1044
1192
  const wrote = await writeCacheEntry(ctx, child, suppliedHash, outcome.items);
1045
1193
  await release();
1046
- if (!wrote)
1047
- return notCached(child, suppliedHash, "cache unavailable");
1048
- return { child, status: "cached", inputHash: suppliedHash, items: outcome.items };
1194
+ if (!wrote) {
1195
+ return notCached(child, suppliedHash, "cache unavailable", {
1196
+ openDecisionDropped: outcome.openDecisionDropped,
1197
+ });
1198
+ }
1199
+ return {
1200
+ child,
1201
+ status: "cached",
1202
+ inputHash: suppliedHash,
1203
+ items: outcome.items,
1204
+ ...(outcome.openDecisionDropped > 0 ? { openDecisionDropped: outcome.openDecisionDropped } : {}),
1205
+ };
1049
1206
  }
1050
1207
  catch {
1051
1208
  return notCached(child, suppliedHash, "cache unavailable");
@@ -1061,7 +1218,11 @@ async function recordResult(ctx, deps, parsed, stdinText) {
1061
1218
  * {@link readCacheEntry}. It takes no scan claim, creates no directory, writes no
1062
1219
  * file, and never reports a scan as needed. A child with no valid entry (a miss, a
1063
1220
  * changed description, an unreadable or corrupt entry, an oversize input, a failed
1064
- * ticket read) is simply absent from the result. Only a failure that affects every
1221
+ * ticket read) is simply absent from the result, unless the BAPI-1704 open-decision
1222
+ * backstop finds a match in the child's own text: then the entry holds only those
1223
+ * generated items. An entry may therefore carry transient enrichment (cached agent
1224
+ * items followed by freshly derived backstop items) rather than only persisted
1225
+ * scanner results; nothing derived is ever written. Only a failure that affects every
1065
1226
  * child (an epic read failure, an unavailable scanner entry, bad keys) is
1066
1227
  * `unavailable`. Descriptions and evidence never leave this function except as
1067
1228
  * validated items.
@@ -1092,7 +1253,13 @@ export async function readCachedPrerequisites(input, deps = {}) {
1092
1253
  if (Buffer.byteLength(content, "utf8") > PREREQUISITE_INPUT_MAX_BYTES)
1093
1254
  return null;
1094
1255
  const cached = await readCacheEntry(ctx, child, computeInputHash(agentVersion, content), content);
1095
- return cached.kind === "hit" ? { child, items: cached.items } : null;
1256
+ const cachedItems = cached.kind === "hit" ? cached.items : [];
1257
+ // BAPI-1704: recompute the uncached backstop from the child's own description
1258
+ // (isolated; never parsed out of the combined epic-and-child text).
1259
+ const backstop = openDecisionBackstop({ kind: "isolated", text: wrapDescription(ticket.description) }, child, cachedItems);
1260
+ if (cached.kind !== "hit" && backstop.length === 0)
1261
+ return null;
1262
+ return { child, items: [...cachedItems, ...backstop] };
1096
1263
  }
1097
1264
  catch {
1098
1265
  return null;
@@ -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",