@bridge_gpt/mcp-server 0.2.70 → 0.2.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -17
- package/build/agent-launchers/claude-executor-adapter.js +29 -4
- package/build/agent-notes.js +171 -95
- package/build/agent-registry.js +5 -5
- package/build/agents.generated.js +12 -2
- package/build/bounded-wait.js +9 -1
- package/build/bridge-permissions.js +17 -5
- package/build/bridge-worktree-inspection.js +237 -0
- package/build/check-evidence.js +6 -0
- package/build/claude-review-workflow.js +1 -1
- package/build/cli-help.js +6 -0
- package/build/codex-auto-recovery.js +126 -0
- package/build/codex-skill-adapter.js +2 -0
- package/build/commands.generated.js +5 -5
- package/build/conductor/bridge-api-client.js +776 -23
- package/build/conductor/command-drift-production.js +7 -2
- package/build/conductor/doctor.js +93 -13
- package/build/conductor/epic-implementer-cli.js +55 -2
- package/build/conductor/gate-discovery.js +659 -19
- package/build/conductor/gate-settings-review.js +751 -0
- package/build/conductor/git-hooks-uninstall.js +112 -0
- package/build/conductor/git-hooks.js +81 -15
- package/build/conductor/guided-repair.js +10 -1
- package/build/conductor/install-doctor.js +2 -4
- package/build/conductor/launch-need-probes.js +16 -11
- package/build/conductor/launch-plan.js +185 -0
- package/build/conductor/local-merge.js +12 -1
- package/build/conductor/merge-execution-contract.js +1 -1
- package/build/conductor/merged-child-check.js +2 -1
- package/build/conductor/precheck-timings.js +14 -0
- package/build/conductor/prerequisite-inputs.js +379 -0
- package/build/conductor/preview-observations.js +10 -0
- package/build/conductor/readiness-assessment.js +78 -0
- package/build/conductor/readiness-cli.js +10 -0
- package/build/conductor/readiness-prerequisites.js +53 -0
- package/build/conductor/readiness-sections.js +25 -9
- package/build/conductor/readiness.js +20 -2
- package/build/conductor/recovery-cli.js +281 -14
- package/build/conductor/recovery-operations.js +78 -5
- package/build/conductor/repair-contract.js +33 -0
- package/build/conductor/tools.js +34 -3
- package/build/conductor/wait-run-attention.js +115 -0
- package/build/conductor/wait-run-cli.js +96 -3
- package/build/conductor/worker-database-doctor-inspector.js +1 -0
- package/build/credential-store.js +25 -20
- package/build/dependency-install-declarations.js +157 -0
- package/build/docs.generated.js +4 -4
- package/build/doctor.js +37 -5
- package/build/drive-epic-help.js +2 -2
- package/build/drive-epic.js +240 -56
- package/build/epic-ci-workflow-drift.js +71 -23
- package/build/epic-ci-workflow-install.js +83 -26
- package/build/epic-ci-workflow-v1.js +132 -0
- package/build/epic-ci-workflow.js +174 -13
- package/build/epic-implementer-bin.js +119 -44
- package/build/epic-launch-profile.js +1 -1
- package/build/executor/ci-rerun-job.js +220 -14
- package/build/executor/cli.js +2 -0
- package/build/executor/completion-contract.js +16 -0
- package/build/executor/credentials.js +1 -1
- package/build/executor/delivery-observations.js +113 -0
- package/build/executor/delivery-outcome.js +30 -0
- package/build/executor/dependency-refresh-runner.js +132 -0
- package/build/executor/dependency-refresh.js +530 -0
- package/build/executor/deps.js +4 -0
- package/build/executor/env.js +274 -5
- package/build/executor/gate-qualification-job.js +20 -5
- package/build/executor/harness-coverage.js +19 -0
- package/build/executor/http-client.js +35 -1
- package/build/executor/index.js +2 -1
- package/build/executor/install-preflight.js +1 -1
- package/build/executor/job-runner.js +355 -36
- package/build/executor/likely-tests.js +100 -98
- package/build/executor/preflight.js +5 -0
- package/build/executor/process-containment.js +18 -0
- package/build/executor/prompt-spec.js +84 -15
- package/build/executor/reconcile-overlap-job.js +6 -1
- package/build/executor/required-verification.js +28 -0
- package/build/executor/required-work-diagnostics.js +30 -0
- package/build/executor/required-work-ledger.js +19 -1
- package/build/executor/results.js +42 -0
- package/build/executor/service-discovery.js +42 -0
- package/build/executor/service-lifecycle.js +109 -2
- package/build/executor/service-uninstall.js +205 -0
- package/build/executor/service-unit.js +5 -3
- package/build/executor/test-clock.js +3 -0
- package/build/executor/verification-hints.js +179 -0
- package/build/executor/worker-command.js +188 -1
- package/build/executor/worker-database.js +299 -40
- package/build/executor/worker-finalization.js +65 -10
- package/build/executor/worker-guard-hook.js +10 -2
- package/build/executor/worker-resources.js +12 -1
- package/build/executor/worker-verification-guidance.js +64 -0
- package/build/executor/worktree-inspection.js +42 -0
- package/build/github-sign-in.js +1 -1
- package/build/index.js +767 -310
- package/build/init.js +3 -3
- package/build/install-bridge-conductor-gate.js +416 -41
- package/build/install-bridge-conductor-setup.js +135 -32
- package/build/install-bridge-conductor.js +769 -353
- package/build/install-bridge.js +419 -124
- package/build/install-maintenance.js +104 -0
- package/build/install-reexec.js +1 -1
- package/build/local-cleanup.js +59 -0
- package/build/mcp-install-state.js +68 -2
- package/build/merge-workflow-install.js +22 -2
- package/build/package-script-semantics.js +10 -0
- package/build/pipeline-utils.js +1 -1
- package/build/pipelines.generated.js +6 -6
- package/build/plan-execution-ledger.js +171 -10
- package/build/plane/plane-freshness.js +12 -9
- package/build/plane/preflight.js +19 -0
- package/build/plane/terminal-run-cleanup.js +5 -1
- package/build/plane/terminal-run-status.js +4 -0
- package/build/printed-remedy-commands.js +31 -4
- package/build/readiness-check.js +1 -78
- package/build/readiness-prerequisites.generated.js +199 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-toolchains.js +623 -0
- package/build/setup-change-policy.js +32 -0
- package/build/setup-epic.js +26 -9
- package/build/setup-question.js +62 -0
- package/build/start-tickets.js +4 -0
- package/build/test-command-detection.js +61 -80
- package/build/test-support/notes-fs.js +40 -0
- package/build/ticket-delivery-artifacts.js +7 -0
- package/build/ticket-delivery-enrollment.js +80 -4
- package/build/ticket-delivery-run-scope.js +128 -0
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktrees.js +105 -0
- package/docs/EPIC-IMPLEMENTER.md +43 -0
- package/docs/epic-implementer/getting-started.md +95 -14
- package/package.json +2 -2
package/build/drive-epic.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { sanitizeHarnessCoverage } from "./executor/harness-coverage.js";
|
|
2
|
+
import { isTerminalRunCleanupStatus } from "./plane/terminal-run-status.js";
|
|
3
|
+
import { monotonicNow, elapsedMs, measurePrecheck } from "./conductor/precheck-timings.js";
|
|
4
|
+
import { buildLaunchPlan } from "./conductor/launch-plan.js";
|
|
1
5
|
import { ticketReviewSummary } from "./ticket-review-summary.js";
|
|
2
6
|
import { parseConductorReadinessResponse } from "./conductor/bridge-api-client.js";
|
|
3
7
|
import { READINESS_PRE_CREATE_CODES, READINESS_PREREQUISITE_BY_ID, READINESS_LEGACY_IDS } from "./readiness-prerequisites.generated.js";
|
|
@@ -56,7 +60,7 @@ import { READINESS_PRE_CREATE_CODES, READINESS_PREREQUISITE_BY_ID, READINESS_LEG
|
|
|
56
60
|
* ratcheted down, and a tool would be useless in a bare-chat session anyway,
|
|
57
61
|
* where the model has no tool call to make.
|
|
58
62
|
*/
|
|
59
|
-
import { access as fsAccess, readdir, readFile, stat as fsStat } from "node:fs/promises";
|
|
63
|
+
import { access as fsAccess, readdir, readFile, realpath, stat as fsStat } from "node:fs/promises";
|
|
60
64
|
import { constants as fsConstants } from "node:fs";
|
|
61
65
|
import path, { dirname, join } from "node:path";
|
|
62
66
|
import { ConductorBridgeApiError, resolveEpicLaunchBridgeApiAccess, fetchConductorReadiness, fetchRepositoryUsageAdvisory, REPOSITORY_USAGE_ADVISORY_UNAVAILABLE, formatSchemaIncompatibleRefusal, isSchemaIncompatibleError, SCHEMA_INCOMPATIBLE_REPAIR_ROUTE, fetchEpicRunState, isProviderRepositoryIdentity, safeDiagnosticMessage, classifyChildMergeStatus as classifyChildMergeStatusClient, recordSkippedChildren as recordSkippedChildrenClient, } from "./conductor/bridge-api-client.js";
|
|
@@ -71,7 +75,7 @@ import { V2_READINESS_REQUIREMENTS, buildLaunchReadinessChecks, firstLaunchEvide
|
|
|
71
75
|
import { classifyLocalGhPreflight, probeLocalMergeCapability, } from "./conductor/local-merge.js";
|
|
72
76
|
import { nodeGithubMergeCredentialReadDeps, resolveMergeCredentialAtAction, } from "./conductor/stored-merge-credential.js";
|
|
73
77
|
import { resolveWorktreeSettingsExclude, } from "./executor/permissions.js";
|
|
74
|
-
import { collectWorkerDatabaseDoctorSection, WORKER_DATABASE_DOCTOR_TIMEOUT_MS, } from "./conductor/doctor.js";
|
|
78
|
+
import { collectWorkerDatabaseDoctorSection, sanitizeOwnerRoles, sanitizeOwnerRoleTotal, WORKER_DATABASE_DOCTOR_TIMEOUT_MS, } from "./conductor/doctor.js";
|
|
75
79
|
import { buildEpicBranchBehindBaseLaunchRow, buildHostPowerLaunchRow, buildSelfHostedRunnerLaunchRow, buildUsageResetAfterRunLaunchRow, buildWorkerDbRoleLaunchRow, hostPowerFactFromReport, workerDatabaseReadinessChecks, } from "./conductor/readiness-sections.js";
|
|
76
80
|
import { createWorkflowSource, inspectEpicBranchBehindBase, inspectRequiredSelfHostedRunners, } from "./conductor/launch-need-probes.js";
|
|
77
81
|
import { createWorkerDatabaseDoctorInspector } from "./conductor/worker-database-doctor-inspector.js";
|
|
@@ -82,7 +86,7 @@ import { BRIDGE_LAUNCHER_ENV } from "./bridge-permissions.js";
|
|
|
82
86
|
import { checkPlaneBuildFreshness, PLANE_BUILD_FIX_REMEDIATION } from "./plane/build-freshness.js";
|
|
83
87
|
import { discoverEpicPlan, } from "./plan-discovery.js";
|
|
84
88
|
import { formatPlaneDiagnostic, launchPlaneControlPlane, requestPlaneScopedLanes, runDefaultPlanePreflight, runPlaneCli, } from "./plane/cli.js";
|
|
85
|
-
import { PLANE_PORT_PROBE_TIMEOUT_MS, describePlanePortOccupant, } from "./plane/preflight.js";
|
|
89
|
+
import { PLANE_PORT_PROBE_TIMEOUT_MS, describePlanePortOccupant, isBridgeEngineRepository, } from "./plane/preflight.js";
|
|
86
90
|
import { createPlaneExecFile, createPlaneFsDeps, probeAutomationHealth, probeTcpPort, resolveHostname, } from "./plane/defaults.js";
|
|
87
91
|
import { readPlaneManifest } from "./plane/manifest.js";
|
|
88
92
|
import { cleanupTerminalRunPlane, createTerminalRunCleanupDeps, terminalRunCleanupStderrLine, } from "./plane/terminal-run-cleanup.js";
|
|
@@ -1060,6 +1064,7 @@ export async function readLiveEpicRunByKey(access, epicKey, fetchImpl = globalTh
|
|
|
1060
1064
|
}
|
|
1061
1065
|
return {
|
|
1062
1066
|
kind: "live",
|
|
1067
|
+
state,
|
|
1063
1068
|
epicRunId: run.epic_run_id,
|
|
1064
1069
|
status: run.status,
|
|
1065
1070
|
ticketReview: ticketReviewSummary(run.ticket_review),
|
|
@@ -1084,6 +1089,15 @@ export async function readLiveEpicRunByKey(access, epicKey, fetchImpl = globalTh
|
|
|
1084
1089
|
}
|
|
1085
1090
|
export function createDefaultDriveEpicDeps() {
|
|
1086
1091
|
return {
|
|
1092
|
+
inspectRepositoryIdentity: async () => {
|
|
1093
|
+
const top = await createPlaneExecFile()("git", ["rev-parse", "--show-toplevel"], {
|
|
1094
|
+
cwd: process.cwd(), timeoutMs: 5000,
|
|
1095
|
+
});
|
|
1096
|
+
if (!top.ok || !path.isAbsolute(top.stdout.trim()))
|
|
1097
|
+
throw new Error("repository_root_unverifiable");
|
|
1098
|
+
const repoRoot = await realpath(top.stdout.trim());
|
|
1099
|
+
return { repoRoot, isBridge: await isBridgeEngineRepository(repoRoot, createPlaneFsDeps()) };
|
|
1100
|
+
},
|
|
1087
1101
|
resolveAccess: async (repo, cwd, launch) => {
|
|
1088
1102
|
// BAPI-1260: the target-first launch contract. BAPI-1272: with no target
|
|
1089
1103
|
// selected it defaults to production, and a stored key is sent there only
|
|
@@ -1140,7 +1154,7 @@ export function createDefaultDriveEpicDeps() {
|
|
|
1140
1154
|
}),
|
|
1141
1155
|
inspectEpicBranchBehind: ({ repoRoot, branch, baseBranch }) => inspectEpicBranchBehindBase({ repoRoot, branch, baseBranch, execFile: createPlaneExecFile() }),
|
|
1142
1156
|
fetchUsageAdvisory: (access) => fetchRepositoryUsageAdvisory(access),
|
|
1143
|
-
inspectWorkerDatabase: createWorkerDatabaseDoctorInspector({ env: process.env, cwd: process.cwd() }),
|
|
1157
|
+
inspectWorkerDatabase: (repoRoot) => createWorkerDatabaseDoctorInspector({ env: process.env, cwd: repoRoot ?? process.cwd() })(),
|
|
1144
1158
|
cleanupTerminalRunPlane: (input) => cleanupTerminalRunPlane(input, createTerminalRunCleanupDeps(process.env)),
|
|
1145
1159
|
readRunState: async (access, epicRunId) => {
|
|
1146
1160
|
const state = await fetchEpicRunState(access, epicRunId, globalThis.fetch);
|
|
@@ -1175,13 +1189,14 @@ export function createDefaultDriveEpicDeps() {
|
|
|
1175
1189
|
readPlanDag: (filePath) => readFile(filePath, "utf8"),
|
|
1176
1190
|
readPolicyFile: (filePath) => readFile(filePath, "utf8"),
|
|
1177
1191
|
readLiveEpicRun: (access, epicKey) => readLiveEpicRunByKey(access, epicKey),
|
|
1178
|
-
previewSetupEpic: async ({ argv, baseUrl, handoff }) => {
|
|
1192
|
+
previewSetupEpic: async ({ argv, baseUrl, handoff, observations }) => {
|
|
1179
1193
|
const stdout = [];
|
|
1180
1194
|
const stderr = [];
|
|
1181
1195
|
const result = await runSetupEpicWorkflow(argv, {
|
|
1182
1196
|
// A COPY carrying the resolved target: the preview never mutates
|
|
1183
1197
|
// `process.env`, so a dry run leaves the process exactly as it found it.
|
|
1184
1198
|
env: { ...process.env, BAPI_BASE_URL: baseUrl },
|
|
1199
|
+
previewObservations: observations,
|
|
1185
1200
|
log: (message) => stdout.push(message),
|
|
1186
1201
|
errorLog: (message) => stderr.push(message),
|
|
1187
1202
|
}, handoff);
|
|
@@ -1244,6 +1259,10 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1244
1259
|
return 1;
|
|
1245
1260
|
}
|
|
1246
1261
|
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);
|
|
1247
1266
|
const launch = launchSelectionOf(parsed.options);
|
|
1248
1267
|
// BAPI-1285 — the read-only preview is its own path from here. It shares the
|
|
1249
1268
|
// classification and refusal builders below and none of the launch code.
|
|
@@ -1521,7 +1540,7 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1521
1540
|
"",
|
|
1522
1541
|
"This is not something starting the runtime can fix, so nothing was started.",
|
|
1523
1542
|
// The requirement's OWN remedy when it has one. Telling an operator to
|
|
1524
|
-
// run `install-
|
|
1543
|
+
// run `install epic-implementer` for a missing consent flag sends them
|
|
1525
1544
|
// to a command that cannot set it.
|
|
1526
1545
|
operatorBlockedRemedy(classification),
|
|
1527
1546
|
].join("\n");
|
|
@@ -1635,7 +1654,7 @@ export async function runDriveEpicCli(argv, overrides = {}) {
|
|
|
1635
1654
|
`${epicKey}: ${selection.reason}.`,
|
|
1636
1655
|
"",
|
|
1637
1656
|
"The v2 engine is not ready to drive this epic, and there is no alternative",
|
|
1638
|
-
"engine to fall back to. Resolve Epic Implementer readiness (`install
|
|
1657
|
+
"engine to fall back to. Resolve Epic Implementer readiness (`install epic-implementer`,",
|
|
1639
1658
|
"then `doctor`) and run drive-epic again.",
|
|
1640
1659
|
`See ${CONSUMER_GUIDE_POINTER}.`,
|
|
1641
1660
|
].join("\n");
|
|
@@ -1722,8 +1741,8 @@ function escalate(deps, epicKey, reason) {
|
|
|
1722
1741
|
function channelIdentityOf(label) {
|
|
1723
1742
|
return label === "configured webhook" || label === "account email" ? label : "unavailable";
|
|
1724
1743
|
}
|
|
1725
|
-
async function prepareSetupSelection(ctx, coldStart = false) {
|
|
1726
|
-
const live = coldStart ? { kind: "none" } : await ctx.deps.readLiveEpicRun(ctx.access, ctx.epicKey);
|
|
1744
|
+
async function prepareSetupSelection(ctx, coldStart = false, observedLive) {
|
|
1745
|
+
const live = coldStart ? { kind: "none" } : observedLive ?? await ctx.deps.readLiveEpicRun(ctx.access, ctx.epicKey);
|
|
1727
1746
|
if (live.kind === "conflict")
|
|
1728
1747
|
return { ok: false, reasonId: "live-run-ambiguous" };
|
|
1729
1748
|
if (live.kind === "unknown")
|
|
@@ -1952,6 +1971,15 @@ async function runSelectedSetupEpic(ctx) {
|
|
|
1952
1971
|
const pr = skippedChildPr(evaluation.state, key);
|
|
1953
1972
|
deps.log(`${epicKey}: ${confirmed ? "skipping (confirmed by you)" : "skipping already-merged child"} ${key}` +
|
|
1954
1973
|
`${pr !== null ? ` (#${pr})` : ""}`);
|
|
1974
|
+
if (!confirmed) {
|
|
1975
|
+
deps.log(`already merged, will skip: ${key}${pr !== null ? ` (#${pr})` : ""}`);
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
for (const child of evaluation.state.children) {
|
|
1979
|
+
if (child.classification === "probably_done" && !evaluation.skipKeys.has(child.ticket_key)) {
|
|
1980
|
+
const pr = skippedChildPr(evaluation.state, child.ticket_key);
|
|
1981
|
+
deps.log(`may already be merged; kept: ${child.ticket_key}${pr !== null ? ` (#${pr})` : ""}`);
|
|
1982
|
+
}
|
|
1955
1983
|
}
|
|
1956
1984
|
const trimmed = trimDonePlanNodes(evaluation.plan, evaluation.skipKeys);
|
|
1957
1985
|
const withPath = deps.withPlanPath ?? withPlanPath;
|
|
@@ -2165,8 +2193,13 @@ async function previewLaunchCapability(ctx, readiness, topology) {
|
|
|
2165
2193
|
if (!isUnattendedLaunch(options)) {
|
|
2166
2194
|
return { checks: buildLaunchReadinessChecks(readiness, context), refusal: null };
|
|
2167
2195
|
}
|
|
2168
|
-
const
|
|
2169
|
-
const
|
|
2196
|
+
const durations = {};
|
|
2197
|
+
const [credential, worktree] = await Promise.all([
|
|
2198
|
+
measurePrecheck(() => collectCredentialEvidence(deps, readiness, topology), (ms) => { durations["conductor.merge-credential-capability"] = ms; }),
|
|
2199
|
+
measurePrecheck(() => collectWorktreeEvidence(deps, topology), (ms) => { durations["conductor.worktree-preparation"] = ms; }),
|
|
2200
|
+
]);
|
|
2201
|
+
const evidence = { credential, worktree };
|
|
2202
|
+
const checks = buildLaunchReadinessChecks(readiness, { ...context, launchEvidence: evidence }).map((row) => ({ ...row, duration_ms: durations[row.id] ?? elapsedMs(monotonicNow()) }));
|
|
2170
2203
|
const classification = classifyV2Readiness(readiness, { ...context, effectivePolicy: ctx.handoff?.selection }, evidence);
|
|
2171
2204
|
if (classification.kind === "operator_blocked" && LAUNCH_REFUSAL_IDS.includes(classification.id)) {
|
|
2172
2205
|
return {
|
|
@@ -2289,7 +2322,11 @@ async function collectHostSleep(ctx, repoRoot) {
|
|
|
2289
2322
|
if (inspect === undefined)
|
|
2290
2323
|
return null;
|
|
2291
2324
|
const cache = ctx.freshness ?? createPlaneFreshnessCache();
|
|
2292
|
-
cache.sleep ??=
|
|
2325
|
+
cache.sleep ??= (async () => {
|
|
2326
|
+
const started = monotonicNow();
|
|
2327
|
+
const report = await inspect(repoRoot).catch(() => null);
|
|
2328
|
+
return report === null ? null : { ...report, duration_ms: elapsedMs(started) };
|
|
2329
|
+
})();
|
|
2293
2330
|
return cache.sleep;
|
|
2294
2331
|
}
|
|
2295
2332
|
/**
|
|
@@ -2338,18 +2375,20 @@ function assessPlaneFreshness(reports, sleep, mode, allowStalePlane,
|
|
|
2338
2375
|
* remedy, which never advises `plane down` for a run that is not finished.
|
|
2339
2376
|
* Absent keeps `PLANE_SNAPSHOT_STALE_REMEDY` byte for byte.
|
|
2340
2377
|
*/
|
|
2341
|
-
boundRun) {
|
|
2378
|
+
boundRun, cleanupPreview = false) {
|
|
2342
2379
|
const rows = [];
|
|
2343
2380
|
const blockers = [];
|
|
2344
2381
|
let overridden = false;
|
|
2345
2382
|
const flagNote = allowStalePlane ? "; overridden for this invocation by --allow-stale-plane" : "";
|
|
2346
2383
|
const project = (id, label, report, refusal) => {
|
|
2384
|
+
const duration_ms = report.duration_ms ?? elapsedMs(monotonicNow());
|
|
2347
2385
|
const { verdict, detail } = freshnessVerdictOf(report);
|
|
2348
2386
|
if (verdict === "pass") {
|
|
2349
|
-
rows.push({ id, label, status: "pass", blocking: false, detail: `pass — ${detail}` });
|
|
2387
|
+
rows.push({ duration_ms, id, label, status: "pass", blocking: false, detail: `pass — ${detail}` });
|
|
2350
2388
|
}
|
|
2351
2389
|
else if (verdict === "unverified") {
|
|
2352
2390
|
rows.push({
|
|
2391
|
+
duration_ms,
|
|
2353
2392
|
id,
|
|
2354
2393
|
label,
|
|
2355
2394
|
status: "warn",
|
|
@@ -2361,6 +2400,7 @@ boundRun) {
|
|
|
2361
2400
|
else if (verdict === "refuse" && mode === "attach") {
|
|
2362
2401
|
// Warning-only: an existing run is never stopped for freshness.
|
|
2363
2402
|
rows.push({
|
|
2403
|
+
duration_ms,
|
|
2364
2404
|
id,
|
|
2365
2405
|
label,
|
|
2366
2406
|
status: "warn",
|
|
@@ -2369,9 +2409,18 @@ boundRun) {
|
|
|
2369
2409
|
remedy: refusal.remedy,
|
|
2370
2410
|
});
|
|
2371
2411
|
}
|
|
2412
|
+
else if (verdict === "refuse" && mode === "create" && !allowStalePlane && cleanupPreview &&
|
|
2413
|
+
id === PLANE_SNAPSHOT_FRESHNESS_ID && isTerminalRunCleanupStatus(boundRun?.status)) {
|
|
2414
|
+
rows.push({
|
|
2415
|
+
duration_ms, id, label, status: "warn", blocking: false,
|
|
2416
|
+
detail: `This create will attempt guarded cleanup — ${detail}. Create rechecks ownership and run status before teardown.`,
|
|
2417
|
+
remedy: refusal.remedy,
|
|
2418
|
+
});
|
|
2419
|
+
}
|
|
2372
2420
|
else if (verdict === "refuse" && allowStalePlane) {
|
|
2373
2421
|
overridden = true;
|
|
2374
2422
|
rows.push({
|
|
2423
|
+
duration_ms,
|
|
2375
2424
|
id,
|
|
2376
2425
|
label,
|
|
2377
2426
|
status: "fail",
|
|
@@ -2383,6 +2432,7 @@ boundRun) {
|
|
|
2383
2432
|
else if (verdict === "refuse") {
|
|
2384
2433
|
blockers.push(refusal);
|
|
2385
2434
|
rows.push({
|
|
2435
|
+
duration_ms,
|
|
2386
2436
|
id,
|
|
2387
2437
|
label,
|
|
2388
2438
|
status: "fail",
|
|
@@ -2403,12 +2453,14 @@ boundRun) {
|
|
|
2403
2453
|
});
|
|
2404
2454
|
}
|
|
2405
2455
|
if (sleep !== null) {
|
|
2456
|
+
const duration_ms = sleep.duration_ms ?? elapsedMs(monotonicNow());
|
|
2406
2457
|
const { verdict, detail } = freshnessVerdictOf(sleep);
|
|
2407
2458
|
if (verdict === "skip") {
|
|
2408
|
-
rows.push({ id: PLANE_HOST_SLEEP_ID, label: "Host sleep", status: "skip", blocking: false, detail: `not applicable — ${detail}` });
|
|
2459
|
+
rows.push({ duration_ms, id: PLANE_HOST_SLEEP_ID, label: "Host sleep", status: "skip", blocking: false, detail: `not applicable — ${detail}` });
|
|
2409
2460
|
}
|
|
2410
2461
|
else if (verdict === "unverified") {
|
|
2411
2462
|
rows.push({
|
|
2463
|
+
duration_ms,
|
|
2412
2464
|
id: PLANE_HOST_SLEEP_ID,
|
|
2413
2465
|
label: "Host sleep",
|
|
2414
2466
|
status: "warn",
|
|
@@ -2421,6 +2473,7 @@ boundRun) {
|
|
|
2421
2473
|
// BAPI-1506: a battery or lid advisory is a warning with its remedy, not
|
|
2422
2474
|
// a pass. It still never blocks.
|
|
2423
2475
|
rows.push({
|
|
2476
|
+
duration_ms,
|
|
2424
2477
|
id: PLANE_HOST_SLEEP_ID,
|
|
2425
2478
|
label: "Host sleep",
|
|
2426
2479
|
status: "warn",
|
|
@@ -2431,7 +2484,7 @@ boundRun) {
|
|
|
2431
2484
|
}
|
|
2432
2485
|
else {
|
|
2433
2486
|
// Readable evidence never blocks setup. "pass" means exactly that.
|
|
2434
|
-
rows.push({ id: PLANE_HOST_SLEEP_ID, label: "Host sleep", status: "pass", blocking: false, detail: `pass — ${detail}` });
|
|
2487
|
+
rows.push({ duration_ms, id: PLANE_HOST_SLEEP_ID, label: "Host sleep", status: "pass", blocking: false, detail: `pass — ${detail}` });
|
|
2435
2488
|
}
|
|
2436
2489
|
}
|
|
2437
2490
|
return { rows, blockers, overridden };
|
|
@@ -2548,7 +2601,7 @@ async function collectWorkerDatabaseAdvisory(deps, baseUrl, cache) {
|
|
|
2548
2601
|
return null;
|
|
2549
2602
|
const run = async () => {
|
|
2550
2603
|
let failed = false;
|
|
2551
|
-
const section = await collectWorkerDatabaseDoctorSection(inspect, WORKER_DATABASE_DOCTOR_TIMEOUT_MS, (failure) => {
|
|
2604
|
+
const section = await collectWorkerDatabaseDoctorSection(() => inspect(deps.cwd()), WORKER_DATABASE_DOCTOR_TIMEOUT_MS, (failure) => {
|
|
2552
2605
|
failed = true;
|
|
2553
2606
|
deps.errorLog(`worker-db inspection failed: ${failure}`);
|
|
2554
2607
|
}).catch(() => null);
|
|
@@ -2599,7 +2652,13 @@ async function surfaceWorkerDatabaseAdvisory(ctx) {
|
|
|
2599
2652
|
* inspector and its JSON is unchanged. Never changes the decision, a refusal,
|
|
2600
2653
|
* readiness, or the exit code.
|
|
2601
2654
|
*/
|
|
2602
|
-
async function appendWorkerDatabaseAdvisoryRows(deps, preview) {
|
|
2655
|
+
async function appendWorkerDatabaseAdvisoryRows(deps, preview, repository) {
|
|
2656
|
+
if (repository?.isBridge === false) {
|
|
2657
|
+
preview.launch_checks = [...(preview.launch_checks ?? []), ...nonBridgeRows(WORKER_DATABASE_PREVIEW_IDS)];
|
|
2658
|
+
return null;
|
|
2659
|
+
}
|
|
2660
|
+
if (repository === undefined)
|
|
2661
|
+
return null;
|
|
2603
2662
|
if (preview.target.kind !== "local_plane")
|
|
2604
2663
|
return null;
|
|
2605
2664
|
try {
|
|
@@ -3069,7 +3128,7 @@ function remoteRuntimeRefusal(epicKey, access, readiness) {
|
|
|
3069
3128
|
function durableCoverageRefusal(epicKey, access, profile, coverage, outcome) {
|
|
3070
3129
|
const remedy = [
|
|
3071
3130
|
"Start the durable host's executor with --repo-wide",
|
|
3072
|
-
" (`install
|
|
3131
|
+
" (`install epic-implementer --execution-mode durable --executor-id <id> --repo-wide`; see `drive-epic --help-advanced`),",
|
|
3073
3132
|
"or launch without the durable profile.",
|
|
3074
3133
|
].join("\n");
|
|
3075
3134
|
return {
|
|
@@ -3462,16 +3521,40 @@ export const DRIVE_EPIC_ACCESS_REFUSAL_REASON_IDS = {
|
|
|
3462
3521
|
"credentials-unavailable": "access-credentials-unavailable",
|
|
3463
3522
|
"credential-unbound": "access-credential-unbound",
|
|
3464
3523
|
};
|
|
3524
|
+
const WORKER_DATABASE_PREVIEW_IDS = ["worker-db-role", "worker-db-boundary", "worker-db-alembic", "worker-db-leftovers", "worker-db-unverifiable", "worker-db-harness"];
|
|
3525
|
+
function nonBridgeRows(ids) {
|
|
3526
|
+
return ids.map((id) => {
|
|
3527
|
+
const started = monotonicNow();
|
|
3528
|
+
return { id, label: id, status: "skip", blocking: false,
|
|
3529
|
+
reason: "not_bridge_repository", detail: "not_bridge_repository", duration_ms: elapsedMs(started) };
|
|
3530
|
+
});
|
|
3531
|
+
}
|
|
3465
3532
|
/** BAPI-1452 — project launch rows into the stable preview shape. */
|
|
3466
|
-
function previewLaunchRows(checks) {
|
|
3467
|
-
return checks.map((check) =>
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3533
|
+
export function previewLaunchRows(checks) {
|
|
3534
|
+
return checks.map((check) => {
|
|
3535
|
+
const started = monotonicNow();
|
|
3536
|
+
return {
|
|
3537
|
+
duration_ms: check.duration_ms ?? elapsedMs(started),
|
|
3538
|
+
id: check.id,
|
|
3539
|
+
label: check.label,
|
|
3540
|
+
status: check.status,
|
|
3541
|
+
blocking: check.blocking,
|
|
3542
|
+
...(check.detail ? { detail: check.detail } : {}),
|
|
3543
|
+
...(check.remediation ? { remedy: check.remediation } : {}),
|
|
3544
|
+
...harnessOwnerMetadata(check),
|
|
3545
|
+
};
|
|
3546
|
+
});
|
|
3547
|
+
}
|
|
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
|
+
};
|
|
3475
3558
|
}
|
|
3476
3559
|
/** The readiness reason a preview reports for a generic not-ready engine. */
|
|
3477
3560
|
const ENGINE_NOT_READY_REASON_ID = "engine-not-ready";
|
|
@@ -3578,9 +3661,21 @@ async function readPlanChildCount(deps, planPath) {
|
|
|
3578
3661
|
* named refusal in the same document.
|
|
3579
3662
|
*/
|
|
3580
3663
|
async function runDriveEpicPreview(deps, options) {
|
|
3664
|
+
const started = monotonicNow();
|
|
3665
|
+
const timings = {};
|
|
3666
|
+
const original = deps;
|
|
3667
|
+
const timed = (phase, run) => measurePrecheck(run, (duration) => { timings[phase] = duration; });
|
|
3668
|
+
deps = {
|
|
3669
|
+
...original,
|
|
3670
|
+
inspectRepositoryIdentity: () => timed("repository_identity_ms", () => original.inspectRepositoryIdentity()),
|
|
3671
|
+
readReadiness: (access) => timed("readiness_ms", () => original.readReadiness(access)),
|
|
3672
|
+
readLiveEpicRun: (access, epic) => timed("live_run_ms", () => original.readLiveEpicRun(access, epic)),
|
|
3673
|
+
previewSetupEpic: (args) => timed("setup_preview_ms", () => original.previewSetupEpic(args)),
|
|
3674
|
+
};
|
|
3581
3675
|
const { epicKey } = options;
|
|
3582
3676
|
const posture = options.attended === true || options.intoBase === true ? "attended" : "unattended";
|
|
3583
3677
|
const preview = {
|
|
3678
|
+
timings,
|
|
3584
3679
|
epic_key: epicKey,
|
|
3585
3680
|
target: { base_url: null, kind: null },
|
|
3586
3681
|
readiness: { kind: "unknown" },
|
|
@@ -3621,7 +3716,7 @@ async function runDriveEpicPreview(deps, options) {
|
|
|
3621
3716
|
// `null` when no read succeeded, which the row reports as unconfirmed.
|
|
3622
3717
|
const observed = { readiness: null };
|
|
3623
3718
|
try {
|
|
3624
|
-
await previewDecision(deps, options, preview, refuseWithReadiness, refuseTopLevel, observed);
|
|
3719
|
+
await timed("decision_ms", () => previewDecision(deps, options, preview, refuseWithReadiness, refuseTopLevel, observed));
|
|
3625
3720
|
}
|
|
3626
3721
|
catch {
|
|
3627
3722
|
// Sanitized on purpose: nothing from the thrown value reaches the document.
|
|
@@ -3633,10 +3728,46 @@ async function runDriveEpicPreview(deps, options) {
|
|
|
3633
3728
|
});
|
|
3634
3729
|
}
|
|
3635
3730
|
ensureRefusalExplained(preview);
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3731
|
+
if (observed.repository?.isBridge === false && !preview.launch_checks?.some((row) => row.id === "plane-snapshot-freshness")) {
|
|
3732
|
+
preview.launch_checks = [...(preview.launch_checks ?? []), ...nonBridgeRows(["plane-snapshot-freshness", "plane-database-head"])];
|
|
3733
|
+
}
|
|
3734
|
+
const isolated = () => ({ ...preview, launch_checks: [] });
|
|
3735
|
+
const worker = isolated();
|
|
3736
|
+
const escalation = isolated();
|
|
3737
|
+
const executor = isolated();
|
|
3738
|
+
const needs = isolated();
|
|
3739
|
+
const scopeBase = previewScopeBaseBranch.get(preview);
|
|
3740
|
+
if (scopeBase)
|
|
3741
|
+
previewScopeBaseBranch.set(needs, scopeBase);
|
|
3742
|
+
// Collect into private arrays; only launch-needs waits for the worker result.
|
|
3743
|
+
const workerTask = timed("worker_database_ms", () => appendWorkerDatabaseAdvisoryRows(deps, worker, observed.repository));
|
|
3744
|
+
const needsTask = workerTask.then((section) => {
|
|
3745
|
+
needs.launch_checks = [...(worker.launch_checks ?? [])];
|
|
3746
|
+
return timed("launch_needs_ms", () => appendLaunchNeedRows(deps, needs, observed, section));
|
|
3747
|
+
});
|
|
3748
|
+
await Promise.all([
|
|
3749
|
+
needsTask,
|
|
3750
|
+
timed("escalation_ms", async () => { appendEscalationReachabilityRow(escalation, observed.readiness); }),
|
|
3751
|
+
timed("executor_build_ms", () => appendExecutorBuildFreshnessWarning(deps, executor)),
|
|
3752
|
+
]);
|
|
3753
|
+
const workerIds = new Set(worker.launch_checks?.map((row) => row.id));
|
|
3754
|
+
const needRows = needs.launch_checks ?? [];
|
|
3755
|
+
preview.launch_checks = [
|
|
3756
|
+
...(preview.launch_checks ?? []), ...needRows.filter((row) => workerIds.has(row.id)),
|
|
3757
|
+
...(escalation.launch_checks ?? []), ...(executor.launch_checks ?? []),
|
|
3758
|
+
...needRows.filter((row) => !workerIds.has(row.id)),
|
|
3759
|
+
];
|
|
3760
|
+
if (preview.decision === "create") {
|
|
3761
|
+
try {
|
|
3762
|
+
const result = (deps.buildLaunchPlan ?? buildLaunchPlan)(preview);
|
|
3763
|
+
if (result)
|
|
3764
|
+
preview.launch_plan = result.launch_plan;
|
|
3765
|
+
}
|
|
3766
|
+
catch {
|
|
3767
|
+
deps.errorLog("Launch plan unavailable; the driving session will compute it.");
|
|
3768
|
+
}
|
|
3769
|
+
}
|
|
3770
|
+
timings.total_ms = elapsedMs(started);
|
|
3640
3771
|
const emitted = await emitPreview(deps, options, preview);
|
|
3641
3772
|
// BAPI-1397 (F3): a `--json` document that could not reach stdout whole is a
|
|
3642
3773
|
// failed preview, never a silently truncated one.
|
|
@@ -3655,6 +3786,7 @@ async function runDriveEpicPreview(deps, options) {
|
|
|
3655
3786
|
* A refused or stopped preview describes no launch, so it gets none.
|
|
3656
3787
|
*/
|
|
3657
3788
|
function appendEscalationReachabilityRow(preview, readiness) {
|
|
3789
|
+
const started = monotonicNow();
|
|
3658
3790
|
if (preview.decision !== "create" && preview.decision !== "attach")
|
|
3659
3791
|
return;
|
|
3660
3792
|
const [row] = previewLaunchRows([
|
|
@@ -3662,7 +3794,7 @@ function appendEscalationReachabilityRow(preview, readiness) {
|
|
|
3662
3794
|
]);
|
|
3663
3795
|
preview.launch_checks = [
|
|
3664
3796
|
...(preview.launch_checks ?? []).filter((existing) => existing.id !== ESCALATION_REACHABILITY_CHECK_ID),
|
|
3665
|
-
row,
|
|
3797
|
+
{ ...row, duration_ms: elapsedMs(started) },
|
|
3666
3798
|
];
|
|
3667
3799
|
}
|
|
3668
3800
|
/**
|
|
@@ -3674,6 +3806,7 @@ function appendEscalationReachabilityRow(preview, readiness) {
|
|
|
3674
3806
|
* fixed line and nothing from the exception.
|
|
3675
3807
|
*/
|
|
3676
3808
|
async function appendExecutorBuildFreshnessWarning(deps, preview) {
|
|
3809
|
+
const started = monotonicNow();
|
|
3677
3810
|
const override = process.env[BRIDGE_LAUNCHER_ENV];
|
|
3678
3811
|
if (override === undefined || override.trim() === "")
|
|
3679
3812
|
return;
|
|
@@ -3686,6 +3819,7 @@ async function appendExecutorBuildFreshnessWarning(deps, preview) {
|
|
|
3686
3819
|
const outcome = report.outcomes.find((entry) => entry.status === "warn" || entry.status === "fail") ?? report.outcomes[0];
|
|
3687
3820
|
const row = {
|
|
3688
3821
|
id: "executor-build-freshness",
|
|
3822
|
+
duration_ms: elapsedMs(started),
|
|
3689
3823
|
label: outcome?.label ?? "Executor build freshness",
|
|
3690
3824
|
status: "warn",
|
|
3691
3825
|
blocking: false,
|
|
@@ -3745,24 +3879,26 @@ async function appendLaunchNeedRows(deps, preview, observed, workerDatabase) {
|
|
|
3745
3879
|
if (preview.decision !== "create")
|
|
3746
3880
|
return;
|
|
3747
3881
|
try {
|
|
3748
|
-
const repoRoot = deps.cwd();
|
|
3882
|
+
const repoRoot = observed.repository?.repoRoot ?? deps.cwd();
|
|
3749
3883
|
const local = preview.target.kind === "local_plane";
|
|
3750
3884
|
const readiness = observed.readiness;
|
|
3751
3885
|
const access = observed.access;
|
|
3752
3886
|
const nowMs = (deps.now ?? Date.now)();
|
|
3887
|
+
const durations = [];
|
|
3888
|
+
const measured = (index, work) => measurePrecheck(work, (duration) => { durations[index] = duration; });
|
|
3753
3889
|
const [runner, power, usage, branch] = await Promise.all([
|
|
3754
|
-
guardedProbe(deps.inspectRequiredRunners === undefined
|
|
3890
|
+
measured(0, () => guardedProbe(deps.inspectRequiredRunners === undefined
|
|
3755
3891
|
? undefined
|
|
3756
3892
|
: () => deps.inspectRequiredRunners({
|
|
3757
3893
|
repoRoot,
|
|
3758
3894
|
providerRepository: readiness?.provider_repository,
|
|
3759
3895
|
gateProfile: readiness?.gate_profile,
|
|
3760
|
-
}), { state: "unverifiable", reason: "probe_failed" }),
|
|
3761
|
-
guardedProbe(() => collectHostPowerFact(deps, observed.launchTopology), { state: "unverifiable", reason: "probe_failed" }),
|
|
3762
|
-
guardedProbe(deps.fetchUsageAdvisory === undefined || access === undefined
|
|
3896
|
+
}), { state: "unverifiable", reason: "probe_failed" })),
|
|
3897
|
+
measured(1, () => guardedProbe(() => collectHostPowerFact(deps, observed.launchTopology), { state: "unverifiable", reason: "probe_failed" })),
|
|
3898
|
+
measured(2, () => guardedProbe(deps.fetchUsageAdvisory === undefined || access === undefined
|
|
3763
3899
|
? undefined
|
|
3764
|
-
: () => deps.fetchUsageAdvisory(access), null),
|
|
3765
|
-
guardedProbe(deps.inspectEpicBranchBehind === undefined
|
|
3900
|
+
: () => deps.fetchUsageAdvisory(access), null)),
|
|
3901
|
+
measured(3, () => guardedProbe(deps.inspectEpicBranchBehind === undefined
|
|
3766
3902
|
? undefined
|
|
3767
3903
|
: () => deps.inspectEpicBranchBehind({
|
|
3768
3904
|
repoRoot,
|
|
@@ -3770,9 +3906,12 @@ async function appendLaunchNeedRows(deps, preview, observed, workerDatabase) {
|
|
|
3770
3906
|
baseBranch: previewScopeBaseBranch.get(preview) ?? null,
|
|
3771
3907
|
}), preview.summary.branch === null
|
|
3772
3908
|
? { state: "not_applicable", reason: "no_epic_branch" }
|
|
3773
|
-
: { state: "unverifiable", reason: "git_failed" }),
|
|
3909
|
+
: { state: "unverifiable", reason: "git_failed" })),
|
|
3774
3910
|
]);
|
|
3775
|
-
const workerRow =
|
|
3911
|
+
const workerRow = observed.repository?.isBridge === false
|
|
3912
|
+
? { ...nonBridgeRows(["worker-db-role"])[0], launch_need: { need: "worker_db_role", state: "not_applicable", asked: false } }
|
|
3913
|
+
: { ...buildWorkerDbRoleLaunchRow(workerDatabase, local),
|
|
3914
|
+
duration_ms: workerDatabase?.rows.find((row) => row.id === "worker-db-role")?.duration_ms ?? elapsedMs(monotonicNow()) };
|
|
3776
3915
|
const rows = [
|
|
3777
3916
|
buildSelfHostedRunnerLaunchRow(runner),
|
|
3778
3917
|
buildHostPowerLaunchRow(power),
|
|
@@ -3782,7 +3921,7 @@ async function appendLaunchNeedRows(deps, preview, observed, workerDatabase) {
|
|
|
3782
3921
|
nowMs,
|
|
3783
3922
|
}),
|
|
3784
3923
|
buildEpicBranchBehindBaseLaunchRow(branch),
|
|
3785
|
-
];
|
|
3924
|
+
].map((row, index) => ({ ...row, duration_ms: durations[index] }));
|
|
3786
3925
|
const existing = preview.launch_checks ?? [];
|
|
3787
3926
|
const roleIndex = existing.findIndex((row) => row.id === workerRow.id);
|
|
3788
3927
|
const merged = roleIndex >= 0
|
|
@@ -3830,6 +3969,18 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
3830
3969
|
reasonId: READINESS_UNKNOWN_REASON_ID,
|
|
3831
3970
|
remedy: ESCALATE_REMEDY,
|
|
3832
3971
|
});
|
|
3972
|
+
try {
|
|
3973
|
+
observed.repository = await deps.inspectRepositoryIdentity();
|
|
3974
|
+
// This deps object is invocation-owned; subsequent relative probes use the
|
|
3975
|
+
// verified Git toplevel even when the command started in a subdirectory.
|
|
3976
|
+
deps.cwd = () => observed.repository.repoRoot;
|
|
3977
|
+
}
|
|
3978
|
+
catch {
|
|
3979
|
+
return refuseTopLevel({
|
|
3980
|
+
reasonId: "repository-identity-unverifiable",
|
|
3981
|
+
remedy: "Resolve the invocation Git worktree and its marker-file permissions, then preview again.",
|
|
3982
|
+
});
|
|
3983
|
+
}
|
|
3833
3984
|
// --- Target: resolved, never adopted. -------------------------------------
|
|
3834
3985
|
const accessResult = await deps.resolveAccess(options.repo, undefined, launchSelectionOf(options));
|
|
3835
3986
|
if (!accessResult.ok) {
|
|
@@ -3866,6 +4017,7 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
3866
4017
|
options,
|
|
3867
4018
|
access,
|
|
3868
4019
|
profile,
|
|
4020
|
+
previewRepository: observed.repository,
|
|
3869
4021
|
targetSource: accessResult.targetSource ?? "default",
|
|
3870
4022
|
freshness: createPlaneFreshnessCache(),
|
|
3871
4023
|
launchCredential: {},
|
|
@@ -3916,7 +4068,7 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
3916
4068
|
`${SCHEMA_INCOMPATIBLE_REPAIR_ROUTE} Nothing was created or started.`,
|
|
3917
4069
|
});
|
|
3918
4070
|
}
|
|
3919
|
-
if (planPath !== undefined && endpoint !== null && profile?.executionMode !== "durable" &&
|
|
4071
|
+
if (observed.repository.isBridge && planPath !== undefined && endpoint !== null && profile?.executionMode !== "durable" &&
|
|
3920
4072
|
err instanceof ConductorBridgeApiError && err.kind === "network") {
|
|
3921
4073
|
const probe = await deps.probePlanePort(endpoint.host, endpoint.port).catch(() => ({ kind: "error" }));
|
|
3922
4074
|
if (probe.kind === "refused") {
|
|
@@ -3993,7 +4145,13 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
3993
4145
|
const attachingDiscoveredPlan = options.planFile === undefined && plan.status === "found" && live.kind === "live";
|
|
3994
4146
|
const effectivePlanPath = attachingDiscoveredPlan ? undefined : planPath;
|
|
3995
4147
|
const previewCtx = { ...ctx, options: { ...options, ...(effectivePlanPath ? { planFile: effectivePlanPath } : {}) } };
|
|
3996
|
-
const
|
|
4148
|
+
const observations = {
|
|
4149
|
+
endpoint: access.baseUrl, repository: access.repoName, epic: epicKey,
|
|
4150
|
+
readiness: { state: "supplied", value: readiness },
|
|
4151
|
+
liveRun: live.kind === "none" ? { state: "absent" }
|
|
4152
|
+
: live.kind === "live" && live.state ? { state: "supplied", value: live.state } : { state: "error" },
|
|
4153
|
+
};
|
|
4154
|
+
const prepared = effectivePlanPath ? await prepareSetupSelection(previewCtx, false, live) : null;
|
|
3997
4155
|
if (prepared !== null && !prepared.ok) {
|
|
3998
4156
|
return refuseTopLevel({
|
|
3999
4157
|
reasonId: prepared.reasonId,
|
|
@@ -4010,7 +4168,7 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
4010
4168
|
if (classification.kind === 'operator_blocked') {
|
|
4011
4169
|
const requirement = V2_READINESS_REQUIREMENTS.find(req => req.id === classification.id);
|
|
4012
4170
|
if (requirement)
|
|
4013
|
-
preview.launch_checks = [{ id: requirement.id, label: requirement.describe, status: 'fail', blocking: true, remedy: classification.remedy }];
|
|
4171
|
+
preview.launch_checks = [{ id: requirement.id, label: requirement.describe, status: 'fail', blocking: true, remedy: classification.remedy, duration_ms: elapsedMs(monotonicNow()) }];
|
|
4014
4172
|
}
|
|
4015
4173
|
const selection = selectConductor(readiness);
|
|
4016
4174
|
// --- The live run. Conflict and unknown refuse whatever the plan says. ------
|
|
@@ -4078,13 +4236,15 @@ async function previewDecision(deps, options, preview, refuseWithReadiness, refu
|
|
|
4078
4236
|
const launchTopology = planeTarget && classification.kind === "runtime_only"
|
|
4079
4237
|
? { kind: "plane_lane" }
|
|
4080
4238
|
: topology.value ?? { kind: "local", repoRoot: null };
|
|
4239
|
+
const mergedEvaluation = live.kind !== "live" && options.noMergedCheck !== true
|
|
4240
|
+
? evaluateMergedChildren(ctx, planPathForCreate).catch(() => notChecked("check_failed")) : undefined;
|
|
4081
4241
|
const launch = await previewLaunchCapability(prepared?.ok ? { ...previewCtx, handoff: prepared.handoff } : previewCtx, readiness, launchTopology);
|
|
4082
4242
|
preview.launch_checks = previewLaunchRows(launch.checks);
|
|
4083
4243
|
if (launch.refusal !== null)
|
|
4084
4244
|
return refuseWithReadiness("operator_blocked", launch.refusal);
|
|
4085
4245
|
observed.access = access;
|
|
4086
4246
|
observed.launchTopology = launchTopology;
|
|
4087
|
-
await finalizeCreatePreview(prepared?.ok ? { ...previewCtx, handoff: prepared.handoff } : previewCtx, preview, planPathForCreate, false, refuseTopLevel, live.kind === "live");
|
|
4247
|
+
await finalizeCreatePreview(prepared?.ok ? { ...previewCtx, handoff: prepared.handoff, previewObservations: observations, previewMergedEvaluation: mergedEvaluation } : { ...previewCtx, previewObservations: observations, previewMergedEvaluation: mergedEvaluation }, preview, planPathForCreate, false, refuseTopLevel, live.kind === "live");
|
|
4088
4248
|
await applyPreviewFreshness(ctx, preview, topology, false);
|
|
4089
4249
|
}
|
|
4090
4250
|
async function finalizeCreatePreview(ctx, preview, planPath, coldStart, refuseTopLevel, liveRunKnown = false) {
|
|
@@ -4106,6 +4266,10 @@ async function finalizeCreatePreview(ctx, preview, planPath, coldStart, refuseTo
|
|
|
4106
4266
|
? "webhook"
|
|
4107
4267
|
: prepared.handoff.selection.escalationChannel === "account email" ? "email" : null;
|
|
4108
4268
|
}
|
|
4269
|
+
// Compatibility path when no trusted repository-applicability fact is supplied.
|
|
4270
|
+
// Unknown is advisory, not a prerequisite on the sibling identity gate. Neither
|
|
4271
|
+
// declared paths nor target topology can establish repository identity.
|
|
4272
|
+
preview.plan_database_relevance = "unknown";
|
|
4109
4273
|
preview.summary.child_count = await readPlanChildCount(deps, planPath);
|
|
4110
4274
|
preview.summary.children_to_run = preview.summary.child_count;
|
|
4111
4275
|
// BAPI-1510 — the already-merged check, after plan discovery and BEFORE the
|
|
@@ -4123,7 +4287,7 @@ async function finalizeCreatePreview(ctx, preview, planPath, coldStart, refuseTo
|
|
|
4123
4287
|
preview.already_done_children = { status: "not_checked", reason: "cold_start", children: [] };
|
|
4124
4288
|
}
|
|
4125
4289
|
else {
|
|
4126
|
-
evaluation = await evaluateMergedChildren(ctx, planPath);
|
|
4290
|
+
evaluation = await (ctx.previewMergedEvaluation ?? evaluateMergedChildren(ctx, planPath));
|
|
4127
4291
|
preview.already_done_children = evaluation.state;
|
|
4128
4292
|
if (evaluation.refusals.length > 0) {
|
|
4129
4293
|
return refuseTopLevel({
|
|
@@ -4150,6 +4314,7 @@ async function finalizeCreatePreview(ctx, preview, planPath, coldStart, refuseTo
|
|
|
4150
4314
|
const runPreviewSetup = (effectivePlanPath) => deps.previewSetupEpic({
|
|
4151
4315
|
argv: [...buildSetupEpicArgv({ ...options, planFile: effectivePlanPath }), ...(coldStart ? ["--local-only"] : []), "--dry-run", "--json"],
|
|
4152
4316
|
baseUrl: access.baseUrl,
|
|
4317
|
+
observations: ctx.previewObservations,
|
|
4153
4318
|
handoff: trim !== null ? { ...prepared.handoff, expectedCutCommitSha: trim.cut } : prepared.handoff,
|
|
4154
4319
|
});
|
|
4155
4320
|
const setup = trim !== null
|
|
@@ -4247,6 +4412,10 @@ function previewReadinessRefusal(ctx, classification, readiness, planeTarget, pa
|
|
|
4247
4412
|
async function applyPreviewFreshness(ctx, preview, topology, coldStart) {
|
|
4248
4413
|
if (preview.decision !== "create" && preview.decision !== "attach")
|
|
4249
4414
|
return;
|
|
4415
|
+
if (ctx.previewRepository?.isBridge === false) {
|
|
4416
|
+
preview.launch_checks = [...(preview.launch_checks ?? []), ...nonBridgeRows(["plane-snapshot-freshness", "plane-database-head"])];
|
|
4417
|
+
return;
|
|
4418
|
+
}
|
|
4250
4419
|
const { deps } = ctx;
|
|
4251
4420
|
if (planeEndpointForBaseUrl(deps, ctx.access.baseUrl) === null)
|
|
4252
4421
|
return;
|
|
@@ -4266,7 +4435,7 @@ async function applyPreviewFreshness(ctx, preview, topology, coldStart) {
|
|
|
4266
4435
|
const sleep = preview.decision === "attach" ? await collectHostSleep(ctx, own.repoRoot) : null;
|
|
4267
4436
|
// Read-only: one run-state read, local plane only, and only for a bound plane.
|
|
4268
4437
|
const boundRun = await boundRunForStaleRemedy(ctx, own, reports);
|
|
4269
|
-
const assessment = assessPlaneFreshness(reports, sleep, preview.decision === "create" ? "create" : "attach", ctx.options.allowStalePlane === true, boundRun);
|
|
4438
|
+
const assessment = assessPlaneFreshness(reports, sleep, preview.decision === "create" ? "create" : "attach", ctx.options.allowStalePlane === true, boundRun, true);
|
|
4270
4439
|
if (assessment.rows.length > 0) {
|
|
4271
4440
|
preview.launch_checks = [...(preview.launch_checks ?? []), ...assessment.rows];
|
|
4272
4441
|
}
|
|
@@ -4308,7 +4477,7 @@ topologyOut) {
|
|
|
4308
4477
|
? null
|
|
4309
4478
|
: durableCoverageRefusal(epicKey, access, profile, coverage, outcome);
|
|
4310
4479
|
}
|
|
4311
|
-
if (planeTarget) {
|
|
4480
|
+
if (planeTarget && ctx.previewRepository?.isBridge !== false) {
|
|
4312
4481
|
if (live !== null) {
|
|
4313
4482
|
const manifest = await findAttachablePlane(ctx).catch(() => null);
|
|
4314
4483
|
if (topologyOut)
|
|
@@ -4382,7 +4551,7 @@ const UNKNOWN_REASON_TEXT = {
|
|
|
4382
4551
|
const NOT_CHECKED_TEXT = {
|
|
4383
4552
|
disabled: "Merged check: turned off (--no-merged-check). Every child will run.",
|
|
4384
4553
|
attach: "Merged check: not applied; existing runs are unchanged.",
|
|
4385
|
-
cold_start: "Merged check: will be checked at create.",
|
|
4554
|
+
cold_start: "Merged check: will be checked at create. Already-merged children will be skipped; pass --keep-child <KEY> to keep one.",
|
|
4386
4555
|
cut_commit_unavailable: "Merged check: the indexed commit could not be read. Every child will run.",
|
|
4387
4556
|
check_failed: "Merged check: could not complete. Every child will run.",
|
|
4388
4557
|
no_plan: null,
|
|
@@ -4392,7 +4561,7 @@ const NOT_CHECKED_TEXT = {
|
|
|
4392
4561
|
* children to run and skipped, then the groups in a fixed order. Meaning is carried
|
|
4393
4562
|
* by words, never colour; only customer ticket keys and validated PR numbers appear.
|
|
4394
4563
|
*/
|
|
4395
|
-
function alreadyDoneLines(preview) {
|
|
4564
|
+
export function alreadyDoneLines(preview) {
|
|
4396
4565
|
const s = preview.summary;
|
|
4397
4566
|
const state = preview.already_done_children ?? { status: "not_checked", reason: "no_plan", children: [] };
|
|
4398
4567
|
const lines = [];
|
|
@@ -4418,8 +4587,14 @@ function alreadyDoneLines(preview) {
|
|
|
4418
4587
|
: "";
|
|
4419
4588
|
if (skipped.length > 0) {
|
|
4420
4589
|
lines.push(" Skipped (already merged):");
|
|
4421
|
-
|
|
4422
|
-
|
|
4590
|
+
const confirmedMerged = skipped.filter((child) => child.classification === "done");
|
|
4591
|
+
for (const child of confirmedMerged) {
|
|
4592
|
+
lines.push(` already merged, will skip: ${child.ticket_key}${pr(child)}`);
|
|
4593
|
+
}
|
|
4594
|
+
if (confirmedMerged.length > 0)
|
|
4595
|
+
lines.push(" To keep one, pass --keep-child <KEY>.");
|
|
4596
|
+
for (const child of skipped.filter((entry) => entry.classification !== "done")) {
|
|
4597
|
+
lines.push(` ${child.ticket_key}${pr(child)} — confirmed skip`);
|
|
4423
4598
|
}
|
|
4424
4599
|
}
|
|
4425
4600
|
const probably = state.children.filter((child) => child.classification === "probably_done" && !child.will_skip);
|
|
@@ -4491,7 +4666,16 @@ async function emitPreview(deps, options, preview) {
|
|
|
4491
4666
|
lines.push(` skipped: ${skipped.path} (${skipped.reason})`);
|
|
4492
4667
|
}
|
|
4493
4668
|
const s = preview.summary;
|
|
4494
|
-
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"}`, ` Auto-merge: ${s.auto_merge_scope ?? "n/a"}`, ` Escalation: ${s.escalation_channel ?? "n/a"}`, ...reachabilityLines(preview),
|
|
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"}`, ` Auto-merge: ${s.auto_merge_scope ?? "n/a"}`, ` Escalation: ${s.escalation_channel ?? "n/a"}`, ...reachabilityLines(preview), ...(preview.launch_plan ? [
|
|
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}`);
|
|
4495
4679
|
if (isPlaneDownStop(preview)) {
|
|
4496
4680
|
// The shared stop text, verbatim and unindented, so it reads exactly as the
|
|
4497
4681
|
// real launch prints it. It is a stop, not a refusal.
|