@bridge_gpt/mcp-server 0.2.73 → 0.2.75

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 (123) hide show
  1. package/README.md +14 -7
  2. package/build/agent-launchers/claude-executor-adapter.js +12 -0
  3. package/build/agent-launchers/prompt.js +9 -21
  4. package/build/agents.generated.js +4 -4
  5. package/build/authored-plan.js +542 -0
  6. package/build/bridge-config.js +7 -1
  7. package/build/bridge-permissions.js +11 -0
  8. package/build/command-provisioning.js +4 -3
  9. package/build/commands.generated.js +6 -6
  10. package/build/conductor/bridge-api-client.js +692 -47
  11. package/build/conductor/command-drift.js +1 -1
  12. package/build/conductor/declared-extras.js +335 -0
  13. package/build/conductor/doctor.js +2 -0
  14. package/build/conductor/driver-pass-output.js +104 -0
  15. package/build/conductor/driver-pass.js +571 -0
  16. package/build/conductor/epic-branch-ci-inspection.js +61 -16
  17. package/build/conductor/epic-implementer-cli.js +370 -93
  18. package/build/conductor/epic-server-sfcc-upload.js +1567 -0
  19. package/build/conductor/epic-server-sfcc.js +58 -80
  20. package/build/conductor/epic-server.js +57 -4
  21. package/build/conductor/gate-discovery.js +253 -13
  22. package/build/conductor/gate-settings-review.js +58 -25
  23. package/build/conductor/launch-plan.js +58 -12
  24. package/build/conductor/open-decision-phrases.js +50 -0
  25. package/build/conductor/prerequisite-inputs.js +181 -14
  26. package/build/connect-github-api.js +18 -0
  27. package/build/connect-github.js +35 -18
  28. package/build/credential-delivery.js +280 -0
  29. package/build/credential-launch-safety.js +142 -0
  30. package/build/credential-materialization.js +91 -16
  31. package/build/credential-references-node-deps.js +29 -0
  32. package/build/credential-references.js +1394 -0
  33. package/build/credential-references.test-fixtures.js +211 -0
  34. package/build/credential-scan-conventions.js +145 -0
  35. package/build/credential-scan.js +517 -0
  36. package/build/credential-store.js +50 -0
  37. package/build/credentials-cli.js +252 -3
  38. package/build/dependency-install-declarations.js +47 -1
  39. package/build/docs.generated.js +8 -1
  40. package/build/doctor.js +41 -0
  41. package/build/drive-epic.js +684 -49
  42. package/build/epic-branch-ci-summary.js +18 -1
  43. package/build/epic-capability-statement.js +71 -3
  44. package/build/epic-ci-workflow-drift.js +52 -13
  45. package/build/epic-ci-workflow-install.js +31 -6
  46. package/build/epic-ci-workflow-v3.js +273 -0
  47. package/build/epic-ci-workflow.js +129 -7
  48. package/build/epic-implementer-bin.js +288 -83
  49. package/build/epic-implementer-bundle-cli.js +61 -0
  50. package/build/epic-implementer-claude-hook-bin.js +1 -1
  51. package/build/epic-implementer-env.js +3 -4
  52. package/build/epic-integration-pr.js +5 -2
  53. package/build/epic-launch-context.js +102 -7
  54. package/build/epic-server-record.js +30 -15
  55. package/build/executor/completion-contract.js +24 -1
  56. package/build/executor/credential-delivery-step.js +168 -0
  57. package/build/executor/deps.js +3 -1
  58. package/build/executor/env.js +39 -1
  59. package/build/executor/epic-server-context.js +23 -7
  60. package/build/executor/gate-qualification-job.js +193 -23
  61. package/build/executor/gate-qualification-tests-ran.js +232 -0
  62. package/build/executor/guarded-fast-forward-push.js +13 -8
  63. package/build/executor/job-runner.js +167 -738
  64. package/build/executor/job-type-wrappers.js +734 -0
  65. package/build/executor/permissions.js +85 -3
  66. package/build/executor/preflight.js +6 -2
  67. package/build/executor/process-containment.js +8 -1
  68. package/build/executor/prompt-spec.js +37 -3
  69. package/build/executor/required-verification.js +28 -2
  70. package/build/executor/runner.js +4 -1
  71. package/build/executor/types.js +9 -0
  72. package/build/executor/worker-database.js +6 -1
  73. package/build/executor/worker-guard-hook.js +24 -2
  74. package/build/executor-launch.js +4 -2
  75. package/build/generated/ticket-status.js +20 -0
  76. package/build/git-exclude-lock.js +187 -0
  77. package/build/index.js +589 -326
  78. package/build/install-bridge-conductor-answers.js +112 -22
  79. package/build/install-bridge-conductor-apply.js +38 -1
  80. package/build/install-bridge-conductor-assessment.js +482 -53
  81. package/build/install-bridge-conductor-compact.js +29 -2
  82. package/build/install-bridge-conductor-contracts.js +10 -1
  83. package/build/install-bridge-conductor-gate.js +379 -89
  84. package/build/install-bridge-conductor-setup.js +46 -8
  85. package/build/install-bridge-conductor-trial-report.js +170 -0
  86. package/build/install-bridge-conductor.js +925 -141
  87. package/build/install-bridge.js +88 -11
  88. package/build/install-doctor.js +38 -8
  89. package/build/install-sfcc-detection.js +120 -0
  90. package/build/install-sfcc-setup.js +185 -0
  91. package/build/mcp-grant-candidates.js +108 -96
  92. package/build/mcp-invoke.js +168 -4
  93. package/build/mcp-provisioning.js +21 -4
  94. package/build/mcp-server-invocation.js +13 -0
  95. package/build/merge-workflow-install.js +9 -1
  96. package/build/pipelines.generated.js +8 -7
  97. package/build/plan-generation.js +17 -0
  98. package/build/plane/status.js +8 -2
  99. package/build/printed-remedy-commands.js +59 -0
  100. package/build/project-root.js +40 -0
  101. package/build/readme.generated.js +1 -1
  102. package/build/repository-state-paths.js +5 -2
  103. package/build/repository-toolchains.js +16 -7
  104. package/build/scripts/saved-commands-config-field-driver.js +65 -0
  105. package/build/setup-epic.js +126 -16
  106. package/build/sfcc/credentials.js +3 -2
  107. package/build/sfcc/hostname.js +98 -2
  108. package/build/sfcc/tool-wrapper.js +6 -95
  109. package/build/start-tickets.js +193 -29
  110. package/build/test-support/executor-source-files.js +200 -0
  111. package/build/testing-config-client.js +25 -2
  112. package/build/third-party-mcp-targets.js +35 -4
  113. package/build/v2-readiness-requirements.js +5 -1
  114. package/build/version.generated.js +3 -3
  115. package/build/with-credentials.js +208 -0
  116. package/build/worker-guard-hook-bin.js +2 -2
  117. package/build/worktree-credential-delivery.js +340 -0
  118. package/docs/EPIC-IMPLEMENTER.md +4 -4
  119. package/docs/install/github-app.md +79 -92
  120. package/package.json +1 -1
  121. package/build/conductor/epic-reconcile.js +0 -603
  122. package/build/conductor/epic-runtime.js +0 -2020
  123. package/build/conductor/epic-state.js +0 -774
