@bridge_gpt/mcp-server 0.2.73 → 0.2.74
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.
- package/README.md +5 -5
- package/build/agent-launchers/claude-executor-adapter.js +12 -0
- package/build/agents.generated.js +3 -3
- package/build/bridge-config.js +7 -1
- package/build/bridge-permissions.js +3 -0
- package/build/command-provisioning.js +4 -3
- package/build/commands.generated.js +5 -5
- package/build/conductor/bridge-api-client.js +26 -1
- package/build/conductor/command-drift.js +1 -1
- package/build/conductor/declared-extras.js +335 -0
- package/build/conductor/doctor.js +2 -0
- package/build/conductor/driver-pass-output.js +104 -0
- package/build/conductor/driver-pass.js +571 -0
- package/build/conductor/epic-branch-ci-inspection.js +61 -16
- package/build/conductor/epic-implementer-cli.js +33 -0
- package/build/conductor/epic-server-sfcc-upload.js +1567 -0
- package/build/conductor/epic-server-sfcc.js +58 -80
- package/build/conductor/epic-server.js +57 -4
- package/build/conductor/gate-discovery.js +46 -6
- package/build/conductor/gate-settings-review.js +51 -14
- package/build/credential-delivery.js +280 -0
- package/build/credential-launch-safety.js +142 -0
- package/build/credential-materialization.js +91 -16
- package/build/credential-references-node-deps.js +29 -0
- package/build/credential-references.js +1394 -0
- package/build/credential-references.test-fixtures.js +211 -0
- package/build/credential-scan-conventions.js +145 -0
- package/build/credential-scan.js +517 -0
- package/build/credential-store.js +50 -0
- package/build/credentials-cli.js +252 -3
- package/build/dependency-install-declarations.js +47 -1
- package/build/docs.generated.js +8 -1
- package/build/doctor.js +41 -0
- package/build/drive-epic.js +297 -37
- package/build/epic-branch-ci-summary.js +18 -1
- package/build/epic-capability-statement.js +71 -3
- package/build/epic-ci-workflow-drift.js +52 -13
- package/build/epic-ci-workflow-install.js +31 -6
- package/build/epic-ci-workflow-v3.js +273 -0
- package/build/epic-ci-workflow.js +128 -7
- package/build/epic-implementer-bin.js +161 -70
- package/build/epic-launch-context.js +102 -7
- package/build/epic-server-record.js +30 -15
- package/build/executor/credential-delivery-step.js +168 -0
- package/build/executor/deps.js +3 -1
- package/build/executor/env.js +39 -1
- package/build/executor/epic-server-context.js +23 -7
- package/build/executor/guarded-fast-forward-push.js +13 -8
- package/build/executor/job-runner.js +159 -17
- package/build/executor/permissions.js +85 -3
- package/build/executor/prompt-spec.js +37 -3
- package/build/executor-launch.js +4 -2
- package/build/git-exclude-lock.js +187 -0
- package/build/index.js +398 -269
- package/build/install-bridge-conductor-answers.js +84 -21
- package/build/install-bridge-conductor-apply.js +30 -1
- package/build/install-bridge-conductor-assessment.js +375 -48
- package/build/install-bridge-conductor-compact.js +27 -2
- package/build/install-bridge-conductor-contracts.js +10 -1
- package/build/install-bridge-conductor-gate.js +124 -11
- package/build/install-bridge-conductor-setup.js +46 -8
- package/build/install-bridge-conductor.js +625 -113
- package/build/install-bridge.js +88 -11
- package/build/install-doctor.js +38 -8
- package/build/install-sfcc-detection.js +120 -0
- package/build/install-sfcc-setup.js +185 -0
- package/build/mcp-grant-candidates.js +108 -96
- package/build/mcp-invoke.js +168 -4
- package/build/mcp-provisioning.js +21 -4
- package/build/mcp-server-invocation.js +13 -0
- package/build/merge-workflow-install.js +9 -1
- package/build/pipelines.generated.js +2 -1
- package/build/plane/status.js +8 -2
- package/build/printed-remedy-commands.js +5 -0
- package/build/project-root.js +40 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +5 -2
- package/build/repository-toolchains.js +6 -3
- package/build/setup-epic.js +116 -15
- package/build/sfcc/credentials.js +3 -2
- package/build/sfcc/hostname.js +98 -2
- package/build/sfcc/tool-wrapper.js +6 -95
- package/build/start-tickets.js +193 -29
- package/build/test-support/executor-source-files.js +200 -0
- package/build/testing-config-client.js +25 -2
- package/build/third-party-mcp-targets.js +35 -4
- package/build/version.generated.js +3 -3
- package/build/with-credentials.js +208 -0
- package/build/worktree-credential-delivery.js +340 -0
- package/package.json +1 -1
|
@@ -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
|
|
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: "
|
|
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,54 @@ 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(
|
|
153
|
-
|
|
154
|
-
|
|
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
|
+
return {
|
|
242
|
+
commands: input.commands.map(row),
|
|
243
|
+
...(input.differs ? { stored: input.stored.map(row) } : {}),
|
|
244
|
+
evidence: input.evidence.map((e) => ({ extra: displayArg(e.extra), field: e.field, span: displayArg(e.span) })),
|
|
245
|
+
lifecycle: "Each command runs in every fresh worker worktree, and again only when a file it names changes.",
|
|
246
|
+
limitations: input.limitations.map(displayArg),
|
|
247
|
+
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
248
|
};
|
|
160
249
|
}
|
|
161
250
|
/** The bounded discovery-and-promotion trial: the server tries learned candidates and stores one only if it passes. */
|
|
@@ -167,11 +256,14 @@ export const LEARN_EFFECT = Object.freeze({
|
|
|
167
256
|
});
|
|
168
257
|
function testCommandChoice(t) {
|
|
169
258
|
const options = [];
|
|
259
|
+
const candidate = t.candidate !== undefined && t.candidate !== null ? displayArg(t.candidate) : null;
|
|
170
260
|
if (t.trialEligible) {
|
|
171
261
|
options.push({
|
|
172
262
|
id: "learn",
|
|
173
|
-
label: "Let Bridge learn and prove the test command",
|
|
174
|
-
consequence:
|
|
263
|
+
label: candidate !== null ? `Let Bridge learn and prove the test command (it expects to try ${candidate})` : "Let Bridge learn and prove the test command",
|
|
264
|
+
consequence: (candidate !== null ? `Bridge expects to try ${candidate} first. ` : "") +
|
|
265
|
+
"Learning stores instructions, not a proven command, so they guide the attempt and the server may choose another command. " +
|
|
266
|
+
"It runs one bounded trial and stores a command only if the check passes.",
|
|
175
267
|
});
|
|
176
268
|
}
|
|
177
269
|
options.push(t.stored
|
|
@@ -188,7 +280,7 @@ function testCommandChoice(t) {
|
|
|
188
280
|
? "A learned command is stored only after the server proves it passes, so it cannot weaken the gate."
|
|
189
281
|
: t.stored
|
|
190
282
|
? "A command is already stored and proven, so nothing changes."
|
|
191
|
-
: "
|
|
283
|
+
: "There is no test command Bridge can try right now, and setup can still finish without one.",
|
|
192
284
|
consequential: false,
|
|
193
285
|
applicable: t.trialEligible || t.ownerCommandSupplied,
|
|
194
286
|
selection: "single",
|
|
@@ -440,16 +532,19 @@ function mcpGrantChoice(g) {
|
|
|
440
532
|
// A settled grant is kept when its key is left out; only an open grant recommends the empty selection.
|
|
441
533
|
if (!g.applicable)
|
|
442
534
|
options.unshift(KEEP_OPTION("Workers keep exactly the MCP servers already approved."));
|
|
535
|
+
const sfccGrant = g.applicable ? recommendMcpGrant(g) : [];
|
|
443
536
|
return {
|
|
444
537
|
id: "worker_mcp_grant",
|
|
445
538
|
family: "worker_mcp_grant",
|
|
446
539
|
answer_key: "worker_mcp_grant",
|
|
447
540
|
current: g.current,
|
|
448
541
|
options,
|
|
449
|
-
recommended: g.applicable ?
|
|
450
|
-
why_recommended:
|
|
451
|
-
? "
|
|
452
|
-
:
|
|
542
|
+
recommended: g.applicable ? sfccGrant : "keep",
|
|
543
|
+
why_recommended: sfccGrant.length > 0
|
|
544
|
+
? "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."
|
|
545
|
+
: g.applicable
|
|
546
|
+
? "Workers always get Bridge; each extra server is a deliberate grant, so setup recommends none and you add only what you need."
|
|
547
|
+
: "The approved servers still match what this repository offers, so nothing changes.",
|
|
453
548
|
consequential: true,
|
|
454
549
|
applicable: g.applicable,
|
|
455
550
|
selection: "multiple",
|
|
@@ -460,23 +555,28 @@ function mcpGrantChoice(g) {
|
|
|
460
555
|
invalid_existing: g.invalidExisting.map(excludedEntry),
|
|
461
556
|
};
|
|
462
557
|
}
|
|
558
|
+
/** BAPI-1667 — an SFCC repository whose check did not run says so, the same as one that could not. */
|
|
559
|
+
const UPLOAD_CHECK_NOT_RUN = Object.freeze({ state: "unknown", missing: [] });
|
|
463
560
|
function epicServerChoice(e) {
|
|
464
561
|
const current = e?.current ?? null;
|
|
562
|
+
// BAPI-1667: fixed additions only when SFCC or a recorded sandbox applies; otherwise the text is unchanged.
|
|
563
|
+
const uploadText = e?.sfcc?.detected === true ? describeSfccUpload(e.sfcc.uploadCheck ?? UPLOAD_CHECK_NOT_RUN) : "";
|
|
564
|
+
const keptSandbox = e?.sandboxRecorded === true ? " The approved sandbox stays recorded, so uploads stay on." : "";
|
|
465
565
|
const options = [
|
|
466
566
|
{
|
|
467
567
|
id: "none",
|
|
468
568
|
label: "No epic server",
|
|
469
|
-
consequence:
|
|
569
|
+
consequence: `Runs start no epic server; UI checks are handed off to a person.${keptSandbox}`,
|
|
470
570
|
},
|
|
471
571
|
{
|
|
472
572
|
id: "local",
|
|
473
573
|
label: "A local epic server",
|
|
474
|
-
consequence:
|
|
574
|
+
consequence: `The driver starts the epic's code with a throwaway test login, and workers borrow it in turns for UI checks.${keptSandbox}`,
|
|
475
575
|
},
|
|
476
576
|
{
|
|
477
577
|
id: "sfcc_shared_active",
|
|
478
578
|
label: "One approved SFCC sandbox",
|
|
479
|
-
consequence:
|
|
579
|
+
consequence: `Workers use the approved sandbox. Its account secret stays in the credential store; only its reference is stored.${uploadText !== "" ? ` ${uploadText}` : ""}`,
|
|
480
580
|
},
|
|
481
581
|
];
|
|
482
582
|
const applicable = e?.applicable ?? false;
|
|
@@ -486,18 +586,15 @@ function epicServerChoice(e) {
|
|
|
486
586
|
options.unshift(KEEP_OPTION(`The stored choice (${current}) stays as it is.`));
|
|
487
587
|
else
|
|
488
588
|
options.unshift(KEEP_OPTION("Nothing is written; the epic-server record stays as it is."));
|
|
589
|
+
const recommendation = recommendEpicServer(e);
|
|
489
590
|
return {
|
|
490
591
|
id: "epic_server",
|
|
491
592
|
family: "epic_server",
|
|
492
593
|
answer_key: "epic_server",
|
|
493
594
|
current,
|
|
494
595
|
options,
|
|
495
|
-
recommended:
|
|
496
|
-
why_recommended:
|
|
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.",
|
|
596
|
+
recommended: recommendation.recommended,
|
|
597
|
+
why_recommended: recommendation.why,
|
|
501
598
|
consequential: true,
|
|
502
599
|
applicable,
|
|
503
600
|
selection: "single",
|
|
@@ -506,6 +603,9 @@ function epicServerChoice(e) {
|
|
|
506
603
|
local: { action: "write_epic_server_record", target: "epic_server_record", params: { mode: "local" } },
|
|
507
604
|
sfcc_shared_active: { action: "write_epic_server_record", target: "epic_server_record", params: { mode: "sfcc_shared_active" } },
|
|
508
605
|
},
|
|
606
|
+
...(e?.credentialReferences !== undefined
|
|
607
|
+
? { credential_references: e.credentialReferences.map((r) => ({ name: String(r.name), level: r.level, reaches_worker_tools: r.reaches_worker_tools === true })) }
|
|
608
|
+
: {}),
|
|
509
609
|
};
|
|
510
610
|
}
|
|
511
611
|
/** The summary input for this evidence. */
|
|
@@ -594,6 +694,18 @@ function epicCiChangeChoice(e) {
|
|
|
594
694
|
effects: { approve: effect },
|
|
595
695
|
};
|
|
596
696
|
}
|
|
697
|
+
/**
|
|
698
|
+
* What choosing `include` means, by what is known. Never claims checks run or pass:
|
|
699
|
+
* confirmed coverage says a workflow is configured to start; otherwise it says plainly
|
|
700
|
+
* that none is confirmed, and whether an approved change would only propose one.
|
|
701
|
+
*/
|
|
702
|
+
function includeConsequence(covers, delivered) {
|
|
703
|
+
if (covers)
|
|
704
|
+
return "Each child waits for the checks of a workflow configured to start on its epic-branch PR before it merges.";
|
|
705
|
+
return delivered
|
|
706
|
+
? "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."
|
|
707
|
+
: "No workflow is confirmed to run on epic-branch pull requests, so there may be no checks for a child to wait for.";
|
|
708
|
+
}
|
|
597
709
|
function epicBranchCiChoices(e) {
|
|
598
710
|
const covers = e?.coverage === "covers";
|
|
599
711
|
const recorded = e?.recordedDecision ?? null;
|
|
@@ -613,7 +725,7 @@ function epicBranchCiChoices(e) {
|
|
|
613
725
|
{
|
|
614
726
|
id: "include",
|
|
615
727
|
label: "Include",
|
|
616
|
-
consequence:
|
|
728
|
+
consequence: includeConsequence(covers, false),
|
|
617
729
|
},
|
|
618
730
|
{
|
|
619
731
|
id: "decline",
|
|
@@ -633,7 +745,7 @@ function epicBranchCiChoices(e) {
|
|
|
633
745
|
// recommendation, never the earlier answer.
|
|
634
746
|
...(recorded !== null ? { earlier_answer: recorded } : {}),
|
|
635
747
|
why_recommended: covers
|
|
636
|
-
? "A workflow
|
|
748
|
+
? "A workflow is configured to start on epic-branch PRs, so waiting for its checks catches problems before each merge."
|
|
637
749
|
: 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
750
|
consequential: false,
|
|
639
751
|
applicable: e !== null,
|
|
@@ -645,6 +757,11 @@ function epicBranchCiChoices(e) {
|
|
|
645
757
|
};
|
|
646
758
|
const approvals = e?.approvalsRequired ?? null;
|
|
647
759
|
const exemptionApplicable = approvals === "yes";
|
|
760
|
+
// Absent and unreadable are different facts, so they get different sentences. Neither
|
|
761
|
+
// changes an option, an effect, or a digest-bearing field.
|
|
762
|
+
const exemptionKeepSentence = approvals === "no"
|
|
763
|
+
? "No approval rule applies to epic-branch pull requests."
|
|
764
|
+
: "The approval rule could not be read, so nothing will change; check it yourself.";
|
|
648
765
|
const exemption = {
|
|
649
766
|
id: "approval_exemption",
|
|
650
767
|
family: "approval_exemption",
|
|
@@ -652,11 +769,11 @@ function epicBranchCiChoices(e) {
|
|
|
652
769
|
current: approvals,
|
|
653
770
|
options: exemptionApplicable
|
|
654
771
|
? 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(
|
|
772
|
+
: [KEEP_OPTION(exemptionKeepSentence)],
|
|
656
773
|
recommended: exemptionApplicable ? "decline" : "keep",
|
|
657
774
|
why_recommended: exemptionApplicable
|
|
658
775
|
? "Changing a ruleset is consequential, so the safe default is to leave it and decide yourself."
|
|
659
|
-
:
|
|
776
|
+
: exemptionKeepSentence,
|
|
660
777
|
consequential: true,
|
|
661
778
|
applicable: exemptionApplicable,
|
|
662
779
|
selection: "single",
|
|
@@ -699,7 +816,7 @@ export const RECOMMENDATION_POLICY = Object.freeze({
|
|
|
699
816
|
never: Object.freeze(["decline"]),
|
|
700
817
|
replacement: Object.freeze({
|
|
701
818
|
option: "approve",
|
|
702
|
-
why: "
|
|
819
|
+
why: "A run cannot start until a gate is saved, because the gate sets what must pass before a child merges.",
|
|
703
820
|
}),
|
|
704
821
|
}),
|
|
705
822
|
approval_exemption: Object.freeze({
|
|
@@ -713,7 +830,7 @@ export const RECOMMENDATION_POLICY = Object.freeze({
|
|
|
713
830
|
test_command: Object.freeze({
|
|
714
831
|
lastResort: Object.freeze({
|
|
715
832
|
option: "skip",
|
|
716
|
-
why: "This is the last resort because no
|
|
833
|
+
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
834
|
}),
|
|
718
835
|
}),
|
|
719
836
|
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 +872,169 @@ export function finalizeRecommendation(choice) {
|
|
|
755
872
|
* The question each choice asks, in the owner's words. Keyed by answer key so
|
|
756
873
|
* every choice has one. Display only: none of it reaches the digest.
|
|
757
874
|
*/
|
|
875
|
+
// ---------------------------------------------------------------------------
|
|
876
|
+
// BAPI-1678: merge-test protection, the proposal's wording, and the final verdict
|
|
877
|
+
// ---------------------------------------------------------------------------
|
|
878
|
+
/** The no-tests sentence. Exact wording: the skill and the lanes pin it. */
|
|
879
|
+
export const NO_TESTS_SENTENCE = "Bridge will not require a passing test run before a child merges.";
|
|
880
|
+
/** Named apart from the sentence when a trial that has not run yet is the only route to a test. */
|
|
881
|
+
export const TEST_TRIAL_CONDITION = "If the test-command trial does not pass:";
|
|
882
|
+
/** The next step when nothing is left to do. */
|
|
883
|
+
export const READY_NEXT_STEP = "Next step: Run /drive-epic-run for an epic.";
|
|
884
|
+
/**
|
|
885
|
+
* The one rule for merge-test protection, used for both the proposal's planned value
|
|
886
|
+
* and the verdict's confirmed value. Returns `undefined` when the evidence does not
|
|
887
|
+
* settle it, and the field is then left out.
|
|
888
|
+
*
|
|
889
|
+
* - `local`: the gate is `local` or `mixed` and a command is stored. This wins over
|
|
890
|
+
* every CI fact, so unreadable CI does not hide it.
|
|
891
|
+
* - `ci`: `epic-implementer-ci / gate` is a stored check that is required, not watched.
|
|
892
|
+
* The managed workflow is installed, epic-branch CI is not declined, and the server
|
|
893
|
+
* reports an empty `no_ci_reasons`. All of these must hold. A workflow file, a check
|
|
894
|
+
* name, or an `include` answer alone is not proof of tests. Customer workflow
|
|
895
|
+
* contents are never parsed.
|
|
896
|
+
* - `watched_only` or `none`: only after enforced protection is confirmed absent. No
|
|
897
|
+
* required check remains, the gate and CI facts are readable, and the watched list
|
|
898
|
+
* is non-empty (`watched_only`) or empty (`none`). A declined managed check counts
|
|
899
|
+
* as absent, because declined CI means child merges do not wait for it.
|
|
900
|
+
* - `undefined`: an unreadable gate, command, or CI fact the answer depends on; a
|
|
901
|
+
* customer-owned required check, whose tests Bridge cannot know; or a managed check
|
|
902
|
+
* that is required but not proven. A required check that is missing holds a merge,
|
|
903
|
+
* so it does not prove that no test guards the merge. The managed workflow's state
|
|
904
|
+
* matters only while a required check depends on it, so reading it as unknown does
|
|
905
|
+
* not hide a confirmed absence. That read is unknown whenever no command is stored.
|
|
906
|
+
*/
|
|
907
|
+
export function classifyMergeTestProtection(evidence) {
|
|
908
|
+
const { gate, localCommandStored, managedWorkflowInstalled, epicBranchCi } = evidence;
|
|
909
|
+
if (gate === null)
|
|
910
|
+
return undefined;
|
|
911
|
+
if (gate.kind === "local" || gate.kind === "mixed") {
|
|
912
|
+
if (localCommandStored === true)
|
|
913
|
+
return "local";
|
|
914
|
+
if (localCommandStored === null)
|
|
915
|
+
return undefined;
|
|
916
|
+
}
|
|
917
|
+
if (gate.requiredChecks.includes(EPIC_IMPLEMENTER_CI_CHECK_NAME) && !gate.watchedChecks.includes(EPIC_IMPLEMENTER_CI_CHECK_NAME)) {
|
|
918
|
+
if (epicBranchCi === null)
|
|
919
|
+
return undefined;
|
|
920
|
+
if (epicBranchCi.decision !== "decline") {
|
|
921
|
+
return managedWorkflowInstalled === true && epicBranchCi.noCiReasons.length === 0 ? "ci" : undefined;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
if (gate.requiredChecks.some((name) => name !== EPIC_IMPLEMENTER_CI_CHECK_NAME))
|
|
925
|
+
return undefined;
|
|
926
|
+
if (epicBranchCi === null)
|
|
927
|
+
return undefined;
|
|
928
|
+
return gate.watchedChecks.length > 0 ? "watched_only" : "none";
|
|
929
|
+
}
|
|
930
|
+
/** The shared consequence's own parts, unchanged. Joining them with "; " gives it back. */
|
|
931
|
+
export function gateEffectLines(consequence) {
|
|
932
|
+
return consequence === "" ? [] : consequence.split("; ");
|
|
933
|
+
}
|
|
934
|
+
/** The proposal's planned protection, its disclosure, and the gate's effect lines. Pure. */
|
|
935
|
+
export function buildProposalPresentation(input) {
|
|
936
|
+
const planned = classifyMergeTestProtection(input.evidence);
|
|
937
|
+
const disclosed = planned === "none" || planned === "watched_only";
|
|
938
|
+
return {
|
|
939
|
+
...(planned !== undefined ? { merge_test_protection: planned } : {}),
|
|
940
|
+
...(disclosed ? { disclosure: { text: NO_TESTS_SENTENCE, ...(input.trialPending ? { condition: TEST_TRIAL_CONDITION } : {}) } } : {}),
|
|
941
|
+
gate_effect_lines: gateEffectLines(input.consequence),
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
const SETTING_LABEL = Object.freeze({
|
|
945
|
+
gate: "Merge gate",
|
|
946
|
+
dependency_install: "Install commands",
|
|
947
|
+
ci_database: "CI database",
|
|
948
|
+
must_order_paths: "Ordered paths",
|
|
949
|
+
worker_database: "Worker database",
|
|
950
|
+
test_command: "Test command",
|
|
951
|
+
setup_pr: "Setup pull request",
|
|
952
|
+
merge_token: "Merge token",
|
|
953
|
+
reindex: "Repository index",
|
|
954
|
+
reindex_branch: "Index branch",
|
|
955
|
+
reindex_retry: "Index retry",
|
|
956
|
+
worker_mcp_grant: "Worker servers",
|
|
957
|
+
epic_server: "Epic server",
|
|
958
|
+
epic_branch_ci: "Epic-branch CI",
|
|
959
|
+
approval_exemption: "Approval rule",
|
|
960
|
+
launch_profile: "Launch profile",
|
|
961
|
+
epic_ci_change: "Epic-branch CI change",
|
|
962
|
+
setup_record: "Setup record",
|
|
963
|
+
});
|
|
964
|
+
const INCOMPLETE_STATUS = new Set(["failed", "refused", "uncertain", "unattempted"]);
|
|
965
|
+
const FALLBACK_REASON = Object.freeze({
|
|
966
|
+
failed: "the write failed",
|
|
967
|
+
refused: "the write was refused",
|
|
968
|
+
uncertain: "the write could not be confirmed",
|
|
969
|
+
unattempted: "the write was not attempted",
|
|
970
|
+
});
|
|
971
|
+
function oneLine(text) {
|
|
972
|
+
return text.replace(/\s+/g, " ").trim();
|
|
973
|
+
}
|
|
974
|
+
function asSentence(text) {
|
|
975
|
+
const line = oneLine(text);
|
|
976
|
+
return /[.!?]$/.test(line) ? line : `${line}.`;
|
|
977
|
+
}
|
|
978
|
+
function asNextStep(fix) {
|
|
979
|
+
const line = oneLine(fix);
|
|
980
|
+
return line.startsWith("Next step:") ? line : `Next step: ${line}`;
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* The final verdict, from post-apply evidence. Pure.
|
|
984
|
+
*
|
|
985
|
+
* `ready` says whether a run can start, and comes only from the readiness evidence.
|
|
986
|
+
* `settings_not_applied` says what the owner approved that did not take. The two stay
|
|
987
|
+
* apart, so a failed optional setting never turns a confirmed `Ready` into a failure.
|
|
988
|
+
* A missing fix uses the read-only doctor check, and with no fix at all an unconfirmed
|
|
989
|
+
* verdict names that check too instead of recommending a run.
|
|
990
|
+
*/
|
|
991
|
+
export function buildInstallVerdict(input) {
|
|
992
|
+
const { ready, blockers, results, protection } = input;
|
|
993
|
+
const settings = results
|
|
994
|
+
.filter((r) => INCOMPLETE_STATUS.has(r.status))
|
|
995
|
+
.map((r) => ({
|
|
996
|
+
key: r.key,
|
|
997
|
+
status: r.status,
|
|
998
|
+
reason: r.reason ?? FALLBACK_REASON[r.status] ?? "the write did not finish",
|
|
999
|
+
fix: r.fix ?? READINESS_PREREQUISITE_FIXES.doctor,
|
|
1000
|
+
}));
|
|
1001
|
+
const rule = results.find((r) => r.key === "approval_exemption");
|
|
1002
|
+
const approvalRule = rule === undefined
|
|
1003
|
+
? undefined
|
|
1004
|
+
: { status: rule.status, ...(rule.reason !== undefined ? { reason: rule.reason } : {}) };
|
|
1005
|
+
const ruleText = approvalRule === undefined
|
|
1006
|
+
? null
|
|
1007
|
+
: approvalRule.reason !== undefined ? `${approvalRule.status} — ${approvalRule.reason}` : approvalRule.status;
|
|
1008
|
+
const parts = [];
|
|
1009
|
+
if (ready === true)
|
|
1010
|
+
parts.push("Ready.");
|
|
1011
|
+
else if (ready === false)
|
|
1012
|
+
parts.push(blockers.length > 0 ? `Not ready. Still blocking: ${blockers.map((b) => oneLine(b.label)).join(", ")}.` : "Not ready.");
|
|
1013
|
+
else
|
|
1014
|
+
parts.push("Readiness was not confirmed.");
|
|
1015
|
+
const others = settings.filter((s) => s.key !== "approval_exemption");
|
|
1016
|
+
if (others.length > 0) {
|
|
1017
|
+
parts.push("These settings did not take:");
|
|
1018
|
+
for (const s of others)
|
|
1019
|
+
parts.push(`${SETTING_LABEL[s.key]}: ${asSentence(s.reason)} Fix: ${asSentence(s.fix)}`);
|
|
1020
|
+
}
|
|
1021
|
+
if (ruleText !== null) {
|
|
1022
|
+
const ruleFix = settings.find((s) => s.key === "approval_exemption")?.fix;
|
|
1023
|
+
parts.push(`${SETTING_LABEL.approval_exemption}: ${asSentence(ruleText)}${ruleFix !== undefined ? ` Fix: ${asSentence(ruleFix)}` : ""}`);
|
|
1024
|
+
}
|
|
1025
|
+
if (protection === "none" || protection === "watched_only")
|
|
1026
|
+
parts.push(NO_TESTS_SENTENCE);
|
|
1027
|
+
const firstFix = settings[0]?.fix ?? blockers[0]?.fix;
|
|
1028
|
+
const nextStep = firstFix !== undefined
|
|
1029
|
+
? asNextStep(firstFix)
|
|
1030
|
+
: ready === true ? READY_NEXT_STEP : asNextStep(READINESS_PREREQUISITE_FIXES.doctor);
|
|
1031
|
+
return {
|
|
1032
|
+
line: parts.join(" "),
|
|
1033
|
+
settings_not_applied: settings,
|
|
1034
|
+
...(approvalRule !== undefined ? { approval_rule: approvalRule } : {}),
|
|
1035
|
+
next_step: nextStep,
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
758
1038
|
const CHOICE_QUESTION = Object.freeze({
|
|
759
1039
|
gate: "Should setup save the checks each piece of epic work must pass before it can merge?",
|
|
760
1040
|
dependency_install: "Should workers refresh the project's dependencies, using the steps setup found, before each piece of work?",
|
|
@@ -779,6 +1059,29 @@ function withQuestion(c) {
|
|
|
779
1059
|
const { id, family, answer_key, ...rest } = c;
|
|
780
1060
|
return { id, family, answer_key, question: CHOICE_QUESTION[answer_key], ...rest };
|
|
781
1061
|
}
|
|
1062
|
+
/** What the settled answers say will deliver checks on epic-branch pull requests. */
|
|
1063
|
+
function epicBranchCiDelivery(choices, settled, context) {
|
|
1064
|
+
const picked = (key) => {
|
|
1065
|
+
const c = choiceFor(choices, key);
|
|
1066
|
+
if (c === undefined || !c.applicable)
|
|
1067
|
+
return undefined;
|
|
1068
|
+
return settled(key) ?? (typeof c.recommended === "string" ? c.recommended : undefined);
|
|
1069
|
+
};
|
|
1070
|
+
return {
|
|
1071
|
+
covers: choiceFor(choices, "epic_branch_ci")?.current === "covers",
|
|
1072
|
+
ciApproved: picked("epic_ci_change") === "approve",
|
|
1073
|
+
setupApproved: context.setupSuppliesWorkflow && picked("setup_pr") === "approve",
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* BAPI-1679 — true when the setup pull request is the only thing behind a recommended `include`.
|
|
1078
|
+
* The setup pull request opens only if the test trial passes, so at apply time this credit still
|
|
1079
|
+
* has to be proven. Confirmed coverage and an approved CI change do not depend on it.
|
|
1080
|
+
*/
|
|
1081
|
+
export function epicBranchCiIncludeRestsOnSetupPr(choices, settled, context) {
|
|
1082
|
+
const { covers, ciApproved, setupApproved } = epicBranchCiDelivery(choices, settled, context);
|
|
1083
|
+
return setupApproved && !covers && !ciApproved;
|
|
1084
|
+
}
|
|
782
1085
|
/**
|
|
783
1086
|
* BAPI-1659 — the one answer-aware place where `epic_branch_ci` is recommended.
|
|
784
1087
|
*
|
|
@@ -794,29 +1097,42 @@ export function resolveEpicBranchCiRecommendation(choices, settled, context = {
|
|
|
794
1097
|
const ci = choiceFor(choices, "epic_branch_ci");
|
|
795
1098
|
if (ci === undefined || ci.recommended === null || typeof ci.recommended !== "string")
|
|
796
1099
|
return [...choices];
|
|
797
|
-
const
|
|
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";
|
|
1100
|
+
const { covers, ciApproved, setupApproved } = epicBranchCiDelivery(choices, settled, context);
|
|
806
1101
|
const delivered = ciApproved || setupApproved;
|
|
807
1102
|
const target = covers || delivered ? "include" : "decline";
|
|
1103
|
+
// The include option always reads from the final answers; an explicit `include` is never
|
|
1104
|
+
// reworded into a claim that checks run.
|
|
1105
|
+
const options = ci.options.map((o) => (o.id === "include" ? { ...o, consequence: includeConsequence(covers, delivered) } : o));
|
|
1106
|
+
const withOptions = { ...ci, options };
|
|
1107
|
+
const replaceCi = (next) => choices.map((c) => (c.answer_key === "epic_branch_ci" ? next : c));
|
|
808
1108
|
if (target === ci.recommended)
|
|
809
|
-
return
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
1109
|
+
return replaceCi(withOptions);
|
|
1110
|
+
if (target === "include") {
|
|
1111
|
+
// Delivered but not yet merged: say the checks are proposed and not running. The offer-state
|
|
1112
|
+
// sentence ("would fix that") is not reused. Only the unsupported-CI-systems sentence is kept.
|
|
1113
|
+
const unsupported = /This repository (?:also )?uses [^.]*\. Bridge can't safely change [^.]*\./.exec(context.stateText ?? "")?.[0];
|
|
1114
|
+
const next = {
|
|
1115
|
+
...withOptions,
|
|
813
1116
|
recommended: "include",
|
|
814
|
-
why_recommended:
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
1117
|
+
why_recommended: [
|
|
1118
|
+
"Checks are proposed, not running yet: the pull request you approve adds them.",
|
|
1119
|
+
// A one-line trigger edit leaves the workflow as it is until merged, so say what children do meanwhile.
|
|
1120
|
+
// Bridge's own new workflow is described only as proposed.
|
|
1121
|
+
choiceFor(choices, "epic_ci_change")?.current === "trigger_edit"
|
|
1122
|
+
? "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."
|
|
1123
|
+
: "Each child waits for them only once you merge it.",
|
|
1124
|
+
...(unsupported !== undefined ? [unsupported] : []),
|
|
1125
|
+
].join(" "),
|
|
1126
|
+
};
|
|
1127
|
+
return replaceCi(finalizeRecommendation(next));
|
|
1128
|
+
}
|
|
1129
|
+
// Decline: the draft's reason described a delivery the final answers no longer approve. Finalize
|
|
1130
|
+
// first, then set the reason, so the generic last-resort sentence cannot replace it.
|
|
1131
|
+
const declined = finalizeRecommendation({ ...withOptions, recommended: "decline" });
|
|
1132
|
+
return replaceCi({
|
|
1133
|
+
...declined,
|
|
1134
|
+
why_recommended: "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.",
|
|
1135
|
+
});
|
|
820
1136
|
}
|
|
821
1137
|
/** Build the full choice catalog. Every family appears, applicable or not. */
|
|
822
1138
|
export function buildInstallChoices(d) {
|
|
@@ -867,6 +1183,17 @@ function projectFacts(facts) {
|
|
|
867
1183
|
...(facts.ci_systems !== undefined
|
|
868
1184
|
? { ci_systems: facts.ci_systems === null ? null : facts.ci_systems.map((c) => ({ name: String(c.name), path: String(c.path) })) }
|
|
869
1185
|
: {}),
|
|
1186
|
+
// BAPI-1667: additive, and only when detection ran.
|
|
1187
|
+
...(facts.sfcc !== undefined
|
|
1188
|
+
? {
|
|
1189
|
+
sfcc: {
|
|
1190
|
+
detected: facts.sfcc.detected,
|
|
1191
|
+
signals: [...facts.sfcc.signals],
|
|
1192
|
+
dev_script: facts.sfcc.dev_script,
|
|
1193
|
+
upload_check: facts.sfcc.upload_check === null ? null : { state: facts.sfcc.upload_check.state, missing: [...facts.sfcc.upload_check.missing] },
|
|
1194
|
+
},
|
|
1195
|
+
}
|
|
1196
|
+
: {}),
|
|
870
1197
|
};
|
|
871
1198
|
}
|
|
872
1199
|
/** The choice for a key, or undefined. */
|