@bridge_gpt/mcp-server 0.2.72 → 0.2.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/build/agent-launchers/claude-executor-adapter.js +3 -0
- package/build/agents.generated.js +6 -6
- package/build/bridge-permissions.js +27 -0
- package/build/ci-system-detection.js +50 -0
- package/build/ci-trigger-adapters.js +631 -0
- package/build/ci-trigger-install.js +106 -0
- package/build/codex-launcher-pin.js +33 -2
- package/build/codex-skill-adapter.js +3 -1
- package/build/command-host.js +33 -0
- package/build/commands.generated.js +7 -6
- package/build/conductor/bridge-api-client.js +842 -35
- package/build/conductor/bring-up-facts.js +18 -5
- package/build/conductor/command-drift-production.js +42 -17
- package/build/conductor/command-drift.js +47 -0
- package/build/conductor/declare-blocked.js +554 -0
- package/build/conductor/doctor.js +106 -21
- package/build/conductor/driver-commands.js +141 -0
- package/build/conductor/driver-guard.js +277 -0
- package/build/conductor/driver-lapse.js +321 -0
- package/build/conductor/driver-register.js +176 -0
- package/build/conductor/driver-release.js +174 -0
- package/build/conductor/driver-session-state.js +315 -0
- package/build/conductor/epic-branch-ci-inspection.js +222 -29
- package/build/conductor/epic-implementer-cli.js +166 -15
- package/build/conductor/epic-server-database.js +162 -0
- package/build/conductor/epic-server-guidance.js +278 -0
- package/build/conductor/epic-server-journal.js +239 -0
- package/build/conductor/epic-server-processes.js +324 -0
- package/build/conductor/epic-server-recipe.js +397 -0
- package/build/conductor/epic-server-runtime.js +1207 -0
- package/build/conductor/epic-server-sfcc.js +107 -0
- package/build/conductor/epic-server-state.js +427 -0
- package/build/conductor/epic-server.js +594 -0
- package/build/conductor/gate-discovery.js +150 -5
- package/build/conductor/gate-settings-review.js +224 -4
- package/build/conductor/launch-need-probes.js +6 -53
- package/build/conductor/launch-plan.js +313 -156
- package/build/conductor/prerequisite-inputs.js +879 -45
- package/build/conductor/readiness-assessment.js +16 -1
- package/build/conductor/readiness-cli.js +20 -9
- package/build/conductor/readiness-prerequisites.js +28 -9
- package/build/conductor/readiness-sections.js +133 -126
- package/build/conductor/readiness.js +1 -1
- package/build/conductor/recovery-cli.js +13 -2
- package/build/conductor/tools.js +6 -5
- package/build/conductor/wait-run-attention.js +2 -2
- package/build/conductor/wait-run-cli.js +208 -22
- package/build/conductor/worker-database-doctor-inspector.js +33 -2
- package/build/conductor/worker-setup-tally.js +27 -0
- package/build/credential-store.js +71 -1
- package/build/dependency-install-declarations.js +55 -0
- package/build/docs.generated.js +2 -2
- package/build/doctor.js +54 -3
- package/build/drive-epic-help.js +21 -2
- package/build/drive-epic.js +1811 -351
- package/build/engine-paths.js +20 -0
- package/build/epic-branch-ci-summary.js +140 -0
- package/build/epic-capability-statement.js +107 -0
- package/build/epic-ci-workflow-drift.js +30 -15
- package/build/epic-ci-workflow-install.js +110 -42
- package/build/epic-ci-workflow-v2.js +274 -0
- package/build/epic-ci-workflow.js +38 -12
- package/build/epic-implementer-bin.js +2101 -44
- package/build/epic-launch-context.js +607 -0
- package/build/epic-server-record.js +273 -0
- package/build/epic-shared/bridge-client.js +11 -3
- package/build/escalation-reachability.js +43 -0
- package/build/executor/ci-fix-test-runs.js +334 -0
- package/build/executor/completion-contract.js +8 -1
- package/build/executor/env.js +59 -22
- package/build/executor/epic-server-context.js +141 -0
- package/build/executor/gate-qualification-job.js +127 -26
- package/build/executor/http-client.js +52 -5
- package/build/executor/job-runner.js +423 -69
- package/build/executor/observation.js +8 -0
- package/build/executor/pre-pr-checks.js +363 -0
- package/build/executor/prompt-spec.js +114 -2
- package/build/executor/reconcile-overlap-job.js +5 -3
- package/build/executor/required-work-diagnostics.js +4 -2
- package/build/executor/required-work-ledger.js +936 -38
- package/build/executor/results.js +58 -0
- package/build/executor/terminal-mutation.js +8 -0
- package/build/executor/worker-command.js +72 -3
- package/build/executor/worker-database-config.js +281 -0
- package/build/executor/worker-database-target.js +16 -12
- package/build/executor/worker-database.js +320 -101
- package/build/executor/worker-finalization.js +7 -1
- package/build/executor/worker-resources.js +25 -3
- package/build/executor/worker-verification-guidance.js +18 -3
- package/build/executor/worktree.js +20 -1
- package/build/executor-launch.js +54 -2
- package/build/generated-assets-catalog.js +2 -2
- package/build/index.js +664 -335
- package/build/init.js +26 -11
- package/build/install-bridge-conductor-answers.js +465 -0
- package/build/install-bridge-conductor-apply.js +259 -0
- package/build/install-bridge-conductor-assessment.js +895 -0
- package/build/install-bridge-conductor-compact.js +161 -0
- package/build/install-bridge-conductor-contracts.js +63 -0
- package/build/install-bridge-conductor-gate.js +1197 -196
- package/build/install-bridge-conductor-setup.js +535 -79
- package/build/install-bridge-conductor.js +2885 -560
- package/build/install-bridge.js +199 -21
- package/build/install-maintenance.js +26 -3
- package/build/launcher-config-inspection.js +162 -1
- package/build/mcp-grant-candidates.js +767 -0
- package/build/mcp-grant-doctor.js +63 -0
- package/build/mcp-grant.js +288 -0
- package/build/mcp-host-targets.js +8 -0
- package/build/mcp-identity.js +23 -0
- package/build/mcp-invoke.js +126 -13
- package/build/mcp-presets.js +107 -0
- package/build/mcp-provisioning.js +134 -2
- package/build/mcp-registration-doctor.js +31 -2
- package/build/mcp-server-invocation.js +6 -1
- package/build/merge-workflow-install.js +234 -109
- package/build/pipelines.generated.js +5 -5
- package/build/plan-discovery.js +97 -4
- package/build/plan-execution-ledger.js +100 -7
- package/build/plan-generation-io.js +262 -0
- package/build/plan-generation.js +424 -0
- package/build/plane/build-freshness.js +6 -1
- package/build/plane/cli.js +75 -9
- package/build/plane/plane-freshness.js +17 -0
- package/build/plane/preflight.js +50 -10
- package/build/plane/shutdown.js +19 -0
- package/build/plane/terminal-run-cleanup.js +18 -4
- package/build/printed-remedy-commands.js +206 -12
- package/build/readiness-check.js +77 -0
- package/build/readiness-prerequisites.generated.js +122 -14
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +38 -0
- package/build/run-unit-tests-launcher.js +8 -1
- package/build/setup-epic.js +1190 -196
- package/build/setup-progress.js +44 -0
- package/build/setup-question.js +122 -4
- package/build/third-party-mcp-targets.js +30 -0
- package/build/ticket-delivery-enrollment.js +9 -0
- package/build/upgrade-cli.js +85 -2
- package/build/v2-readiness-requirements.js +28 -1
- package/build/version.generated.js +3 -3
- package/docs/EPIC-IMPLEMENTER-INSTALL.md +9 -1
- package/docs/epic-implementer/getting-started.md +3 -1
- package/docs/epic-implementer/self-hosting.md +14 -1
- package/package.json +2 -2
|
@@ -21,11 +21,13 @@ import { formatReadinessAssessment } from './conductor/readiness-prerequisites.j
|
|
|
21
21
|
* row for the same fact. An unmet blocking item is counted once.
|
|
22
22
|
*/
|
|
23
23
|
import { READINESS_PREREQUISITE_BY_ID, READINESS_PREREQUISITE_CATALOG, } from "./readiness-prerequisites.generated.js";
|
|
24
|
-
import { READINESS_PREREQUISITE_FIXES, assessmentRemedyQuestion } from "./printed-remedy-commands.js";
|
|
24
|
+
import { READINESS_PREREQUISITE_FIXES, assessmentRemedyQuestion, formatProfilePolicyRemedy, resolveReadinessRemedy, } from "./printed-remedy-commands.js";
|
|
25
|
+
import { COMMAND_DRIFT_UNASSESSABLE_REMEDIATION } from "./conductor/command-drift.js";
|
|
26
|
+
import { shellQuote } from "./epic-launch-profile.js";
|
|
25
27
|
import { decodeCanonicalProvenance } from "./conductor/bridge-api-client.js";
|
|
26
28
|
import { githubSignInRemedy } from "./github-sign-in.js";
|
|
27
29
|
import { EPIC_CI_WORKFLOW_ALL_MANAGED_BRANCHES } from "./epic-ci-workflow-install.js";
|
|
28
|
-
import { MCP_PACKAGE_NAME } from "./mcp-identity.js";
|
|
30
|
+
import { MCP_PACKAGE_NAME, isLocalBuildLauncher } from "./mcp-identity.js";
|
|
29
31
|
/** The catalog ids setup reports, named once. */
|
|
30
32
|
export const SETUP_ITEM_IDS = Object.freeze({
|
|
31
33
|
claudeLogin: "conductor.claude-login",
|
|
@@ -39,7 +41,29 @@ export const SETUP_ITEM_IDS = Object.freeze({
|
|
|
39
41
|
requiredChecks: "server.supervisor-required-checks",
|
|
40
42
|
repositoryIdentity: "install.identity",
|
|
41
43
|
serverConnectivity: "install.connectivity",
|
|
44
|
+
/**
|
|
45
|
+
* BAPI-1545: a LOCAL advisory item. Deliberately not in the server readiness
|
|
46
|
+
* catalog (that would regenerate the shared catalog and its Python twin), so
|
|
47
|
+
* it carries its own label.
|
|
48
|
+
*/
|
|
49
|
+
mcpGrant: "local.mcp-grant",
|
|
50
|
+
/**
|
|
51
|
+
* BAPI-1546: the epic-server opt-in. A LOCAL advisory item beside the MCP
|
|
52
|
+
* grant, behind its own consent, for the same reason the grant stays out of
|
|
53
|
+
* the server catalog. It never changes the verdict.
|
|
54
|
+
*/
|
|
55
|
+
epicServer: "local.epic-server",
|
|
56
|
+
/** BAPI-1635: a LOCAL advisory item for default-branch index lag. Never blocking. */
|
|
57
|
+
indexFreshness: "local.index-freshness",
|
|
58
|
+
/** BAPI-1635: the committed-asset drift advisory, a catalog row labeled "Command versions". */
|
|
59
|
+
commandDrift: "conductor.command-drift",
|
|
42
60
|
});
|
|
61
|
+
/** BAPI-1635: the explicit label of the local index-freshness item. */
|
|
62
|
+
export const INDEX_FRESHNESS_ITEM_LABEL = "Repository index freshness";
|
|
63
|
+
/** BAPI-1545: the explicit label of the local MCP grant item. */
|
|
64
|
+
export const MCP_GRANT_ITEM_LABEL = "Worker MCP servers (owner approval)";
|
|
65
|
+
/** BAPI-1546: the explicit label of the local epic-server item. */
|
|
66
|
+
export const EPIC_SERVER_ITEM_LABEL = "Epic server for UI checks (owner opt-in)";
|
|
43
67
|
/** The catalog label for an id, falling back to the id itself. */
|
|
44
68
|
export function catalogLabel(id) {
|
|
45
69
|
return READINESS_PREREQUISITE_BY_ID.get(id)?.label ?? id;
|
|
@@ -51,13 +75,57 @@ function catalogIndex(id) {
|
|
|
51
75
|
}
|
|
52
76
|
/** The printed setup command, used in fixes that point back at setup. */
|
|
53
77
|
export const PRINTED_SETUP_COMMAND = `npx -y ${MCP_PACKAGE_NAME} install epic-implementer`;
|
|
78
|
+
/** The default launcher: the published package through `npx`. */
|
|
79
|
+
export const NPM_SETUP_LAUNCHER = Object.freeze({ shape: "npm", base: `npx -y ${MCP_PACKAGE_NAME}` });
|
|
54
80
|
/**
|
|
55
|
-
* The
|
|
56
|
-
*
|
|
57
|
-
* sends an email address.
|
|
81
|
+
* The local-build launcher for a validated entry path, or null. Callers pass a path
|
|
82
|
+
* only after confirming the destination is local; this checks the path's shape.
|
|
58
83
|
*/
|
|
59
|
-
export
|
|
60
|
-
"
|
|
84
|
+
export function localBuildSetupLauncher(entryPath) {
|
|
85
|
+
if (!isLocalBuildLauncher("node", [entryPath]))
|
|
86
|
+
return null;
|
|
87
|
+
return { shape: "local-build", base: `node ${shellQuote(entryPath)}` };
|
|
88
|
+
}
|
|
89
|
+
function launcherOf(evidence) {
|
|
90
|
+
return evidence.launcher ?? NPM_SETUP_LAUNCHER;
|
|
91
|
+
}
|
|
92
|
+
/** The setup command in the detected launcher form. */
|
|
93
|
+
export function setupCommandFor(evidence) {
|
|
94
|
+
return `${launcherOf(evidence).base} install epic-implementer`;
|
|
95
|
+
}
|
|
96
|
+
/** The supported asset-refresh invocation (`--init` rewrites the packaged assets) in the detected launcher form. */
|
|
97
|
+
export function assetRefreshCommandFor(evidence) {
|
|
98
|
+
return `${launcherOf(evidence).base} --init`;
|
|
99
|
+
}
|
|
100
|
+
/** The profile-policy remedy for a known unmet escalation route, in the detected launcher form. */
|
|
101
|
+
export function profilePolicyRemedyFor(evidence) {
|
|
102
|
+
return formatProfilePolicyRemedy(setupCommandFor(evidence));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The one notice for a setup PR that was closed without merging. Legacy output,
|
|
106
|
+
* assessment JSON, and the final summary all print this exact string.
|
|
107
|
+
*/
|
|
108
|
+
export function closedSetupPullRequestNotice(pr) {
|
|
109
|
+
return `The setup pull request ${pr.url} was closed without being merged. Bridge's GitHub workflow is not on your default branch, so epic pull requests do not run it. Setup will not reopen it or open another one. To fix this, reopen and merge it, or delete the branch ${pr.branch} and re-run setup.`;
|
|
110
|
+
}
|
|
111
|
+
/** BAPI-1657: the owner-facing remedy when approving this setup stores a missing test gate. */
|
|
112
|
+
const GATE_STORED_ON_APPROVAL_REMEDY = "No test gate is stored yet; approving this setup stores it.";
|
|
113
|
+
/** The proposal questions for the two local choices, shared with the agent proposal's catalog. */
|
|
114
|
+
export const MCP_GRANT_QUESTION = "Which of your MCP servers should every worker also be able to use?";
|
|
115
|
+
export const EPIC_SERVER_QUESTION = "Should runs start a test server so workers can check the user interface?";
|
|
116
|
+
export const REINDEX_RETRY_QUESTION = "Should Bridge try once more to read your repository, now that the last attempt did not finish?";
|
|
117
|
+
/**
|
|
118
|
+
* Client-only wording for a default-branch revision Bridge could not read. A
|
|
119
|
+
* parse cannot bind it, so the action is restoring Bridge's access to GitHub.
|
|
120
|
+
* Deliberately not in the shared published remedy tables.
|
|
121
|
+
*/
|
|
122
|
+
const DEFAULT_BRANCH_ACCESS_REMEDY = "Bridge could not read the default branch from GitHub. Check Bridge’s access to the repository, then re-run setup.";
|
|
123
|
+
/** Opening words of an agent-path remedy that points at a proposal question. */
|
|
124
|
+
const AGENT_CHOICE_REMEDY_PREFIX = "Re-run setup with your answer to";
|
|
125
|
+
/** Present only in a printed command wrapped for the agent path. */
|
|
126
|
+
const AGENT_ANSWERS_MARKER = "--answers <answers-file>";
|
|
127
|
+
/** Index states in which a parse is already running or queued. */
|
|
128
|
+
const ACTIVE_INDEX_STATES = ["in_progress", "queued_by_setup", "recovery_pending"];
|
|
61
129
|
// ---------------------------------------------------------------------------
|
|
62
130
|
// Projection
|
|
63
131
|
// ---------------------------------------------------------------------------
|
|
@@ -99,9 +167,12 @@ function local(id, state, blocking, remedy) {
|
|
|
99
167
|
* Project one assessment pass onto the readiness items, in catalog order.
|
|
100
168
|
*
|
|
101
169
|
* Pure. It never derives readiness from a local write or an exit code: a
|
|
102
|
-
*
|
|
103
|
-
* the
|
|
104
|
-
* the
|
|
170
|
+
* workflow is met only when the installer found it identical, and indexing only
|
|
171
|
+
* when the index reached the merge commit. There is no test-command item: the
|
|
172
|
+
* command is learned and proven by the server, or there is none, and neither is a
|
|
173
|
+
* client-side blocker. The managed workflow blocks only when it is wanted (a
|
|
174
|
+
* `managed` plan, or a gate that requires its check); a watched, none, or
|
|
175
|
+
* declined-local plan stays ready without it.
|
|
105
176
|
*/
|
|
106
177
|
export function projectSetupItems(evidence) {
|
|
107
178
|
if (evidence.readiness?.assessmentNegotiation)
|
|
@@ -131,50 +202,149 @@ export function projectSetupItems(evidence) {
|
|
|
131
202
|
upsert(items, local(SETUP_ITEM_IDS.githubSignIn, evidence.githubSignIn === "signed_in" ? "met" : evidence.githubSignIn === "unavailable" ? "unknown" : "needs_action", true, githubSignInRemedy(evidence.githubSignIn)));
|
|
132
203
|
// --- Repository identity ------------------------------------------------
|
|
133
204
|
if (evidence.repositoryIdentity !== "resolved") {
|
|
134
|
-
upsert(items, local(SETUP_ITEM_IDS.repositoryIdentity, "needs_action", true, evidence.repositoryIdentity
|
|
135
|
-
? "this checkout's github.com remote names a different repository than Bridge does; run setup from the matching checkout"
|
|
136
|
-
: "run setup from a checkout whose `origin` remote is the github.com repository"));
|
|
137
|
-
}
|
|
138
|
-
// --- Test command (the stored value, read back) --------------------------
|
|
139
|
-
if (evidence.testCommand.state !== "stored") {
|
|
140
|
-
const existing = items.find((i) => i.id === SETUP_ITEM_IDS.testCommand);
|
|
141
|
-
upsert(items, local(SETUP_ITEM_IDS.testCommand, evidence.testCommand.state === "missing" ? "needs_action" : "unknown", true, evidence.testCommand.state === "missing"
|
|
142
|
-
? "save a test command: re-run setup and give the command that runs your tests"
|
|
143
|
-
: existing?.remedy ?? READINESS_PREREQUISITE_FIXES.retry));
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
const existing = items.find((i) => i.id === SETUP_ITEM_IDS.testCommand);
|
|
147
|
-
if (existing === undefined)
|
|
148
|
-
upsert(items, local(SETUP_ITEM_IDS.testCommand, "met", true, null));
|
|
205
|
+
upsert(items, local(SETUP_ITEM_IDS.repositoryIdentity, "needs_action", true, repositoryIdentityRemedy(evidence.repositoryIdentity)));
|
|
149
206
|
}
|
|
150
207
|
// --- Workflow, setup pull request, and indexing --------------------------
|
|
151
208
|
const workflowItem = projectWorkflowItem(evidence, items.find((i) => i.id === SETUP_ITEM_IDS.workflows));
|
|
152
209
|
if (workflowItem !== null)
|
|
153
210
|
upsert(items, workflowItem);
|
|
154
|
-
// --- The gate change the owner declined ---------------------------------
|
|
155
|
-
if (evidence.gateChangeDeclined) {
|
|
156
|
-
upsert(items, local(SETUP_ITEM_IDS.requiredChecks, "needs_action", true, "add the CI workflow check to the repository gate: re-run setup and accept the gate change"));
|
|
157
|
-
}
|
|
158
211
|
// --- Merge credential ----------------------------------------------------
|
|
159
212
|
const merge = projectMergeCredential(evidence.mergeCredential);
|
|
160
213
|
if (merge !== null)
|
|
161
214
|
upsert(items, merge);
|
|
162
|
-
// ---
|
|
163
|
-
const
|
|
164
|
-
if (
|
|
165
|
-
upsert(items,
|
|
166
|
-
|
|
215
|
+
// --- BAPI-1545: worker MCP grant (advisory, never the verdict) ----------
|
|
216
|
+
const grant = projectMcpGrantItem(evidence.mcpGrant, evidence.path);
|
|
217
|
+
if (grant !== null)
|
|
218
|
+
upsert(items, grant);
|
|
219
|
+
// --- BAPI-1546: epic-server opt-in (advisory, never the verdict) ---------
|
|
220
|
+
const epicServer = projectEpicServerItem(evidence.epicServer, evidence.path);
|
|
221
|
+
if (epicServer !== null)
|
|
222
|
+
upsert(items, epicServer);
|
|
223
|
+
// --- BAPI-1635: a known unmet row never keeps the generic retry -----------
|
|
224
|
+
// `fromServerPrerequisite` stays as it was; a blank wire fix is resolved here by ID.
|
|
225
|
+
for (const item of items)
|
|
226
|
+
normalizeKnownRemedy(item);
|
|
227
|
+
// --- Escalation channel: the selected launch profile's route, or its remedy -
|
|
228
|
+
applyNotificationEvidence(items, evidence);
|
|
229
|
+
// --- BAPI-1635: index lag and committed-asset drift (advisory, never the verdict) ---
|
|
230
|
+
const freshness = projectFreshnessItem(evidence.freshness);
|
|
231
|
+
if (freshness !== null)
|
|
232
|
+
upsert(items, freshness);
|
|
233
|
+
const drift = projectCommandDriftItem(evidence);
|
|
234
|
+
if (drift !== null)
|
|
235
|
+
upsert(items, drift);
|
|
167
236
|
return items
|
|
168
237
|
.map((item, arrival) => ({ item, arrival }))
|
|
169
238
|
.sort((a, b) => catalogIndex(a.item.id) - catalogIndex(b.item.id) || a.arrival - b.arrival)
|
|
170
239
|
.map(({ item }) => item);
|
|
171
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* BAPI-1635: replace the generic retry on a KNOWN unmet catalog row with its
|
|
243
|
+
* per-ID remedy. An unknown row, a met row, and a row with its own remedy are untouched.
|
|
244
|
+
*/
|
|
245
|
+
function normalizeKnownRemedy(item) {
|
|
246
|
+
if (item.state !== "needs_action" || item.remedy !== READINESS_PREREQUISITE_FIXES.retry)
|
|
247
|
+
return;
|
|
248
|
+
const descriptor = READINESS_PREREQUISITE_BY_ID.get(item.id);
|
|
249
|
+
if (descriptor === undefined)
|
|
250
|
+
return;
|
|
251
|
+
item.remedy = resolveReadinessRemedy({ id: item.id, state: "not_met", scope: descriptor.scope, impact: item.blocking ? "blocking" : "warning" });
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* BAPI-1635: apply the selected launch profile's notification evidence to the
|
|
255
|
+
* effective escalation item. A valid declaration is an effective route; an
|
|
256
|
+
* independently confirmed live-email route (the item already met) is kept; a
|
|
257
|
+
* confirmed absent or invalid declaration keeps the profile-policy remedy; an
|
|
258
|
+
* unreadable policy stays unknown. Reachability is never inferred.
|
|
259
|
+
*/
|
|
260
|
+
function applyNotificationEvidence(items, evidence) {
|
|
261
|
+
const escalation = items.find((i) => i.id === SETUP_ITEM_IDS.escalation);
|
|
262
|
+
if (escalation === undefined || escalation.state === "met")
|
|
263
|
+
return;
|
|
264
|
+
const notification = evidence.notification;
|
|
265
|
+
if (notification?.state === "declared") {
|
|
266
|
+
upsert(items, { ...escalation, state: "met", remedy: null });
|
|
267
|
+
}
|
|
268
|
+
else if (notification?.state === "unreadable") {
|
|
269
|
+
upsert(items, { ...escalation, state: "unknown", remedy: READINESS_PREREQUISITE_FIXES.retry });
|
|
270
|
+
}
|
|
271
|
+
else if (escalation.state === "needs_action") {
|
|
272
|
+
upsert(items, { ...escalation, remedy: profilePolicyRemedyFor(evidence) });
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const COMMIT_ID = /^[0-9a-f]{40}$/;
|
|
276
|
+
/** The one remedy for index lag; names both commits and the manual re-index. */
|
|
277
|
+
function freshnessRemedy(fresh) {
|
|
278
|
+
const indexed = fresh.indexedSha ?? "unknown";
|
|
279
|
+
const head = fresh.defaultBranchSha ?? "unknown";
|
|
280
|
+
const relation = fresh.relation === "diverged" ? "diverges from" : "is behind";
|
|
281
|
+
return `The index at ${indexed} ${relation} the default branch at ${head}. ${READINESS_PREREQUISITE_FIXES.reindex_manual}`;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* BAPI-1635: the advisory index-freshness item. Lag is confirmed only when both
|
|
285
|
+
* commit IDs are valid and the ancestry relation says so; `unknown` and `diverged`
|
|
286
|
+
* stay distinct. Always non-blocking: a mandatory server blocker is the server row's.
|
|
287
|
+
*/
|
|
288
|
+
export function projectFreshnessItem(fresh) {
|
|
289
|
+
if (fresh === undefined)
|
|
290
|
+
return null;
|
|
291
|
+
const item = (state, remedy) => ({
|
|
292
|
+
id: SETUP_ITEM_IDS.indexFreshness,
|
|
293
|
+
label: INDEX_FRESHNESS_ITEM_LABEL,
|
|
294
|
+
state,
|
|
295
|
+
blocking: false,
|
|
296
|
+
remedy: state === "met" ? null : remedy,
|
|
297
|
+
});
|
|
298
|
+
const valid = fresh.indexedSha !== null && fresh.defaultBranchSha !== null
|
|
299
|
+
&& COMMIT_ID.test(fresh.indexedSha) && COMMIT_ID.test(fresh.defaultBranchSha);
|
|
300
|
+
if (!valid)
|
|
301
|
+
return item("unknown", "the index could not be compared with the default branch; re-run setup later");
|
|
302
|
+
switch (fresh.relation) {
|
|
303
|
+
case "equal":
|
|
304
|
+
case "contains_target":
|
|
305
|
+
return item("met", null);
|
|
306
|
+
case "behind":
|
|
307
|
+
case "diverged":
|
|
308
|
+
if (fresh.requestState === "queued" || fresh.requestState === "in_progress") {
|
|
309
|
+
return item("pending", "indexing is running; re-run setup when it finishes");
|
|
310
|
+
}
|
|
311
|
+
return item("needs_action", freshnessRemedy(fresh));
|
|
312
|
+
case "unknown":
|
|
313
|
+
return item("unknown", "the index could not be compared with the default branch; re-run setup later");
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* BAPI-1635: the non-blocking "Command versions" advisory. Divergent stays
|
|
318
|
+
* divergent until refreshed bytes are committed at HEAD; setup never refreshes
|
|
319
|
+
* or commits on its own.
|
|
320
|
+
*/
|
|
321
|
+
export function projectCommandDriftItem(evidence) {
|
|
322
|
+
const drift = evidence.drift;
|
|
323
|
+
if (drift === undefined)
|
|
324
|
+
return null;
|
|
325
|
+
const item = (state, remedy) => ({
|
|
326
|
+
id: SETUP_ITEM_IDS.commandDrift,
|
|
327
|
+
label: catalogLabel(SETUP_ITEM_IDS.commandDrift),
|
|
328
|
+
state,
|
|
329
|
+
blocking: false,
|
|
330
|
+
remedy: state === "met" ? null : remedy,
|
|
331
|
+
});
|
|
332
|
+
if (drift.status === "pass")
|
|
333
|
+
return item("met", null);
|
|
334
|
+
if (drift.kind === "unassessable")
|
|
335
|
+
return item("unknown", COMMAND_DRIFT_UNASSESSABLE_REMEDIATION);
|
|
336
|
+
return item("needs_action", `Run ${assetRefreshCommandFor(evidence)}, review the changed files, then commit them, or mark the commands customized in the gate profile.`);
|
|
337
|
+
}
|
|
172
338
|
function projectWorkflowItem(evidence, server) {
|
|
173
339
|
const id = SETUP_ITEM_IDS.workflows;
|
|
174
340
|
const pr = evidence.setupPullRequest;
|
|
175
341
|
if (evidence.index.state === "recovery_unresolved")
|
|
176
342
|
return local(id, "needs_action", true, evidence.index.remedy);
|
|
177
343
|
if (evidence.recovery && evidence.index.state !== "reached") {
|
|
344
|
+
if (!evidence.recovery.supported && (evidence.freshness?.relation === "behind" || evidence.freshness?.relation === "diverged")) {
|
|
345
|
+
// BAPI-1635: a proven lag and its manual recovery beat "upgrade the backend".
|
|
346
|
+
return local(id, "needs_action", true, freshnessRemedy(evidence.freshness));
|
|
347
|
+
}
|
|
178
348
|
if (!evidence.recovery.supported)
|
|
179
349
|
return local(id, "unknown", true, evidence.recovery.reason === "upgrade_required" ? "upgrade the Bridge backend for target-aware setup recovery, then re-run setup" : "setup recovery evidence is unavailable; inspect the configured branch with your Bridge administrator, then re-run setup");
|
|
180
350
|
const r = evidence.recovery.evidence;
|
|
@@ -182,39 +352,45 @@ function projectWorkflowItem(evidence, server) {
|
|
|
182
352
|
if (r.request && ["queued", "in_progress"].includes(r.request.status ?? ""))
|
|
183
353
|
return local(id, "pending", true, `${target}: request ${r.request.id}, run ${r.request.parse_run_id ?? "retained"} is pending; re-run setup to inspect it without replacing healthy work`);
|
|
184
354
|
if (r.retry_generation !== null)
|
|
185
|
-
return local(id, "needs_action", true,
|
|
355
|
+
return local(id, "needs_action", true, evidence.path === "agent"
|
|
356
|
+
? `${target}: prior request ${r.request?.id ?? "unknown"} ${r.request?.status ?? "unknown"}; re-run setup with your answer to “${REINDEX_RETRY_QUESTION}”`
|
|
357
|
+
: `${target}: prior request ${r.request?.id ?? "unknown"} ${r.request?.status ?? "unknown"}; explicit retry ${r.retry_generation} needs review in interactive setup`);
|
|
186
358
|
if (r.reason)
|
|
187
359
|
return local(id, "unknown", true, `${target}: ${r.reason}; inspect the configuration and verified index with your Bridge administrator`);
|
|
188
360
|
if (r.active_runs.some(run => run.requested_target_sha === null))
|
|
189
361
|
return local(id, "pending", true, `${target}: legacy-target-unknown active work cannot prove a match; interactive setup can admit one tracked successor after reviewing the target`);
|
|
190
362
|
return local(id, "needs_action", true, `${target}: canonical content ${r.canonical_relation}; review keep/correct/defer in interactive setup`);
|
|
191
363
|
}
|
|
364
|
+
// The managed workflow is wanted only when the plan is `managed` or the gate
|
|
365
|
+
// already requires its check. Otherwise its absence, an available upgrade, and
|
|
366
|
+
// an assessment that could not run say nothing about readiness: the server's own
|
|
367
|
+
// fact decides, and with none the item is met.
|
|
368
|
+
const workflowWanted = evidence.ciPlan === "managed" || evidence.gateRequiresManagedCheck === true;
|
|
192
369
|
switch (evidence.workflow.state) {
|
|
193
370
|
case "pr_open":
|
|
194
371
|
return local(id, "pending", true, `merge the setup PR: ${evidence.workflow.url}`);
|
|
372
|
+
case "absent":
|
|
373
|
+
if (!workflowWanted)
|
|
374
|
+
return server ?? local(id, "met", true, null);
|
|
375
|
+
return local(id, "needs_action", true, "open the setup PR: re-run setup and accept the setup pull request");
|
|
195
376
|
case "needs_pr":
|
|
377
|
+
// An installed Bridge workflow that could be upgraded still does its job.
|
|
378
|
+
if (!workflowWanted)
|
|
379
|
+
return server ?? local(id, "met", true, null);
|
|
196
380
|
return local(id, "needs_action", true, "open the setup PR: re-run setup and accept the setup pull request");
|
|
197
381
|
case "blocked":
|
|
382
|
+
// A real conflict (a modified managed file, a different open setup PR, a
|
|
383
|
+
// checkout that is not the repository root) stays visible whatever the plan.
|
|
198
384
|
return local(id, "needs_action", true, evidence.workflow.remedy);
|
|
199
|
-
case "needs_command":
|
|
200
|
-
return local(id, "needs_action", true, "save a test command first; setup builds the CI workflow from it");
|
|
201
385
|
case "unknown":
|
|
386
|
+
if (!workflowWanted)
|
|
387
|
+
return server ?? local(id, "met", true, null);
|
|
202
388
|
return server ?? local(id, "unknown", true, "the CI workflow could not be checked; re-run setup");
|
|
203
|
-
case "precondition":
|
|
204
|
-
// The local preflight could not run, but a merged setup PR still proves the
|
|
205
|
-
// workflow reached the default branch; then only indexing remains.
|
|
206
|
-
if (server?.state === "met")
|
|
207
|
-
return server;
|
|
208
|
-
if (pr.state !== "merged")
|
|
209
|
-
return local(id, "needs_action", true, evidence.workflow.remedy);
|
|
210
|
-
break;
|
|
211
389
|
case "installed":
|
|
212
390
|
break;
|
|
213
391
|
}
|
|
214
392
|
// The workflow is on the default branch. What remains is indexing.
|
|
215
|
-
|
|
216
|
-
return local(id, "needs_action", true, `the setup PR was closed without merging (${pr.url}); reopen and merge it, or delete the branch ${pr.branch} and re-run setup`);
|
|
217
|
-
}
|
|
393
|
+
// A closed setup PR is moot once the workflow is on the default branch.
|
|
218
394
|
switch (evidence.index.state) {
|
|
219
395
|
case "recovery_pending":
|
|
220
396
|
return local(id, "pending", true, `request ${evidence.index.requestId}, run ${evidence.index.runId ?? "retained"} is pending; re-run setup to inspect it without cancelling parsing`);
|
|
@@ -236,6 +412,69 @@ function projectWorkflowItem(evidence, server) {
|
|
|
236
412
|
return server ?? local(id, "met", true, null);
|
|
237
413
|
}
|
|
238
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* BAPI-1545: the advisory MCP grant item. Non-blocking in every state, so it
|
|
417
|
+
* never changes the setup verdict.
|
|
418
|
+
*/
|
|
419
|
+
export function projectMcpGrantItem(state, path = "terminal") {
|
|
420
|
+
if (state === undefined)
|
|
421
|
+
return null;
|
|
422
|
+
const item = (s, remedy) => ({
|
|
423
|
+
id: SETUP_ITEM_IDS.mcpGrant,
|
|
424
|
+
label: MCP_GRANT_ITEM_LABEL,
|
|
425
|
+
state: s,
|
|
426
|
+
blocking: false,
|
|
427
|
+
remedy: s === "met" ? null : remedy,
|
|
428
|
+
});
|
|
429
|
+
switch (state.state) {
|
|
430
|
+
case "met":
|
|
431
|
+
return item("met", null);
|
|
432
|
+
case "unknown":
|
|
433
|
+
return item("unknown", "the MCP grant could not be checked; re-run setup");
|
|
434
|
+
case "needs_action":
|
|
435
|
+
return item("needs_action", state.reason === "no_grant"
|
|
436
|
+
? path === "agent"
|
|
437
|
+
? `Re-run setup with your answer to “${MCP_GRANT_QUESTION}” Workers keep today's servers until then.`
|
|
438
|
+
: "approve which extra MCP servers workers get: re-run setup in an interactive terminal (workers keep today's servers until then)"
|
|
439
|
+
: state.reason === "changed"
|
|
440
|
+
? "the MCP servers available to approve changed since the last approval; re-run setup to review them (the current grant stays in force)"
|
|
441
|
+
: "the MCP grant file is unusable, so workers get Bridge only; re-run setup to replace it");
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* BAPI-1546: the advisory epic-server item. Non-blocking in every state, so it
|
|
446
|
+
* never changes the setup verdict. A failed capability-statement write after a
|
|
447
|
+
* change is reported here only.
|
|
448
|
+
*/
|
|
449
|
+
export function projectEpicServerItem(state, path = "terminal") {
|
|
450
|
+
if (state === undefined)
|
|
451
|
+
return null;
|
|
452
|
+
const item = (s, remedy) => ({
|
|
453
|
+
id: SETUP_ITEM_IDS.epicServer,
|
|
454
|
+
label: EPIC_SERVER_ITEM_LABEL,
|
|
455
|
+
state: s,
|
|
456
|
+
blocking: false,
|
|
457
|
+
remedy: s === "met" ? null : remedy,
|
|
458
|
+
});
|
|
459
|
+
switch (state.state) {
|
|
460
|
+
case "met":
|
|
461
|
+
if (state.statementError !== undefined) {
|
|
462
|
+
return {
|
|
463
|
+
...item("met", null),
|
|
464
|
+
remedy: `the epic-server choice was saved, but ${state.statementError}; re-run setup to retry the capability statement`,
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
return item("met", null);
|
|
468
|
+
case "unknown":
|
|
469
|
+
return item("unknown", "the epic-server choice could not be checked; re-run setup");
|
|
470
|
+
case "needs_action":
|
|
471
|
+
return item("needs_action", state.reason === "no_record"
|
|
472
|
+
? path === "agent"
|
|
473
|
+
? `Re-run setup with your answer to “${EPIC_SERVER_QUESTION}” UI checks are handed off until then.`
|
|
474
|
+
: "choose whether Epic Implementer runs get an epic server for UI checks: re-run setup in an interactive terminal (UI checks are handed off until then)"
|
|
475
|
+
: "the epic-server record is unusable, so runs have no epic server; re-run setup to replace it");
|
|
476
|
+
}
|
|
477
|
+
}
|
|
239
478
|
function projectMergeCredential(state) {
|
|
240
479
|
const id = SETUP_ITEM_IDS.mergeCredential;
|
|
241
480
|
switch (state.state) {
|
|
@@ -255,17 +494,17 @@ function projectMergeCredential(state) {
|
|
|
255
494
|
return local(id, "unknown", true, "the merge token could not be checked right now; re-run setup later");
|
|
256
495
|
}
|
|
257
496
|
}
|
|
258
|
-
/** The two fixes that write the stored test command. */
|
|
259
|
-
export function isTestCommandFix(fix) {
|
|
260
|
-
return fix === "save_test_command" || fix === "replace_test_command";
|
|
261
|
-
}
|
|
262
497
|
/**
|
|
263
498
|
* Pick the permitted fixes for the unmet items, in the order they must run.
|
|
264
499
|
*
|
|
265
500
|
* Pure. Dependencies are explicit:
|
|
266
|
-
* -
|
|
267
|
-
*
|
|
268
|
-
*
|
|
501
|
+
* - there is no test-command fix: the command is learned and proven by the
|
|
502
|
+
* server through a trial that setup's orchestration runs in its own explicit
|
|
503
|
+
* order, after the gate is written and before any workflow is offered;
|
|
504
|
+
* - the setup PR is planned to UPGRADE a Bridge workflow that is already
|
|
505
|
+
* installed, or to install the one a stored or explicit gate already requires
|
|
506
|
+
* the check of. A first workflow for a plan that does not need it is offered
|
|
507
|
+
* once by the orchestration, only for a proven local plan, and is never planned here;
|
|
269
508
|
* - a GitHub sign-in that is not ready blocks GitHub-dependent fixes (the
|
|
270
509
|
* setup PR), never the Bridge or local ones;
|
|
271
510
|
* - an unresolved repository identity blocks the stored merge token.
|
|
@@ -275,18 +514,8 @@ export function isTestCommandFix(fix) {
|
|
|
275
514
|
export function planSetupFixes(evidence, context) {
|
|
276
515
|
const fixes = [];
|
|
277
516
|
const githubReady = evidence.githubSignIn === "signed_in";
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
if (context.replaceTestCommandRequested === true)
|
|
281
|
-
fixes.push("replace_test_command");
|
|
282
|
-
else if (evidence.testCommand.state === "missing")
|
|
283
|
-
fixes.push("save_test_command");
|
|
284
|
-
// Either command fix is a potential dependency of the workflow fix; whether
|
|
285
|
-
// the workflow is then installed depends on the read-back being confirmed.
|
|
286
|
-
const commandAvailable = evidence.testCommand.state === "stored" || fixes.some(isTestCommandFix);
|
|
287
|
-
if (githubReady &&
|
|
288
|
-
commandAvailable &&
|
|
289
|
-
(evidence.workflow.state === "needs_pr" || evidence.workflow.state === "needs_command")) {
|
|
517
|
+
const workflowWanted = evidence.ciPlan === "managed" || evidence.gateRequiresManagedCheck === true;
|
|
518
|
+
if (githubReady && (evidence.workflow.state === "needs_pr" || (evidence.workflow.state === "absent" && workflowWanted))) {
|
|
290
519
|
fixes.push("setup_pr");
|
|
291
520
|
}
|
|
292
521
|
if (context.gateOrDefaultsNeedWrite || context.suppliedPolicyInput)
|
|
@@ -295,7 +524,7 @@ export function planSetupFixes(evidence, context) {
|
|
|
295
524
|
(evidence.mergeCredential.state === "missing" || evidence.mergeCredential.state === "stored_rejected")) {
|
|
296
525
|
fixes.push("merge_token");
|
|
297
526
|
}
|
|
298
|
-
const recovery = evidence.recovery;
|
|
527
|
+
const recovery = evidence.setupPullRequest.state === "merged" ? evidence.recovery : undefined;
|
|
299
528
|
const knownUnverified = recovery?.supported && !recovery.evidence.canonical.verified
|
|
300
529
|
&& ["absent", "unverified"].includes(recovery.evidence.canonical_observation ?? "unknown");
|
|
301
530
|
if (recovery?.supported && !recovery.evidence.reason && ((recovery.evidence.canonical.verified
|
|
@@ -303,6 +532,18 @@ export function planSetupFixes(evidence, context) {
|
|
|
303
532
|
&& recovery.evidence.configured_relation !== "unknown"
|
|
304
533
|
&& !["queued", "in_progress"].includes(recovery.evidence.request?.status ?? ""))
|
|
305
534
|
fixes.push("reindex");
|
|
535
|
+
// BAPI-1545: one advisory approval, asked only when the grant is missing,
|
|
536
|
+
// unusable, or its candidates changed. A met grant asks nothing.
|
|
537
|
+
if (evidence.mcpGrant?.state === "needs_action")
|
|
538
|
+
fixes.push("mcp_grant");
|
|
539
|
+
// BAPI-1546: the epic-server choice, after the grant, behind its own consent.
|
|
540
|
+
// Asked only when the record is missing or unusable, or the owner asked to
|
|
541
|
+
// change it. A valid record of any mode (`none` included) asks nothing.
|
|
542
|
+
if (evidence.epicServer !== undefined &&
|
|
543
|
+
evidence.epicServer.state !== "unknown" &&
|
|
544
|
+
(evidence.epicServer.state === "needs_action" || context.epicServerChangeRequested === true)) {
|
|
545
|
+
fixes.push("epic_server");
|
|
546
|
+
}
|
|
306
547
|
return fixes;
|
|
307
548
|
}
|
|
308
549
|
const SHA_RE = /^[0-9a-f]{40}$/;
|
|
@@ -415,6 +656,37 @@ export async function assessSetupIndex(pr, readParseStatus, compare) {
|
|
|
415
656
|
return { state: "in_progress" };
|
|
416
657
|
return { state: "unknown" };
|
|
417
658
|
}
|
|
659
|
+
/**
|
|
660
|
+
* BAPI-1635: compare the verified canonical index with the default-branch head.
|
|
661
|
+
*
|
|
662
|
+
* Read-only, and independent of {@link assessSetupIndex}: a repository with no setup
|
|
663
|
+
* pull request can still lag. It reuses canonical provenance decoding and
|
|
664
|
+
* {@link compareIndexedToMerge} with the default-branch commit as the comparison
|
|
665
|
+
* target. Lag is `behind` only when both commit IDs and GitHub's ancestry answer
|
|
666
|
+
* establish it; every other shape stays `unknown` or `diverged`. Never queues anything.
|
|
667
|
+
*/
|
|
668
|
+
export async function assessIndexFreshness(defaultBranchSha, readParseStatus, compare) {
|
|
669
|
+
const unknown = (indexedSha, requestState) => ({
|
|
670
|
+
indexedSha,
|
|
671
|
+
defaultBranchSha,
|
|
672
|
+
relation: "unknown",
|
|
673
|
+
...(requestState !== undefined ? { requestState } : {}),
|
|
674
|
+
});
|
|
675
|
+
let status;
|
|
676
|
+
try {
|
|
677
|
+
status = await readParseStatus();
|
|
678
|
+
}
|
|
679
|
+
catch {
|
|
680
|
+
return unknown(null);
|
|
681
|
+
}
|
|
682
|
+
const requestState = status.status === "queued" ? "queued" : status.status === "in_progress" ? "in_progress" : "none";
|
|
683
|
+
const canonical = decodeCanonicalProvenance(status);
|
|
684
|
+
if (!canonical.verified || defaultBranchSha === null || !SHA_RE.test(defaultBranchSha)) {
|
|
685
|
+
return unknown(canonical.verified ? canonical.sourceCommitSha : null, requestState);
|
|
686
|
+
}
|
|
687
|
+
const relation = await compare(defaultBranchSha, canonical.sourceCommitSha);
|
|
688
|
+
return { indexedSha: canonical.sourceCommitSha, defaultBranchSha, relation, requestState };
|
|
689
|
+
}
|
|
418
690
|
// ---------------------------------------------------------------------------
|
|
419
691
|
// Rendering
|
|
420
692
|
// ---------------------------------------------------------------------------
|
|
@@ -424,6 +696,28 @@ const STATE_WORD = Object.freeze({
|
|
|
424
696
|
pending: "pending",
|
|
425
697
|
unknown: "could not verify",
|
|
426
698
|
});
|
|
699
|
+
/** The advisory findings setup adds beside the server's own rows. */
|
|
700
|
+
const ADVISORY_FINDING_IDS = new Set([SETUP_ITEM_IDS.indexFreshness, SETUP_ITEM_IDS.commandDrift]);
|
|
701
|
+
/**
|
|
702
|
+
* BAPI-1635: the lines for the advisory findings setup adds (index lag, command
|
|
703
|
+
* versions) in the compact summary and in read-only runs, where the full assessment
|
|
704
|
+
* is not printed. Empty when none is unmet. They never change the verdict.
|
|
705
|
+
*/
|
|
706
|
+
export function advisoryFindingLines(items) {
|
|
707
|
+
// Only a finding (needs action, or indexing already running); an unreadable comparison is not advice.
|
|
708
|
+
const found = items.filter((i) => !i.blocking && (i.state === "needs_action" || i.state === "pending") && ADVISORY_FINDING_IDS.has(i.id) && i.remedy !== null);
|
|
709
|
+
return found.length === 0 ? [] : ["", "Also worth doing (advisory)", ...found.map((i) => ` - ${i.label}: ${i.remedy}`)];
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* BAPI-1635: the one remedy to print for an item. An item with its own remedy keeps
|
|
713
|
+
* it; with none, a known state resolves by catalog ID and only an unreadable or
|
|
714
|
+
* pending one falls back to retry.
|
|
715
|
+
*/
|
|
716
|
+
export function setupItemRemedy(item) {
|
|
717
|
+
if (item.remedy !== null)
|
|
718
|
+
return item.remedy;
|
|
719
|
+
return resolveReadinessRemedy({ id: item.id, state: item.state === "needs_action" ? "not_met" : "unknown" });
|
|
720
|
+
}
|
|
427
721
|
/** Blocking items that are not met, each counted once. */
|
|
428
722
|
export function unmetBlockingItems(items) {
|
|
429
723
|
const seen = new Set();
|
|
@@ -438,8 +732,10 @@ export function unmetBlockingItems(items) {
|
|
|
438
732
|
export function setupVerdictLine(items) {
|
|
439
733
|
const assessment = items.find(i => i.assessment)?.assessment;
|
|
440
734
|
if (assessment) {
|
|
735
|
+
// BAPI-1635: the verdict reads the effective assessment; the raw one stays evidence.
|
|
736
|
+
const effective = items.find(i => i.effectiveAssessment)?.effectiveAssessment ?? assessment;
|
|
441
737
|
const extras = additionalRequiredItems(items, assessment);
|
|
442
|
-
const verdict = extras.some(i => i.state === 'needs_action') ? 'Not ready' : extras.length && deriveAdvisoryVerdict(
|
|
738
|
+
const verdict = extras.some(i => i.state === 'needs_action') ? 'Not ready' : extras.length && deriveAdvisoryVerdict(effective) === 'Ready' ? 'Readiness not confirmed' : deriveAdvisoryVerdict(effective);
|
|
443
739
|
return `${verdict} — ${assessmentContextLabel(assessment)}; advisory only.`;
|
|
444
740
|
}
|
|
445
741
|
const left = unmetBlockingItems(items).length;
|
|
@@ -449,15 +745,31 @@ export function setupVerdictLine(items) {
|
|
|
449
745
|
export function renderSetupAssessment(items, heading, phase = 'final') {
|
|
450
746
|
const assessment = items.find(i => i.assessment)?.assessment;
|
|
451
747
|
if (assessment) {
|
|
452
|
-
const
|
|
748
|
+
const effective = items.find(i => i.effectiveAssessment)?.effectiveAssessment;
|
|
749
|
+
const profile = items.find(i => i.escalationProfile !== undefined)?.escalationProfile;
|
|
750
|
+
// The projected remedy replaces the raw reference text where setup chose a more specific one:
|
|
751
|
+
// an unbound revision, or a command wrapped for the agent path. Other records render as before.
|
|
752
|
+
const projected = new Map(items.filter(i => i.remedy !== null).map(i => [i.id, i.remedy]));
|
|
753
|
+
const remedyTextForRecord = (r) => {
|
|
754
|
+
const text = projected.get(`${r.scope}:${r.id}`);
|
|
755
|
+
return text !== undefined && (r.reason === 'revision_unbound' || text.includes(AGENT_ANSWERS_MARKER)) ? text : undefined;
|
|
756
|
+
};
|
|
757
|
+
const lines = formatReadinessAssessment(phase === 'final' && effective ? effective : assessment, { initial: phase === 'initial', remedyTextForRecord });
|
|
453
758
|
if (phase === 'final') {
|
|
454
759
|
lines.pop();
|
|
760
|
+
// The raw repository observation stays visible; the run's effective route is named beside it.
|
|
761
|
+
if (profile !== undefined)
|
|
762
|
+
lines.push(`Escalation route: the repository observation is unchanged; launch profile '${profile}' declares a notification route.`);
|
|
455
763
|
const extras = additionalRequiredItems(items, assessment);
|
|
456
764
|
if (extras.length)
|
|
457
765
|
lines.push('Additional required setup actions', ...extras.map(item => renderSetupQuestion({
|
|
458
766
|
...assessmentRemedyQuestion({ reference: 'setup', audience: 'repository_admin' }, [`${item.label}: ${item.state}`]),
|
|
459
|
-
purpose: item.remedy ??
|
|
767
|
+
purpose: item.remedy ?? resolveReadinessRemedy({ id: item.id, state: item.state === 'unknown' || item.state === 'pending' ? 'unknown' : 'not_met' }),
|
|
460
768
|
})));
|
|
769
|
+
const advisories = items.filter(i => !i.blocking && i.state !== 'met' && i.remedy !== null
|
|
770
|
+
&& (ADVISORY_FINDING_IDS.has(i.id) || ((i.id === SETUP_ITEM_IDS.mcpGrant || i.id === SETUP_ITEM_IDS.epicServer) && i.remedy.startsWith(AGENT_CHOICE_REMEDY_PREFIX))));
|
|
771
|
+
if (advisories.length)
|
|
772
|
+
lines.push('Advisory findings (not blocking)', ...advisories.map(i => ` ${i.label}: ${i.remedy}`));
|
|
461
773
|
lines.push(setupVerdictLine(items));
|
|
462
774
|
}
|
|
463
775
|
return ['', heading, ...lines];
|
|
@@ -475,9 +787,10 @@ export function renderSetupAssessment(items, heading, phase = 'final') {
|
|
|
475
787
|
const unmet = unmetBlockingItems(items);
|
|
476
788
|
if (unmet.length > 0) {
|
|
477
789
|
lines.push("", "Steps left");
|
|
478
|
-
unmet.forEach((item, index) => lines.push(` ${index + 1}. ${item.label}: ${item
|
|
790
|
+
unmet.forEach((item, index) => lines.push(` ${index + 1}. ${item.label}: ${setupItemRemedy(item)}`));
|
|
479
791
|
}
|
|
480
|
-
|
|
792
|
+
// BAPI-1546: a met epic-server item may still carry its failed statement write.
|
|
793
|
+
const advisories = items.filter((i) => !i.blocking && i.remedy !== null && (i.state !== "met" || i.id === SETUP_ITEM_IDS.epicServer));
|
|
481
794
|
if (advisories.length > 0) {
|
|
482
795
|
lines.push("", "Also worth doing (advisory)");
|
|
483
796
|
for (const item of advisories)
|
|
@@ -485,6 +798,23 @@ export function renderSetupAssessment(items, heading, phase = 'final') {
|
|
|
485
798
|
}
|
|
486
799
|
return lines;
|
|
487
800
|
}
|
|
801
|
+
/** The advisory setup-PR fact. Only a known closed-unmerged PR is deficient and carries a remedy. */
|
|
802
|
+
function setupPullRequestFact(pr, workflowInstalled) {
|
|
803
|
+
switch (pr.state) {
|
|
804
|
+
case 'closed_unmerged':
|
|
805
|
+
// With the workflow already on the default branch the closed PR is moot.
|
|
806
|
+
if (workflowInstalled)
|
|
807
|
+
return { id: 'local.setup-pr', observed_state: 'unknown', impact: 'advisory' };
|
|
808
|
+
return { id: 'local.setup-pr', observed_state: 'deficient', impact: 'advisory', remedy: closedSetupPullRequestNotice(pr) };
|
|
809
|
+
case 'merged':
|
|
810
|
+
return { id: 'local.setup-pr', observed_state: 'confirmed', impact: 'advisory' };
|
|
811
|
+
case 'open':
|
|
812
|
+
return { id: 'local.setup-pr', observed_state: 'pending', impact: 'advisory' };
|
|
813
|
+
case 'none':
|
|
814
|
+
case 'unknown':
|
|
815
|
+
return { id: 'local.setup-pr', observed_state: 'unknown', impact: 'advisory' };
|
|
816
|
+
}
|
|
817
|
+
}
|
|
488
818
|
/** Separate negotiated path: local setup never overlays server-owned facts. */
|
|
489
819
|
function projectAssessmentSetupItems(evidence) {
|
|
490
820
|
const state = (value) => value === null ? 'unknown' : value ? 'confirmed' : 'absent';
|
|
@@ -496,20 +826,146 @@ function projectAssessmentSetupItems(evidence) {
|
|
|
496
826
|
if (evidence.mergeCredential.state !== 'not_applicable')
|
|
497
827
|
localFacts.push({ id: 'local.merge-credential',
|
|
498
828
|
observed_state: evidence.mergeCredential.state === 'configured' ? 'confirmed' : evidence.mergeCredential.state === 'unknown' ? 'unknown' : 'absent', impact: 'mandatory' });
|
|
499
|
-
localFacts.push({ id: 'local.workflow', observed_state: evidence.workflow.state === 'installed' ? 'confirmed' : evidence.workflow.state === 'unknown' ? 'unknown' : 'pending', impact: 'advisory' },
|
|
829
|
+
localFacts.push({ id: 'local.workflow', observed_state: evidence.workflow.state === 'installed' ? 'confirmed' : evidence.workflow.state === 'unknown' ? 'unknown' : 'pending', impact: 'advisory' }, setupPullRequestFact(evidence.setupPullRequest, evidence.workflow.state === 'installed'), { id: 'local.index-progress', observed_state: evidence.index.state === 'reached' ? 'confirmed' : ['in_progress', 'queued_by_setup', 'recovery_pending'].includes(evidence.index.state) ? 'pending' : 'unknown', impact: 'advisory' });
|
|
500
830
|
const assessment = composeReadinessAssessment(evidence.readiness?.assessmentNegotiation ?? { status: 'unavailable' }, localFacts);
|
|
501
|
-
|
|
831
|
+
// BAPI-1635: a valid launch-profile route satisfies escalation for this run only. The
|
|
832
|
+
// composed assessment stays untouched; the effective copy feeds the items and the verdict.
|
|
833
|
+
const escalationRecord = assessment.records.find(r => r.id === SETUP_ITEM_IDS.escalation && r.blocking_effect !== 'none');
|
|
834
|
+
const profileSatisfies = evidence.notification?.state === 'declared' && escalationRecord !== undefined;
|
|
835
|
+
const effective = profileSatisfies
|
|
836
|
+
? Object.freeze({ ...assessment, records: assessment.records.map(r => r === escalationRecord ? { ...r, blocking_effect: 'none' } : r) })
|
|
837
|
+
: assessment;
|
|
838
|
+
// The remedy decision matrix. Terminal results are the established ones; the agent path
|
|
839
|
+
// differs only where a printed command would prompt for input.
|
|
840
|
+
// no blocking effect ............... null
|
|
841
|
+
// unbound indexed revision, parse active ... pending-index remedy
|
|
842
|
+
// unbound indexed revision, no parse ....... re-index remedy
|
|
843
|
+
// unbound default-branch revision .......... GitHub-access remedy
|
|
844
|
+
// other unresolved, pending ................ wait for indexing
|
|
845
|
+
// other unresolved, unverified index ....... manual re-index
|
|
846
|
+
// other unresolved ......................... retry
|
|
847
|
+
// escalation ............................... notification-aware remedy
|
|
848
|
+
// direct supported reference ............... its table remedy
|
|
849
|
+
// resolver fallback ........................ resolver result; on the agent path a
|
|
850
|
+
// prompting setup command is wrapped
|
|
851
|
+
const recordRemedy = (r) => {
|
|
852
|
+
if (r.blocking_effect === 'none')
|
|
853
|
+
return null;
|
|
854
|
+
// BAPI-1657: only a known-missing gate with a readable basis and a planned write says approval stores it.
|
|
855
|
+
if (r.id === 'server.gate-profile' && r.observed_state === 'unknown' && r.basis !== undefined
|
|
856
|
+
&& r.basis !== 'policy_unreadable' && evidence.plannedGateWrite === true) {
|
|
857
|
+
return GATE_STORED_ON_APPROVAL_REMEDY;
|
|
858
|
+
}
|
|
859
|
+
if (r.blocking_effect === 'unresolved') {
|
|
860
|
+
// An unbound revision is not cured by a retry: name the action that supplies it.
|
|
861
|
+
// Any scope other than these two keeps the generic handling below.
|
|
862
|
+
if (r.reason === 'revision_unbound') {
|
|
863
|
+
if (r.scope === 'indexed_commit') {
|
|
864
|
+
return ACTIVE_INDEX_STATES.includes(evidence.index.state)
|
|
865
|
+
? READINESS_PREREQUISITE_FIXES.pending_index
|
|
866
|
+
: READINESS_PREREQUISITE_FIXES.reindex_manual;
|
|
867
|
+
}
|
|
868
|
+
if (r.scope === 'default_branch')
|
|
869
|
+
return DEFAULT_BRANCH_ACCESS_REMEDY;
|
|
870
|
+
}
|
|
871
|
+
// Only a KNOWN state with a server-named index remedy (an index never verified) gets a repair;
|
|
872
|
+
// unreadable or unknown evidence retries, and a running parse is waited on.
|
|
873
|
+
if (r.observed_state === 'pending')
|
|
874
|
+
return 'indexing is running; re-run setup when it finishes';
|
|
875
|
+
return r.observed_state === 'unverified' && r.remedy.reference === 'index'
|
|
876
|
+
? READINESS_PREREQUISITE_FIXES.reindex_manual
|
|
877
|
+
: READINESS_PREREQUISITE_FIXES.retry;
|
|
878
|
+
}
|
|
879
|
+
if (r.id === SETUP_ITEM_IDS.escalation)
|
|
880
|
+
return evidence.notification?.state === 'unreadable' ? READINESS_PREREQUISITE_FIXES.retry : profilePolicyRemedyFor(evidence);
|
|
881
|
+
const reference = r.remedy.reference;
|
|
882
|
+
return ['github', 'escalation', 'self_host', 'consent', 'missing_review_workflow'].includes(reference)
|
|
883
|
+
? READINESS_PREREQUISITE_FIXES[reference]
|
|
884
|
+
: agentRunnableRemedy(resolveReadinessRemedy({ id: r.id, state: 'not_met', scope: READINESS_PREREQUISITE_BY_ID.get(r.id)?.scope }), evidence);
|
|
885
|
+
};
|
|
886
|
+
const items = effective.records.map(r => ({ id: `${r.scope}:${r.id}`, label: ASSESSMENT_ONLY_LABELS[r.id] ?? catalogLabel(r.id),
|
|
502
887
|
state: r.blocking_effect === 'blocker' ? 'needs_action' : r.blocking_effect === 'unresolved' ? r.observed_state === 'pending' ? 'pending' : 'unknown' : 'met',
|
|
503
|
-
blocking: r.impact === 'mandatory' && r.applicability !== 'policy_inapplicable', remedy:
|
|
504
|
-
|
|
505
|
-
|
|
888
|
+
blocking: r.impact === 'mandatory' && r.applicability !== 'policy_inapplicable', remedy: recordRemedy(r) }));
|
|
889
|
+
const localRemedy = (f) => {
|
|
890
|
+
if (f.observed_state === 'confirmed')
|
|
891
|
+
return null;
|
|
892
|
+
if (f.id === 'local.github-login')
|
|
893
|
+
return githubSignInRemedy(evidence.githubSignIn);
|
|
894
|
+
if (f.id === 'local.repository-identity')
|
|
895
|
+
return repositoryIdentityRemedy(evidence.repositoryIdentity);
|
|
896
|
+
if (f.id === 'local.merge-credential')
|
|
897
|
+
return projectMergeCredential(evidence.mergeCredential)?.remedy ?? null;
|
|
898
|
+
return null;
|
|
899
|
+
};
|
|
900
|
+
items.push(...localFacts.map(f => ({ id: f.id, label: LOCAL_FACT_LABELS[f.id] ?? f.id, state: (f.observed_state === 'confirmed' ? 'met' : f.observed_state === 'absent' ? 'needs_action' : 'unknown'),
|
|
901
|
+
blocking: f.impact === 'mandatory', remedy: localRemedy(f) })));
|
|
902
|
+
const grantItem = projectMcpGrantItem(evidence.mcpGrant, evidence.path);
|
|
903
|
+
if (grantItem !== null)
|
|
904
|
+
items.push(grantItem);
|
|
905
|
+
const epicServerItem = projectEpicServerItem(evidence.epicServer, evidence.path);
|
|
906
|
+
if (epicServerItem !== null)
|
|
907
|
+
items.push(epicServerItem);
|
|
908
|
+
// BAPI-1635: advisory findings beside the server's records; neither changes the verdict.
|
|
909
|
+
const freshnessItem = projectFreshnessItem(evidence.freshness);
|
|
910
|
+
if (freshnessItem !== null)
|
|
911
|
+
items.push(freshnessItem);
|
|
912
|
+
const driftItem = projectCommandDriftItem(evidence);
|
|
913
|
+
if (driftItem !== null)
|
|
914
|
+
items.push(driftItem);
|
|
506
915
|
if (assessment.negotiation !== 'available')
|
|
507
916
|
items.unshift({ id: 'assessment.coverage', label: 'Server assessment coverage', state: 'unknown', blocking: true, remedy: 'Upgrade the Bridge backend or contact Bridge support, then retry readiness.' });
|
|
508
917
|
// The attached composition is immutable and reused by both final renderers.
|
|
509
|
-
if (items[0])
|
|
918
|
+
if (items[0]) {
|
|
510
919
|
items[0].assessment = assessment;
|
|
920
|
+
if (profileSatisfies && evidence.notification?.state === 'declared') {
|
|
921
|
+
items[0].effectiveAssessment = effective;
|
|
922
|
+
items[0].escalationProfile = evidence.notification.profile;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
511
925
|
return items;
|
|
512
926
|
}
|
|
927
|
+
/**
|
|
928
|
+
* BAPI-1657: plain owner-facing labels for the local setup rows. These are local
|
|
929
|
+
* presentation facts, so they stay out of the shared readiness catalog. Every
|
|
930
|
+
* local row the projection emits has an entry here.
|
|
931
|
+
*/
|
|
932
|
+
const LOCAL_FACT_LABELS = {
|
|
933
|
+
'local.claude-login': 'Claude sign-in',
|
|
934
|
+
'local.github-login': 'GitHub sign-in',
|
|
935
|
+
'local.repository-identity': 'Repository identity',
|
|
936
|
+
'local.merge-credential': 'Merge credential',
|
|
937
|
+
'local.executor-installation': 'Executor installation',
|
|
938
|
+
'local.workflow': 'Workflow installation',
|
|
939
|
+
'local.setup-pr': 'Setup pull request',
|
|
940
|
+
'local.index-progress': 'Index progress',
|
|
941
|
+
};
|
|
942
|
+
/** Labels for assessment-only records, matching the assessment renderer's own. */
|
|
943
|
+
const ASSESSMENT_ONLY_LABELS = {
|
|
944
|
+
'server.canonical-index': 'Canonical index validity',
|
|
945
|
+
'server.parse-progress': 'Parse progress',
|
|
946
|
+
};
|
|
947
|
+
/** Only the plain-command remedies are wrapped; flag-driven ones (such as the executor fix) stay as printed. */
|
|
948
|
+
const AGENT_WRAPPED_REMEDIES = [
|
|
949
|
+
READINESS_PREREQUISITE_FIXES.install_setup,
|
|
950
|
+
READINESS_PREREQUISITE_FIXES.supervisor_gate,
|
|
951
|
+
];
|
|
952
|
+
/**
|
|
953
|
+
* The printed setup command prompts for input, so an agent cannot run it as printed.
|
|
954
|
+
* On the agent path it is replaced by the existing proposal and approved-answers route,
|
|
955
|
+
* in the detected launcher form. The terminal result is returned untouched.
|
|
956
|
+
*/
|
|
957
|
+
function agentRunnableRemedy(remedy, evidence) {
|
|
958
|
+
if (evidence.path !== "agent" || !AGENT_WRAPPED_REMEDIES.includes(remedy))
|
|
959
|
+
return remedy;
|
|
960
|
+
const command = setupCommandFor(evidence);
|
|
961
|
+
return `Run ${command} --json to see the setup proposal, then run ${command} --answers <answers-file> with the owner's approved answers, then retry readiness.`;
|
|
962
|
+
}
|
|
963
|
+
/** The identity remedy in one place, so both projection paths print the same text. */
|
|
964
|
+
function repositoryIdentityRemedy(state) {
|
|
965
|
+
return state === "conflict"
|
|
966
|
+
? "this checkout's github.com remote names a different repository than Bridge does; run setup from the matching checkout"
|
|
967
|
+
: "run setup from a checkout whose `origin` remote is the github.com repository";
|
|
968
|
+
}
|
|
513
969
|
function additionalRequiredItems(items, assessment) {
|
|
514
970
|
const represented = new Set([...assessment.records.map(r => `${r.scope}:${r.id}`), ...assessment.local.map(r => r.id), 'assessment.coverage']);
|
|
515
971
|
return items.filter(i => i.blocking && i.state !== 'met' && !represented.has(i.id));
|