@bridge_gpt/mcp-server 0.2.76 → 0.2.77
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 +8 -6
- package/build/agents.generated.js +3 -3
- package/build/cli-dispatch.js +333 -0
- package/build/commands.generated.js +5 -5
- package/build/conductor/bridge-api-client.js +52 -7
- package/build/conductor/declare-blocked.js +142 -7
- package/build/conductor/driver-register.js +8 -2
- package/build/conductor/epic-implementer-cli.js +11 -7
- package/build/conductor/epic-server-journal.js +39 -22
- package/build/conductor/launch-plan.js +28 -7
- package/build/conductor/local-merge.js +1 -1
- package/build/conductor/readiness-prerequisites.js +89 -2
- package/build/conductor/recovery-cli.js +2 -0
- package/build/docs.generated.js +67 -4
- package/build/doctor.js +97 -1
- package/build/drive-epic.js +223 -6
- package/build/engine-paths.js +10 -0
- package/build/epic-coherence-input-cli.js +105 -10
- package/build/epic-coherence-input.js +877 -4
- package/build/epic-coherence-input.test-fixtures.js +117 -0
- package/build/epic-implementer-bin.js +901 -94
- package/build/epic-implementer-env.js +2 -2
- package/build/executor/completion-contract.js +14 -1
- package/build/executor/guarded-fast-forward-push.js +25 -2
- package/build/executor/job-runner.js +83 -27
- package/build/executor/likely-tests.js +78 -6
- package/build/executor/provider-checks.js +73 -0
- package/build/executor/rebase-finalization.js +29 -27
- package/build/executor/rename-aside.js +265 -0
- package/build/executor/required-work-ledger.js +82 -4
- package/build/executor/types.js +121 -0
- package/build/executor/worktree.js +27 -1
- package/build/index.js +2449 -386
- package/build/install-bridge-conductor-assessment.js +13 -0
- package/build/install-bridge-conductor.js +60 -776
- package/build/install-bridge.js +4 -11
- package/build/language-catalog.generated.js +2649 -0
- package/build/pipelines.generated.js +45 -17
- package/build/plan-execution-ledger.js +8 -0
- package/build/plan-generation.js +34 -0
- package/build/plane/build-freshness.js +6 -0
- package/build/plane/cli.js +12 -5
- package/build/printed-remedy-commands.js +9 -0
- package/build/readiness-prerequisites.generated.js +28 -0
- package/build/readme.generated.js +1 -1
- package/build/run-unit-tests-launcher.js +3 -1
- package/build/server.js +7946 -0
- package/build/start-tickets-prereqs.js +3 -6
- package/build/test-support/console-guard.js +30 -0
- package/build/test-support/module-imports.js +155 -0
- package/build/test-support/server-client.js +96 -0
- package/build/test-support/stdio-server.js +146 -0
- package/build/v2-readiness-requirements.js +31 -2
- package/build/version.generated.js +3 -3
- package/docs/EPIC-IMPLEMENTER.md +71 -2
- package/docs/epic-implementer/getting-started.md +4 -0
- package/package.json +3 -3
- package/pipelines/learn-repository.json +19 -1
package/build/doctor.js
CHANGED
|
@@ -43,7 +43,10 @@ import { createBridgeApiUrls } from "./bridge-api-urls.js";
|
|
|
43
43
|
import { probeToolSurface } from "./tool-surface-gating.js";
|
|
44
44
|
import { readStoredBindingState, resolveBapiCredentials } from "./credential-store.js";
|
|
45
45
|
import { EPIC_LAUNCH_PROFILE_NAME_PATTERN, listEpicLaunchProfiles } from "./epic-launch-profile.js";
|
|
46
|
-
import { CONDUCTOR_DEFAULT_BASE_URL, resolveConductorBridgeApiAccess } from "./conductor/bridge-api-client.js";
|
|
46
|
+
import { CONDUCTOR_DEFAULT_BASE_URL, resolveConductorBridgeApiAccess, fetchConductorReadiness } from "./conductor/bridge-api-client.js";
|
|
47
|
+
import { formatReadinessPrerequisites, overlayReadinessPrerequisites, toolVisibilityStateFromInspection } from "./conductor/readiness-prerequisites.js";
|
|
48
|
+
import { inspectBridgeApiProfileToken } from "./mcp-host-config.js";
|
|
49
|
+
import { EPIC_IMPLEMENTER_PROFILE_TOKEN } from "./conductor/readiness-sections.js";
|
|
47
50
|
import { validateHttpBaseUrl } from "./base-url.js";
|
|
48
51
|
import { getLiveRepositoryConductors, getParseDispatcherHealth, } from "./epic-shared/bridge-client.js";
|
|
49
52
|
import { resolveRequiredStartTicketsRepoName } from "./start-tickets-repo.js";
|
|
@@ -1195,6 +1198,68 @@ export function formatToolSurfaceDiagnosticReport(diag) {
|
|
|
1195
1198
|
return lines.join("\n");
|
|
1196
1199
|
}
|
|
1197
1200
|
// ---------------------------------------------------------------------------
|
|
1201
|
+
// Epic Implementer readiness rows (BAPI-1747) — STRICTLY read-only.
|
|
1202
|
+
//
|
|
1203
|
+
// One GET to `/jira/epic-runs/conductor-readiness` for doctor's resolved
|
|
1204
|
+
// repository, plus a read-only inspection of the project's MCP host configs for
|
|
1205
|
+
// tool visibility. The rows are composed through the same client overlay the
|
|
1206
|
+
// launch preview and install's final verdict use, so all three name the same
|
|
1207
|
+
// prerequisite IDs and gaps. Any failure prints "Couldn't check"; the section
|
|
1208
|
+
// never writes, never migrates credentials, and never changes the exit code.
|
|
1209
|
+
// ---------------------------------------------------------------------------
|
|
1210
|
+
/** Doctor's bound on its one readiness read. */
|
|
1211
|
+
export const RUN_PATH_READINESS_TIMEOUT_MS = 8_000;
|
|
1212
|
+
async function localToolVisibility(deps) {
|
|
1213
|
+
try {
|
|
1214
|
+
return toolVisibilityStateFromInspection(await deps.inspectProfileToken());
|
|
1215
|
+
}
|
|
1216
|
+
catch {
|
|
1217
|
+
return { state: "unknown", reason: "inspection" };
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
/** Collect the readiness rows read-only. Never throws. */
|
|
1221
|
+
export async function collectRunPathReadinessDiagnostic(deps) {
|
|
1222
|
+
try {
|
|
1223
|
+
const target = await resolveInstallDoctorTarget(deps);
|
|
1224
|
+
if (!target.repoName)
|
|
1225
|
+
return { state: "unresolved", detail: "no BAPI_REPO_NAME in the environment or project-local MCP configs" };
|
|
1226
|
+
const cred = await resolveBapiCredentials(target.repoName, {
|
|
1227
|
+
env: deps.env, homedir: deps.homedir, platform: deps.platform,
|
|
1228
|
+
readFile: deps.readFile, stat: deps.stat, stderr: () => { },
|
|
1229
|
+
});
|
|
1230
|
+
if (!cred.ok)
|
|
1231
|
+
return { state: "unresolved", detail: `no Bridge API credential resolved (${cred.kind})` };
|
|
1232
|
+
// Doctor bounds this one read well below the client's 60s readiness timeout.
|
|
1233
|
+
const bounded = (url, init) => deps.fetch(url, { ...init, signal: AbortSignal.any([init.signal, AbortSignal.timeout(RUN_PATH_READINESS_TIMEOUT_MS)]) });
|
|
1234
|
+
const readiness = await fetchConductorReadiness({ repoName: target.repoName, apiKey: cred.credentials.apiKey, baseUrl: target.baseUrl }, bounded);
|
|
1235
|
+
const toolVisibility = await localToolVisibility(deps);
|
|
1236
|
+
return {
|
|
1237
|
+
state: "read",
|
|
1238
|
+
repoName: target.repoName,
|
|
1239
|
+
prerequisites: overlayReadinessPrerequisites([], readiness.prerequisites ?? [], toolVisibility),
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
catch {
|
|
1243
|
+
return { state: "failed" };
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
/** Render the advisory readiness section (pure formatting). */
|
|
1247
|
+
export function formatRunPathReadinessReport(diag) {
|
|
1248
|
+
const lines = ["", "Epic Implementer readiness (read-only — advisory)", ""];
|
|
1249
|
+
if (diag.state === "read") {
|
|
1250
|
+
lines.push(`Repository: ${diag.repoName}`);
|
|
1251
|
+
lines.push(...formatReadinessPrerequisites(diag.prerequisites, { isProduction: true }));
|
|
1252
|
+
}
|
|
1253
|
+
else if (diag.state === "unresolved") {
|
|
1254
|
+
lines.push(`Couldn't check: ${diag.detail}.`);
|
|
1255
|
+
}
|
|
1256
|
+
else {
|
|
1257
|
+
lines.push("Couldn't check: the readiness read failed. Retry doctor, or run the launch preview.");
|
|
1258
|
+
}
|
|
1259
|
+
lines.push("", "This section is advisory and never changes the exit code.");
|
|
1260
|
+
return lines.join("\n");
|
|
1261
|
+
}
|
|
1262
|
+
// ---------------------------------------------------------------------------
|
|
1198
1263
|
// Executor provisioning diagnostics (BAPI-688) — STRICTLY read-only.
|
|
1199
1264
|
//
|
|
1200
1265
|
// Enumerates the deterministic, convention-named executor service units this
|
|
@@ -2382,6 +2447,37 @@ export async function runDoctorCli(argv, overrides = {}) {
|
|
|
2382
2447
|
}));
|
|
2383
2448
|
}
|
|
2384
2449
|
}
|
|
2450
|
+
// Advisory Epic Implementer readiness section (BAPI-1747). Strictly read-only:
|
|
2451
|
+
// one readiness GET and a host-config read. Any failure prints "Couldn't check"
|
|
2452
|
+
// and never affects the exit code.
|
|
2453
|
+
if (overrides.runPathReadiness !== false) {
|
|
2454
|
+
try {
|
|
2455
|
+
const injectedFs = deps;
|
|
2456
|
+
const o = overrides.runPathReadiness ?? {};
|
|
2457
|
+
const readFileImpl = o.readFile ?? injectedFs.readFile ?? ((p) => readFile(p, "utf-8"));
|
|
2458
|
+
const cwd = o.cwd ?? deps.cwd;
|
|
2459
|
+
const readinessDeps = {
|
|
2460
|
+
env: o.env ?? deps.env,
|
|
2461
|
+
cwd,
|
|
2462
|
+
platform: o.platform ?? deps.platform,
|
|
2463
|
+
homedir: o.homedir ?? injectedFs.homedir ?? os.homedir,
|
|
2464
|
+
readFile: readFileImpl,
|
|
2465
|
+
stat: o.stat ?? injectedFs.stat ?? ((p) => stat(p)),
|
|
2466
|
+
fetch: o.fetch ?? ((url, init) => fetch(url, init)),
|
|
2467
|
+
inspectProfileToken: o.inspectProfileToken ??
|
|
2468
|
+
(() => inspectBridgeApiProfileToken(cwd, EPIC_IMPLEMENTER_PROFILE_TOKEN, { readFile: readFileImpl })),
|
|
2469
|
+
};
|
|
2470
|
+
log(formatRunPathReadinessReport(await collectRunPathReadinessDiagnostic(readinessDeps)));
|
|
2471
|
+
}
|
|
2472
|
+
catch {
|
|
2473
|
+
try {
|
|
2474
|
+
log(formatRunPathReadinessReport({ state: "failed" }));
|
|
2475
|
+
}
|
|
2476
|
+
catch {
|
|
2477
|
+
/* advisory; never block the doctor report */
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2385
2481
|
// Advisory executor-provisioning section (BAPI-688). Strictly read-only: it
|
|
2386
2482
|
// enumerates convention-named units under a fixed OS directory, parses their
|
|
2387
2483
|
// non-secret configuration, and probes credential resolution WITHOUT retaining
|
package/build/drive-epic.js
CHANGED
|
@@ -87,12 +87,12 @@ import { collectWorkerDatabaseDoctorSection, WORKER_DATABASE_DOCTOR_TIMEOUT_MS,
|
|
|
87
87
|
import { buildHostPowerLaunchRow, buildSelfHostedRunnerLaunchRow, buildWorkerDbRoleLaunchRow, hostPowerFactFromReport, LAUNCH_NEED_ROW_IDS, workerDatabaseReadinessChecks, } from "./conductor/readiness-sections.js";
|
|
88
88
|
import { createWorkflowSource, inspectRequiredSelfHostedRunners, } from "./conductor/launch-need-probes.js";
|
|
89
89
|
import { createWorkerDatabaseDoctorInspector } from "./conductor/worker-database-doctor-inspector.js";
|
|
90
|
-
import { ENGINE_PATHS } from "./engine-paths.js";
|
|
91
|
-
import { policyDeclaresNotifyWebhook, policyNotifyDestinationsConflict, notifyDestinationsConflictMessage, effectivePolicyFacts, evaluateParallelPolicyPreflight, parseParallelLimit, readSetupEpicPolicyFile, retainedParallelLimitNotice, resolveFeatureBranchSelection, readCanonicalParseTruth as readSetupCanonicalParseTruth, runSetupEpicWorkflow, launchReconnectCommand, READINESS_UNKNOWN_CONTINUING_WARNING, RUN_WAITING_FOR_APPROVAL_PHRASE, classifyRemoteEpicBranch, formatSetupEpicAutoMergeIntent, resolveSetupEpicAutoMergeIntent, readinessSnapshotFromLaunchContext, } from "./setup-epic.js";
|
|
90
|
+
import { ENGINE_PATHS, isEngineTestFile } from "./engine-paths.js";
|
|
91
|
+
import { policyDeclaresNotifyWebhook, policyNotifyDestinationsConflict, notifyDestinationsConflictMessage, effectivePolicyFacts, evaluateParallelPolicyPreflight, parseParallelLimit, readSetupEpicPolicyFile, retainedParallelLimitNotice, resolveFeatureBranchSelection, readCanonicalParseTruth as readSetupCanonicalParseTruth, runSetupEpicWorkflow, launchReconnectCommand, READINESS_UNKNOWN_CONTINUING_WARNING, RUN_WAITING_FOR_APPROVAL_PHRASE, classifyRemoteEpicBranch, formatSetupEpicAutoMergeIntent, resolveSetupEpicAutoMergeIntent, readinessSnapshotFromLaunchContext, validateEpicPlanSidecar, } from "./setup-epic.js";
|
|
92
92
|
import { getConfigFieldBaseBranch } from "./epic-shared/bridge-client.js";
|
|
93
93
|
import { createExecFileRunCommand, normalizeCommitSha } from "./epic-shared/cut-protocol.js";
|
|
94
94
|
import { EPIC_KEY_PATTERN } from "./drive-epic-key.js";
|
|
95
|
-
import { AUTHORED_PLAN_SERVER_TOO_OLD_NOTICE, AUTHORED_PLAN_UNKNOWN_REASON_ID, AUTHORED_PLAN_UPLOAD_FAILED_REASON_ID, authoredPlanUnknownRemedy, authoredPlanUploadFailedRemedy, createDefaultAuthoredPlanSaveDeps, explainRunPlanHash, lookupAuthoredPlanForLaunch, materializeAuthoredPlanSnapshot, resolveAuthoredPlanAccess, nonServerPlanProvenance, renderPlanProvenanceLine, saveLocalAuthoredPlan, serverPlanProvenance, } from "./authored-plan.js";
|
|
95
|
+
import { AUTHORED_PLAN_DAG_FILE, AUTHORED_PLAN_META_FILE, AUTHORED_PLAN_SERVER_TOO_OLD_NOTICE, AUTHORED_PLAN_UNKNOWN_REASON_ID, AUTHORED_PLAN_UPLOAD_FAILED_REASON_ID, authoredPlanUnknownRemedy, authoredPlanUploadFailedRemedy, createDefaultAuthoredPlanSaveDeps, explainRunPlanHash, lookupAuthoredPlanForLaunch, materializeAuthoredPlanSnapshot, resolveAuthoredPlanAccess, nonServerPlanProvenance, renderPlanProvenanceLine, saveLocalAuthoredPlan, serverPlanProvenance, } from "./authored-plan.js";
|
|
96
96
|
import { hashPlan } from "./conductor/plan.js";
|
|
97
97
|
import { buildEpicLaunchContext, projectWorkerDatabase, readEpicLaunchContext, writeEpicLaunchContext, writeEpicLaunchOutcome, } from "./epic-launch-context.js";
|
|
98
98
|
import { flushProcessStdout, writeJsonDocument } from "./conductor/json-output.js";
|
|
@@ -100,7 +100,7 @@ import { BRIDGE_LAUNCHER_ENV } from "./bridge-permissions.js";
|
|
|
100
100
|
import { checkPlaneBuildFreshness, PLANE_BUILD_FIX_REMEDIATION } from "./plane/build-freshness.js";
|
|
101
101
|
import { discoverEpicPlan, isPlanGenerationEligible, unrelatedMissingMetaPaths, } from "./plan-discovery.js";
|
|
102
102
|
import { attemptPlanGeneration, createDefaultPlanPublicationFs, generatedPlanFolder, listTrackedFilesWithGit, publishGeneratedPlan, validateGeneratedPlan, } from "./plan-generation-io.js";
|
|
103
|
-
import { PLAN_GENERATION_FAILURE_TEXT, } from "./plan-generation.js";
|
|
103
|
+
import { PLAN_GENERATION_FAILURE_TEXT, PLAN_ORDER_NEEDED_REASON_ID, PLAN_ORDER_NEEDED_REMEDY, needsPlanOrder, } from "./plan-generation.js";
|
|
104
104
|
import { DEFAULT_RUN_PARALLEL_LIMIT, formatPlaneDiagnostic, isPlaneExecutorLaneMember, launchPlaneControlPlane, parallelLimitToExecutorLanes, requestPlaneScopedLanes, runDefaultPlanePreflight, runPlaneCli, } from "./plane/cli.js";
|
|
105
105
|
import { PLANE_PORT_PROBE_TIMEOUT_MS, describePlanePortOccupant, classifyBridgeCheckout, } from "./plane/preflight.js";
|
|
106
106
|
import { createPlaneExecFile, createPlaneFsDeps, probeAutomationHealth, probeTcpPort, resolveHostname, } from "./plane/defaults.js";
|
|
@@ -1576,6 +1576,20 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1576
1576
|
// plan: it stops when (and only when) the launch would create a run.
|
|
1577
1577
|
let serverPlan = null;
|
|
1578
1578
|
let authoredLookup = null;
|
|
1579
|
+
// BAPI-1782 — an explicit `--plan-file` in the authored-plan folder shape (the
|
|
1580
|
+
// canonical DAG name beside metadata naming this epic) may be stored as the
|
|
1581
|
+
// epic's authored plan on a real create. It stays the selected plan whatever
|
|
1582
|
+
// the lookup answers; only a definite `not_stored` uploads it, later, on a
|
|
1583
|
+
// create path. Any other file keeps its existing behavior and makes no lookup.
|
|
1584
|
+
const explicitUpload = planFile !== undefined && deps.lookupAuthoredPlan !== undefined
|
|
1585
|
+
? await explicitPlanUploadCandidate(deps, epicKey, planFile)
|
|
1586
|
+
: null;
|
|
1587
|
+
let explicitLookup = null;
|
|
1588
|
+
if (explicitUpload !== null && deps.lookupAuthoredPlan !== undefined) {
|
|
1589
|
+
explicitLookup = await deps
|
|
1590
|
+
.lookupAuthoredPlan(epicKey, repo)
|
|
1591
|
+
.catch(() => ({ lookup: { kind: "unknown", reason: "network" }, endpoint: null }));
|
|
1592
|
+
}
|
|
1579
1593
|
if (planFile === undefined && deps.lookupAuthoredPlan !== undefined) {
|
|
1580
1594
|
authoredLookup = await deps
|
|
1581
1595
|
.lookupAuthoredPlan(epicKey, repo)
|
|
@@ -1601,6 +1615,11 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1601
1615
|
discovered = await discoverEpicPlan(epicKey, docs.docsDir, deps.discoveryFs);
|
|
1602
1616
|
if (discovered.status === "plan_not_found") {
|
|
1603
1617
|
const generated = await generateMissingPlanForLaunch(ctx, docs.docsDir, discovered);
|
|
1618
|
+
// BAPI-1782 — a freshly built plan whose order fails launch admission is
|
|
1619
|
+
// refused before anything is published. Generation only reaches a built
|
|
1620
|
+
// plan after reading "no live run", so no attach is skipped here.
|
|
1621
|
+
if (generated.planOrderNeeded === true)
|
|
1622
|
+
return refuse(deps, [planOrderNeededRefusalLine(epicKey)]);
|
|
1604
1623
|
discovered = generated.discovery;
|
|
1605
1624
|
generationReason = generated.reason;
|
|
1606
1625
|
}
|
|
@@ -1631,6 +1650,47 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1631
1650
|
* its own, or a concurrent writer's. A generated plan is never uploaded.
|
|
1632
1651
|
*/
|
|
1633
1652
|
const uploadLocalPlanIfNeeded = async () => {
|
|
1653
|
+
// BAPI-1782 — an eligible explicit `--plan-file` after a definite "no plan
|
|
1654
|
+
// stored". The run starts from the returned snapshot only when it is the
|
|
1655
|
+
// same plan as the file; a different stored plan was never shown, so refuse.
|
|
1656
|
+
if (explicitUpload !== null) {
|
|
1657
|
+
if (serverPlan !== null ||
|
|
1658
|
+
explicitLookup?.lookup.kind !== "not_stored" ||
|
|
1659
|
+
deps.uploadAuthoredPlan === undefined) {
|
|
1660
|
+
return { ok: true };
|
|
1661
|
+
}
|
|
1662
|
+
const uploaded = await deps
|
|
1663
|
+
.uploadAuthoredPlan({ epicKey, planDir: dirname(explicitUpload.planFile), repo })
|
|
1664
|
+
.catch(() => null);
|
|
1665
|
+
if (uploaded === null || !uploaded.ok) {
|
|
1666
|
+
const retry = uploaded !== null && !uploaded.ok
|
|
1667
|
+
? uploaded.retryCommand
|
|
1668
|
+
: `npx -y ${MCP_PACKAGE_NAME} epic-plan save --epic-key ${epicKey}`;
|
|
1669
|
+
return {
|
|
1670
|
+
ok: false,
|
|
1671
|
+
code: refuse(deps, [
|
|
1672
|
+
`${epicKey}: REFUSED (${AUTHORED_PLAN_UPLOAD_FAILED_REASON_ID}) — ${authoredPlanUploadFailedRemedy(retry)}`,
|
|
1673
|
+
]),
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
if (uploaded.result.snapshot.plan_hash !== explicitUpload.planHash) {
|
|
1677
|
+
return {
|
|
1678
|
+
ok: false,
|
|
1679
|
+
code: refuse(deps, [
|
|
1680
|
+
`${epicKey}: REFUSED (${AUTHORED_PLAN_UPLOAD_FAILED_REASON_ID}) — ${explicitPlanStoredDiffersRemedy(epicKey)}`,
|
|
1681
|
+
]),
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
serverPlan = uploaded.result.snapshot;
|
|
1685
|
+
deps.log(`${epicKey}: saved the plan file to the Bridge server as authored version ` +
|
|
1686
|
+
`${serverPlan.authored_version}${uploaded.created ? "" : " (the same plan was already stored; using it)"}.`);
|
|
1687
|
+
const provenance = serverPlanProvenance(serverPlan, uploaded.endpoint);
|
|
1688
|
+
if (ctx.planProvenance !== undefined)
|
|
1689
|
+
Object.assign(ctx.planProvenance, provenance);
|
|
1690
|
+
else
|
|
1691
|
+
ctx = { ...ctx, planProvenance: provenance, planHashEvidence: {} };
|
|
1692
|
+
return { ok: true };
|
|
1693
|
+
}
|
|
1634
1694
|
if (serverPlan !== null ||
|
|
1635
1695
|
authoredLookup?.lookup.kind !== "not_stored" ||
|
|
1636
1696
|
discovered?.status !== "found" ||
|
|
@@ -1721,6 +1781,11 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1721
1781
|
return escalate(deps, epicKey, `launch profile '${launchProfile.name}' selects durable execution, and its control plane is ` +
|
|
1722
1782
|
"not answering; no local replacement was started");
|
|
1723
1783
|
}
|
|
1784
|
+
// BAPI-1782 — never cold-start a plane for a generated plan whose order
|
|
1785
|
+
// fails launch admission. Checked before any upload or plane start.
|
|
1786
|
+
if (await foundGeneratedPlanNeedsOrder(deps, discovered)) {
|
|
1787
|
+
return refuse(deps, [planOrderNeededRefusalLine(epicKey)]);
|
|
1788
|
+
}
|
|
1724
1789
|
// BAPI-1706 — a cold start creates a run, so a local-only plan is uploaded
|
|
1725
1790
|
// first and the server snapshot is what the new plane receives.
|
|
1726
1791
|
const upload = await uploadLocalPlanIfNeeded();
|
|
@@ -1762,6 +1827,18 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1762
1827
|
// run only on the create path, after the live-run read below, so attaching to a
|
|
1763
1828
|
// live run never depends on them.
|
|
1764
1829
|
if (ctx.options.planFile !== undefined && !planWasDiscovered) {
|
|
1830
|
+
// BAPI-1782 — store an eligible explicit plan only when the launch's one
|
|
1831
|
+
// live-run observation (the same cached read setup selection uses) shows no
|
|
1832
|
+
// run to reuse. A live or uncertain read keeps today's explicit behavior.
|
|
1833
|
+
if (explicitUpload !== null && explicitLookup?.lookup.kind === "not_stored") {
|
|
1834
|
+
const live = await acquireObservedLive(ctx);
|
|
1835
|
+
if (live.kind === "none") {
|
|
1836
|
+
const upload = await uploadLocalPlanIfNeeded();
|
|
1837
|
+
if (!upload.ok)
|
|
1838
|
+
return upload.code;
|
|
1839
|
+
await selectServerPlanFile();
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1765
1842
|
const prepared = await prepareSetupSelection(ctx);
|
|
1766
1843
|
if (!prepared.ok) {
|
|
1767
1844
|
return refuse(deps, [
|
|
@@ -1836,6 +1913,11 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1836
1913
|
const { planFile: _unusedDiscoveredPlan, ...attachOptions } = ctx.options;
|
|
1837
1914
|
return await attachToLiveRun({ ...ctx, options: attachOptions }, readiness, live, discovered.path);
|
|
1838
1915
|
}
|
|
1916
|
+
// BAPI-1782 — the selected plan (after any publication-collision
|
|
1917
|
+
// rediscovery) is checked here, before upload, setup selection, or create.
|
|
1918
|
+
if (await foundGeneratedPlanNeedsOrder(deps, discovered)) {
|
|
1919
|
+
return refuse(deps, [planOrderNeededRefusalLine(epicKey)]);
|
|
1920
|
+
}
|
|
1839
1921
|
// BAPI-1706 — the first real create from a local-only authored plan uploads
|
|
1840
1922
|
// it, then runs the server-confirmed snapshot.
|
|
1841
1923
|
const upload = await uploadLocalPlanIfNeeded();
|
|
@@ -2187,6 +2269,10 @@ async function generateMissingPlanForLaunch(ctx, docsDir, discovery) {
|
|
|
2187
2269
|
if (!(await planGenerationAllowed(deps.discoveryFs, epicKey, discovery, attempt))) {
|
|
2188
2270
|
return { discovery, reason: "discovery_blocked" };
|
|
2189
2271
|
}
|
|
2272
|
+
// BAPI-1782 — launch admission, before anything is written: a built plan that
|
|
2273
|
+
// runs more than one planned child in key order is never published.
|
|
2274
|
+
if (needsPlanOrder(attempt.dag.nodes, attempt.summary))
|
|
2275
|
+
return { discovery, planOrderNeeded: true };
|
|
2190
2276
|
let published;
|
|
2191
2277
|
try {
|
|
2192
2278
|
published = await deps.publishGeneratedPlan({
|
|
@@ -2210,6 +2296,54 @@ async function generateMissingPlanForLaunch(ctx, docsDir, discovery) {
|
|
|
2210
2296
|
const after = await discoverEpicPlan(epicKey, docsDir, deps.discoveryFs);
|
|
2211
2297
|
return after.status === "plan_not_found" ? { discovery: after, reason: "publish_failed" } : { discovery: after };
|
|
2212
2298
|
}
|
|
2299
|
+
/** BAPI-1782 — the one-line real-launch refusal for an untrustworthy generated order. */
|
|
2300
|
+
function planOrderNeededRefusalLine(epicKey) {
|
|
2301
|
+
return `${epicKey}: REFUSED (${PLAN_ORDER_NEEDED_REASON_ID}) — ${PLAN_ORDER_NEEDED_REMEDY}`;
|
|
2302
|
+
}
|
|
2303
|
+
/**
|
|
2304
|
+
* BAPI-1782 — whether the SELECTED found plan is a generated plan that fails
|
|
2305
|
+
* launch admission. Reads the same nodes the preview reads; an authored plan, or
|
|
2306
|
+
* a generated DAG whose nodes cannot be read, is left to the existing checks.
|
|
2307
|
+
*/
|
|
2308
|
+
async function foundGeneratedPlanNeedsOrder(deps, discovered) {
|
|
2309
|
+
if (discovered?.status !== "found" || discovered.generated === undefined)
|
|
2310
|
+
return false;
|
|
2311
|
+
const nodes = await readGeneratedPlanNodes(deps, discovered.path);
|
|
2312
|
+
return nodes !== null && needsPlanOrder(nodes, discovered.generated.summary);
|
|
2313
|
+
}
|
|
2314
|
+
/**
|
|
2315
|
+
* BAPI-1782 — an explicit `--plan-file` is eligible for upload only in the
|
|
2316
|
+
* authored-plan folder shape: the exact canonical DAG name, a sibling metadata
|
|
2317
|
+
* file that names this epic (the authored-plan reader's own identity rule), and
|
|
2318
|
+
* a DAG that passes the same sidecar validation. Anything else returns null and
|
|
2319
|
+
* keeps the explicit file's existing launch behavior, with no new refusal.
|
|
2320
|
+
*/
|
|
2321
|
+
async function explicitPlanUploadCandidate(deps, epicKey, planFile) {
|
|
2322
|
+
if (path.basename(planFile) !== AUTHORED_PLAN_DAG_FILE)
|
|
2323
|
+
return null;
|
|
2324
|
+
try {
|
|
2325
|
+
const meta = JSON.parse(await deps.readPlanDag(path.join(dirname(planFile), AUTHORED_PLAN_META_FILE)));
|
|
2326
|
+
if (meta === null || typeof meta !== "object" || Array.isArray(meta))
|
|
2327
|
+
return null;
|
|
2328
|
+
const metaKey = meta.epic_key;
|
|
2329
|
+
if (typeof metaKey !== "string" || metaKey.trim() !== epicKey)
|
|
2330
|
+
return null;
|
|
2331
|
+
const validation = validateEpicPlanSidecar(JSON.parse(await deps.readPlanDag(planFile)));
|
|
2332
|
+
if (!validation.ok)
|
|
2333
|
+
return null;
|
|
2334
|
+
return { planFile, planHash: hashPlan(validation.plan) };
|
|
2335
|
+
}
|
|
2336
|
+
catch {
|
|
2337
|
+
return null;
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
/** BAPI-1782 — the remedy when the server already stores a different plan than the explicit file. */
|
|
2341
|
+
function explicitPlanStoredDiffersRemedy(epicKey) {
|
|
2342
|
+
return ("No run was created; the Bridge server already stores a different plan for this epic than the " +
|
|
2343
|
+
"file passed with --plan-file, and a run never starts from a plan nobody was shown. Run the " +
|
|
2344
|
+
`preview again (\`drive-epic ${epicKey} --dry-run\`) to see the stored plan, then launch. ` +
|
|
2345
|
+
"Nothing was created or started.");
|
|
2346
|
+
}
|
|
2213
2347
|
/**
|
|
2214
2348
|
* Whether discovery's skipped entries allow generation. A DAG with no metadata
|
|
2215
2349
|
* blocks only when it names the epic or one of its children, or can't be read.
|
|
@@ -4518,6 +4652,41 @@ function docsRootRefusal(epicKey) {
|
|
|
4518
4652
|
],
|
|
4519
4653
|
};
|
|
4520
4654
|
}
|
|
4655
|
+
/**
|
|
4656
|
+
* BAPI-1781 — the epic's live run is explicitly STOPPED: `blocked` with a stored
|
|
4657
|
+
* `run_control` whose state is `stopped` (what `stop-run` writes). A stopped run
|
|
4658
|
+
* never resumes on its own, so attaching a new launch to it would drive nothing.
|
|
4659
|
+
* Returns the run id, or `null` for any other live run — another blocked state
|
|
4660
|
+
* (paused, quarantined, a preflight block with no record), an unreadable or
|
|
4661
|
+
* missing control, or an unknown read all keep their existing outcomes. Pure.
|
|
4662
|
+
*/
|
|
4663
|
+
export function stoppedLiveRunId(live) {
|
|
4664
|
+
if (live.kind !== "live" || live.status !== "blocked")
|
|
4665
|
+
return null;
|
|
4666
|
+
const run = live.state?.epic_run;
|
|
4667
|
+
const control = run?.run_control;
|
|
4668
|
+
if (control === null || typeof control !== "object" || Array.isArray(control))
|
|
4669
|
+
return null;
|
|
4670
|
+
return control.state === "stopped" ? live.epicRunId : null;
|
|
4671
|
+
}
|
|
4672
|
+
export const LIVE_RUN_STOPPED_REASON_ID = "live-run-stopped";
|
|
4673
|
+
/** BAPI-1781 — a stopped live run is ended, not attached to: name the one-step verb. */
|
|
4674
|
+
function liveRunStoppedRefusal(epicKey, epicRunId) {
|
|
4675
|
+
const remedy = `The live run ${epicRunId} is stopped; stop-run pauses a run but does not end it. ` +
|
|
4676
|
+
`End it in one step with \`epic-implementer abandon-run --epic-run-id ${epicRunId}\`, ` +
|
|
4677
|
+
"then run drive-epic again.";
|
|
4678
|
+
return {
|
|
4679
|
+
reasonId: LIVE_RUN_STOPPED_REASON_ID,
|
|
4680
|
+
remedy,
|
|
4681
|
+
lines: [
|
|
4682
|
+
`${epicKey}: REFUSED (${LIVE_RUN_STOPPED_REASON_ID}) — this epic's live run ${epicRunId} is stopped, ` +
|
|
4683
|
+
"so drive-epic will not attach a new launch to it.",
|
|
4684
|
+
remedy,
|
|
4685
|
+
"",
|
|
4686
|
+
"Nothing was created and nothing was started.",
|
|
4687
|
+
],
|
|
4688
|
+
};
|
|
4689
|
+
}
|
|
4521
4690
|
/** BAPI-1285 — several active runs for one epic: it is wedged. */
|
|
4522
4691
|
function liveRunAmbiguousRefusal(epicKey) {
|
|
4523
4692
|
const remedy = "Abandon the duplicate run with `epic-implementer abandon-run --epic-run-id " +
|
|
@@ -4724,6 +4893,12 @@ async function planeServesLiveRun(ctx, live) {
|
|
|
4724
4893
|
*/
|
|
4725
4894
|
async function attachToLiveRun(ctx, readiness, live, unusedDiscoveredPlan) {
|
|
4726
4895
|
const { deps, epicKey, access, profile } = ctx;
|
|
4896
|
+
// BAPI-1781 — a stopped run never resumes on its own, so a real launch must not
|
|
4897
|
+
// attach to it either (the preview already refuses the same way). Checked first,
|
|
4898
|
+
// at the one choke point every attach path goes through.
|
|
4899
|
+
const stoppedRunId = stoppedLiveRunId(live);
|
|
4900
|
+
if (stoppedRunId !== null)
|
|
4901
|
+
return refuse(deps, liveRunStoppedRefusal(epicKey, stoppedRunId).lines);
|
|
4727
4902
|
// BAPI-1593 — an unknown report proves nothing to refuse on: attach.
|
|
4728
4903
|
const classification = readiness === null
|
|
4729
4904
|
? { kind: "green" }
|
|
@@ -4948,19 +5123,28 @@ function classifyEngineStatus(stdout) {
|
|
|
4948
5123
|
return "unreadable";
|
|
4949
5124
|
const fields = stdout.slice(0, -1).split("\0");
|
|
4950
5125
|
let records = 0;
|
|
5126
|
+
// BAPI-1782 — records that touch only engine test files are counted (so the
|
|
5127
|
+
// output still parses as status) but do not make the checkout dirty.
|
|
5128
|
+
let runtimeRecords = 0;
|
|
4951
5129
|
for (let i = 0; i < fields.length; i += 1) {
|
|
4952
5130
|
const field = fields[i];
|
|
4953
5131
|
if (!PORCELAIN_RECORD.test(field))
|
|
4954
5132
|
return "unreadable";
|
|
4955
5133
|
records += 1;
|
|
5134
|
+
let testOnly = isEngineTestFile(field.slice(3));
|
|
4956
5135
|
if (/^[RC]/.test(field) || /^.[RC]/.test(field)) {
|
|
4957
5136
|
// The rename/copy origin path follows as its own field.
|
|
4958
5137
|
i += 1;
|
|
4959
5138
|
if (i >= fields.length || fields[i] === "")
|
|
4960
5139
|
return "unreadable";
|
|
5140
|
+
testOnly = testOnly && isEngineTestFile(fields[i]);
|
|
4961
5141
|
}
|
|
5142
|
+
if (!testOnly)
|
|
5143
|
+
runtimeRecords += 1;
|
|
4962
5144
|
}
|
|
4963
|
-
|
|
5145
|
+
if (records === 0)
|
|
5146
|
+
return "unreadable";
|
|
5147
|
+
return runtimeRecords > 0 ? "dirty" : "clean";
|
|
4964
5148
|
}
|
|
4965
5149
|
/**
|
|
4966
5150
|
* Collect the health-check fact for a verified Bridge LOCAL-plane create preview
|
|
@@ -6098,6 +6282,10 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
6098
6282
|
// BAPI-1621 — why automatic generation stopped, and whether it read "no live run".
|
|
6099
6283
|
let generationReason;
|
|
6100
6284
|
let generatedLiveRunChecked = false;
|
|
6285
|
+
// BAPI-1782 — a generated plan (in memory or found) whose order fails launch
|
|
6286
|
+
// admission. Applied only where this preview would create a run; the plan block
|
|
6287
|
+
// is kept as it is so the driver can read the child keys from it.
|
|
6288
|
+
let planOrderNeeded = false;
|
|
6101
6289
|
let docsRootUnresolved = false;
|
|
6102
6290
|
// BAPI-1706 — the same server-first precedence the launch uses, read once and
|
|
6103
6291
|
// written nowhere: no upload, no temporary folder, no local file.
|
|
@@ -6173,8 +6361,10 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
6173
6361
|
if (discovered.generated !== undefined) {
|
|
6174
6362
|
plan.generated = true;
|
|
6175
6363
|
const nodes = await readGeneratedPlanNodes(deps, discovered.path);
|
|
6176
|
-
if (nodes !== null)
|
|
6364
|
+
if (nodes !== null) {
|
|
6177
6365
|
plan.generation = { nodes, summary: discovered.generated.summary };
|
|
6366
|
+
planOrderNeeded = needsPlanOrder(nodes, discovered.generated.summary);
|
|
6367
|
+
}
|
|
6178
6368
|
}
|
|
6179
6369
|
}
|
|
6180
6370
|
else if (discovered.status === "plan_not_found" && deps.attemptPlanGeneration !== undefined) {
|
|
@@ -6204,6 +6394,7 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
6204
6394
|
epic_plans_dir: discovered.epic_plans_dir,
|
|
6205
6395
|
};
|
|
6206
6396
|
generatedLiveRunChecked = true;
|
|
6397
|
+
planOrderNeeded = needsPlanOrder(attempt.dag.nodes, attempt.summary);
|
|
6207
6398
|
ctx = { ...ctx, deps: withInlinePlan(ctx.deps, planPath, JSON.stringify(attempt.dag, null, 2) + "\n") };
|
|
6208
6399
|
}
|
|
6209
6400
|
}
|
|
@@ -6230,6 +6421,18 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
6230
6421
|
const authoredPlanUnknown = authoredLookupKind === "unknown";
|
|
6231
6422
|
// Every later exit, refusal or not, reports the plan state as discovered.
|
|
6232
6423
|
preview.plan = plan;
|
|
6424
|
+
/**
|
|
6425
|
+
* BAPI-1782 — the launch-admission refusal for an untrustworthy generated order.
|
|
6426
|
+
* Called only on a path that would create a run, after the existing gates, so
|
|
6427
|
+
* a live run is still attached to and earlier refusals keep their precedence.
|
|
6428
|
+
* Returns true when it refused.
|
|
6429
|
+
*/
|
|
6430
|
+
const refusePlanOrderNeeded = () => {
|
|
6431
|
+
if (!planOrderNeeded)
|
|
6432
|
+
return false;
|
|
6433
|
+
refuseTopLevel({ reasonId: PLAN_ORDER_NEEDED_REASON_ID, remedy: PLAN_ORDER_NEEDED_REMEDY, authoritative: true });
|
|
6434
|
+
return true;
|
|
6435
|
+
};
|
|
6233
6436
|
// --- Readiness. -----------------------------------------------------------
|
|
6234
6437
|
// BAPI-1593 — ONE acquisition for this preview: at most two full reads. The
|
|
6235
6438
|
// first failure is inspected on its own (a refused plane port is a cold start);
|
|
@@ -6281,6 +6484,8 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
6281
6484
|
});
|
|
6282
6485
|
}
|
|
6283
6486
|
preview.readiness = { kind: "cold_start" };
|
|
6487
|
+
if (refusePlanOrderNeeded())
|
|
6488
|
+
return;
|
|
6284
6489
|
await finalizeCreatePreview(ctx, preview, planPath, true, refuseTopLevel);
|
|
6285
6490
|
if (preview.decision === "create") {
|
|
6286
6491
|
preview.cold_start = {
|
|
@@ -6346,6 +6551,10 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
6346
6551
|
if (unknownLive.kind === "live") {
|
|
6347
6552
|
preview.live_run = { epic_run_id: unknownLive.epicRunId, status: unknownLive.status };
|
|
6348
6553
|
if (options.planFile === undefined && !isPlanningSetupToFinish(unknownLive, previewServerPlan)) {
|
|
6554
|
+
// BAPI-1781 — a stopped live run is reported with its one-step exit, not attached to.
|
|
6555
|
+
const stoppedRunId = stoppedLiveRunId(unknownLive);
|
|
6556
|
+
if (stoppedRunId !== null)
|
|
6557
|
+
return refuseTopLevel(liveRunStoppedRefusal(epicKey, stoppedRunId));
|
|
6349
6558
|
preview.decision = "attach";
|
|
6350
6559
|
return;
|
|
6351
6560
|
}
|
|
@@ -6357,6 +6566,8 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
6357
6566
|
preview.decision = "stop";
|
|
6358
6567
|
return;
|
|
6359
6568
|
}
|
|
6569
|
+
if (refusePlanOrderNeeded())
|
|
6570
|
+
return;
|
|
6360
6571
|
await finalizeCreatePreview(ctx, preview, planPath, false, refuseTopLevel, true);
|
|
6361
6572
|
return;
|
|
6362
6573
|
}
|
|
@@ -6454,6 +6665,10 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
6454
6665
|
preview.decision = "stop";
|
|
6455
6666
|
return;
|
|
6456
6667
|
}
|
|
6668
|
+
// BAPI-1781 — a stopped live run is reported with its one-step exit, not attached to.
|
|
6669
|
+
const stoppedRunId = stoppedLiveRunId(live);
|
|
6670
|
+
if (stoppedRunId !== null)
|
|
6671
|
+
return refuseTopLevel(liveRunStoppedRefusal(epicKey, stoppedRunId));
|
|
6457
6672
|
const blocked = previewReadinessRefusal(ctx, classification, readiness, planeTarget, "attach");
|
|
6458
6673
|
if (blocked !== null)
|
|
6459
6674
|
return refuseWithReadiness(classification.kind, blocked);
|
|
@@ -6498,6 +6713,8 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
6498
6713
|
return refuseWithReadiness("operator_blocked", launch.refusal);
|
|
6499
6714
|
observed.access = access;
|
|
6500
6715
|
observed.launchTopology = launchTopology;
|
|
6716
|
+
if (refusePlanOrderNeeded())
|
|
6717
|
+
return;
|
|
6501
6718
|
await finalizeCreatePreview(prepared?.ok ? { ...previewCtx, handoff: prepared.handoff, previewObservations: observations, previewMergedEvaluation: mergedEvaluation } : { ...previewCtx, previewObservations: observations, previewMergedEvaluation: mergedEvaluation }, preview, planPathForCreate, false, refuseTopLevel, live.kind === "live");
|
|
6502
6719
|
await applyPreviewFreshness(ctx, preview, topology, false);
|
|
6503
6720
|
}
|
package/build/engine-paths.js
CHANGED
|
@@ -18,3 +18,13 @@ export const ENGINE_PATHS = [
|
|
|
18
18
|
"tests/integration/conductor_harness/",
|
|
19
19
|
"tests/pytest/db/test_executor_protocol_contract_fidelity.py",
|
|
20
20
|
];
|
|
21
|
+
/**
|
|
22
|
+
* BAPI-1782 — the one shared rule that a path is an engine TEST file, not engine
|
|
23
|
+
* runtime code. Both the launch health check (`classifyEngineStatus`) and the
|
|
24
|
+
* plane build-freshness check ignore such a file, so editing a test never asks
|
|
25
|
+
* for a health check or stales the executor build. Only the exact `.test.ts`
|
|
26
|
+
* suffix counts; every other `.ts` file still triggers both checks.
|
|
27
|
+
*/
|
|
28
|
+
export function isEngineTestFile(filePath) {
|
|
29
|
+
return filePath.endsWith(".test.ts");
|
|
30
|
+
}
|