@bridge_gpt/mcp-server 0.2.71 → 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 +55 -17
- package/build/agent-launchers/claude-executor-adapter.js +22 -3
- package/build/agent-notes.js +171 -95
- package/build/agents.generated.js +7 -7
- package/build/bridge-permissions.js +31 -0
- package/build/bridge-worktree-inspection.js +237 -0
- package/build/check-evidence.js +6 -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/claude-review-workflow.js +1 -1
- package/build/cli-help.js +6 -0
- package/build/codex-auto-recovery.js +126 -0
- package/build/codex-launcher-pin.js +33 -2
- package/build/codex-skill-adapter.js +5 -1
- package/build/command-host.js +33 -0
- package/build/commands.generated.js +7 -6
- package/build/conductor/bridge-api-client.js +1352 -50
- 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 +187 -28
- 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 +213 -13
- 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 +281 -10
- package/build/conductor/gate-settings-review.js +525 -5
- package/build/conductor/git-hooks-uninstall.js +112 -0
- package/build/conductor/git-hooks.js +81 -15
- package/build/conductor/guided-repair.js +10 -1
- package/build/conductor/install-doctor.js +2 -4
- package/build/conductor/launch-need-probes.js +6 -53
- package/build/conductor/launch-plan.js +318 -121
- package/build/conductor/local-merge.js +12 -1
- package/build/conductor/merge-execution-contract.js +1 -1
- package/build/conductor/merged-child-check.js +2 -1
- package/build/conductor/prerequisite-inputs.js +1213 -0
- package/build/conductor/readiness-assessment.js +93 -0
- package/build/conductor/readiness-cli.js +30 -9
- package/build/conductor/readiness-prerequisites.js +77 -5
- package/build/conductor/readiness-sections.js +146 -126
- package/build/conductor/readiness.js +21 -3
- package/build/conductor/recovery-cli.js +236 -15
- package/build/conductor/recovery-operations.js +34 -4
- package/build/conductor/repair-contract.js +33 -0
- package/build/conductor/tools.js +36 -4
- package/build/conductor/wait-run-attention.js +115 -0
- package/build/conductor/wait-run-cli.js +300 -21
- package/build/conductor/worker-database-doctor-inspector.js +34 -2
- package/build/conductor/worker-setup-tally.js +27 -0
- package/build/credential-store.js +96 -21
- package/build/dependency-install-declarations.js +212 -0
- package/build/docs.generated.js +4 -4
- package/build/doctor.js +91 -8
- package/build/drive-epic-help.js +23 -4
- package/build/drive-epic.js +1841 -340
- 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 +2184 -52
- package/build/epic-launch-context.js +607 -0
- package/build/epic-launch-profile.js +1 -1
- 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/cli.js +2 -0
- package/build/executor/completion-contract.js +24 -1
- package/build/executor/credentials.js +1 -1
- package/build/executor/delivery-observations.js +113 -0
- package/build/executor/delivery-outcome.js +30 -0
- package/build/executor/dependency-refresh-runner.js +132 -0
- package/build/executor/dependency-refresh.js +530 -0
- package/build/executor/deps.js +4 -0
- package/build/executor/env.js +119 -17
- package/build/executor/epic-server-context.js +141 -0
- package/build/executor/gate-qualification-job.js +127 -26
- package/build/executor/harness-coverage.js +19 -0
- package/build/executor/http-client.js +87 -6
- package/build/executor/index.js +2 -1
- package/build/executor/install-preflight.js +1 -1
- package/build/executor/job-runner.js +659 -87
- package/build/executor/likely-tests.js +94 -97
- package/build/executor/observation.js +8 -0
- package/build/executor/pre-pr-checks.js +363 -0
- package/build/executor/prompt-spec.js +127 -5
- package/build/executor/reconcile-overlap-job.js +5 -3
- package/build/executor/required-verification.js +28 -0
- package/build/executor/required-work-diagnostics.js +32 -0
- package/build/executor/required-work-ledger.js +955 -39
- package/build/executor/results.js +100 -0
- package/build/executor/service-discovery.js +42 -0
- package/build/executor/service-lifecycle.js +109 -2
- package/build/executor/service-uninstall.js +205 -0
- package/build/executor/service-unit.js +5 -3
- package/build/executor/terminal-mutation.js +8 -0
- package/build/executor/test-clock.js +3 -0
- package/build/executor/verification-hints.js +179 -0
- package/build/executor/worker-command.js +126 -5
- package/build/executor/worker-database-config.js +281 -0
- package/build/executor/worker-database-target.js +16 -12
- package/build/executor/worker-database.js +575 -116
- package/build/executor/worker-finalization.js +71 -10
- package/build/executor/worker-guard-hook.js +10 -2
- package/build/executor/worker-resources.js +25 -3
- package/build/executor/worker-verification-guidance.js +55 -5
- package/build/executor/worktree-inspection.js +42 -0
- package/build/executor/worktree.js +20 -1
- package/build/executor-launch.js +54 -2
- package/build/generated-assets-catalog.js +2 -2
- package/build/github-sign-in.js +1 -1
- package/build/index.js +1111 -381
- package/build/init.js +29 -14
- 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 +1383 -188
- package/build/install-bridge-conductor-setup.js +637 -92
- package/build/install-bridge-conductor.js +3163 -740
- package/build/install-bridge.js +601 -128
- package/build/install-maintenance.js +127 -0
- package/build/install-reexec.js +1 -1
- package/build/launcher-config-inspection.js +162 -1
- package/build/local-cleanup.js +59 -0
- 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-install-state.js +68 -2
- 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 +236 -111
- package/build/package-script-semantics.js +10 -0
- package/build/pipeline-utils.js +1 -1
- package/build/pipelines.generated.js +6 -6
- package/build/plan-discovery.js +97 -4
- package/build/plan-execution-ledger.js +248 -9
- 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 +23 -7
- package/build/plane/preflight.js +50 -10
- package/build/plane/shutdown.js +19 -0
- package/build/plane/terminal-run-cleanup.js +23 -5
- package/build/plane/terminal-run-status.js +4 -0
- package/build/printed-remedy-commands.js +229 -15
- package/build/readiness-check.js +1 -1
- package/build/readiness-prerequisites.generated.js +311 -4
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +38 -0
- package/build/repository-toolchains.js +50 -8
- package/build/run-unit-tests-launcher.js +8 -1
- package/build/setup-change-policy.js +32 -0
- package/build/setup-epic.js +1192 -198
- package/build/setup-progress.js +44 -0
- package/build/setup-question.js +180 -0
- package/build/start-tickets.js +4 -0
- package/build/test-command-detection.js +32 -88
- package/build/test-support/notes-fs.js +40 -0
- package/build/third-party-mcp-targets.js +30 -0
- package/build/ticket-delivery-enrollment.js +30 -8
- package/build/ticket-delivery-run-scope.js +128 -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/worker-guard-hook-bin.js +2 -2
- package/build/worktrees.js +105 -0
- package/docs/EPIC-IMPLEMENTER-INSTALL.md +9 -1
- package/docs/EPIC-IMPLEMENTER.md +5 -0
- package/docs/epic-implementer/getting-started.md +42 -15
- package/docs/epic-implementer/self-hosting.md +14 -1
- package/package.json +2 -2
|
@@ -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).
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isTerminalRunCleanupStatus } from "./terminal-run-status.js";
|
|
1
2
|
import { monotonicNow, elapsedMs } from "../conductor/precheck-timings.js";
|
|
2
3
|
/**
|
|
3
4
|
* Local-plane freshness evidence (BAPI-1476).
|
|
@@ -62,8 +63,6 @@ const BOUND_RUN_STATUSES = new Set([
|
|
|
62
63
|
"abandoned",
|
|
63
64
|
"done",
|
|
64
65
|
]);
|
|
65
|
-
/** The run statuses after which nothing more will happen (as `wait-run` uses). */
|
|
66
|
-
const BOUND_RUN_TERMINAL_STATUSES = new Set(["done", "abandoned"]);
|
|
67
66
|
/** A run id is rendered only when it has a plain, bounded identifier shape. */
|
|
68
67
|
const BOUND_RUN_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
|
|
69
68
|
/**
|
|
@@ -72,8 +71,8 @@ const BOUND_RUN_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
|
|
|
72
71
|
* - Non-terminal and unknown status: inspect the run and the plane. It NEVER
|
|
73
72
|
* recommends `plane down`, because that would stop a run that may still be
|
|
74
73
|
* working, and an unknown status is not evidence that it is finished.
|
|
75
|
-
* - Terminal status (`done`/`abandoned`):
|
|
76
|
-
*
|
|
74
|
+
* - Terminal status (`done`/`abandoned`): this launch's create attempts guarded cleanup
|
|
75
|
+
* of the plane; if that cleanup reports it was incomplete, inspect with
|
|
77
76
|
* `plane status` before any manual wind-down.
|
|
78
77
|
*
|
|
79
78
|
* Pure and secret-free: the output names only the run id and a closed status.
|
|
@@ -83,10 +82,10 @@ export function formatBoundPlaneStaleRemedy(input) {
|
|
|
83
82
|
? `run ${input.epicRunId}`
|
|
84
83
|
: "its bound run";
|
|
85
84
|
const status = typeof input.status === "string" && BOUND_RUN_STATUSES.has(input.status) ? input.status : null;
|
|
86
|
-
if (
|
|
85
|
+
if (isTerminalRunCleanupStatus(status)) {
|
|
87
86
|
return (`this plane is bound to ${runLabel}, which is ${status}. Bring the main checkout up to ` +
|
|
88
|
-
"`origin/main`;
|
|
89
|
-
"
|
|
87
|
+
"`origin/main`; this launch's create attempts guarded cleanup of this plane " +
|
|
88
|
+
"before starting a fresh one. If that cleanup reports it was incomplete, inspect the plane " +
|
|
90
89
|
"with `plane status` before winding it down by hand. This CLI does not update the " +
|
|
91
90
|
`checkout. ${PLANE_BOUND_STALE_OVERRIDE_NOTE}`);
|
|
92
91
|
}
|
|
@@ -96,6 +95,23 @@ export function formatBoundPlaneStaleRemedy(input) {
|
|
|
96
95
|
"run finish or stop it deliberately before refreshing the plane. This CLI does not update " +
|
|
97
96
|
`the checkout. ${PLANE_BOUND_STALE_OVERRIDE_NOTE}`);
|
|
98
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
|
+
}
|
|
99
115
|
/** The fix for a confirmed database-head mismatch, plus the override. */
|
|
100
116
|
export const PLANE_DATABASE_HEAD_REMEDY = "run `alembic -c alembic.ini upgrade head`, then retry. `--allow-stale-plane` overrides " +
|
|
101
117
|
"this refusal for one invocation only and repairs nothing.";
|
package/build/plane/preflight.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* it — including any manifest belonging to a plane that is already running.
|
|
13
13
|
*/
|
|
14
14
|
import path from "path";
|
|
15
|
-
import { PLANE_SERVER_PORT_ENV_VAR, planeCheckFinding, planeCheckPassed, } from "./types.js";
|
|
15
|
+
import { PLANE_SERVER_PORT_ENV_VAR, planeCheckFinding, planeCheckPassed, planeCheckSkipped, } from "./types.js";
|
|
16
16
|
import { runLegacyEpicImplementerEnvPreflight } from "../epic-implementer-env.js";
|
|
17
17
|
import { checkPlaneBuildFreshness, checkPlaneRuntimeEntrypoint } from "./build-freshness.js";
|
|
18
18
|
import { checkAlembicHead } from "./alembic-head.js";
|
|
@@ -21,6 +21,36 @@ import { detectClaudeLogin, formatClaudeLoginAdvisory } from "../claude-login.js
|
|
|
21
21
|
import { createReadinessCheck, createReadinessCheckSafely, } from "../readiness-check.js";
|
|
22
22
|
/** Files that must exist for a path to be this repository's root. */
|
|
23
23
|
const REQUIRED_REPO_FILES = ["main.py", "worker.py", "alembic.ini"];
|
|
24
|
+
/** The four markers that identify a Bridge API engine checkout (BAPI-1595). */
|
|
25
|
+
export const BRIDGE_ENGINE_MARKERS = [
|
|
26
|
+
...REQUIRED_REPO_FILES,
|
|
27
|
+
"scripts/conductor_health_check.py",
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* Tri-state classification of `repoRoot` by its Bridge markers.
|
|
31
|
+
*
|
|
32
|
+
* Absence is proven only by `ENOENT` or `ENOTDIR`. A marker that exists as any
|
|
33
|
+
* kind of entry (including a directory standing where a file should be) counts
|
|
34
|
+
* as present, so it can never be read as "every marker is absent".
|
|
35
|
+
*/
|
|
36
|
+
export async function classifyBridgeCheckout(repoRoot, fs) {
|
|
37
|
+
let present = false;
|
|
38
|
+
let unreadable = false;
|
|
39
|
+
for (const marker of BRIDGE_ENGINE_MARKERS) {
|
|
40
|
+
try {
|
|
41
|
+
await fs.stat(path.join(repoRoot, marker));
|
|
42
|
+
present = true;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
const code = error?.code;
|
|
46
|
+
if (code !== "ENOENT" && code !== "ENOTDIR")
|
|
47
|
+
unreadable = true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (present)
|
|
51
|
+
return "bridge";
|
|
52
|
+
return unreadable ? "unknown" : "not_bridge";
|
|
53
|
+
}
|
|
24
54
|
/** Applicability only. Plane startup has additional, independent prerequisites. */
|
|
25
55
|
export async function isBridgeEngineRepository(repoRoot, fs) {
|
|
26
56
|
let missing = false;
|
|
@@ -183,6 +213,8 @@ const ROOT_DEPENDENT_CHECKS = [
|
|
|
183
213
|
["alembic-head", "alembic-head", "Database migration head"],
|
|
184
214
|
["existing-plane", "existing-plane", "Existing plane"],
|
|
185
215
|
];
|
|
216
|
+
/** BAPI-1595 — fixed detail for a Bridge-only check skipped on a confirmed non-Bridge checkout. */
|
|
217
|
+
export const PLANE_NOT_BRIDGE_SKIP_DETAIL = "skipped: this checkout is not a Bridge API checkout, so the Bridge-only check does not apply";
|
|
186
218
|
/** Fixed detail for a prerequisite skipped because the legacy-environment guard refused first. */
|
|
187
219
|
const PLANE_LEGACY_ENVIRONMENT_SKIP_DETAIL = "not run — the legacy-environment guard refused first";
|
|
188
220
|
/**
|
|
@@ -269,7 +301,10 @@ export async function runPlanePreflight(repoRoot, deps) {
|
|
|
269
301
|
}
|
|
270
302
|
return { ok: false, diagnostics, outcomes };
|
|
271
303
|
}
|
|
272
|
-
const
|
|
304
|
+
const notBridge = deps.bridgeApplicability === "not_bridge";
|
|
305
|
+
const rootCheck = record(notBridge
|
|
306
|
+
? planeCheckSkipped("repository-root", "Repository root", PLANE_NOT_BRIDGE_SKIP_DETAIL)
|
|
307
|
+
: await checkRepositoryRoot(repoRoot, deps));
|
|
273
308
|
// Every remaining check is relative to the repository root. Without a valid
|
|
274
309
|
// one there is nothing coherent left to check, so report and stop here rather
|
|
275
310
|
// than emitting a cascade of derived failures the operator cannot act on.
|
|
@@ -307,7 +342,10 @@ export async function runPlanePreflight(repoRoot, deps) {
|
|
|
307
342
|
add(advisory);
|
|
308
343
|
if (!credentials.ok)
|
|
309
344
|
add(credentials.diagnostic);
|
|
310
|
-
record(await checkPlaneBuildFreshness(repoRoot, {
|
|
345
|
+
record(await checkPlaneBuildFreshness(repoRoot, {
|
|
346
|
+
fs: deps.fs,
|
|
347
|
+
...(notBridge ? { isBridge: false } : {}),
|
|
348
|
+
}));
|
|
311
349
|
// Read-only, and evaluated alongside the other independent checks so an
|
|
312
350
|
// unresolvable re-exec target aggregates with them instead of short-circuiting.
|
|
313
351
|
const runtimeEntrypoint = deps.resolveRuntimeEntrypoint();
|
|
@@ -331,13 +369,15 @@ export async function runPlanePreflight(repoRoot, deps) {
|
|
|
331
369
|
remediation: PLANE_SERVER_ENDPOINT_REMEDIATION,
|
|
332
370
|
}, "Local server port", "the configured local server endpoint could not be resolved"));
|
|
333
371
|
}
|
|
334
|
-
record(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
372
|
+
record(notBridge
|
|
373
|
+
? planeCheckSkipped("alembic-head", "Database migration head", PLANE_NOT_BRIDGE_SKIP_DETAIL)
|
|
374
|
+
: await checkAlembicHead(repoRoot, {
|
|
375
|
+
execFile: deps.execFile,
|
|
376
|
+
fileExists: (filePath) => fileExists(filePath, deps.fs),
|
|
377
|
+
platform: deps.platform,
|
|
378
|
+
},
|
|
379
|
+
// The code this plane will RUN. The executable still comes from `repoRoot`.
|
|
380
|
+
deps.codeSnapshot?.path ?? repoRoot));
|
|
341
381
|
const existing = await checkExistingPlane(repoRoot, deps);
|
|
342
382
|
record(existing);
|
|
343
383
|
observations.existingPlane = existing.observation;
|
package/build/plane/shutdown.js
CHANGED
|
@@ -248,6 +248,22 @@ export async function inspectPlaneRunExecutors(runExecutors) {
|
|
|
248
248
|
}
|
|
249
249
|
return { ok: true, targeting, malformed: listed.malformed };
|
|
250
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* Does another run still ride on this plane? True only when a run-scoped
|
|
253
|
+
* executor record for a run OTHER than `epicRunId` targets this plane and its
|
|
254
|
+
* process is VERIFIED alive. Read-only.
|
|
255
|
+
*
|
|
256
|
+
* Deliberately narrower than the terminal-run cleanup's dependency check: an
|
|
257
|
+
* unreadable registry, a malformed record, or an unverifiable process answers
|
|
258
|
+
* `false`, so a single-epic wind-down with a stale record behaves exactly as
|
|
259
|
+
* before. Only a positively live second run blocks.
|
|
260
|
+
*/
|
|
261
|
+
export async function planeHasLiveOtherRunExecutor(runExecutors, epicRunId) {
|
|
262
|
+
const inspected = await inspectPlaneRunExecutors(runExecutors);
|
|
263
|
+
if (!inspected.ok)
|
|
264
|
+
return false;
|
|
265
|
+
return inspected.targeting.some(({ record, state }) => record.epicRunId !== epicRunId && state === "verified");
|
|
266
|
+
}
|
|
251
267
|
/** `verify`, with a throw settled as `unknown` — never a signal target. */
|
|
252
268
|
async function verifyRunExecutorSafely(runExecutors, record) {
|
|
253
269
|
try {
|
|
@@ -406,6 +422,9 @@ function formatRunShutdown(outcome) {
|
|
|
406
422
|
case "already-stopped":
|
|
407
423
|
return [`Run shutdown: run ${outcome.epicRunId} was already stopped; no further action.`];
|
|
408
424
|
case "terminal":
|
|
425
|
+
if (outcome.status === "done") {
|
|
426
|
+
return [`Run shutdown: run ${outcome.epicRunId} already finished (done); nothing to stop.`];
|
|
427
|
+
}
|
|
409
428
|
return [
|
|
410
429
|
`Run shutdown: run ${outcome.epicRunId} is terminal (${outcome.status}) and cannot be ` +
|
|
411
430
|
"stopped. Signalling local processes does not change this — run " +
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isTerminalRunCleanupStatus } from "./terminal-run-status.js";
|
|
1
2
|
/**
|
|
2
3
|
* Terminal-run plane cleanup (BAPI-1496).
|
|
3
4
|
*
|
|
@@ -50,7 +51,8 @@ export function createTerminalRunCleanupDeps(env = process.env) {
|
|
|
50
51
|
resolveAccess: async (repoRoot) => {
|
|
51
52
|
try {
|
|
52
53
|
const { resolveConductorBridgeApiAccess } = await import("../conductor/bridge-api-client.js");
|
|
53
|
-
|
|
54
|
+
// The plane is the run's own server, so follow the selected launch profile to reach it.
|
|
55
|
+
return await resolveConductorBridgeApiAccess({ env, cwd: repoRoot, followEpicLaunchProfile: true });
|
|
54
56
|
}
|
|
55
57
|
catch {
|
|
56
58
|
return { ok: false, kind: "credentials-unavailable", error: "access could not be resolved" };
|
|
@@ -133,7 +135,7 @@ export async function cleanupTerminalRunPlane(input, overrides = {}) {
|
|
|
133
135
|
// Only the statuses after which nothing more will happen (the set `wait-run`
|
|
134
136
|
// uses). Every other status, known or not, leaves the plane alone.
|
|
135
137
|
const status = runState.state.status;
|
|
136
|
-
if (status
|
|
138
|
+
if (!isTerminalRunCleanupStatus(status)) {
|
|
137
139
|
return { kind: "ineligible", reason: "not-terminal" };
|
|
138
140
|
}
|
|
139
141
|
// The executor registry below is this checkout's only. A run launched from a
|
|
@@ -274,16 +276,29 @@ async function otherRunDependency(teardownDeps, epicRunId) {
|
|
|
274
276
|
* positively holds no non-terminal run but the bound one.
|
|
275
277
|
*/
|
|
276
278
|
async function otherServedRun(deps, access, epicRunId) {
|
|
279
|
+
const other = await readOtherLiveRun(deps.listLiveRunIds, access, epicRunId);
|
|
280
|
+
if (other.kind === "unconfirmed")
|
|
281
|
+
return "live-runs-unconfirmed";
|
|
282
|
+
return other.kind === "live" ? "shared-with-live-run" : null;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Read-only: whether the plane's server holds a non-terminal run other than
|
|
286
|
+
* `epicRunId`. `unconfirmed` when the list cannot be read. Never throws. The
|
|
287
|
+
* cleanup above and the launch preview (BAPI-1651) both ask this one question,
|
|
288
|
+
* so the preview cannot promise a cleanup the create will refuse.
|
|
289
|
+
*/
|
|
290
|
+
export async function readOtherLiveRun(listLiveRunIds, access, epicRunId) {
|
|
277
291
|
let ids;
|
|
278
292
|
try {
|
|
279
|
-
ids = await
|
|
293
|
+
ids = await listLiveRunIds(access);
|
|
280
294
|
}
|
|
281
295
|
catch {
|
|
282
296
|
ids = null;
|
|
283
297
|
}
|
|
284
298
|
if (ids === null)
|
|
285
|
-
return "
|
|
286
|
-
|
|
299
|
+
return { kind: "unconfirmed" };
|
|
300
|
+
const other = ids.find((id) => id !== epicRunId);
|
|
301
|
+
return other === undefined ? { kind: "none" } : { kind: "live", epicRunId: other };
|
|
287
302
|
}
|
|
288
303
|
function incomplete(epicRunId, planeId, cause) {
|
|
289
304
|
return {
|
|
@@ -299,5 +314,8 @@ function runLabel(epicRunId) {
|
|
|
299
314
|
}
|
|
300
315
|
/** Exported for callers that render a cleanup outcome: the stderr line, or `null` when silent. */
|
|
301
316
|
export function terminalRunCleanupStderrLine(result) {
|
|
317
|
+
if (result.kind === "completed") {
|
|
318
|
+
return `plane cleanup for finished ${runLabel(result.epicRunId)} completed; the plane manifest was cleared.`;
|
|
319
|
+
}
|
|
302
320
|
return result.kind === "incomplete" || result.kind === "ownership_aborted" ? result.message : null;
|
|
303
321
|
}
|