@bridge_gpt/mcp-server 0.2.74 → 0.2.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -7
- package/build/agent-launchers/prompt.js +9 -21
- package/build/agents.generated.js +6 -6
- package/build/authored-plan.js +542 -0
- package/build/bridge-permissions.js +8 -0
- package/build/codex-auto-recovery.js +25 -7
- package/build/commands.generated.js +7 -7
- package/build/conductor/bridge-api-client.js +807 -52
- package/build/conductor/declare-blocked.js +4 -0
- package/build/conductor/driver-pass.js +8 -0
- package/build/conductor/epic-implementer-cli.js +341 -96
- package/build/conductor/epic-server-journal.js +13 -0
- package/build/conductor/epic-server-recipe.js +15 -5
- package/build/conductor/epic-server-runtime.js +163 -45
- package/build/conductor/epic-server.js +13 -6
- package/build/conductor/gate-discovery.js +209 -9
- package/build/conductor/gate-settings-review.js +7 -11
- package/build/conductor/install-doctor.js +30 -2
- package/build/conductor/launch-plan.js +58 -12
- package/build/conductor/local-merge.js +54 -12
- package/build/conductor/open-decision-phrases.js +50 -0
- package/build/conductor/pr-ci-producer.js +12 -3
- package/build/conductor/prerequisite-inputs.js +181 -14
- package/build/conductor/readiness-sections.js +46 -13
- package/build/conductor/readiness.js +3 -40
- package/build/conductor/recovery-cli.js +12 -12
- package/build/conductor/repository-workflow-remedy.js +147 -7
- package/build/conductor/ui-readiness.js +224 -0
- package/build/conductor/wait-run-attention.js +9 -4
- package/build/conductor/wait-run-cli.js +9 -2
- package/build/connect-github-api.js +18 -0
- package/build/connect-github.js +35 -18
- package/build/docs.generated.js +3 -3
- package/build/drive-epic.js +787 -37
- package/build/epic-ci-workflow.js +3 -2
- package/build/epic-implementer-bin.js +200 -66
- package/build/epic-implementer-bundle-cli.js +61 -0
- package/build/epic-implementer-claude-hook-bin.js +1 -1
- package/build/epic-implementer-env.js +3 -4
- package/build/epic-integration-pr.js +5 -2
- package/build/epic-launch-context.js +8 -1
- package/build/epic-shared/cut-protocol.js +55 -3
- package/build/executor/completion-contract.js +24 -1
- package/build/executor/failure-reason-codes.js +2 -0
- package/build/executor/gate-qualification-job.js +193 -23
- package/build/executor/gate-qualification-tests-ran.js +232 -0
- package/build/executor/integration-job.js +56 -2
- package/build/executor/job-runner.js +13 -723
- package/build/executor/job-type-wrappers.js +734 -0
- package/build/executor/merge-job.js +45 -1
- package/build/executor/permissions.js +187 -2
- package/build/executor/preflight.js +6 -2
- package/build/executor/process-containment.js +8 -1
- package/build/executor/provider-checks.js +28 -5
- package/build/executor/reconcile-overlap-job.js +70 -17
- package/build/executor/required-verification.js +28 -2
- package/build/executor/required-work-ledger.js +7 -2
- package/build/executor/resume-pre-spawn.js +32 -8
- package/build/executor/runner.js +30 -5
- package/build/executor/types.js +9 -0
- package/build/executor/worker-database.js +6 -1
- package/build/executor/worker-guard-hook.js +24 -2
- package/build/executor/worktree.js +12 -1
- package/build/generated/ticket-status.js +20 -0
- package/build/index.js +627 -551
- package/build/init.js +16 -0
- package/build/install-bridge-conductor-answers.js +32 -1
- package/build/install-bridge-conductor-apply.js +21 -3
- package/build/install-bridge-conductor-assessment.js +185 -12
- package/build/install-bridge-conductor-compact.js +2 -0
- package/build/install-bridge-conductor-contracts.js +9 -1
- package/build/install-bridge-conductor-gate.js +257 -80
- package/build/install-bridge-conductor-setup.js +106 -6
- package/build/install-bridge-conductor-trial-report.js +170 -0
- package/build/install-bridge-conductor.js +740 -124
- package/build/mcp-host-config.js +54 -37
- package/build/phase-context-git-probe.js +16 -0
- package/build/pipelines.generated.js +15 -15
- package/build/plan-execution-ledger.js +27 -0
- package/build/plan-generation.js +17 -0
- package/build/plane/plane-freshness.js +43 -26
- package/build/printed-remedy-commands.js +62 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-toolchains.js +11 -5
- package/build/scripts/saved-commands-config-field-driver.js +65 -0
- package/build/secret-redaction.js +3 -0
- package/build/setup-epic.js +51 -9
- package/build/test-support/create-preview-world.js +232 -0
- package/build/test-support/executor-source-files.js +1 -1
- package/build/ticket-delivery.js +65 -0
- package/build/v2-readiness-requirements.js +13 -4
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktree-core.js +51 -7
- package/docs/EPIC-IMPLEMENTER.md +83 -4
- package/docs/epic-implementer/getting-started.md +1 -1
- package/docs/install/github-app.md +79 -92
- package/package.json +1 -1
- package/pipelines/implement-ticket.json +2 -2
- package/build/conductor/epic-reconcile.js +0 -603
- package/build/conductor/epic-runtime.js +0 -2020
- package/build/conductor/epic-state.js +0 -774
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { writeJsonDocument, flushProcessStdout } from './conductor/json-output.js';
|
|
2
2
|
import { INSTALL_ASSESSMENT_SCHEMA_VERSION, } from './install-bridge-conductor-contracts.js';
|
|
3
|
-
import { buildInstallAssessment, buildInstallChoices, recommendEpicServer, buildInstallVerdict, buildProposalPresentation, classifyMergeTestProtection, dependencyInstallDetails, epicBranchCiIncludeRestsOnSetupPr, epicBranchCiStateText, indexDisplayStatus, } from './install-bridge-conductor-assessment.js';
|
|
3
|
+
import { buildInstallAssessment, buildInstallChoices, recommendEpicServer, buildInstallVerdict, buildProposalPresentation, classifyMergeTestProtection, dependencyInstallDetails, epicBranchCiIncludeRestsOnSetupPr, epicBranchCiStateText, indexDisplayStatus, savedStatusLabel, } from './install-bridge-conductor-assessment.js';
|
|
4
|
+
import { sanitizeCommandText } from './install-bridge-conductor-trial-report.js';
|
|
5
|
+
import { readConductorSavedTestCommands, saveConductorSavedTestCommands, } from './conductor/bridge-api-client.js';
|
|
4
6
|
import { GITHUB_ACTIONS_TRIGGER_ADAPTER, recognizeAppliedEdit, selectTriggerEdit, sha256Hex, } from './ci-trigger-adapters.js';
|
|
5
7
|
import { detectCiSystems } from './ci-system-detection.js';
|
|
8
|
+
import { presentTrialResult } from './install-bridge-conductor-trial-report.js';
|
|
6
9
|
import { describeDeclinedCiChange, describeProposedCiChange, describeUnopenedSetupCredit } from './epic-branch-ci-summary.js';
|
|
7
10
|
import { buildCompactApply, buildCompactAssessment, buildCompactProposal } from './install-bridge-conductor-compact.js';
|
|
8
11
|
import { decisionFor, normalizeInstallAnswers, parseAnswerValue, parseAnswersText, readAnswersSource, } from './install-bridge-conductor-answers.js';
|
|
@@ -129,8 +132,8 @@ import { withSetupProgress } from "./setup-progress.js";
|
|
|
129
132
|
* default branch, not the person's folder. The one stop this adds is the learned
|
|
130
133
|
* stop; everything else it adds only warns.
|
|
131
134
|
*/
|
|
132
|
-
import {
|
|
133
|
-
import { collectEpicBranchCi, confirmRequestFor, planDeclarations, resolveEffectiveDependencyInstall, describeGateRestoration, desiredFromStored, emptyConductorGateFlags, hasExplicitGateInput, parseLocalCommandFlag, parseEpicBranchCiDecisionFlag, parseMigrationGuardFlag, planManagedProviderGate, reportLearnedCommandTrial, describePolicyChanges, resolveConductorGate, runEpicBranchCiInspection, runGateConsequenceSummary, runClearConductorGate, mapExemptionOutcomeToWriteResult, runConductorGateQualification, runLearnedTestCommandTrial, runQualifyConductorGate, validateConductorGateFlags, } from "./install-bridge-conductor-gate.js";
|
|
135
|
+
import { PRINTED_QUALIFY_GATE_COMMAND, CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION } from "./printed-remedy-commands.js";
|
|
136
|
+
import { collectEpicBranchCi, confirmRequestFor, planDeclarations, resolveEffectiveDependencyInstall, describeGateRestoration, desiredFromStored, emptyConductorGateFlags, hasExplicitGateInput, parseLocalCommandFlag, parseEpicBranchCiDecisionFlag, parseMigrationGuardFlag, planManagedProviderGate, reportLearnedCommandTrial, isInformationalNoCommandReason, NO_COMMAND_INFORMATION_TEXT, CANDIDATE_REJECTION_FIX, formatSetupPolicyRefusal, describePolicyChanges, resolveConductorGate, runEpicBranchCiInspection, runGateConsequenceSummary, runClearConductorGate, mapExemptionOutcomeToWriteResult, runConductorGateQualification, runLearnedTestCommandTrial, runQualifyConductorGate, validateConductorGateFlags, } from "./install-bridge-conductor-gate.js";
|
|
134
137
|
import { classifyEpicPullRequestTrigger, readDefaultBranchRequiredChecksViaGh, readPullRequestBranchFilters, } from "./conductor/epic-branch-ci-inspection.js";
|
|
135
138
|
import { describeGateConsequence } from "./conductor/readiness-sections.js";
|
|
136
139
|
import { fetchConductorReadiness, } from "./conductor/bridge-api-client.js";
|
|
@@ -155,6 +158,9 @@ import { buildEpicCapabilityStatement } from "./epic-capability-statement.js";
|
|
|
155
158
|
import { MCP_GRANT_MAX_SERVERS } from "./mcp-grant.js";
|
|
156
159
|
import { advisoryFindingLines, assessIndexFreshness, assessSetupIndex, catalogLabel, NPM_SETUP_LAUNCHER, closedSetupPullRequestNotice, compareIndexedToMerge, planSetupFixes, projectSetupItems, readSetupPullRequest, renderSetupAssessment, deriveCompactReadiness, setupItemRemedy, setupVerdictLine, unmetBlockingItems, } from "./install-bridge-conductor-setup.js";
|
|
157
160
|
import { CONDUCTOR_BIN_UNRESOLVED_ERROR, MANAGED_HOOK_NAMES, } from "./conductor/git-hooks.js";
|
|
161
|
+
import { profileMergeNeededFrom } from "./mcp-host-config.js";
|
|
162
|
+
import { DuplicateRegistrationError } from "./init.js";
|
|
163
|
+
import { DUPLICATE_REGISTRATION_GUIDANCE } from "./launcher-config-inspection.js";
|
|
158
164
|
import os from "node:os";
|
|
159
165
|
import path from "node:path";
|
|
160
166
|
import { readFile as readFileAsync, stat as statAsync } from "node:fs/promises";
|
|
@@ -226,7 +232,7 @@ export function getInstallBridgeConductorUsage() {
|
|
|
226
232
|
" - which indexing branch to use, only when an existing different branch makes",
|
|
227
233
|
" the choice unclear;",
|
|
228
234
|
" - adding Bridge's own GitHub workflow, once, only for a repository with no CI of",
|
|
229
|
-
" its own and a test command Bridge
|
|
235
|
+
" its own and a test command that passed Bridge's trial run (then the setup pull request has",
|
|
230
236
|
" its own consent);",
|
|
231
237
|
" - storing a GitHub merge token on this computer (read with no echo).",
|
|
232
238
|
"Setup never asks for a test command. The destination is displayed without a",
|
|
@@ -267,8 +273,8 @@ export function getInstallBridgeConductorUsage() {
|
|
|
267
273
|
"stored as watched members of the gate. A red watched check stops a merge; a",
|
|
268
274
|
"missing one only warns. A gate you already confirmed is kept as it is.",
|
|
269
275
|
"",
|
|
270
|
-
"Bridge's workflow is optional: for a repository with no CI of its own and a
|
|
271
|
-
"
|
|
276
|
+
"Bridge's workflow is optional: for a repository with no CI of its own and a test",
|
|
277
|
+
"command that passed the trial run, setup offers it once (default no). It runs only for pull requests",
|
|
272
278
|
"into epic/** branches, and its check is added to the gate only after the setup",
|
|
273
279
|
"pull request is open. The pull request is built from a clean copy of your default",
|
|
274
280
|
"branch, so uncommitted or unpushed changes in your folder never block it or enter it.",
|
|
@@ -280,7 +286,7 @@ export function getInstallBridgeConductorUsage() {
|
|
|
280
286
|
"are unchanged.",
|
|
281
287
|
"",
|
|
282
288
|
"Options:",
|
|
283
|
-
" --test-command <command> Offer your own test command for Bridge to
|
|
289
|
+
" --test-command <command> Offer your own test command for Bridge to try once;",
|
|
284
290
|
" it replaces the stored local command only if it passes.",
|
|
285
291
|
" Not combinable with --remove-merge-token or",
|
|
286
292
|
" --clear-gate; may be given once.",
|
|
@@ -302,7 +308,7 @@ export function getInstallBridgeConductorUsage() {
|
|
|
302
308
|
"Explicit gate flags are the complete requested gate. Otherwise a confirmed gate",
|
|
303
309
|
"already stored is used unchanged; otherwise setup decides from facts, with no",
|
|
304
310
|
"question: checks your CI has really reported become watched members, and the",
|
|
305
|
-
"server adds a
|
|
311
|
+
"server adds a local command that passed the trial run. Nothing is stored until you authorize the",
|
|
306
312
|
"combined policy change that setup previews.",
|
|
307
313
|
" --provider-check <name> An exact provider-reported check name (repeatable).",
|
|
308
314
|
" Admission refuses one that has never reported.",
|
|
@@ -325,10 +331,11 @@ export function getInstallBridgeConductorUsage() {
|
|
|
325
331
|
"",
|
|
326
332
|
` --review-policy <source> One of: ${CONDUCTOR_REVIEW_POLICY_SOURCES.join(", ")}`,
|
|
327
333
|
" Omitted, setup keeps a project default that is already",
|
|
328
|
-
" stored. With none stored it stores verdict_protocol
|
|
329
|
-
" .github/workflows/claude-review.yml
|
|
330
|
-
" branch,
|
|
331
|
-
"
|
|
334
|
+
" stored. With none stored it stores verdict_protocol only",
|
|
335
|
+
" when Bridge read .github/workflows/claude-review.yml on",
|
|
336
|
+
" your default branch, the file exists, and it emits both the",
|
|
337
|
+
" run-id: and Reviewed-SHA: markers. Otherwise it stores",
|
|
338
|
+
" repository_policy. It scaffolds no Claude review workflow unless you",
|
|
332
339
|
" pass --review-policy verdict_protocol. Supplying any value",
|
|
333
340
|
" persists it as the project default, stamped into a new",
|
|
334
341
|
" run that carries no review policy of its own.",
|
|
@@ -1350,9 +1357,11 @@ export function formatConductorRestartAdvisory(mergedProfile) {
|
|
|
1350
1357
|
"at startup, so this activates on the next MCP server launch — restart your MCP " +
|
|
1351
1358
|
"client to gain access to the Epic Implementer tools.");
|
|
1352
1359
|
}
|
|
1353
|
-
/**
|
|
1354
|
-
|
|
1355
|
-
|
|
1360
|
+
/**
|
|
1361
|
+
* Remediation printed when no supported host config carries a Bridge entry.
|
|
1362
|
+
* Owned by `printed-remedy-commands.ts` since BAPI-1719; re-exported for compatibility.
|
|
1363
|
+
*/
|
|
1364
|
+
export { CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION };
|
|
1356
1365
|
/** Remediation printed whenever the managed git hooks were not installed. */
|
|
1357
1366
|
export const CONDUCTOR_HOOKS_MANUAL_REMEDIATION = "re-run `install epic-implementer` and accept the local-observability consent, or run " +
|
|
1358
1367
|
"`epic-implementer install-git-hooks` directly.";
|
|
@@ -1363,6 +1372,101 @@ export const CONDUCTOR_HOOKS_MANUAL_REMEDIATION = "re-run `install epic-implemen
|
|
|
1363
1372
|
export const CONDUCTOR_HOOKS_DURABLE_REMEDIATION = `install the CLI persistently (\`npm i -g ${MCP_PACKAGE_NAME}\`), then run ` +
|
|
1364
1373
|
"`epic-implementer install-git-hooks` (or re-run `install epic-implementer` and accept the " +
|
|
1365
1374
|
"local-observability consent).";
|
|
1375
|
+
/**
|
|
1376
|
+
* The plain restart line the converging setup prints once after a confirmed write
|
|
1377
|
+
* (BAPI-1719), and the advisory its structured result carries.
|
|
1378
|
+
*/
|
|
1379
|
+
export const TOOL_VISIBILITY_RESTART_LINE = "Restart your MCP client so this session can see the Epic Implementer tools.";
|
|
1380
|
+
/** Fixed, secret-free wording for the closed failure cases. Never an exception message. */
|
|
1381
|
+
const TOOL_VISIBILITY_FAILURE_TEXT = Object.freeze({
|
|
1382
|
+
inspection: "the MCP configuration could not be inspected",
|
|
1383
|
+
write: "the host MCP profile could not be updated",
|
|
1384
|
+
duplicate: "a config registers Bridge under two names, so nothing was changed",
|
|
1385
|
+
});
|
|
1386
|
+
/**
|
|
1387
|
+
* Add the `epic_implementer` group to the EXISTING project-local Bridge MCP entries.
|
|
1388
|
+
*
|
|
1389
|
+
* CONSENT BELONGS TO THE CALLER: this function never asks. It modifies only entries
|
|
1390
|
+
* that already exist (the writer never creates a file, directory, or registration),
|
|
1391
|
+
* and it writes only through `local.mergeProfileToken()`.
|
|
1392
|
+
*
|
|
1393
|
+
* Mutation success is decoupled from what follows it: once the writer returns a
|
|
1394
|
+
* non-empty profile the outcome is `written`, whatever the read-back or the
|
|
1395
|
+
* capability record later report. `deps` is accepted for signature symmetry with the
|
|
1396
|
+
* other setup operations; the helper itself prints nothing.
|
|
1397
|
+
*/
|
|
1398
|
+
export async function applyToolVisibility(deps, local, options = {}) {
|
|
1399
|
+
void deps;
|
|
1400
|
+
const base = {
|
|
1401
|
+
outcome: "failed", changedPaths: [], mergedProfile: "", carryingPaths: [],
|
|
1402
|
+
verification: "not_run", guidance: [], advisories: [], notes: [], failurePaths: [],
|
|
1403
|
+
};
|
|
1404
|
+
let changedPaths = [];
|
|
1405
|
+
if (options.freshInspection !== false) {
|
|
1406
|
+
// Fresh evidence only: nothing from the earlier assessment is reused.
|
|
1407
|
+
let pre;
|
|
1408
|
+
try {
|
|
1409
|
+
pre = await local.inspectProfileToken();
|
|
1410
|
+
}
|
|
1411
|
+
catch {
|
|
1412
|
+
return { ...base, failure: TOOL_VISIBILITY_FAILURE_TEXT.inspection, guidance: ["re-run setup once the MCP configuration is readable"] };
|
|
1413
|
+
}
|
|
1414
|
+
if (!profileMergeNeededFrom(pre)) {
|
|
1415
|
+
if (pre.bridgeEntryPresent)
|
|
1416
|
+
return { ...base, outcome: "unchanged" };
|
|
1417
|
+
if (pre.configs.some((c) => c.state === "unreadable")) {
|
|
1418
|
+
return { ...base, failure: TOOL_VISIBILITY_FAILURE_TEXT.inspection, guidance: ["re-run setup once the MCP configuration is readable"] };
|
|
1419
|
+
}
|
|
1420
|
+
return { ...base, outcome: "no_entry", guidance: [CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION] };
|
|
1421
|
+
}
|
|
1422
|
+
changedPaths = pre.configs.filter((c) => c.state === "token-absent").map((c) => c.path);
|
|
1423
|
+
}
|
|
1424
|
+
let merged;
|
|
1425
|
+
try {
|
|
1426
|
+
merged = await local.mergeProfileToken();
|
|
1427
|
+
}
|
|
1428
|
+
catch (error) {
|
|
1429
|
+
// The thrown value is discarded except for a duplicate's fixed config paths:
|
|
1430
|
+
// any other message can carry an absolute path or an environment value.
|
|
1431
|
+
if (error instanceof DuplicateRegistrationError) {
|
|
1432
|
+
return {
|
|
1433
|
+
...base,
|
|
1434
|
+
failure: TOOL_VISIBILITY_FAILURE_TEXT.duplicate,
|
|
1435
|
+
failurePaths: [...error.relPaths],
|
|
1436
|
+
guidance: [DUPLICATE_REGISTRATION_GUIDANCE],
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
return { ...base, failure: TOOL_VISIBILITY_FAILURE_TEXT.write };
|
|
1440
|
+
}
|
|
1441
|
+
if (merged === "") {
|
|
1442
|
+
return { ...base, outcome: "no_entry", guidance: [CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION] };
|
|
1443
|
+
}
|
|
1444
|
+
// The write is confirmed. Nothing below can turn it into a failure.
|
|
1445
|
+
const result = { ...base, outcome: "written", changedPaths, mergedProfile: merged, advisories: [TOOL_VISIBILITY_RESTART_LINE] };
|
|
1446
|
+
try {
|
|
1447
|
+
// Which configs carry the group now: the READ-ONLY inspector, not a guess from the merged string.
|
|
1448
|
+
const post = await local.inspectProfileToken();
|
|
1449
|
+
result.carryingPaths = post.configs.filter((c) => c.state === "token-present").map((c) => c.path);
|
|
1450
|
+
result.verification = profileMergeNeededFrom(post) ? "unknown" : "confirmed";
|
|
1451
|
+
}
|
|
1452
|
+
catch {
|
|
1453
|
+
result.verification = "unknown";
|
|
1454
|
+
}
|
|
1455
|
+
if (result.verification === "unknown") {
|
|
1456
|
+
result.guidance.push("the write could not be confirmed by reading the configuration back; run `epic-implementer doctor` after restarting your MCP client");
|
|
1457
|
+
}
|
|
1458
|
+
try {
|
|
1459
|
+
const recorded = await local.recordCapability("conductor_tool_visibility");
|
|
1460
|
+
// Advisory: install state is a diagnostic aid. A recording failure does not
|
|
1461
|
+
// invalidate the host-config change that just landed.
|
|
1462
|
+
if (!recorded.ok)
|
|
1463
|
+
result.notes.push(`install-state not updated (${recorded.error ?? "unknown"})`);
|
|
1464
|
+
}
|
|
1465
|
+
catch {
|
|
1466
|
+
result.notes.push("install-state not updated (unknown)");
|
|
1467
|
+
}
|
|
1468
|
+
return result;
|
|
1469
|
+
}
|
|
1366
1470
|
/**
|
|
1367
1471
|
* Phase: tool visibility.
|
|
1368
1472
|
*
|
|
@@ -1370,6 +1474,8 @@ export const CONDUCTOR_HOOKS_DURABLE_REMEDIATION = `install the CLI persistently
|
|
|
1370
1474
|
* own consent, then prints the restart advisory. It never creates a host config
|
|
1371
1475
|
* — the merge helper's never-create rule is what keeps a declined or
|
|
1372
1476
|
* unconfigured repository from acquiring files it did not ask for.
|
|
1477
|
+
*
|
|
1478
|
+
* Production has not reached this phase since BAPI-1461; the converging setup applies the same operation.
|
|
1373
1479
|
*/
|
|
1374
1480
|
async function runConductorToolVisibilityPhase(deps, local) {
|
|
1375
1481
|
const consented = await confirm(deps, "Update existing supported host MCP configurations (.mcp.json, .vscode/mcp.json, " +
|
|
@@ -1383,16 +1489,13 @@ async function runConductorToolVisibilityPhase(deps, local) {
|
|
|
1383
1489
|
],
|
|
1384
1490
|
};
|
|
1385
1491
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
}
|
|
1390
|
-
catch {
|
|
1391
|
-
// The thrown value is discarded: it can carry an absolute config path.
|
|
1492
|
+
// The legacy phase merges unconditionally and reports every non-empty merge, so it skips the fresh pre-write inspection.
|
|
1493
|
+
const result = await applyToolVisibility(deps, local, { freshInspection: false });
|
|
1494
|
+
if (result.outcome === "failed") {
|
|
1392
1495
|
deps.errorLog(" the host MCP profile could not be updated.");
|
|
1393
1496
|
return { manualActions: [], fatal: true };
|
|
1394
1497
|
}
|
|
1395
|
-
if (
|
|
1498
|
+
if (result.outcome === "no_entry") {
|
|
1396
1499
|
deps.log(" no supported host MCP configuration carries a Bridge entry, so nothing " +
|
|
1397
1500
|
"was written (this command never creates one).");
|
|
1398
1501
|
return {
|
|
@@ -1401,31 +1504,14 @@ async function runConductorToolVisibilityPhase(deps, local) {
|
|
|
1401
1504
|
],
|
|
1402
1505
|
};
|
|
1403
1506
|
}
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
// nothing about which files it came from.
|
|
1407
|
-
let carrying = [];
|
|
1408
|
-
try {
|
|
1409
|
-
const inspection = await local.inspectProfileToken();
|
|
1410
|
-
carrying = inspection.configs
|
|
1411
|
-
.filter((c) => c.state === "token-present")
|
|
1412
|
-
.map((c) => c.path);
|
|
1413
|
-
}
|
|
1414
|
-
catch {
|
|
1415
|
-
// A failed read-back is not a failed merge. The advisory below still prints.
|
|
1416
|
-
}
|
|
1417
|
-
deps.log(carrying.length > 0
|
|
1418
|
-
? ` updated: ${carrying.join(", ")}`
|
|
1507
|
+
deps.log(result.carryingPaths.length > 0
|
|
1508
|
+
? ` updated: ${result.carryingPaths.join(", ")}`
|
|
1419
1509
|
: " the Epic Implementer profile was merged into your supported host MCP config(s).");
|
|
1420
1510
|
// Coverage honesty: the merge path writes these three files and no others.
|
|
1421
1511
|
deps.log(" Codex and Copilot host configuration was NOT inspected or changed.");
|
|
1422
|
-
deps.log(` ${formatConductorRestartAdvisory(mergedProfile)}`);
|
|
1423
|
-
const
|
|
1424
|
-
|
|
1425
|
-
// Advisory: install state is a diagnostic aid. A recording failure does not
|
|
1426
|
-
// invalidate the host-config change that just landed.
|
|
1427
|
-
deps.errorLog(` note: install-state not updated (${recorded.error ?? "unknown"})`);
|
|
1428
|
-
}
|
|
1512
|
+
deps.log(` ${formatConductorRestartAdvisory(result.mergedProfile)}`);
|
|
1513
|
+
for (const note of result.notes)
|
|
1514
|
+
deps.errorLog(` note: ${note}`);
|
|
1429
1515
|
return { manualActions: [] };
|
|
1430
1516
|
}
|
|
1431
1517
|
/**
|
|
@@ -2027,11 +2113,16 @@ function renderReviewPolicy(deps, options, decision) {
|
|
|
2027
2113
|
"default and stamped into a new run that sets no review policy of its own. An explicit per-run " +
|
|
2028
2114
|
"policy always wins, and changing this later never alters an already-approved run."
|
|
2029
2115
|
: decision.basis === "workflow_present"
|
|
2030
|
-
? ` Inferred: ${CLAUDE_REVIEW_WORKFLOW_RELPATH} exists on your default branch
|
|
2031
|
-
"project default, and a stored default is never overwritten by a later run.
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2116
|
+
? ` Inferred: ${CLAUDE_REVIEW_WORKFLOW_RELPATH} exists on your default branch and emits both the run-id: and ` +
|
|
2117
|
+
"Reviewed-SHA: markers. It is stored as the project default, and a stored default is never overwritten by a later run. " +
|
|
2118
|
+
"Pass --review-policy to choose another."
|
|
2119
|
+
: decision.basis === "workflow_without_markers"
|
|
2120
|
+
? ` Inferred: ${CLAUDE_REVIEW_WORKFLOW_RELPATH} exists on your default branch but does not emit both the run-id: ` +
|
|
2121
|
+
"and Reviewed-SHA: markers that verdict_protocol needs, so repository_policy was stored as the project default. " +
|
|
2122
|
+
"Pass --review-policy verdict_protocol to opt in; setup then offers to write the workflow."
|
|
2123
|
+
: ` Inferred: no ${CLAUDE_REVIEW_WORKFLOW_RELPATH} was found on your default branch, so no Claude review ` +
|
|
2124
|
+
"workflow is needed. It is stored as the project default, and a stored default is never overwritten by a " +
|
|
2125
|
+
"later run. Pass --review-policy verdict_protocol to opt in to AI review.");
|
|
2035
2126
|
return;
|
|
2036
2127
|
}
|
|
2037
2128
|
deps.log(`Review policy: ${options.reviewPolicy}`);
|
|
@@ -2951,27 +3042,21 @@ function storedReviewSource(policy) {
|
|
|
2951
3042
|
// A stored value this client cannot interpret is still a stored choice.
|
|
2952
3043
|
return "unrecognized";
|
|
2953
3044
|
}
|
|
2954
|
-
/** Whether `.github/workflows/claude-review.yml` exists on the remote default branch snapshot. */
|
|
2955
|
-
async function remoteReviewWorkflowExists(setup, snapshot) {
|
|
2956
|
-
if (snapshot === null || setup.readSnapshotFile === undefined)
|
|
2957
|
-
return false;
|
|
2958
|
-
try {
|
|
2959
|
-
await setup.readSnapshotFile(snapshot, CLAUDE_REVIEW_WORKFLOW_RELPATH);
|
|
2960
|
-
return true;
|
|
2961
|
-
}
|
|
2962
|
-
catch {
|
|
2963
|
-
// Absent and unreadable both fall back to repository_policy, which needs no workflow.
|
|
2964
|
-
return false;
|
|
2965
|
-
}
|
|
2966
|
-
}
|
|
2967
3045
|
/**
|
|
2968
3046
|
* Decide the review default: explicit `--review-policy` first; otherwise none when
|
|
2969
|
-
* a project default is already stored (or cannot be read); otherwise
|
|
2970
|
-
*
|
|
2971
|
-
*
|
|
2972
|
-
*
|
|
3047
|
+
* a project default is already stored (or cannot be read); otherwise infer from the
|
|
3048
|
+
* server's own read of the review workflow (BAPI-1714).
|
|
3049
|
+
*
|
|
3050
|
+
* `verdict_protocol` is inferred ONLY when the server's probe succeeded, the file
|
|
3051
|
+
* is present, and it emits BOTH the `run-id:` and `Reviewed-SHA:` markers (each
|
|
3052
|
+
* literally `true`). A workflow that is present but known to lack a marker cannot
|
|
3053
|
+
* produce the evidence `verdict_protocol` needs, so `repository_policy` is stored
|
|
3054
|
+
* with the `workflow_without_markers` basis. An absent workflow, a failed probe, or
|
|
3055
|
+
* any unknown fact keeps the `repository_policy` fallback. Workflow parsing stays
|
|
3056
|
+
* server-owned: this reads the typed observation and adds no YAML parser, marker
|
|
3057
|
+
* scanner, or provider probe. Reads only.
|
|
2973
3058
|
*/
|
|
2974
|
-
async function resolveReviewDefault(deps, options,
|
|
3059
|
+
async function resolveReviewDefault(deps, options, access, reviewWorkflow) {
|
|
2975
3060
|
let stored;
|
|
2976
3061
|
try {
|
|
2977
3062
|
stored = storedReviewSource(await fetchConductorSetupPolicy(access, deps.fetchJson));
|
|
@@ -2986,11 +3071,16 @@ async function resolveReviewDefault(deps, options, setup, access, snapshot) {
|
|
|
2986
3071
|
return { kind: "preserve", basis: "unreadable", stored: null };
|
|
2987
3072
|
if (stored !== null)
|
|
2988
3073
|
return { kind: "preserve", basis: "stored", stored };
|
|
2989
|
-
const
|
|
3074
|
+
const probed = reviewWorkflow?.probe_succeeded === true;
|
|
3075
|
+
const present = probed && reviewWorkflow?.workflow_present === true;
|
|
3076
|
+
if (present && reviewWorkflow?.emits_run_id === true && reviewWorkflow?.emits_reviewed_sha === true) {
|
|
3077
|
+
return { kind: "send", source: "verdict_protocol", basis: "workflow_present", stored: null };
|
|
3078
|
+
}
|
|
3079
|
+
const knownMissingMarker = present && (reviewWorkflow?.emits_run_id === false || reviewWorkflow?.emits_reviewed_sha === false);
|
|
2990
3080
|
return {
|
|
2991
3081
|
kind: "send",
|
|
2992
|
-
source:
|
|
2993
|
-
basis:
|
|
3082
|
+
source: "repository_policy",
|
|
3083
|
+
basis: knownMissingMarker ? "workflow_without_markers" : "workflow_absent",
|
|
2994
3084
|
stored: null,
|
|
2995
3085
|
};
|
|
2996
3086
|
}
|
|
@@ -3086,9 +3176,9 @@ decision) {
|
|
|
3086
3176
|
try {
|
|
3087
3177
|
preview = await previewConductorSetupPolicy(access, request, deps.postJson);
|
|
3088
3178
|
}
|
|
3089
|
-
catch {
|
|
3179
|
+
catch (error) {
|
|
3090
3180
|
deps.log("Deferred: combined setup policy is unavailable or unsupported. Rerun with a compatible server; ask a bootstrap administrator if this persists.");
|
|
3091
|
-
return { status: "deferred" };
|
|
3181
|
+
return { status: "deferred", ...(error instanceof ConductorSetupPolicyError ? { refusal: error.reason } : {}) };
|
|
3092
3182
|
}
|
|
3093
3183
|
// One plain line per changed setting. The before → after JSON is a diagnostic, shown only under --verbose.
|
|
3094
3184
|
const logEffects = (effects) => {
|
|
@@ -3165,7 +3255,7 @@ decision) {
|
|
|
3165
3255
|
}
|
|
3166
3256
|
if (error instanceof ConductorSetupPolicyError && ["refused", "stale", "unsupported"].includes(error.reason)) {
|
|
3167
3257
|
deps.log("Deferred: policy was refused or changed. Rerun for a fresh preview.");
|
|
3168
|
-
return { status: "deferred" };
|
|
3258
|
+
return { status: "deferred", refusal: error.reason };
|
|
3169
3259
|
}
|
|
3170
3260
|
}
|
|
3171
3261
|
try {
|
|
@@ -3173,14 +3263,14 @@ decision) {
|
|
|
3173
3263
|
}
|
|
3174
3264
|
catch {
|
|
3175
3265
|
deps.log("Unknown—verify before retrying: policy apply could not be confirmed. Ask the bootstrap administrator.");
|
|
3176
|
-
return { status: "unknown" };
|
|
3266
|
+
return { status: "unknown", refusal: "uncertain" };
|
|
3177
3267
|
}
|
|
3178
3268
|
if (uncertain
|
|
3179
3269
|
|| (appliedState !== undefined && !policyMatches(appliedState, current.state))
|
|
3180
3270
|
|| !policyMatches(preview.after, current.policy) || current.state.generation <= preview.state.generation
|
|
3181
3271
|
|| current.state.revision < preview.state.revision) {
|
|
3182
3272
|
deps.log("Unknown—verify before retrying: coherent read-back does not confirm the intended complete policy.");
|
|
3183
|
-
return { status: "unknown" };
|
|
3273
|
+
return { status: "unknown", refusal: "uncertain" };
|
|
3184
3274
|
}
|
|
3185
3275
|
if (applyWithoutQuestion) {
|
|
3186
3276
|
deps.log("Policy applied (confirmed by reading it back).");
|
|
@@ -3563,11 +3653,8 @@ async function runRemoveMergeToken(options, deps, setup) {
|
|
|
3563
3653
|
function localAdvisories(report) {
|
|
3564
3654
|
const out = [];
|
|
3565
3655
|
const section = (id) => report.sections.find((s) => s.id === id);
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
out.push("to see the Epic Implementer tools in your editor, add `epic_implementer` to BRIDGE_MCP_PROFILE " +
|
|
3569
|
-
"in your MCP configuration, then restart the editor");
|
|
3570
|
-
}
|
|
3656
|
+
// BAPI-1719: the profile-token advisory moved to the `local.tool-visibility` setup item,
|
|
3657
|
+
// the single representation of that gap. Only the hook advisory stays here.
|
|
3571
3658
|
const hooks = section("conductor-hook-targets");
|
|
3572
3659
|
if (hooks !== undefined && hooks.status !== "ok") {
|
|
3573
3660
|
out.push("for local event history, run `epic-implementer install-git-hooks`");
|
|
@@ -3777,6 +3864,38 @@ async function learnedCommandHints(setup, access) {
|
|
|
3777
3864
|
: candidate.provenance,
|
|
3778
3865
|
}));
|
|
3779
3866
|
}
|
|
3867
|
+
/**
|
|
3868
|
+
* BAPI-1699 — the saved selection as assessment evidence, or `undefined`. Never throws:
|
|
3869
|
+
* an older server, a transport failure, an unreadable body, or a fake transport that
|
|
3870
|
+
* does not know the URL all mean "no saved evidence", and the plan continues unchanged.
|
|
3871
|
+
*/
|
|
3872
|
+
async function readSavedTestCommandsEvidence(deps, access) {
|
|
3873
|
+
try {
|
|
3874
|
+
const read = await readConductorSavedTestCommands(access, deps.fetchJson);
|
|
3875
|
+
if (read.kind !== "saved")
|
|
3876
|
+
return undefined;
|
|
3877
|
+
return {
|
|
3878
|
+
commands: read.record.commands,
|
|
3879
|
+
generation: read.record.generation,
|
|
3880
|
+
trialState: read.trialState,
|
|
3881
|
+
commandsInForce: read.commandsInForce,
|
|
3882
|
+
setBy: read.record.set_by,
|
|
3883
|
+
};
|
|
3884
|
+
}
|
|
3885
|
+
catch {
|
|
3886
|
+
return undefined;
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
/**
|
|
3890
|
+
* BAPI-1699 — whether the saved commands are, in order, the commands the stored gate already
|
|
3891
|
+
* runs. The comparison splits each saved line on whitespace; a quoted command that does not
|
|
3892
|
+
* split to the stored argv counts as different, which is the safe direction (it is offered as
|
|
3893
|
+
* a pending selection, never silently skipped).
|
|
3894
|
+
*/
|
|
3895
|
+
export function savedCommandsEqualStoredGate(saved, stored) {
|
|
3896
|
+
return (saved.length === stored.length &&
|
|
3897
|
+
stored.every((command, index) => JSON.stringify(command.argv) === JSON.stringify(saved[index].trim().split(/\s+/))));
|
|
3898
|
+
}
|
|
3780
3899
|
/**
|
|
3781
3900
|
* BAPI-1677 — whether a test trial can be offered. The candidates are the ones the
|
|
3782
3901
|
* client can see: file detection first, then the repository's local commands, in
|
|
@@ -3785,6 +3904,17 @@ async function learnedCommandHints(setup, access) {
|
|
|
3785
3904
|
*/
|
|
3786
3905
|
async function resolveTestCommandTrial(deps, setup, access, gatePlan, storedCommand) {
|
|
3787
3906
|
const none = { eligible: false, candidates: [] };
|
|
3907
|
+
// BAPI-1699: one read of the saved field. A saved selection wins over every discovery
|
|
3908
|
+
// below, even when a local gate is already stored (a pending replacement is still offered).
|
|
3909
|
+
// Unsupported, failed, or unreadable reads are no evidence and change nothing else.
|
|
3910
|
+
const saved = await readSavedTestCommandsEvidence(deps, access);
|
|
3911
|
+
if (saved !== undefined && saved.trialState === "passed")
|
|
3912
|
+
return { eligible: false, candidates: [], saved };
|
|
3913
|
+
// Saved commands that already ARE the stored gate's local commands are not a replacement. An
|
|
3914
|
+
// unqualified stored gate keeps its own qualification flow, exactly as before saving existed.
|
|
3915
|
+
if (saved !== undefined && !savedCommandsEqualStoredGate(saved.commands, gatePlan.current.profile?.local_commands ?? [])) {
|
|
3916
|
+
return { eligible: true, candidates: saved.commands.map((command) => ({ command, source: "saved commands" })), saved };
|
|
3917
|
+
}
|
|
3788
3918
|
const inferred = gatePlan.inferred;
|
|
3789
3919
|
const storedGateRetry = inferred === undefined && gatePlan.origin === "stored" && gatePlan.current.confirmed &&
|
|
3790
3920
|
storedCommand === null && (gatePlan.current.profile?.local_commands.length ?? 0) === 0;
|
|
@@ -3811,6 +3941,94 @@ async function resolveTestCommandTrial(deps, setup, access, gatePlan, storedComm
|
|
|
3811
3941
|
}
|
|
3812
3942
|
return { eligible: candidates.length > 0, candidates };
|
|
3813
3943
|
}
|
|
3944
|
+
/** Read the stored gate once for a trial; `null` (already reported) when it cannot be read. */
|
|
3945
|
+
async function readGateForTrial(deps, access, policyResult) {
|
|
3946
|
+
let current;
|
|
3947
|
+
try {
|
|
3948
|
+
current = await fetchConductorGateProfile(access, deps.fetchJson);
|
|
3949
|
+
}
|
|
3950
|
+
catch {
|
|
3951
|
+
deps.log(" skipped — the stored gate could not be read, so nothing was started.");
|
|
3952
|
+
return null;
|
|
3953
|
+
}
|
|
3954
|
+
if ((policyResult?.status === "deferred" || policyResult?.status === "unknown") && !current.confirmed) {
|
|
3955
|
+
deps.log(" skipped — the gate and defaults were not stored, so there is no stored gate for a tested command to attach to.");
|
|
3956
|
+
return null;
|
|
3957
|
+
}
|
|
3958
|
+
return current;
|
|
3959
|
+
}
|
|
3960
|
+
/**
|
|
3961
|
+
* BAPI-1699 — give exactly the saved commands (one generation) their trial run through
|
|
3962
|
+
* the existing POST and executor path. Nothing here writes a gate or saves a command;
|
|
3963
|
+
* the server promotes only a passing trial of the current generation, and a replacement
|
|
3964
|
+
* leaves the previously qualified guard in force until it does.
|
|
3965
|
+
*/
|
|
3966
|
+
async function runSavedTrial(deps, access, baseUrl, state, policyResult, commands, generation) {
|
|
3967
|
+
deps.log("");
|
|
3968
|
+
deps.log("Test command");
|
|
3969
|
+
const current = await readGateForTrial(deps, access, policyResult);
|
|
3970
|
+
if (current === null)
|
|
3971
|
+
return;
|
|
3972
|
+
const io = gateIoFor(deps);
|
|
3973
|
+
const trialGateDeps = deps.gate !== undefined && deps.progressTimer !== undefined && deps.gate.progressTimer === undefined
|
|
3974
|
+
? { ...deps.gate, progressTimer: deps.progressTimer }
|
|
3975
|
+
: deps.gate;
|
|
3976
|
+
const result = await runLearnedTestCommandTrial(io, access, trialGateDeps, {
|
|
3977
|
+
baseUrl,
|
|
3978
|
+
current,
|
|
3979
|
+
expectedGeneration: generation,
|
|
3980
|
+
savedCommands: commands,
|
|
3981
|
+
});
|
|
3982
|
+
reportLearnedCommandTrial(io, result);
|
|
3983
|
+
if (result.status !== "promoted" && (current.profile?.local_commands.length ?? 0) > 0) {
|
|
3984
|
+
deps.log(" The guard you had before stays in force until the saved commands pass the trial run.");
|
|
3985
|
+
}
|
|
3986
|
+
state.trial = result;
|
|
3987
|
+
if (result.status === "uncertain")
|
|
3988
|
+
state.commandUncertain = true;
|
|
3989
|
+
if (result.status === "promoted")
|
|
3990
|
+
state.promotedCommands = result.commands;
|
|
3991
|
+
}
|
|
3992
|
+
/**
|
|
3993
|
+
* BAPI-1699 — save an approved `{"commands": [...]}` answer through the config field, then
|
|
3994
|
+
* try the generation the save returned. Returns `single_fallback` only when an older server
|
|
3995
|
+
* refused the field (400 or 404) and exactly one command was approved: the caller then uses
|
|
3996
|
+
* today's owner-command request. Anything else is reported here and the phase ends.
|
|
3997
|
+
*/
|
|
3998
|
+
async function saveApprovedCommands(deps, access, baseUrl, state, gatePlan, policyResult, commands) {
|
|
3999
|
+
deps.log("");
|
|
4000
|
+
deps.log("Test command");
|
|
4001
|
+
const io = gateIoFor(deps);
|
|
4002
|
+
const write = await saveConductorSavedTestCommands(access, commands, io.postJson);
|
|
4003
|
+
switch (write.kind) {
|
|
4004
|
+
case "saved": {
|
|
4005
|
+
deps.log(` Saved ${commands.length} test command${commands.length === 1 ? "" : "s"}: ` +
|
|
4006
|
+
`${commands.map((c) => `\`${sanitizeCommandText(c)}\``).join(", ")} (${savedStatusLabel(write.trialState)}). ` +
|
|
4007
|
+
"Saving does not put them in force: they are relied on only after they pass the trial run.");
|
|
4008
|
+
await runSavedTrial(deps, access, baseUrl, state, policyResult, commands, write.record.generation);
|
|
4009
|
+
return "done";
|
|
4010
|
+
}
|
|
4011
|
+
case "unsupported":
|
|
4012
|
+
if (commands.length === 1)
|
|
4013
|
+
return "single_fallback";
|
|
4014
|
+
deps.log(" This Bridge server cannot save several test commands yet, so none were saved or tried. " +
|
|
4015
|
+
"Update the Bridge API and run setup again.");
|
|
4016
|
+
state.trial = { status: "unsupported" };
|
|
4017
|
+
return "done";
|
|
4018
|
+
case "refused":
|
|
4019
|
+
deps.log(write.reason === "unauthorized"
|
|
4020
|
+
? " This key cannot save test commands (an administrator key is needed), so Bridge skipped them."
|
|
4021
|
+
: " Bridge's server refused the test commands, so none were saved or tried.");
|
|
4022
|
+
state.trial = { status: "refused", reason: write.reason };
|
|
4023
|
+
return "done";
|
|
4024
|
+
case "uncertain":
|
|
4025
|
+
deps.log(" Bridge cannot tell whether the test commands were saved. It will not try again on its own. " +
|
|
4026
|
+
"Run setup again to read what the server holds.");
|
|
4027
|
+
state.commandUncertain = true;
|
|
4028
|
+
state.trial = { status: "uncertain", reason: "request_unclear", profile: null };
|
|
4029
|
+
return "done";
|
|
4030
|
+
}
|
|
4031
|
+
}
|
|
3814
4032
|
/**
|
|
3815
4033
|
* Ask the server for the learned (or the owner's) test command and prove it.
|
|
3816
4034
|
*
|
|
@@ -3830,7 +4048,26 @@ async function runTestCommandPhase(deps, options, setup, access, baseUrl, state,
|
|
|
3830
4048
|
answer) {
|
|
3831
4049
|
if (answer !== undefined && (answer.decision === "skip" || answer.decision === "keep"))
|
|
3832
4050
|
return;
|
|
3833
|
-
|
|
4051
|
+
// BAPI-1699: an approved `commands` answer is saved once through the config field, and
|
|
4052
|
+
// only the generation that save returned is tried. An older server falls back to today's
|
|
4053
|
+
// single owner command; several commands are never cut down to the first.
|
|
4054
|
+
let commandsAnswer = answer?.decision === "commands" ? answer.commands : undefined;
|
|
4055
|
+
let fallbackOwnerCommand;
|
|
4056
|
+
if (commandsAnswer !== undefined) {
|
|
4057
|
+
const saved = await saveApprovedCommands(deps, access, baseUrl, state, gatePlan, policyResult, commandsAnswer);
|
|
4058
|
+
if (saved !== "single_fallback")
|
|
4059
|
+
return;
|
|
4060
|
+
fallbackOwnerCommand = commandsAnswer[0];
|
|
4061
|
+
commandsAnswer = undefined;
|
|
4062
|
+
}
|
|
4063
|
+
const ownerCommand = fallbackOwnerCommand ?? (answer?.decision === "command" ? answer.command : options.testCommand);
|
|
4064
|
+
// BAPI-1699: pending saved commands are tried exactly as assessed: no model, no candidates,
|
|
4065
|
+
// no owner command, and no PUT. The request is bound to the assessed generation.
|
|
4066
|
+
const pendingSaved = gatePlan?.testCommandTrial?.saved;
|
|
4067
|
+
if (ownerCommand === undefined && pendingSaved !== undefined && pendingSaved.trialState !== "passed") {
|
|
4068
|
+
await runSavedTrial(deps, access, baseUrl, state, policyResult, pendingSaved.commands, pendingSaved.generation);
|
|
4069
|
+
return;
|
|
4070
|
+
}
|
|
3834
4071
|
const automatic = ownerCommand === undefined && gatePlan?.testCommandTrial?.eligible === true;
|
|
3835
4072
|
if (ownerCommand === undefined && !automatic)
|
|
3836
4073
|
return;
|
|
@@ -3847,7 +4084,7 @@ answer) {
|
|
|
3847
4084
|
// A policy change the owner deferred only holds the trial back when it WAS the gate the
|
|
3848
4085
|
// command attaches to; an unrelated deferral never stops a confirmed gate's command proof.
|
|
3849
4086
|
if ((policyResult?.status === "deferred" || policyResult?.status === "unknown") && !current.confirmed) {
|
|
3850
|
-
deps.log(" skipped — the gate and defaults were not stored, so there is no stored gate
|
|
4087
|
+
deps.log(" skipped — the gate and defaults were not stored, so there is no stored gate for a tested command to attach to.");
|
|
3851
4088
|
return;
|
|
3852
4089
|
}
|
|
3853
4090
|
const candidates = automatic ? gatePlan?.testCommandTrial?.candidates : undefined;
|
|
@@ -3902,12 +4139,16 @@ function settleCiPlan(deps, state, gatePlan) {
|
|
|
3902
4139
|
deps.log("");
|
|
3903
4140
|
// BAPI-1654: "no CI" is said only when no CI files exist. No reported checks is not no CI.
|
|
3904
4141
|
const systems = state.ciSystems ?? [];
|
|
4142
|
+
// BAPI-1701: a test command that was never found did not "fail a trial run"; say which it was.
|
|
4143
|
+
const noCommandFound = state.trial?.status === "no_command" && isInformationalNoCommandReason(state.trial.reason);
|
|
4144
|
+
const commandFact = noCommandFound ? "Bridge found no test command" : "no test command passed the trial run";
|
|
4145
|
+
const gateWord = noCommandFound ? "local test gate" : "test gate";
|
|
3905
4146
|
deps.log(systems.length > 0
|
|
3906
4147
|
? `Bridge found CI configuration (${[...new Set(systems.map((s) => s.name))].join(", ")}) but no checks have ` +
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
:
|
|
3910
|
-
|
|
4148
|
+
`reported from it yet, and ${commandFact}. Child pull requests will merge into the epic ` +
|
|
4149
|
+
`branch without a ${gateWord}. You review everything in the final pull request.`
|
|
4150
|
+
: `Bridge found no CI and ${noCommandFound ? "no test command" : commandFact}. Child pull requests will merge into the epic ` +
|
|
4151
|
+
`branch without a ${gateWord}. You review everything in the final pull request.`);
|
|
3911
4152
|
}
|
|
3912
4153
|
}
|
|
3913
4154
|
// ---------------------------------------------------------------------------
|
|
@@ -3933,7 +4174,7 @@ async function offerManagedWorkflow(deps) {
|
|
|
3933
4174
|
recommended: "no",
|
|
3934
4175
|
recordingFlag: "no flag records this choice; rerun setup in an interactive terminal to be asked again.",
|
|
3935
4176
|
evidence: [
|
|
3936
|
-
"Bridge already runs your
|
|
4177
|
+
"Bridge already runs your test command, which passed the trial run, before each merge, so the gate works without it.",
|
|
3937
4178
|
"The workflow runs the same command on GitHub, only for pull requests into epic branches.",
|
|
3938
4179
|
],
|
|
3939
4180
|
consequences: [
|
|
@@ -4188,6 +4429,10 @@ function renderDryRunCiPlan(deps, options, gatePlan) {
|
|
|
4188
4429
|
deps.log(" Test command: a real run offers your --test-command to Bridge's server and proves it by running it once on " +
|
|
4189
4430
|
"this computer. Dry run requested nothing and started nothing.");
|
|
4190
4431
|
}
|
|
4432
|
+
else if (gatePlan?.testCommandTrial?.saved !== undefined) {
|
|
4433
|
+
deps.log(" Test command: a real run gives the saved test commands a trial run in a clean checkout and relies on them " +
|
|
4434
|
+
"only once they passed the trial run. The model is not consulted. Dry run requested nothing and started nothing.");
|
|
4435
|
+
}
|
|
4191
4436
|
else if (gatePlan?.testCommandTrial?.eligible === true) {
|
|
4192
4437
|
deps.log(" Test command: a real run asks Bridge's server to learn it from this repository and proves it by running it " +
|
|
4193
4438
|
"once on this computer, and nobody is asked for it. Dry run requested nothing and started nothing.");
|
|
@@ -4199,7 +4444,7 @@ function renderDryRunCiPlan(deps, options, gatePlan) {
|
|
|
4199
4444
|
"is added only if the command passes."
|
|
4200
4445
|
: " CI plan: no CI reported. A local test gate is stored only if the command passes; otherwise the gate has " +
|
|
4201
4446
|
"no members.");
|
|
4202
|
-
deps.log(" Bridge's workflow: offered once, only for a
|
|
4447
|
+
deps.log(" Bridge's workflow: offered once, only for a local plan whose command passed the trial run, and only added if you say yes and the setup " +
|
|
4203
4448
|
"pull request opens. Dry run asked nothing and opened nothing.");
|
|
4204
4449
|
}
|
|
4205
4450
|
}
|
|
@@ -4480,6 +4725,7 @@ async function collectDecisionEvidence(input) {
|
|
|
4480
4725
|
trialEligible,
|
|
4481
4726
|
candidate: gatePlan?.testCommandTrial?.candidates[0]?.command ?? null,
|
|
4482
4727
|
ownerCommandSupplied: options.testCommand !== undefined,
|
|
4728
|
+
...(gatePlan?.testCommandTrial?.saved !== undefined ? { saved: gatePlan.testCommandTrial.saved } : {}),
|
|
4483
4729
|
},
|
|
4484
4730
|
setupPr: {
|
|
4485
4731
|
applicable: setupPrOffersWorkflow(input),
|
|
@@ -4509,6 +4755,13 @@ async function collectDecisionEvidence(input) {
|
|
|
4509
4755
|
...(setupPrOffersWorkflow(input) && workflowState !== "installed" ? { managedWorkflowViaSetupPr: true } : {}),
|
|
4510
4756
|
},
|
|
4511
4757
|
launchProfile: { selected: options.launchProfile ?? null, notification: state.evidence.notification?.state ?? null },
|
|
4758
|
+
// BAPI-1719: from the same collected evidence and planned-fix list setup uses. Present only
|
|
4759
|
+
// when the fix is planned, so every proposal without it keeps its exact evidence and digest.
|
|
4760
|
+
...(fixes.includes("tool_visibility")
|
|
4761
|
+
? { toolVisibility: { planned: true, configPaths: state.evidence.toolVisibility?.state === "needs_merge" ? [...state.evidence.toolVisibility.configPaths] : [] } }
|
|
4762
|
+
: {}),
|
|
4763
|
+
// BAPI-1526: present only when the fix is planned, so every other proposal keeps its digest.
|
|
4764
|
+
...(fixes.includes("qualify_gate") ? { qualifyGate: { planned: true } } : {}),
|
|
4512
4765
|
repositoryFacts: {
|
|
4513
4766
|
...(await collectRepositoryFacts(deps, grantInventory, input.readToolchains)),
|
|
4514
4767
|
...(state.ciSystems !== undefined
|
|
@@ -4656,8 +4909,44 @@ function settledGateResults(proposal) {
|
|
|
4656
4909
|
.filter((a) => (a.key === "gate" || DECLARATION_KEYS.includes(a.key)) && a.intent === "write")
|
|
4657
4910
|
.map((a) => ({ key: a.key, status: "unchanged", target: a.effect?.target ?? "repository_gate" }));
|
|
4658
4911
|
}
|
|
4912
|
+
/** BAPI-1701: the runbook section that names the `stored_malformed: true` recovery. */
|
|
4913
|
+
const MALFORMED_GATE_FIX = "Ask Bridge support, or follow the operator runbook's `stored_malformed: true` recovery. " +
|
|
4914
|
+
"The stored value is kept as it is. Rerunning setup will not repair it.";
|
|
4915
|
+
/**
|
|
4916
|
+
* BAPI-1701: a setup that ends with no stored gate says why, with a remedy that can make progress.
|
|
4917
|
+
* Only an inferred plan with no write and no confirmed gate qualifies. A plan with `write: null`
|
|
4918
|
+
* is never read as a stored gate, and a confirmed stored gate never reaches this.
|
|
4919
|
+
*/
|
|
4920
|
+
export function unresolvedGateResult(plan) {
|
|
4921
|
+
const inferred = plan.inferred;
|
|
4922
|
+
if (inferred === undefined || plan.write !== null || plan.current.confirmed)
|
|
4923
|
+
return null;
|
|
4924
|
+
const target = "repository_gate";
|
|
4925
|
+
if (inferred.storedUnreadable) {
|
|
4926
|
+
return { key: "gate", status: "unattempted", target, reason: "the stored gate could not be read, so setup left it alone", fix: MALFORMED_GATE_FIX };
|
|
4927
|
+
}
|
|
4928
|
+
if (inferred.historyUnavailable === true) {
|
|
4929
|
+
return {
|
|
4930
|
+
key: "gate",
|
|
4931
|
+
status: "unattempted",
|
|
4932
|
+
target,
|
|
4933
|
+
reason: "Bridge could not read this repository's CI history, so it stored no gate",
|
|
4934
|
+
fix: "Check GitHub access, sign-in, or the app installation for this repository, then rerun setup.",
|
|
4935
|
+
};
|
|
4936
|
+
}
|
|
4937
|
+
if (inferred.watchedUnsupported) {
|
|
4938
|
+
return {
|
|
4939
|
+
key: "gate",
|
|
4940
|
+
status: "unattempted",
|
|
4941
|
+
target,
|
|
4942
|
+
reason: "this server cannot store the watched CI checks Bridge found, so it stored no gate",
|
|
4943
|
+
fix: "Update the Bridge API, then rerun setup. Nothing was replaced.",
|
|
4944
|
+
};
|
|
4945
|
+
}
|
|
4946
|
+
return null;
|
|
4947
|
+
}
|
|
4659
4948
|
const DECLARATION_KEYS = ["dependency_install", "ci_database", "must_order_paths", "worker_database"];
|
|
4660
|
-
function gateWriteResults(result, proposal, plan,
|
|
4949
|
+
export function gateWriteResults(result, proposal, plan,
|
|
4661
4950
|
/** BAPI-1677 — the install commands read back after the write; `null` when they could not be confirmed. */
|
|
4662
4951
|
installReadBack) {
|
|
4663
4952
|
const readBack = result.current !== undefined ? { revision: result.current.state.revision } : undefined;
|
|
@@ -4670,8 +4959,9 @@ installReadBack) {
|
|
|
4670
4959
|
status,
|
|
4671
4960
|
target: "repository_gate",
|
|
4672
4961
|
...(readBack !== undefined ? { read_back: readBack } : {}),
|
|
4673
|
-
|
|
4674
|
-
...(status === "
|
|
4962
|
+
// BAPI-1701: the validated category picks the reason and the one fix. No category keeps the bounded fallback.
|
|
4963
|
+
...(status === "refused" ? formatSetupPolicyRefusal(result.refusal) : {}),
|
|
4964
|
+
...(status === "uncertain" ? formatSetupPolicyRefusal(result.refusal, true) : {}),
|
|
4675
4965
|
};
|
|
4676
4966
|
if (proposal === null)
|
|
4677
4967
|
return [gate];
|
|
@@ -4696,6 +4986,8 @@ function testCommandAnswer(d) {
|
|
|
4696
4986
|
return undefined;
|
|
4697
4987
|
if (d.kind === "command")
|
|
4698
4988
|
return { decision: "command", command: d.command };
|
|
4989
|
+
if (d.kind === "commands")
|
|
4990
|
+
return { decision: "commands", commands: d.commands };
|
|
4699
4991
|
if (d.kind === "option" && (d.option === "learn" || d.option === "skip" || d.option === "keep"))
|
|
4700
4992
|
return { decision: d.option };
|
|
4701
4993
|
return undefined;
|
|
@@ -4704,6 +4996,13 @@ function testCommandAnswer(d) {
|
|
|
4704
4996
|
export const NO_TEST_COMMAND_REASON = "Bridge found no test command in this repository";
|
|
4705
4997
|
/** BAPI-1657: the plain owner-facing reason when the server could not read the testing instructions. */
|
|
4706
4998
|
export const NO_COMMAND_RETRY_REASON = "the server could not read the repository's testing instructions just now";
|
|
4999
|
+
/** BAPI-1701: why a found candidate was not usable, one plain line per rejection reason. */
|
|
5000
|
+
const NO_COMMAND_REJECTION_REASON = Object.freeze({
|
|
5001
|
+
working_directory_unsupported: "the test command has to run from a subdirectory, which a gate cannot do",
|
|
5002
|
+
not_plain_argv: "the test command is not a plain program and arguments",
|
|
5003
|
+
command_not_allowed: "the test command is not one Bridge allows",
|
|
5004
|
+
invalid_command: "the test command is not valid",
|
|
5005
|
+
});
|
|
4707
5006
|
/**
|
|
4708
5007
|
* BAPI-1657: the launcher text for an owner-run command. The detected launcher wins,
|
|
4709
5008
|
* then the published package. A detection failure falls back to the published package.
|
|
@@ -4718,6 +5017,10 @@ async function detectedLauncherBase(deps, repoName) {
|
|
|
4718
5017
|
}
|
|
4719
5018
|
return (detected ?? NPM_SETUP_LAUNCHER).base;
|
|
4720
5019
|
}
|
|
5020
|
+
/** BAPI-1701: whether this no-command reason's remedy runs `install epic-implementer --test-command`. */
|
|
5021
|
+
function needsLauncherRemedy(reason) {
|
|
5022
|
+
return reason === "working_directory_unsupported" || reason === "not_plain_argv" || reason === "command_not_allowed" || reason === "invalid_command";
|
|
5023
|
+
}
|
|
4721
5024
|
/** The learned check's own entry, carrying child 3's phase. `null` when no trial ran and none was asked for. */
|
|
4722
5025
|
export function trialWriteResult(trial, asked, launcher) {
|
|
4723
5026
|
const target = "repository_gate.local_commands";
|
|
@@ -4725,18 +5028,41 @@ export function trialWriteResult(trial, asked, launcher) {
|
|
|
4725
5028
|
return asked ? { key: "test_command", status: "unchanged", target, reason: "no trial was needed for the stored gate" } : null;
|
|
4726
5029
|
const phase = "evidence" in trial && trial.evidence !== undefined ? trial.evidence.phase : null;
|
|
4727
5030
|
switch (trial.status) {
|
|
4728
|
-
case "no_command":
|
|
4729
|
-
// BAPI-
|
|
5031
|
+
case "no_command": {
|
|
5032
|
+
// BAPI-1701: a genuine absence is information. The local gate is simply not there; setup is not incomplete for it.
|
|
5033
|
+
if (isInformationalNoCommandReason(trial.reason)) {
|
|
5034
|
+
return { key: "test_command", status: "unchanged", target, reason: NO_COMMAND_INFORMATION_TEXT };
|
|
5035
|
+
}
|
|
4730
5036
|
if (trial.reason === "llm_unavailable") {
|
|
4731
5037
|
return { key: "test_command", status: "failed", target, reason: NO_COMMAND_RETRY_REASON, fix: "Rerun setup to try reading the repository's testing instructions again." };
|
|
4732
5038
|
}
|
|
5039
|
+
if (trial.reason === "llm_output_invalid") {
|
|
5040
|
+
return {
|
|
5041
|
+
key: "test_command",
|
|
5042
|
+
status: "failed",
|
|
5043
|
+
target,
|
|
5044
|
+
reason: "the server could not turn the repository's testing instructions into a command",
|
|
5045
|
+
fix: "Rerun setup to try again. If it fails again, update the repository's testing instructions (run /learn-repository) so a command can be read from them.",
|
|
5046
|
+
};
|
|
5047
|
+
}
|
|
5048
|
+
if (trial.reason === "generation_superseded") {
|
|
5049
|
+
return {
|
|
5050
|
+
key: "test_command",
|
|
5051
|
+
status: "failed",
|
|
5052
|
+
target,
|
|
5053
|
+
reason: "the saved test commands changed after you approved them",
|
|
5054
|
+
fix: "Rerun setup to review and approve a fresh proposal; nothing was stored from the old one.",
|
|
5055
|
+
};
|
|
5056
|
+
}
|
|
5057
|
+
// BAPI-1657: the owner-facing remedy names the launcher the owner runs in their own terminal.
|
|
4733
5058
|
return {
|
|
4734
5059
|
key: "test_command",
|
|
4735
5060
|
status: "failed",
|
|
4736
5061
|
target,
|
|
4737
|
-
reason:
|
|
4738
|
-
fix:
|
|
5062
|
+
reason: NO_COMMAND_REJECTION_REASON[trial.reason],
|
|
5063
|
+
fix: `${CANDIDATE_REJECTION_FIX[trial.reason]} In your own terminal, run \`${launcher ?? NPM_SETUP_LAUNCHER.base} install epic-implementer --test-command "<your command>"\` with a command that meets this.`,
|
|
4739
5064
|
};
|
|
5065
|
+
}
|
|
4740
5066
|
case "promoted":
|
|
4741
5067
|
return { key: "test_command", status: "written", target, phase, read_back: { commands: trial.commands.map((c) => c.name), ran: trial.commands.map((c) => c.command) } };
|
|
4742
5068
|
case "not_needed":
|
|
@@ -4745,8 +5071,20 @@ export function trialWriteResult(trial, asked, launcher) {
|
|
|
4745
5071
|
return { key: "test_command", status: "uncertain", target, phase, reason: `the trial's completion is unknown (${trial.reason})`, fix: "Rerun setup to read the trial again; it is not started twice." };
|
|
4746
5072
|
case "unqualified":
|
|
4747
5073
|
case "stale":
|
|
4748
|
-
case "could_not_run":
|
|
4749
|
-
|
|
5074
|
+
case "could_not_run": {
|
|
5075
|
+
// BAPI-1698: the remedy names what to change for THIS result. A deterministic
|
|
5076
|
+
// failure never gets "rerun setup" on its own: an unchanged retry fails again.
|
|
5077
|
+
const presentation = presentTrialResult({
|
|
5078
|
+
phase,
|
|
5079
|
+
dependencyInstallDeclared: trial.evidence?.dependencyInstallDeclared ?? null,
|
|
5080
|
+
interrupted: trial.status === "could_not_run",
|
|
5081
|
+
commandResults: trial.evidence?.commandResults ?? null,
|
|
5082
|
+
});
|
|
5083
|
+
const fix = trial.status === "stale"
|
|
5084
|
+
? "The gate changed while the trial ran; run setup again to try the current gate."
|
|
5085
|
+
: presentation.remedy ?? "Run setup again to read the trial result.";
|
|
5086
|
+
return { key: "test_command", status: "failed", target, phase, reason: `the check did not pass (${trial.status})`, fix };
|
|
5087
|
+
}
|
|
4750
5088
|
default:
|
|
4751
5089
|
return { key: "test_command", status: "failed", target, phase: null, reason: `the trial did not run (${trial.status})`, fix: "Rerun setup; if this persists, run `epic-implementer doctor`." };
|
|
4752
5090
|
}
|
|
@@ -4771,13 +5109,44 @@ export function workflowWriteResult(outcome, asked, decision) {
|
|
|
4771
5109
|
return { key: "setup_pr", status: outcome.status, target, reason: outcome.reason, fix: "Rerun setup once the cause above is fixed." };
|
|
4772
5110
|
}
|
|
4773
5111
|
}
|
|
5112
|
+
/** BAPI-1526 — why a declined gate qualification leaves the item outstanding. */
|
|
5113
|
+
const QUALIFY_GATE_DECLINED_REASON = "the gate was not qualified, so unattended runs that rely on it stay refused";
|
|
5114
|
+
/**
|
|
5115
|
+
* BAPI-1526 — one `qualify_gate` write result per qualification report. The text is
|
|
5116
|
+
* fixed; the qualification phase already printed its own explanation above.
|
|
5117
|
+
*/
|
|
5118
|
+
export function qualifyGateWriteResult(report, target) {
|
|
5119
|
+
const rerun = `Fix the cause above, then rerun setup or run ${PRINTED_QUALIFY_GATE_COMMAND}.`;
|
|
5120
|
+
switch (report) {
|
|
5121
|
+
case "qualified":
|
|
5122
|
+
return { key: "qualify_gate", status: "written", target };
|
|
5123
|
+
case "not_applicable":
|
|
5124
|
+
return { key: "qualify_gate", status: "unchanged", target, reason: "the stored gate has no local commands to qualify" };
|
|
5125
|
+
case "queued":
|
|
5126
|
+
case "running":
|
|
5127
|
+
case "unverified":
|
|
5128
|
+
return { key: "qualify_gate", status: "uncertain", target, reason: "the qualification has not finished, or its result could not be read", fix: `Check readiness, or run ${PRINTED_QUALIFY_GATE_COMMAND}.` };
|
|
5129
|
+
case "failed":
|
|
5130
|
+
case "could_not_run":
|
|
5131
|
+
case "stale":
|
|
5132
|
+
case "refused":
|
|
5133
|
+
return { key: "qualify_gate", status: "failed", target, reason: `the gate qualification ${report === "failed" ? "failed" : report === "could_not_run" ? "could not run" : report === "stale" ? "was for an older gate revision" : "was refused"}`, fix: rerun };
|
|
5134
|
+
}
|
|
5135
|
+
}
|
|
5136
|
+
/** BAPI-1718 — why a reference answer did nothing when a merge token is already stored. Fixed text. */
|
|
5137
|
+
const MERGE_TOKEN_REFERENCE_UNUSED_REASON = "a merge token is already stored for this repository, so the reference was not used. " +
|
|
5138
|
+
"To replace it, run install epic-implementer --remove-merge-token, then rerun setup";
|
|
4774
5139
|
function fixOutcomeResult(key, target, outcome) {
|
|
4775
5140
|
if (outcome.status === "failed") {
|
|
4776
|
-
return { key, status: "failed", target, reason: outcome.reason, fix: "Fix the cause above, then rerun setup with the same answers." };
|
|
5141
|
+
return { key, status: "failed", target, reason: outcome.reason, fix: outcome.fix ?? "Fix the cause above, then rerun setup with the same answers." };
|
|
5142
|
+
}
|
|
5143
|
+
if (outcome.status === "unattempted") {
|
|
5144
|
+
return { key, status: "unattempted", target, reason: outcome.reason, fix: outcome.fix };
|
|
4777
5145
|
}
|
|
4778
5146
|
// BAPI-1667: fixed advisory text only. It reports; it never changes the status.
|
|
4779
5147
|
const advisories = [...new Set(outcome.advisories ?? [])];
|
|
4780
|
-
|
|
5148
|
+
const reason = outcome.reason ?? (advisories.length > 0 ? advisories.join(" ") : undefined);
|
|
5149
|
+
return { key, status: outcome.status, target, ...(reason !== undefined ? { reason } : {}) };
|
|
4781
5150
|
}
|
|
4782
5151
|
function indexProgress(index) {
|
|
4783
5152
|
if (index.state === "reached")
|
|
@@ -5033,7 +5402,7 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5033
5402
|
}
|
|
5034
5403
|
const readToolchains = snapshotToolchainReader(setup, snapshot);
|
|
5035
5404
|
// ---- The review default: explicit flag, then what is stored, then the remote workflow ----
|
|
5036
|
-
const reviewDefault = await resolveReviewDefault(deps, options,
|
|
5405
|
+
const reviewDefault = await resolveReviewDefault(deps, options, access, firstReport.readiness?.review_workflow);
|
|
5037
5406
|
renderReviewPolicy(deps, options, reviewDefault);
|
|
5038
5407
|
// ---- The gate: explicit flags win, a stored gate is kept, otherwise facts decide ----
|
|
5039
5408
|
// BAPI-1638: the answers path plans the gate without a terminal, so no discovered
|
|
@@ -5101,6 +5470,8 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5101
5470
|
if (setup.epicServer !== undefined) {
|
|
5102
5471
|
state.evidence = { ...state.evidence, epicServer: await assessEpicServer(setup.epicServer, access.repoName) };
|
|
5103
5472
|
}
|
|
5473
|
+
// BAPI-1719: whether the Bridge MCP entries load the Epic Implementer group, read-only. Its item is advisory.
|
|
5474
|
+
state.evidence = { ...state.evidence, toolVisibility: await collectToolVisibilityEvidence(deps.localProvisioning) };
|
|
5104
5475
|
// BAPI-1635: the selected profile's escalation declaration, read-only.
|
|
5105
5476
|
{
|
|
5106
5477
|
const notification = await collectNotificationEvidence(deps, options, baseUrl);
|
|
@@ -5124,6 +5495,14 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5124
5495
|
gateOrDefaultsNeedWrite: gateOrDefaultsNeedWrite(gatePlan, firstReport.readiness, reviewDefault),
|
|
5125
5496
|
suppliedPolicyInput: options.reviewPolicyExplicit || options.replaceDoneGate || hasExplicitGateInput(options.gate),
|
|
5126
5497
|
...(options.epicServerChange === true ? { epicServerChangeRequested: true } : {}),
|
|
5498
|
+
// BAPI-1526: the two gate-qualification facts. A gate revision with local commands this
|
|
5499
|
+
// pass writes (from explicit gate input, or setup's own policy write), with no test-command
|
|
5500
|
+
// trial in this pass that would qualify it, is offered qualification.
|
|
5501
|
+
...(options.gate.qualifyGate ? { qualifyGateRequested: true } : {}),
|
|
5502
|
+
...(gatePlan !== null && gatePlan.write !== null && gatePlan.desired.localCommands.length > 0
|
|
5503
|
+
&& options.testCommand === undefined && gatePlan.testCommandTrial?.eligible !== true
|
|
5504
|
+
? { explicitLocalGateUnproven: true }
|
|
5505
|
+
: {}),
|
|
5127
5506
|
};
|
|
5128
5507
|
const fixes = planSetupFixes(state.evidence, planContext);
|
|
5129
5508
|
// BAPI-1667: one read-only snapshot for both setup paths. An ordinary interactive run
|
|
@@ -5307,6 +5686,8 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5307
5686
|
}
|
|
5308
5687
|
let policyResult = null;
|
|
5309
5688
|
let epicServerChanged = false;
|
|
5689
|
+
// BAPI-1719: what the profile merge did, for the closing assessment and the closing line.
|
|
5690
|
+
let toolVisibilityApplied = null;
|
|
5310
5691
|
const answerOf = (key) => decisionFor(proposal, key);
|
|
5311
5692
|
const optionOf = (key) => {
|
|
5312
5693
|
const d = answerOf(key);
|
|
@@ -5335,6 +5716,10 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5335
5716
|
if (!gateOpen && approvedDeclarations.length === 0) {
|
|
5336
5717
|
if (proposal === null)
|
|
5337
5718
|
return null;
|
|
5719
|
+
// BAPI-1701: no planned write is not a stored gate. An unresolved plan says why, with its own fix.
|
|
5720
|
+
const unresolved = unresolvedGateResult(gatePlan);
|
|
5721
|
+
if (unresolved !== null)
|
|
5722
|
+
return [unresolved];
|
|
5338
5723
|
return settledGateResults(proposal);
|
|
5339
5724
|
}
|
|
5340
5725
|
const gateAnswer = proposal === null ? undefined : gateOpen ? (optionOf("gate") === "decline" ? "decline" : "approve") : "approve";
|
|
@@ -5368,7 +5753,10 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5368
5753
|
await runTestCommandPhase(deps, options, setup, access, baseUrl, state, gatePlan, policyResult, answer);
|
|
5369
5754
|
settleCiPlan(deps, state, gatePlan);
|
|
5370
5755
|
// BAPI-1657: only the no-command remedy needs the launcher text, so detection runs only for that outcome.
|
|
5371
|
-
|
|
5756
|
+
// BAPI-1701: and only for a rejected candidate. Informational and retry results name no command to enter.
|
|
5757
|
+
const launcher = state.trial?.status === "no_command" && needsLauncherRemedy(state.trial.reason)
|
|
5758
|
+
? await detectedLauncherBase(deps, access.repoName)
|
|
5759
|
+
: undefined;
|
|
5372
5760
|
const trialResult = trialWriteResult(state.trial, proposal !== null && answer !== undefined && answer.decision !== "skip" && answer.decision !== "keep", launcher);
|
|
5373
5761
|
// BAPI-1677: a replay names what the trial proved, so the setup record reads the same. The
|
|
5374
5762
|
// gate's local commands are that proof. The separate stored test command can still be unset.
|
|
@@ -5412,22 +5800,72 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5412
5800
|
key: "test_command",
|
|
5413
5801
|
run: async () => {
|
|
5414
5802
|
// ---- Explicit operations, each behind its own consent (unchanged) -------
|
|
5415
|
-
|
|
5416
|
-
&& policyResult?.status !== "deferred" && policyResult?.status !== "unknown"
|
|
5803
|
+
const qualifiable = gatePlan !== null && gatePlan.desired.localCommands.length > 0
|
|
5804
|
+
&& policyResult?.status !== "deferred" && policyResult?.status !== "unknown";
|
|
5805
|
+
if (options.gate.qualifyGate && qualifiable) {
|
|
5417
5806
|
await runConductorGateQualification(gateIo, access, deps.gate, {
|
|
5418
5807
|
revision: policyResult?.current?.state.revision ?? gatePlan.current.revision,
|
|
5419
5808
|
baseUrl,
|
|
5420
5809
|
});
|
|
5810
|
+
return null;
|
|
5811
|
+
}
|
|
5812
|
+
// BAPI-1526: the `qualify_gate` fix, behind its own consent. Same step, same revision.
|
|
5813
|
+
if (!fixes.includes("qualify_gate"))
|
|
5814
|
+
return null;
|
|
5815
|
+
const target = "repository_gate.qualification";
|
|
5816
|
+
// A test-command trial in this pass already qualifies the gate (promoted), or is still finishing
|
|
5817
|
+
// the same job (uncertain). Asking again would be redundant, so nothing is asked or queued.
|
|
5818
|
+
if (state.trial?.status === "promoted" || state.trial?.status === "uncertain") {
|
|
5819
|
+
return { key: "qualify_gate", status: "unchanged", target, reason: "the test-command check in this pass qualifies the gate" };
|
|
5820
|
+
}
|
|
5821
|
+
if (proposal !== null) {
|
|
5822
|
+
const d = answerOf("qualify_gate");
|
|
5823
|
+
if (d === undefined)
|
|
5824
|
+
return null;
|
|
5825
|
+
if (d.kind === "decline")
|
|
5826
|
+
return { key: "qualify_gate", status: "declined", target, reason: QUALIFY_GATE_DECLINED_REASON };
|
|
5827
|
+
}
|
|
5828
|
+
else {
|
|
5829
|
+
if (deps.promptLine === undefined) {
|
|
5830
|
+
return { key: "qualify_gate", status: "declined", target, reason: "there is no interactive terminal, so the gate was not qualified" };
|
|
5831
|
+
}
|
|
5832
|
+
deps.log("");
|
|
5833
|
+
deps.log("Gate qualification");
|
|
5834
|
+
deps.log(" The local gate must pass once under the executor before an unattended run is admitted. Setup will run it now if you approve.");
|
|
5835
|
+
if (!(await confirm(deps, "Run the local gate once now to qualify it? [y/N]: "))) {
|
|
5836
|
+
deps.log(` declined — ${QUALIFY_GATE_DECLINED_REASON}.`);
|
|
5837
|
+
return { key: "qualify_gate", status: "declined", target, reason: QUALIFY_GATE_DECLINED_REASON };
|
|
5838
|
+
}
|
|
5839
|
+
}
|
|
5840
|
+
if (!qualifiable) {
|
|
5841
|
+
return { key: "qualify_gate", status: "unattempted", target, reason: "the gate this pass would qualify was not stored", fix: "Rerun setup once the gate is stored." };
|
|
5842
|
+
}
|
|
5843
|
+
let report;
|
|
5844
|
+
try {
|
|
5845
|
+
report = await runConductorGateQualification(gateIo, access, deps.gate, {
|
|
5846
|
+
revision: policyResult?.current?.state.revision ?? gatePlan.current.revision,
|
|
5847
|
+
baseUrl,
|
|
5848
|
+
});
|
|
5849
|
+
}
|
|
5850
|
+
catch {
|
|
5851
|
+
return { key: "qualify_gate", status: "uncertain", target, reason: "the qualification's result is unknown", fix: `Check readiness, or run ${PRINTED_QUALIFY_GATE_COMMAND}.` };
|
|
5421
5852
|
}
|
|
5422
|
-
|
|
5853
|
+
// A local result is reported only. The closing verdict still comes from the server's refreshed report.
|
|
5854
|
+
return qualifyGateWriteResult(report, target);
|
|
5423
5855
|
},
|
|
5424
5856
|
},
|
|
5425
5857
|
{
|
|
5426
5858
|
key: "merge_token",
|
|
5427
5859
|
run: async () => {
|
|
5428
5860
|
if (!fixes.includes("merge_token") || state.identity === null) {
|
|
5429
|
-
|
|
5430
|
-
|
|
5861
|
+
if (proposal === null || answerOf("merge_token")?.kind !== "reference")
|
|
5862
|
+
return null;
|
|
5863
|
+
// BAPI-1718: a reference answered against an already configured token is a deliberate
|
|
5864
|
+
// no-op. Say so, without resolving the reference or touching the credential store.
|
|
5865
|
+
// The reason lives here only; the setup record's stable "in place" row is unchanged.
|
|
5866
|
+
return fixes.includes("merge_token")
|
|
5867
|
+
? { key: "merge_token", status: "unchanged", target: "merge_token" }
|
|
5868
|
+
: { key: "merge_token", status: "unchanged", target: "merge_token", reason: MERGE_TOKEN_REFERENCE_UNUSED_REASON };
|
|
5431
5869
|
}
|
|
5432
5870
|
const d = answerOf("merge_token");
|
|
5433
5871
|
const answer = proposal === null || d === undefined ? undefined
|
|
@@ -5457,14 +5895,33 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5457
5895
|
{
|
|
5458
5896
|
key: "worker_mcp_grant",
|
|
5459
5897
|
run: async () => {
|
|
5460
|
-
if (
|
|
5461
|
-
return
|
|
5462
|
-
: { key: "worker_mcp_grant", status: "unchanged", target: "mcp_grant" };
|
|
5463
|
-
}
|
|
5898
|
+
if (setup.mcpGrant === undefined)
|
|
5899
|
+
return null;
|
|
5464
5900
|
const d = answerOf("worker_mcp_grant");
|
|
5901
|
+
const planned = fixes.includes("mcp_grant");
|
|
5902
|
+
// BAPI-1718: a stated selection reaches the writer whether or not the grant was planned
|
|
5903
|
+
// as a fix. Before, a settled grant answered "unchanged" and silently wrote nothing.
|
|
5904
|
+
const stated = proposal !== null && d?.kind === "selection";
|
|
5905
|
+
// Not planned, and no selection to apply: absent, keep, and decline all change nothing.
|
|
5906
|
+
if (!planned && !stated)
|
|
5907
|
+
return null;
|
|
5908
|
+
if (grantInventory === null) {
|
|
5909
|
+
// A planned grant with no stated selection keeps its earlier behavior: nothing to do.
|
|
5910
|
+
if (!stated)
|
|
5911
|
+
return null;
|
|
5912
|
+
return {
|
|
5913
|
+
key: "worker_mcp_grant",
|
|
5914
|
+
status: "unattempted",
|
|
5915
|
+
target: "mcp_grant",
|
|
5916
|
+
reason: "the MCP servers could not be inspected, so the approved selection was not written",
|
|
5917
|
+
fix: "Rerun setup with the same answers.",
|
|
5918
|
+
};
|
|
5919
|
+
}
|
|
5465
5920
|
const answer = proposal === null || d === undefined ? undefined
|
|
5466
5921
|
: d.kind === "selection" ? { decision: "select", ids: d.ids } : { decision: "decline" };
|
|
5467
|
-
const outcome = await fixMcpGrant(deps, setup.mcpGrant, access.repoName, grantInventory, answer, sfccGrantIds(epicServerSnapshot, grantInventory)
|
|
5922
|
+
const outcome = await fixMcpGrant(deps, setup.mcpGrant, access.repoName, grantInventory, answer, sfccGrantIds(epicServerSnapshot, grantInventory),
|
|
5923
|
+
// Only the newly enabled path (a settled grant) is protected from losing servers.
|
|
5924
|
+
stated && !planned ? { keepStored: true } : {});
|
|
5468
5925
|
return fixOutcomeResult("worker_mcp_grant", "mcp_grant", outcome);
|
|
5469
5926
|
},
|
|
5470
5927
|
},
|
|
@@ -5591,13 +6048,69 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5591
6048
|
return written;
|
|
5592
6049
|
},
|
|
5593
6050
|
},
|
|
6051
|
+
{
|
|
6052
|
+
// BAPI-1719: the local MCP profile merge, last, behind terminal or answers approval.
|
|
6053
|
+
// It never gates readiness: a decline, a failure, or an unknown read stays advisory.
|
|
6054
|
+
key: "tool_visibility",
|
|
6055
|
+
run: async () => {
|
|
6056
|
+
const local = deps.localProvisioning;
|
|
6057
|
+
// No planned fix (including a stated conditional answer whose choice is gone) means no apply.
|
|
6058
|
+
if (!fixes.includes("tool_visibility") || local === undefined)
|
|
6059
|
+
return null;
|
|
6060
|
+
const target = "host_mcp_profile";
|
|
6061
|
+
const paths = state.evidence.toolVisibility?.state === "needs_merge" ? state.evidence.toolVisibility.configPaths : [];
|
|
6062
|
+
if (proposal !== null) {
|
|
6063
|
+
const d = answerOf("tool_visibility");
|
|
6064
|
+
if (d === undefined || (d.kind === "option" && d.option === "keep"))
|
|
6065
|
+
return null;
|
|
6066
|
+
if (d.kind === "decline") {
|
|
6067
|
+
return { key: "tool_visibility", status: "declined", target, reason: "no MCP configuration was changed" };
|
|
6068
|
+
}
|
|
6069
|
+
}
|
|
6070
|
+
else {
|
|
6071
|
+
// The terminal path: the phased y/N wording. Without a terminal this is "no", and nothing is asked.
|
|
6072
|
+
if (deps.promptLine === undefined)
|
|
6073
|
+
return { key: "tool_visibility", status: "declined", target, reason: "there is no interactive terminal, so no MCP configuration was changed" };
|
|
6074
|
+
deps.log("");
|
|
6075
|
+
deps.log("Epic Implementer tools in your editor");
|
|
6076
|
+
deps.log(` ${paths.length > 0 ? paths.join(", ") : "Your MCP configuration"} does not load the epic_implementer group yet. Approving adds it to the existing Bridge entry and keeps your other groups; you then restart your MCP client.`);
|
|
6077
|
+
const consented = await confirm(deps, "Update existing supported host MCP configurations (.mcp.json, .vscode/mcp.json, " +
|
|
6078
|
+
".cursor/mcp.json) to add the `epic_implementer` profile? [y/N]: ");
|
|
6079
|
+
if (!consented) {
|
|
6080
|
+
deps.log(" declined — no host MCP configuration was changed.");
|
|
6081
|
+
return { key: "tool_visibility", status: "declined", target, reason: "no MCP configuration was changed" };
|
|
6082
|
+
}
|
|
6083
|
+
}
|
|
6084
|
+
const result = await applyToolVisibility(deps, local);
|
|
6085
|
+
toolVisibilityApplied = result;
|
|
6086
|
+
for (const note of result.notes)
|
|
6087
|
+
deps.errorLog(` note: ${note}`);
|
|
6088
|
+
// A failure is advisory, but never silent: fixed wording and fixed paths only.
|
|
6089
|
+
if (result.outcome === "failed") {
|
|
6090
|
+
deps.errorLog(` ${result.failure ?? TOOL_VISIBILITY_FAILURE_TEXT.write}${result.failurePaths.length > 0 ? ` (${result.failurePaths.join(", ")})` : ""}; the MCP profile was not changed by setup.`);
|
|
6091
|
+
}
|
|
6092
|
+
if (result.outcome === "written") {
|
|
6093
|
+
deps.log(` updated: ${(result.changedPaths.length > 0 ? result.changedPaths : result.carryingPaths).join(", ")}`);
|
|
6094
|
+
// Coverage honesty: the merge path writes these three files and no others.
|
|
6095
|
+
deps.log(" Codex and Copilot host configuration was NOT inspected or changed.");
|
|
6096
|
+
}
|
|
6097
|
+
const guidance = result.guidance.join(" ");
|
|
6098
|
+
const outcome = result.outcome === "failed"
|
|
6099
|
+
? { status: "failed", reason: `${result.failure ?? TOOL_VISIBILITY_FAILURE_TEXT.write}${result.failurePaths.length > 0 ? ` (${result.failurePaths.join(", ")})` : ""}`, ...(guidance.length > 0 ? { fix: guidance } : {}) }
|
|
6100
|
+
: result.outcome === "written"
|
|
6101
|
+
? { status: "written", advisories: [...result.advisories, ...result.guidance] }
|
|
6102
|
+
: { status: "unchanged", ...(result.outcome === "no_entry" ? { advisories: ["no supported Bridge entry exists, so nothing was written (setup never creates one)"] } : {}) };
|
|
6103
|
+
const written = fixOutcomeResult("tool_visibility", target, outcome);
|
|
6104
|
+
return result.outcome === "written" ? { ...written, read_back: { config_paths: result.changedPaths.length > 0 ? result.changedPaths : result.carryingPaths } } : written;
|
|
6105
|
+
},
|
|
6106
|
+
},
|
|
5594
6107
|
];
|
|
5595
6108
|
// The interactive path keeps its original question order: the missing-item fixes
|
|
5596
6109
|
// (merge token, re-index, grant, epic server) come right after the gate and before
|
|
5597
6110
|
// the learned check, the setup PR, and qualification. The answers path runs the
|
|
5598
6111
|
// array as written so the learned check and setup PR chain on the gate.
|
|
5599
6112
|
const ordered = proposal !== null ? operations
|
|
5600
|
-
: [operations[0], ...operations.slice(4, 8), ...operations.slice(1, 4), operations[8], operations[9]];
|
|
6113
|
+
: [operations[0], ...operations.slice(4, 8), ...operations.slice(1, 4), operations[8], operations[9], operations[10]];
|
|
5601
6114
|
const firstApply = await applyInstallProposal({ proposal, digest: proposalDigest, refusal: null }, { operations: ordered });
|
|
5602
6115
|
const applied = firstApply.kind === "applied" ? firstApply.result : { complete: false, results: [] };
|
|
5603
6116
|
if (options.reviewPolicy === "verdict_protocol" && !options.skipWorkflow) {
|
|
@@ -5688,6 +6201,16 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5688
6201
|
? { ...closingEpicServer, statementError }
|
|
5689
6202
|
: closingEpicServer;
|
|
5690
6203
|
}
|
|
6204
|
+
// BAPI-1719: the same read-only collection, run again after the apply. A confirmed write whose
|
|
6205
|
+
// read-back does not show the group stays visible as `unknown` verification, never as satisfied.
|
|
6206
|
+
{
|
|
6207
|
+
const closingVisibility = await collectToolVisibilityEvidence(deps.localProvisioning);
|
|
6208
|
+
const applied = toolVisibilityApplied;
|
|
6209
|
+
closing.evidence.toolVisibility =
|
|
6210
|
+
applied?.outcome === "written" && closingVisibility.state !== "met"
|
|
6211
|
+
? { state: "unknown", reason: "verification" }
|
|
6212
|
+
: closingVisibility;
|
|
6213
|
+
}
|
|
5691
6214
|
// ---- BAPI-1260: the reusable launch profile (explicit) ------------------
|
|
5692
6215
|
// BAPI-1635: this runs BEFORE the final items are projected, so a profile saved by
|
|
5693
6216
|
// this invocation is read back and judged for escalation, not left as pre-save evidence.
|
|
@@ -5795,6 +6318,12 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5795
6318
|
if (r.fix !== undefined)
|
|
5796
6319
|
deps.log(` ${r.key}: ${r.fix}`);
|
|
5797
6320
|
}
|
|
6321
|
+
// BAPI-1719: once, after a confirmed profile write, even when its verification is unknown.
|
|
6322
|
+
// The same instruction rides in the structured write result's reason.
|
|
6323
|
+
if (toolVisibilityApplied?.outcome === "written") {
|
|
6324
|
+
deps.log("");
|
|
6325
|
+
deps.log(TOOL_VISIBILITY_RESTART_LINE);
|
|
6326
|
+
}
|
|
5798
6327
|
deps.installDocumentSink?.({
|
|
5799
6328
|
items,
|
|
5800
6329
|
decisions: decisionEvidence,
|
|
@@ -5807,10 +6336,28 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5807
6336
|
const ready = unmet.length === 0 && (proposal === null || applyResult.complete);
|
|
5808
6337
|
deps.log(setupVerdictLine(items));
|
|
5809
6338
|
// Exactly one next step: the first unmet blocking item's remedy, or the start command.
|
|
5810
|
-
|
|
6339
|
+
// BAPI-1701: when nothing blocks readiness but a write did not finish, the next step is that write's own
|
|
6340
|
+
// fix (the gate's first), the same one the structured verdict carries. The generic rerun is only the fallback.
|
|
6341
|
+
const writeNextStep = unmet.length === 0 && !ready && proposal !== null
|
|
6342
|
+
? applyResultNextStep(applyResult)
|
|
6343
|
+
: undefined;
|
|
6344
|
+
deps.log(writeNextStep ??
|
|
6345
|
+
`Next step: ${unmet.length === 0 ? (ready ? "Run drive-epic to start your first epic" : "Rerun setup with the same answers to finish the writes listed above") : setupItemRemedy(unmet[0])}`);
|
|
5811
6346
|
deps.log(ready ? "complete" : "complete-with-manual-steps");
|
|
5812
6347
|
return ready ? conductorInstallDoctorExitCode(finalReport) : 1;
|
|
5813
6348
|
}
|
|
6349
|
+
/**
|
|
6350
|
+
* BAPI-1701: the one next step drawn from the first incomplete write's own fix, the gate's before any other.
|
|
6351
|
+
* `undefined` when no incomplete write carries a fix. Pure text from the result; nothing is parsed.
|
|
6352
|
+
*/
|
|
6353
|
+
export function applyResultNextStep(applyResult) {
|
|
6354
|
+
const incomplete = applyResult.results.filter((r) => r.status === "failed" || r.status === "refused" || r.status === "uncertain" || r.status === "unattempted");
|
|
6355
|
+
const fix = (incomplete.find((r) => r.key === "gate" && r.fix !== undefined) ?? incomplete.find((r) => r.fix !== undefined))?.fix;
|
|
6356
|
+
if (fix === undefined)
|
|
6357
|
+
return undefined;
|
|
6358
|
+
const line = fix.replace(/\s+/g, " ").trim();
|
|
6359
|
+
return line.startsWith("Next step:") ? line : `Next step: ${line}`;
|
|
6360
|
+
}
|
|
5814
6361
|
/** BAPI-1678 — a readable stored gate, with required and watched checks apart. Anything else is unknown. */
|
|
5815
6362
|
function storedGateEvidence(profile) {
|
|
5816
6363
|
if (profile === null || profile === undefined || profile.read_failed || profile.stored_malformed || profile.kind === null)
|
|
@@ -5929,7 +6476,7 @@ async function closingMcpGrantState(grantDeps, repoName, inventory) {
|
|
|
5929
6476
|
? { state: "met" }
|
|
5930
6477
|
: { state: "needs_action", reason: "changed" };
|
|
5931
6478
|
}
|
|
5932
|
-
export async function fixMcpGrant(deps, grantDeps, repoName, inventory, answer, sfccRecommendedIds = []) {
|
|
6479
|
+
export async function fixMcpGrant(deps, grantDeps, repoName, inventory, answer, sfccRecommendedIds = [], options = {}) {
|
|
5933
6480
|
deps.log("");
|
|
5934
6481
|
deps.log("Worker MCP servers");
|
|
5935
6482
|
deps.log(` Epic Implementer workers in ${repoName} always get Bridge. You can approve extra MCP servers for them, ` +
|
|
@@ -5962,7 +6509,7 @@ export async function fixMcpGrant(deps, grantDeps, repoName, inventory, answer,
|
|
|
5962
6509
|
return { status: "declined" };
|
|
5963
6510
|
}
|
|
5964
6511
|
if (answer?.decision === "select")
|
|
5965
|
-
return publishApprovedGrant(deps, grantDeps, repoName, inventory, answer.ids);
|
|
6512
|
+
return publishApprovedGrant(deps, grantDeps, repoName, inventory, answer.ids, options);
|
|
5966
6513
|
if (!deps.promptLine) {
|
|
5967
6514
|
deps.log(" skipped approving MCP servers: there is no interactive terminal, so this counts as declined. Nothing changed.");
|
|
5968
6515
|
return { status: "declined" };
|
|
@@ -6042,25 +6589,55 @@ async function publishGrant(deps, grantDeps, repoName, inventory, selectedIds) {
|
|
|
6042
6589
|
* BAPI-1638 — the answers path: the selection is the approved option ids.
|
|
6043
6590
|
* A grant that already holds exactly these servers, for the same inventory, is
|
|
6044
6591
|
* `unchanged` and is not rewritten.
|
|
6592
|
+
*
|
|
6593
|
+
* BAPI-1718 — the stored names are compared whole, with no name filtered out, so a
|
|
6594
|
+
* selection that differs from what is stored is never reported `unchanged`.
|
|
6045
6595
|
*/
|
|
6046
|
-
async function publishApprovedGrant(deps, grantDeps, repoName, inventory, ids) {
|
|
6596
|
+
async function publishApprovedGrant(deps, grantDeps, repoName, inventory, ids, options = {}) {
|
|
6047
6597
|
const names = inventory.candidates
|
|
6048
6598
|
.filter((c) => c.definitions.some((d) => ids.includes(d.id)))
|
|
6049
6599
|
.map((c) => c.name)
|
|
6050
6600
|
.sort();
|
|
6601
|
+
let current;
|
|
6602
|
+
let readFailed = false;
|
|
6051
6603
|
try {
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6604
|
+
current = await grantDeps.readGrant(repoName);
|
|
6605
|
+
}
|
|
6606
|
+
catch {
|
|
6607
|
+
readFailed = true;
|
|
6608
|
+
}
|
|
6609
|
+
// The keep-stored guard protects a settled grant's selections within this one setup run: it
|
|
6610
|
+
// reads the grant fresh, just before any publish, and refuses to drop an approved server. It
|
|
6611
|
+
// takes no lock (a concurrent edit between the read and the write is not prevented) and it
|
|
6612
|
+
// does not change how a planned replacement behaves, which never sets the flag.
|
|
6613
|
+
if (options.keepStored === true) {
|
|
6614
|
+
if (readFailed || current === undefined || current.state === "unusable") {
|
|
6615
|
+
deps.log(" The approved MCP servers could not be read. Nothing changed.");
|
|
6616
|
+
return {
|
|
6617
|
+
status: "unattempted",
|
|
6618
|
+
reason: "the approved MCP servers could not be read, so the selection was not written",
|
|
6619
|
+
fix: "Rerun setup with the same answers.",
|
|
6620
|
+
};
|
|
6621
|
+
}
|
|
6622
|
+
if (current.state === "ok") {
|
|
6623
|
+
const omitted = current.grant.servers.map((server) => server.name).filter((name) => !names.includes(name)).sort();
|
|
6624
|
+
if (omitted.length > 0) {
|
|
6625
|
+
const reason = `the selection leaves out ${omitted.join(", ")}, which are already approved for workers. ` +
|
|
6626
|
+
"Setup never removes an approved server from a settled grant, so nothing changed. " +
|
|
6627
|
+
"To add a server, list every approved server plus the new one.";
|
|
6628
|
+
deps.log(` declined — ${reason}`);
|
|
6629
|
+
return { status: "declined", reason };
|
|
6058
6630
|
}
|
|
6059
6631
|
}
|
|
6060
6632
|
}
|
|
6061
|
-
|
|
6062
|
-
|
|
6633
|
+
if (current !== undefined && current.state === "ok" && current.grant.candidate_fingerprint === inventory.fingerprint) {
|
|
6634
|
+
const stored = current.grant.servers.map((server) => server.name).sort();
|
|
6635
|
+
if (stored.length === names.length && stored.every((name, i) => name === names[i])) {
|
|
6636
|
+
deps.log(" unchanged — the stored approval already says this.");
|
|
6637
|
+
return { status: "unchanged" };
|
|
6638
|
+
}
|
|
6063
6639
|
}
|
|
6640
|
+
// An unreadable grant (without the flag) is replaced through the same revalidated publication.
|
|
6064
6641
|
deps.log(` Workers in ${repoName} would get: Bridge${names.length > 0 ? ` + ${names.join(", ")}` : " only"}.`);
|
|
6065
6642
|
return publishGrant(deps, grantDeps, repoName, inventory, ids);
|
|
6066
6643
|
}
|
|
@@ -6089,6 +6666,43 @@ async function publishCapabilityStatement(deps, grantDeps, access, verbose) {
|
|
|
6089
6666
|
// BAPI-1546: the epic-server item
|
|
6090
6667
|
// ---------------------------------------------------------------------------
|
|
6091
6668
|
/** Read the record and map it to setup evidence. Read-only; never throws. */
|
|
6669
|
+
/**
|
|
6670
|
+
* BAPI-1719: project one read-only profile inspection onto the setup evidence.
|
|
6671
|
+
* `met` only when every supported Bridge entry loads the group AND the inspection
|
|
6672
|
+
* was conclusive (no unreadable config); a needed merge, a missing entry, and an
|
|
6673
|
+
* inconclusive read stay distinct. Carries fixed config paths only.
|
|
6674
|
+
*
|
|
6675
|
+
* A config that registers Bridge under both names comes first: the writer refuses
|
|
6676
|
+
* it all-or-nothing, so planning a merge would only produce a failed write and a
|
|
6677
|
+
* setup that exits 1 on every run. Setup skips the merge and shows a notice instead,
|
|
6678
|
+
* the way the SFCC profile merge (`index.ts`) and vendor-first host provisioning
|
|
6679
|
+
* (`skipped-duplicate-registration`) leave such a config untouched.
|
|
6680
|
+
*/
|
|
6681
|
+
export function toolVisibilityStateFrom(inspection) {
|
|
6682
|
+
const duplicates = inspection.configs.filter((c) => c.duplicateRegistration === true).map((c) => c.path);
|
|
6683
|
+
if (duplicates.length > 0)
|
|
6684
|
+
return { state: "duplicate_registration", configPaths: duplicates };
|
|
6685
|
+
if (profileMergeNeededFrom(inspection)) {
|
|
6686
|
+
return {
|
|
6687
|
+
state: "needs_merge",
|
|
6688
|
+
configPaths: inspection.configs.filter((c) => c.state === "token-absent").map((c) => c.path),
|
|
6689
|
+
};
|
|
6690
|
+
}
|
|
6691
|
+
if (inspection.configs.some((c) => c.state === "unreadable"))
|
|
6692
|
+
return { state: "unknown", reason: "inspection" };
|
|
6693
|
+
return inspection.bridgeEntryPresent ? { state: "met" } : { state: "no_entry" };
|
|
6694
|
+
}
|
|
6695
|
+
/** Read-only. Unwired dependencies or a throwing inspector are `unknown`, never satisfied. */
|
|
6696
|
+
async function collectToolVisibilityEvidence(local) {
|
|
6697
|
+
if (local === undefined)
|
|
6698
|
+
return { state: "unknown", reason: "inspection" };
|
|
6699
|
+
try {
|
|
6700
|
+
return toolVisibilityStateFrom(await local.inspectProfileToken());
|
|
6701
|
+
}
|
|
6702
|
+
catch {
|
|
6703
|
+
return { state: "unknown", reason: "inspection" };
|
|
6704
|
+
}
|
|
6705
|
+
}
|
|
6092
6706
|
async function assessEpicServer(epicDeps, repoName) {
|
|
6093
6707
|
let read;
|
|
6094
6708
|
try {
|
|
@@ -6312,6 +6926,8 @@ const DRY_RUN_FIX_TEXT = Object.freeze({
|
|
|
6312
6926
|
merge_token: "store a GitHub merge token on this computer (its own consent, read with no echo)",
|
|
6313
6927
|
mcp_grant: "approve which extra MCP servers Epic Implementer workers get in this repository (one consent; the grant is stored outside every worktree)",
|
|
6314
6928
|
epic_server: "choose the epic server for Epic Implementer runs: none, local, or sfcc_shared_active (its own consent; the record is stored outside every worktree)",
|
|
6929
|
+
tool_visibility: "add the epic_implementer group to your existing Bridge MCP entries, keeping the groups already listed, then restart your MCP client (its own consent; no file is created)",
|
|
6930
|
+
qualify_gate: "run the stored local gate once under a short-lived executor to qualify it for its current revision (its own consent; dry run runs nothing)",
|
|
6315
6931
|
reindex: "use the default branch for indexing when it is the only candidate, or ask which branch to use when a different branch exists; then queue one tracked first parse, or one retry you approve. Dry run writes no configuration, queue, retry, authorization record, or file",
|
|
6316
6932
|
});
|
|
6317
6933
|
/**
|