@@ -13,7 +13,50 @@
13
13
  import { INSTALL_ASSESSMENT_SCHEMA_VERSION, } from "./install-bridge-conductor-contracts.js";
14
14
  import { EPIC_SERVER_QUESTION, MCP_GRANT_QUESTION, REINDEX_RETRY_QUESTION, SETUP_ITEM_IDS, setupItemRemedy } from "./install-bridge-conductor-setup.js";
15
15
  import { describeDeclinedCiChange, describeEpicBranchCi, finalIntegrationSentence } from "./epic-branch-ci-summary.js";
16
- import { EPIC_CI_WORKFLOW_PATH } from "./epic-ci-workflow.js";
16
+ import { EPIC_CI_WORKFLOW_PATH, EPIC_IMPLEMENTER_CI_CHECK_NAME } from "./epic-ci-workflow.js";
17
+ import { READINESS_PREREQUISITE_FIXES } from "./printed-remedy-commands.js";
18
+ import { plainDisplayText } from "./conductor/gate-settings-review.js";
19
+ import { describeSfccUpload, isSfccUploadCapable, WORKER_UPLOAD_ADVISORY } from "./install-sfcc-setup.js";
20
+ /**
21
+ * BAPI-1667 — recommend the mode by where browser checks run. A settled or
22
+ * unreadable choice keeps. For an open choice: `local` with guidance or a dev script
23
+ * (uploads still work there), then `sfcc_shared_active` when upload can work and
24
+ * nothing runs locally, then `none`.
25
+ */
26
+ export function recommendEpicServer(e) {
27
+ const current = e?.current ?? null;
28
+ if (e === null || !e.applicable || current !== null) {
29
+ return {
30
+ recommended: "keep",
31
+ why: current !== null ? "A valid choice is already stored, so nothing changes." : "The epic-server record could not be read here, so nothing is written.",
32
+ };
33
+ }
34
+ const sfccDetected = e.sfcc?.detected === true;
35
+ const check = sfccDetected ? e.sfcc?.uploadCheck ?? null : null;
36
+ const capable = isSfccUploadCapable(check);
37
+ const workerAdvisory = check?.state === "possible_with_advisory" ? ` ${WORKER_UPLOAD_ADVISORY}` : "";
38
+ if (e.guidancePresent === true || e.devScript === true) {
39
+ const base = e.guidancePresent === true
40
+ ? "This repository has epic-server guidance, so a local epic server can run the app for browser checks."
41
+ : "This repository has a dev script, so the app can likely run on this machine for browser checks. Add .bridge/epic-server.toml and run epic-server prove; until then UI checks are handed off, exactly as with none.";
42
+ const upload = capable ? ` With an approved sandbox, cartridge changes are uploaded to it before each turn, so the local app sees them.${workerAdvisory}` : "";
43
+ return { recommended: "local", why: `${base}${upload}` };
44
+ }
45
+ if (capable) {
46
+ return {
47
+ recommended: "sfcc_shared_active",
48
+ why: `This SFCC repository can upload cartridges and has no local dev server, so browser checks run on one approved sandbox.${workerAdvisory}`,
49
+ };
50
+ }
51
+ return { recommended: "none", why: RECOMMENDATION_POLICY.epic_server.lastResort.why };
52
+ }
53
+ /**
54
+ * BAPI-1667 — the option ids to recommend for an open grant. Empty unless an SFCC
55
+ * repository's candidates were flagged, so every other repository keeps `[]`.
56
+ */
57
+ export function recommendMcpGrant(g) {
58
+ return g.candidates.filter((c) => c.sfcc_recommended === true).map((c) => c.id).sort();
59
+ }
17
60
  // ---------------------------------------------------------------------------
18
61
  // Items
19
62
  // ---------------------------------------------------------------------------
@@ -109,9 +152,9 @@ function gateChoice(gate) {
109
152
  family: "gate",
110
153
  answer_key: "gate",
111
154
  current: gate.currentKind,
112
- options: approveDecline(gate.consequence || "Stores the proposed gate and the safe supervisor defaults.", "Keeps the gate and defaults unchanged. A run without a stored gate is not ready."),
155
+ options: approveDecline(gate.consequence || "Stores the proposed gate and the safe supervisor defaults.", "Keeps the saved merge checks and run defaults as they are, and writes nothing. A run without a stored gate is not ready."),
113
156
  recommended: "approve",
114
- why_recommended: "Runs are admitted only once a confirmed gate and the safe defaults are stored.",
157
+ why_recommended: "A run cannot start until a gate is saved, because the gate sets what must pass before a child merges.",
115
158
  consequential: true,
116
159
  applicable: true,
117
160
  selection: "single",
@@ -124,6 +167,20 @@ const DECLARATION_LABEL = Object.freeze({
124
167
  must_order_paths: "paths that must change in order",
125
168
  worker_database: "the worker database",
126
169
  });
170
+ /** BAPI-1678 — why each declaration is offered. Each one states its own purpose. */
171
+ const DECLARATION_REASON = Object.freeze({
172
+ dependency_install: "Workers need this to install what the gate's command uses before they run it.",
173
+ ci_database: "CI needs this to know which database to start for its checks.",
174
+ must_order_paths: "Two children adding migrations at once can create two migration heads, so these merge one at a time.",
175
+ worker_database: "Workers use this to prepare the database they need while running checks.",
176
+ });
177
+ /** BAPI-1678 — what declining keeps. Declining never clears a stored value. */
178
+ const DECLARATION_DECLINE = Object.freeze({
179
+ dependency_install: "Writes nothing. Any install commands already stored stay, and workers and the test trial keep using them. If none are stored, they run no declared install.",
180
+ ci_database: "Writes nothing. Any CI database setting already stored stays, and CI keeps using it. If none is stored, CI has no declared database.",
181
+ must_order_paths: "Writes nothing. Any ordered paths already stored stay. These paths are not added, so children that change them are not held to one merge at a time.",
182
+ worker_database: "Writes nothing. Any worker database setting already stored stays, and workers keep using it. If none is stored, workers have no declared database.",
183
+ });
127
184
  function declarationEffect(key, value) {
128
185
  return { action: "store_declaration", target: `repository_gate.${key}`, params: { value } };
129
186
  }
@@ -140,22 +197,56 @@ function declarationChoice(key, found) {
140
197
  consequential: true,
141
198
  applicable: false,
142
199
  selection: "single",
143
- ...(found !== undefined ? { effects: { approve: declarationEffect(key, found.value) } } : {}),
200
+ ...(found !== undefined && found.value !== null ? { effects: { approve: declarationEffect(key, found.value) } } : {}),
201
+ ...(found?.dependencyInstall !== undefined ? { dependency_install: found.dependencyInstall } : {}),
144
202
  };
145
203
  }
