@bridge_gpt/mcp-server 0.2.72 → 0.2.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/build/agent-launchers/claude-executor-adapter.js +15 -0
- package/build/agents.generated.js +6 -6
- package/build/bridge-config.js +7 -1
- package/build/bridge-permissions.js +30 -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/command-provisioning.js +4 -3
- package/build/commands.generated.js +7 -6
- package/build/conductor/bridge-api-client.js +867 -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 +48 -1
- package/build/conductor/declare-blocked.js +554 -0
- package/build/conductor/declared-extras.js +335 -0
- package/build/conductor/doctor.js +108 -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-pass-output.js +104 -0
- package/build/conductor/driver-pass.js +571 -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 +281 -43
- package/build/conductor/epic-implementer-cli.js +199 -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-upload.js +1567 -0
- package/build/conductor/epic-server-sfcc.js +85 -0
- package/build/conductor/epic-server-state.js +427 -0
- package/build/conductor/epic-server.js +647 -0
- package/build/conductor/gate-discovery.js +196 -11
- package/build/conductor/gate-settings-review.js +261 -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-delivery.js +280 -0
- package/build/credential-launch-safety.js +142 -0
- package/build/credential-materialization.js +91 -16
- package/build/credential-references-node-deps.js +29 -0
- package/build/credential-references.js +1394 -0
- package/build/credential-references.test-fixtures.js +211 -0
- package/build/credential-scan-conventions.js +145 -0
- package/build/credential-scan.js +517 -0
- package/build/credential-store.js +121 -1
- package/build/credentials-cli.js +252 -3
- package/build/dependency-install-declarations.js +102 -1
- package/build/docs.generated.js +10 -3
- package/build/doctor.js +95 -3
- package/build/drive-epic-help.js +21 -2
- package/build/drive-epic.js +2095 -375
- package/build/engine-paths.js +20 -0
- package/build/epic-branch-ci-summary.js +157 -0
- package/build/epic-capability-statement.js +175 -0
- package/build/epic-ci-workflow-drift.js +77 -23
- package/build/epic-ci-workflow-install.js +137 -44
- package/build/epic-ci-workflow-v2.js +274 -0
- package/build/epic-ci-workflow-v3.js +273 -0
- package/build/epic-ci-workflow.js +165 -18
- package/build/epic-implementer-bin.js +2204 -56
- package/build/epic-launch-context.js +702 -0
- package/build/epic-server-record.js +288 -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/credential-delivery-step.js +168 -0
- package/build/executor/deps.js +3 -1
- package/build/executor/env.js +98 -23
- package/build/executor/epic-server-context.js +157 -0
- package/build/executor/gate-qualification-job.js +127 -26
- package/build/executor/guarded-fast-forward-push.js +13 -8
- package/build/executor/http-client.js +52 -5
- package/build/executor/job-runner.js +577 -81
- package/build/executor/observation.js +8 -0
- package/build/executor/permissions.js +85 -3
- package/build/executor/pre-pr-checks.js +363 -0
- package/build/executor/prompt-spec.js +149 -3
- 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 +58 -4
- package/build/generated-assets-catalog.js +2 -2
- package/build/git-exclude-lock.js +187 -0
- package/build/index.js +824 -366
- package/build/init.js +26 -11
- package/build/install-bridge-conductor-answers.js +528 -0
- package/build/install-bridge-conductor-apply.js +288 -0
- package/build/install-bridge-conductor-assessment.js +1222 -0
- package/build/install-bridge-conductor-compact.js +186 -0
- package/build/install-bridge-conductor-contracts.js +72 -0
- package/build/install-bridge-conductor-gate.js +1312 -198
- package/build/install-bridge-conductor-setup.js +577 -83
- package/build/install-bridge-conductor.js +3381 -544
- package/build/install-bridge.js +280 -25
- package/build/install-doctor.js +38 -8
- package/build/install-maintenance.js +26 -3
- package/build/install-sfcc-detection.js +120 -0
- package/build/install-sfcc-setup.js +185 -0
- package/build/launcher-config-inspection.js +162 -1
- package/build/mcp-grant-candidates.js +779 -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 +292 -15
- package/build/mcp-presets.js +107 -0
- package/build/mcp-provisioning.js +155 -6
- package/build/mcp-registration-doctor.js +31 -2
- package/build/mcp-server-invocation.js +19 -1
- package/build/merge-workflow-install.js +243 -110
- package/build/pipelines.generated.js +7 -6
- 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/status.js +8 -2
- package/build/plane/terminal-run-cleanup.js +18 -4
- package/build/printed-remedy-commands.js +211 -12
- package/build/project-root.js +40 -0
- 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 +41 -0
- package/build/repository-toolchains.js +6 -3
- package/build/run-unit-tests-launcher.js +8 -1
- package/build/setup-epic.js +1305 -210
- package/build/setup-progress.js +44 -0
- package/build/setup-question.js +122 -4
- package/build/sfcc/credentials.js +3 -2
- package/build/sfcc/hostname.js +98 -2
- package/build/sfcc/tool-wrapper.js +6 -95
- package/build/start-tickets.js +193 -29
- package/build/test-support/executor-source-files.js +200 -0
- package/build/testing-config-client.js +25 -2
- package/build/third-party-mcp-targets.js +63 -2
- 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/build/with-credentials.js +208 -0
- package/build/worktree-credential-delivery.js +340 -0
- 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
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BAPI-1621: build a missing epic plan DAG from stored ticket data.
|
|
3
|
+
*
|
|
4
|
+
* `drive-epic` needs `epic-plan.dag.json` for every new run. When discovery finds
|
|
5
|
+
* none, setup can build one here instead of stopping. This module is the ONE owner
|
|
6
|
+
* of that policy, and it is pure: every input is injected, and nothing here reads
|
|
7
|
+
* a file, runs a process, opens a socket, reads the environment, or calls a model.
|
|
8
|
+
* `plan-generation-io.ts` collects the inputs and publishes the result.
|
|
9
|
+
*
|
|
10
|
+
* The rules, in the order they apply:
|
|
11
|
+
*
|
|
12
|
+
* - **Nodes come only from the complete child list.** Ticket text never adds a
|
|
13
|
+
* node, changes a status, or names a child. An incomplete list, a repeated or
|
|
14
|
+
* malformed key, or a child with no usable status category or type fails the
|
|
15
|
+
* whole build with a fixed reason.
|
|
16
|
+
* - **Done first, then spikes.** A child whose backend category is `done` is a
|
|
17
|
+
* `done` node whatever its type. An unfinished Spike is left out with the fixed
|
|
18
|
+
* reason `unfinished_spike`. No planned child left means `no_runnable_children`.
|
|
19
|
+
* - **Order is all-or-nothing.** The epic's "Ordered child manifest" section gives
|
|
20
|
+
* the order and edges only when every part of it is usable. Otherwise the
|
|
21
|
+
* children run as one chain in ascending key order.
|
|
22
|
+
* - **Uncertain files never allow parallel work.** File citations in each child's
|
|
23
|
+
* description are kept only when they are safe, repository-relative, and match
|
|
24
|
+
* the tracked-file inventory. If any planned child has no kept file, every
|
|
25
|
+
* planned child runs one at a time, in the selected order, and no node carries
|
|
26
|
+
* `touched_files` (an omitted field is the server's opt-out; `[]` would claim
|
|
27
|
+
* "touches nothing", which is not known).
|
|
28
|
+
*/
|
|
29
|
+
import { EPIC_KEY_PATTERN } from "./drive-epic-key.js";
|
|
30
|
+
/** The generation policy's version. Bump it when any rule here changes. */
|
|
31
|
+
export const PLAN_GENERATOR_VERSION = 1;
|
|
32
|
+
/** The `generated_by` value a generated plan's metadata carries. */
|
|
33
|
+
export const PLAN_GENERATED_BY = "drive-epic";
|
|
34
|
+
/** The DAG `plan_version` every generated plan uses. */
|
|
35
|
+
export const GENERATED_PLAN_VERSION = 1;
|
|
36
|
+
/** Every reason a generation attempt can stop. Fixed vocabulary, never raw text. */
|
|
37
|
+
export const PLAN_GENERATION_FAILURE_REASONS = [
|
|
38
|
+
"enumeration_incomplete",
|
|
39
|
+
"invalid_child_metadata",
|
|
40
|
+
"description_unreadable",
|
|
41
|
+
"no_runnable_children",
|
|
42
|
+
"children_unreadable",
|
|
43
|
+
"inventory_unavailable",
|
|
44
|
+
"access_unavailable",
|
|
45
|
+
"live_run_unknown",
|
|
46
|
+
"discovery_blocked",
|
|
47
|
+
"validation_rejected",
|
|
48
|
+
"validation_unavailable",
|
|
49
|
+
"publish_failed",
|
|
50
|
+
"collision_unresolved",
|
|
51
|
+
];
|
|
52
|
+
/** One fixed, plain sentence per failure reason, for stop text and previews. */
|
|
53
|
+
export const PLAN_GENERATION_FAILURE_TEXT = {
|
|
54
|
+
enumeration_incomplete: "the epic's child list could not be read completely",
|
|
55
|
+
invalid_child_metadata: "a child has a malformed key, or no usable status category or type",
|
|
56
|
+
description_unreadable: "a ticket description could not be read",
|
|
57
|
+
no_runnable_children: "the epic has no unfinished child the Epic Implementer can run",
|
|
58
|
+
children_unreadable: "the epic's child list could not be read",
|
|
59
|
+
inventory_unavailable: "the repository's tracked-file list could not be read",
|
|
60
|
+
access_unavailable: "Bridge API access could not be resolved for the ticket reads",
|
|
61
|
+
live_run_unknown: "whether the epic already has a live run could not be confirmed",
|
|
62
|
+
discovery_blocked: "plan discovery skipped a folder that might hold this epic's plan",
|
|
63
|
+
validation_rejected: "the server's plan validation rejected the generated plan",
|
|
64
|
+
validation_unavailable: "the server's plan validation could not be reached",
|
|
65
|
+
publish_failed: "the generated plan could not be written",
|
|
66
|
+
collision_unresolved: "the generated plan's folder is already taken by something that is not a plan",
|
|
67
|
+
};
|
|
68
|
+
/** Why a planned child was left out of the plan. */
|
|
69
|
+
export const PLAN_GENERATION_EXCLUSION_REASONS = ["unfinished_spike"];
|
|
70
|
+
/** Where the order came from. */
|
|
71
|
+
export const PLAN_GENERATION_ORDER_SOURCES = ["epic_manifest", "key_order"];
|
|
72
|
+
/** Why the plan runs one child at a time, when it does. */
|
|
73
|
+
export const PLAN_GENERATION_SERIALIZED_REASONS = ["unknown_touched_files", "key_order_fallback"];
|
|
74
|
+
/** The backend status categories the builder recognizes. */
|
|
75
|
+
export const RECOGNIZED_STATUS_CATEGORIES = ["new", "indeterminate", "done"];
|
|
76
|
+
/** Ticket keys in stored text. */
|
|
77
|
+
const TICKET_KEY_IN_TEXT = /\b[A-Z][A-Z0-9_]{0,19}-[0-9]+\b/g;
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
// Key ordering
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
/**
|
|
82
|
+
* Ascending, locale-independent key order: project prefix by code unit, then the
|
|
83
|
+
* number numerically, so `BAPI-9` sorts before `BAPI-10`.
|
|
84
|
+
*/
|
|
85
|
+
export function compareTicketKeys(a, b) {
|
|
86
|
+
const split = (key) => {
|
|
87
|
+
const dash = key.lastIndexOf("-");
|
|
88
|
+
return [key.slice(0, dash), Number(key.slice(dash + 1))];
|
|
89
|
+
};
|
|
90
|
+
const [pa, na] = split(a);
|
|
91
|
+
const [pb, nb] = split(b);
|
|
92
|
+
if (pa !== pb)
|
|
93
|
+
return pa < pb ? -1 : 1;
|
|
94
|
+
return na - nb;
|
|
95
|
+
}
|
|
96
|
+
const MD_MANIFEST_HEADING = /^\s{0,3}##\s+ordered child manifest\b/i;
|
|
97
|
+
const JIRA_MANIFEST_HEADING = /^\s*h2\.\s+ordered child manifest\b/i;
|
|
98
|
+
const MD_SECTION_END = /^\s{0,3}#{1,2}\s/;
|
|
99
|
+
const JIRA_SECTION_END = /^\s*h[12]\.\s/;
|
|
100
|
+
const MD_ITEM = /^\s{0,3}(?:[-*+]|\d{1,3}[.)])\s+(.*)$/;
|
|
101
|
+
const JIRA_ITEM = /^(?:#|\*|-)\s+(.*)$/;
|
|
102
|
+
const DEPENDS_ON = /[`*_]*depends_on[`*_]*\s*:\s*/gi;
|
|
103
|
+
const DEPENDS_ON_VALUE = /^[`*_]*\s*(none|[A-Z][A-Z0-9_]{0,19}-[0-9]+(?:\s*,\s*[A-Z][A-Z0-9_]{0,19}-[0-9]+)*)\s*[`*_]*\s*[.;]?\s*[`*_]*\s*$/i;
|
|
104
|
+
/**
|
|
105
|
+
* Parse the epic's "Ordered child manifest" section, or return null when there is
|
|
106
|
+
* no single, well-formed section. Membership and edge checks happen later, against
|
|
107
|
+
* the child list. Ticket text is data: nothing here is executed or followed.
|
|
108
|
+
*/
|
|
109
|
+
export function parseOrderedChildManifest(description) {
|
|
110
|
+
const lines = description.split(/\r?\n/);
|
|
111
|
+
const headings = [];
|
|
112
|
+
lines.forEach((line, index) => {
|
|
113
|
+
if (MD_MANIFEST_HEADING.test(line))
|
|
114
|
+
headings.push({ index, jira: false });
|
|
115
|
+
else if (JIRA_MANIFEST_HEADING.test(line))
|
|
116
|
+
headings.push({ index, jira: true });
|
|
117
|
+
});
|
|
118
|
+
if (headings.length !== 1)
|
|
119
|
+
return null;
|
|
120
|
+
const { index: start, jira } = headings[0];
|
|
121
|
+
const sectionEnd = jira ? JIRA_SECTION_END : MD_SECTION_END;
|
|
122
|
+
const itemPattern = jira ? JIRA_ITEM : MD_ITEM;
|
|
123
|
+
const rawItems = [];
|
|
124
|
+
let current = null;
|
|
125
|
+
const flush = () => {
|
|
126
|
+
if (current !== null)
|
|
127
|
+
rawItems.push(current.join(" "));
|
|
128
|
+
current = null;
|
|
129
|
+
};
|
|
130
|
+
for (let i = start + 1; i < lines.length; i += 1) {
|
|
131
|
+
const line = lines[i];
|
|
132
|
+
if (sectionEnd.test(line))
|
|
133
|
+
break;
|
|
134
|
+
const item = itemPattern.exec(line);
|
|
135
|
+
if (item !== null) {
|
|
136
|
+
flush();
|
|
137
|
+
current = [item[1]];
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (line.trim() === "") {
|
|
141
|
+
flush();
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
// An indented line continues the current item; an unindented paragraph is
|
|
145
|
+
// section prose and is ignored.
|
|
146
|
+
if (current !== null && /^\s+\S/.test(line))
|
|
147
|
+
current.push(line.trim());
|
|
148
|
+
else
|
|
149
|
+
flush();
|
|
150
|
+
}
|
|
151
|
+
flush();
|
|
152
|
+
if (rawItems.length === 0)
|
|
153
|
+
return null;
|
|
154
|
+
const items = [];
|
|
155
|
+
for (const text of rawItems) {
|
|
156
|
+
const markers = [...text.matchAll(DEPENDS_ON)];
|
|
157
|
+
if (markers.length !== 1)
|
|
158
|
+
return null;
|
|
159
|
+
const marker = markers[0];
|
|
160
|
+
const identityText = text.slice(0, marker.index);
|
|
161
|
+
const valueText = text.slice((marker.index ?? 0) + marker[0].length);
|
|
162
|
+
const identities = new Set(identityText.match(TICKET_KEY_IN_TEXT) ?? []);
|
|
163
|
+
if (identities.size !== 1)
|
|
164
|
+
return null;
|
|
165
|
+
const value = DEPENDS_ON_VALUE.exec(valueText);
|
|
166
|
+
if (value === null)
|
|
167
|
+
return null;
|
|
168
|
+
const dependsOn = value[1].toLowerCase() === "none" ? [] : value[1].split(",").map((part) => part.trim().toUpperCase());
|
|
169
|
+
items.push({ key: [...identities][0], dependsOn });
|
|
170
|
+
}
|
|
171
|
+
return items;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Check a parsed manifest against the classified children. Returns the order and
|
|
175
|
+
* edges over retained nodes, or null when ANY part is unusable — never a partly
|
|
176
|
+
* repaired list.
|
|
177
|
+
*/
|
|
178
|
+
function applyManifest(items, allChildKeys, retained, excluded) {
|
|
179
|
+
const seenItems = new Set();
|
|
180
|
+
const listedRetained = new Set();
|
|
181
|
+
const order = [];
|
|
182
|
+
const dependsOn = new Map();
|
|
183
|
+
for (const item of items) {
|
|
184
|
+
if (!allChildKeys.has(item.key) || seenItems.has(item.key))
|
|
185
|
+
return null;
|
|
186
|
+
seenItems.add(item.key);
|
|
187
|
+
const deps = new Set();
|
|
188
|
+
for (const dep of item.dependsOn) {
|
|
189
|
+
// A dependency must be a retained item listed EARLIER: that one rule
|
|
190
|
+
// rejects unknown keys, excluded spikes, self-edges, cycles, and
|
|
191
|
+
// out-of-order declarations.
|
|
192
|
+
if (dep === item.key || deps.has(dep) || !listedRetained.has(dep))
|
|
193
|
+
return null;
|
|
194
|
+
deps.add(dep);
|
|
195
|
+
}
|
|
196
|
+
if (excluded.has(item.key)) {
|
|
197
|
+
// A listed unfinished spike is dropped only when nothing depends on it; a
|
|
198
|
+
// later dependency on it fails the "listed earlier and retained" check.
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
listedRetained.add(item.key);
|
|
202
|
+
order.push(item.key);
|
|
203
|
+
dependsOn.set(item.key, [...deps]);
|
|
204
|
+
}
|
|
205
|
+
for (const key of retained) {
|
|
206
|
+
if (!listedRetained.has(key))
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
return { order, dependsOn };
|
|
210
|
+
}
|
|
211
|
+
// ---------------------------------------------------------------------------
|
|
212
|
+
// Touched-file evidence
|
|
213
|
+
// ---------------------------------------------------------------------------
|
|
214
|
+
const BRACE_SPAN = /\{\{([^{}\r\n]{1,300})\}\}/g;
|
|
215
|
+
const BACKTICK_SPAN = /`([^`\r\n]{1,300})`/g;
|
|
216
|
+
const LINE_SUFFIX = /:\d+(?:[-–]\d+)?$/;
|
|
217
|
+
const UNSAFE_PATH_CHARS = /[\s*?[\]{}$;&|<>()'"!`\\#:,=%^~@]|[\u0000-\u001f\u007f]/;
|
|
218
|
+
export function buildTrackedInventory(trackedFiles) {
|
|
219
|
+
const files = new Set();
|
|
220
|
+
const directories = new Set();
|
|
221
|
+
for (const file of trackedFiles) {
|
|
222
|
+
if (file === "")
|
|
223
|
+
continue;
|
|
224
|
+
files.add(file);
|
|
225
|
+
const parts = file.split("/");
|
|
226
|
+
for (let i = 1; i < parts.length; i += 1)
|
|
227
|
+
directories.add(parts.slice(0, i).join("/"));
|
|
228
|
+
}
|
|
229
|
+
return { files, directories };
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Return the repository-relative path a cited span names, or null when the span is
|
|
233
|
+
* not a safe, plausible repository file. Lexical only: no filesystem access.
|
|
234
|
+
*/
|
|
235
|
+
export function acceptCitedPath(span, inventory) {
|
|
236
|
+
let candidate = span.trim().replace(LINE_SUFFIX, "");
|
|
237
|
+
if (candidate === "" || candidate.length > 300)
|
|
238
|
+
return null;
|
|
239
|
+
if (candidate.startsWith("/") || /^[A-Za-z]:/.test(candidate) || candidate.includes("\\"))
|
|
240
|
+
return null;
|
|
241
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(candidate) || candidate.startsWith("www."))
|
|
242
|
+
return null;
|
|
243
|
+
if (candidate.endsWith("/"))
|
|
244
|
+
return null;
|
|
245
|
+
// Traversal is checked on the raw segments, before any normalization.
|
|
246
|
+
const rawSegments = candidate.split("/");
|
|
247
|
+
if (rawSegments.some((segment) => segment === ".."))
|
|
248
|
+
return null;
|
|
249
|
+
if (UNSAFE_PATH_CHARS.test(candidate))
|
|
250
|
+
return null;
|
|
251
|
+
if (candidate.startsWith("./"))
|
|
252
|
+
candidate = candidate.slice(2);
|
|
253
|
+
const segments = candidate.split("/");
|
|
254
|
+
if (segments.some((segment) => segment === "" || segment === "."))
|
|
255
|
+
return null;
|
|
256
|
+
if (inventory.files.has(candidate))
|
|
257
|
+
return candidate;
|
|
258
|
+
if (inventory.directories.has(candidate))
|
|
259
|
+
return null;
|
|
260
|
+
// A file the change will create: its parent must already hold tracked files.
|
|
261
|
+
// The root never qualifies, so a bare word in backticks is not a new file.
|
|
262
|
+
if (segments.length < 2)
|
|
263
|
+
return null;
|
|
264
|
+
const parent = segments.slice(0, -1).join("/");
|
|
265
|
+
return inventory.directories.has(parent) ? candidate : null;
|
|
266
|
+
}
|
|
267
|
+
/** The safe, deduplicated, sorted paths a description cites. */
|
|
268
|
+
export function extractTouchedFiles(description, inventory) {
|
|
269
|
+
const kept = new Set();
|
|
270
|
+
for (const pattern of [BRACE_SPAN, BACKTICK_SPAN]) {
|
|
271
|
+
for (const match of description.matchAll(pattern)) {
|
|
272
|
+
const accepted = acceptCitedPath(match[1], inventory);
|
|
273
|
+
if (accepted !== null)
|
|
274
|
+
kept.add(accepted);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return [...kept].sort();
|
|
278
|
+
}
|
|
279
|
+
// ---------------------------------------------------------------------------
|
|
280
|
+
// Summary validation (shared with discovery)
|
|
281
|
+
// ---------------------------------------------------------------------------
|
|
282
|
+
const CHILD_KEY_PATTERN = /^[A-Z][A-Z0-9_]{0,19}-[0-9]+$/;
|
|
283
|
+
function isOneOf(values, value) {
|
|
284
|
+
return typeof value === "string" && values.includes(value);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Validate a stored summary against the same fixed vocabularies the builder uses.
|
|
288
|
+
* Returns null for anything else, so free-form metadata never reaches a launch
|
|
289
|
+
* screen.
|
|
290
|
+
*/
|
|
291
|
+
export function parseGeneratedPlanSummary(value) {
|
|
292
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
293
|
+
return null;
|
|
294
|
+
const record = value;
|
|
295
|
+
if (!isOneOf(PLAN_GENERATION_ORDER_SOURCES, record.order_source))
|
|
296
|
+
return null;
|
|
297
|
+
const serialized = record.serialized_reason;
|
|
298
|
+
if (serialized !== null && !isOneOf(PLAN_GENERATION_SERIALIZED_REASONS, serialized))
|
|
299
|
+
return null;
|
|
300
|
+
if (!Array.isArray(record.excluded) || !Array.isArray(record.unknown_files))
|
|
301
|
+
return null;
|
|
302
|
+
const excluded = [];
|
|
303
|
+
for (const entry of record.excluded) {
|
|
304
|
+
if (entry === null || typeof entry !== "object")
|
|
305
|
+
return null;
|
|
306
|
+
const { ticket_key: key, reason } = entry;
|
|
307
|
+
if (typeof key !== "string" || !CHILD_KEY_PATTERN.test(key))
|
|
308
|
+
return null;
|
|
309
|
+
if (!isOneOf(PLAN_GENERATION_EXCLUSION_REASONS, reason))
|
|
310
|
+
return null;
|
|
311
|
+
excluded.push({ ticket_key: key, reason });
|
|
312
|
+
}
|
|
313
|
+
const unknownFiles = [];
|
|
314
|
+
for (const key of record.unknown_files) {
|
|
315
|
+
if (typeof key !== "string" || !CHILD_KEY_PATTERN.test(key))
|
|
316
|
+
return null;
|
|
317
|
+
unknownFiles.push(key);
|
|
318
|
+
}
|
|
319
|
+
return {
|
|
320
|
+
order_source: record.order_source,
|
|
321
|
+
serialized_reason: serialized,
|
|
322
|
+
excluded,
|
|
323
|
+
unknown_files: unknownFiles,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
// ---------------------------------------------------------------------------
|
|
327
|
+
// The builder
|
|
328
|
+
// ---------------------------------------------------------------------------
|
|
329
|
+
/** Build the plan, or return the one fixed reason it cannot be built. */
|
|
330
|
+
export function buildGeneratedEpicPlan(input) {
|
|
331
|
+
const fail = (reason) => ({ ok: false, reason });
|
|
332
|
+
if (!EPIC_KEY_PATTERN.test(input.epicKey))
|
|
333
|
+
return fail("invalid_child_metadata");
|
|
334
|
+
if (input.enumerationComplete !== true)
|
|
335
|
+
return fail("enumeration_incomplete");
|
|
336
|
+
// --- Boundary validation of the authoritative child list. -----------------
|
|
337
|
+
const allKeys = new Set();
|
|
338
|
+
for (const child of input.children) {
|
|
339
|
+
const key = child.ticket_key;
|
|
340
|
+
if (!CHILD_KEY_PATTERN.test(key) || key === input.epicKey || allKeys.has(key)) {
|
|
341
|
+
return fail("invalid_child_metadata");
|
|
342
|
+
}
|
|
343
|
+
if (!isOneOf(RECOGNIZED_STATUS_CATEGORIES, child.status_category))
|
|
344
|
+
return fail("invalid_child_metadata");
|
|
345
|
+
if (typeof child.issue_type !== "string" || child.issue_type.trim() === "") {
|
|
346
|
+
return fail("invalid_child_metadata");
|
|
347
|
+
}
|
|
348
|
+
allKeys.add(key);
|
|
349
|
+
}
|
|
350
|
+
// --- Classify: done first, then unfinished spikes. -------------------------
|
|
351
|
+
const done = new Set();
|
|
352
|
+
const planned = new Set();
|
|
353
|
+
const excludedKeys = new Set();
|
|
354
|
+
for (const child of input.children) {
|
|
355
|
+
if (child.status_category === "done")
|
|
356
|
+
done.add(child.ticket_key);
|
|
357
|
+
else if (child.issue_type.trim().toLowerCase() === "spike")
|
|
358
|
+
excludedKeys.add(child.ticket_key);
|
|
359
|
+
else
|
|
360
|
+
planned.add(child.ticket_key);
|
|
361
|
+
}
|
|
362
|
+
if (planned.size === 0)
|
|
363
|
+
return fail("no_runnable_children");
|
|
364
|
+
for (const key of planned) {
|
|
365
|
+
if (!input.childDescriptions.has(key))
|
|
366
|
+
return fail("description_unreadable");
|
|
367
|
+
}
|
|
368
|
+
const retained = new Set([...done, ...planned]);
|
|
369
|
+
// --- Order: the whole manifest, or ascending key order. --------------------
|
|
370
|
+
const items = parseOrderedChildManifest(input.epicDescription);
|
|
371
|
+
const manifest = items === null ? null : applyManifest(items, allKeys, retained, excludedKeys);
|
|
372
|
+
const orderSource = manifest === null ? "key_order" : "epic_manifest";
|
|
373
|
+
const order = manifest?.order ?? [...retained].sort(compareTicketKeys);
|
|
374
|
+
// --- Files. -----------------------------------------------------------------
|
|
375
|
+
const inventory = buildTrackedInventory(input.trackedFiles);
|
|
376
|
+
const filesByKey = new Map();
|
|
377
|
+
const unknownFiles = [];
|
|
378
|
+
for (const key of order) {
|
|
379
|
+
if (!planned.has(key))
|
|
380
|
+
continue;
|
|
381
|
+
const files = extractTouchedFiles(input.childDescriptions.get(key) ?? "", inventory);
|
|
382
|
+
if (files.length === 0)
|
|
383
|
+
unknownFiles.push(key);
|
|
384
|
+
else
|
|
385
|
+
filesByKey.set(key, files);
|
|
386
|
+
}
|
|
387
|
+
// --- Edges. -----------------------------------------------------------------
|
|
388
|
+
// A chain links PLANNED children only: a done node is already satisfied, so a
|
|
389
|
+
// chain through it would let the next planned child start beside the previous.
|
|
390
|
+
const serializedReason = unknownFiles.length > 0 ? "unknown_touched_files" : manifest === null ? "key_order_fallback" : null;
|
|
391
|
+
const chain = serializedReason !== null;
|
|
392
|
+
const dependsOn = new Map();
|
|
393
|
+
let previousPlanned = null;
|
|
394
|
+
for (const key of order) {
|
|
395
|
+
if (!planned.has(key)) {
|
|
396
|
+
dependsOn.set(key, chain ? [] : [...(manifest?.dependsOn.get(key) ?? [])]);
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
dependsOn.set(key, chain ? (previousPlanned === null ? [] : [previousPlanned]) : [...(manifest?.dependsOn.get(key) ?? [])]);
|
|
400
|
+
previousPlanned = key;
|
|
401
|
+
}
|
|
402
|
+
const nodes = order.map((key) => {
|
|
403
|
+
const node = {
|
|
404
|
+
ticket_key: key,
|
|
405
|
+
status: done.has(key) ? "done" : "planned",
|
|
406
|
+
depends_on: dependsOn.get(key) ?? [],
|
|
407
|
+
};
|
|
408
|
+
// Omitted, never `[]`, whenever files are not known for the whole plan.
|
|
409
|
+
if (unknownFiles.length === 0 && planned.has(key))
|
|
410
|
+
node.touched_files = filesByKey.get(key) ?? [];
|
|
411
|
+
return node;
|
|
412
|
+
});
|
|
413
|
+
const edges = nodes.flatMap((node) => node.depends_on.map((from) => ({ from, to: node.ticket_key })));
|
|
414
|
+
return {
|
|
415
|
+
ok: true,
|
|
416
|
+
dag: { plan_version: GENERATED_PLAN_VERSION, nodes, edges },
|
|
417
|
+
summary: {
|
|
418
|
+
order_source: orderSource,
|
|
419
|
+
serialized_reason: serializedReason,
|
|
420
|
+
excluded: [...excludedKeys].sort(compareTicketKeys).map((key) => ({ ticket_key: key, reason: "unfinished_spike" })),
|
|
421
|
+
unknown_files: unknownFiles,
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* can be older than a rebuild that overwrote files in place.
|
|
14
14
|
*/
|
|
15
15
|
import path from "path";
|
|
16
|
-
import { planeCheckFinding, planeCheckPassed } from "./types.js";
|
|
16
|
+
import { planeCheckFinding, planeCheckPassed, planeCheckSkipped } from "./types.js";
|
|
17
17
|
/** Remediation text embedded in every blocking build diagnostic. */
|
|
18
18
|
export const PLANE_BUILD_REMEDIATION = "cd mcp_server && npm run build";
|
|
19
19
|
/**
|
|
@@ -31,6 +31,8 @@ function isRelevantSourceFile(name) {
|
|
|
31
31
|
return false;
|
|
32
32
|
return true;
|
|
33
33
|
}
|
|
34
|
+
/** BAPI-1595 — fixed detail for the executor-build check skipped outside a Bridge checkout. */
|
|
35
|
+
export const PLANE_BUILD_NOT_BRIDGE_SKIP_DETAIL = "skipped: this checkout is not a Bridge API checkout, so there is no executor build to check";
|
|
34
36
|
/**
|
|
35
37
|
* Newest modification time across the compiled package's TypeScript sources.
|
|
36
38
|
*
|
|
@@ -97,6 +99,9 @@ export async function findBuildMtime(executorEntrypoint, deps) {
|
|
|
97
99
|
export const PLANE_BUILD_FIX_REMEDIATION = "run `cd mcp_server && npm run build` to rebuild the executor entrypoint, then retry.";
|
|
98
100
|
export async function checkPlaneBuildFreshness(repoRoot, deps) {
|
|
99
101
|
const label = "Executor build freshness";
|
|
102
|
+
if (deps.isBridge === false) {
|
|
103
|
+
return planeCheckSkipped("executor-build", label, PLANE_BUILD_NOT_BRIDGE_SKIP_DETAIL);
|
|
104
|
+
}
|
|
100
105
|
const packageRoot = path.join(repoRoot, "mcp_server");
|
|
101
106
|
const buildDir = path.join(packageRoot, "build");
|
|
102
107
|
const executorEntrypoint = path.join(buildDir, "index.js");
|
package/build/plane/cli.js
CHANGED
|
@@ -20,10 +20,10 @@ import { lockCodeSnapshot, prepareCodeSnapshot, releaseCodeSnapshotForManifest,
|
|
|
20
20
|
import { checkAlembicHead } from "./alembic-head.js";
|
|
21
21
|
import { checkSchemaCompatibility } from "./schema-compatibility.js";
|
|
22
22
|
import { formatPlaneRestartOutcome, isPlaneRestartableMember, requestPlaneRestart, } from "./restart.js";
|
|
23
|
-
import { runPlanePreflight } from "./preflight.js";
|
|
23
|
+
import { runPlanePreflight, } from "./preflight.js";
|
|
24
24
|
import { buildPlaneControlPlaneRoster, buildPlaneExecutorLaneRoster, buildPlaneMemberRoster, buildPlaneObserverRoster, resolvePlaneServerEndpoint, resolvePythonExecutable, } from "./member-roster.js";
|
|
25
25
|
import { getPlaneStatus, formatPlaneStatus } from "./status.js";
|
|
26
|
-
import { shutdownPlane, formatPlaneShutdown } from "./shutdown.js";
|
|
26
|
+
import { shutdownPlane, formatPlaneShutdown, planeHasLiveOtherRunExecutor, } from "./shutdown.js";
|
|
27
27
|
import { buildPlaneTeardownDeps } from "./shutdown-deps.js";
|
|
28
28
|
import { cleanupTerminalRunPlane, createTerminalRunCleanupDeps, terminalRunCleanupStderrLine, } from "./terminal-run-cleanup.js";
|
|
29
29
|
import { launchPlaneSupervisor, runPlaneRuntime, PLANE_RUNTIME_TWO_PHASE_FLAG, } from "./supervisor.js";
|
|
@@ -34,6 +34,27 @@ import { resolveRequiredStartTicketsRepoName } from "../start-tickets-repo.js";
|
|
|
34
34
|
export const PLANE_MAX_EXECUTORS = 32;
|
|
35
35
|
/** Default executor lane count when `--executors` is omitted. */
|
|
36
36
|
export const PLANE_DEFAULT_EXECUTORS = 1;
|
|
37
|
+
/**
|
|
38
|
+
* The parallel limit a composed launch assumes when `--parallel` is omitted and
|
|
39
|
+
* no stored limit is readable yet. Mirrors `_DEFAULT_PARALLEL_LIMIT_FALLBACK` in
|
|
40
|
+
* `api/routes/epic_runs.py`: lane sizing happens before the plane is available to
|
|
41
|
+
* ask the server, so the client keeps its own copy of the same default.
|
|
42
|
+
*/
|
|
43
|
+
export const DEFAULT_RUN_PARALLEL_LIMIT = 2;
|
|
44
|
+
/**
|
|
45
|
+
* BAPI-1581 — map a validated run parallel limit to a lane count. One lane serves
|
|
46
|
+
* one job at a time, so a limit of N asks for N lanes, bounded to the plane's own
|
|
47
|
+
* lane range (never below one, never above {@link PLANE_MAX_EXECUTORS}).
|
|
48
|
+
*/
|
|
49
|
+
export function parallelLimitToExecutorLanes(limit) {
|
|
50
|
+
if (!Number.isFinite(limit))
|
|
51
|
+
return PLANE_DEFAULT_EXECUTORS;
|
|
52
|
+
return Math.min(PLANE_MAX_EXECUTORS, Math.max(1, Math.trunc(limit)));
|
|
53
|
+
}
|
|
54
|
+
/** Is this manifest member name an executor lane (`executor-1`, `executor-2`, ...)? */
|
|
55
|
+
export function isPlaneExecutorLaneMember(member) {
|
|
56
|
+
return /^executor-[1-9][0-9]*$/.test(member);
|
|
57
|
+
}
|
|
37
58
|
export function parsePlaneArgs(argv) {
|
|
38
59
|
if (argv.length === 0) {
|
|
39
60
|
return {
|
|
@@ -98,7 +119,7 @@ export function parsePlaneArgs(argv) {
|
|
|
98
119
|
const member = rest[0];
|
|
99
120
|
if (isPlaneRestartableMember(member))
|
|
100
121
|
return { kind: "restart", member };
|
|
101
|
-
if (
|
|
122
|
+
if (isPlaneExecutorLaneMember(member)) {
|
|
102
123
|
return {
|
|
103
124
|
kind: "error",
|
|
104
125
|
message: `per-member restart is unavailable for executor lane '${member}'. Executor lanes are ` +
|
|
@@ -306,6 +327,8 @@ export function getPlaneUsage() {
|
|
|
306
327
|
"",
|
|
307
328
|
"Options:",
|
|
308
329
|
` --executors N Executor lanes to start (default ${PLANE_DEFAULT_EXECUTORS}, max ${PLANE_MAX_EXECUTORS}).`,
|
|
330
|
+
" Each lane serves one job at a time, so a run whose",
|
|
331
|
+
" parallel limit is N needs N lanes.",
|
|
309
332
|
" --epic-run-id <id> Claim scope: serve this epic run. REPEATABLE, and",
|
|
310
333
|
" every id is passed to every lane in the order given.",
|
|
311
334
|
" Mutually exclusive with --repo-wide.",
|
|
@@ -485,6 +508,13 @@ async function runRestartAction(member, sinks, overrides) {
|
|
|
485
508
|
export const PLANE_DOWN_OWNERSHIP_REFUSED = "plane down REFUSED: the plane is not bound to the expected epic run (or its manifest could not " +
|
|
486
509
|
"be read). Nothing was stopped or signalled and the manifest was kept; inspect it with " +
|
|
487
510
|
"`plane status`.";
|
|
511
|
+
/**
|
|
512
|
+
* Said when `plane down --expect-epic-run-id` refuses because another epic run's
|
|
513
|
+
* executor is still live on this plane. Fixed prose.
|
|
514
|
+
*/
|
|
515
|
+
export const PLANE_DOWN_SHARED_RUN_REFUSED = "plane down REFUSED: another epic run's executor is still using this plane. Nothing was " +
|
|
516
|
+
"stopped or signalled and the manifest was kept. Run the same command again after that run " +
|
|
517
|
+
"finishes; its executor exits on its own once the run is terminal.";
|
|
488
518
|
async function runDownAction(sinks, overrides, expectEpicRunId) {
|
|
489
519
|
const repoRoot = overrides.cwd ?? process.cwd();
|
|
490
520
|
if (overrides.down) {
|
|
@@ -495,14 +525,30 @@ async function runDownAction(sinks, overrides, expectEpicRunId) {
|
|
|
495
525
|
return injected.ok ? 0 : 1;
|
|
496
526
|
}
|
|
497
527
|
const fs = createPlaneFsDeps();
|
|
498
|
-
|
|
528
|
+
// The guard reads the executor registry the teardown deps build; assigned
|
|
529
|
+
// below, before `shutdownPlane` can consult it.
|
|
530
|
+
let teardownDeps = null;
|
|
531
|
+
let sharedWithLiveRun = false;
|
|
532
|
+
teardownDeps = buildPlaneTeardownDeps({
|
|
499
533
|
repoRoot,
|
|
500
534
|
env: process.env,
|
|
501
535
|
stopBoundRun: stopBoundEpicRun,
|
|
502
536
|
...(expectEpicRunId !== undefined
|
|
503
|
-
? {
|
|
537
|
+
? {
|
|
538
|
+
ownershipGuard: expectedRunOwnershipGuard(repoRoot, expectEpicRunId, fs, {
|
|
539
|
+
runExecutors: () => teardownDeps?.runExecutors,
|
|
540
|
+
onSharedWithLiveRun: () => {
|
|
541
|
+
sharedWithLiveRun = true;
|
|
542
|
+
},
|
|
543
|
+
}),
|
|
544
|
+
}
|
|
504
545
|
: {}),
|
|
505
|
-
})
|
|
546
|
+
});
|
|
547
|
+
const result = await shutdownPlane(repoRoot, teardownDeps);
|
|
548
|
+
if (!result.ok && result.reason === "ownership-aborted" && sharedWithLiveRun) {
|
|
549
|
+
sinks.stderr(PLANE_DOWN_SHARED_RUN_REFUSED);
|
|
550
|
+
return 1;
|
|
551
|
+
}
|
|
506
552
|
// An unreadable manifest cannot show the expected binding either, so under
|
|
507
553
|
// `--expect-epic-run-id` it is refused with the same fixed line (BAPI-1496).
|
|
508
554
|
if (!result.ok &&
|
|
@@ -522,8 +568,13 @@ async function runDownAction(sinks, overrides, expectEpicRunId) {
|
|
|
522
568
|
* a fresh re-read must still show the same plane bound to it — so a plane that
|
|
523
569
|
* was replaced between the two reads is never signalled. Fixed abort wording:
|
|
524
570
|
* the CLI prints {@link PLANE_DOWN_OWNERSHIP_REFUSED} instead.
|
|
571
|
+
*
|
|
572
|
+
* It also aborts while another run's executor is verified live on this plane,
|
|
573
|
+
* so finishing one epic never stops a second epic sharing the plane. The CLI
|
|
574
|
+
* then prints {@link PLANE_DOWN_SHARED_RUN_REFUSED}. Anything less than a
|
|
575
|
+
* verified live executor proceeds exactly as before.
|
|
525
576
|
*/
|
|
526
|
-
function expectedRunOwnershipGuard(repoRoot, expectEpicRunId, fs) {
|
|
577
|
+
function expectedRunOwnershipGuard(repoRoot, expectEpicRunId, fs, shared) {
|
|
527
578
|
return async (manifest) => {
|
|
528
579
|
if (manifest.epicRunId !== expectEpicRunId) {
|
|
529
580
|
return { kind: "abort", message: "the plane is not bound to the expected epic run" };
|
|
@@ -534,6 +585,11 @@ function expectedRunOwnershipGuard(repoRoot, expectEpicRunId, fs) {
|
|
|
534
585
|
reread.manifest.epicRunId !== expectEpicRunId) {
|
|
535
586
|
return { kind: "abort", message: "the plane manifest changed during wind-down" };
|
|
536
587
|
}
|
|
588
|
+
const runExecutors = shared.runExecutors();
|
|
589
|
+
if (runExecutors !== undefined && (await planeHasLiveOtherRunExecutor(runExecutors, expectEpicRunId))) {
|
|
590
|
+
shared.onSharedWithLiveRun();
|
|
591
|
+
return { kind: "abort", message: "another epic run's executor is still using this plane" };
|
|
592
|
+
}
|
|
537
593
|
return { kind: "proceed" };
|
|
538
594
|
};
|
|
539
595
|
}
|
|
@@ -1190,8 +1246,18 @@ function buildPreflightDeps(env) {
|
|
|
1190
1246
|
* Thin by design. It owns no policy — only the `(repoRoot, env)` -> result
|
|
1191
1247
|
* binding, so there is exactly one place that knows how a real preflight is built.
|
|
1192
1248
|
*/
|
|
1193
|
-
export function runDefaultPlanePreflight(repoRoot, env = process.env
|
|
1194
|
-
|
|
1249
|
+
export function runDefaultPlanePreflight(repoRoot, env = process.env,
|
|
1250
|
+
/**
|
|
1251
|
+
* BAPI-1595 — the VERIFIED Bridge applicability of `repoRoot`, from an advisory
|
|
1252
|
+
* caller only. Only `not_bridge` changes anything. `plane up` never passes it,
|
|
1253
|
+
* so a skipped customer-checkout finding never authorizes starting Bridge
|
|
1254
|
+
* server members from that checkout.
|
|
1255
|
+
*/
|
|
1256
|
+
bridgeApplicability) {
|
|
1257
|
+
return runPlanePreflight(repoRoot, {
|
|
1258
|
+
...buildPreflightDeps(env),
|
|
1259
|
+
...(bridgeApplicability !== undefined ? { bridgeApplicability } : {}),
|
|
1260
|
+
});
|
|
1195
1261
|
}
|
|
1196
1262
|
/**
|
|
1197
1263
|
* Render ONE diagnostic exactly as `plane up` renders it (BAPI-1054).
|
|
@@ -95,6 +95,23 @@ export function formatBoundPlaneStaleRemedy(input) {
|
|
|
95
95
|
"run finish or stop it deliberately before refreshing the plane. This CLI does not update " +
|
|
96
96
|
`the checkout. ${PLANE_BOUND_STALE_OVERRIDE_NOTE}`);
|
|
97
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* BAPI-1651 — the stale-snapshot fix for a plane bound to a FINISHED run when
|
|
100
|
+
* the plane's server still holds another live run, or cannot say. Create's
|
|
101
|
+
* guarded cleanup refuses then, so the preview must not promise it.
|
|
102
|
+
* `otherRunId` is the other live run, or `null` when the list could not be read.
|
|
103
|
+
*/
|
|
104
|
+
export function formatSharedPlaneStaleRemedy(input, otherRunId) {
|
|
105
|
+
const runLabel = BOUND_RUN_ID_PATTERN.test(input.epicRunId) ? `run ${input.epicRunId}` : "its bound run";
|
|
106
|
+
const status = typeof input.status === "string" && BOUND_RUN_STATUSES.has(input.status) ? input.status : "finished";
|
|
107
|
+
const other = otherRunId === null
|
|
108
|
+
? "the plane's server could not confirm that no other run is still live on it"
|
|
109
|
+
: `the plane's server still holds another live run (${BOUND_RUN_ID_PATTERN.test(otherRunId) ? `run ${otherRunId}` : "a run whose id cannot be shown"})`;
|
|
110
|
+
return (`this plane is bound to ${runLabel}, which is ${status}, but ${other}. So this launch's ` +
|
|
111
|
+
"guarded cleanup will refuse to wind the plane down. Make sure no other run is live on this " +
|
|
112
|
+
"plane (let it finish or stop it deliberately), then inspect the plane with `plane status`. This CLI does not update " +
|
|
113
|
+
`the checkout. ${PLANE_BOUND_STALE_OVERRIDE_NOTE}`);
|
|
114
|
+
}
|
|
98
115
|
/** The fix for a confirmed database-head mismatch, plus the override. */
|
|
99
116
|
export const PLANE_DATABASE_HEAD_REMEDY = "run `alembic -c alembic.ini upgrade head`, then retry. `--allow-stale-plane` overrides " +
|
|
100
117
|
"this refusal for one invocation only and repairs nothing.";
|