@bridge_gpt/mcp-server 0.2.72 → 0.2.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/build/agent-launchers/claude-executor-adapter.js +3 -0
- package/build/agents.generated.js +6 -6
- package/build/bridge-permissions.js +27 -0
- package/build/ci-system-detection.js +50 -0
- package/build/ci-trigger-adapters.js +631 -0
- package/build/ci-trigger-install.js +106 -0
- package/build/codex-launcher-pin.js +33 -2
- package/build/codex-skill-adapter.js +3 -1
- package/build/command-host.js +33 -0
- package/build/commands.generated.js +7 -6
- package/build/conductor/bridge-api-client.js +842 -35
- package/build/conductor/bring-up-facts.js +18 -5
- package/build/conductor/command-drift-production.js +42 -17
- package/build/conductor/command-drift.js +47 -0
- package/build/conductor/declare-blocked.js +554 -0
- package/build/conductor/doctor.js +106 -21
- package/build/conductor/driver-commands.js +141 -0
- package/build/conductor/driver-guard.js +277 -0
- package/build/conductor/driver-lapse.js +321 -0
- package/build/conductor/driver-register.js +176 -0
- package/build/conductor/driver-release.js +174 -0
- package/build/conductor/driver-session-state.js +315 -0
- package/build/conductor/epic-branch-ci-inspection.js +222 -29
- package/build/conductor/epic-implementer-cli.js +166 -15
- package/build/conductor/epic-server-database.js +162 -0
- package/build/conductor/epic-server-guidance.js +278 -0
- package/build/conductor/epic-server-journal.js +239 -0
- package/build/conductor/epic-server-processes.js +324 -0
- package/build/conductor/epic-server-recipe.js +397 -0
- package/build/conductor/epic-server-runtime.js +1207 -0
- package/build/conductor/epic-server-sfcc.js +107 -0
- package/build/conductor/epic-server-state.js +427 -0
- package/build/conductor/epic-server.js +594 -0
- package/build/conductor/gate-discovery.js +150 -5
- package/build/conductor/gate-settings-review.js +224 -4
- package/build/conductor/launch-need-probes.js +6 -53
- package/build/conductor/launch-plan.js +313 -156
- package/build/conductor/prerequisite-inputs.js +879 -45
- package/build/conductor/readiness-assessment.js +16 -1
- package/build/conductor/readiness-cli.js +20 -9
- package/build/conductor/readiness-prerequisites.js +28 -9
- package/build/conductor/readiness-sections.js +133 -126
- package/build/conductor/readiness.js +1 -1
- package/build/conductor/recovery-cli.js +13 -2
- package/build/conductor/tools.js +6 -5
- package/build/conductor/wait-run-attention.js +2 -2
- package/build/conductor/wait-run-cli.js +208 -22
- package/build/conductor/worker-database-doctor-inspector.js +33 -2
- package/build/conductor/worker-setup-tally.js +27 -0
- package/build/credential-store.js +71 -1
- package/build/dependency-install-declarations.js +55 -0
- package/build/docs.generated.js +2 -2
- package/build/doctor.js +54 -3
- package/build/drive-epic-help.js +21 -2
- package/build/drive-epic.js +1811 -351
- package/build/engine-paths.js +20 -0
- package/build/epic-branch-ci-summary.js +140 -0
- package/build/epic-capability-statement.js +107 -0
- package/build/epic-ci-workflow-drift.js +30 -15
- package/build/epic-ci-workflow-install.js +110 -42
- package/build/epic-ci-workflow-v2.js +274 -0
- package/build/epic-ci-workflow.js +38 -12
- package/build/epic-implementer-bin.js +2101 -44
- package/build/epic-launch-context.js +607 -0
- package/build/epic-server-record.js +273 -0
- package/build/epic-shared/bridge-client.js +11 -3
- package/build/escalation-reachability.js +43 -0
- package/build/executor/ci-fix-test-runs.js +334 -0
- package/build/executor/completion-contract.js +8 -1
- package/build/executor/env.js +59 -22
- package/build/executor/epic-server-context.js +141 -0
- package/build/executor/gate-qualification-job.js +127 -26
- package/build/executor/http-client.js +52 -5
- package/build/executor/job-runner.js +423 -69
- package/build/executor/observation.js +8 -0
- package/build/executor/pre-pr-checks.js +363 -0
- package/build/executor/prompt-spec.js +114 -2
- package/build/executor/reconcile-overlap-job.js +5 -3
- package/build/executor/required-work-diagnostics.js +4 -2
- package/build/executor/required-work-ledger.js +936 -38
- package/build/executor/results.js +58 -0
- package/build/executor/terminal-mutation.js +8 -0
- package/build/executor/worker-command.js +72 -3
- package/build/executor/worker-database-config.js +281 -0
- package/build/executor/worker-database-target.js +16 -12
- package/build/executor/worker-database.js +320 -101
- package/build/executor/worker-finalization.js +7 -1
- package/build/executor/worker-resources.js +25 -3
- package/build/executor/worker-verification-guidance.js +18 -3
- package/build/executor/worktree.js +20 -1
- package/build/executor-launch.js +54 -2
- package/build/generated-assets-catalog.js +2 -2
- package/build/index.js +664 -335
- package/build/init.js +26 -11
- package/build/install-bridge-conductor-answers.js +465 -0
- package/build/install-bridge-conductor-apply.js +259 -0
- package/build/install-bridge-conductor-assessment.js +895 -0
- package/build/install-bridge-conductor-compact.js +161 -0
- package/build/install-bridge-conductor-contracts.js +63 -0
- package/build/install-bridge-conductor-gate.js +1197 -196
- package/build/install-bridge-conductor-setup.js +535 -79
- package/build/install-bridge-conductor.js +2885 -560
- package/build/install-bridge.js +199 -21
- package/build/install-maintenance.js +26 -3
- package/build/launcher-config-inspection.js +162 -1
- package/build/mcp-grant-candidates.js +767 -0
- package/build/mcp-grant-doctor.js +63 -0
- package/build/mcp-grant.js +288 -0
- package/build/mcp-host-targets.js +8 -0
- package/build/mcp-identity.js +23 -0
- package/build/mcp-invoke.js +126 -13
- package/build/mcp-presets.js +107 -0
- package/build/mcp-provisioning.js +134 -2
- package/build/mcp-registration-doctor.js +31 -2
- package/build/mcp-server-invocation.js +6 -1
- package/build/merge-workflow-install.js +234 -109
- package/build/pipelines.generated.js +5 -5
- package/build/plan-discovery.js +97 -4
- package/build/plan-execution-ledger.js +100 -7
- package/build/plan-generation-io.js +262 -0
- package/build/plan-generation.js +424 -0
- package/build/plane/build-freshness.js +6 -1
- package/build/plane/cli.js +75 -9
- package/build/plane/plane-freshness.js +17 -0
- package/build/plane/preflight.js +50 -10
- package/build/plane/shutdown.js +19 -0
- package/build/plane/terminal-run-cleanup.js +18 -4
- package/build/printed-remedy-commands.js +206 -12
- package/build/readiness-check.js +77 -0
- package/build/readiness-prerequisites.generated.js +122 -14
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +38 -0
- package/build/run-unit-tests-launcher.js +8 -1
- package/build/setup-epic.js +1190 -196
- package/build/setup-progress.js +44 -0
- package/build/setup-question.js +122 -4
- package/build/third-party-mcp-targets.js +30 -0
- package/build/ticket-delivery-enrollment.js +9 -0
- package/build/upgrade-cli.js +85 -2
- package/build/v2-readiness-requirements.js +28 -1
- package/build/version.generated.js +3 -3
- package/docs/EPIC-IMPLEMENTER-INSTALL.md +9 -1
- package/docs/epic-implementer/getting-started.md +3 -1
- package/docs/epic-implementer/self-hosting.md +14 -1
- package/package.json +2 -2
package/build/drive-epic.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { sanitizeHarnessCoverage } from "./executor/harness-coverage.js";
|
|
2
1
|
import { isTerminalRunCleanupStatus } from "./plane/terminal-run-status.js";
|
|
2
|
+
import { resolveDeclaredRunBaseBranch } from "./conductor/run-branch.js";
|
|
3
3
|
import { monotonicNow, elapsedMs, measurePrecheck } from "./conductor/precheck-timings.js";
|
|
4
|
-
import { buildLaunchPlan } from "./conductor/launch-plan.js";
|
|
4
|
+
import { buildLaunchPlan, LAUNCH_PRE_CREATE_CODES, PARALLEL_LIMIT_CHANGE_ADVISORY, PARALLEL_LIMIT_MEANING_COPY, SERVER_WEBHOOK_ROW_ID, } from "./conductor/launch-plan.js";
|
|
5
5
|
import { ticketReviewSummary } from "./ticket-review-summary.js";
|
|
6
6
|
import { parseConductorReadinessResponse } from "./conductor/bridge-api-client.js";
|
|
7
|
+
import { workerSetupTallyEntries } from "./conductor/worker-setup-tally.js";
|
|
7
8
|
import { READINESS_PRE_CREATE_CODES, READINESS_PREREQUISITE_BY_ID, READINESS_LEGACY_IDS } from "./readiness-prerequisites.generated.js";
|
|
8
9
|
/**
|
|
9
10
|
* `drive-epic` — the one universal conductor entry point (BAPI-887).
|
|
@@ -63,34 +64,39 @@ import { READINESS_PRE_CREATE_CODES, READINESS_PREREQUISITE_BY_ID, READINESS_LEG
|
|
|
63
64
|
import { access as fsAccess, readdir, readFile, realpath, stat as fsStat } from "node:fs/promises";
|
|
64
65
|
import { constants as fsConstants } from "node:fs";
|
|
65
66
|
import path, { dirname, join } from "node:path";
|
|
66
|
-
import { ConductorBridgeApiError, resolveEpicLaunchBridgeApiAccess, fetchConductorReadiness,
|
|
67
|
+
import { ConductorBridgeApiError, createReadinessAcquisition, resolveEpicLaunchBridgeApiAccess, fetchConductorReadiness, isSchemaIncompatibleError, SCHEMA_INCOMPATIBLE_REPAIR_ROUTE, fetchEpicRunState, isProviderRepositoryIdentity, safeDiagnosticMessage, classifyChildMergeStatus as classifyChildMergeStatusClient, recordSkippedChildren as recordSkippedChildrenClient, fetchEpicChildren, fetchStoredTicketDescription, resolveConductorBridgeApiAccess, validateEpicPlan, } from "./conductor/bridge-api-client.js";
|
|
67
68
|
import { CHILD_MERGE_STATUS_BATCH_SIZE, buildAlreadyDoneEntries, classifyPlanChildren, selectSkips, } from "./conductor/merged-child-check.js";
|
|
68
69
|
import { trimDonePlanNodes } from "./conductor/plan-trim.js";
|
|
69
70
|
import { withPlanPath } from "./conductor/temporary-plan.js";
|
|
70
|
-
import { ESCALATION_REACHABILITY_CHECK_ID, buildEscalationReachabilityCheck, } from "./escalation-reachability.js";
|
|
71
|
-
import { EPIC_LAUNCH_PROFILE_NAME_PATTERN, epicLaunchPolicyDigest, pinEpicLaunchPolicy, renderEpicLaunchCommand, resolveEpicLaunchSelection, shellQuote, } from "./epic-launch-profile.js";
|
|
71
|
+
import { ESCALATION_REACHABILITY_CHECK_ID, buildEscalationReachabilityCheck, classifyEscalationReachabilityPresentation, } from "./escalation-reachability.js";
|
|
72
|
+
import { EPIC_LAUNCH_PROFILE_NAME_PATTERN, epicLaunchPolicyDigest, getPinnedEpicLaunchPolicy, pinEpicLaunchPolicy, renderEpicLaunchCommand, resolveEpicLaunchSelection, shellQuote, } from "./epic-launch-profile.js";
|
|
72
73
|
import { validateHttpBaseUrl, describeBaseUrlRejection } from "./base-url.js";
|
|
73
|
-
import { BRING_UP_REFUSAL_MESSAGES, BRING_UP_RUNBOOK, firstBringUpRefusal, } from "./conductor/bring-up-facts.js";
|
|
74
|
-
import { V2_READINESS_REQUIREMENTS, buildLaunchReadinessChecks, firstLaunchEvidenceBlocker,
|
|
74
|
+
import { BRING_UP_REFUSAL_MESSAGES, BRING_UP_RUNBOOK, firstBringUpRefusal, firstProvenBringUpRefusal, } from "./conductor/bring-up-facts.js";
|
|
75
|
+
import { V2_READINESS_REQUIREMENTS, buildLaunchEvidenceChecks, buildLaunchReadinessChecks, firstLaunchEvidenceBlocker, projectReadinessRowBlocking, unattendedPostureCheck, } from "./v2-readiness-requirements.js";
|
|
75
76
|
import { classifyLocalGhPreflight, probeLocalMergeCapability, } from "./conductor/local-merge.js";
|
|
76
77
|
import { nodeGithubMergeCredentialReadDeps, resolveMergeCredentialAtAction, } from "./conductor/stored-merge-credential.js";
|
|
77
78
|
import { resolveWorktreeSettingsExclude, } from "./executor/permissions.js";
|
|
78
|
-
import { collectWorkerDatabaseDoctorSection,
|
|
79
|
-
import {
|
|
80
|
-
import { createWorkflowSource,
|
|
79
|
+
import { collectWorkerDatabaseDoctorSection, WORKER_DATABASE_DOCTOR_TIMEOUT_MS, } from "./conductor/doctor.js";
|
|
80
|
+
import { buildHostPowerLaunchRow, buildSelfHostedRunnerLaunchRow, buildWorkerDbRoleLaunchRow, hostPowerFactFromReport, LAUNCH_NEED_ROW_IDS, workerDatabaseReadinessChecks, } from "./conductor/readiness-sections.js";
|
|
81
|
+
import { createWorkflowSource, inspectRequiredSelfHostedRunners, } from "./conductor/launch-need-probes.js";
|
|
81
82
|
import { createWorkerDatabaseDoctorInspector } from "./conductor/worker-database-doctor-inspector.js";
|
|
82
|
-
import {
|
|
83
|
+
import { ENGINE_PATHS } from "./engine-paths.js";
|
|
84
|
+
import { policyDeclaresNotifyWebhook, policyNotifyDestinationsConflict, notifyDestinationsConflictMessage, effectivePolicyFacts, evaluateParallelPolicyPreflight, parseParallelLimit, readSetupEpicPolicyFile, retainedParallelLimitNotice, resolveFeatureBranchSelection, readCanonicalParseTruth as readSetupCanonicalParseTruth, runSetupEpicWorkflow, launchReconnectCommand, READINESS_UNKNOWN_CONTINUING_WARNING, RUN_WAITING_FOR_APPROVAL_PHRASE, formatSetupEpicAutoMergeIntent, resolveSetupEpicAutoMergeIntent, readinessSnapshotFromLaunchContext, } from "./setup-epic.js";
|
|
85
|
+
import { getConfigFieldBaseBranch } from "./epic-shared/bridge-client.js";
|
|
83
86
|
import { EPIC_KEY_PATTERN } from "./drive-epic-key.js";
|
|
87
|
+
import { buildEpicLaunchContext, projectWorkerDatabase, readEpicLaunchContext, writeEpicLaunchContext, } from "./epic-launch-context.js";
|
|
84
88
|
import { flushProcessStdout, writeJsonDocument } from "./conductor/json-output.js";
|
|
85
89
|
import { BRIDGE_LAUNCHER_ENV } from "./bridge-permissions.js";
|
|
86
90
|
import { checkPlaneBuildFreshness, PLANE_BUILD_FIX_REMEDIATION } from "./plane/build-freshness.js";
|
|
87
|
-
import { discoverEpicPlan, } from "./plan-discovery.js";
|
|
88
|
-
import {
|
|
89
|
-
import {
|
|
91
|
+
import { discoverEpicPlan, isPlanGenerationEligible, unrelatedMissingMetaPaths, } from "./plan-discovery.js";
|
|
92
|
+
import { attemptPlanGeneration, createDefaultPlanPublicationFs, generatedPlanFolder, listTrackedFilesWithGit, publishGeneratedPlan, validateGeneratedPlan, } from "./plan-generation-io.js";
|
|
93
|
+
import { PLAN_GENERATION_FAILURE_TEXT, } from "./plan-generation.js";
|
|
94
|
+
import { DEFAULT_RUN_PARALLEL_LIMIT, formatPlaneDiagnostic, isPlaneExecutorLaneMember, launchPlaneControlPlane, parallelLimitToExecutorLanes, requestPlaneScopedLanes, runDefaultPlanePreflight, runPlaneCli, } from "./plane/cli.js";
|
|
95
|
+
import { PLANE_PORT_PROBE_TIMEOUT_MS, describePlanePortOccupant, classifyBridgeCheckout, } from "./plane/preflight.js";
|
|
90
96
|
import { createPlaneExecFile, createPlaneFsDeps, probeAutomationHealth, probeTcpPort, resolveHostname, } from "./plane/defaults.js";
|
|
91
97
|
import { readPlaneManifest } from "./plane/manifest.js";
|
|
92
|
-
import { cleanupTerminalRunPlane, createTerminalRunCleanupDeps, terminalRunCleanupStderrLine, } from "./plane/terminal-run-cleanup.js";
|
|
93
|
-
import { checkPlaneFreshness, inspectHostSleep, PLANE_DATABASE_HEAD_ID, PLANE_DATABASE_HEAD_REMEDY, PLANE_FRESHNESS_UNVERIFIED_REMEDY, PLANE_HOST_SLEEP_ID, PLANE_SLEEP_REMEDY, formatBoundPlaneStaleRemedy, PLANE_SNAPSHOT_FRESHNESS_ID, PLANE_SNAPSHOT_STALE_REMEDY, } from "./plane/plane-freshness.js";
|
|
98
|
+
import { cleanupTerminalRunPlane, createTerminalRunCleanupDeps, readOtherLiveRun, terminalRunCleanupStderrLine, } from "./plane/terminal-run-cleanup.js";
|
|
99
|
+
import { checkPlaneFreshness, inspectHostSleep, PLANE_DATABASE_HEAD_ID, PLANE_DATABASE_HEAD_REMEDY, PLANE_FRESHNESS_UNVERIFIED_REMEDY, PLANE_HOST_SLEEP_ID, PLANE_SLEEP_REMEDY, formatBoundPlaneStaleRemedy, formatSharedPlaneStaleRemedy, PLANE_SNAPSHOT_FRESHNESS_ID, PLANE_SNAPSHOT_STALE_REMEDY, } from "./plane/plane-freshness.js";
|
|
94
100
|
import { baseUrlNamesPlaneEndpoint, planeEndpointForTarget } from "./plane/endpoint.js";
|
|
95
101
|
import { resolvePlaneServerEndpoint, } from "./plane/member-roster.js";
|
|
96
102
|
import { resolveMemberInstanceId } from "./plane/supervisor.js";
|
|
@@ -102,7 +108,7 @@ import { isTerminalEpicRunStatus } from "./epic-run-status.js";
|
|
|
102
108
|
import { MCP_PACKAGE_NAME } from "./mcp-identity.js";
|
|
103
109
|
import { getDriveEpicAdvancedUsage, getDriveEpicUsage } from "./drive-epic-help.js";
|
|
104
110
|
export { getDriveEpicUsage };
|
|
105
|
-
import { CONSUMER_GUIDE_POINTER, PRINTED_CHECK_NAME_INSTRUCTION, PRINTED_CONDUCTOR_INSTALL_COMMAND, PRINTED_DOCTOR_COMMAND, } from "./printed-remedy-commands.js";
|
|
111
|
+
import { CONSUMER_GUIDE_POINTER, PRINTED_CHECK_NAME_INSTRUCTION, PRINTED_CONDUCTOR_INSTALL_COMMAND, PRINTED_DOCTOR_COMMAND, READINESS_PREREQUISITE_FIXES, resolveReadinessRemedy, } from "./printed-remedy-commands.js";
|
|
106
112
|
/** The conductor paths. Derived types below come from this constant. */
|
|
107
113
|
export const DRIVE_EPIC_CONDUCTORS = ["v2"];
|
|
108
114
|
/**
|
|
@@ -153,6 +159,21 @@ const MERGE_CREDENTIAL_ROW = "conductor.merge-credential-capability";
|
|
|
153
159
|
* three competing actions has to work out which to do first, and the order here
|
|
154
160
|
* already encodes that (setup, then config, then credentials).
|
|
155
161
|
*/
|
|
162
|
+
/** The reason id of a PROVEN mandatory-diagnostic failure (unchanged by BAPI-1595). */
|
|
163
|
+
const MANDATORY_DIAGNOSTIC_FAILED_ID = "mandatory-diagnostic-unverified";
|
|
164
|
+
const MANDATORY_DIAGNOSTIC_FAILED_REMEDY = "Resolve the mandatory diagnostic at the selected Bridge API target and retry.";
|
|
165
|
+
/**
|
|
166
|
+
* BAPI-1595 — whether any diagnostic is uncertain: missing severity or
|
|
167
|
+
* applicability, or a mandatory applicable one whose verdict was not established.
|
|
168
|
+
* Such a finding warns (it is never a proven failure) and the launch continues.
|
|
169
|
+
*/
|
|
170
|
+
export function mandatoryDiagnosticsUncertain(diagnostics) {
|
|
171
|
+
return (diagnostics ?? []).some((diagnostic) => diagnostic.severity === null ||
|
|
172
|
+
diagnostic.applicability === null ||
|
|
173
|
+
(diagnostic.applicability === "applicable" &&
|
|
174
|
+
diagnostic.severity === "mandatory" &&
|
|
175
|
+
diagnostic.verdict === "unknown"));
|
|
176
|
+
}
|
|
156
177
|
export function classifyV2Readiness(readiness, options = {},
|
|
157
178
|
/**
|
|
158
179
|
* BAPI-1452 — the value-free launch evidence (credential probe verdict and
|
|
@@ -163,21 +184,17 @@ export function classifyV2Readiness(readiness, options = {},
|
|
|
163
184
|
* posture is never read from here — only from the server report.
|
|
164
185
|
*/
|
|
165
186
|
launchEvidence) {
|
|
187
|
+
// BAPI-1595 — only a PROVEN failure refuses: a diagnostic that is explicitly
|
|
188
|
+
// mandatory, explicitly applicable, and `failed`. An unknown verdict, or one whose
|
|
189
|
+
// severity or applicability was not established, is uncertainty (see
|
|
190
|
+
// {@link mandatoryDiagnosticsUncertain}), never a stop.
|
|
166
191
|
for (const diagnostic of readiness.diagnostics ?? []) {
|
|
167
|
-
if (diagnostic.severity ===
|
|
168
|
-
return {
|
|
169
|
-
kind: "operator_blocked",
|
|
170
|
-
id: "diagnostic-metadata-unknown",
|
|
171
|
-
describe: "Additional readiness diagnostics",
|
|
172
|
-
remedy: "Upgrade or repair the readiness producer, then retry the selected target.",
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
if (diagnostic.applicability === "applicable" && diagnostic.severity === "mandatory" && diagnostic.verdict !== "passed") {
|
|
192
|
+
if (diagnostic.applicability === "applicable" && diagnostic.severity === "mandatory" && diagnostic.verdict === "failed") {
|
|
176
193
|
return {
|
|
177
194
|
kind: "operator_blocked",
|
|
178
|
-
id:
|
|
195
|
+
id: MANDATORY_DIAGNOSTIC_FAILED_ID,
|
|
179
196
|
describe: "Additional readiness diagnostics",
|
|
180
|
-
remedy:
|
|
197
|
+
remedy: MANDATORY_DIAGNOSTIC_FAILED_REMEDY,
|
|
181
198
|
};
|
|
182
199
|
}
|
|
183
200
|
}
|
|
@@ -268,16 +285,47 @@ launchEvidence) {
|
|
|
268
285
|
if (blocker) {
|
|
269
286
|
return {
|
|
270
287
|
kind: "operator_blocked",
|
|
271
|
-
id: { "server.indexed-workflows": READINESS_PRE_CREATE_CODES.INDEXED_WORKFLOWS_NOT_MET, "server.unattended-notify-default": READINESS_PRE_CREATE_CODES.ESCALATION_CHANNEL_NOT_MET, "server.
|
|
288
|
+
id: { "server.indexed-workflows": READINESS_PRE_CREATE_CODES.INDEXED_WORKFLOWS_NOT_MET, "server.unattended-notify-default": READINESS_PRE_CREATE_CODES.ESCALATION_CHANNEL_NOT_MET, "server.escalation-webhook-reachable": LAUNCH_PRE_CREATE_CODES.ESCALATION_WEBHOOK_UNREACHABLE, "server.provider-default-branch-readable": LAUNCH_PRE_CREATE_CODES.PROVIDER_DEFAULT_BRANCH_UNREADABLE }[blocker.id] ?? blocker.id,
|
|
272
289
|
describe: blocker.describe,
|
|
273
290
|
...(() => {
|
|
274
|
-
const remedy = blocker.
|
|
291
|
+
const remedy = blocker.id === INDEXED_WORKFLOWS_ROW_ID
|
|
292
|
+
? indexedWorkflowsRemedy(readiness)
|
|
293
|
+
: blocker.remedyFor?.(readiness) ?? blocker.remedy;
|
|
275
294
|
return remedy ? { remedy } : {};
|
|
276
295
|
})(),
|
|
277
296
|
};
|
|
278
297
|
}
|
|
279
298
|
return { kind: "runtime_only", unmetIds: unmet.map((req) => req.id) };
|
|
280
299
|
}
|
|
300
|
+
const INDEXED_WORKFLOWS_ROW_ID = "server.indexed-workflows";
|
|
301
|
+
/**
|
|
302
|
+
* BAPI-1635 — the refusal guidance for an unmet indexed-workflows row, chosen from
|
|
303
|
+
* the row the server already sent. No new read is made.
|
|
304
|
+
*
|
|
305
|
+
* The server sends a wire-compatible EMPTY fix for the richer remedies, so an empty
|
|
306
|
+
* or missing fix resolves by prerequisite ID (the repository is not indexed). An
|
|
307
|
+
* explicit published remedy keeps its meaning: `no_index` re-indexes, `pending_index`
|
|
308
|
+
* waits, and only a fix that actually carries the setup remedy tells the owner to
|
|
309
|
+
* merge the setup pull request. Anything else known-but-unclassified says the
|
|
310
|
+
* determining state could not be established, so no pending pull request is guessed.
|
|
311
|
+
*/
|
|
312
|
+
function indexedWorkflowsRemedy(readiness) {
|
|
313
|
+
const row = readiness.prerequisites?.find((p) => p.id === INDEXED_WORKFLOWS_ROW_ID);
|
|
314
|
+
if (row === undefined)
|
|
315
|
+
return INDEXED_WORKFLOWS_UNCLASSIFIED;
|
|
316
|
+
const fix = row.fix.length > 0
|
|
317
|
+
? row.fix
|
|
318
|
+
: resolveReadinessRemedy({ id: INDEXED_WORKFLOWS_ROW_ID, state: row.check_status === "unknown" ? "unknown" : "not_met" });
|
|
319
|
+
if (fix === READINESS_PREREQUISITE_FIXES.no_index || fix === READINESS_PREREQUISITE_FIXES.reindex_manual) {
|
|
320
|
+
return READINESS_PREREQUISITE_FIXES.reindex_manual;
|
|
321
|
+
}
|
|
322
|
+
if (fix === READINESS_PREREQUISITE_FIXES.pending_index)
|
|
323
|
+
return "Wait for indexing to finish, then run drive-epic again.";
|
|
324
|
+
if (fix.includes("Merge the setup pull request") || fix === READINESS_PREREQUISITE_FIXES.setup || fix.includes("merge the workflow changes"))
|
|
325
|
+
return fix;
|
|
326
|
+
return INDEXED_WORKFLOWS_UNCLASSIFIED;
|
|
327
|
+
}
|
|
328
|
+
const INDEXED_WORKFLOWS_UNCLASSIFIED = "The state blocking the indexed workflows could not be established; run readiness again to read it.";
|
|
281
329
|
/**
|
|
282
330
|
* Parse argv. Rejects malformed input BEFORE any side effect — no readiness
|
|
283
331
|
* read, no credential resolution, no delegation.
|
|
@@ -334,12 +382,25 @@ export function parseDriveEpicArgs(argv) {
|
|
|
334
382
|
const keepChildren = [];
|
|
335
383
|
const skipChildren = [];
|
|
336
384
|
let noMergedCheck = false;
|
|
385
|
+
// BAPI-1581 — validated for shape with setup-epic's own parser; forwarded verbatim.
|
|
386
|
+
let parallel;
|
|
337
387
|
for (let i = 0; i < argv.length; i++) {
|
|
338
388
|
const arg = argv[i];
|
|
339
389
|
if (arg === "--all") {
|
|
340
390
|
all = true;
|
|
341
391
|
continue;
|
|
342
392
|
}
|
|
393
|
+
if (arg === "--parallel" || arg.startsWith("--parallel=")) {
|
|
394
|
+
const inline = arg.startsWith("--parallel=");
|
|
395
|
+
const raw = inline ? arg.slice("--parallel=".length) : argv[i + 1];
|
|
396
|
+
const parsedParallel = parseParallelLimit(!inline && (raw === undefined || raw.startsWith("-")) ? undefined : raw);
|
|
397
|
+
if (!parsedParallel.ok)
|
|
398
|
+
return { status: "error", message: parsedParallel.error };
|
|
399
|
+
parallel = parsedParallel.value;
|
|
400
|
+
if (!inline)
|
|
401
|
+
i++;
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
343
404
|
if (arg === "--no-merged-check") {
|
|
344
405
|
noMergedCheck = true;
|
|
345
406
|
continue;
|
|
@@ -490,6 +551,16 @@ export function parseDriveEpicArgs(argv) {
|
|
|
490
551
|
"form of the read-only launch preview, and a real launch has no JSON output.",
|
|
491
552
|
};
|
|
492
553
|
}
|
|
554
|
+
// BAPI-1581 — an unattended-only request against an explicit opt-out, refused by
|
|
555
|
+
// name whatever the argument order, before any request or local service.
|
|
556
|
+
if (parallel !== undefined && (attended || intoBase)) {
|
|
557
|
+
return {
|
|
558
|
+
status: "error",
|
|
559
|
+
message: "drive-epic REFUSED (parallel-requires-unattended): --parallel sets the limit of an " +
|
|
560
|
+
`unattended run, and ${attended ? "--attended opts out of unattended operation" : "--into-base runs children directly into the repository base branch"}. ` +
|
|
561
|
+
"Drop --parallel, or make the run unattended.",
|
|
562
|
+
};
|
|
563
|
+
}
|
|
493
564
|
// BAPI-1510 — contradictory child intent is refused before any file read or launch.
|
|
494
565
|
const overlap = keepChildren.filter((key) => skipChildren.includes(key));
|
|
495
566
|
if (overlap.length > 0) {
|
|
@@ -559,6 +630,7 @@ export function parseDriveEpicArgs(argv) {
|
|
|
559
630
|
// Added only when supplied, so the no-flag options object stays byte-identical.
|
|
560
631
|
...(attended ? { attended: true } : {}),
|
|
561
632
|
...(policyFile ? { policyFile } : {}),
|
|
633
|
+
...(parallel !== undefined ? { parallel } : {}),
|
|
562
634
|
...(reviewPolicy ? { reviewPolicy } : {}),
|
|
563
635
|
...(replacePolicy ? { replacePolicy: true } : {}),
|
|
564
636
|
...(launchProfile ? { launchProfile } : {}),
|
|
@@ -598,7 +670,7 @@ export function parseDriveEpicArgs(argv) {
|
|
|
598
670
|
* about to be created.
|
|
599
671
|
*/
|
|
600
672
|
export function selectConductor(readiness) {
|
|
601
|
-
const missing = V2_READINESS_REQUIREMENTS.filter((req) => req.unattendedOnly !== true && req.advisoryOnly !== true && !req.satisfied(readiness));
|
|
673
|
+
const missing = V2_READINESS_REQUIREMENTS.filter((req) => req.unattendedOnly !== true && req.launchOnly !== true && req.advisoryOnly !== true && !req.satisfied(readiness));
|
|
602
674
|
if (missing.length === 0) {
|
|
603
675
|
return {
|
|
604
676
|
kind: "selected",
|
|
@@ -624,7 +696,7 @@ export function selectConductor(readiness) {
|
|
|
624
696
|
* no quoting to get wrong.
|
|
625
697
|
*/
|
|
626
698
|
export function buildSetupEpicArgv(options) {
|
|
627
|
-
const { epicKey, planFile, repo, featureBranch, intoBase, attended, policyFile, reviewPolicy, replacePolicy, launchProfile, baseUrl, verificationHandoff, verificationHandoffExceptions, } = options;
|
|
699
|
+
const { epicKey, planFile, repo, featureBranch, intoBase, attended, policyFile, reviewPolicy, replacePolicy, launchProfile, baseUrl, verificationHandoff, verificationHandoffExceptions, parallel, } = options;
|
|
628
700
|
return [
|
|
629
701
|
"--epic-key",
|
|
630
702
|
epicKey,
|
|
@@ -649,6 +721,9 @@ export function buildSetupEpicArgv(options) {
|
|
|
649
721
|
// when supplied, so every pre-existing argv stays byte-identical.
|
|
650
722
|
...(verificationHandoff !== undefined ? ["--verification-handoff", verificationHandoff] : []),
|
|
651
723
|
...(verificationHandoffExceptions ?? []).flatMap((entry) => ["--verification-handoff-exception", entry]),
|
|
724
|
+
// BAPI-1581 — the operator's requested limit, appended last and only when
|
|
725
|
+
// supplied, so every pre-existing argv stays byte-identical.
|
|
726
|
+
...(parallel !== undefined ? ["--parallel", String(parallel)] : []),
|
|
652
727
|
];
|
|
653
728
|
}
|
|
654
729
|
/**
|
|
@@ -681,7 +756,9 @@ launch = { profile: null },
|
|
|
681
756
|
* BAPI-1285 — what discovery found. Absent reads as "no metadata named this
|
|
682
757
|
* epic", with the searched directory left as its placeholder.
|
|
683
758
|
*/
|
|
684
|
-
discovery, presentation = "default"
|
|
759
|
+
discovery, presentation = "default",
|
|
760
|
+
/** BAPI-1621 — why automatic plan generation stopped, when it was tried. */
|
|
761
|
+
generationReason) {
|
|
685
762
|
// BAPI-1496 — an owner's explicit verification hand-off choice survives the
|
|
686
763
|
// re-run command verbatim. Nothing is derived: no flag, no flag added.
|
|
687
764
|
const handoffSuffix = [
|
|
@@ -713,6 +790,13 @@ discovery, presentation = "default") {
|
|
|
713
790
|
...discovery.candidates.map((candidate) => ` - ${candidate}`),
|
|
714
791
|
]
|
|
715
792
|
: [`No epic-plan.meta.json under ${plansDir} names ${epicKey}.`];
|
|
793
|
+
const generation = generationReason !== undefined
|
|
794
|
+
? [
|
|
795
|
+
"",
|
|
796
|
+
`Automatic plan generation was tried and stopped (${generationReason}): ` +
|
|
797
|
+
`${PLAN_GENERATION_FAILURE_TEXT[generationReason]}. Nothing was written.`,
|
|
798
|
+
]
|
|
799
|
+
: [];
|
|
716
800
|
const skipped = discovery !== undefined && discovery.skipped.length > 0
|
|
717
801
|
? [
|
|
718
802
|
"",
|
|
@@ -729,6 +813,7 @@ discovery, presentation = "default") {
|
|
|
729
813
|
: `${epicKey}: ${selection.reason}, but no plan was supplied and none could be selected.`,
|
|
730
814
|
"",
|
|
731
815
|
...outcome,
|
|
816
|
+
...generation,
|
|
732
817
|
...skipped,
|
|
733
818
|
"",
|
|
734
819
|
"Discovery reads only epic-plan.meta.json ({\"epic_key\": ...}). It never matches a",
|
|
@@ -771,8 +856,8 @@ const PLANE_DOWN_SELECTION = {
|
|
|
771
856
|
* The one text both the preview and a real launch print for the guarded
|
|
772
857
|
* plane-down no-plan stop, so the preview is a verbatim part of the real output.
|
|
773
858
|
*/
|
|
774
|
-
function planeDownNoPlanStopText(epicKey, launch, discovery) {
|
|
775
|
-
const text = renderConductorHandoff(PLANE_DOWN_SELECTION, epicKey, launch, discovery, "plane_not_running")
|
|
859
|
+
function planeDownNoPlanStopText(epicKey, launch, discovery, generationReason) {
|
|
860
|
+
const text = renderConductorHandoff(PLANE_DOWN_SELECTION, epicKey, launch, discovery, "plane_not_running", generationReason)
|
|
776
861
|
.lines.join("\n");
|
|
777
862
|
assertSingleConductorInvocation(text);
|
|
778
863
|
return text;
|
|
@@ -1044,9 +1129,16 @@ function createDefaultPlanDiscoveryFs() {
|
|
|
1044
1129
|
readFile: (filePath) => readFile(filePath, "utf8"),
|
|
1045
1130
|
};
|
|
1046
1131
|
}
|
|
1132
|
+
/**
|
|
1133
|
+
* The server's terminal code for more than one active run on one epic
|
|
1134
|
+
* (`api/library/db/epic_runs.py:EPIC_RUN_CODE_ACTIVE_RUN_EXISTS`). The only 409
|
|
1135
|
+
* the live-run read counts as a wedged epic (BAPI-1595).
|
|
1136
|
+
*/
|
|
1137
|
+
export const ACTIVE_EPIC_RUN_EXISTS_ERROR_CODE = "ACTIVE_EPIC_RUN_EXISTS";
|
|
1047
1138
|
/**
|
|
1048
1139
|
* BAPI-1285 — map the by-epic-key run read the way `setup-epic`'s Step 0 does:
|
|
1049
|
-
* 404 is no run, 409 is a wedged epic, and
|
|
1140
|
+
* 404 is no run, a 409 carrying `ACTIVE_EPIC_RUN_EXISTS` is a wedged epic, and
|
|
1141
|
+
* every other failure (any other 409 included) is unknown.
|
|
1050
1142
|
* Nothing but a status and an error kind is ever kept from a failure.
|
|
1051
1143
|
*/
|
|
1052
1144
|
export async function readLiveEpicRunByKey(access, epicKey, fetchImpl = globalThis.fetch) {
|
|
@@ -1077,8 +1169,12 @@ export async function readLiveEpicRunByKey(access, epicKey, fetchImpl = globalTh
|
|
|
1077
1169
|
if (err instanceof ConductorBridgeApiError) {
|
|
1078
1170
|
if (err.status === 404)
|
|
1079
1171
|
return { kind: "none" };
|
|
1080
|
-
|
|
1172
|
+
// BAPI-1595 — a 409 is a wedged epic ONLY when its typed `errorCode` says so.
|
|
1173
|
+
// Any other 409, or one with no readable code, proves nothing about whether a
|
|
1174
|
+
// second run exists, so it is unknown (the server's idempotent create decides).
|
|
1175
|
+
if (err.status === 409 && err.errorCode === ACTIVE_EPIC_RUN_EXISTS_ERROR_CODE) {
|
|
1081
1176
|
return { kind: "conflict" };
|
|
1177
|
+
}
|
|
1082
1178
|
return {
|
|
1083
1179
|
kind: "unknown",
|
|
1084
1180
|
reason: `kind=${err.kind}${typeof err.status === "number" ? ` status=${err.status}` : ""}`,
|
|
@@ -1096,7 +1192,19 @@ export function createDefaultDriveEpicDeps() {
|
|
|
1096
1192
|
if (!top.ok || !path.isAbsolute(top.stdout.trim()))
|
|
1097
1193
|
throw new Error("repository_root_unverifiable");
|
|
1098
1194
|
const repoRoot = await realpath(top.stdout.trim());
|
|
1099
|
-
|
|
1195
|
+
// BAPI-1595 — tri-state: only all-markers-absent is non-Bridge. A partial
|
|
1196
|
+
// checkout stays Bridge-applicable, and a marker that cannot be inspected
|
|
1197
|
+
// keeps the existing `repository-identity-unverifiable` refusal.
|
|
1198
|
+
const applicability = await classifyBridgeCheckout(repoRoot, createPlaneFsDeps());
|
|
1199
|
+
if (applicability === "unknown")
|
|
1200
|
+
throw new Error("repository_identity_unverifiable");
|
|
1201
|
+
return { repoRoot, isBridge: applicability === "bridge" };
|
|
1202
|
+
},
|
|
1203
|
+
readScopeBaseBranch: async (access) => {
|
|
1204
|
+
const configured = await getConfigFieldBaseBranch(access, globalThis.fetch);
|
|
1205
|
+
if (!configured.ok)
|
|
1206
|
+
return null;
|
|
1207
|
+
return configured.value.base_branch !== null ? configured.value.base_branch : "main";
|
|
1100
1208
|
},
|
|
1101
1209
|
resolveAccess: async (repo, cwd, launch) => {
|
|
1102
1210
|
// BAPI-1260: the target-first launch contract. BAPI-1272: with no target
|
|
@@ -1117,6 +1225,8 @@ export function createDefaultDriveEpicDeps() {
|
|
|
1117
1225
|
process.env.BAPI_BASE_URL = baseUrl;
|
|
1118
1226
|
},
|
|
1119
1227
|
readReadiness: (access) => fetchConductorReadiness(access, globalThis.fetch),
|
|
1228
|
+
writeLaunchContext: (context) => writeEpicLaunchContext(context),
|
|
1229
|
+
reportLaunch: (report) => console.error(`${LAUNCH_REPORT_PREFIX}${JSON.stringify(report)}`),
|
|
1120
1230
|
runSetupEpic: (argv, handoff) => runSetupEpicWorkflow(argv, {}, handoff),
|
|
1121
1231
|
readEligibilityArtifact: (path) => readFile(path, "utf8"),
|
|
1122
1232
|
runPlanePreflight: (repoRoot) => runDefaultPlanePreflight(repoRoot),
|
|
@@ -1137,7 +1247,10 @@ export function createDefaultDriveEpicDeps() {
|
|
|
1137
1247
|
cwd: () => process.cwd(),
|
|
1138
1248
|
resolvePlaneEndpoint: () => resolvePlaneServerEndpoint(process.env),
|
|
1139
1249
|
probePlanePort: (host, port) => probeTcpPort(host, port, PLANE_PORT_PROBE_TIMEOUT_MS),
|
|
1140
|
-
checkExecutorBuildFreshness: (repoRoot) => checkPlaneBuildFreshness(repoRoot, {
|
|
1250
|
+
checkExecutorBuildFreshness: (repoRoot, applicability) => checkPlaneBuildFreshness(repoRoot, {
|
|
1251
|
+
fs: createPlaneFsDeps(),
|
|
1252
|
+
...(applicability?.isBridge === false ? { isBridge: false } : {}),
|
|
1253
|
+
}),
|
|
1141
1254
|
collectPlaneFreshness: ({ repoRoot, ownsManifest, expectedPlaneId }) => checkPlaneFreshness(repoRoot, {
|
|
1142
1255
|
execFile: createPlaneExecFile(),
|
|
1143
1256
|
fileExists: (filePath) => fsStat(filePath).then((entry) => entry.isFile(), () => false),
|
|
@@ -1152,10 +1265,30 @@ export function createDefaultDriveEpicDeps() {
|
|
|
1152
1265
|
execFile: createPlaneExecFile(),
|
|
1153
1266
|
workflows: createWorkflowSource(),
|
|
1154
1267
|
}),
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1268
|
+
// A launch shows only the role and the boundary (BAPI-1594); `doctor` keeps the full inspection.
|
|
1269
|
+
inspectWorkerDatabase: (repoRoot, config) => createWorkerDatabaseDoctorInspector({ env: process.env, cwd: repoRoot ?? process.cwd(), scope: "launch" })(config),
|
|
1270
|
+
// BAPI-1596 — child 5's validated cache, read-only: no claim, no write, bounded in time.
|
|
1271
|
+
readPrerequisiteCache: async ({ epicKey, children, access }) => {
|
|
1272
|
+
const { readCachedPrerequisites } = await import("./conductor/prerequisite-inputs.js");
|
|
1273
|
+
const { fetchStoredTicket } = await import("./conductor/bridge-api-client.js");
|
|
1274
|
+
let timer;
|
|
1275
|
+
const deadline = new Promise((resolve) => {
|
|
1276
|
+
timer = setTimeout(() => resolve({ kind: "unavailable" }), PREREQUISITE_CACHE_READ_TIMEOUT_MS);
|
|
1277
|
+
});
|
|
1278
|
+
try {
|
|
1279
|
+
return await Promise.race([
|
|
1280
|
+
readCachedPrerequisites({ epicKey, children, fetchTicket: (key) => fetchStoredTicket(access, key) }),
|
|
1281
|
+
deadline,
|
|
1282
|
+
]);
|
|
1283
|
+
}
|
|
1284
|
+
finally {
|
|
1285
|
+
if (timer !== undefined)
|
|
1286
|
+
clearTimeout(timer);
|
|
1287
|
+
}
|
|
1288
|
+
},
|
|
1289
|
+
execEngineStatus: createPlaneExecFile(),
|
|
1158
1290
|
cleanupTerminalRunPlane: (input) => cleanupTerminalRunPlane(input, createTerminalRunCleanupDeps(process.env)),
|
|
1291
|
+
listLiveRunIds: (access) => createTerminalRunCleanupDeps(process.env).listLiveRunIds(access),
|
|
1159
1292
|
readRunState: async (access, epicRunId) => {
|
|
1160
1293
|
const state = await fetchEpicRunState(access, epicRunId, globalThis.fetch);
|
|
1161
1294
|
const run = state.epic_run;
|
|
@@ -1187,12 +1320,39 @@ export function createDefaultDriveEpicDeps() {
|
|
|
1187
1320
|
}),
|
|
1188
1321
|
discoveryFs: createDefaultPlanDiscoveryFs(),
|
|
1189
1322
|
readPlanDag: (filePath) => readFile(filePath, "utf8"),
|
|
1323
|
+
// BAPI-1621 — the general resolver, never the launch profile: generation runs
|
|
1324
|
+
// before any local plane is up, exactly like `prerequisite-inputs`.
|
|
1325
|
+
attemptPlanGeneration: (epicKey) => attemptPlanGeneration(epicKey, {
|
|
1326
|
+
resolveAccess: () => resolveConductorBridgeApiAccess(),
|
|
1327
|
+
readLiveRun: async (access, key) => (await readLiveEpicRunByKey(access, key)).kind,
|
|
1328
|
+
fetchChildren: (access, key) => fetchEpicChildren(access, key),
|
|
1329
|
+
fetchTicket: async (access, key) => ({ description: await fetchStoredTicketDescription(access, key) }),
|
|
1330
|
+
listTrackedFiles: () => listTrackedFilesWithGit(process.cwd()),
|
|
1331
|
+
validatePlan: (access, request) => validateEpicPlan(access, request),
|
|
1332
|
+
}),
|
|
1333
|
+
publishGeneratedPlan: ({ epicKey, docsDir, dag, summary, access }) => publishGeneratedPlan({
|
|
1334
|
+
epicKey,
|
|
1335
|
+
docsDir,
|
|
1336
|
+
dag,
|
|
1337
|
+
summary,
|
|
1338
|
+
fs: createDefaultPlanPublicationFs(),
|
|
1339
|
+
validate: () => validateGeneratedPlan(access, epicKey, dag, (a, request) => validateEpicPlan(a, request)),
|
|
1340
|
+
rediscover: () => discoverEpicPlan(epicKey, docsDir, createDefaultPlanDiscoveryFs()),
|
|
1341
|
+
}),
|
|
1190
1342
|
readPolicyFile: (filePath) => readFile(filePath, "utf8"),
|
|
1191
1343
|
readLiveEpicRun: (access, epicKey) => readLiveEpicRunByKey(access, epicKey),
|
|
1192
|
-
previewSetupEpic: async ({ argv, baseUrl, handoff, observations }) => {
|
|
1344
|
+
previewSetupEpic: async ({ argv, baseUrl, handoff, observations, planContents }) => {
|
|
1193
1345
|
const stdout = [];
|
|
1194
1346
|
const stderr = [];
|
|
1195
1347
|
const result = await runSetupEpicWorkflow(argv, {
|
|
1348
|
+
...(planContents !== undefined
|
|
1349
|
+
? {
|
|
1350
|
+
readFile: (filePath) => {
|
|
1351
|
+
const inline = planContents.get(filePath);
|
|
1352
|
+
return inline !== undefined ? Promise.resolve(inline) : readFile(filePath, "utf8");
|
|
1353
|
+
},
|
|
1354
|
+
}
|
|
1355
|
+
: {}),
|
|
1196
1356
|
// A COPY carrying the resolved target: the preview never mutates
|
|
1197
1357
|
// `process.env`, so a dry run leaves the process exactly as it found it.
|
|
1198
1358
|
env: { ...process.env, BAPI_BASE_URL: baseUrl },
|
|
@@ -1259,11 +1419,16 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1259
1419
|
return 1;
|
|
1260
1420
|
}
|
|
1261
1421
|
const { epicKey, planFile, repo, featureBranch, intoBase } = parsed.options;
|
|
1262
|
-
const { bridgeWorktreeCleanupAdvisory } = await import("./bridge-worktree-inspection.js");
|
|
1263
|
-
const cleanupAdvisory = await bridgeWorktreeCleanupAdvisory(deps.cwd());
|
|
1264
|
-
if (cleanupAdvisory)
|
|
1265
|
-
deps.errorLog(cleanupAdvisory);
|
|
1266
1422
|
const launch = launchSelectionOf(parsed.options);
|
|
1423
|
+
// BAPI-1581 — a supplied `--parallel` against an explicit policy file is judged
|
|
1424
|
+
// locally, before any request, readiness probe, setup call, or local service
|
|
1425
|
+
// start. Only the explicit file is read here; a profile or default composition
|
|
1426
|
+
// is judged on the creation routes, where a candidate creation policy exists.
|
|
1427
|
+
const earlyParallelRefusal = await explicitPolicyParallelRefusal(deps, parsed.options);
|
|
1428
|
+
if (earlyParallelRefusal !== null) {
|
|
1429
|
+
deps.errorLog(earlyParallelRefusal);
|
|
1430
|
+
return 1;
|
|
1431
|
+
}
|
|
1267
1432
|
// BAPI-1285 — the read-only preview is its own path from here. It shares the
|
|
1268
1433
|
// classification and refusal builders below and none of the launch code.
|
|
1269
1434
|
if (parsed.options.dryRun === true) {
|
|
@@ -1302,6 +1467,10 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1302
1467
|
targetSource: accessResult.targetSource ?? "default",
|
|
1303
1468
|
freshness: createPlaneFreshnessCache(),
|
|
1304
1469
|
launchCredential: {},
|
|
1470
|
+
launchObservations: [],
|
|
1471
|
+
liveObservation: {},
|
|
1472
|
+
invokedAt: new Date((deps.now ?? Date.now)()).toISOString(),
|
|
1473
|
+
launchReportState: { reported: false },
|
|
1305
1474
|
};
|
|
1306
1475
|
// BAPI-1285 — with no `--plan-file`, look for the plan BEFORE readiness. A
|
|
1307
1476
|
// discovered plan must count as a supplied one for the BAPI-1153 cold-start
|
|
@@ -1316,10 +1485,17 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1316
1485
|
// discovered plan is a convenience, not approved input: it may still be used to
|
|
1317
1486
|
// create a run, but a live run is attached to first and the plan stays unused.
|
|
1318
1487
|
let planWasDiscovered = false;
|
|
1488
|
+
// BAPI-1621 — why automatic generation stopped, for the no-plan stop text.
|
|
1489
|
+
let generationReason;
|
|
1319
1490
|
if (planFile === undefined) {
|
|
1320
1491
|
const docs = await deps.resolveDocsDir();
|
|
1321
1492
|
if (docs.ok) {
|
|
1322
1493
|
discovered = await discoverEpicPlan(epicKey, docs.docsDir, deps.discoveryFs);
|
|
1494
|
+
if (discovered.status === "plan_not_found") {
|
|
1495
|
+
const generated = await generateMissingPlanForLaunch(ctx, docs.docsDir, discovered);
|
|
1496
|
+
discovered = generated.discovery;
|
|
1497
|
+
generationReason = generated.reason;
|
|
1498
|
+
}
|
|
1323
1499
|
if (discovered.status === "found") {
|
|
1324
1500
|
planWasDiscovered = true;
|
|
1325
1501
|
ctx = { ...ctx, options: { ...ctx.options, planFile: discovered.path } };
|
|
@@ -1331,73 +1507,68 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1331
1507
|
}
|
|
1332
1508
|
let foundPlanAnnounced = false;
|
|
1333
1509
|
/** Names the found plan once, BEFORE anything is created, and surfaces its advisory. */
|
|
1334
|
-
const announceFoundPlan = async (
|
|
1510
|
+
const announceFoundPlan = async () => {
|
|
1335
1511
|
if (foundPlanAnnounced || discovered?.status !== "found")
|
|
1336
1512
|
return;
|
|
1337
1513
|
foundPlanAnnounced = true;
|
|
1338
1514
|
deps.log(`${epicKey}: using the plan found by epic key: ${discovered.path}`);
|
|
1339
|
-
if (surfaceAdvisory)
|
|
1340
|
-
await surfaceContainmentAdvisory(deps, discovered.path);
|
|
1341
1515
|
};
|
|
1342
|
-
// ---
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
return escalate(deps, epicKey, `launch profile '${launchProfile.name}' selects durable execution, and its control plane is ` +
|
|
1369
|
-
"not answering; no local replacement was started");
|
|
1370
|
-
}
|
|
1371
|
-
if (endpoint !== null) {
|
|
1372
|
-
const probe = await deps.probePlanePort(endpoint.host, endpoint.port);
|
|
1373
|
-
if (probe.kind === "refused") {
|
|
1374
|
-
// `coldStartPlane` surfaces the containment advisory itself.
|
|
1375
|
-
await announceFoundPlan(false);
|
|
1376
|
-
return await coldStartPlane(ctx);
|
|
1516
|
+
// --- No readiness read at launch (BAPI-1595). -----------------------------
|
|
1517
|
+
// The preview owns readiness acquisition (one attempt plus one retry). A real
|
|
1518
|
+
// launch reads nothing: it reuses the preview's stored snapshot when that
|
|
1519
|
+
// snapshot is bound to THIS launch, and otherwise writes one fixed tally line
|
|
1520
|
+
// and carries on with every evaluator on its unknown (warn) path. The server's
|
|
1521
|
+
// create and approve stay the gate.
|
|
1522
|
+
//
|
|
1523
|
+
// A cold start used to be recognized from a failed readiness read. It is now
|
|
1524
|
+
// recognized from the plane port itself: a refused port IS "no server yet".
|
|
1525
|
+
const planeEndpoint = planeTarget ? planeEndpointForBaseUrl(deps, accessResult.access.baseUrl) : null;
|
|
1526
|
+
const noPlanDiscovery = launchProfile?.executionMode !== "durable" &&
|
|
1527
|
+
discovered !== null &&
|
|
1528
|
+
(discovered.status === "plan_not_found" || discovered.status === "plan_ambiguous")
|
|
1529
|
+
? discovered
|
|
1530
|
+
: null;
|
|
1531
|
+
if (planeEndpoint !== null && (ctx.options.planFile !== undefined || noPlanDiscovery !== null)) {
|
|
1532
|
+
const probe = await deps.probePlanePort(planeEndpoint.host, planeEndpoint.port).catch(() => ({ kind: "error" }));
|
|
1533
|
+
if (probe.kind === "refused") {
|
|
1534
|
+
if (ctx.options.planFile !== undefined) {
|
|
1535
|
+
// BAPI-1260 — only a SELECTED LOCAL plane is ever started here. A
|
|
1536
|
+
// profile approved for durable execution names an authority this
|
|
1537
|
+
// machine does not own, so a refused port is that authority being
|
|
1538
|
+
// down — never permission to launch a local replacement.
|
|
1539
|
+
if (launchProfile !== null && launchProfile.executionMode !== "local") {
|
|
1540
|
+
return escalate(deps, epicKey, `launch profile '${launchProfile.name}' selects durable execution, and its control plane is ` +
|
|
1541
|
+
"not answering; no local replacement was started");
|
|
1377
1542
|
}
|
|
1543
|
+
// `coldStartPlane` surfaces the containment advisory itself.
|
|
1544
|
+
await announceFoundPlan();
|
|
1545
|
+
return await coldStartPlane(ctx);
|
|
1378
1546
|
}
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
planeTarget &&
|
|
1386
|
-
err instanceof ConductorBridgeApiError &&
|
|
1387
|
-
err.kind === "network" &&
|
|
1388
|
-
launchProfile?.executionMode !== "durable" &&
|
|
1389
|
-
discovered !== null &&
|
|
1390
|
-
(discovered.status === "plan_not_found" || discovered.status === "plan_ambiguous")) {
|
|
1391
|
-
const endpoint = planeEndpointForBaseUrl(deps, accessResult.access.baseUrl);
|
|
1392
|
-
if (endpoint !== null) {
|
|
1393
|
-
const probe = await deps.probePlanePort(endpoint.host, endpoint.port).catch(() => ({ kind: "error" }));
|
|
1394
|
-
if (probe.kind === "refused") {
|
|
1395
|
-
deps.errorLog(planeDownNoPlanStopText(epicKey, { profile: launchProfile, options: parsed.options }, discovered));
|
|
1396
|
-
return 1;
|
|
1397
|
-
}
|
|
1547
|
+
// The narrow no-plan stop: a local, non-durable plane that refuses
|
|
1548
|
+
// connections, with no usable plan supplied or discovered. This is the
|
|
1549
|
+
// existing stop outcome, not a new refusal. Nothing is started or created.
|
|
1550
|
+
if (noPlanDiscovery !== null) {
|
|
1551
|
+
deps.errorLog(planeDownNoPlanStopText(epicKey, { profile: launchProfile, options: parsed.options }, noPlanDiscovery, generationReason));
|
|
1552
|
+
return 1;
|
|
1398
1553
|
}
|
|
1399
1554
|
}
|
|
1400
|
-
|
|
1555
|
+
}
|
|
1556
|
+
const resolvedSnapshot = await resolveLaunchSnapshot(ctx);
|
|
1557
|
+
ctx = {
|
|
1558
|
+
...ctx,
|
|
1559
|
+
launchSnapshot: resolvedSnapshot.snapshot,
|
|
1560
|
+
...(resolvedSnapshot.previewRepository !== undefined
|
|
1561
|
+
? { previewRepository: resolvedSnapshot.previewRepository }
|
|
1562
|
+
: {}),
|
|
1563
|
+
};
|
|
1564
|
+
const readiness = launchFullReadiness();
|
|
1565
|
+
// BAPI-1595 — a launch from a VERIFIED non-Bridge checkout runs none of the
|
|
1566
|
+
// Bridge-only checks, so no repository-root, build-entrypoint, plane database
|
|
1567
|
+
// head, or worker-database finding exists to render. Each skip is written to the
|
|
1568
|
+
// tally exactly once.
|
|
1569
|
+
if (isConfirmedNonBridge(ctx)) {
|
|
1570
|
+
for (const skip of Object.values(BRIDGE_ONLY_SKIPS))
|
|
1571
|
+
tallyBridgeOnlySkip(ctx, skip);
|
|
1401
1572
|
}
|
|
1402
1573
|
// BAPI-1532 — an EXPLICIT plan selects its setup now. A discovered plan does
|
|
1403
1574
|
// not: plan selection, approval, and the create-time escalation-channel checks
|
|
@@ -1414,15 +1585,9 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1414
1585
|
ctx = { ...ctx, handoff: prepared.handoff };
|
|
1415
1586
|
}
|
|
1416
1587
|
// --- Route. Exactly one path from here on. -------------------------------
|
|
1417
|
-
|
|
1418
|
-
//
|
|
1419
|
-
|
|
1420
|
-
// other resolvable location). Fail-open: any failure here — missing
|
|
1421
|
-
// artifact, bad JSON, malformed/inconsistent shape, an unsafe rendered
|
|
1422
|
-
// value — silently yields no advisory and never affects routing, the
|
|
1423
|
-
// delegated argv, or the exit code.
|
|
1424
|
-
if (planFile)
|
|
1425
|
-
await surfaceContainmentAdvisory(deps, planFile);
|
|
1588
|
+
// BAPI-1593 — an unknown report selects the one engine there is (v2) and
|
|
1589
|
+
// takes the green route below; nothing here is decided from it.
|
|
1590
|
+
const selection = readiness === null ? READINESS_UNKNOWN_SELECTION : selectConductor(readiness);
|
|
1426
1591
|
// BAPI-1285 — no `--plan-file`: find the plan from the epic key, and read the
|
|
1427
1592
|
// epic's live run. Readiness has already been resolved (unknown escalated
|
|
1428
1593
|
// above), so nothing here can be a discovery-driven create on unknown.
|
|
@@ -1434,13 +1599,15 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1434
1599
|
if (docsRootUnresolved || discovered === null) {
|
|
1435
1600
|
return refuse(deps, docsRootRefusal(epicKey).lines);
|
|
1436
1601
|
}
|
|
1437
|
-
|
|
1438
|
-
//
|
|
1439
|
-
|
|
1602
|
+
// BAPI-1595 — the launch's ONE pre-mutation live-run observation (one retry on
|
|
1603
|
+
// unknown), shared by every pre-create consumer below.
|
|
1604
|
+
const live = await acquireObservedLive(ctx);
|
|
1605
|
+
// Wedged (the server's typed `ACTIVE_EPIC_RUN_EXISTS`): never a create and
|
|
1606
|
+
// never an attach, whatever discovery found. An UNKNOWN read is not that: it
|
|
1607
|
+
// warned in the tally, and the server's idempotent create returns the existing
|
|
1608
|
+
// run if there is one, so it continues as "no run seen".
|
|
1440
1609
|
if (live.kind === "conflict")
|
|
1441
1610
|
return refuse(deps, liveRunAmbiguousRefusal(epicKey).lines);
|
|
1442
|
-
if (live.kind === "unknown")
|
|
1443
|
-
return refuse(deps, liveRunUnknownRefusal(epicKey, live.reason).lines);
|
|
1444
1611
|
if (discovered.status === "found") {
|
|
1445
1612
|
if (live.kind === "live") {
|
|
1446
1613
|
// BAPI-1532 — attach FIRST. The discovered plan is dropped from the
|
|
@@ -1484,11 +1651,13 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1484
1651
|
// reads: whatever a `--policy-file` says stays opaque here, exactly as it
|
|
1485
1652
|
// always has. Its mere PRESENCE defers the escalation-channel requirement
|
|
1486
1653
|
// to `setup-epic`, which composes the policy and can actually read it.
|
|
1487
|
-
const classification =
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1654
|
+
const classification = readiness === null
|
|
1655
|
+
? classifySnapshotDiagnostics(ctx)
|
|
1656
|
+
: classifyV2Readiness(readiness, {
|
|
1657
|
+
attended: parsed.options.attended === true,
|
|
1658
|
+
intoBase: parsed.options.intoBase === true,
|
|
1659
|
+
effectivePolicy: ctx.handoff?.selection,
|
|
1660
|
+
});
|
|
1492
1661
|
// Green: create the run, then make sure something will claim its jobs
|
|
1493
1662
|
// (BAPI-1279). Before this, green delegated to setup-epic and nothing
|
|
1494
1663
|
// else, so a production launch — or any second run — created a run no
|
|
@@ -1512,8 +1681,11 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1512
1681
|
const probe = endpoint
|
|
1513
1682
|
? await deps.probePlanePort(endpoint.host, endpoint.port).catch(() => ({ kind: "error" }))
|
|
1514
1683
|
: null;
|
|
1515
|
-
|
|
1684
|
+
// BAPI-1593 — a fresh plane is a fresh server, so the stopped plane's
|
|
1685
|
+
// answer (and any stored snapshot of it) is never reused for it.
|
|
1686
|
+
if (probe?.kind === "refused") {
|
|
1516
1687
|
return await coldStartPlane(ctx);
|
|
1688
|
+
}
|
|
1517
1689
|
}
|
|
1518
1690
|
const attachable = await findAttachablePlane(ctx);
|
|
1519
1691
|
if (attachable !== null) {
|
|
@@ -1551,12 +1723,14 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1551
1723
|
deps.errorLog(refusal);
|
|
1552
1724
|
return 1;
|
|
1553
1725
|
}
|
|
1726
|
+
// Only a READABLE report reaches here: an unknown one took the green route.
|
|
1727
|
+
const report = readiness;
|
|
1554
1728
|
// BAPI-1279 — runtime-only against a target that is NOT this machine's
|
|
1555
1729
|
// plane: starting anything here could not help, because the missing
|
|
1556
1730
|
// reconciler belongs to that deployment. One named reason, and nothing
|
|
1557
1731
|
// local is touched.
|
|
1558
1732
|
if (!planeTarget) {
|
|
1559
|
-
return refuseRemoteRuntime(ctx,
|
|
1733
|
+
return refuseRemoteRuntime(ctx, report);
|
|
1560
1734
|
}
|
|
1561
1735
|
// Runtime-only: this invocation composes bring-up with run creation.
|
|
1562
1736
|
const repoRoot = deps.cwd();
|
|
@@ -1598,7 +1772,7 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1598
1772
|
return 1;
|
|
1599
1773
|
}
|
|
1600
1774
|
if (attachManifest !== null) {
|
|
1601
|
-
return await attachToPlane(ctx, attachManifest,
|
|
1775
|
+
return await attachToPlane(ctx, attachManifest, report);
|
|
1602
1776
|
}
|
|
1603
1777
|
// ---- PHASE ONE: the control plane, and NOTHING that claims jobs --------
|
|
1604
1778
|
//
|
|
@@ -1616,7 +1790,13 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1616
1790
|
deps.log(`${epicKey}: the Epic Implementer runtime is not live; starting its control plane before creating the run.`);
|
|
1617
1791
|
// The SAME preflight result is handed to the launch, so the port that was
|
|
1618
1792
|
// probed is the port that gets launched and the two cannot disagree.
|
|
1619
|
-
const
|
|
1793
|
+
const parallelCreationRefusal = await parallelCreationCandidateRefusal(ctx);
|
|
1794
|
+
if (parallelCreationRefusal !== null) {
|
|
1795
|
+
deps.errorLog(`${epicKey}: ${parallelCreationRefusal}\nNothing was started.`);
|
|
1796
|
+
return 1;
|
|
1797
|
+
}
|
|
1798
|
+
const startedLanes = parallelLimitToExecutorLanes(ctx.options.parallel ?? DEFAULT_RUN_PARALLEL_LIMIT);
|
|
1799
|
+
const controlPlane = await deps.launchControlPlane({ preflight, executors: startedLanes });
|
|
1620
1800
|
if (!controlPlane.ok) {
|
|
1621
1801
|
// The launch already reported why, in its own words, and it rolls its own
|
|
1622
1802
|
// startup back. No run was created here.
|
|
@@ -1644,7 +1824,8 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1644
1824
|
repoRoot,
|
|
1645
1825
|
planeId: controlPlane.planeId,
|
|
1646
1826
|
awaitPlaneReady: controlPlane.awaitPlaneReady,
|
|
1647
|
-
|
|
1827
|
+
laneCount: startedLanes,
|
|
1828
|
+
}, report);
|
|
1648
1829
|
}
|
|
1649
1830
|
// No plan file, and readiness is not green: v2 is not ready and there is no
|
|
1650
1831
|
// second conductor to offer. Report it as a not-ready refusal on stderr with
|
|
@@ -1664,7 +1845,7 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1664
1845
|
}
|
|
1665
1846
|
// BAPI-1285 — reached only after discovery came back empty or ambiguous and no
|
|
1666
1847
|
// live run exists. Nothing was created, so this is a stop, not a success.
|
|
1667
|
-
const handoff = renderConductorHandoff(selection, epicKey, { profile: launchProfile, options: parsed.options }, discoveryStop);
|
|
1848
|
+
const handoff = renderConductorHandoff(selection, epicKey, { profile: launchProfile, options: parsed.options }, discoveryStop, "default", generationReason);
|
|
1668
1849
|
const text = handoff.lines.join("\n");
|
|
1669
1850
|
assertSingleConductorInvocation(text);
|
|
1670
1851
|
deps.errorLog(text);
|
|
@@ -1678,28 +1859,6 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1678
1859
|
return 1;
|
|
1679
1860
|
}
|
|
1680
1861
|
}
|
|
1681
|
-
/**
|
|
1682
|
-
* BAPI-1022: surface any containment-hazard advisory before dispatch or handoff.
|
|
1683
|
-
*
|
|
1684
|
-
* Read only when a plan file was supplied (the sidecar has no other resolvable
|
|
1685
|
-
* location). Fail-open: any failure — missing artifact, bad JSON,
|
|
1686
|
-
* malformed/inconsistent shape, an unsafe rendered value — silently yields no
|
|
1687
|
-
* advisory and never affects routing, the delegated argv, or the exit code.
|
|
1688
|
-
* One helper, so the cold-start path (BAPI-1153) cannot drift from the rest.
|
|
1689
|
-
*/
|
|
1690
|
-
async function surfaceContainmentAdvisory(deps, planFile) {
|
|
1691
|
-
try {
|
|
1692
|
-
const advisory = await readContainmentEligibilityAdvisory(planFile, deps.readEligibilityArtifact);
|
|
1693
|
-
if (advisory) {
|
|
1694
|
-
const rendered = renderContainmentEligibilityAdvisory(advisory);
|
|
1695
|
-
if (rendered)
|
|
1696
|
-
deps.log(rendered);
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
catch {
|
|
1700
|
-
// Fail open — a containment advisory is never allowed to block dispatch.
|
|
1701
|
-
}
|
|
1702
|
-
}
|
|
1703
1862
|
/**
|
|
1704
1863
|
* BAPI-1285 — the one remedy sentence an unknown-readiness escalation ends with.
|
|
1705
1864
|
* A constant so the preview's `readiness.remedy` is the very line the real
|
|
@@ -1719,34 +1878,421 @@ function operatorBlockedRemedy(classification) {
|
|
|
1719
1878
|
return `${remedy} See ${CONSUMER_GUIDE_POINTER}.`;
|
|
1720
1879
|
}
|
|
1721
1880
|
/**
|
|
1722
|
-
* The
|
|
1723
|
-
*
|
|
1724
|
-
*
|
|
1881
|
+
* The stop for a launch that cannot reach its target: no usable credential, or a
|
|
1882
|
+
* durable profile's control plane that does not answer. Both are needs only a
|
|
1883
|
+
* person can meet. Prints NO conductor invocation.
|
|
1884
|
+
*
|
|
1885
|
+
* BAPI-1593 — an unknown readiness read no longer comes here: it warns and
|
|
1886
|
+
* continues to the server's create and approve. There is one engine
|
|
1887
|
+
* (`DRIVE_EPIC_CONDUCTORS = ["v2"]`), so there is no "wrong engine" to start.
|
|
1725
1888
|
*/
|
|
1726
1889
|
function escalate(deps, epicKey, reason) {
|
|
1727
|
-
const lines = [
|
|
1728
|
-
`Cannot determine which engine owns ${epicKey}: ${reason}`,
|
|
1729
|
-
"",
|
|
1730
|
-
"This is not a not-ready result — it is an unknown one, and starting the wrong",
|
|
1731
|
-
"engine on an epic wedges it permanently.",
|
|
1732
|
-
ESCALATE_REMEDY,
|
|
1733
|
-
];
|
|
1890
|
+
const lines = [`Cannot start ${epicKey}: ${reason}`, "", ESCALATE_REMEDY];
|
|
1734
1891
|
const text = lines.join("\n");
|
|
1735
1892
|
assertSingleConductorInvocation(text);
|
|
1736
1893
|
deps.errorLog(text);
|
|
1737
1894
|
return 1;
|
|
1738
1895
|
}
|
|
1896
|
+
/** The prefix of the default launch-report line. */
|
|
1897
|
+
export const LAUNCH_REPORT_PREFIX = "Launch report: ";
|
|
1898
|
+
/** How long drive-epic watches a planning run for activation after an uncertain approve. */
|
|
1899
|
+
export const ACTIVATION_ATTACH_WINDOW_MS = 10 * 60_000;
|
|
1900
|
+
/** The pause between activation reads, capped to the time left. */
|
|
1901
|
+
export const ACTIVATION_POLL_INTERVAL_MS = 15_000;
|
|
1902
|
+
/** The warning printed when the attach window ends with the run still waiting. */
|
|
1903
|
+
export const APPROVAL_NOT_CONFIRMED_WARNING = "approval not confirmed: the run is still waiting for approval";
|
|
1904
|
+
/** The selection an unknown report takes: the one engine there is. */
|
|
1905
|
+
const READINESS_UNKNOWN_SELECTION = {
|
|
1906
|
+
kind: "selected",
|
|
1907
|
+
conductor: DRIVE_EPIC_PREFERRED_CONDUCTOR,
|
|
1908
|
+
reason: "readiness is unknown",
|
|
1909
|
+
};
|
|
1910
|
+
const defaultLaunchSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
1911
|
+
function launchNowIso(ctx) {
|
|
1912
|
+
return new Date((ctx.deps.now ?? Date.now)()).toISOString();
|
|
1913
|
+
}
|
|
1914
|
+
/** BAPI-1621 — the tally reason code for a published generated plan. */
|
|
1915
|
+
export const PLAN_GENERATED_REASON_CODE = "plan_generated";
|
|
1916
|
+
/**
|
|
1917
|
+
* BAPI-1621 — the real launch's generation step, run only after discovery
|
|
1918
|
+
* returned `plan_not_found` with no `--plan-file`.
|
|
1919
|
+
*
|
|
1920
|
+
* It rebuilds from current stored ticket data (never the preview's copy),
|
|
1921
|
+
* publishes by one folder rename, and runs discovery again so the published plan
|
|
1922
|
+
* continues through the ordinary found-plan path. A live run, an ineligible
|
|
1923
|
+
* discovery, or any failure returns the original `plan_not_found` (with a fixed
|
|
1924
|
+
* reason when one applies), so today's attach and stop behavior is unchanged. A
|
|
1925
|
+
* successful rename ends generation's ownership: nothing later removes the folder.
|
|
1926
|
+
*/
|
|
1927
|
+
async function generateMissingPlanForLaunch(ctx, docsDir, discovery) {
|
|
1928
|
+
const { deps, epicKey } = ctx;
|
|
1929
|
+
if (deps.attemptPlanGeneration === undefined || deps.publishGeneratedPlan === undefined)
|
|
1930
|
+
return { discovery };
|
|
1931
|
+
if (!(await planGenerationAllowed(deps.discoveryFs, epicKey, discovery))) {
|
|
1932
|
+
return { discovery, reason: "discovery_blocked" };
|
|
1933
|
+
}
|
|
1934
|
+
deps.log(`${epicKey}: no plan found; checking epic children and building a deterministic plan…`);
|
|
1935
|
+
let attempt;
|
|
1936
|
+
try {
|
|
1937
|
+
attempt = await deps.attemptPlanGeneration(epicKey);
|
|
1938
|
+
}
|
|
1939
|
+
catch {
|
|
1940
|
+
return { discovery, reason: "children_unreadable" };
|
|
1941
|
+
}
|
|
1942
|
+
if (attempt.kind === "not_attempted")
|
|
1943
|
+
return { discovery };
|
|
1944
|
+
if (attempt.kind === "failed")
|
|
1945
|
+
return { discovery, reason: attempt.reason };
|
|
1946
|
+
if (!(await planGenerationAllowed(deps.discoveryFs, epicKey, discovery, attempt))) {
|
|
1947
|
+
return { discovery, reason: "discovery_blocked" };
|
|
1948
|
+
}
|
|
1949
|
+
let published;
|
|
1950
|
+
try {
|
|
1951
|
+
published = await deps.publishGeneratedPlan({
|
|
1952
|
+
epicKey,
|
|
1953
|
+
docsDir,
|
|
1954
|
+
dag: attempt.dag,
|
|
1955
|
+
summary: attempt.summary,
|
|
1956
|
+
access: attempt.access,
|
|
1957
|
+
});
|
|
1958
|
+
}
|
|
1959
|
+
catch {
|
|
1960
|
+
return { discovery, reason: "publish_failed" };
|
|
1961
|
+
}
|
|
1962
|
+
if (published.kind === "failed")
|
|
1963
|
+
return { discovery, reason: published.reason };
|
|
1964
|
+
if (published.kind === "collision")
|
|
1965
|
+
return { discovery: published.discovery };
|
|
1966
|
+
const relative = path.relative(docsDir, published.dagPath).split(path.sep).join("/");
|
|
1967
|
+
observeLaunch(ctx, PLAN_GENERATED_REASON_CODE, `plan: generated ${relative}`);
|
|
1968
|
+
deps.log(`${epicKey}: plan: generated ${published.dagPath}`);
|
|
1969
|
+
const after = await discoverEpicPlan(epicKey, docsDir, deps.discoveryFs);
|
|
1970
|
+
return after.status === "plan_not_found" ? { discovery: after, reason: "publish_failed" } : { discovery: after };
|
|
1971
|
+
}
|
|
1972
|
+
/**
|
|
1973
|
+
* Whether discovery's skipped entries allow generation. A DAG with no metadata
|
|
1974
|
+
* blocks only when it names the epic or one of its children, or can't be read.
|
|
1975
|
+
* Before the attempt only the epic key is known; after a generated attempt, every
|
|
1976
|
+
* child it accounts for (its nodes and the spikes it left out) is checked too.
|
|
1977
|
+
*/
|
|
1978
|
+
async function planGenerationAllowed(fs, epicKey, discovery, attempt) {
|
|
1979
|
+
const related = [epicKey];
|
|
1980
|
+
if (attempt !== undefined) {
|
|
1981
|
+
related.push(...attempt.dag.nodes.map((node) => node.ticket_key));
|
|
1982
|
+
related.push(...attempt.summary.excluded.map((entry) => entry.ticket_key));
|
|
1983
|
+
}
|
|
1984
|
+
return isPlanGenerationEligible(discovery, await unrelatedMissingMetaPaths(discovery, related, fs));
|
|
1985
|
+
}
|
|
1986
|
+
/** Record one bookkeeping observation for the launch report. */
|
|
1987
|
+
function observeLaunch(ctx, code, message) {
|
|
1988
|
+
ctx.launchObservations?.push({ code, message, at: launchNowIso(ctx) });
|
|
1989
|
+
}
|
|
1990
|
+
// ---------------------------------------------------------------------------
|
|
1991
|
+
// BAPI-1595 — fixed tally lines and stable reason codes
|
|
1992
|
+
// ---------------------------------------------------------------------------
|
|
1993
|
+
// Each constant sits beside the function that writes it, and a test imports it
|
|
1994
|
+
// rather than retyping the text. None carries a path, a credential, an email
|
|
1995
|
+
// address, a payload, or exception text.
|
|
1996
|
+
/** The launch could not reuse the preview's stored snapshot, so it asked nothing and went on. */
|
|
1997
|
+
export const SNAPSHOT_EXPIRED_WARNING = "readiness snapshot expired; server create and approve decide";
|
|
1998
|
+
export const SNAPSHOT_EXPIRED_REASON_CODE = "readiness_snapshot_expired";
|
|
1999
|
+
/** The pause before the one retry of the pre-mutation live-run read. */
|
|
2000
|
+
export const LIVE_RUN_RETRY_BACKOFF_MS = 1_500;
|
|
2001
|
+
export const LIVE_RUN_RETRY_REASON_CODE = "live_run_read_retried";
|
|
2002
|
+
export const LIVE_RUN_RETRY_MESSAGE = "live run read uncertain; retrying once";
|
|
2003
|
+
/** The live-run read stayed unknown after its retry: the idempotent create decides. */
|
|
2004
|
+
export const LIVE_RUN_UNKNOWN_WARNING = "live run: unknown, continuing; create is idempotent";
|
|
2005
|
+
export const LIVE_RUN_UNKNOWN_REASON_CODE = "live_run_unknown_continued";
|
|
2006
|
+
/** A mandatory diagnostic whose verdict or classification was not established. */
|
|
2007
|
+
export const MANDATORY_DIAGNOSTIC_UNKNOWN_WARNING = "mandatory diagnostic: unknown, continuing; server create and approve decide";
|
|
2008
|
+
export const MANDATORY_DIAGNOSTIC_UNKNOWN_REASON_CODE = "mandatory_diagnostic_unknown_continued";
|
|
2009
|
+
/** The escalation channel evidence was not established, so no "no channel" claim is made. */
|
|
2010
|
+
export const ESCALATION_CHANNEL_UNCERTAIN_WARNING = "escalation channel: unconfirmed, continuing; server create and approve decide";
|
|
2011
|
+
export const ESCALATION_CHANNEL_UNCERTAIN_REASON_CODE = "escalation_channel_unconfirmed_continued";
|
|
2012
|
+
/** Written once whenever the reachability line is left out of the output. */
|
|
2013
|
+
export const ESCALATION_LINE_SUPPRESSED_LINE = "escalation reachability line omitted: a no-channel condition is not established";
|
|
2014
|
+
export const ESCALATION_LINE_SUPPRESSED_REASON_CODE = "escalation_reachability_line_suppressed";
|
|
2015
|
+
/** One Bridge-only check skipped on a verified non-Bridge checkout. */
|
|
2016
|
+
export const BRIDGE_ONLY_SKIPS = {
|
|
2017
|
+
repositoryRoot: {
|
|
2018
|
+
id: "repository-root",
|
|
2019
|
+
reasonCode: "bridge_only_check_skipped_repository_root",
|
|
2020
|
+
line: "repository root check skipped: not a Bridge checkout",
|
|
2021
|
+
},
|
|
2022
|
+
executorBuild: {
|
|
2023
|
+
id: "executor-build",
|
|
2024
|
+
reasonCode: "bridge_only_check_skipped_executor_build",
|
|
2025
|
+
line: "build entrypoint check skipped: not a Bridge checkout",
|
|
2026
|
+
},
|
|
2027
|
+
planeDatabaseHead: {
|
|
2028
|
+
id: "plane-database-head",
|
|
2029
|
+
reasonCode: "bridge_only_check_skipped_plane_database_head",
|
|
2030
|
+
line: "plane database head check skipped: not a Bridge checkout",
|
|
2031
|
+
},
|
|
2032
|
+
workerDatabase: {
|
|
2033
|
+
id: "worker-database",
|
|
2034
|
+
reasonCode: "bridge_only_check_skipped_worker_database",
|
|
2035
|
+
line: "worker database check skipped: not a Bridge checkout",
|
|
2036
|
+
},
|
|
2037
|
+
};
|
|
2038
|
+
/** Write one tally observation and its warning line, once per (code, message) per launch. */
|
|
2039
|
+
function tallyOnce(ctx, code, message, printed = true) {
|
|
2040
|
+
const seen = ctx.launchObservations?.some((entry) => entry.code === code && entry.message === message);
|
|
2041
|
+
if (seen === true)
|
|
2042
|
+
return;
|
|
2043
|
+
if (printed)
|
|
2044
|
+
ctx.deps.errorLog(`${ctx.epicKey}: [warn] ${message}`);
|
|
2045
|
+
observeLaunch(ctx, code, message);
|
|
2046
|
+
}
|
|
2047
|
+
/** Record that a Bridge-only check was skipped, exactly once per launch. */
|
|
2048
|
+
function tallyBridgeOnlySkip(ctx, skip) {
|
|
2049
|
+
// Informational, not a warning: it goes to the launch report's observations, not the terminal.
|
|
2050
|
+
tallyOnce(ctx, skip.reasonCode, skip.line, false);
|
|
2051
|
+
}
|
|
2052
|
+
/**
|
|
2053
|
+
* Whether the launch may skip Bridge-only checks: only a verified, carried
|
|
2054
|
+
* `isBridge === false`. An absent identity, a Bridge, and a partial checkout all
|
|
2055
|
+
* keep the checks.
|
|
2056
|
+
*/
|
|
2057
|
+
function isConfirmedNonBridge(ctx) {
|
|
2058
|
+
return ctx.previewRepository?.isBridge === false;
|
|
2059
|
+
}
|
|
2060
|
+
/**
|
|
2061
|
+
* The full readiness report a real launch holds: none. The preview acquires it and
|
|
2062
|
+
* the launch reads only the narrow, validated snapshot. A function rather than a
|
|
2063
|
+
* literal so the paths that still accept a report keep their signature and TypeScript
|
|
2064
|
+
* does not narrow the null away.
|
|
2065
|
+
*/
|
|
2066
|
+
function launchFullReadiness() {
|
|
2067
|
+
return null;
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2070
|
+
* BAPI-1595 — the mandatory-diagnostic decision for a launch that holds only the
|
|
2071
|
+
* preview's snapshot. A diagnostic recorded as `failed` was explicitly mandatory and
|
|
2072
|
+
* applicable when it was projected, so it keeps today's refusal. One recorded as
|
|
2073
|
+
* `unknown` (an unknown verdict, or severity / applicability not established)
|
|
2074
|
+
* warns under a stable reason code and the launch continues. No readiness read is
|
|
2075
|
+
* ever made here.
|
|
2076
|
+
*/
|
|
2077
|
+
function classifySnapshotDiagnostics(ctx) {
|
|
2078
|
+
const readiness = ctx.launchSnapshot?.context.readiness;
|
|
2079
|
+
if (readiness === undefined || readiness.state !== "known")
|
|
2080
|
+
return { kind: "green" };
|
|
2081
|
+
const diagnostics = readiness.value.mandatory_diagnostics;
|
|
2082
|
+
if (diagnostics.some((entry) => entry.verdict === "failed")) {
|
|
2083
|
+
return {
|
|
2084
|
+
kind: "operator_blocked",
|
|
2085
|
+
id: MANDATORY_DIAGNOSTIC_FAILED_ID,
|
|
2086
|
+
describe: "Additional readiness diagnostics",
|
|
2087
|
+
remedy: MANDATORY_DIAGNOSTIC_FAILED_REMEDY,
|
|
2088
|
+
};
|
|
2089
|
+
}
|
|
2090
|
+
if (diagnostics.some((entry) => entry.verdict === "unknown")) {
|
|
2091
|
+
tallyOnce(ctx, MANDATORY_DIAGNOSTIC_UNKNOWN_REASON_CODE, MANDATORY_DIAGNOSTIC_UNKNOWN_WARNING);
|
|
2092
|
+
}
|
|
2093
|
+
return { kind: "green" };
|
|
2094
|
+
}
|
|
2095
|
+
/**
|
|
2096
|
+
* Resolve the preview's stored snapshot for THIS launch (BAPI-1595). Never throws,
|
|
2097
|
+
* never reads the readiness report, and never refuses.
|
|
2098
|
+
*
|
|
2099
|
+
* The identity is recomputed locally here only to BIND the snapshot; the preview's
|
|
2100
|
+
* verified classification (carried in the snapshot) stays the applicability
|
|
2101
|
+
* authority. An unavailable or mismatched local identity makes the snapshot
|
|
2102
|
+
* unusable, and an unusable snapshot is never read as "not a Bridge checkout".
|
|
2103
|
+
*/
|
|
2104
|
+
async function resolveLaunchSnapshot(ctx) {
|
|
2105
|
+
const { deps } = ctx;
|
|
2106
|
+
let local = null;
|
|
2107
|
+
try {
|
|
2108
|
+
local = await deps.inspectRepositoryIdentity();
|
|
2109
|
+
}
|
|
2110
|
+
catch {
|
|
2111
|
+
local = null;
|
|
2112
|
+
}
|
|
2113
|
+
let baseBranch = null;
|
|
2114
|
+
try {
|
|
2115
|
+
baseBranch = (await deps.readScopeBaseBranch?.(ctx.access)) ?? null;
|
|
2116
|
+
}
|
|
2117
|
+
catch {
|
|
2118
|
+
baseBranch = null;
|
|
2119
|
+
}
|
|
2120
|
+
const binding = {
|
|
2121
|
+
epicKey: ctx.epicKey,
|
|
2122
|
+
baseBranch,
|
|
2123
|
+
targetBaseUrl: ctx.access.baseUrl,
|
|
2124
|
+
repository: local !== null ? { repoName: ctx.access.repoName, isBridge: local.isBridge } : null,
|
|
2125
|
+
now: new Date((deps.now ?? Date.now)()),
|
|
2126
|
+
};
|
|
2127
|
+
let result;
|
|
2128
|
+
try {
|
|
2129
|
+
result = await (deps.readLaunchContext ?? ((b) => readEpicLaunchContext(b)))(binding);
|
|
2130
|
+
}
|
|
2131
|
+
catch {
|
|
2132
|
+
result = { kind: "unusable", reason: "unreadable" };
|
|
2133
|
+
}
|
|
2134
|
+
if (result.kind === "usable" && local !== null) {
|
|
2135
|
+
return { snapshot: result.value, previewRepository: local };
|
|
2136
|
+
}
|
|
2137
|
+
tallyOnce(ctx, SNAPSHOT_EXPIRED_REASON_CODE, SNAPSHOT_EXPIRED_WARNING);
|
|
2138
|
+
return { snapshot: null };
|
|
2139
|
+
}
|
|
2140
|
+
/**
|
|
2141
|
+
* The launch's ONE pre-mutation live-run observation (BAPI-1595).
|
|
2142
|
+
*
|
|
2143
|
+
* Read once; an `unknown` answer spends ONE retry (its own budget, separate from
|
|
2144
|
+
* readiness), and a second `unknown` warns and continues — a create is idempotent
|
|
2145
|
+
* (`POST /runs` returns the existing run) and the unique index allows one active
|
|
2146
|
+
* run per epic. The result is memoized on the launch's shared holder, so every
|
|
2147
|
+
* pre-create consumer reads the same value instead of asking again. This is
|
|
2148
|
+
* never evidence of what a later create or approve committed; post-mutation
|
|
2149
|
+
* reconciliation reads for itself.
|
|
2150
|
+
*/
|
|
2151
|
+
async function acquireObservedLive(ctx) {
|
|
2152
|
+
const holder = ctx.liveObservation;
|
|
2153
|
+
if (holder?.pending !== undefined)
|
|
2154
|
+
return holder.pending;
|
|
2155
|
+
const acquire = async () => {
|
|
2156
|
+
let live = await ctx.deps.readLiveEpicRun(ctx.access, ctx.epicKey);
|
|
2157
|
+
if (live.kind !== "unknown")
|
|
2158
|
+
return live;
|
|
2159
|
+
observeLaunch(ctx, LIVE_RUN_RETRY_REASON_CODE, LIVE_RUN_RETRY_MESSAGE);
|
|
2160
|
+
await (ctx.deps.launchSleep ?? defaultLaunchSleep)(LIVE_RUN_RETRY_BACKOFF_MS);
|
|
2161
|
+
live = await ctx.deps.readLiveEpicRun(ctx.access, ctx.epicKey);
|
|
2162
|
+
if (live.kind === "unknown")
|
|
2163
|
+
tallyOnce(ctx, LIVE_RUN_UNKNOWN_REASON_CODE, LIVE_RUN_UNKNOWN_WARNING);
|
|
2164
|
+
return live;
|
|
2165
|
+
};
|
|
2166
|
+
const pending = acquire();
|
|
2167
|
+
if (holder !== undefined)
|
|
2168
|
+
holder.pending = pending;
|
|
2169
|
+
return pending;
|
|
2170
|
+
}
|
|
2171
|
+
/**
|
|
2172
|
+
* Print the launch report once per invocation. Setup's observations follow
|
|
2173
|
+
* drive's own, in order, with exact duplicates dropped.
|
|
2174
|
+
*/
|
|
2175
|
+
function reportLaunchOutcome(ctx, outcome, facts) {
|
|
2176
|
+
const state = ctx.launchReportState;
|
|
2177
|
+
if (state === undefined || state.reported)
|
|
2178
|
+
return;
|
|
2179
|
+
state.reported = true;
|
|
2180
|
+
const at = launchNowIso(ctx);
|
|
2181
|
+
const observations = [];
|
|
2182
|
+
const seen = new Set();
|
|
2183
|
+
for (const entry of [...(ctx.launchObservations ?? []), ...(facts.observations ?? []).map((o) => ({ ...o, at }))]) {
|
|
2184
|
+
const key = `${entry.code}\u0000${entry.message}`;
|
|
2185
|
+
if (seen.has(key))
|
|
2186
|
+
continue;
|
|
2187
|
+
seen.add(key);
|
|
2188
|
+
observations.push(entry);
|
|
2189
|
+
}
|
|
2190
|
+
const report = {
|
|
2191
|
+
launch_outcome: outcome,
|
|
2192
|
+
epic_key: ctx.epicKey,
|
|
2193
|
+
epic_run_id: facts.epicRunId ?? null,
|
|
2194
|
+
run_status: facts.runStatus ?? null,
|
|
2195
|
+
invoked_at: ctx.invokedAt ?? at,
|
|
2196
|
+
first_claimed_job_at: "pending",
|
|
2197
|
+
observations,
|
|
2198
|
+
};
|
|
2199
|
+
ctx.deps.reportLaunch?.(report);
|
|
2200
|
+
}
|
|
2201
|
+
/** A refusal that also settles the launch outcome. */
|
|
2202
|
+
function refuseLaunch(ctx, lines) {
|
|
2203
|
+
reportLaunchOutcome(ctx, "refused", {});
|
|
2204
|
+
return refuse(ctx.deps, lines);
|
|
2205
|
+
}
|
|
2206
|
+
/**
|
|
2207
|
+
* Watch a planning run for activation after an uncertain approve. Reads only —
|
|
2208
|
+
* it never approves. A failed read keeps the known id and tries again. Bounded
|
|
2209
|
+
* by {@link ACTIVATION_ATTACH_WINDOW_MS}; every pause is capped to the time left.
|
|
2210
|
+
*/
|
|
2211
|
+
async function awaitRunActivation(ctx, epicRunId) {
|
|
2212
|
+
const now = ctx.deps.launchClock ?? (() => performance.now());
|
|
2213
|
+
const sleep = ctx.deps.launchSleep ?? defaultLaunchSleep;
|
|
2214
|
+
const deadline = now() + ACTIVATION_ATTACH_WINDOW_MS;
|
|
2215
|
+
for (;;) {
|
|
2216
|
+
const remaining = deadline - now();
|
|
2217
|
+
if (remaining <= 0)
|
|
2218
|
+
return { kind: "exhausted" };
|
|
2219
|
+
await sleep(Math.min(ACTIVATION_POLL_INTERVAL_MS, remaining));
|
|
2220
|
+
let status;
|
|
2221
|
+
try {
|
|
2222
|
+
status = (await ctx.deps.readRunState(ctx.access, epicRunId)).status;
|
|
2223
|
+
}
|
|
2224
|
+
catch {
|
|
2225
|
+
continue;
|
|
2226
|
+
}
|
|
2227
|
+
if (status === "active")
|
|
2228
|
+
return { kind: "active" };
|
|
2229
|
+
if (status !== "planning")
|
|
2230
|
+
return { kind: "changed", status };
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
/**
|
|
2234
|
+
* Settle what setup established. `active` continues to the caller's ordinary
|
|
2235
|
+
* lane or executor dispatch. A planning run after an uncertain approve is watched
|
|
2236
|
+
* until it activates (then dispatched the same way) or the window ends. Every
|
|
2237
|
+
* other outcome is reported here and handled: nothing claims jobs for it.
|
|
2238
|
+
*/
|
|
2239
|
+
async function settleSetupLaunch(ctx, setup) {
|
|
2240
|
+
const { deps, epicKey } = ctx;
|
|
2241
|
+
const facts = {
|
|
2242
|
+
...(setup.epicRunId !== undefined ? { epicRunId: setup.epicRunId } : {}),
|
|
2243
|
+
...(setup.runStatus !== undefined ? { runStatus: setup.runStatus } : {}),
|
|
2244
|
+
...(setup.observations !== undefined ? { observations: setup.observations } : {}),
|
|
2245
|
+
};
|
|
2246
|
+
if (setup.exitCode !== 0) {
|
|
2247
|
+
reportLaunchOutcome(ctx, setup.launchOutcome === "terminal" ? "terminal" : "refused", facts);
|
|
2248
|
+
return setup;
|
|
2249
|
+
}
|
|
2250
|
+
if (setup.launchOutcome === "not_confirmed") {
|
|
2251
|
+
reportLaunchOutcome(ctx, "not_confirmed", facts);
|
|
2252
|
+
return { ...setup, launchHandled: true };
|
|
2253
|
+
}
|
|
2254
|
+
if (setup.launchOutcome === "pending_activation" && setup.epicRunId !== undefined) {
|
|
2255
|
+
if (setup.runStatus !== "planning") {
|
|
2256
|
+
deps.log(`${epicKey}: run ${setup.epicRunId} is ${setup.runStatus ?? "not active"}; attached without changing it.`);
|
|
2257
|
+
reportLaunchOutcome(ctx, "pending_activation", facts);
|
|
2258
|
+
return { ...setup, launchHandled: true };
|
|
2259
|
+
}
|
|
2260
|
+
deps.errorLog(`${epicKey}: run ${setup.epicRunId}: ${RUN_WAITING_FOR_APPROVAL_PHRASE}. Watching for activation ` +
|
|
2261
|
+
"for up to 10 minutes; nothing is approved from here.");
|
|
2262
|
+
const activation = await awaitRunActivation(ctx, setup.epicRunId);
|
|
2263
|
+
if (activation.kind === "active") {
|
|
2264
|
+
observeLaunch(ctx, "launch_outcome_reread", "approve re-read: run activated while attached");
|
|
2265
|
+
reportLaunchOutcome(ctx, "active", { ...facts, runStatus: "active" });
|
|
2266
|
+
return { ...setup, launchOutcome: "active", runStatus: "active" };
|
|
2267
|
+
}
|
|
2268
|
+
if (activation.kind === "changed") {
|
|
2269
|
+
const terminal = isTerminalEpicRunStatus(activation.status);
|
|
2270
|
+
deps.log(`${epicKey}: run ${setup.epicRunId} is ${activation.status}; attached without changing it.`);
|
|
2271
|
+
reportLaunchOutcome(ctx, terminal ? "terminal" : "pending_activation", { ...facts, runStatus: activation.status });
|
|
2272
|
+
return { ...setup, exitCode: terminal ? 1 : 0, launchHandled: true };
|
|
2273
|
+
}
|
|
2274
|
+
deps.errorLog(`${epicKey}: [warn] ${APPROVAL_NOT_CONFIRMED_WARNING}. Re-run setup with: ` +
|
|
2275
|
+
launchReconnectCommand(epicKey, ctx.access));
|
|
2276
|
+
reportLaunchOutcome(ctx, "pending_activation", facts);
|
|
2277
|
+
return { ...setup, launchHandled: true };
|
|
2278
|
+
}
|
|
2279
|
+
// Never inferred from exit 0: only a reported `active` status counts.
|
|
2280
|
+
reportLaunchOutcome(ctx, setup.launchOutcome === "active" || setup.runStatus === "active" ? "active" : "pending_activation", facts);
|
|
2281
|
+
return setup;
|
|
2282
|
+
}
|
|
1739
2283
|
/** Resolve policy intent once for the setup delegation, after a fresh run read. */
|
|
1740
2284
|
/** Narrow an effective-policy channel label to the closed identity set. */
|
|
1741
2285
|
function channelIdentityOf(label) {
|
|
1742
2286
|
return label === "configured webhook" || label === "account email" ? label : "unavailable";
|
|
1743
2287
|
}
|
|
1744
2288
|
async function prepareSetupSelection(ctx, coldStart = false, observedLive) {
|
|
1745
|
-
|
|
1746
|
-
|
|
2289
|
+
// BAPI-1595 — one observation per launch, reused here instead of a fresh read. An
|
|
2290
|
+
// unknown one (already retried and warned about) is treated as "no run seen":
|
|
2291
|
+
// `POST /runs` is idempotent, so it returns the existing run if there is one.
|
|
2292
|
+
const observed = coldStart ? { kind: "none" } : observedLive ?? await acquireObservedLive(ctx);
|
|
2293
|
+
if (observed.kind === "conflict")
|
|
1747
2294
|
return { ok: false, reasonId: "live-run-ambiguous" };
|
|
1748
|
-
|
|
1749
|
-
return { ok: false, reasonId: "live-run-unknown" };
|
|
2295
|
+
const live = observed.kind === "unknown" ? { kind: "none" } : observed;
|
|
1750
2296
|
const explicit = ctx.options.policyFile;
|
|
1751
2297
|
const selectedPath = explicit ?? (live.kind === "none" ? ctx.profile?.policyRef?.path : undefined);
|
|
1752
2298
|
let pinnedPolicy;
|
|
@@ -1929,14 +2475,118 @@ async function recordSkippedChildrenBestEffort(ctx, epicRunId, skipped) {
|
|
|
1929
2475
|
deps.errorLog("The run was created, but the skipped-child record could not be saved.");
|
|
1930
2476
|
}
|
|
1931
2477
|
}
|
|
2478
|
+
// ---------------------------------------------------------------------------
|
|
2479
|
+
// BAPI-1581 — parallel limit: local preflight and capacity reporting
|
|
2480
|
+
// ---------------------------------------------------------------------------
|
|
2481
|
+
/**
|
|
2482
|
+
* The refusal for a supplied `--parallel` judged against an EXPLICIT policy
|
|
2483
|
+
* file, or `null`. Read-only and local: it reads the one file the operator named,
|
|
2484
|
+
* and an unreadable file is left to the existing policy-read handling.
|
|
2485
|
+
*/
|
|
2486
|
+
async function explicitPolicyParallelRefusal(deps, options) {
|
|
2487
|
+
if (options.parallel === undefined || options.policyFile === undefined)
|
|
2488
|
+
return null;
|
|
2489
|
+
const read = await readSetupEpicPolicyFile(options.policyFile, (filePath) => deps.readPolicyFile(filePath));
|
|
2490
|
+
if (!read.ok)
|
|
2491
|
+
return null;
|
|
2492
|
+
const verdict = evaluateParallelPolicyPreflight({
|
|
2493
|
+
parallel: options.parallel,
|
|
2494
|
+
attended: options.attended === true,
|
|
2495
|
+
intoBase: options.intoBase === true,
|
|
2496
|
+
filePolicy: read.policy,
|
|
2497
|
+
// BAPI-1595 — the plan is not read yet, so whether create would select an epic
|
|
2498
|
+
// branch (and fill a posture-silent file as unattended) is not known. The
|
|
2499
|
+
// creation routes judge that case with the branch selection in hand.
|
|
2500
|
+
postureFillDeferred: true,
|
|
2501
|
+
});
|
|
2502
|
+
return verdict.ok ? null : verdict.message.replace(/^setup-epic REFUSED/, `${options.epicKey}: REFUSED`);
|
|
2503
|
+
}
|
|
2504
|
+
/**
|
|
2505
|
+
* The refusal for a supplied `--parallel` judged against the CANDIDATE creation
|
|
2506
|
+
* policy (pinned file/profile policy, or the default composition for this plan),
|
|
2507
|
+
* or `null`. Called only on routes that are about to start a plane and create a
|
|
2508
|
+
* run, so it never judges an existing run's stored policy.
|
|
2509
|
+
*/
|
|
2510
|
+
async function parallelCreationCandidateRefusal(ctx) {
|
|
2511
|
+
const parallel = ctx.options.parallel;
|
|
2512
|
+
if (parallel === undefined)
|
|
2513
|
+
return null;
|
|
2514
|
+
const planPath = ctx.options.planFile;
|
|
2515
|
+
if (planPath === undefined)
|
|
2516
|
+
return null;
|
|
2517
|
+
const children = await readPlanChildren(ctx.deps, planPath);
|
|
2518
|
+
if (children === null)
|
|
2519
|
+
return null;
|
|
2520
|
+
const pinned = ctx.handoff ? getPinnedEpicLaunchPolicy(ctx.handoff.selection) : undefined;
|
|
2521
|
+
const declaresBranch = pinned !== undefined && resolveDeclaredRunBaseBranch(pinned) !== undefined;
|
|
2522
|
+
const verdict = evaluateParallelPolicyPreflight({
|
|
2523
|
+
parallel,
|
|
2524
|
+
attended: ctx.options.attended === true,
|
|
2525
|
+
intoBase: ctx.options.intoBase === true,
|
|
2526
|
+
...(pinned !== undefined ? { filePolicy: pinned } : {}),
|
|
2527
|
+
featureBranch: resolveFeatureBranchSelection({
|
|
2528
|
+
epicKey: ctx.epicKey,
|
|
2529
|
+
featureBranch: ctx.options.featureBranch,
|
|
2530
|
+
intoBase: ctx.options.intoBase === true,
|
|
2531
|
+
}, children.keys.length, declaresBranch),
|
|
2532
|
+
});
|
|
2533
|
+
return verdict.ok ? null : verdict.message.replace(/^setup-epic REFUSED/, "REFUSED");
|
|
2534
|
+
}
|
|
2535
|
+
/** The durable-profile capacity line: the stored limit, and where concurrency is configured. */
|
|
2536
|
+
function durableCapacityLine(storedLimit) {
|
|
2537
|
+
return (`The run's parallel limit is ${storedLimit}. Concurrency of the durable executor is configured on its ` +
|
|
2538
|
+
"host; this command starts no executor and cannot change it.");
|
|
2539
|
+
}
|
|
2540
|
+
/** Executor lanes an attached plane's manifest records: `executor-N` members only, no liveness filter. */
|
|
2541
|
+
function attachedPlaneLaneCount(manifest) {
|
|
2542
|
+
return manifest.members.filter((member) => isPlaneExecutorLaneMember(member.name)).length;
|
|
2543
|
+
}
|
|
2544
|
+
/**
|
|
2545
|
+
* Warn, once, when the plane's known lane count is below the run's stored
|
|
2546
|
+
* parallel limit. Never an action: nothing is stopped, parked, refused, or resized.
|
|
2547
|
+
*/
|
|
2548
|
+
function reportPlaneCapacity(ctx, lanes, storedLimit, posture) {
|
|
2549
|
+
if (lanes === undefined || storedLimit === undefined || posture !== "unattended")
|
|
2550
|
+
return;
|
|
2551
|
+
if (lanes >= storedLimit)
|
|
2552
|
+
return;
|
|
2553
|
+
ctx.deps.errorLog(`${ctx.epicKey}: [warn] this plane has ${lanes} executor lane${lanes === 1 ? "" : "s"}, but the run's ` +
|
|
2554
|
+
`parallel limit is ${storedLimit}. Each lane serves one job at a time, so capacity is reduced to ` +
|
|
2555
|
+
`${lanes} job${lanes === 1 ? "" : "s"} at once. Nothing was stopped. To use the full limit, wind the ` +
|
|
2556
|
+
`plane down after the run or between runs, then relaunch with \`--parallel ${storedLimit}\`.`);
|
|
2557
|
+
}
|
|
2558
|
+
/**
|
|
2559
|
+
* BAPI-1593 — delegate to setup-epic, then settle what it established before
|
|
2560
|
+
* anything claims jobs. A `launchHandled` result was fully reported here, and
|
|
2561
|
+
* its caller returns its exit code without requesting lanes or an executor.
|
|
2562
|
+
*/
|
|
1932
2563
|
async function runSelectedSetupEpic(ctx) {
|
|
1933
|
-
|
|
2564
|
+
return settleSetupLaunch(ctx, await runSelectedSetupEpicWorkflow(ctx));
|
|
2565
|
+
}
|
|
2566
|
+
async function runSelectedSetupEpicWorkflow(ctx) {
|
|
2567
|
+
const selected = ctx.handoff
|
|
1934
2568
|
? { ok: true, handoff: ctx.handoff }
|
|
1935
2569
|
: await prepareSetupSelection(ctx);
|
|
1936
|
-
if (!
|
|
1937
|
-
ctx.deps.errorLog(`${ctx.epicKey}: REFUSED (${
|
|
2570
|
+
if (!selected.ok) {
|
|
2571
|
+
ctx.deps.errorLog(`${ctx.epicKey}: REFUSED (${selected.reasonId}) — the selected run or policy could not be verified.`);
|
|
1938
2572
|
return { exitCode: 1 };
|
|
1939
2573
|
}
|
|
2574
|
+
// BAPI-1595 — readiness is acquired by the PREVIEW and never by a launch. The
|
|
2575
|
+
// hand-off says so explicitly (an in-process contract, not an argv flag), and
|
|
2576
|
+
// carries the narrow evidence the stored snapshot held, or `null` when none was
|
|
2577
|
+
// usable: setup-epic then reads nothing, every evaluator takes its warn path, and
|
|
2578
|
+
// the server's create and approve decide.
|
|
2579
|
+
const snapshotEvidence = ctx.launchSnapshot !== undefined && ctx.launchSnapshot !== null
|
|
2580
|
+
? readinessSnapshotFromLaunchContext(ctx.launchSnapshot.context)
|
|
2581
|
+
: null;
|
|
2582
|
+
const prepared = {
|
|
2583
|
+
ok: true,
|
|
2584
|
+
handoff: {
|
|
2585
|
+
...selected.handoff,
|
|
2586
|
+
readinessDisposition: "preview_handoff",
|
|
2587
|
+
launchEvidence: snapshotEvidence,
|
|
2588
|
+
},
|
|
2589
|
+
};
|
|
1940
2590
|
const { deps, options, epicKey } = ctx;
|
|
1941
2591
|
// BAPI-1510 — fresh classification immediately before setup. Preview verdicts are
|
|
1942
2592
|
// never consumed: each create starts from the ORIGINAL plan and re-checks.
|
|
@@ -2015,7 +2665,14 @@ function isUnattendedLaunch(options) {
|
|
|
2015
2665
|
return options.attended !== true && options.intoBase !== true;
|
|
2016
2666
|
}
|
|
2017
2667
|
/** The launch row ids a launch can be refused on, without their namespace. */
|
|
2018
|
-
|
|
2668
|
+
/**
|
|
2669
|
+
* BAPI-1585 — the two pre-create refusal codes the server added after the
|
|
2670
|
+
* generator's regex was written. The generator is read-only for this ticket, so
|
|
2671
|
+
* they are spelled once in `conductor/launch-plan.ts` (which also renders them)
|
|
2672
|
+
* and pinned against `pre_create_refusal.py` in
|
|
2673
|
+
* `readiness-prerequisites-contract.test.ts`.
|
|
2674
|
+
*/
|
|
2675
|
+
const LAUNCH_REFUSAL_IDS = ["merge-credential-capability", "worktree-preparation", ...Object.values(READINESS_PRE_CREATE_CODES), ...Object.values(LAUNCH_PRE_CREATE_CODES)];
|
|
2019
2676
|
/**
|
|
2020
2677
|
* The credential evidence. Probes ONLY a locally owned executor's credential in
|
|
2021
2678
|
* `local` / `machine_token` mode, against the server's explicit `owner/name`;
|
|
@@ -2114,9 +2771,12 @@ async function launchCredentialForExecutor(ctx, readiness) {
|
|
|
2114
2771
|
if (box !== undefined && box.resolved !== undefined) {
|
|
2115
2772
|
return box.resolved?.kind === "local" ? box.resolved : null;
|
|
2116
2773
|
}
|
|
2117
|
-
|
|
2774
|
+
// BAPI-1595 — the mode and repository come from the full report when one is held,
|
|
2775
|
+
// otherwise from the preview's validated snapshot. No usable source: no credential.
|
|
2776
|
+
const source = readiness ?? credentialFactsOfSnapshot(ctx);
|
|
2777
|
+
if (source === null || source.resolved_merge_execution_mode !== "local")
|
|
2118
2778
|
return null;
|
|
2119
|
-
const repository =
|
|
2779
|
+
const repository = source.provider_repository;
|
|
2120
2780
|
if (typeof repository !== "string" || !isProviderRepositoryIdentity(repository))
|
|
2121
2781
|
return null;
|
|
2122
2782
|
const resolved = await resolveLaunchCredentialOnce(ctx.deps, "local", repository, box);
|
|
@@ -2156,6 +2816,50 @@ async function collectLaunchEvidence(deps, readiness, topology, box) {
|
|
|
2156
2816
|
worktree: await collectWorktreeEvidence(deps, topology),
|
|
2157
2817
|
};
|
|
2158
2818
|
}
|
|
2819
|
+
/**
|
|
2820
|
+
* BAPI-1595 — the two facts the merge-credential probe reads, taken from the
|
|
2821
|
+
* preview's validated snapshot. `null` when no usable snapshot (or no known facts)
|
|
2822
|
+
* is held. Never a rebuilt readiness report: only these two members exist.
|
|
2823
|
+
*/
|
|
2824
|
+
function credentialFactsOfSnapshot(ctx) {
|
|
2825
|
+
const readiness = ctx.launchSnapshot?.context.readiness;
|
|
2826
|
+
if (readiness === undefined || readiness.state !== "known")
|
|
2827
|
+
return null;
|
|
2828
|
+
const mode = readiness.value.resolved_merge_execution_mode;
|
|
2829
|
+
return {
|
|
2830
|
+
resolved_merge_execution_mode: mode === "local" || mode === "machine_token" || mode === "github_actions" ? mode : null,
|
|
2831
|
+
provider_repository: readiness.value.provider_repository,
|
|
2832
|
+
};
|
|
2833
|
+
}
|
|
2834
|
+
/**
|
|
2835
|
+
* BAPI-1595 — the local launch-evidence gate for a launch that holds the preview's
|
|
2836
|
+
* snapshot but no full readiness report. It keeps the AC-3 local refusals — a merge
|
|
2837
|
+
* credential that is PROVEN missing, invalid, or without access, and a worktree
|
|
2838
|
+
* exclude proven unwritable — and nothing else. With no usable snapshot there is
|
|
2839
|
+
* nothing to probe against, and the server's create and approve decide.
|
|
2840
|
+
*/
|
|
2841
|
+
async function snapshotLaunchEvidenceGate(ctx, topology, outcome) {
|
|
2842
|
+
const facts = credentialFactsOfSnapshot(ctx);
|
|
2843
|
+
if (facts === null)
|
|
2844
|
+
return null;
|
|
2845
|
+
const { deps, epicKey } = ctx;
|
|
2846
|
+
const evidence = {
|
|
2847
|
+
credential: await collectCredentialEvidence(deps, facts, topology, ctx.launchCredential),
|
|
2848
|
+
worktree: await collectWorktreeEvidence(deps, topology),
|
|
2849
|
+
};
|
|
2850
|
+
const blocker = firstLaunchEvidenceBlocker(buildLaunchEvidenceChecks({ attended: false, intoBase: false }, evidence));
|
|
2851
|
+
if (blocker === null)
|
|
2852
|
+
return null;
|
|
2853
|
+
const describe = blocker.id === MERGE_CREDENTIAL_ROW
|
|
2854
|
+
? "a merge credential that has push and can read pull requests"
|
|
2855
|
+
: "an executor clone whose shared git exclude can be prepared";
|
|
2856
|
+
const remedy = `${blocker.detail ?? blocker.label}. ${blocker.remediation} See ${CONSUMER_GUIDE_POINTER}.`;
|
|
2857
|
+
return refuse(deps, [
|
|
2858
|
+
`${epicKey}: REFUSED (${blocker.id.slice(blocker.id.indexOf(".") + 1)}) — the launch still needs ${describe}.`,
|
|
2859
|
+
remedy,
|
|
2860
|
+
outcome,
|
|
2861
|
+
]);
|
|
2862
|
+
}
|
|
2159
2863
|
/**
|
|
2160
2864
|
* The launch capability gate (BAPI-1452). Runs after readiness and executor
|
|
2161
2865
|
* topology are resolved and BEFORE the run is created, dispatched, or given an
|
|
@@ -2169,8 +2873,12 @@ async function launchCapabilityGate(ctx, readiness, topology, outcome = "Nothing
|
|
|
2169
2873
|
const { deps, epicKey, options } = ctx;
|
|
2170
2874
|
if (!isUnattendedLaunch(options))
|
|
2171
2875
|
return null;
|
|
2876
|
+
// BAPI-1593 — no report, no rows: the server's create and approve enforce what
|
|
2877
|
+
// these rows mirror. BAPI-1595 — the local PROVEN refusals (merge credential,
|
|
2878
|
+
// worktree) still run from the preview's snapshot when the launch holds one.
|
|
2879
|
+
if (readiness === null)
|
|
2880
|
+
return await snapshotLaunchEvidenceGate(ctx, topology, outcome);
|
|
2172
2881
|
const evidence = await collectLaunchEvidence(deps, readiness, topology, ctx.launchCredential);
|
|
2173
|
-
(deps.launchReadinessLog ?? deps.errorLog)(formatLaunchReadinessSummary(buildLaunchReadinessChecks(readiness, { launchEvidence: evidence }), { all: ctx.options.all, isProduction: readiness.is_production, prerequisites: readiness.prerequisites }).join("\n"));
|
|
2174
2882
|
const classification = classifyV2Readiness(readiness, { attended: false, intoBase: false, effectivePolicy: ctx.handoff?.selection }, evidence);
|
|
2175
2883
|
if (classification.kind !== "operator_blocked" || !LAUNCH_REFUSAL_IDS.includes(classification.id)) {
|
|
2176
2884
|
return null;
|
|
@@ -2210,6 +2918,8 @@ async function previewLaunchCapability(ctx, readiness, topology) {
|
|
|
2210
2918
|
return { checks, refusal: null };
|
|
2211
2919
|
}
|
|
2212
2920
|
function durableActorAdmissionDenied(readiness) {
|
|
2921
|
+
if (readiness === null)
|
|
2922
|
+
return false;
|
|
2213
2923
|
const evidence = readiness.admission_evidence;
|
|
2214
2924
|
return evidence?.schema_version === 1 &&
|
|
2215
2925
|
evidence.records.some((record) => record.predicate === "durable_actor" && record.verdict === "denied");
|
|
@@ -2247,7 +2957,18 @@ const LAUNCHED_PLANE_LEFT_RUNNING = [
|
|
|
2247
2957
|
* rebuilt from the manifest, sent as a query parameter, and never rendered.
|
|
2248
2958
|
*/
|
|
2249
2959
|
async function checkPlaneAdmission(ctx, readiness, manifest) {
|
|
2250
|
-
|
|
2960
|
+
// BAPI-1593 — an unknown report proves no bring-up fact; the plane's own
|
|
2961
|
+
// reconciler is still confirmed below, from its own read. BAPI-1595 — only a
|
|
2962
|
+
// PROVEN-bad fact refuses (a second reconciler, a database behind head, a missing
|
|
2963
|
+
// worker). The facts come from the full report when one is held, otherwise from
|
|
2964
|
+
// the preview's validated snapshot; unreadable or unreported ones are unknown.
|
|
2965
|
+
const snapshotReadiness = ctx.launchSnapshot?.context.readiness;
|
|
2966
|
+
const bringUpFacts = readiness !== null
|
|
2967
|
+
? (readiness.bring_up ?? null)
|
|
2968
|
+
: snapshotReadiness !== undefined && snapshotReadiness.state === "known"
|
|
2969
|
+
? snapshotReadiness.value.bring_up
|
|
2970
|
+
: null;
|
|
2971
|
+
const bringUpRefusal = firstProvenBringUpRefusal(bringUpFacts);
|
|
2251
2972
|
if (bringUpRefusal !== null) {
|
|
2252
2973
|
return [
|
|
2253
2974
|
`${ctx.epicKey}: REFUSED (${bringUpRefusal}) — ${BRING_UP_REFUSAL_MESSAGES[bringUpRefusal]}`,
|
|
@@ -2375,7 +3096,12 @@ function assessPlaneFreshness(reports, sleep, mode, allowStalePlane,
|
|
|
2375
3096
|
* remedy, which never advises `plane down` for a run that is not finished.
|
|
2376
3097
|
* Absent keeps `PLANE_SNAPSHOT_STALE_REMEDY` byte for byte.
|
|
2377
3098
|
*/
|
|
2378
|
-
boundRun,
|
|
3099
|
+
boundRun,
|
|
3100
|
+
/**
|
|
3101
|
+
* A create preview only: the plane server's other live runs (BAPI-1651).
|
|
3102
|
+
* The stale refusal becomes a cleanup warning only when this is `none`.
|
|
3103
|
+
*/
|
|
3104
|
+
cleanupPreview = null) {
|
|
2379
3105
|
const rows = [];
|
|
2380
3106
|
const blockers = [];
|
|
2381
3107
|
let overridden = false;
|
|
@@ -2409,7 +3135,7 @@ boundRun, cleanupPreview = false) {
|
|
|
2409
3135
|
remedy: refusal.remedy,
|
|
2410
3136
|
});
|
|
2411
3137
|
}
|
|
2412
|
-
else if (verdict === "refuse" && mode === "create" && !allowStalePlane && cleanupPreview &&
|
|
3138
|
+
else if (verdict === "refuse" && mode === "create" && !allowStalePlane && cleanupPreview?.kind === "none" &&
|
|
2413
3139
|
id === PLANE_SNAPSHOT_FRESHNESS_ID && isTerminalRunCleanupStatus(boundRun?.status)) {
|
|
2414
3140
|
rows.push({
|
|
2415
3141
|
duration_ms, id, label, status: "warn", blocking: false,
|
|
@@ -2445,7 +3171,11 @@ boundRun, cleanupPreview = false) {
|
|
|
2445
3171
|
if (reports !== null) {
|
|
2446
3172
|
project(PLANE_SNAPSHOT_FRESHNESS_ID, "Plane snapshot freshness", reports.snapshot, {
|
|
2447
3173
|
reasonId: "plane-snapshot-stale",
|
|
2448
|
-
remedy: boundRun
|
|
3174
|
+
remedy: boundRun === undefined
|
|
3175
|
+
? PLANE_SNAPSHOT_STALE_REMEDY
|
|
3176
|
+
: cleanupPreview !== null && cleanupPreview.kind !== "none" && isTerminalRunCleanupStatus(boundRun.status)
|
|
3177
|
+
? formatSharedPlaneStaleRemedy(boundRun, cleanupPreview.kind === "live" ? cleanupPreview.epicRunId : null)
|
|
3178
|
+
: formatBoundPlaneStaleRemedy(boundRun),
|
|
2449
3179
|
});
|
|
2450
3180
|
project(PLANE_DATABASE_HEAD_ID, "Plane database head", reports.database, {
|
|
2451
3181
|
reasonId: "plane-database-head-mismatch",
|
|
@@ -2515,6 +3245,13 @@ function renderFreshnessRows(rows, heading = 'Plane freshness:') {
|
|
|
2515
3245
|
* it is never proof of staleness and never permission to skip another safeguard.
|
|
2516
3246
|
*/
|
|
2517
3247
|
async function planeFreshnessCreateGuard(ctx, own, trailer = []) {
|
|
3248
|
+
// BAPI-1595 — plane freshness and the plane database head are Bridge-only. A
|
|
3249
|
+
// verified non-Bridge checkout skips both, with its fixed tally line; a Bridge,
|
|
3250
|
+
// a partial checkout, and an unestablished identity keep them.
|
|
3251
|
+
if (isConfirmedNonBridge(ctx)) {
|
|
3252
|
+
tallyBridgeOnlySkip(ctx, BRIDGE_ONLY_SKIPS.planeDatabaseHead);
|
|
3253
|
+
return null;
|
|
3254
|
+
}
|
|
2518
3255
|
try {
|
|
2519
3256
|
const reports = await collectFreshnessObservations(ctx, own);
|
|
2520
3257
|
if (reports === null)
|
|
@@ -2525,9 +3262,7 @@ async function planeFreshnessCreateGuard(ctx, own, trailer = []) {
|
|
|
2525
3262
|
// setup-epic REUSES the epic's live run instead of creating one, and a reuse
|
|
2526
3263
|
// is an attachment: it is warned about, never refused. Asked only when a
|
|
2527
3264
|
// confirmed finding would otherwise block, so the common path reads nothing.
|
|
2528
|
-
const live = await ctx.
|
|
2529
|
-
.readLiveEpicRun(ctx.access, ctx.epicKey)
|
|
2530
|
-
.catch(() => ({ kind: "unknown" }));
|
|
3265
|
+
const live = await acquireObservedLive(ctx).catch(() => ({ kind: "unknown" }));
|
|
2531
3266
|
if (live.kind === "live") {
|
|
2532
3267
|
assessment = assessPlaneFreshness(reports, null, "attach", ctx.options.allowStalePlane === true, boundRun);
|
|
2533
3268
|
}
|
|
@@ -2562,6 +3297,10 @@ async function planeFreshnessCreateGuard(ctx, own, trailer = []) {
|
|
|
2562
3297
|
}
|
|
2563
3298
|
/** The warning-only counterpart for an existing run. Never refuses, never throws. */
|
|
2564
3299
|
async function surfacePlaneFreshnessForExistingRun(ctx, own) {
|
|
3300
|
+
if (isConfirmedNonBridge(ctx)) {
|
|
3301
|
+
tallyBridgeOnlySkip(ctx, BRIDGE_ONLY_SKIPS.planeDatabaseHead);
|
|
3302
|
+
return;
|
|
3303
|
+
}
|
|
2565
3304
|
try {
|
|
2566
3305
|
const reports = await collectFreshnessObservations(ctx, own);
|
|
2567
3306
|
if (reports === null)
|
|
@@ -2581,19 +3320,60 @@ async function surfacePlaneFreshnessForExistingRun(ctx, own) {
|
|
|
2581
3320
|
// Advisory only.
|
|
2582
3321
|
}
|
|
2583
3322
|
}
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
3323
|
+
export const WORKER_DATABASE_UNPROVEN_REASON_CODE = "worker_database_configuration_unproven";
|
|
3324
|
+
export const WORKER_DATABASE_UNPROVEN_LINE = "worker database boundary: not checked (the project's database configuration was not reported)";
|
|
3325
|
+
export const WORKER_DATABASE_FALLBACK_REASON_CODE = "worker_database_configuration_defaulted";
|
|
3326
|
+
export const WORKER_DATABASE_FALLBACK_LINE = "worker database boundary: configuration not reported; checked with Bridge's own database names";
|
|
3327
|
+
export function resolveWorkerDatabaseApplicability(input) {
|
|
3328
|
+
const declared = input.declaration;
|
|
3329
|
+
if (declared !== null && declared !== undefined) {
|
|
3330
|
+
if (declared.mode === "none")
|
|
3331
|
+
return { kind: "skip", reason: "mode_none" };
|
|
3332
|
+
return {
|
|
3333
|
+
kind: "inspect",
|
|
3334
|
+
fallback: false,
|
|
3335
|
+
config: {
|
|
3336
|
+
status: "configured",
|
|
3337
|
+
mode: "disposable_postgres",
|
|
3338
|
+
...(declared.worker_role !== null ? { workerRole: declared.worker_role } : {}),
|
|
3339
|
+
protectedDatabases: [...declared.protected_databases],
|
|
3340
|
+
envNames: [],
|
|
3341
|
+
},
|
|
3342
|
+
};
|
|
3343
|
+
}
|
|
3344
|
+
if (input.validContext && input.isBridge === true)
|
|
3345
|
+
return { kind: "inspect", config: undefined, fallback: true };
|
|
3346
|
+
return { kind: "unproven" };
|
|
3347
|
+
}
|
|
3348
|
+
/** The applicability for a real launch, from its validated snapshot and verified identity. */
|
|
3349
|
+
function launchWorkerDatabaseApplicability(ctx) {
|
|
3350
|
+
const readiness = ctx.launchSnapshot?.context.readiness;
|
|
3351
|
+
return resolveWorkerDatabaseApplicability({
|
|
3352
|
+
declaration: readiness?.state === "known" ? readiness.value.worker_database : null,
|
|
3353
|
+
validContext: ctx.launchSnapshot !== undefined && ctx.launchSnapshot !== null,
|
|
3354
|
+
isBridge: ctx.previewRepository?.isBridge,
|
|
3355
|
+
});
|
|
3356
|
+
}
|
|
3357
|
+
/** Copy the typed worker state onto its row so a consumer never reads `detail` prose. */
|
|
3358
|
+
function stampWorkerState(rows, section) {
|
|
3359
|
+
return rows.map((row) => {
|
|
3360
|
+
const source = section.rows.find((entry) => entry.id === row.id);
|
|
3361
|
+
return source !== undefined && (source.state === "unsafe" || source.state === "unknown")
|
|
3362
|
+
? { ...row, worker_state: source.state }
|
|
3363
|
+
: row;
|
|
3364
|
+
});
|
|
3365
|
+
}
|
|
2587
3366
|
/**
|
|
2588
3367
|
* Run the worker-database inspection for a local-plane target, once.
|
|
2589
3368
|
*
|
|
2590
3369
|
* `null` when nothing applies: a target that is not this machine's plane never
|
|
2591
3370
|
* runs the inspector, so a remote launch's requests and output are unchanged.
|
|
2592
3371
|
* An inspector that throws or times out prints one fixed line naming only the
|
|
2593
|
-
* closed classification, then yields
|
|
2594
|
-
*
|
|
3372
|
+
* closed classification, then yields a section with NO rows: a launch shows no
|
|
3373
|
+
* advisory row for an inspection it could not make (BAPI-1594), and the
|
|
3374
|
+
* missing role row still resolves the role need to `unverifiable`.
|
|
2595
3375
|
*/
|
|
2596
|
-
async function collectWorkerDatabaseAdvisory(deps, baseUrl, cache) {
|
|
3376
|
+
async function collectWorkerDatabaseAdvisory(deps, baseUrl, cache, config) {
|
|
2597
3377
|
if (baseUrl === null || planeEndpointForBaseUrl(deps, baseUrl) === null)
|
|
2598
3378
|
return null;
|
|
2599
3379
|
const inspect = deps.inspectWorkerDatabase;
|
|
@@ -2601,16 +3381,12 @@ async function collectWorkerDatabaseAdvisory(deps, baseUrl, cache) {
|
|
|
2601
3381
|
return null;
|
|
2602
3382
|
const run = async () => {
|
|
2603
3383
|
let failed = false;
|
|
2604
|
-
const section = await collectWorkerDatabaseDoctorSection(() => inspect(deps.cwd()), WORKER_DATABASE_DOCTOR_TIMEOUT_MS, (failure) => {
|
|
3384
|
+
const section = await collectWorkerDatabaseDoctorSection(() => inspect(deps.cwd(), config), WORKER_DATABASE_DOCTOR_TIMEOUT_MS, (failure) => {
|
|
2605
3385
|
failed = true;
|
|
2606
3386
|
deps.errorLog(`worker-db inspection failed: ${failure}`);
|
|
2607
3387
|
}).catch(() => null);
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
// rows. The doctor's own all-unknown section is left as it is.
|
|
2611
|
-
if (section !== null && failed) {
|
|
2612
|
-
return { ...section, rows: section.rows.filter((row) => row.id === "worker-db-unverifiable") };
|
|
2613
|
-
}
|
|
3388
|
+
if (section !== null && failed)
|
|
3389
|
+
return { ...section, rows: [] };
|
|
2614
3390
|
return section;
|
|
2615
3391
|
};
|
|
2616
3392
|
if (cache === undefined)
|
|
@@ -2618,9 +3394,9 @@ async function collectWorkerDatabaseAdvisory(deps, baseUrl, cache) {
|
|
|
2618
3394
|
cache.workerDatabase ??= run();
|
|
2619
3395
|
return cache.workerDatabase;
|
|
2620
3396
|
}
|
|
2621
|
-
/** The advisory rows for a local launch: non-healthy `worker-db
|
|
2622
|
-
async function workerDatabaseAdvisoryRows(deps, baseUrl, cache) {
|
|
2623
|
-
const section = await collectWorkerDatabaseAdvisory(deps, baseUrl, cache);
|
|
3397
|
+
/** The advisory rows for a local launch: non-healthy `worker-db-role` and `worker-db-boundary` warnings only. */
|
|
3398
|
+
async function workerDatabaseAdvisoryRows(deps, baseUrl, cache, config) {
|
|
3399
|
+
const section = await collectWorkerDatabaseAdvisory(deps, baseUrl, cache, config);
|
|
2624
3400
|
return section === null ? [] : previewLaunchRows(workerDatabaseReadinessChecks(section));
|
|
2625
3401
|
}
|
|
2626
3402
|
/**
|
|
@@ -2631,8 +3407,24 @@ async function workerDatabaseAdvisoryRows(deps, baseUrl, cache) {
|
|
|
2631
3407
|
* an unexpected failure prints nothing.
|
|
2632
3408
|
*/
|
|
2633
3409
|
async function surfaceWorkerDatabaseAdvisory(ctx) {
|
|
3410
|
+
// BAPI-1596 — the configured mode decides, not the checkout's identity. A verified
|
|
3411
|
+
// non-Bridge checkout that declares no database skips with its one fixed tally line;
|
|
3412
|
+
// a configuration that was not reported is tallied and never inspected.
|
|
3413
|
+
const applicability = launchWorkerDatabaseApplicability(ctx);
|
|
3414
|
+
if (applicability.kind === "skip") {
|
|
3415
|
+
if (isConfirmedNonBridge(ctx))
|
|
3416
|
+
tallyBridgeOnlySkip(ctx, BRIDGE_ONLY_SKIPS.workerDatabase);
|
|
3417
|
+
return;
|
|
3418
|
+
}
|
|
3419
|
+
if (applicability.kind === "unproven") {
|
|
3420
|
+
tallyOnce(ctx, WORKER_DATABASE_UNPROVEN_REASON_CODE, WORKER_DATABASE_UNPROVEN_LINE, false);
|
|
3421
|
+
return;
|
|
3422
|
+
}
|
|
3423
|
+
if (applicability.fallback) {
|
|
3424
|
+
tallyOnce(ctx, WORKER_DATABASE_FALLBACK_REASON_CODE, WORKER_DATABASE_FALLBACK_LINE, false);
|
|
3425
|
+
}
|
|
2634
3426
|
try {
|
|
2635
|
-
const rows = await workerDatabaseAdvisoryRows(ctx.deps, ctx.access.baseUrl, ctx.freshness);
|
|
3427
|
+
const rows = await workerDatabaseAdvisoryRows(ctx.deps, ctx.access.baseUrl, ctx.freshness, applicability.config);
|
|
2636
3428
|
if (rows.length === 0)
|
|
2637
3429
|
return;
|
|
2638
3430
|
const log = ctx.deps.launchReadinessLog ?? ctx.deps.errorLog;
|
|
@@ -2652,11 +3444,21 @@ async function surfaceWorkerDatabaseAdvisory(ctx) {
|
|
|
2652
3444
|
* inspector and its JSON is unchanged. Never changes the decision, a refusal,
|
|
2653
3445
|
* readiness, or the exit code.
|
|
2654
3446
|
*/
|
|
2655
|
-
async function appendWorkerDatabaseAdvisoryRows(deps, preview, repository) {
|
|
2656
|
-
|
|
2657
|
-
|
|
3447
|
+
async function appendWorkerDatabaseAdvisoryRows(deps, preview, repository, applicability) {
|
|
3448
|
+
// BAPI-1596 — gated on the configured mode, not on checkout identity. A verified
|
|
3449
|
+
// non-Bridge checkout keeps its two fixed `not_bridge_repository` skip rows.
|
|
3450
|
+
if (applicability.kind !== "inspect") {
|
|
3451
|
+
if (repository?.isBridge === false) {
|
|
3452
|
+
preview.launch_checks = [...(preview.launch_checks ?? []), ...nonBridgeRows(WORKER_DATABASE_PREVIEW_IDS)];
|
|
3453
|
+
}
|
|
3454
|
+
if (applicability.kind === "unproven") {
|
|
3455
|
+
(preview.tally_lines ??= []).push({ code: WORKER_DATABASE_UNPROVEN_REASON_CODE, line: WORKER_DATABASE_UNPROVEN_LINE });
|
|
3456
|
+
}
|
|
2658
3457
|
return null;
|
|
2659
3458
|
}
|
|
3459
|
+
if (applicability.fallback) {
|
|
3460
|
+
(preview.tally_lines ??= []).push({ code: WORKER_DATABASE_FALLBACK_REASON_CODE, line: WORKER_DATABASE_FALLBACK_LINE });
|
|
3461
|
+
}
|
|
2660
3462
|
if (repository === undefined)
|
|
2661
3463
|
return null;
|
|
2662
3464
|
if (preview.target.kind !== "local_plane")
|
|
@@ -2664,8 +3466,8 @@ async function appendWorkerDatabaseAdvisoryRows(deps, preview, repository) {
|
|
|
2664
3466
|
try {
|
|
2665
3467
|
// BAPI-1506: the section is returned so the launch-need step reuses this one
|
|
2666
3468
|
// inspection instead of running a second.
|
|
2667
|
-
const section = await collectWorkerDatabaseAdvisory(deps, preview.target.base_url);
|
|
2668
|
-
const rows = section === null ? [] : previewLaunchRows(workerDatabaseReadinessChecks(section));
|
|
3469
|
+
const section = await collectWorkerDatabaseAdvisory(deps, preview.target.base_url, undefined, applicability.config);
|
|
3470
|
+
const rows = section === null ? [] : stampWorkerState(previewLaunchRows(workerDatabaseReadinessChecks(section)), section);
|
|
2669
3471
|
if (rows.length > 0)
|
|
2670
3472
|
preview.launch_checks = [...(preview.launch_checks ?? []), ...rows];
|
|
2671
3473
|
return section;
|
|
@@ -2741,11 +3543,6 @@ async function coldStartPlane(ctx) {
|
|
|
2741
3543
|
]);
|
|
2742
3544
|
}
|
|
2743
3545
|
}
|
|
2744
|
-
// The cold start leaves the readiness `catch` before the ordinary advisory
|
|
2745
|
-
// read is reached, so it surfaces the BAPI-1022 containment advisory itself —
|
|
2746
|
-
// before anything is started, exactly as every other plan-file route does.
|
|
2747
|
-
if (ctx.options.planFile)
|
|
2748
|
-
await surfaceContainmentAdvisory(deps, ctx.options.planFile);
|
|
2749
3546
|
deps.log(`${epicKey}: nothing is listening on the plane endpoint; cold-starting the local plane.`);
|
|
2750
3547
|
const repoRoot = deps.cwd();
|
|
2751
3548
|
// BAPI-1496: a plane bound to a finished run is torn down before preflight.
|
|
@@ -2760,28 +3557,23 @@ async function coldStartPlane(ctx) {
|
|
|
2760
3557
|
"Nothing was started. Fix the item above and run drive-epic again.",
|
|
2761
3558
|
]);
|
|
2762
3559
|
}
|
|
2763
|
-
const
|
|
3560
|
+
const parallelColdRefusal = await parallelCreationCandidateRefusal(ctx);
|
|
3561
|
+
if (parallelColdRefusal !== null) {
|
|
3562
|
+
deps.errorLog(`${epicKey}: ${parallelColdRefusal}\nNothing was started.`);
|
|
3563
|
+
return 1;
|
|
3564
|
+
}
|
|
3565
|
+
const coldLanes = parallelLimitToExecutorLanes(ctx.options.parallel ?? DEFAULT_RUN_PARALLEL_LIMIT);
|
|
3566
|
+
const controlPlane = await deps.launchControlPlane({ preflight, executors: coldLanes });
|
|
2764
3567
|
if (!controlPlane.ok) {
|
|
2765
3568
|
return reportControlPlaneLaunchFailure(ctx, controlPlane);
|
|
2766
3569
|
}
|
|
2767
3570
|
void controlPlane.lifetime.catch(() => undefined);
|
|
2768
|
-
//
|
|
2769
|
-
//
|
|
2770
|
-
//
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
}
|
|
2775
|
-
catch (err) {
|
|
2776
|
-
if (isSchemaIncompatibleError(err)) {
|
|
2777
|
-
return refuse(deps, [...formatSchemaIncompatibleRefusal(epicKey, err), ...LAUNCHED_PLANE_LEFT_RUNNING]);
|
|
2778
|
-
}
|
|
2779
|
-
return refuse(deps, [
|
|
2780
|
-
`${epicKey}: the plane came up, but its Epic Implementer readiness could not be read: ` +
|
|
2781
|
-
safeDiagnosticMessage(err, "readiness request failed"),
|
|
2782
|
-
...LAUNCHED_PLANE_LEFT_RUNNING,
|
|
2783
|
-
]);
|
|
2784
|
-
}
|
|
3571
|
+
// BAPI-1595 — a launch reads no readiness report, a cold start included. This
|
|
3572
|
+
// plane is a fresh server, so no stored snapshot describes it: say so once and
|
|
3573
|
+
// carry on with every evaluator on its unknown (warn) path. The server's create
|
|
3574
|
+
// and approve decide; the plane's own reconciler is still confirmed below.
|
|
3575
|
+
tallyOnce(ctx, SNAPSHOT_EXPIRED_REASON_CODE, SNAPSHOT_EXPIRED_WARNING);
|
|
3576
|
+
const readiness = launchFullReadiness();
|
|
2785
3577
|
const prepared = await prepareSetupSelection(ctx);
|
|
2786
3578
|
if (!prepared.ok) {
|
|
2787
3579
|
return refuse(deps, [
|
|
@@ -2790,11 +3582,13 @@ async function coldStartPlane(ctx) {
|
|
|
2790
3582
|
]);
|
|
2791
3583
|
}
|
|
2792
3584
|
ctx = { ...ctx, handoff: prepared.handoff };
|
|
2793
|
-
const classification =
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
3585
|
+
const classification = readiness === null
|
|
3586
|
+
? classifySnapshotDiagnostics(ctx)
|
|
3587
|
+
: classifyV2Readiness(readiness, {
|
|
3588
|
+
attended: ctx.options.attended === true,
|
|
3589
|
+
intoBase: ctx.options.intoBase === true,
|
|
3590
|
+
effectivePolicy: ctx.handoff?.selection,
|
|
3591
|
+
});
|
|
2798
3592
|
if (classification.kind === "operator_blocked") {
|
|
2799
3593
|
return refuse(deps, [
|
|
2800
3594
|
`${epicKey}: the engine path still needs ${classification.describe}.`,
|
|
@@ -2824,6 +3618,7 @@ async function coldStartPlane(ctx) {
|
|
|
2824
3618
|
repoRoot,
|
|
2825
3619
|
planeId: controlPlane.planeId,
|
|
2826
3620
|
awaitPlaneReady: controlPlane.awaitPlaneReady,
|
|
3621
|
+
laneCount: coldLanes,
|
|
2827
3622
|
}, readiness);
|
|
2828
3623
|
}
|
|
2829
3624
|
/**
|
|
@@ -2906,6 +3701,7 @@ async function attachToPlane(ctx, manifest, readiness) {
|
|
|
2906
3701
|
repoRoot: manifest.repoRoot,
|
|
2907
3702
|
planeId: manifest.planeId,
|
|
2908
3703
|
...(manifest.epicRunId !== undefined ? { boundRunId: manifest.epicRunId } : {}),
|
|
3704
|
+
laneCount: attachedPlaneLaneCount(manifest),
|
|
2909
3705
|
}, readiness);
|
|
2910
3706
|
}
|
|
2911
3707
|
/**
|
|
@@ -2922,13 +3718,15 @@ async function createRunAndRequestLanes(ctx, plane, readiness) {
|
|
|
2922
3718
|
const launched = plane.origin === "launched";
|
|
2923
3719
|
// BAPI-1452: a plane lane owns this run's executor, so the launch evidence
|
|
2924
3720
|
// can only warn here; printed before the run exists.
|
|
2925
|
-
if (readiness !== undefined) {
|
|
3721
|
+
if (readiness !== undefined && readiness !== null) {
|
|
2926
3722
|
const gate = await launchCapabilityGate(ctx, readiness, { kind: "plane_lane" });
|
|
2927
3723
|
if (gate !== null)
|
|
2928
3724
|
return gate;
|
|
2929
3725
|
}
|
|
2930
3726
|
// ---- PHASE TWO, part one: create the run ------------------------------
|
|
2931
3727
|
const setup = await runSelectedSetupEpic(ctx);
|
|
3728
|
+
if (setup.launchHandled === true)
|
|
3729
|
+
return setup.exitCode;
|
|
2932
3730
|
if (setup.exitCode !== 0) {
|
|
2933
3731
|
// The control plane is deliberately LEFT RUNNING, and NO EXECUTOR LANE
|
|
2934
3732
|
// was spawned — there is nothing to claim a job that may not exist.
|
|
@@ -2997,6 +3795,7 @@ async function createRunAndRequestLanes(ctx, plane, readiness) {
|
|
|
2997
3795
|
].join("\n"));
|
|
2998
3796
|
return 1;
|
|
2999
3797
|
}
|
|
3798
|
+
reportPlaneCapacity(ctx, plane.laneCount, setup.parallelLimit, setup.runPosture);
|
|
3000
3799
|
if (plane.awaitPlaneReady === undefined) {
|
|
3001
3800
|
// Attached: the plane's own detached runtime performs the spawn and the
|
|
3002
3801
|
// per-lane readiness gating, and this process may exit first. Its progress
|
|
@@ -3147,6 +3946,22 @@ function durableCoverageRefusal(epicKey, access, profile, coverage, outcome) {
|
|
|
3147
3946
|
],
|
|
3148
3947
|
};
|
|
3149
3948
|
}
|
|
3949
|
+
/**
|
|
3950
|
+
* BAPI-1595 — the durable-host coverage a launch may refuse on. The launch holds the
|
|
3951
|
+
* preview's snapshot rather than a report, so coverage refuses only when the snapshot
|
|
3952
|
+
* PROVES it absent (`false`); an unreported or unreadable value is unknown and the
|
|
3953
|
+
* server's create decides. A full report, when one is held, keeps its strict reading.
|
|
3954
|
+
*/
|
|
3955
|
+
function durableCoverageOf(ctx, readiness) {
|
|
3956
|
+
if (readiness !== null)
|
|
3957
|
+
return readiness.executor.repo_wide_executor_live;
|
|
3958
|
+
const snapshotReadiness = ctx.launchSnapshot?.context.readiness;
|
|
3959
|
+
return snapshotReadiness !== undefined &&
|
|
3960
|
+
snapshotReadiness.state === "known" &&
|
|
3961
|
+
snapshotReadiness.value.repo_wide_executor_live === false
|
|
3962
|
+
? false
|
|
3963
|
+
: true;
|
|
3964
|
+
}
|
|
3150
3965
|
/** The pre-create refusal when no executor could ever be started from this checkout. */
|
|
3151
3966
|
function executorPreconditionRefusal(epicKey, message, outcome) {
|
|
3152
3967
|
return {
|
|
@@ -3188,21 +4003,6 @@ function liveRunAmbiguousRefusal(epicKey) {
|
|
|
3188
4003
|
],
|
|
3189
4004
|
};
|
|
3190
4005
|
}
|
|
3191
|
-
/** BAPI-1285 — the epic's run state could not be read, so nothing may be assumed. */
|
|
3192
|
-
function liveRunUnknownRefusal(epicKey, reason) {
|
|
3193
|
-
const remedy = "Restore Bridge API access, then run drive-epic again. Creating a run without knowing " +
|
|
3194
|
-
"whether one exists could mint a duplicate, which wedges the epic permanently.";
|
|
3195
|
-
return {
|
|
3196
|
-
reasonId: "live-run-unknown",
|
|
3197
|
-
remedy,
|
|
3198
|
-
lines: [
|
|
3199
|
-
`${epicKey}: REFUSED (live-run-unknown) — the epic's run state could not be read (${reason}).`,
|
|
3200
|
-
remedy,
|
|
3201
|
-
"",
|
|
3202
|
-
"Nothing was created and nothing was started.",
|
|
3203
|
-
],
|
|
3204
|
-
};
|
|
3205
|
-
}
|
|
3206
4006
|
/**
|
|
3207
4007
|
* Create the run, then make sure an executor will claim its jobs — the path for
|
|
3208
4008
|
* every launch that does not request a plane lane.
|
|
@@ -3225,7 +4025,8 @@ async function createRunWithRunExecutor(ctx, readiness) {
|
|
|
3225
4025
|
"No run was created and no local executor was started.",
|
|
3226
4026
|
]);
|
|
3227
4027
|
}
|
|
3228
|
-
|
|
4028
|
+
// BAPI-1593 — unknown readiness: the server's create and approve decide.
|
|
4029
|
+
const coverage = durableCoverageOf(ctx, readiness);
|
|
3229
4030
|
if (coverage !== true) {
|
|
3230
4031
|
return refuse(deps, durableCoverageRefusal(epicKey, access, profile, coverage, "No run was created").lines);
|
|
3231
4032
|
}
|
|
@@ -3235,11 +4036,16 @@ async function createRunWithRunExecutor(ctx, readiness) {
|
|
|
3235
4036
|
if (gate !== null)
|
|
3236
4037
|
return gate;
|
|
3237
4038
|
const setup = await runSelectedSetupEpic(ctx);
|
|
4039
|
+
if (setup.launchHandled === true)
|
|
4040
|
+
return setup.exitCode;
|
|
3238
4041
|
if (setup.exitCode === 0) {
|
|
3239
4042
|
deps.log([
|
|
3240
4043
|
"",
|
|
3241
4044
|
`${epicKey}: run ${setup.epicRunId ?? "(id not reported)"} created on ${access.baseUrl}.`,
|
|
3242
4045
|
"The durable host's repo-wide executor claims its jobs; no local executor was started.",
|
|
4046
|
+
...(setup.parallelLimit !== undefined && setup.runPosture === "unattended"
|
|
4047
|
+
? [durableCapacityLine(setup.parallelLimit)]
|
|
4048
|
+
: []),
|
|
3243
4049
|
].join("\n"));
|
|
3244
4050
|
}
|
|
3245
4051
|
return setup.exitCode;
|
|
@@ -3255,6 +4061,8 @@ async function createRunWithRunExecutor(ctx, readiness) {
|
|
|
3255
4061
|
if (gate !== null)
|
|
3256
4062
|
return gate;
|
|
3257
4063
|
const setup = await runSelectedSetupEpic(ctx);
|
|
4064
|
+
if (setup.launchHandled === true)
|
|
4065
|
+
return setup.exitCode;
|
|
3258
4066
|
if (setup.exitCode !== 0) {
|
|
3259
4067
|
// setup-epic already said why. Nothing was started for a run that may not exist.
|
|
3260
4068
|
deps.errorLog(`\n${epicKey}: no executor was started.`);
|
|
@@ -3280,6 +4088,10 @@ async function createRunWithRunExecutor(ctx, readiness) {
|
|
|
3280
4088
|
access,
|
|
3281
4089
|
profile,
|
|
3282
4090
|
mergeCredential: await launchCredentialForExecutor(ctx, readiness),
|
|
4091
|
+
// BAPI-1581 — the SERVER-stored limit, and only for a stored unattended run.
|
|
4092
|
+
...(setup.runPosture === "unattended" && setup.parallelLimit !== undefined
|
|
4093
|
+
? { maxConcurrent: setup.parallelLimit }
|
|
4094
|
+
: {}),
|
|
3283
4095
|
});
|
|
3284
4096
|
return reportExecutorOutcome(ctx, ensured, setup.epicRunId, "created");
|
|
3285
4097
|
}
|
|
@@ -3328,6 +4140,10 @@ function reportExecutorOutcome(ctx, ensured, epicRunId, framing) {
|
|
|
3328
4140
|
? `${epicKey}: run ${epicRunId} is created on ${access.baseUrl}.`
|
|
3329
4141
|
: `${epicKey}: run ${epicRunId} is already live on ${access.baseUrl}; nothing was created.`,
|
|
3330
4142
|
started,
|
|
4143
|
+
...(ensured.maxConcurrent !== undefined && ensured.maxConcurrent > 1
|
|
4144
|
+
? [`It serves ${ensured.maxConcurrent} jobs at a time.`]
|
|
4145
|
+
: []),
|
|
4146
|
+
...(ensured.capacityNotice !== undefined ? [ensured.capacityNotice] : []),
|
|
3331
4147
|
"It claims only this run's jobs, and exits on its own once the run is done or abandoned.",
|
|
3332
4148
|
` Log: ${ensured.logPath}`,
|
|
3333
4149
|
` Record: ${ensured.recordPath}`,
|
|
@@ -3372,11 +4188,14 @@ async function planeServesLiveRun(ctx, live) {
|
|
|
3372
4188
|
*/
|
|
3373
4189
|
async function attachToLiveRun(ctx, readiness, live, unusedDiscoveredPlan) {
|
|
3374
4190
|
const { deps, epicKey, access, profile } = ctx;
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
4191
|
+
// BAPI-1593 — an unknown report proves nothing to refuse on: attach.
|
|
4192
|
+
const classification = readiness === null
|
|
4193
|
+
? { kind: "green" }
|
|
4194
|
+
: classifyV2Readiness(readiness, {
|
|
4195
|
+
attended: ctx.options.attended === true,
|
|
4196
|
+
intoBase: ctx.options.intoBase === true,
|
|
4197
|
+
approvedStoredPolicy: true,
|
|
4198
|
+
});
|
|
3380
4199
|
if (classification.kind === "operator_blocked") {
|
|
3381
4200
|
return refuse(deps, [
|
|
3382
4201
|
`${epicKey}: the engine path still needs ${classification.describe}.`,
|
|
@@ -3386,11 +4205,15 @@ async function attachToLiveRun(ctx, readiness, live, unusedDiscoveredPlan) {
|
|
|
3386
4205
|
]);
|
|
3387
4206
|
}
|
|
3388
4207
|
const planeTarget = planeEndpointForBaseUrl(deps, access.baseUrl) !== null;
|
|
3389
|
-
if (classification.kind === "runtime_only") {
|
|
4208
|
+
if (classification.kind === "runtime_only" && readiness !== null) {
|
|
3390
4209
|
if (!planeTarget)
|
|
3391
4210
|
return refuseRemoteRuntime(ctx, readiness);
|
|
3392
4211
|
return refuse(deps, localReconcilerRefusal(epicKey, readiness).lines);
|
|
3393
4212
|
}
|
|
4213
|
+
reportLaunchOutcome(ctx, live.status === "active" ? "active" : "pending_activation", {
|
|
4214
|
+
epicRunId: live.epicRunId,
|
|
4215
|
+
runStatus: live.status,
|
|
4216
|
+
});
|
|
3394
4217
|
if (planeTarget) {
|
|
3395
4218
|
const manifest = await findAttachablePlane(ctx).catch(() => null);
|
|
3396
4219
|
if (manifest?.epicRunId === live.epicRunId) {
|
|
@@ -3414,8 +4237,15 @@ async function attachToLiveRun(ctx, readiness, live, unusedDiscoveredPlan) {
|
|
|
3414
4237
|
"found, so nothing will be created; making sure it has an executor."
|
|
3415
4238
|
: `${epicKey}: run ${live.epicRunId} is already live (${live.status}); the plan found by epic key ` +
|
|
3416
4239
|
`(${unusedDiscoveredPlan}) is not used, so nothing will be created; making sure it has an executor.`);
|
|
4240
|
+
// BAPI-1581 — the limit and posture that GOVERN this run come from its stored
|
|
4241
|
+
// policy; launch flags never decide them. A missing stored policy reads as no
|
|
4242
|
+
// known limit and adds no executor concurrency.
|
|
4243
|
+
const storedParallel = live.effectivePolicy !== undefined && typeof live.effectivePolicy.parallel_limit === "number"
|
|
4244
|
+
? live.effectivePolicy.parallel_limit
|
|
4245
|
+
: undefined;
|
|
4246
|
+
const storedUnattended = live.effectivePolicy?.posture === "unattended";
|
|
3417
4247
|
if (live.effectivePolicy) {
|
|
3418
|
-
deps.log(`Effective policy: stored;
|
|
4248
|
+
deps.log(`Effective policy: stored; parallel limit ${live.effectivePolicy.parallel_limit}; caps ${live.effectivePolicy.caps ? JSON.stringify(live.effectivePolicy.caps) : "unavailable"}; ` +
|
|
3419
4249
|
`timeouts ${live.effectivePolicy.job_timeouts ? JSON.stringify(live.effectivePolicy.job_timeouts) : "unavailable"}; ` +
|
|
3420
4250
|
`channel ${live.effectivePolicy.escalation_channel}.`);
|
|
3421
4251
|
}
|
|
@@ -3426,7 +4256,9 @@ async function attachToLiveRun(ctx, readiness, live, unusedDiscoveredPlan) {
|
|
|
3426
4256
|
"No run was changed and no local executor was started.",
|
|
3427
4257
|
]);
|
|
3428
4258
|
}
|
|
3429
|
-
|
|
4259
|
+
// BAPI-1593 — unknown readiness says nothing about coverage; the warning
|
|
4260
|
+
// already printed, and the run is left as it is.
|
|
4261
|
+
const coverage = durableCoverageOf(ctx, readiness);
|
|
3430
4262
|
if (coverage !== true) {
|
|
3431
4263
|
return refuse(deps, durableCoverageRefusal(epicKey, access, profile, coverage, "No run was changed").lines);
|
|
3432
4264
|
}
|
|
@@ -3434,15 +4266,32 @@ async function attachToLiveRun(ctx, readiness, live, unusedDiscoveredPlan) {
|
|
|
3434
4266
|
"",
|
|
3435
4267
|
`${epicKey}: run ${live.epicRunId} is served by the durable host's confirmed repo-wide executor.`,
|
|
3436
4268
|
"No local executor was started.",
|
|
4269
|
+
...(storedParallel !== undefined && storedUnattended ? [durableCapacityLine(storedParallel)] : []),
|
|
3437
4270
|
].join("\n"));
|
|
3438
4271
|
return 0;
|
|
3439
4272
|
}
|
|
4273
|
+
// BAPI-1581 — one informational notice, never a refusal or a policy change.
|
|
4274
|
+
if (ctx.options.parallel !== undefined) {
|
|
4275
|
+
if (!storedUnattended) {
|
|
4276
|
+
deps.log(`${epicKey}: --parallel ${ctx.options.parallel} was not applied: run ${live.epicRunId} is not ` +
|
|
4277
|
+
"unattended, and the limit applies only to unattended runs. Nothing was changed.");
|
|
4278
|
+
}
|
|
4279
|
+
else if (storedParallel !== undefined) {
|
|
4280
|
+
const retained = retainedParallelLimitNotice(ctx.options.parallel, storedParallel);
|
|
4281
|
+
if (retained !== null)
|
|
4282
|
+
deps.log(retained);
|
|
4283
|
+
}
|
|
4284
|
+
}
|
|
3440
4285
|
if (planeTarget && (await planeServesLiveRun(ctx, live))) {
|
|
3441
4286
|
deps.log([
|
|
3442
4287
|
"",
|
|
3443
4288
|
`${epicKey}: this checkout's plane is bound to run ${live.epicRunId}; its executor lanes serve it.`,
|
|
3444
4289
|
"No run-scoped executor was started beside them.",
|
|
3445
4290
|
].join("\n"));
|
|
4291
|
+
const servingManifest = await findAttachablePlane(ctx).catch(() => null);
|
|
4292
|
+
if (servingManifest !== null) {
|
|
4293
|
+
reportPlaneCapacity(ctx, attachedPlaneLaneCount(servingManifest), storedParallel, storedUnattended ? "unattended" : "attended");
|
|
4294
|
+
}
|
|
3446
4295
|
return 0;
|
|
3447
4296
|
}
|
|
3448
4297
|
const prepared = await deps.prepareRunExecutor(deps.cwd());
|
|
@@ -3456,6 +4305,7 @@ async function attachToLiveRun(ctx, readiness, live, unusedDiscoveredPlan) {
|
|
|
3456
4305
|
access,
|
|
3457
4306
|
profile,
|
|
3458
4307
|
mergeCredential: await launchCredentialForExecutor(ctx, readiness),
|
|
4308
|
+
...(storedUnattended && storedParallel !== undefined ? { maxConcurrent: storedParallel } : {}),
|
|
3459
4309
|
});
|
|
3460
4310
|
return reportExecutorOutcome(ctx, ensured, live.epicRunId, "attached");
|
|
3461
4311
|
}
|
|
@@ -3511,6 +4361,100 @@ function reportControlPlaneLaunchFailure(ctx, controlPlane) {
|
|
|
3511
4361
|
"No run was created.",
|
|
3512
4362
|
]);
|
|
3513
4363
|
}
|
|
4364
|
+
// ---------------------------------------------------------------------------
|
|
4365
|
+
// BAPI-1285 — the read-only launch preview (`--dry-run [--json]`)
|
|
4366
|
+
// ---------------------------------------------------------------------------
|
|
4367
|
+
//
|
|
4368
|
+
// The preview answers "what would a real invocation do?" and changes nothing. It
|
|
4369
|
+
// resolves the target, reads readiness and the epic's live run, discovers the
|
|
4370
|
+
// plan, and — when a plan is available — runs setup-epic's OWN dry run so the
|
|
4371
|
+
// server's real plan validator speaks. It never calls `adoptLaunchTarget`, a
|
|
4372
|
+
// non-dry `runSetupEpic`, `prepareRunExecutor`, `ensureRunExecutor`,
|
|
4373
|
+
// `launchControlPlane`, `runPlane`, or `requestScopedLanes`, and it never mutates
|
|
4374
|
+
// `process.env`.
|
|
4375
|
+
//
|
|
4376
|
+
// Output discipline: with `--json` stdout carries exactly ONE single-line JSON
|
|
4377
|
+
// document and nothing else, even on refusal. Nothing captured from setup-epic is
|
|
4378
|
+
// replayed, and no error text, credential, webhook URL, or policy content is ever
|
|
4379
|
+
// put into the document. The narrow exception is the production epic-launch
|
|
4380
|
+
// resolver's fixed sentences: they may name a store target key, store/profile
|
|
4381
|
+
// path, profile name, or validated safe binding target URL, never a credential
|
|
4382
|
+
// value or entry contents. Readiness, live-run, setup, and thrown errors remain
|
|
4383
|
+
// excluded.
|
|
4384
|
+
//
|
|
4385
|
+
// Known limits, stated plainly: the preview probes a port in exactly two narrow
|
|
4386
|
+
// cases, both after a local readiness read failed at the transport — a supplied
|
|
4387
|
+
// or discovered plan (to preview the guarded cold start), and no usable plan (the
|
|
4388
|
+
// plane-down stop, whose text is a verbatim part of the real launch's output).
|
|
4389
|
+
// Any other local plane that is not listening reads as unknown readiness; and a
|
|
4390
|
+
// local-plane target with only the reconciler missing previews as if the runtime
|
|
4391
|
+
// could be brought up, as a real launch with a plan composes.
|
|
4392
|
+
// BAPI-1594 — the engine's own paths live in their own module (they are Bridge repository
|
|
4393
|
+
// paths, not owner-facing text); re-exported here beside the preview definitions.
|
|
4394
|
+
export { ENGINE_PATHS };
|
|
4395
|
+
/** Bound for the one engine-path `git status`. */
|
|
4396
|
+
const ENGINE_STATUS_TIMEOUT_MS = 10_000;
|
|
4397
|
+
/** One porcelain-v1 `-z` record: two status columns, a space, then a path. */
|
|
4398
|
+
const PORCELAIN_RECORD = /^[ MTADRCU?!][ MTADRCU?!] [^\0]+$/;
|
|
4399
|
+
/**
|
|
4400
|
+
* Classify the NUL-delimited porcelain-v1 output of the engine-path status.
|
|
4401
|
+
* `clean` only for explicitly empty output. A rename or copy record is followed
|
|
4402
|
+
* by its origin path as a separate NUL-terminated field; a path-filtered rename
|
|
4403
|
+
* into or out of an engine path can legally appear as just the engine-side
|
|
4404
|
+
* addition or deletion. Anything that does not parse is `unreadable`, never clean.
|
|
4405
|
+
*/
|
|
4406
|
+
function classifyEngineStatus(stdout) {
|
|
4407
|
+
if (typeof stdout !== "string")
|
|
4408
|
+
return "unreadable";
|
|
4409
|
+
if (stdout === "")
|
|
4410
|
+
return "clean";
|
|
4411
|
+
if (!stdout.endsWith("\0"))
|
|
4412
|
+
return "unreadable";
|
|
4413
|
+
const fields = stdout.slice(0, -1).split("\0");
|
|
4414
|
+
let records = 0;
|
|
4415
|
+
for (let i = 0; i < fields.length; i += 1) {
|
|
4416
|
+
const field = fields[i];
|
|
4417
|
+
if (!PORCELAIN_RECORD.test(field))
|
|
4418
|
+
return "unreadable";
|
|
4419
|
+
records += 1;
|
|
4420
|
+
if (/^[RC]/.test(field) || /^.[RC]/.test(field)) {
|
|
4421
|
+
// The rename/copy origin path follows as its own field.
|
|
4422
|
+
i += 1;
|
|
4423
|
+
if (i >= fields.length || fields[i] === "")
|
|
4424
|
+
return "unreadable";
|
|
4425
|
+
}
|
|
4426
|
+
}
|
|
4427
|
+
return records > 0 ? "dirty" : "unreadable";
|
|
4428
|
+
}
|
|
4429
|
+
/**
|
|
4430
|
+
* Collect the health-check fact for a verified Bridge LOCAL-plane create preview
|
|
4431
|
+
* (BAPI-1594). Advisory by construction: it never changes the decision, a
|
|
4432
|
+
* refusal, or the exit code, and nothing it saw (a filename, raw porcelain, an
|
|
4433
|
+
* error) reaches the document. Any uncertainty asks for the check.
|
|
4434
|
+
*/
|
|
4435
|
+
async function appendHealthCheckFact(deps, preview, repository) {
|
|
4436
|
+
if (repository?.isBridge !== true || preview.target.kind !== "local_plane" || preview.decision !== "create")
|
|
4437
|
+
return;
|
|
4438
|
+
const exec = deps.execEngineStatus;
|
|
4439
|
+
if (exec === undefined)
|
|
4440
|
+
return;
|
|
4441
|
+
let outcome = "unreadable";
|
|
4442
|
+
try {
|
|
4443
|
+
const result = await exec("git", ["status", "--porcelain=v1", "-z", "--untracked-files=all", "--", ...ENGINE_PATHS], { cwd: repository.repoRoot, timeoutMs: ENGINE_STATUS_TIMEOUT_MS });
|
|
4444
|
+
if (result !== null && typeof result === "object" && result.ok === true)
|
|
4445
|
+
outcome = classifyEngineStatus(result.stdout);
|
|
4446
|
+
}
|
|
4447
|
+
catch {
|
|
4448
|
+
outcome = "unreadable";
|
|
4449
|
+
}
|
|
4450
|
+
if (outcome === "clean") {
|
|
4451
|
+
preview.health_check_needed = false;
|
|
4452
|
+
}
|
|
4453
|
+
else {
|
|
4454
|
+
preview.health_check_needed = true;
|
|
4455
|
+
preview.health_check_reason = outcome === "dirty" ? "engine_paths_changed" : "git_status_unreadable";
|
|
4456
|
+
}
|
|
4457
|
+
}
|
|
3514
4458
|
export const DRIVE_EPIC_ACCESS_REFUSAL_REASON_IDS = {
|
|
3515
4459
|
"profile-unusable": "access-profile-unusable",
|
|
3516
4460
|
"target-missing": "access-target-missing",
|
|
@@ -3521,7 +4465,7 @@ export const DRIVE_EPIC_ACCESS_REFUSAL_REASON_IDS = {
|
|
|
3521
4465
|
"credentials-unavailable": "access-credentials-unavailable",
|
|
3522
4466
|
"credential-unbound": "access-credential-unbound",
|
|
3523
4467
|
};
|
|
3524
|
-
const WORKER_DATABASE_PREVIEW_IDS = ["worker-db-role", "worker-db-boundary"
|
|
4468
|
+
const WORKER_DATABASE_PREVIEW_IDS = ["worker-db-role", "worker-db-boundary"];
|
|
3525
4469
|
function nonBridgeRows(ids) {
|
|
3526
4470
|
return ids.map((id) => {
|
|
3527
4471
|
const started = monotonicNow();
|
|
@@ -3541,24 +4485,32 @@ export function previewLaunchRows(checks) {
|
|
|
3541
4485
|
blocking: check.blocking,
|
|
3542
4486
|
...(check.detail ? { detail: check.detail } : {}),
|
|
3543
4487
|
...(check.remediation ? { remedy: check.remediation } : {}),
|
|
3544
|
-
...harnessOwnerMetadata(check),
|
|
3545
4488
|
};
|
|
3546
4489
|
});
|
|
3547
4490
|
}
|
|
3548
|
-
/** BAPI-1558 — carry typed owner roles through the allowlist, for the harness row only, revalidated. */
|
|
3549
|
-
function harnessOwnerMetadata(check) {
|
|
3550
|
-
if (check.id !== "worker-db-harness")
|
|
3551
|
-
return {};
|
|
3552
|
-
const roles = sanitizeOwnerRoles(check.owner_roles);
|
|
3553
|
-
const coverage = sanitizeHarnessCoverage(check.harness_coverage);
|
|
3554
|
-
return {
|
|
3555
|
-
...(roles.length > 0 ? { owner_roles: roles, owner_role_total: sanitizeOwnerRoleTotal(check.owner_role_total, roles.length) } : {}),
|
|
3556
|
-
...(coverage ? { harness_coverage: coverage } : {}),
|
|
3557
|
-
};
|
|
3558
|
-
}
|
|
3559
4491
|
/** The readiness reason a preview reports for a generic not-ready engine. */
|
|
3560
4492
|
const ENGINE_NOT_READY_REASON_ID = "engine-not-ready";
|
|
3561
4493
|
const ENGINE_NOT_READY_REMEDY = `Resolve Epic Implementer readiness (\`${PRINTED_CONDUCTOR_INSTALL_COMMAND}\`, then \`${PRINTED_DOCTOR_COMMAND}\`) and run drive-epic again. ${PRINTED_CHECK_NAME_INSTRUCTION} See ${CONSUMER_GUIDE_POINTER}.`;
|
|
4494
|
+
const CREATE_POLICY_PROJECTION_KEYS = [
|
|
4495
|
+
"posture",
|
|
4496
|
+
"v2_auto_merge_enabled",
|
|
4497
|
+
"merge_execution_mode",
|
|
4498
|
+
"integration_preparation",
|
|
4499
|
+
];
|
|
4500
|
+
/** Structural check only: an object carrying exactly the four projection keys. */
|
|
4501
|
+
function readCreatePolicyEnvelope(value) {
|
|
4502
|
+
if (value === undefined)
|
|
4503
|
+
return { kind: "absent" };
|
|
4504
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
4505
|
+
return { kind: "malformed" };
|
|
4506
|
+
const record = value;
|
|
4507
|
+
const keys = Object.keys(record);
|
|
4508
|
+
if (keys.length !== CREATE_POLICY_PROJECTION_KEYS.length ||
|
|
4509
|
+
!CREATE_POLICY_PROJECTION_KEYS.every((key) => Object.prototype.hasOwnProperty.call(record, key))) {
|
|
4510
|
+
return { kind: "malformed" };
|
|
4511
|
+
}
|
|
4512
|
+
return { kind: "present", policy: record };
|
|
4513
|
+
}
|
|
3562
4514
|
/**
|
|
3563
4515
|
* Read exactly one well-shaped setup-epic dry-run JSON document out of captured
|
|
3564
4516
|
* `log` output. Anything else — none, several, or one with the wrong shape — is
|
|
@@ -3615,7 +4567,15 @@ function readSetupPreviewPayload(stdout) {
|
|
|
3615
4567
|
const jobTimeouts = numericMap(facts.job_timeouts);
|
|
3616
4568
|
if (caps === undefined || jobTimeouts === undefined)
|
|
3617
4569
|
return null;
|
|
4570
|
+
// BAPI-1581 — strict when present (an integer 1-4 or "server_default"); an
|
|
4571
|
+
// absent field is older setup output and stays absent.
|
|
4572
|
+
const rawParallel = facts.parallel_limit;
|
|
4573
|
+
if (rawParallel !== undefined &&
|
|
4574
|
+
rawParallel !== "server_default" &&
|
|
4575
|
+
!(typeof rawParallel === "number" && Number.isInteger(rawParallel) && rawParallel >= 1 && rawParallel <= 4))
|
|
4576
|
+
return null;
|
|
3618
4577
|
effectivePolicy = {
|
|
4578
|
+
...(rawParallel !== undefined ? { parallel_limit: rawParallel } : {}),
|
|
3619
4579
|
source: facts.source,
|
|
3620
4580
|
serial_execution: "serial",
|
|
3621
4581
|
posture: facts.posture,
|
|
@@ -3640,16 +4600,95 @@ function readSetupPreviewPayload(stdout) {
|
|
|
3640
4600
|
catch {
|
|
3641
4601
|
return null;
|
|
3642
4602
|
} })(),
|
|
4603
|
+
serverPlanHash: typeof doc.server_plan_hash === "string" && /^[A-Za-z0-9:_-]{8,128}$/.test(doc.server_plan_hash)
|
|
4604
|
+
? doc.server_plan_hash
|
|
4605
|
+
: null,
|
|
4606
|
+
createPolicy: readCreatePolicyEnvelope(doc.create_policy),
|
|
3643
4607
|
};
|
|
3644
4608
|
}
|
|
3645
|
-
/** The
|
|
3646
|
-
async function
|
|
4609
|
+
/** The node count and the valid ticket keys in file order, or `null` unless the DAG has `{ nodes: [...] }`. */
|
|
4610
|
+
async function readPlanDagChildren(deps, planPath) {
|
|
3647
4611
|
try {
|
|
3648
4612
|
const parsed = JSON.parse(await deps.readPlanDag(planPath));
|
|
3649
4613
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
3650
4614
|
return null;
|
|
3651
4615
|
const nodes = parsed.nodes;
|
|
3652
|
-
|
|
4616
|
+
if (!Array.isArray(nodes))
|
|
4617
|
+
return null;
|
|
4618
|
+
const keys = [];
|
|
4619
|
+
for (const node of nodes) {
|
|
4620
|
+
const key = node !== null && typeof node === "object" ? node.ticket_key : undefined;
|
|
4621
|
+
if (typeof key === "string" && EPIC_KEY_PATTERN.test(key))
|
|
4622
|
+
keys.push(key);
|
|
4623
|
+
}
|
|
4624
|
+
return { count: nodes.length, keys };
|
|
4625
|
+
}
|
|
4626
|
+
catch {
|
|
4627
|
+
return null;
|
|
4628
|
+
}
|
|
4629
|
+
}
|
|
4630
|
+
/**
|
|
4631
|
+
* BAPI-1621 — serve a generated preview's plan from memory.
|
|
4632
|
+
*
|
|
4633
|
+
* Every preview read of the plan goes through `readPlanDag`, setup-epic's dry
|
|
4634
|
+
* run, or `withPlanPath` (the trimmed copy when merged children are skipped).
|
|
4635
|
+
* This overlay answers all three for `planPath` without touching the disk, so a
|
|
4636
|
+
* generated preview stays completely read-only. Every other path reads as before.
|
|
4637
|
+
*/
|
|
4638
|
+
function withInlinePlan(deps, planPath, json) {
|
|
4639
|
+
const files = new Map([[planPath, json]]);
|
|
4640
|
+
const inner = deps.withPlanPath ?? withPlanPath;
|
|
4641
|
+
const inMemoryWithPlanPath = async (options, callback) => {
|
|
4642
|
+
if (!options.skipped || options.originalPath !== planPath)
|
|
4643
|
+
return inner(options, callback);
|
|
4644
|
+
const trimmedPath = planPath.replace(/\.json$/, ".trimmed.json");
|
|
4645
|
+
files.set(trimmedPath, options.trimmedJson);
|
|
4646
|
+
try {
|
|
4647
|
+
return await callback(trimmedPath);
|
|
4648
|
+
}
|
|
4649
|
+
finally {
|
|
4650
|
+
files.delete(trimmedPath);
|
|
4651
|
+
}
|
|
4652
|
+
};
|
|
4653
|
+
return {
|
|
4654
|
+
...deps,
|
|
4655
|
+
readPlanDag: (filePath) => {
|
|
4656
|
+
const inline = files.get(filePath);
|
|
4657
|
+
return inline !== undefined ? Promise.resolve(inline) : deps.readPlanDag(filePath);
|
|
4658
|
+
},
|
|
4659
|
+
previewSetupEpic: (args) => deps.previewSetupEpic({ ...args, planContents: files }),
|
|
4660
|
+
withPlanPath: inMemoryWithPlanPath,
|
|
4661
|
+
};
|
|
4662
|
+
}
|
|
4663
|
+
/**
|
|
4664
|
+
* BAPI-1621 — a found generated plan's nodes for the launch screen, read from the
|
|
4665
|
+
* DAG on disk. Null when the file cannot be read or is not a node list; the
|
|
4666
|
+
* preview's own validation stays the authority on the plan.
|
|
4667
|
+
*/
|
|
4668
|
+
async function readGeneratedPlanNodes(deps, planPath) {
|
|
4669
|
+
try {
|
|
4670
|
+
const parsed = JSON.parse(await deps.readPlanDag(planPath));
|
|
4671
|
+
const nodes = parsed?.nodes;
|
|
4672
|
+
if (!Array.isArray(nodes))
|
|
4673
|
+
return null;
|
|
4674
|
+
const result = [];
|
|
4675
|
+
for (const raw of nodes) {
|
|
4676
|
+
const node = raw;
|
|
4677
|
+
if (typeof node?.ticket_key !== "string" || !EPIC_KEY_PATTERN.test(node.ticket_key))
|
|
4678
|
+
return null;
|
|
4679
|
+
if (node.status !== "planned" && node.status !== "done")
|
|
4680
|
+
return null;
|
|
4681
|
+
const dependsOn = Array.isArray(node.depends_on) ? node.depends_on : [];
|
|
4682
|
+
if (!dependsOn.every((dep) => typeof dep === "string" && EPIC_KEY_PATTERN.test(dep)))
|
|
4683
|
+
return null;
|
|
4684
|
+
result.push({
|
|
4685
|
+
ticket_key: node.ticket_key,
|
|
4686
|
+
status: node.status,
|
|
4687
|
+
depends_on: dependsOn,
|
|
4688
|
+
...(Array.isArray(node.touched_files) ? { touched_files: node.touched_files.filter((f) => typeof f === "string") } : {}),
|
|
4689
|
+
});
|
|
4690
|
+
}
|
|
4691
|
+
return result;
|
|
3653
4692
|
}
|
|
3654
4693
|
catch {
|
|
3655
4694
|
return null;
|
|
@@ -3704,12 +4743,21 @@ async function runDriveEpicPreview(deps, options) {
|
|
|
3704
4743
|
*/
|
|
3705
4744
|
const refuseWithReadiness = (kind, named, _alsoTopLevel = false) => {
|
|
3706
4745
|
preview.readiness = { kind, reason_id: named.reasonId, remedy: named.remedy };
|
|
3707
|
-
|
|
4746
|
+
// BAPI-1596: `operator_blocked` is the classification that rests on proven evidence.
|
|
4747
|
+
preview.refusal = {
|
|
4748
|
+
reason_id: named.reasonId,
|
|
4749
|
+
remedy: named.remedy,
|
|
4750
|
+
...(kind === "operator_blocked" ? { authoritative: true } : {}),
|
|
4751
|
+
};
|
|
3708
4752
|
preview.decision = "refuse";
|
|
3709
4753
|
};
|
|
3710
4754
|
/** A refusal that is not about readiness: only the top-level block carries it. */
|
|
3711
4755
|
const refuseTopLevel = (named) => {
|
|
3712
|
-
preview.refusal = {
|
|
4756
|
+
preview.refusal = {
|
|
4757
|
+
reason_id: named.reasonId,
|
|
4758
|
+
remedy: named.remedy,
|
|
4759
|
+
...(named.authoritative === true ? { authoritative: true } : {}),
|
|
4760
|
+
};
|
|
3713
4761
|
preview.decision = "refuse";
|
|
3714
4762
|
};
|
|
3715
4763
|
// The readiness read previewDecision observed, for the reachability row. It stays
|
|
@@ -3728,10 +4776,13 @@ async function runDriveEpicPreview(deps, options) {
|
|
|
3728
4776
|
});
|
|
3729
4777
|
}
|
|
3730
4778
|
ensureRefusalExplained(preview);
|
|
4779
|
+
await writePreviewLaunchContext(deps, options, preview, observed);
|
|
3731
4780
|
if (observed.repository?.isBridge === false && !preview.launch_checks?.some((row) => row.id === "plane-snapshot-freshness")) {
|
|
3732
4781
|
preview.launch_checks = [...(preview.launch_checks ?? []), ...nonBridgeRows(["plane-snapshot-freshness", "plane-database-head"])];
|
|
3733
4782
|
}
|
|
3734
|
-
|
|
4783
|
+
// Each probe writes to a private copy. `tally_lines` and `warnings` start empty on a copy
|
|
4784
|
+
// (a shared array would double-count; an absent one would be lost) and are merged back below.
|
|
4785
|
+
const isolated = () => ({ ...preview, launch_checks: [], tally_lines: undefined, warnings: undefined });
|
|
3735
4786
|
const worker = isolated();
|
|
3736
4787
|
const escalation = isolated();
|
|
3737
4788
|
const executor = isolated();
|
|
@@ -3740,15 +4791,23 @@ async function runDriveEpicPreview(deps, options) {
|
|
|
3740
4791
|
if (scopeBase)
|
|
3741
4792
|
previewScopeBaseBranch.set(needs, scopeBase);
|
|
3742
4793
|
// Collect into private arrays; only launch-needs waits for the worker result.
|
|
3743
|
-
|
|
4794
|
+
// BAPI-1596 — the boundary follows the configured mode, from the readiness this preview
|
|
4795
|
+
// already holds (the same projection the launch-context file stores). No extra read.
|
|
4796
|
+
const applicability = resolveWorkerDatabaseApplicability({
|
|
4797
|
+
declaration: projectWorkerDatabase(observed.readiness?.gate_profile?.worker_database),
|
|
4798
|
+
validContext: observed.readiness !== null,
|
|
4799
|
+
isBridge: observed.repository?.isBridge,
|
|
4800
|
+
});
|
|
4801
|
+
const workerTask = timed("worker_database_ms", () => appendWorkerDatabaseAdvisoryRows(deps, worker, observed.repository, applicability));
|
|
3744
4802
|
const needsTask = workerTask.then((section) => {
|
|
3745
4803
|
needs.launch_checks = [...(worker.launch_checks ?? [])];
|
|
3746
|
-
return timed("launch_needs_ms", () => appendLaunchNeedRows(deps, needs, observed, section));
|
|
4804
|
+
return timed("launch_needs_ms", () => appendLaunchNeedRows(deps, needs, observed, section, applicability));
|
|
3747
4805
|
});
|
|
3748
4806
|
await Promise.all([
|
|
3749
4807
|
needsTask,
|
|
4808
|
+
timed("health_status_ms", () => appendHealthCheckFact(deps, preview, observed.repository)),
|
|
3750
4809
|
timed("escalation_ms", async () => { appendEscalationReachabilityRow(escalation, observed.readiness); }),
|
|
3751
|
-
timed("executor_build_ms", () => appendExecutorBuildFreshnessWarning(deps, executor)),
|
|
4810
|
+
timed("executor_build_ms", () => appendExecutorBuildFreshnessWarning(deps, executor, observed.repository)),
|
|
3752
4811
|
]);
|
|
3753
4812
|
const workerIds = new Set(worker.launch_checks?.map((row) => row.id));
|
|
3754
4813
|
const needRows = needs.launch_checks ?? [];
|
|
@@ -3757,14 +4816,21 @@ async function runDriveEpicPreview(deps, options) {
|
|
|
3757
4816
|
...(escalation.launch_checks ?? []), ...(executor.launch_checks ?? []),
|
|
3758
4817
|
...needRows.filter((row) => !workerIds.has(row.id)),
|
|
3759
4818
|
];
|
|
3760
|
-
|
|
4819
|
+
mergeIsolatedObservations(preview, escalation, [worker, escalation, executor, needs]);
|
|
4820
|
+
// BAPI-1596 — the plan is built once, from the finished preview, and only for a create
|
|
4821
|
+
// or a refusal the preview selected as authoritative. A failure leaves no plan; the
|
|
4822
|
+
// session then shows the plain older-CLI screen and computes nothing.
|
|
4823
|
+
if (preview.decision === "create" || (preview.decision === "refuse" && preview.refusal?.authoritative === true)) {
|
|
3761
4824
|
try {
|
|
3762
|
-
const
|
|
4825
|
+
const collected = await collectLaunchPlanFacts(deps, options, preview, observed);
|
|
4826
|
+
// The tally lines do not depend on the builder succeeding.
|
|
4827
|
+
recordLaunchPlanObservations(preview, collected.tally);
|
|
4828
|
+
const result = (deps.buildLaunchPlan ?? buildLaunchPlan)(preview, collected.facts);
|
|
3763
4829
|
if (result)
|
|
3764
4830
|
preview.launch_plan = result.launch_plan;
|
|
3765
4831
|
}
|
|
3766
4832
|
catch {
|
|
3767
|
-
deps.errorLog("Launch plan unavailable; the
|
|
4833
|
+
deps.errorLog("Launch plan unavailable; the preview carries no plan.");
|
|
3768
4834
|
}
|
|
3769
4835
|
}
|
|
3770
4836
|
timings.total_ms = elapsedMs(started);
|
|
@@ -3775,6 +4841,160 @@ async function runDriveEpicPreview(deps, options) {
|
|
|
3775
4841
|
return 1;
|
|
3776
4842
|
return preview.decision === "create" || preview.decision === "attach" ? 0 : 1;
|
|
3777
4843
|
}
|
|
4844
|
+
/** The plan's child keys per preview, in file order. Kept off the document. */
|
|
4845
|
+
const previewPlanChildKeys = new WeakMap();
|
|
4846
|
+
/** The most time a launch preview spends reading the prerequisite cache before it carries on without it. */
|
|
4847
|
+
const PREREQUISITE_CACHE_READ_TIMEOUT_MS = 10_000;
|
|
4848
|
+
const PREREQUISITE_ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
|
|
4849
|
+
function handoffValueText(value) {
|
|
4850
|
+
return value === "unknown" ? "unknown (today's default: proceed)" : value;
|
|
4851
|
+
}
|
|
4852
|
+
/**
|
|
4853
|
+
* BAPI-1596 — collect the launch plan's facts ONCE, from evidence the preview already
|
|
4854
|
+
* holds. The only new reads are the injected cache read and a boolean-only presence
|
|
4855
|
+
* check per distinct core variable name. Nothing here reads an environment value,
|
|
4856
|
+
* refuses, or changes a decision; unavailable evidence is tallied and the launch goes on.
|
|
4857
|
+
*/
|
|
4858
|
+
async function collectLaunchPlanFacts(deps, options, preview, observed) {
|
|
4859
|
+
const tally = [];
|
|
4860
|
+
// The hand-off policy this launch will stamp, and the project default beside it.
|
|
4861
|
+
const reported = observed.readiness?.gate_profile?.verification_handoff_default;
|
|
4862
|
+
const projectDefault = reported === "proceed" || reported === "block" ? reported : "unknown";
|
|
4863
|
+
const explicit = options.verificationHandoff === "proceed" || options.verificationHandoff === "block"
|
|
4864
|
+
? options.verificationHandoff
|
|
4865
|
+
: null;
|
|
4866
|
+
const handoff = { explicit, projectDefault };
|
|
4867
|
+
const effective = explicit ?? projectDefault;
|
|
4868
|
+
const source = explicit !== null ? "explicit choice"
|
|
4869
|
+
: projectDefault !== "unknown" ? "project default"
|
|
4870
|
+
: observed.readiness === null ? "readiness not read" : "older server, no default reported";
|
|
4871
|
+
tally.push({
|
|
4872
|
+
code: "verification_handoff_policy",
|
|
4873
|
+
line: `verification hand-off: ${handoffValueText(effective)} (${source}); project default ${handoffValueText(projectDefault)}`,
|
|
4874
|
+
});
|
|
4875
|
+
// Child 5's cache, for the children this launch will actually run.
|
|
4876
|
+
let prerequisites = { status: "not_collected" };
|
|
4877
|
+
const keys = previewPlanChildKeys.get(preview);
|
|
4878
|
+
if (deps.readPrerequisiteCache !== undefined && keys !== undefined) {
|
|
4879
|
+
const skipped = new Set();
|
|
4880
|
+
const merged = preview.already_done_children;
|
|
4881
|
+
if (merged !== undefined && merged.status === "checked") {
|
|
4882
|
+
for (const child of merged.children)
|
|
4883
|
+
if (child.will_skip === true)
|
|
4884
|
+
skipped.add(child.ticket_key);
|
|
4885
|
+
}
|
|
4886
|
+
const members = new Set(keys.filter((key) => !skipped.has(key)));
|
|
4887
|
+
let read;
|
|
4888
|
+
try {
|
|
4889
|
+
read = observed.contextAccess === undefined
|
|
4890
|
+
? { kind: "unavailable" }
|
|
4891
|
+
: await deps.readPrerequisiteCache({ epicKey: options.epicKey, children: keys, access: observed.contextAccess });
|
|
4892
|
+
}
|
|
4893
|
+
catch {
|
|
4894
|
+
read = { kind: "unavailable" };
|
|
4895
|
+
}
|
|
4896
|
+
if (read.kind === "unavailable") {
|
|
4897
|
+
tally.push({ code: "prerequisite_cache_unavailable", line: "prerequisite scan: cache not read at preview" });
|
|
4898
|
+
}
|
|
4899
|
+
else {
|
|
4900
|
+
const hasEnv = deps.hasEnvName ?? ((name) => Object.hasOwn(process.env, name));
|
|
4901
|
+
const presence = new Map();
|
|
4902
|
+
const missing = new Map();
|
|
4903
|
+
const runtimeChildren = new Set();
|
|
4904
|
+
const kept = { minor: 0, "observed present": 0, "worker runtime": 0, "not measurable": 0, skipped: 0 };
|
|
4905
|
+
for (const entry of read.entries) {
|
|
4906
|
+
if (!members.has(entry.child)) {
|
|
4907
|
+
kept.skipped += entry.items.length;
|
|
4908
|
+
continue;
|
|
4909
|
+
}
|
|
4910
|
+
for (const item of entry.items) {
|
|
4911
|
+
if ("category" in item) {
|
|
4912
|
+
kept["worker runtime"] += 1;
|
|
4913
|
+
runtimeChildren.add(entry.child);
|
|
4914
|
+
continue;
|
|
4915
|
+
}
|
|
4916
|
+
if ("measurable" in item) {
|
|
4917
|
+
kept["not measurable"] += 1;
|
|
4918
|
+
continue;
|
|
4919
|
+
}
|
|
4920
|
+
if (item.class !== "core") {
|
|
4921
|
+
kept.minor += 1;
|
|
4922
|
+
continue;
|
|
4923
|
+
}
|
|
4924
|
+
if (!PREREQUISITE_ENV_NAME.test(item.env)) {
|
|
4925
|
+
kept["not measurable"] += 1;
|
|
4926
|
+
continue;
|
|
4927
|
+
}
|
|
4928
|
+
if (!presence.has(item.env))
|
|
4929
|
+
presence.set(item.env, hasEnv(item.env));
|
|
4930
|
+
if (presence.get(item.env) === true) {
|
|
4931
|
+
kept["observed present"] += 1;
|
|
4932
|
+
continue;
|
|
4933
|
+
}
|
|
4934
|
+
const mapKey = `${item.env}:${item.uncertain}`;
|
|
4935
|
+
const prior = missing.get(mapKey);
|
|
4936
|
+
missing.set(mapKey, prior === undefined
|
|
4937
|
+
? { name: item.env, requirement: item.requirement, dependents: item.dependents, uncertain: item.uncertain === "yes" }
|
|
4938
|
+
: { ...prior, dependents: prior.dependents.split(", ").includes(item.dependents) ? prior.dependents : `${prior.dependents}, ${item.dependents}` });
|
|
4939
|
+
}
|
|
4940
|
+
}
|
|
4941
|
+
for (const [category, count] of Object.entries(kept)) {
|
|
4942
|
+
if (count > 0)
|
|
4943
|
+
tally.push({ code: "prerequisite_kept_off_screen", line: `prerequisite scan: kept off the screen: ${category} ${count}` });
|
|
4944
|
+
}
|
|
4945
|
+
prerequisites = {
|
|
4946
|
+
status: "collected",
|
|
4947
|
+
missingCore: [...missing.values()],
|
|
4948
|
+
workerRuntimeChildren: [...runtimeChildren],
|
|
4949
|
+
};
|
|
4950
|
+
}
|
|
4951
|
+
}
|
|
4952
|
+
// Launch rows the screen leaves out, so nothing is silent.
|
|
4953
|
+
const suppressed = [];
|
|
4954
|
+
// Server rows that only warn (for example an unset integration branch) never reach the screen;
|
|
4955
|
+
// the webhook row is the one warning the plan presents.
|
|
4956
|
+
for (const row of preview.prerequisites ?? []) {
|
|
4957
|
+
if (row.impact === "warning" && row.check_status === "not_met" && row.id !== SERVER_WEBHOOK_ROW_ID) {
|
|
4958
|
+
suppressed.push(row.id.replace(/^server\./, ""));
|
|
4959
|
+
}
|
|
4960
|
+
}
|
|
4961
|
+
// Rows the plan presents are the three launch needs and the proven boundary; any other
|
|
4962
|
+
// warning or failing launch row stays in the preview's rows and is named here.
|
|
4963
|
+
const PRESENTED_ROWS = new Set([...Object.values(LAUNCH_NEED_ROW_IDS), "worker-db-boundary"]);
|
|
4964
|
+
for (const row of preview.launch_checks ?? []) {
|
|
4965
|
+
if ((row.status === "warn" || row.status === "fail") && !PRESENTED_ROWS.has(row.id) &&
|
|
4966
|
+
row.id !== ESCALATION_REACHABILITY_CHECK_ID) {
|
|
4967
|
+
suppressed.push(row.id);
|
|
4968
|
+
}
|
|
4969
|
+
}
|
|
4970
|
+
if (suppressed.length > 0) {
|
|
4971
|
+
tally.push({ code: "launch_rows_kept_off_screen", line: `launch rows kept off the screen: ${[...new Set(suppressed)].join(", ")}` });
|
|
4972
|
+
}
|
|
4973
|
+
return { facts: { prerequisites, handoff }, tally };
|
|
4974
|
+
}
|
|
4975
|
+
/** Append the collected fixed lines to the preview's tally lines, once each. */
|
|
4976
|
+
function recordLaunchPlanObservations(preview, lines) {
|
|
4977
|
+
if (lines.length === 0)
|
|
4978
|
+
return;
|
|
4979
|
+
const seen = new Set((preview.tally_lines ?? []).map((entry) => `${entry.code}\u0000${entry.line}`));
|
|
4980
|
+
const fresh = lines.filter((entry) => !seen.has(`${entry.code}\u0000${entry.line}`));
|
|
4981
|
+
if (fresh.length > 0)
|
|
4982
|
+
preview.tally_lines = [...(preview.tally_lines ?? []), ...fresh];
|
|
4983
|
+
}
|
|
4984
|
+
/** Fold the private copies' tally lines, warnings, and escalation presentation back into the preview. */
|
|
4985
|
+
function mergeIsolatedObservations(preview, escalation, parts) {
|
|
4986
|
+
for (const part of parts) {
|
|
4987
|
+
if (part.tally_lines !== undefined && part.tally_lines.length > 0) {
|
|
4988
|
+
preview.tally_lines = [...(preview.tally_lines ?? []), ...part.tally_lines];
|
|
4989
|
+
}
|
|
4990
|
+
if (part.warnings !== undefined && part.warnings.length > 0) {
|
|
4991
|
+
preview.warnings = [...(preview.warnings ?? []), ...part.warnings];
|
|
4992
|
+
}
|
|
4993
|
+
}
|
|
4994
|
+
const presentation = previewEscalationPresentation.get(escalation);
|
|
4995
|
+
if (presentation !== undefined)
|
|
4996
|
+
previewEscalationPresentation.set(preview, presentation);
|
|
4997
|
+
}
|
|
3778
4998
|
/**
|
|
3779
4999
|
* Give every `create` or `attach` preview exactly one non-blocking
|
|
3780
5000
|
* `escalation-reachability` row (BAPI-1490).
|
|
@@ -3785,13 +5005,40 @@ async function runDriveEpicPreview(deps, options) {
|
|
|
3785
5005
|
* read failure) is passed as unavailable, so the row warns rather than vanishing.
|
|
3786
5006
|
* A refused or stopped preview describes no launch, so it gets none.
|
|
3787
5007
|
*/
|
|
5008
|
+
/** BAPI-1595 — what each preview's reachability output may claim. Kept off the JSON document. */
|
|
5009
|
+
const previewEscalationPresentation = new WeakMap();
|
|
3788
5010
|
function appendEscalationReachabilityRow(preview, readiness) {
|
|
3789
5011
|
const started = monotonicNow();
|
|
3790
5012
|
if (preview.decision !== "create" && preview.decision !== "attach")
|
|
3791
5013
|
return;
|
|
5014
|
+
// BAPI-1598 — fixed tally lines for the worker-database and hand-off settings the
|
|
5015
|
+
// readiness already reported. An older server reports neither, so nothing is added.
|
|
5016
|
+
for (const entry of workerSetupTallyEntries(readiness?.gate_profile)) {
|
|
5017
|
+
(preview.tally_lines ??= []).push({ code: entry.code, line: entry.message });
|
|
5018
|
+
}
|
|
3792
5019
|
const [row] = previewLaunchRows([
|
|
3793
5020
|
buildEscalationReachabilityCheck(readiness, preview.summary.escalation_channel),
|
|
3794
5021
|
]);
|
|
5022
|
+
// BAPI-1595 — decide what the output may SAY. The JSON row stays (an older reader
|
|
5023
|
+
// and the launch plan treat an absent row as "unconfirmed"); the human line is
|
|
5024
|
+
// shown only when it is true, and a left-out line is written to the tally once.
|
|
5025
|
+
const presentation = classifyEscalationReachabilityPresentation(readiness, preview.summary.escalation_channel);
|
|
5026
|
+
previewEscalationPresentation.set(preview, presentation);
|
|
5027
|
+
if (presentation === "uncertain") {
|
|
5028
|
+
(preview.warnings ??= []).push(ESCALATION_CHANNEL_UNCERTAIN_WARNING);
|
|
5029
|
+
}
|
|
5030
|
+
if (presentation === "uncertain" || presentation === "omitted") {
|
|
5031
|
+
(preview.tally_lines ??= []).push({
|
|
5032
|
+
code: ESCALATION_LINE_SUPPRESSED_REASON_CODE,
|
|
5033
|
+
line: ESCALATION_LINE_SUPPRESSED_LINE,
|
|
5034
|
+
});
|
|
5035
|
+
}
|
|
5036
|
+
if (presentation === "uncertain") {
|
|
5037
|
+
(preview.tally_lines ??= []).push({
|
|
5038
|
+
code: ESCALATION_CHANNEL_UNCERTAIN_REASON_CODE,
|
|
5039
|
+
line: ESCALATION_CHANNEL_UNCERTAIN_WARNING,
|
|
5040
|
+
});
|
|
5041
|
+
}
|
|
3795
5042
|
preview.launch_checks = [
|
|
3796
5043
|
...(preview.launch_checks ?? []).filter((existing) => existing.id !== ESCALATION_REACHABILITY_CHECK_ID),
|
|
3797
5044
|
{ ...row, duration_ms: elapsedMs(started) },
|
|
@@ -3805,7 +5052,7 @@ function appendEscalationReachabilityRow(preview, readiness) {
|
|
|
3805
5052
|
* missing dependency leaves `launch_checks` untouched. A thrown check prints one
|
|
3806
5053
|
* fixed line and nothing from the exception.
|
|
3807
5054
|
*/
|
|
3808
|
-
async function appendExecutorBuildFreshnessWarning(deps, preview) {
|
|
5055
|
+
async function appendExecutorBuildFreshnessWarning(deps, preview, repository) {
|
|
3809
5056
|
const started = monotonicNow();
|
|
3810
5057
|
const override = process.env[BRIDGE_LAUNCHER_ENV];
|
|
3811
5058
|
if (override === undefined || override.trim() === "")
|
|
@@ -3813,7 +5060,7 @@ async function appendExecutorBuildFreshnessWarning(deps, preview) {
|
|
|
3813
5060
|
if (deps.checkExecutorBuildFreshness === undefined)
|
|
3814
5061
|
return;
|
|
3815
5062
|
try {
|
|
3816
|
-
const report = await deps.checkExecutorBuildFreshness(deps.cwd());
|
|
5063
|
+
const report = await deps.checkExecutorBuildFreshness(deps.cwd(), repository?.isBridge === false ? { isBridge: false } : undefined);
|
|
3817
5064
|
if (report.diagnostic === null)
|
|
3818
5065
|
return;
|
|
3819
5066
|
const outcome = report.outcomes.find((entry) => entry.status === "warn" || entry.status === "fail") ?? report.outcomes[0];
|
|
@@ -3837,6 +5084,70 @@ async function appendExecutorBuildFreshnessWarning(deps, preview) {
|
|
|
3837
5084
|
* preview document so its JSON shape is unchanged.
|
|
3838
5085
|
*/
|
|
3839
5086
|
const previewScopeBaseBranch = new WeakMap();
|
|
5087
|
+
/** BAPI-1601 — why an `unavailable` auto-merge intent has nothing to show. Print-only. */
|
|
5088
|
+
const previewAutoMergeUnavailableReason = new WeakMap();
|
|
5089
|
+
/** The one human auto-merge line, worded exactly as setup-epic words it. */
|
|
5090
|
+
function autoMergeLine(preview) {
|
|
5091
|
+
const merge = preview.summary.auto_merge;
|
|
5092
|
+
if (merge === undefined)
|
|
5093
|
+
return " Auto-merge: n/a";
|
|
5094
|
+
if (merge.state === "unavailable") {
|
|
5095
|
+
return previewAutoMergeUnavailableReason.get(preview) === "invalid"
|
|
5096
|
+
? " Auto-merge: unavailable (the policy does not declare a valid auto-merge setting)"
|
|
5097
|
+
: " Auto-merge: unavailable (older setup-epic output)";
|
|
5098
|
+
}
|
|
5099
|
+
const intent = merge.state === "on" ? { state: "on" } : { state: "off", reason: merge.reason ?? "" };
|
|
5100
|
+
return ` ${formatSetupEpicAutoMergeIntent(intent, preview.summary.branch ?? undefined)}`;
|
|
5101
|
+
}
|
|
5102
|
+
/** BAPI-1593 — the plan digest setup-epic's dry run says the SERVER validated, per preview. */
|
|
5103
|
+
const previewServerPlanDigest = new WeakMap();
|
|
5104
|
+
/**
|
|
5105
|
+
* BAPI-1593 — write the launch-context file from what the preview already
|
|
5106
|
+
* established. It issues no request: the readiness result is the acquisition's
|
|
5107
|
+
* latest completed attempt, read without spending a retry. A failure is one
|
|
5108
|
+
* warning and a `launch_context_write_failed` observation, never a refusal.
|
|
5109
|
+
*/
|
|
5110
|
+
async function writePreviewLaunchContext(deps, options, preview, observed) {
|
|
5111
|
+
if (deps.writeLaunchContext === undefined || observed.acquisition === undefined)
|
|
5112
|
+
return;
|
|
5113
|
+
const readiness = observed.acquisition.peek();
|
|
5114
|
+
// BAPI-1595 — the base branch the launch will bind to. Setup's dry run reports it for
|
|
5115
|
+
// a branch-bearing run; for any other run (for example `--into-base`) it reports
|
|
5116
|
+
// none, so the same resolution the launch uses fills it in. Without a base on the
|
|
5117
|
+
// stored file the launch could never match it.
|
|
5118
|
+
let baseBranch = previewScopeBaseBranch.get(preview) ?? null;
|
|
5119
|
+
if (baseBranch === null && observed.contextAccess !== undefined && deps.readScopeBaseBranch !== undefined) {
|
|
5120
|
+
try {
|
|
5121
|
+
baseBranch = (await deps.readScopeBaseBranch(observed.contextAccess)) ?? null;
|
|
5122
|
+
}
|
|
5123
|
+
catch {
|
|
5124
|
+
baseBranch = null;
|
|
5125
|
+
}
|
|
5126
|
+
}
|
|
5127
|
+
const context = buildEpicLaunchContext({
|
|
5128
|
+
epicKey: options.epicKey,
|
|
5129
|
+
baseBranch,
|
|
5130
|
+
targetBaseUrl: preview.target.base_url,
|
|
5131
|
+
writtenAt: new Date((deps.now ?? Date.now)()),
|
|
5132
|
+
readiness,
|
|
5133
|
+
// BAPI-1595 — the VERIFIED local identity only. A report's own repo_name is never
|
|
5134
|
+
// substituted when the local identity is unavailable.
|
|
5135
|
+
repoName: observed.repoName ?? null,
|
|
5136
|
+
isBridge: observed.repository?.isBridge ?? null,
|
|
5137
|
+
serverPlanDigest: previewServerPlanDigest.get(preview) ?? null,
|
|
5138
|
+
});
|
|
5139
|
+
let written;
|
|
5140
|
+
try {
|
|
5141
|
+
written = await deps.writeLaunchContext(context);
|
|
5142
|
+
}
|
|
5143
|
+
catch {
|
|
5144
|
+
written = { ok: false, reason: "write_failed" };
|
|
5145
|
+
}
|
|
5146
|
+
if (!written.ok) {
|
|
5147
|
+
deps.errorLog(`${options.epicKey}: [warn] launch_context_write_failed — the launch-context file could not be ` +
|
|
5148
|
+
`written (${written.reason}); the preview is unaffected and no current context was claimed.`);
|
|
5149
|
+
}
|
|
5150
|
+
}
|
|
3840
5151
|
/** Run one probe; a missing boundary or any rejection becomes the fallback fact. */
|
|
3841
5152
|
async function guardedProbe(run, fallback) {
|
|
3842
5153
|
if (run === undefined)
|
|
@@ -3864,29 +5175,29 @@ async function collectHostPowerFact(deps, topology) {
|
|
|
3864
5175
|
return hostPowerFactFromReport(report);
|
|
3865
5176
|
}
|
|
3866
5177
|
/**
|
|
3867
|
-
* Append the
|
|
3868
|
-
* role, self-hosted runner, host power (`host-sleep`)
|
|
3869
|
-
*
|
|
5178
|
+
* Append the three launch-need rows to a `create` preview (BAPI-1506, narrowed by
|
|
5179
|
+
* BAPI-1596): worker DB role, self-hosted runner, and host power (`host-sleep`).
|
|
5180
|
+
* The usage-reset and epic-branch-behind-base needs are gone: a launch neither
|
|
5181
|
+
* probes nor shows them.
|
|
3870
5182
|
*
|
|
3871
|
-
*
|
|
3872
|
-
*
|
|
3873
|
-
*
|
|
3874
|
-
*
|
|
3875
|
-
*
|
|
3876
|
-
*
|
|
5183
|
+
* Each probe runs concurrently and is guarded on its own, so a missing boundary, a
|
|
5184
|
+
* rejection or a timeout is an `unverifiable` warning row. Rows are
|
|
5185
|
+
* `blocking: false` and NEVER change the decision, a refusal, readiness or the
|
|
5186
|
+
* exit code. An `attach`, refused or stopped preview gets none of them. The merged
|
|
5187
|
+
* `worker-db-role` warning row is decorated in place rather than duplicated. When
|
|
5188
|
+
* the project's configuration says the database does not apply (or was not
|
|
5189
|
+
* reported), the role row is `not_applicable`: the same rule as the boundary row.
|
|
3877
5190
|
*/
|
|
3878
|
-
async function appendLaunchNeedRows(deps, preview, observed, workerDatabase) {
|
|
5191
|
+
async function appendLaunchNeedRows(deps, preview, observed, workerDatabase, applicability) {
|
|
3879
5192
|
if (preview.decision !== "create")
|
|
3880
5193
|
return;
|
|
3881
5194
|
try {
|
|
3882
5195
|
const repoRoot = observed.repository?.repoRoot ?? deps.cwd();
|
|
3883
5196
|
const local = preview.target.kind === "local_plane";
|
|
3884
5197
|
const readiness = observed.readiness;
|
|
3885
|
-
const access = observed.access;
|
|
3886
|
-
const nowMs = (deps.now ?? Date.now)();
|
|
3887
5198
|
const durations = [];
|
|
3888
5199
|
const measured = (index, work) => measurePrecheck(work, (duration) => { durations[index] = duration; });
|
|
3889
|
-
const [runner, power
|
|
5200
|
+
const [runner, power] = await Promise.all([
|
|
3890
5201
|
measured(0, () => guardedProbe(deps.inspectRequiredRunners === undefined
|
|
3891
5202
|
? undefined
|
|
3892
5203
|
: () => deps.inspectRequiredRunners({
|
|
@@ -3895,32 +5206,18 @@ async function appendLaunchNeedRows(deps, preview, observed, workerDatabase) {
|
|
|
3895
5206
|
gateProfile: readiness?.gate_profile,
|
|
3896
5207
|
}), { state: "unverifiable", reason: "probe_failed" })),
|
|
3897
5208
|
measured(1, () => guardedProbe(() => collectHostPowerFact(deps, observed.launchTopology), { state: "unverifiable", reason: "probe_failed" })),
|
|
3898
|
-
measured(2, () => guardedProbe(deps.fetchUsageAdvisory === undefined || access === undefined
|
|
3899
|
-
? undefined
|
|
3900
|
-
: () => deps.fetchUsageAdvisory(access), null)),
|
|
3901
|
-
measured(3, () => guardedProbe(deps.inspectEpicBranchBehind === undefined
|
|
3902
|
-
? undefined
|
|
3903
|
-
: () => deps.inspectEpicBranchBehind({
|
|
3904
|
-
repoRoot,
|
|
3905
|
-
branch: preview.summary.branch,
|
|
3906
|
-
baseBranch: previewScopeBaseBranch.get(preview) ?? null,
|
|
3907
|
-
}), preview.summary.branch === null
|
|
3908
|
-
? { state: "not_applicable", reason: "no_epic_branch" }
|
|
3909
|
-
: { state: "unverifiable", reason: "git_failed" })),
|
|
3910
5209
|
]);
|
|
3911
|
-
|
|
3912
|
-
|
|
5210
|
+
// BAPI-1613 R6: a cold start has no readiness yet; that is not a non-Bridge checkout.
|
|
5211
|
+
const skipRow = applicability.kind === "unproven" && observed.repository?.isBridge !== false
|
|
5212
|
+
? { ...nonBridgeRows(["worker-db-role"])[0], reason: "readiness_unknown", detail: "readiness_unknown" }
|
|
5213
|
+
: nonBridgeRows(["worker-db-role"])[0];
|
|
5214
|
+
const workerRow = applicability.kind !== "inspect"
|
|
5215
|
+
? { ...skipRow, launch_need: { need: "worker_db_role", state: "not_applicable", asked: false } }
|
|
3913
5216
|
: { ...buildWorkerDbRoleLaunchRow(workerDatabase, local),
|
|
3914
5217
|
duration_ms: workerDatabase?.rows.find((row) => row.id === "worker-db-role")?.duration_ms ?? elapsedMs(monotonicNow()) };
|
|
3915
5218
|
const rows = [
|
|
3916
5219
|
buildSelfHostedRunnerLaunchRow(runner),
|
|
3917
5220
|
buildHostPowerLaunchRow(power),
|
|
3918
|
-
buildUsageResetAfterRunLaunchRow({
|
|
3919
|
-
advisory: usage ?? REPOSITORY_USAGE_ADVISORY_UNAVAILABLE,
|
|
3920
|
-
childCount: preview.summary.child_count,
|
|
3921
|
-
nowMs,
|
|
3922
|
-
}),
|
|
3923
|
-
buildEpicBranchBehindBaseLaunchRow(branch),
|
|
3924
5221
|
].map((row, index) => ({ ...row, duration_ms: durations[index] }));
|
|
3925
5222
|
const existing = preview.launch_checks ?? [];
|
|
3926
5223
|
const roleIndex = existing.findIndex((row) => row.id === workerRow.id);
|
|
@@ -4001,6 +5298,8 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
4001
5298
|
return;
|
|
4002
5299
|
}
|
|
4003
5300
|
const access = accessResult.access;
|
|
5301
|
+
observed.repoName = access.repoName;
|
|
5302
|
+
observed.contextAccess = access;
|
|
4004
5303
|
const profile = accessResult.profile ?? null;
|
|
4005
5304
|
const endpoint = planeEndpointForBaseUrl(deps, access.baseUrl);
|
|
4006
5305
|
const planeTarget = endpoint !== null;
|
|
@@ -4011,7 +5310,7 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
4011
5310
|
? { source: accessResult.targetSource }
|
|
4012
5311
|
: {}),
|
|
4013
5312
|
};
|
|
4014
|
-
|
|
5313
|
+
let ctx = {
|
|
4015
5314
|
deps,
|
|
4016
5315
|
epicKey,
|
|
4017
5316
|
options,
|
|
@@ -4021,6 +5320,7 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
4021
5320
|
targetSource: accessResult.targetSource ?? "default",
|
|
4022
5321
|
freshness: createPlaneFreshnessCache(),
|
|
4023
5322
|
launchCredential: {},
|
|
5323
|
+
liveObservation: {},
|
|
4024
5324
|
};
|
|
4025
5325
|
// Discover before readiness so a selected local plane can preview its guarded
|
|
4026
5326
|
// cold start. Keep the candidate out of ordinary failure documents.
|
|
@@ -4028,6 +5328,9 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
4028
5328
|
let plan = { status: "not_found" };
|
|
4029
5329
|
// The full discovery result, kept for the guarded plane-down stop below.
|
|
4030
5330
|
let discovery = null;
|
|
5331
|
+
// BAPI-1621 — why automatic generation stopped, and whether it read "no live run".
|
|
5332
|
+
let generationReason;
|
|
5333
|
+
let generatedLiveRunChecked = false;
|
|
4031
5334
|
let docsRootUnresolved = false;
|
|
4032
5335
|
if (planPath !== undefined) {
|
|
4033
5336
|
plan = { status: "supplied", path: planPath };
|
|
@@ -4049,16 +5352,69 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
4049
5352
|
: {}),
|
|
4050
5353
|
epic_plans_dir: discovered.epic_plans_dir,
|
|
4051
5354
|
};
|
|
4052
|
-
if (discovered.status === "found")
|
|
5355
|
+
if (discovered.status === "found") {
|
|
4053
5356
|
planPath = discovered.path;
|
|
5357
|
+
// BAPI-1621 — a found GENERATED plan shows its provenance from the files
|
|
5358
|
+
// already on disk; an authored plan's preview is unchanged.
|
|
5359
|
+
if (discovered.generated !== undefined) {
|
|
5360
|
+
plan.generated = true;
|
|
5361
|
+
const nodes = await readGeneratedPlanNodes(deps, discovered.path);
|
|
5362
|
+
if (nodes !== null)
|
|
5363
|
+
plan.generation = { nodes, summary: discovered.generated.summary };
|
|
5364
|
+
}
|
|
5365
|
+
}
|
|
5366
|
+
else if (discovered.status === "plan_not_found" && deps.attemptPlanGeneration !== undefined) {
|
|
5367
|
+
// BAPI-1621 — build in memory only. The preview writes no folder, staging
|
|
5368
|
+
// directory, temporary file, metadata, or DAG.
|
|
5369
|
+
if (!(await planGenerationAllowed(deps.discoveryFs, epicKey, discovered))) {
|
|
5370
|
+
generationReason = "discovery_blocked";
|
|
5371
|
+
}
|
|
5372
|
+
else {
|
|
5373
|
+
const attempt = await deps.attemptPlanGeneration(epicKey).catch(() => ({ kind: "failed", reason: "children_unreadable" }));
|
|
5374
|
+
if (attempt.kind === "failed") {
|
|
5375
|
+
generationReason = attempt.reason;
|
|
5376
|
+
}
|
|
5377
|
+
else if (attempt.kind === "generated" &&
|
|
5378
|
+
!(await planGenerationAllowed(deps.discoveryFs, epicKey, discovered, attempt))) {
|
|
5379
|
+
generationReason = "discovery_blocked";
|
|
5380
|
+
}
|
|
5381
|
+
else if (attempt.kind === "generated") {
|
|
5382
|
+
const folder = generatedPlanFolder(docs.docsDir, epicKey);
|
|
5383
|
+
planPath = path.join(folder, "epic-plan.dag.json");
|
|
5384
|
+
plan = {
|
|
5385
|
+
status: "generated",
|
|
5386
|
+
generated: true,
|
|
5387
|
+
inline: { nodes: attempt.dag.nodes, summary: attempt.summary },
|
|
5388
|
+
would_write: folder,
|
|
5389
|
+
...(plan.skipped !== undefined ? { skipped: plan.skipped } : {}),
|
|
5390
|
+
epic_plans_dir: discovered.epic_plans_dir,
|
|
5391
|
+
};
|
|
5392
|
+
generatedLiveRunChecked = true;
|
|
5393
|
+
ctx = { ...ctx, deps: withInlinePlan(ctx.deps, planPath, JSON.stringify(attempt.dag, null, 2) + "\n") };
|
|
5394
|
+
}
|
|
5395
|
+
}
|
|
5396
|
+
if (generationReason !== undefined)
|
|
5397
|
+
plan.generation_failure = generationReason;
|
|
5398
|
+
}
|
|
4054
5399
|
}
|
|
4055
5400
|
}
|
|
4056
5401
|
// Every later exit, refusal or not, reports the plan state as discovered.
|
|
4057
5402
|
preview.plan = plan;
|
|
4058
5403
|
// --- Readiness. -----------------------------------------------------------
|
|
4059
|
-
|
|
5404
|
+
// BAPI-1593 — ONE acquisition for this preview: at most two full reads. The
|
|
5405
|
+
// first failure is inspected on its own (a refused plane port is a cold start);
|
|
5406
|
+
// anything else spends the one retry, and a second uncertain read warns and
|
|
5407
|
+
// continues rather than refusing.
|
|
5408
|
+
const previewAcquisition = createReadinessAcquisition(() => deps.readReadiness(access), {
|
|
5409
|
+
...(deps.launchSleep !== undefined ? { sleep: deps.launchSleep } : {}),
|
|
5410
|
+
});
|
|
5411
|
+
observed.acquisition = previewAcquisition;
|
|
5412
|
+
let readiness = null;
|
|
4060
5413
|
try {
|
|
4061
|
-
|
|
5414
|
+
const first = await previewAcquisition.firstAttempt();
|
|
5415
|
+
if (first.kind !== "ready")
|
|
5416
|
+
throw first.error;
|
|
5417
|
+
readiness = first.readiness;
|
|
4062
5418
|
}
|
|
4063
5419
|
catch (err) {
|
|
4064
5420
|
if (isSchemaIncompatibleError(err)) {
|
|
@@ -4097,7 +5453,11 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
4097
5453
|
preview.readiness = { kind: "cold_start" };
|
|
4098
5454
|
await finalizeCreatePreview(ctx, preview, planPath, true, refuseTopLevel);
|
|
4099
5455
|
if (preview.decision === "create") {
|
|
4100
|
-
preview.cold_start = {
|
|
5456
|
+
preview.cold_start = {
|
|
5457
|
+
plane_endpoint: access.baseUrl,
|
|
5458
|
+
will_start_plane: true,
|
|
5459
|
+
live_run_checked: generatedLiveRunChecked,
|
|
5460
|
+
};
|
|
4101
5461
|
}
|
|
4102
5462
|
// No plane exists yet, so there is no snapshot or database to compare;
|
|
4103
5463
|
// the host-sleep advisory still applies to the plane about to start.
|
|
@@ -4122,27 +5482,62 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
4122
5482
|
if (probe.kind === "refused") {
|
|
4123
5483
|
preview.readiness = {
|
|
4124
5484
|
kind: "unknown",
|
|
4125
|
-
remedy: planeDownNoPlanStopText(epicKey, { profile, options }, discovery),
|
|
5485
|
+
remedy: planeDownNoPlanStopText(epicKey, { profile, options }, discovery, generationReason),
|
|
4126
5486
|
};
|
|
4127
5487
|
preview.refusal = null;
|
|
4128
5488
|
preview.decision = "stop";
|
|
4129
5489
|
return;
|
|
4130
5490
|
}
|
|
4131
5491
|
}
|
|
4132
|
-
|
|
5492
|
+
const settled = await previewAcquisition.result();
|
|
5493
|
+
if (settled.kind === "refused") {
|
|
5494
|
+
return refuseTopLevel({
|
|
5495
|
+
reasonId: "schema-incompatible",
|
|
5496
|
+
remedy: "Local schema incompatible: launch-critical schema objects are missing. " +
|
|
5497
|
+
`${SCHEMA_INCOMPATIBLE_REPAIR_ROUTE} Nothing was created or started.`,
|
|
5498
|
+
});
|
|
5499
|
+
}
|
|
5500
|
+
if (settled.kind === "ready")
|
|
5501
|
+
readiness = settled.readiness;
|
|
5502
|
+
}
|
|
5503
|
+
if (readiness === null) {
|
|
5504
|
+
// BAPI-1593 — unknown readiness is a warning, not a refusal: the launch would
|
|
5505
|
+
// continue to the server's create and approve. Only the decisions that need
|
|
5506
|
+
// no readiness report are previewed: the live-run read, and setup's own dry run.
|
|
5507
|
+
preview.readiness = { kind: "unknown", warning: READINESS_UNKNOWN_CONTINUING_WARNING };
|
|
5508
|
+
if (docsRootUnresolved)
|
|
5509
|
+
return refuseTopLevel(docsRootRefusal(epicKey));
|
|
5510
|
+
const unknownLive = await acquireObservedLive(ctx);
|
|
5511
|
+
if (unknownLive.kind === "conflict")
|
|
5512
|
+
return refuseTopLevel(liveRunAmbiguousRefusal(epicKey));
|
|
5513
|
+
if (unknownLive.kind === "unknown")
|
|
5514
|
+
(preview.warnings ??= []).push(LIVE_RUN_UNKNOWN_WARNING);
|
|
5515
|
+
if (unknownLive.kind === "live") {
|
|
5516
|
+
preview.live_run = { epic_run_id: unknownLive.epicRunId, status: unknownLive.status };
|
|
5517
|
+
if (options.planFile === undefined) {
|
|
5518
|
+
preview.decision = "attach";
|
|
5519
|
+
return;
|
|
5520
|
+
}
|
|
5521
|
+
}
|
|
5522
|
+
if (planPath === undefined) {
|
|
5523
|
+
preview.decision = "stop";
|
|
5524
|
+
return;
|
|
5525
|
+
}
|
|
5526
|
+
await finalizeCreatePreview(ctx, preview, planPath, false, refuseTopLevel, true);
|
|
5527
|
+
return;
|
|
4133
5528
|
}
|
|
4134
5529
|
observed.readiness = readiness;
|
|
4135
5530
|
if (docsRootUnresolved)
|
|
4136
5531
|
return refuseTopLevel(docsRootRefusal(epicKey));
|
|
4137
|
-
const live = await
|
|
5532
|
+
const live = await acquireObservedLive(ctx);
|
|
4138
5533
|
if (live.kind === "conflict")
|
|
4139
5534
|
return refuseTopLevel(liveRunAmbiguousRefusal(epicKey));
|
|
4140
5535
|
if (live.kind === "unknown")
|
|
4141
|
-
|
|
5536
|
+
(preview.warnings ??= []).push(LIVE_RUN_UNKNOWN_WARNING);
|
|
4142
5537
|
// BAPI-1532 — a DISCOVERED plan beside a live run is unused: the launch attaches,
|
|
4143
5538
|
// so the effective plan path is cleared while the preview still reports the plan
|
|
4144
5539
|
// as found. An explicit --plan-file keeps its create-path behavior unchanged.
|
|
4145
|
-
const attachingDiscoveredPlan = options.planFile === undefined && plan.status === "found" && live.kind === "live";
|
|
5540
|
+
const attachingDiscoveredPlan = options.planFile === undefined && (plan.status === "found" || plan.status === "generated") && live.kind === "live";
|
|
4146
5541
|
const effectivePlanPath = attachingDiscoveredPlan ? undefined : planPath;
|
|
4147
5542
|
const previewCtx = { ...ctx, options: { ...options, ...(effectivePlanPath ? { planFile: effectivePlanPath } : {}) } };
|
|
4148
5543
|
const observations = {
|
|
@@ -4165,6 +5560,9 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
4165
5560
|
approvedStoredPolicy: live.kind === "live" && !effectivePlanPath,
|
|
4166
5561
|
});
|
|
4167
5562
|
preview.readiness = { kind: classification.kind };
|
|
5563
|
+
if (mandatoryDiagnosticsUncertain(readiness.diagnostics)) {
|
|
5564
|
+
(preview.warnings ??= []).push(MANDATORY_DIAGNOSTIC_UNKNOWN_WARNING);
|
|
5565
|
+
}
|
|
4168
5566
|
if (classification.kind === 'operator_blocked') {
|
|
4169
5567
|
const requirement = V2_READINESS_REQUIREMENTS.find(req => req.id === classification.id);
|
|
4170
5568
|
if (requirement)
|
|
@@ -4178,6 +5576,7 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
4178
5576
|
if (live.effectivePolicy) {
|
|
4179
5577
|
preview.summary.policy_source = live.effectivePolicy.source;
|
|
4180
5578
|
preview.summary.serial_execution = live.effectivePolicy.serial_execution;
|
|
5579
|
+
preview.summary.parallel_limit = live.effectivePolicy.parallel_limit;
|
|
4181
5580
|
preview.summary.caps = live.effectivePolicy.caps;
|
|
4182
5581
|
preview.summary.job_timeouts = live.effectivePolicy.job_timeouts;
|
|
4183
5582
|
preview.summary.escalation_channel_label = live.effectivePolicy.escalation_channel;
|
|
@@ -4266,12 +5665,13 @@ async function finalizeCreatePreview(ctx, preview, planPath, coldStart, refuseTo
|
|
|
4266
5665
|
? "webhook"
|
|
4267
5666
|
: prepared.handoff.selection.escalationChannel === "account email" ? "email" : null;
|
|
4268
5667
|
}
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
// declared paths nor target topology can establish repository identity.
|
|
4272
|
-
preview.plan_database_relevance = "unknown";
|
|
4273
|
-
preview.summary.child_count = await readPlanChildCount(deps, planPath);
|
|
5668
|
+
const planChildren = await readPlanDagChildren(deps, planPath);
|
|
5669
|
+
preview.summary.child_count = planChildren?.count ?? null;
|
|
4274
5670
|
preview.summary.children_to_run = preview.summary.child_count;
|
|
5671
|
+
// A key list is trusted only when it names every node; a partial list would shrink membership.
|
|
5672
|
+
if (planChildren !== null && planChildren.keys.length === planChildren.count) {
|
|
5673
|
+
previewPlanChildKeys.set(preview, planChildren.keys);
|
|
5674
|
+
}
|
|
4275
5675
|
// BAPI-1510 — the already-merged check, after plan discovery and BEFORE the
|
|
4276
5676
|
// setup dry run, so the dry run validates the plan a real create would submit.
|
|
4277
5677
|
// An attach, a disabled check, and a cold start (no plane to ask yet) classify
|
|
@@ -4346,18 +5746,22 @@ async function finalizeCreatePreview(ctx, preview, planPath, coldStart, refuseTo
|
|
|
4346
5746
|
preview.summary.branch = payload.featureBranch;
|
|
4347
5747
|
if (payload.scopeBaseBranch !== null)
|
|
4348
5748
|
previewScopeBaseBranch.set(preview, payload.scopeBaseBranch);
|
|
5749
|
+
if (payload.serverPlanHash !== null)
|
|
5750
|
+
previewServerPlanDigest.set(preview, payload.serverPlanHash);
|
|
4349
5751
|
preview.summary.ticket_review = payload.ticketReview;
|
|
4350
5752
|
if (payload.launchReadiness) {
|
|
4351
5753
|
preview.prerequisites = payload.launchReadiness.prerequisites;
|
|
4352
5754
|
preview.is_production = payload.launchReadiness.is_production;
|
|
4353
5755
|
const launch = classifyV2Readiness(payload.launchReadiness, { attended: options.attended, intoBase: options.intoBase });
|
|
4354
5756
|
if (launch.kind === 'operator_blocked')
|
|
4355
|
-
return refuseTopLevel({ reasonId: launch.id, remedy: launch.remedy ?? 'Retry readiness.' });
|
|
5757
|
+
return refuseTopLevel({ reasonId: launch.id, remedy: launch.remedy ?? 'Retry readiness.', authoritative: true });
|
|
4356
5758
|
}
|
|
4357
5759
|
if (payload.effectivePolicy) {
|
|
4358
5760
|
const facts = payload.effectivePolicy;
|
|
4359
5761
|
preview.summary.policy_source = facts.source;
|
|
4360
5762
|
preview.summary.serial_execution = facts.serial_execution;
|
|
5763
|
+
if (facts.parallel_limit !== undefined)
|
|
5764
|
+
preview.summary.parallel_limit = facts.parallel_limit;
|
|
4361
5765
|
preview.summary.caps = facts.caps;
|
|
4362
5766
|
preview.summary.job_timeouts = facts.job_timeouts;
|
|
4363
5767
|
preview.summary.escalation_channel_label = facts.escalation_channel;
|
|
@@ -4366,8 +5770,27 @@ async function finalizeCreatePreview(ctx, preview, planPath, coldStart, refuseTo
|
|
|
4366
5770
|
preview.summary.escalation_channel = facts.escalation_channel === "configured webhook"
|
|
4367
5771
|
? "webhook" : facts.escalation_channel === "account email" ? "email" : null;
|
|
4368
5772
|
}
|
|
4369
|
-
|
|
4370
|
-
|
|
5773
|
+
// BAPI-1601 — one intent result drives the summary, the printed line, and the
|
|
5774
|
+
// compatibility scope, so they cannot disagree. An absent or unusable
|
|
5775
|
+
// `create_policy` is `unavailable` — never `off`, and never an invented scope.
|
|
5776
|
+
const epicBranch = payload.featureBranch ?? undefined;
|
|
5777
|
+
let intent;
|
|
5778
|
+
if (payload.createPolicy.kind === "present") {
|
|
5779
|
+
intent = resolveSetupEpicAutoMergeIntent(payload.createPolicy.policy, {
|
|
5780
|
+
epicBranch,
|
|
5781
|
+
attended: options.attended === true,
|
|
5782
|
+
});
|
|
5783
|
+
// A present envelope with no usable boolean is not "older output".
|
|
5784
|
+
if (intent.state === "unavailable")
|
|
5785
|
+
previewAutoMergeUnavailableReason.set(preview, "invalid");
|
|
5786
|
+
}
|
|
5787
|
+
else {
|
|
5788
|
+
intent = { state: "unavailable" };
|
|
5789
|
+
previewAutoMergeUnavailableReason.set(preview, payload.createPolicy.kind === "absent" ? "older" : "invalid");
|
|
5790
|
+
}
|
|
5791
|
+
preview.summary.auto_merge =
|
|
5792
|
+
intent.state === "off" ? { state: "off", reason: intent.reason } : { state: intent.state };
|
|
5793
|
+
preview.summary.auto_merge_scope = intent.state === "on" ? payload.featureBranch : null;
|
|
4371
5794
|
// The bootstrap reusing a run IS an attach: it reports the run's id.
|
|
4372
5795
|
if (payload.existingRunId !== null) {
|
|
4373
5796
|
// Existing runs are never trimmed: report the check as not applied.
|
|
@@ -4435,14 +5858,20 @@ async function applyPreviewFreshness(ctx, preview, topology, coldStart) {
|
|
|
4435
5858
|
const sleep = preview.decision === "attach" ? await collectHostSleep(ctx, own.repoRoot) : null;
|
|
4436
5859
|
// Read-only: one run-state read, local plane only, and only for a bound plane.
|
|
4437
5860
|
const boundRun = await boundRunForStaleRemedy(ctx, own, reports);
|
|
4438
|
-
|
|
5861
|
+
// BAPI-1651: create's cleanup also refuses while another run is live on the
|
|
5862
|
+
// plane, so ask the same read-only question before promising it.
|
|
5863
|
+
const otherLive = preview.decision === "create" && boundRun !== undefined && isTerminalRunCleanupStatus(boundRun.status)
|
|
5864
|
+
? await readOtherLiveRun(deps.listLiveRunIds ?? (async () => null), ctx.access, boundRun.epicRunId)
|
|
5865
|
+
: null;
|
|
5866
|
+
const assessment = assessPlaneFreshness(reports, sleep, preview.decision === "create" ? "create" : "attach", ctx.options.allowStalePlane === true, boundRun, otherLive);
|
|
4439
5867
|
if (assessment.rows.length > 0) {
|
|
4440
5868
|
preview.launch_checks = [...(preview.launch_checks ?? []), ...assessment.rows];
|
|
4441
5869
|
}
|
|
4442
5870
|
const refusal = freshnessRefusalOf(assessment.blockers);
|
|
4443
5871
|
if (refusal !== null) {
|
|
4444
5872
|
preview.decision = "refuse";
|
|
4445
|
-
|
|
5873
|
+
// BAPI-1596: a freshness blocker is proven (a stale plane or a database behind head).
|
|
5874
|
+
preview.refusal = { reason_id: refusal.reasonId, remedy: refusal.remedy, authoritative: true };
|
|
4446
5875
|
}
|
|
4447
5876
|
}
|
|
4448
5877
|
catch {
|
|
@@ -4533,6 +5962,15 @@ function reachabilityLines(preview) {
|
|
|
4533
5962
|
const row = preview.launch_checks?.find((entry) => entry.id === ESCALATION_REACHABILITY_CHECK_ID);
|
|
4534
5963
|
if (row === undefined)
|
|
4535
5964
|
return [];
|
|
5965
|
+
// BAPI-1595 — the confirmed "no reachable channel" line appears only when both
|
|
5966
|
+
// facts are established. An unestablished one shows the fixed uncertainty warning
|
|
5967
|
+
// instead, and an unremarkable one shows nothing.
|
|
5968
|
+
const presentation = previewEscalationPresentation.get(preview);
|
|
5969
|
+
if (presentation === "uncertain") {
|
|
5970
|
+
return [` WARN ${ESCALATION_REACHABILITY_CHECK_ID}`, ` ${ESCALATION_CHANNEL_UNCERTAIN_WARNING}`];
|
|
5971
|
+
}
|
|
5972
|
+
if (presentation === "omitted")
|
|
5973
|
+
return [];
|
|
4536
5974
|
return [
|
|
4537
5975
|
` ${row.status === "pass" ? "PASS" : "WARN"} ${ESCALATION_REACHABILITY_CHECK_ID}`,
|
|
4538
5976
|
...(row.detail ? [` ${row.detail}`] : []),
|
|
@@ -4631,6 +6069,32 @@ export function alreadyDoneLines(preview) {
|
|
|
4631
6069
|
}
|
|
4632
6070
|
return lines;
|
|
4633
6071
|
}
|
|
6072
|
+
/** The v2 plan as plain lines: the same document the session renders, never recomputed here. */
|
|
6073
|
+
function launchPlanLines(plan) {
|
|
6074
|
+
const lines = [" Launch plan:", ` ${plan.summary}`, ` Recommended: ${plan.recommendation}`, ` Why: ${plan.reason}`];
|
|
6075
|
+
const groups = [
|
|
6076
|
+
["Blocks the launch", plan.items.blocks_launch],
|
|
6077
|
+
["Needs your choice", plan.items.needs_choice],
|
|
6078
|
+
["Worth knowing", plan.items.worth_knowing],
|
|
6079
|
+
];
|
|
6080
|
+
for (const [title, entries] of groups) {
|
|
6081
|
+
if (entries.length === 0)
|
|
6082
|
+
continue;
|
|
6083
|
+
lines.push(` ${title}:`);
|
|
6084
|
+
for (const entry of entries) {
|
|
6085
|
+
lines.push(` - ${entry.summary}`, ` ${entry.reason}`);
|
|
6086
|
+
if (entry.remedy)
|
|
6087
|
+
lines.push(` Fix: ${entry.remedy}`);
|
|
6088
|
+
}
|
|
6089
|
+
}
|
|
6090
|
+
lines.push(" Your options:");
|
|
6091
|
+
for (const option of plan.options) {
|
|
6092
|
+
lines.push(` ${option.number}. ${option.label}${option.recommended ? " (as recommended)" : ""}. ${option.description} ${option.duration}`);
|
|
6093
|
+
}
|
|
6094
|
+
if (plan.local_handoff)
|
|
6095
|
+
lines.push(` ${plan.local_handoff}`);
|
|
6096
|
+
return lines;
|
|
6097
|
+
}
|
|
4634
6098
|
/**
|
|
4635
6099
|
* Print the preview: one JSON line with `--json`, short readable lines otherwise.
|
|
4636
6100
|
*
|
|
@@ -4660,22 +6124,22 @@ async function emitPreview(deps, options, preview) {
|
|
|
4660
6124
|
? "Found, unused"
|
|
4661
6125
|
: preview.plan.status}${preview.plan.path ? ` — ${preview.plan.path}` : ""}`,
|
|
4662
6126
|
];
|
|
6127
|
+
// BAPI-1621 — generated provenance and a stopped generation, in plain words.
|
|
6128
|
+
if (preview.plan.generated === true) {
|
|
6129
|
+
lines.push(preview.plan.status === "generated"
|
|
6130
|
+
? ` GENERATED — built from current epic children; not written by this preview. A launch saves it to ${preview.plan.would_write ?? "the generated plan folder"}.`
|
|
6131
|
+
: " GENERATED — built from epic children by drive-epic.");
|
|
6132
|
+
}
|
|
6133
|
+
if (preview.plan.generation_failure !== undefined) {
|
|
6134
|
+
lines.push(` generation: stopped (${preview.plan.generation_failure}) — ${PLAN_GENERATION_FAILURE_TEXT[preview.plan.generation_failure]}`);
|
|
6135
|
+
}
|
|
4663
6136
|
for (const candidate of preview.plan.candidates ?? [])
|
|
4664
6137
|
lines.push(` candidate: ${candidate}`);
|
|
4665
6138
|
for (const skipped of preview.plan.skipped ?? []) {
|
|
4666
6139
|
lines.push(` skipped: ${skipped.path} (${skipped.reason})`);
|
|
4667
6140
|
}
|
|
4668
6141
|
const s = preview.summary;
|
|
4669
|
-
lines.push(` Ticket review: ${s.ticket_review ?? "on"}`, ` Posture: ${s.posture ?? "n/a"}`, ` Children: ${s.child_count ?? "n/a"}`, ...alreadyDoneLines(preview), ` Branch: ${s.branch ?? "n/a"}`, `
|
|
4670
|
-
" Launch plan (advisory):",
|
|
4671
|
-
...(preview.launch_plan.items.length === 0 ? [" There are no pending decisions"] :
|
|
4672
|
-
preview.launch_plan.items.flatMap((item) => [
|
|
4673
|
-
` ${item.summary} (${item.id}): ${item.recommendation}`,
|
|
4674
|
-
` ${item.reason}`,
|
|
4675
|
-
...(item.remedy ? [` Remedy: ${item.remedy}`] : []),
|
|
4676
|
-
...(item.recommendation === "fix first" ? [" Launch anyway accepts the unresolved risk; no remediation is performed."] : []),
|
|
4677
|
-
])),
|
|
4678
|
-
] : []), ` Validation: ${preview.cold_start ? "Partial — plane is not yet running" : s.server_validation ?? "n/a"}`, ` Decision: ${preview.decision}`);
|
|
6142
|
+
lines.push(` Ticket review: ${s.ticket_review ?? "on"}`, ` Posture: ${s.posture ?? "n/a"}`, ` Parallel limit: ${s.parallel_limit === undefined ? "unavailable" : s.parallel_limit === "server_default" ? "server default" : s.parallel_limit}`, ` ${PARALLEL_LIMIT_MEANING_COPY}`, ` ${PARALLEL_LIMIT_CHANGE_ADVISORY}`, ` Children: ${s.child_count ?? "n/a"}`, ...alreadyDoneLines(preview), ` Branch: ${s.branch ?? "n/a"}`, autoMergeLine(preview), ` Escalation: ${s.escalation_channel ?? "n/a"}`, ...reachabilityLines(preview), ...(preview.launch_plan ? launchPlanLines(preview.launch_plan) : []), ` Validation: ${preview.cold_start ? "Partial — plane is not yet running" : s.server_validation ?? "n/a"}`, ` Decision: ${preview.decision}`);
|
|
4679
6143
|
if (isPlaneDownStop(preview)) {
|
|
4680
6144
|
// The shared stop text, verbatim and unindented, so it reads exactly as the
|
|
4681
6145
|
// real launch prints it. It is a stop, not a refusal.
|
|
@@ -4689,13 +6153,9 @@ async function emitPreview(deps, options, preview) {
|
|
|
4689
6153
|
if (preview.refusal && preview.refusal.reason_id !== EPIC_ALREADY_COMPLETE_REASON_ID) {
|
|
4690
6154
|
lines.push(` Refusal: ${preview.refusal.reason_id} — ${preview.refusal.remedy}`);
|
|
4691
6155
|
}
|
|
6156
|
+
// BAPI-1596 — no "Not ready: N blocking" summary on the launch preview: the plan above
|
|
6157
|
+
// carries the verdict. The readiness command keeps its own text report.
|
|
4692
6158
|
const summaryRows = (preview.launch_checks ?? []).filter(row => row.id !== ESCALATION_REACHABILITY_CHECK_ID);
|
|
4693
|
-
lines.unshift(...formatLaunchReadinessSummary(summaryRows.map(row => ({
|
|
4694
|
-
id: row.id, source: row.id.startsWith('server.') ? 'server' : 'conductor',
|
|
4695
|
-
label: row.label, status: row.status, blocking: row.blocking,
|
|
4696
|
-
...(row.detail ? { detail: row.detail } : {}),
|
|
4697
|
-
...(row.remedy ? { remediation: row.remedy } : {}),
|
|
4698
|
-
})), { all: options.all, isProduction: preview.is_production, prerequisites: preview.prerequisites }));
|
|
4699
6159
|
const localRows = summaryRows.filter(row => !READINESS_PREREQUISITE_BY_ID.has(READINESS_LEGACY_IDS[row.id] ?? row.id));
|
|
4700
6160
|
// BAPI-1506: launch-need rows get their own heading; they are not plane freshness.
|
|
4701
6161
|
const freshnessRows = localRows.filter(row => row.launch_need === undefined);
|