146
204
  const detail = found.summary.map((line) => line.trim()).join("; ");
205
+ const replacing = found.recommendDecline === true;
147
206
  return {
148
207
  id: key,
149
208
  family: "worker_declaration",
150
209
  answer_key: key,
151
210
  current: null,
152
- options: approveDecline(`Stores ${DECLARATION_LABEL[key]} with the gate${detail ? ` (${detail})` : ""}. Workers prepare with it before qualification.`, `Leaves ${DECLARATION_LABEL[key]} as it is stored.`),
153
- recommended: "approve",
154
- why_recommended: "Discovery read this from the repository's own files, and workers need it to run the gate's command.",
211
+ options: approveDecline(key === "dependency_install" && found.dependencyInstall !== undefined
212
+ ? `Stores these install commands with the gate: ${commandList(found.dependencyInstall.commands)}. ${found.dependencyInstall.lifecycle}`
213
+ : `Stores ${DECLARATION_LABEL[key]} with the gate${detail ? ` (${detail})` : ""}. Workers prepare with it before qualification.`, DECLARATION_DECLINE[key]),
214
+ recommended: replacing ? "decline" : "approve",
215
+ why_recommended: replacing
216
+ ? "This would drop or rewrite a command you already stored, so keeping it is the safer default. Approve it only if the new commands are what you want."
217
+ : DECLARATION_REASON[key],
155
218
  consequential: true,
156
219
  applicable: true,
157
220
  selection: "single",
158
221
  effects: { approve: declarationEffect(key, found.value) },
222
+ ...(found.dependencyInstall !== undefined ? { dependency_install: found.dependencyInstall } : {}),
223
+ };
224
+ }
225
+ /** The exact commands in the plain form people read. The list itself stays an argument array. */
226
+ function commandList(rows) {
227
+ return rows
228
+ .map((row) => `${row.argv.map(displayArg).join(" ")} (in ${row.cwd === "." ? "the repository root" : displayArg(row.cwd)})`)
229
+ .join("; ");
230
+ }
231
+ function displayArg(value) {
232
+ return plainDisplayText(value);
233
+ }
234
+ /** BAPI-1677 — the owner-facing facts of the install plan, safe to show. */
235
+ export function dependencyInstallDetails(input) {
236
+ const row = (e) => ({
237
+ cwd: displayArg(e.cwd),
238
+ argv: e.argv.map(displayArg),
239
+ lockfiles: e.lockfiles.map(displayArg),
240
+ });
241
+ // BAPI-1698: proposed installs come first; named coverage gaps (from the plan's
242
+ // limitations) follow them. Gaps are advisory and never a prerequisite.
243
+ return {
244
+ commands: input.commands.map(row),
245
+ ...(input.differs ? { stored: input.stored.map(row) } : {}),
246
+ evidence: input.evidence.map((e) => ({ extra: displayArg(e.extra), field: e.field, span: displayArg(e.span) })),
247
+ lifecycle: "Each command runs in every fresh worker worktree, and again only when a file it names changes.",
248
+ limitations: input.limitations.map(displayArg),
249
+ correction: "To correct them, choose change something and give the whole list as entries, each with its folder, its command as a list of arguments, and the files it watches. The list replaces every install command, in the order you give. An empty list means workers and the test trial run no declared install, and managed CI uses its normal toolchain install.",
159
250
  };
160
251
  }
161
252
  /** The bounded discovery-and-promotion trial: the server tries learned candidates and stores one only if it passes. */
@@ -165,13 +256,89 @@ export const LEARN_EFFECT = Object.freeze({
165
256
  params: Object.freeze({ bounded: true }),
166
257
  condition: "only_if_check_passes",
167
258
  });
259
+ /** BAPI-1699 — qualify the owner's saved commands; the model is not consulted. */
260
+ export function qualifySavedEffect(saved) {
261
+ return {
262
+ action: "qualify_saved_test_commands",
263
+ target: "repository_gate.local_commands",
264
+ params: { commands: [...saved.commands], generation: saved.generation },
265
+ condition: "only_if_check_passes",
266
+ };
267
+ }
268
+ const SAVED_STATUS_LABEL = Object.freeze({
269
+ not_tried: "Saved; trial not yet run",
270
+ queued: "Trial queued",
271
+ failed: "Trial failed",
272
+ passed: "Passed the trial run",
273
+ });
274
+ /** The factual label for a saved selection's trial state; `null` means the server could not say. */
275
+ export function savedStatusLabel(trialState) {
276
+ return trialState === null ? "Trial could not be read" : SAVED_STATUS_LABEL[trialState] ?? "Trial could not be read";
277
+ }
278
+ function savedDetails(saved) {
279
+ return {
280
+ pending: saved.commands.map(displayArg),
281
+ in_force: (saved.commandsInForce ?? []).map(displayArg),
282
+ status_label: savedStatusLabel(saved.trialState),
283
+ ...(saved.setBy !== null ? { set_by: displayArg(saved.setBy) } : {}),
284
+ };
285
+ }
286
+ function savedCommandsChoice(t, saved) {
287
+ const details = savedDetails(saved);
288
+ const lines = details.pending.map((command) => `\`${command}\``).join(", ");
289
+ if (saved.trialState === "passed") {
290
+ return {
291
+ id: "test_command",
292
+ family: "test_command",
293
+ answer_key: "test_command",
294
+ current: "stored",
295
+ options: [KEEP_OPTION(`The saved test commands (${lines}) passed the trial run and stay in force.`)],
296
+ recommended: "keep",
297
+ why_recommended: "These commands passed the trial run, so nothing changes.",
298
+ consequential: false,
299
+ applicable: t.ownerCommandSupplied,
300
+ selection: "single",
301
+ test_commands: details,
302
+ };
303
+ }
304
+ const replacing = details.in_force.length > 0;
305
+ return {
306
+ id: "test_command",
307
+ family: "test_command",
308
+ answer_key: "test_command",
309
+ current: "saved_pending",
310
+ options: [
311
+ {
312
+ id: "learn",
313
+ label: `Give the saved test commands a trial run: ${lines}`,
314
+ consequence: `Bridge tries exactly these commands, in this order, in a clean checkout. The model is not consulted. ` +
315
+ (replacing
316
+ ? "The guard you have now stays in force until they pass the trial run."
317
+ : "They are relied on for the guard only after they pass the trial run."),
318
+ },
319
+ { id: "skip", label: "Leave the saved commands untried for now", consequence: "Nothing runs; the commands stay saved and are not in force." },
320
+ ],
321
+ recommended: "learn",
322
+ why_recommended: "You or your agent already chose these commands; a trial run proves they work in a clean checkout before anything relies on them.",
323
+ consequential: false,
324
+ applicable: true,
325
+ selection: "single",
326
+ effects: { learn: qualifySavedEffect(saved) },
327
+ test_commands: details,
328
+ };
329
+ }
168
330
  function testCommandChoice(t) {
331
+ if (t.saved !== undefined)
332
+ return savedCommandsChoice(t, t.saved);
169
333
  const options = [];
334
+ const candidate = t.candidate !== undefined && t.candidate !== null ? displayArg(t.candidate) : null;
170
335
  if (t.trialEligible) {
171
336
  options.push({
172
337
  id: "learn",
173
- label: "Let Bridge learn and prove the test command",
174
- consequence: "Bridge tries the commands it learned from the repository, one bounded trial, and stores one only if the check passes.",
338
+ label: candidate !== null ? `Let Bridge learn the test command and give it a trial run (it expects to try ${candidate})` : "Let Bridge learn the test command and give it a trial run",
339
+ consequence: (candidate !== null ? `Bridge expects to try ${candidate} first. ` : "") +
340
+ "Learning stores instructions, not a command that has passed the trial run, so they guide the attempt and the server may choose another command. " +
341
+ "It runs one bounded trial and stores a command only if the check passes.",
175
342
  });
176
343
  }
177
344
  options.push(t.stored
@@ -185,10 +352,10 @@ function testCommandChoice(t) {
185
352
  options,
186
353
  recommended: t.trialEligible ? "learn" : t.stored ? "keep" : "skip",
187
354
  why_recommended: t.trialEligible
188
- ? "A learned command is stored only after the server proves it passes, so it cannot weaken the gate."
355
+ ? "A learned command is stored only after it passes the trial run, so it cannot weaken the gate."
189
356
  : t.stored
190
- ? "A command is already stored and proven, so nothing changes."
191
- : "No trial can run for this gate, so there is nothing to prove now.",
357
+ ? "A command is already stored and passed the trial run, so nothing changes."
358
+ : "There is no test command Bridge can try right now, and setup can still finish without one.",
192
359
  consequential: false,
193
360
  applicable: t.trialEligible || t.ownerCommandSupplied,
194
361
  selection: "single",
@@ -222,9 +389,12 @@ function setupPrChoice(pr) {
222
389
  family: "setup_pr",
223
390
  answer_key: "setup_pr",
224
391
  current: pr.workflowState,
225
- options: approveDecline(`Opens a setup pull request running ${runs}, only if the check passes. You review and merge it.`, "Opens no pull request. Bridge's workflow is not added."),
226
- recommended: "approve",
227
- why_recommended: `The workflow runs ${runs}, the pull request opens only if that check passes, and you review and merge it, so nothing reaches your default branch without you.`,
392
+ options: approveDecline(`Adds a GitHub check (${EPIC_IMPLEMENTER_CI_CHECK_NAME}) to each epic pull request, running ${runs}. ` +
393
+ "The setup pull request opens only if the check passes, and you must merge it before the first epic. " +
394
+ "Approving also adds that check as a required check.", "Opens no pull request. Bridge's workflow is not added, and the managed check is not made required."),
395
+ // BAPI-1701: the managed workflow is an opt-in. Approving it also adds a required check, so it is offered, not recommended.
396
+ recommended: "decline",
397
+ why_recommended: `Declining avoids the setup pull request and does not add ${EPIC_IMPLEMENTER_CI_CHECK_NAME} as a required check, and you can still approve it for a GitHub check on each epic pull request running ${runs}.`,
228
398
  consequential: true,
229
399
  applicable: true,
230
400
  selection: "single",
@@ -440,16 +610,19 @@ function mcpGrantChoice(g) {
440
610
  // A settled grant is kept when its key is left out; only an open grant recommends the empty selection.
441
611
  if (!g.applicable)
442
612
  options.unshift(KEEP_OPTION("Workers keep exactly the MCP servers already approved."));
613
+ const sfccGrant = g.applicable ? recommendMcpGrant(g) : [];
443
614
  return {
444
615
  id: "worker_mcp_grant",
445
616
  family: "worker_mcp_grant",
446
617
  answer_key: "worker_mcp_grant",
447
618
  current: g.current,
448
619
  options,
449
- recommended: g.applicable ? [] : "keep",
450
- why_recommended: g.applicable
451
- ? "Workers always get Bridge; each extra server is a deliberate grant, so setup recommends none and you add only what you need."
452
- : "The approved servers still match what this repository offers, so nothing changes.",
620
+ recommended: g.applicable ? sfccGrant : "keep",
621
+ why_recommended: sfccGrant.length > 0
622
+ ? "This is an SFCC repository, so setup recommends the Playwright preset for browser checks and b2c-dx-mcp, when offered, as an agent tool (logs, SCAPI, docs). Verification uploads go through epic-server sfcc-upload, not through this server."
623
+ : g.applicable
624
+ ? "Workers always get Bridge; each extra server is a deliberate grant, so setup recommends none and you add only what you need."
625
+ : "The approved servers still match what this repository offers, so nothing changes.",
453
626
  consequential: true,
454
627
  applicable: g.applicable,
455
628
  selection: "multiple",
@@ -460,23 +633,28 @@ function mcpGrantChoice(g) {
460
633
  invalid_existing: g.invalidExisting.map(excludedEntry),
461
634
  };
462
635
  }
636
+ /** BAPI-1667 — an SFCC repository whose check did not run says so, the same as one that could not. */
637
+ const UPLOAD_CHECK_NOT_RUN = Object.freeze({ state: "unknown", missing: [] });
463
638
  function epicServerChoice(e) {
464
639
  const current = e?.current ?? null;
640
+ // BAPI-1667: fixed additions only when SFCC or a recorded sandbox applies; otherwise the text is unchanged.
641
+ const uploadText = e?.sfcc?.detected === true ? describeSfccUpload(e.sfcc.uploadCheck ?? UPLOAD_CHECK_NOT_RUN) : "";
642
+ const keptSandbox = e?.sandboxRecorded === true ? " The approved sandbox stays recorded, so uploads stay on." : "";
465
643
  const options = [
466
644
  {
467
645
  id: "none",
468
646
  label: "No epic server",
469
- consequence: "Runs start no epic server; UI checks are handed off to a person.",
647
+ consequence: `Runs start no epic server; UI checks are handed off to a person.${keptSandbox}`,
470
648
  },
471
649
  {
472
650
  id: "local",
473
651
  label: "A local epic server",
474
- consequence: "The driver starts the epic's code with a throwaway test login, and workers borrow it in turns for UI checks.",
652
+ consequence: `The driver starts the epic's code with a throwaway test login, and workers borrow it in turns for UI checks.${keptSandbox}`,
475
653
  },
476
654
  {
477
655
  id: "sfcc_shared_active",
478
656
  label: "One approved SFCC sandbox",
479
- consequence: "Workers use the approved sandbox. Its account secret stays in the credential store; only its reference is stored.",
657
+ consequence: `Workers use the approved sandbox. Its account secret stays in the credential store; only its reference is stored.${uploadText !== "" ? ` ${uploadText}` : ""}`,
480
658
  },
481
659
  ];
482
660
  const applicable = e?.applicable ?? false;
@@ -486,18 +664,15 @@ function epicServerChoice(e) {
486
664
  options.unshift(KEEP_OPTION(`The stored choice (${current}) stays as it is.`));
487
665
  else
488
666
  options.unshift(KEEP_OPTION("Nothing is written; the epic-server record stays as it is."));
667
+ const recommendation = recommendEpicServer(e);
489
668
  return {
490
669
  id: "epic_server",
491
670
  family: "epic_server",
492
671
  answer_key: "epic_server",
493
672
  current,
494
673
  options,
495
- recommended: applicable && current === null ? "none" : "keep",
496
- why_recommended: applicable && current === null
497
- ? "No epic server is the safe default: a missing server only hands UI checks off."
498
- : current !== null
499
- ? "A valid choice is already stored, so nothing changes."
500
- : "The epic-server record could not be read here, so nothing is written.",
674
+ recommended: recommendation.recommended,
675
+ why_recommended: recommendation.why,
501
676
  consequential: true,
502
677
  applicable,
503
678
  selection: "single",
@@ -506,6 +681,9 @@ function epicServerChoice(e) {
506
681
  local: { action: "write_epic_server_record", target: "epic_server_record", params: { mode: "local" } },
507
682
  sfcc_shared_active: { action: "write_epic_server_record", target: "epic_server_record", params: { mode: "sfcc_shared_active" } },
508
683
  },
684
+ ...(e?.credentialReferences !== undefined
685
+ ? { credential_references: e.credentialReferences.map((r) => ({ name: String(r.name), level: r.level, reaches_worker_tools: r.reaches_worker_tools === true })) }
686
+ : {}),
509
687
  };
510
688
  }
511
689
  /** The summary input for this evidence. */
@@ -594,6 +772,18 @@ function epicCiChangeChoice(e) {
594
772
  effects: { approve: effect },
595
773
  };
596
774
  }
775
+ /**
776
+ * What choosing `include` means, by what is known. Never claims checks run or pass:
777
+ * confirmed coverage says a workflow is configured to start; otherwise it says plainly
778
+ * that none is confirmed, and whether an approved change would only propose one.
779
+ */
780
+ function includeConsequence(covers, delivered) {
781
+ if (covers)
782
+ return "Each child waits for the checks of a workflow configured to start on its epic-branch PR before it merges.";
783
+ return delivered
784
+ ? "Each child waits for the proposed checks only once you merge the approved change. Until then, no workflow is confirmed to run on epic-branch pull requests."
785
+ : "No workflow is confirmed to run on epic-branch pull requests, so there may be no checks for a child to wait for.";
786
+ }
597
787
  function epicBranchCiChoices(e) {
598
788
  const covers = e?.coverage === "covers";
599
789
  const recorded = e?.recordedDecision ?? null;
@@ -613,7 +803,7 @@ function epicBranchCiChoices(e) {
613
803
  {
614
804
  id: "include",
615
805
  label: "Include",
616
- consequence: "Each child waits for the checks that run on its epic-branch PR before it merges.",
806
+ consequence: includeConsequence(covers, false),
617
807
  },
618
808
  {
619
809
  id: "decline",
@@ -633,7 +823,7 @@ function epicBranchCiChoices(e) {
633
823
  // recommendation, never the earlier answer.
634
824
  ...(recorded !== null ? { earlier_answer: recorded } : {}),
635
825
  why_recommended: covers
636
- ? "A workflow runs on epic-branch PRs, so waiting for it catches problems before each merge."
826
+ ? "A workflow is configured to start on epic-branch PRs, so waiting for its checks catches problems before each merge."
637
827
  : stateText ?? "Bridge could not confirm a workflow runs on epic-branch PRs, so it recommends neither option; runs behave as include unless you decline.",
638
828
  consequential: false,
639
829
  applicable: e !== null,
@@ -645,6 +835,11 @@ function epicBranchCiChoices(e) {
645
835
  };
646
836
  const approvals = e?.approvalsRequired ?? null;
647
837
  const exemptionApplicable = approvals === "yes";
838
+ // Absent and unreadable are different facts, so they get different sentences. Neither
839
+ // changes an option, an effect, or a digest-bearing field.
840
+ const exemptionKeepSentence = approvals === "no"
841
+ ? "No approval rule applies to epic-branch pull requests."
842
+ : "The approval rule could not be read, so nothing will change; check it yourself.";
648
843
  const exemption = {
649
844
  id: "approval_exemption",
650
845
  family: "approval_exemption",
@@ -652,11 +847,11 @@ function epicBranchCiChoices(e) {
652
847
  current: approvals,
653
848
  options: exemptionApplicable
654
849
  ? approveDecline("Excludes epic/** from the approval rule with your own gh login. Only the ruleset's excluded branches change, and only for a ruleset that holds nothing but the approval rule.", "Changes nothing. Each child merge waits for a human approval unless the merging account can bypass the rule.")
655
- : [KEEP_OPTION("No approval rule needs changing for epic-branch PRs.")],
850
+ : [KEEP_OPTION(exemptionKeepSentence)],
656
851
  recommended: exemptionApplicable ? "decline" : "keep",
657
852
  why_recommended: exemptionApplicable
658
853
  ? "Changing a ruleset is consequential, so the safe default is to leave it and decide yourself."
659
- : "No approval rule applies to epic-branch PRs, or it could not be read, so nothing changes.",
854
+ : exemptionKeepSentence,
660
855
  consequential: true,
661
856
  applicable: exemptionApplicable,
662
857
  selection: "single",
@@ -699,7 +894,7 @@ export const RECOMMENDATION_POLICY = Object.freeze({
699
894
  never: Object.freeze(["decline"]),
700
895
  replacement: Object.freeze({
701
896
  option: "approve",
702
- why: "Runs are admitted only once a confirmed gate and the safe defaults are stored.",
897
+ why: "A run cannot start until a gate is saved, because the gate sets what must pass before a child merges.",
703
898
  }),
704
899
  }),
705
900
  approval_exemption: Object.freeze({
@@ -713,7 +908,7 @@ export const RECOMMENDATION_POLICY = Object.freeze({
713
908
  test_command: Object.freeze({
714
909
  lastResort: Object.freeze({
715
910
  option: "skip",
716
- why: "This is the last resort because no discovery-and-promotion trial can run for this gate, and Bridge recommends learning the command whenever that trial is available.",
911
+ why: "This is the last resort because there is no test command Bridge can try right now, and setup can still finish without one.",
717
912
  }),
718
913
  }),
719
914
  epic_branch_ci: Object.freeze({ lastResort: Object.freeze({ option: "decline", why: "This is the last resort because it lets each child merge without waiting for checks, and Bridge recommends it only when no other option can be offered." }), unresolvedOk: true }),
@@ -755,6 +950,188 @@ export function finalizeRecommendation(choice) {
755
950
  * The question each choice asks, in the owner's words. Keyed by answer key so
756
951
  * every choice has one. Display only: none of it reaches the digest.
757
952
  */
953
+ // ---------------------------------------------------------------------------
954
+ // BAPI-1678: merge-test protection, the proposal's wording, and the final verdict
955
+ // ---------------------------------------------------------------------------
956
+ /** The no-tests sentence. Exact wording: the skill and the lanes pin it. */
957
+ export const NO_TESTS_SENTENCE = "Bridge will not require a passing test run before a child merges.";
958
+ /** Named apart from the sentence when a trial that has not run yet is the only route to a test. */
959
+ export const TEST_TRIAL_CONDITION = "If the test-command trial does not pass:";
960
+ /** The next step when nothing is left to do. */
961
+ export const READY_NEXT_STEP = "Next step: Run /drive-epic-run for an epic.";
962
+ /**
963
+ * BAPI-1698 — the next step when everything a run needs is in place and only the
964
+ * test trial failed. The owner may start now; the warning names the consequence.
965
+ */
966
+ export const GUARDLESS_NEXT_STEP = "Next step: You can start an epic now (run /drive-epic-run for an epic). Until a test command has passed the " +
967
+ "trial run, epics run without a local test guard.";
968
+ /**
969
+ * The one rule for merge-test protection, used for both the proposal's planned value
970
+ * and the verdict's confirmed value. Returns `undefined` when the evidence does not
971
+ * settle it, and the field is then left out.
972
+ *
973
+ * - `local`: the gate is `local` or `mixed` and a command is stored. This wins over
974
+ * every CI fact, so unreadable CI does not hide it.
975
+ * - `ci`: `epic-implementer-ci / gate` is a stored check that is required, not watched.
976
+ * The managed workflow is installed, epic-branch CI is not declined, and the server
977
+ * reports an empty `no_ci_reasons`. All of these must hold. A workflow file, a check
978
+ * name, or an `include` answer alone is not proof of tests. Customer workflow
979
+ * contents are never parsed.
980
+ * - `watched_only` or `none`: only after enforced protection is confirmed absent. No
981
+ * required check remains, the gate and CI facts are readable, and the watched list
982
+ * is non-empty (`watched_only`) or empty (`none`). A declined managed check counts
983
+ * as absent, because declined CI means child merges do not wait for it.
984
+ * - `undefined`: an unreadable gate, command, or CI fact the answer depends on; a
985
+ * customer-owned required check, whose tests Bridge cannot know; or a managed check
986
+ * that is required but not proven. A required check that is missing holds a merge,
987
+ * so it does not prove that no test guards the merge. The managed workflow's state
988
+ * matters only while a required check depends on it, so reading it as unknown does
989
+ * not hide a confirmed absence. That read is unknown whenever no command is stored.
990
+ */
991
+ export function classifyMergeTestProtection(evidence) {
992
+ const { gate, localCommandStored, managedWorkflowInstalled, epicBranchCi } = evidence;
993
+ if (gate === null)
994
+ return undefined;
995
+ if (gate.kind === "local" || gate.kind === "mixed") {
996
+ if (localCommandStored === true)
997
+ return "local";
998
+ if (localCommandStored === null)
999
+ return undefined;
1000
+ }
1001
+ if (gate.requiredChecks.includes(EPIC_IMPLEMENTER_CI_CHECK_NAME) && !gate.watchedChecks.includes(EPIC_IMPLEMENTER_CI_CHECK_NAME)) {
1002
+ if (epicBranchCi === null)
1003
+ return undefined;
1004
+ if (epicBranchCi.decision !== "decline") {
1005
+ return managedWorkflowInstalled === true && epicBranchCi.noCiReasons.length === 0 ? "ci" : undefined;
1006
+ }
1007
+ }
1008
+ if (gate.requiredChecks.some((name) => name !== EPIC_IMPLEMENTER_CI_CHECK_NAME))
1009
+ return undefined;
1010
+ if (epicBranchCi === null)
1011
+ return undefined;
1012
+ return gate.watchedChecks.length > 0 ? "watched_only" : "none";
1013
+ }
1014
+ /** The shared consequence's own parts, unchanged. Joining them with "; " gives it back. */
1015
+ export function gateEffectLines(consequence) {
1016
+ return consequence === "" ? [] : consequence.split("; ");
1017
+ }
1018
+ /** The proposal's planned protection, its disclosure, and the gate's effect lines. Pure. */
1019
+ export function buildProposalPresentation(input) {
1020
+ const planned = classifyMergeTestProtection(input.evidence);
1021
+ const disclosed = planned === "none" || planned === "watched_only";
1022
+ return {
1023
+ ...(planned !== undefined ? { merge_test_protection: planned } : {}),
1024
+ ...(disclosed ? { disclosure: { text: NO_TESTS_SENTENCE, ...(input.trialPending ? { condition: TEST_TRIAL_CONDITION } : {}) } } : {}),
1025
+ gate_effect_lines: gateEffectLines(input.consequence),
1026
+ };
1027
+ }
1028
+ const SETTING_LABEL = Object.freeze({
1029
+ gate: "Merge gate",
1030
+ dependency_install: "Install commands",
1031
+ ci_database: "CI database",
1032
+ must_order_paths: "Ordered paths",
1033
+ worker_database: "Worker database",
1034
+ test_command: "Test command",
1035
+ setup_pr: "Setup pull request",
1036
+ merge_token: "Merge token",
1037
+ reindex: "Repository index",
1038
+ reindex_branch: "Index branch",
1039
+ reindex_retry: "Index retry",
1040
+ worker_mcp_grant: "Worker servers",
1041
+ epic_server: "Epic server",
1042
+ epic_branch_ci: "Epic-branch CI",
1043
+ approval_exemption: "Approval rule",
1044
+ launch_profile: "Launch profile",
1045
+ epic_ci_change: "Epic-branch CI change",
1046
+ setup_record: "Setup record",
1047
+ });
1048
+ const INCOMPLETE_STATUS = new Set(["failed", "refused", "uncertain", "unattempted"]);
1049
+ const FALLBACK_REASON = Object.freeze({
1050
+ failed: "the write failed",
1051
+ refused: "the write was refused",
1052
+ uncertain: "the write could not be confirmed",
1053
+ unattempted: "the write was not attempted",
1054
+ });
1055
+ function oneLine(text) {
1056
+ return text.replace(/\s+/g, " ").trim();
1057
+ }
1058
+ function asSentence(text) {
1059
+ const line = oneLine(text);
1060
+ return /[.!?]$/.test(line) ? line : `${line}.`;
1061
+ }
1062
+ function asNextStep(fix) {
1063
+ const line = oneLine(fix);
1064
+ return line.startsWith("Next step:") ? line : `Next step: ${line}`;
1065
+ }
1066
+ /**
1067
+ * The final verdict, from post-apply evidence. Pure.
1068
+ *
1069
+ * `ready` says whether a run can start, and comes only from the readiness evidence.
1070
+ * `settings_not_applied` says what the owner approved that did not take. The two stay
1071
+ * apart, so a failed optional setting never turns a confirmed `Ready` into a failure.
1072
+ * A missing fix uses the read-only doctor check, and with no fix at all an unconfirmed
1073
+ * verdict names that check too instead of recommending a run.
1074
+ */
1075
+ export function buildInstallVerdict(input) {
1076
+ const { ready, blockers, results, protection } = input;
1077
+ const settings = results
1078
+ .filter((r) => INCOMPLETE_STATUS.has(r.status))
1079
+ .map((r) => ({
1080
+ key: r.key,
1081
+ status: r.status,
1082
+ reason: r.reason ?? FALLBACK_REASON[r.status] ?? "the write did not finish",
1083
+ fix: r.fix ?? READINESS_PREREQUISITE_FIXES.doctor,
1084
+ }));
1085
+ const rule = results.find((r) => r.key === "approval_exemption");
1086
+ const approvalRule = rule === undefined
1087
+ ? undefined
1088
+ : { status: rule.status, ...(rule.reason !== undefined ? { reason: rule.reason } : {}) };
1089
+ const ruleText = approvalRule === undefined
1090
+ ? null
1091
+ : approvalRule.reason !== undefined ? `${approvalRule.status} — ${approvalRule.reason}` : approvalRule.status;
1092
+ const parts = [];
1093
+ if (ready === true)
1094
+ parts.push("Ready.");
1095
+ else if (ready === false)
1096
+ parts.push(blockers.length > 0 ? `Not ready. Still blocking: ${blockers.map((b) => oneLine(b.label)).join(", ")}.` : "Not ready.");
1097
+ else
1098
+ parts.push("Readiness was not confirmed.");
1099
+ const others = settings.filter((s) => s.key !== "approval_exemption");
1100
+ if (others.length > 0) {
1101
+ parts.push("These settings did not take:");
1102
+ for (const s of others)
1103
+ parts.push(`${SETTING_LABEL[s.key]}: ${asSentence(s.reason)} Fix: ${asSentence(s.fix)}`);
1104
+ }
1105
+ if (ruleText !== null) {
1106
+ const ruleFix = settings.find((s) => s.key === "approval_exemption")?.fix;
1107
+ parts.push(`${SETTING_LABEL.approval_exemption}: ${asSentence(ruleText)}${ruleFix !== undefined ? ` Fix: ${asSentence(ruleFix)}` : ""}`);
1108
+ }
1109
+ if (protection === "none" || protection === "watched_only")
1110
+ parts.push(NO_TESTS_SENTENCE);
1111
+ // BAPI-1701: the gate's own fix leads, so an optional setting's generic rerun cannot hide why no gate was stored.
1112
+ const firstFix = (settings.find((s) => s.key === "gate") ?? settings[0])?.fix ?? blockers[0]?.fix;
1113
+ // BAPI-1698: when the ONLY setting that did not take is a completed test trial that
1114
+ // failed, and nothing blocks a run, the owner can start an epic now. Say so, with
1115
+ // the consequence, instead of sending them back to setup.
1116
+ const trialResult = results.find((r) => r.key === "test_command");
1117
+ const onlyFailedTrial = ready === true &&
1118
+ blockers.length === 0 &&
1119
+ settings.length === 1 &&
1120
+ settings[0].key === "test_command" &&
1121
+ trialResult?.status === "failed" &&
1122
+ typeof trialResult.phase === "string";
1123
+ const nextStep = onlyFailedTrial
1124
+ ? GUARDLESS_NEXT_STEP
1125
+ : firstFix !== undefined
1126
+ ? asNextStep(firstFix)
1127
+ : ready === true ? READY_NEXT_STEP : asNextStep(READINESS_PREREQUISITE_FIXES.doctor);
1128
+ return {
1129
+ line: parts.join(" "),
1130
+ settings_not_applied: settings,
1131
+ ...(approvalRule !== undefined ? { approval_rule: approvalRule } : {}),
1132
+ next_step: nextStep,
1133
+ };
1134
+ }
758
1135
  const CHOICE_QUESTION = Object.freeze({
759
1136
  gate: "Should setup save the checks each piece of epic work must pass before it can merge?",
760
1137
  dependency_install: "Should workers refresh the project's dependencies, using the steps setup found, before each piece of work?",
@@ -779,6 +1156,29 @@ function withQuestion(c) {
779
1156
  const { id, family, answer_key, ...rest } = c;
780
1157
  return { id, family, answer_key, question: CHOICE_QUESTION[answer_key], ...rest };
781
1158
  }
1159
+ /** What the settled answers say will deliver checks on epic-branch pull requests. */
1160
+ function epicBranchCiDelivery(choices, settled, context) {
1161
+ const picked = (key) => {
1162
+ const c = choiceFor(choices, key);
1163
+ if (c === undefined || !c.applicable)
1164
+ return undefined;
1165
+ return settled(key) ?? (typeof c.recommended === "string" ? c.recommended : undefined);
1166
+ };
1167
+ return {
1168
+ covers: choiceFor(choices, "epic_branch_ci")?.current === "covers",
1169
+ ciApproved: picked("epic_ci_change") === "approve",
1170
+ setupApproved: context.setupSuppliesWorkflow && picked("setup_pr") === "approve",
1171
+ };
1172
+ }
1173
+ /**
1174
+ * BAPI-1679 — true when the setup pull request is the only thing behind a recommended `include`.
1175
+ * The setup pull request opens only if the test trial passes, so at apply time this credit still
1176
+ * has to be proven. Confirmed coverage and an approved CI change do not depend on it.
1177
+ */
1178
+ export function epicBranchCiIncludeRestsOnSetupPr(choices, settled, context) {
1179
+ const { covers, ciApproved, setupApproved } = epicBranchCiDelivery(choices, settled, context);
1180
+ return setupApproved && !covers && !ciApproved;
1181
+ }
782
1182
  /**
783
1183
  * BAPI-1659 — the one answer-aware place where `epic_branch_ci` is recommended.
784
1184
  *
@@ -794,29 +1194,47 @@ export function resolveEpicBranchCiRecommendation(choices, settled, context = {
794
1194
  const ci = choiceFor(choices, "epic_branch_ci");
795
1195
  if (ci === undefined || ci.recommended === null || typeof ci.recommended !== "string")
796
1196
  return [...choices];
797
- const picked = (key) => {
798
- const c = choiceFor(choices, key);
799
- if (c === undefined || !c.applicable)
800
- return undefined;
801
- return settled(key) ?? (typeof c.recommended === "string" ? c.recommended : undefined);
802
- };
803
- const covers = ci.current === "covers";
804
- const ciApproved = picked("epic_ci_change") === "approve";
805
- const setupApproved = context.setupSuppliesWorkflow && picked("setup_pr") === "approve";
1197
+ const { covers, ciApproved, setupApproved } = epicBranchCiDelivery(choices, settled, context);
806
1198
  const delivered = ciApproved || setupApproved;
807
1199
  const target = covers || delivered ? "include" : "decline";
1200
+ // The include option always reads from the final answers; an explicit `include` is never
1201
+ // reworded into a claim that checks run.
1202
+ const options = ci.options.map((o) => (o.id === "include" ? { ...o, consequence: includeConsequence(covers, delivered) } : o));
1203
+ const withOptions = { ...ci, options };
1204
+ const replaceCi = (next) => choices.map((c) => (c.answer_key === "epic_branch_ci" ? next : c));
808
1205
  if (target === ci.recommended)
809
- return [...choices];
810
- const next = target === "include"
811
- ? {
812
- ...ci,
1206
+ return replaceCi(withOptions);
1207
+ if (target === "include") {
1208
+ // Delivered but not yet merged: say the checks are proposed and not running. The offer-state
1209
+ // sentence ("would fix that") is not reused. Only the unsupported-CI-systems sentence is kept.
1210
+ const unsupported = /This repository (?:also )?uses [^.]*\. Bridge can't safely change [^.]*\./.exec(context.stateText ?? "")?.[0];
1211
+ const next = {
1212
+ ...withOptions,
813
1213
  recommended: "include",
814
- why_recommended: context.stateText !== undefined && context.stateText !== null && context.stateText.length > 0
815
- ? `${context.stateText} Including lets each child wait for those checks once the change is merged.`
816
- : "Checks are proposed, not running yet: the pull request you approve adds them, and each child waits for them only once you merge it.",
817
- }
818
- : { ...ci, recommended: "decline" };
819
- return choices.map((c) => (c.answer_key === "epic_branch_ci" ? finalizeRecommendation(next) : c));
1214
+ why_recommended: [
1215
+ "Checks are proposed, not running yet: the pull request you approve adds them.",
1216
+ // A one-line trigger edit leaves the workflow as it is until merged, so say what children do meanwhile.
1217
+ // Bridge's own new workflow is described only as proposed.
1218
+ choiceFor(choices, "epic_ci_change")?.current === "trigger_edit"
1219
+ ? "Until you merge it, child pull requests merge into the epic branch without checks, and each child waits for them only once the change is merged."
1220
+ : "Each child waits for them only once you merge it.",
1221
+ ...(unsupported !== undefined ? [unsupported] : []),
1222
+ ].join(" "),
1223
+ };
1224
+ return replaceCi(finalizeRecommendation(next));
1225
+ }
1226
+ // Decline: the draft's reason described a delivery the final answers no longer approve. Finalize
1227
+ // first, then set the reason, so the generic last-resort sentence cannot replace it.
1228
+ const declined = finalizeRecommendation({ ...withOptions, recommended: "decline" });
1229
+ // BAPI-1701: when the setup pull request is the only way Bridge's workflow arrives and it is not approved,
1230
+ // say what declining leaves out. Anything another approved action supplies is never described as absent.
1231
+ const setupIsSolePath = context.setupSuppliesWorkflow && !setupApproved && !ciApproved && !covers;
1232
+ return replaceCi({
1233
+ ...declined,
1234
+ why_recommended: setupIsSolePath
1235
+ ? `Declining the setup pull request does not add ${EPIC_IMPLEMENTER_CI_CHECK_NAME} as a required check, and no CI change is approved, so child pull requests merge into the epic branch without that check.`
1236
+ : "No workflow is confirmed to run on pull requests into epic branches and no CI change is approved, so child pull requests merge into the epic branch without checks.",
1237
+ });
820
1238
  }
821
1239
  /** Build the full choice catalog. Every family appears, applicable or not. */
822
1240
  export function buildInstallChoices(d) {
@@ -867,6 +1285,17 @@ function projectFacts(facts) {
867
1285
  ...(facts.ci_systems !== undefined
868
1286
  ? { ci_systems: facts.ci_systems === null ? null : facts.ci_systems.map((c) => ({ name: String(c.name), path: String(c.path) })) }
869
1287
  : {}),
1288
+ // BAPI-1667: additive, and only when detection ran.
1289
+ ...(facts.sfcc !== undefined
1290
+ ? {
1291
+ sfcc: {
1292
+ detected: facts.sfcc.detected,
1293
+ signals: [...facts.sfcc.signals],
1294
+ dev_script: facts.sfcc.dev_script,
1295
+ upload_check: facts.sfcc.upload_check === null ? null : { state: facts.sfcc.upload_check.state, missing: [...facts.sfcc.upload_check.missing] },
1296
+ },
1297
+ }
1298
+ : {}),
870
1299
  };
871
1300
  }
872
1301
  /** The choice for a key, or undefined. */