@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
|
@@ -1,185 +1,342 @@
|
|
|
1
|
-
import { sanitizeHarnessCoverage } from "../executor/harness-coverage.js";
|
|
2
1
|
import { EPIC_KEY_PATTERN } from "../drive-epic-key.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { WORKER_DATABASE_DOCTOR_OWNER, WORKER_DATABASE_DOCTOR_RUNBOOK_SECTION } from "./doctor.js";
|
|
3
|
+
import { LAUNCH_NEED_REMEDIES, LAUNCH_NEED_ROW_IDS, LAUNCH_NEEDS } from "./readiness-sections.js";
|
|
4
|
+
export const NO_LAUNCH_PLAN_FACTS = Object.freeze({
|
|
5
|
+
prerequisites: { status: "not_collected" },
|
|
6
|
+
handoff: { explicit: null, projectDefault: "unknown" },
|
|
7
|
+
});
|
|
8
|
+
/** Fixed meaning of the per-run parallel limit, shared by every surface that names it. */
|
|
9
|
+
export const PARALLEL_LIMIT_MEANING_COPY = "Up to this many independent children may run concurrently, subject to executor or plane capacity.";
|
|
10
|
+
/** Fixed advisory for changing an approved parallel limit. */
|
|
11
|
+
export const PARALLEL_LIMIT_CHANGE_ADVISORY = "Raising the approved limit requires a run policy PATCH and re-approval, then a new executor or relaunched plane lanes; lowering via parallel_throttle takes effect at the next claim and needs nothing local.";
|
|
12
|
+
/** Approximate time to the first job. Fixed copy: it measures start-up, not the whole run. */
|
|
13
|
+
export const LAUNCH_PLAN_DURATION = {
|
|
14
|
+
local: "About 10 minutes to the first job.",
|
|
15
|
+
remote: "About 5 minutes to the first job.",
|
|
16
|
+
nothing: "Nothing is created.",
|
|
17
|
+
};
|
|
18
|
+
export const LAUNCH_PLAN_LOCAL_HANDOFF = "Because this is a local run, I'll give you one command to run in your own terminal.";
|
|
19
|
+
const WORKER_DATABASE_REMEDY = `${WORKER_DATABASE_DOCTOR_OWNER}: see ${WORKER_DATABASE_DOCTOR_RUNBOOK_SECTION}`;
|
|
20
|
+
/** The two server prerequisite rows that can be an authoritative refusal. */
|
|
21
|
+
export const SERVER_WEBHOOK_ROW_ID = "server.escalation-webhook-reachable";
|
|
22
|
+
export const SERVER_PROVIDER_BRANCH_ROW_ID = "server.provider-default-branch-readable";
|
|
7
23
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* probably_done child | run it | [] | skip: [--skip-child, KEY]
|
|
12
|
-
* applicable relevant role / other unhealthy DB | fix first | [] | launch anyway: []
|
|
13
|
-
* asked/present runner | fix first | [] | launch anyway: []
|
|
14
|
-
* asked/present power | proceed, keep the lid open | [] | fix first: []
|
|
15
|
-
* asked/present usage | proceed | [] | fix first: []
|
|
16
|
-
* Fix-first acceptance accepts unresolved risk; it never performs remediation.
|
|
17
|
-
* verification_gap belongs exclusively to the command session, not this union.
|
|
24
|
+
* BAPI-1585 — the two pre-create refusal codes for those rows. Spelled once here;
|
|
25
|
+
* `drive-epic.ts` builds its refusal-id table from them, and
|
|
26
|
+
* `readiness-prerequisites-contract.test.ts` pins them against `pre_create_refusal.py`.
|
|
18
27
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (!applicable || !Array.isArray(nodes))
|
|
23
|
-
return "unknown";
|
|
24
|
-
let declared = false;
|
|
25
|
-
let malformed = false;
|
|
26
|
-
let relevant = false;
|
|
27
|
-
for (const node of nodes) {
|
|
28
|
-
if (!isObject(node)) {
|
|
29
|
-
malformed = true;
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (!("touched_files" in node))
|
|
33
|
-
continue;
|
|
34
|
-
if (!Array.isArray(node.touched_files)) {
|
|
35
|
-
malformed = true;
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
declared = true;
|
|
39
|
-
for (const raw of node.touched_files) {
|
|
40
|
-
const path = normalizeRepoRelativePath(raw);
|
|
41
|
-
if (path === null) {
|
|
42
|
-
malformed = true;
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
if (DB_OR_HARNESS_PATH_HINTS.some((hint) => path.startsWith(hint)) || path.includes("/migrations/"))
|
|
46
|
-
relevant = true;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return relevant ? true : malformed || !declared ? "unknown" : false;
|
|
50
|
-
}
|
|
51
|
-
export const LAUNCH_PLAN_REACHABILITY_COPY = {
|
|
52
|
-
summary: "Escalation reachability",
|
|
53
|
-
reason: "Live delivery is not confirmed; escalations are also shown in the driving session.",
|
|
54
|
-
remedy: "Declare notify.webhook_url in the run policy, or configure live email.",
|
|
55
|
-
};
|
|
56
|
-
export const LAUNCH_PLAN_MERGED_CHILD_COPY = {
|
|
57
|
-
summary: "Already merged child",
|
|
58
|
-
reason: "The child is already merged on the indexed commit and is scheduled to be skipped.",
|
|
59
|
-
remedy: "Nothing to do, or keep the child in this plan to run it again.",
|
|
28
|
+
export const LAUNCH_PRE_CREATE_CODES = {
|
|
29
|
+
ESCALATION_WEBHOOK_UNREACHABLE: "escalation_webhook_unreachable",
|
|
30
|
+
PROVIDER_DEFAULT_BRANCH_UNREADABLE: "provider_default_branch_unreadable",
|
|
60
31
|
};
|
|
61
|
-
export const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
32
|
+
export const LAUNCH_PLAN_COPY = {
|
|
33
|
+
blockedSummary: "Bridge found a proven problem that could cause harm if the run started.",
|
|
34
|
+
blockedWebhook: {
|
|
35
|
+
summary: "Your escalation webhook doesn't answer, and no account email can take over.",
|
|
36
|
+
reason: "An unattended run could ask for help and reach nobody.",
|
|
37
|
+
},
|
|
38
|
+
blockedProviderBranch: {
|
|
39
|
+
summary: "Bridge can't read your repository's default branch.",
|
|
40
|
+
reason: "Merge and delivery guards can't check the base branch without it.",
|
|
41
|
+
},
|
|
42
|
+
webhookFallback: {
|
|
43
|
+
summary: "Your webhook didn't answer. Escalations will go to your account email.",
|
|
44
|
+
reason: "The run keeps going; you will be reached by email instead.",
|
|
45
|
+
},
|
|
46
|
+
boundary: {
|
|
47
|
+
summary: "The worker database role can reach a protected database.",
|
|
48
|
+
reason: "A worker could write outside the run. This is proven, not a guess.",
|
|
49
|
+
},
|
|
50
|
+
workerRole: {
|
|
51
|
+
summary: "The worker database role isn't confirmed safe.",
|
|
52
|
+
reason: "Database-backed checks may be unable to run. The run keeps going and hands those off.",
|
|
53
|
+
},
|
|
54
|
+
selfHostedRunner: {
|
|
55
|
+
summary: "A self-hosted runner your required checks need is offline.",
|
|
56
|
+
reason: "Child checks cannot turn green while it is offline.",
|
|
57
|
+
},
|
|
58
|
+
hostPower: {
|
|
59
|
+
summary: "This computer may go to sleep during the run.",
|
|
60
|
+
reason: "The run needs the machine awake to keep working.",
|
|
61
|
+
},
|
|
78
62
|
};
|
|
79
63
|
function isObject(value) {
|
|
80
64
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
81
65
|
}
|
|
82
|
-
/**
|
|
83
|
-
function
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
66
|
+
/** An eligible, present launch-need row: the typed metadata is complete and the row warns. */
|
|
67
|
+
function presentNeed(rows, need) {
|
|
68
|
+
return rows.find((row) => {
|
|
69
|
+
const meta = row.launch_need;
|
|
70
|
+
return isObject(meta) && LAUNCH_NEEDS.includes(meta.need) && meta.need === need &&
|
|
71
|
+
meta.state === "present" && row.id === LAUNCH_NEED_ROW_IDS[need] && row.status === "warn" &&
|
|
72
|
+
row.blocking === false && typeof row.remedy === "string" && row.remedy.trim() !== "";
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/** The effective policy this launch will stamp: the explicit choice, else the project default. */
|
|
76
|
+
function effectiveHandoff(facts) {
|
|
77
|
+
return facts.explicit ?? facts.projectDefault;
|
|
78
|
+
}
|
|
79
|
+
function handoffLine(facts, children) {
|
|
80
|
+
const effective = effectiveHandoff(facts);
|
|
81
|
+
const who = children === 1 ? "One child has" : `${children} children have`;
|
|
82
|
+
const base = `${who} a check that neither the workers nor CI may be able to run.`;
|
|
83
|
+
let reason;
|
|
84
|
+
if (effective === "block") {
|
|
85
|
+
reason = "This launch is set to stop such a child instead of handing the check off. You decide what to do with it.";
|
|
86
|
+
}
|
|
87
|
+
else if (effective === "proceed") {
|
|
88
|
+
reason = "If so, the worker records a hand-off and the run keeps going. You review it at the end.";
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
reason =
|
|
92
|
+
"Your Bridge server didn't report the project default: unknown (today's default: proceed). " +
|
|
93
|
+
"If a check can't run, the worker records a hand-off and the run keeps going.";
|
|
94
|
+
}
|
|
95
|
+
if (facts.explicit !== null && facts.projectDefault !== "unknown" && facts.explicit !== facts.projectDefault) {
|
|
96
|
+
reason += ` The project default is ${facts.projectDefault}; this launch uses ${facts.explicit}.`;
|
|
97
|
+
}
|
|
98
|
+
return { summary: base, reason };
|
|
99
|
+
}
|
|
100
|
+
function summaryLine(preview, blocked) {
|
|
101
|
+
const local = preview.target.kind === "local_plane";
|
|
102
|
+
const where = local ? "on your local plane" : "on the server";
|
|
103
|
+
if (blocked)
|
|
104
|
+
return `${preview.epic_key} can't launch yet.`;
|
|
105
|
+
const count = preview.summary.children_to_run ?? preview.summary.child_count;
|
|
106
|
+
const parts = [];
|
|
107
|
+
if (typeof count === "number")
|
|
108
|
+
parts.push(`${count} ${count === 1 ? "child" : "children"}`);
|
|
109
|
+
const limit = preview.summary.parallel_limit;
|
|
110
|
+
if (typeof limit === "number" && limit > 0)
|
|
111
|
+
parts.push(`up to ${limit} at a time`);
|
|
112
|
+
parts.push(where);
|
|
113
|
+
return `${preview.epic_key} is ready to launch: ${parts.join(", ")}.`;
|
|
114
|
+
}
|
|
115
|
+
function launchOption(number, label, local, recommended) {
|
|
116
|
+
return {
|
|
117
|
+
number,
|
|
118
|
+
label,
|
|
119
|
+
description: local
|
|
120
|
+
? "Creates the run and starts it on your local plane."
|
|
121
|
+
: "Creates the run and starts it on the server.",
|
|
122
|
+
duration: local ? LAUNCH_PLAN_DURATION.local : LAUNCH_PLAN_DURATION.remote,
|
|
123
|
+
recommended,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function nothingOption(number, label, recommended) {
|
|
127
|
+
return { number, label, description: "Creates nothing and changes nothing.", duration: LAUNCH_PLAN_DURATION.nothing, recommended };
|
|
93
128
|
}
|
|
94
|
-
|
|
95
|
-
|
|
129
|
+
/** The health-check template: always built, inserted by the session only after a non-zero exit. */
|
|
130
|
+
function healthCheckFailedFragment(local) {
|
|
131
|
+
return {
|
|
132
|
+
item: {
|
|
133
|
+
summary: "The Epic Implementer health check did not pass.",
|
|
134
|
+
reason: "The engine code on this checkout may not work. Launching on it could waste the run.",
|
|
135
|
+
},
|
|
136
|
+
recommendation: "stop and fix first.",
|
|
137
|
+
reason: "The health check is how Bridge confirms this checkout's engine works before it spends a run.",
|
|
138
|
+
options: [
|
|
139
|
+
launchOption(1, "Launch anyway", local, false),
|
|
140
|
+
nothingOption(2, "Stop and fix", true),
|
|
141
|
+
],
|
|
142
|
+
option_actions: [
|
|
143
|
+
{ number: 1, action: "launch", argv: [] },
|
|
144
|
+
{ number: 2, action: "create_nothing", argv: [] },
|
|
145
|
+
],
|
|
146
|
+
};
|
|
96
147
|
}
|
|
97
148
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
149
|
+
* Pure projection of a finished preview and normalized facts. Returns `undefined`
|
|
150
|
+
* for a path with no launch decision to present: an attach/reuse, a stop, or a
|
|
151
|
+
* refusal the preview did not select as authoritative.
|
|
101
152
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
153
|
+
/** BAPI-1621 — the details id of the generated-plan item. */
|
|
154
|
+
export const GENERATED_PLAN_ITEM_ID = "plan-generated";
|
|
155
|
+
const SERIALIZED_REASON_COPY = {
|
|
156
|
+
unknown_touched_files: (unknown) => `It runs one child at a time, because the files ${unknown.length === 1 ? "this child touches" : "these children touch"} ` +
|
|
157
|
+
`could not be determined from their tickets: ${unknown.join(", ")}.`,
|
|
158
|
+
key_order_fallback: () => "It runs one child at a time, in ticket-key order, because the epic has no usable ordered child manifest.",
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* BAPI-1621 — the generated-plan explanation: why it is serial (first), where
|
|
162
|
+
* the order came from, which spikes were left out, then every child in order
|
|
163
|
+
* with its dependency. Built from the preview's own plan fields only.
|
|
164
|
+
*/
|
|
165
|
+
function generatedPlanItem(preview) {
|
|
166
|
+
const plan = preview.plan;
|
|
167
|
+
if (plan.generated !== true)
|
|
168
|
+
return null;
|
|
169
|
+
const source = plan.inline ?? plan.generation;
|
|
170
|
+
if (source === undefined)
|
|
171
|
+
return null;
|
|
172
|
+
const summary = source.summary;
|
|
173
|
+
const parts = [];
|
|
174
|
+
if (summary?.serialized_reason) {
|
|
175
|
+
parts.push(SERIALIZED_REASON_COPY[summary.serialized_reason]?.(summary.unknown_files) ?? "It runs one child at a time.");
|
|
176
|
+
}
|
|
177
|
+
if (summary !== null) {
|
|
178
|
+
parts.push(summary.order_source === "epic_manifest"
|
|
179
|
+
? "Order and dependencies come from the epic's ordered child manifest."
|
|
180
|
+
: "Order is ascending ticket key.");
|
|
181
|
+
for (const entry of summary.excluded) {
|
|
182
|
+
parts.push(`Left out: ${entry.ticket_key} (${entry.reason}; the Epic Implementer cannot run an unfinished spike).`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const order = source.nodes.map((node, index) => {
|
|
186
|
+
const after = node.depends_on.length > 0 ? `runs after ${node.depends_on.join(", ")}` : "no dependency";
|
|
187
|
+
return `${index + 1}. ${node.ticket_key} (${node.status}) — ${after}`;
|
|
188
|
+
});
|
|
189
|
+
parts.push(`Order: ${order.join("; ")}.`);
|
|
190
|
+
parts.push("It was built from stored ticket data by fixed rules, with no model.");
|
|
191
|
+
if (plan.status === "generated" && plan.would_write) {
|
|
192
|
+
parts.push(`This preview wrote nothing; launching rebuilds it from current data and saves it to ${plan.would_write}.`);
|
|
193
|
+
}
|
|
194
|
+
return { summary: "GENERATED — Generated from current epic children.", reason: parts.join(" ") };
|
|
112
195
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (preview.decision !== "create")
|
|
196
|
+
export function buildLaunchPlan(preview, facts = NO_LAUNCH_PLAN_FACTS) {
|
|
197
|
+
const refusal = preview.decision === "refuse" && preview.refusal?.authoritative === true ? preview.refusal : null;
|
|
198
|
+
if (preview.decision !== "create" && refusal === null)
|
|
116
199
|
return undefined;
|
|
200
|
+
const local = preview.target.kind === "local_plane";
|
|
117
201
|
const rows = Array.isArray(preview.launch_checks) ? preview.launch_checks.filter(isObject) : [];
|
|
118
|
-
const items = [];
|
|
119
|
-
const
|
|
120
|
-
const add = (entry) => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
items.push(entry);
|
|
124
|
-
}
|
|
202
|
+
const items = { blocks_launch: [], needs_choice: [], worth_knowing: [] };
|
|
203
|
+
const detailItems = [];
|
|
204
|
+
const add = (group, entry, id, flags) => {
|
|
205
|
+
detailItems.push({ group, index: items[group].length, id, ...(flags !== undefined ? { flags } : {}) });
|
|
206
|
+
items[group].push(entry);
|
|
125
207
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
208
|
+
const prerequisites = Array.isArray(preview.prerequisites) ? preview.prerequisites : [];
|
|
209
|
+
const prerequisiteRow = (id) => prerequisites.find((row) => row.id === id);
|
|
210
|
+
// --- blocks the launch: the one refusal the preview already selected -------------
|
|
211
|
+
if (refusal !== null) {
|
|
212
|
+
const webhook = prerequisiteRow(SERVER_WEBHOOK_ROW_ID);
|
|
213
|
+
const branch = prerequisiteRow(SERVER_PROVIDER_BRANCH_ROW_ID);
|
|
214
|
+
const copy = webhook?.check_status === "not_met" && webhook.impact === "blocking" && refusal.reason_id === LAUNCH_PRE_CREATE_CODES.ESCALATION_WEBHOOK_UNREACHABLE
|
|
215
|
+
? LAUNCH_PLAN_COPY.blockedWebhook
|
|
216
|
+
: branch?.check_status === "not_met" && branch.impact === "blocking" && refusal.reason_id === LAUNCH_PRE_CREATE_CODES.PROVIDER_DEFAULT_BRANCH_UNREADABLE
|
|
217
|
+
? LAUNCH_PLAN_COPY.blockedProviderBranch
|
|
218
|
+
: { summary: LAUNCH_PLAN_COPY.blockedSummary, reason: "Bridge stops here so nothing is started that could cause harm." };
|
|
219
|
+
add("blocks_launch", { summary: copy.summary, reason: copy.reason, remedy: refusal.remedy }, refusal.reason_id);
|
|
220
|
+
}
|
|
221
|
+
// --- worth knowing: webhook fell back to email (never a refusal) ------------------
|
|
222
|
+
const webhookRow = prerequisiteRow(SERVER_WEBHOOK_ROW_ID);
|
|
223
|
+
if (refusal === null && webhookRow !== undefined && webhookRow.impact === "warning" &&
|
|
224
|
+
(webhookRow.check_status === "met" || webhookRow.check_status === "not_met")) {
|
|
225
|
+
add("worth_knowing", { ...LAUNCH_PLAN_COPY.webhookFallback }, SERVER_WEBHOOK_ROW_ID);
|
|
226
|
+
}
|
|
227
|
+
// --- needs your choice -----------------------------------------------------------
|
|
228
|
+
let boundaryProven = false;
|
|
229
|
+
if (refusal === null) {
|
|
230
|
+
for (const row of rows) {
|
|
231
|
+
// A boundary row is proven harm only when the producer stamped its typed state `unsafe`.
|
|
232
|
+
if (row.id === "worker-db-boundary" && row.worker_state === "unsafe" && row.blocking === false) {
|
|
233
|
+
boundaryProven = true;
|
|
234
|
+
add("needs_choice", { ...LAUNCH_PLAN_COPY.boundary, remedy: WORKER_DATABASE_REMEDY }, "worker-db-boundary");
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
129
238
|
}
|
|
239
|
+
const prerequisiteFacts = facts.prerequisites;
|
|
240
|
+
const missingCore = refusal === null && prerequisiteFacts.status === "collected" ? prerequisiteFacts.missingCore : [];
|
|
241
|
+
for (const entry of missingCore) {
|
|
242
|
+
const sure = entry.uncertain ? " We are not sure this one is essential." : "";
|
|
243
|
+
add("needs_choice", {
|
|
244
|
+
summary: `${entry.requirement} isn't set in this terminal.`,
|
|
245
|
+
reason: `${entry.dependents} will stop without it. Tickets that don't depend on it keep going.${sure}`,
|
|
246
|
+
}, entry.name);
|
|
247
|
+
}
|
|
248
|
+
// --- worth knowing: surviving non-blocking evidence ------------------------------
|
|
249
|
+
if (refusal === null) {
|
|
250
|
+
const roleRow = presentNeed(rows, "worker_db_role");
|
|
251
|
+
if (roleRow)
|
|
252
|
+
add("worth_knowing", { ...LAUNCH_PLAN_COPY.workerRole, remedy: LAUNCH_NEED_REMEDIES.worker_db_role }, roleRow.id);
|
|
253
|
+
const runnerRow = presentNeed(rows, "self_hosted_runner");
|
|
254
|
+
if (runnerRow)
|
|
255
|
+
add("worth_knowing", { ...LAUNCH_PLAN_COPY.selfHostedRunner, remedy: LAUNCH_NEED_REMEDIES.self_hosted_runner }, runnerRow.id);
|
|
256
|
+
const powerRow = presentNeed(rows, "host_power");
|
|
257
|
+
if (powerRow)
|
|
258
|
+
add("worth_knowing", { ...LAUNCH_PLAN_COPY.hostPower, remedy: LAUNCH_NEED_REMEDIES.host_power }, powerRow.id);
|
|
259
|
+
if (prerequisiteFacts.status === "collected" && prerequisiteFacts.workerRuntimeChildren.length > 0) {
|
|
260
|
+
add("worth_knowing", handoffLine(facts.handoff, prerequisiteFacts.workerRuntimeChildren.length), "verification-handoff");
|
|
261
|
+
}
|
|
262
|
+
// BAPI-1621 — one item for a generated plan, built only from the DAG and the
|
|
263
|
+
// stored summary the preview already carries. No new question.
|
|
264
|
+
const generated = generatedPlanItem(preview);
|
|
265
|
+
if (generated !== null)
|
|
266
|
+
add("worth_knowing", generated, GENERATED_PLAN_ITEM_ID);
|
|
267
|
+
}
|
|
268
|
+
// --- already merged children: summary and details only ---------------------------
|
|
269
|
+
const alreadyMerged = [];
|
|
130
270
|
const children = preview.already_done_children;
|
|
131
271
|
if (isObject(children) && children.status === "checked" && Array.isArray(children.children)) {
|
|
132
272
|
for (const child of children.children) {
|
|
133
273
|
if (!isObject(child) || child.classification !== "done" || child.will_skip !== true ||
|
|
134
274
|
typeof child.ticket_key !== "string" || !EPIC_KEY_PATTERN.test(child.ticket_key))
|
|
135
275
|
continue;
|
|
136
|
-
|
|
137
|
-
...LAUNCH_PLAN_MERGED_CHILD_COPY, summary: `${LAUNCH_PLAN_MERGED_CHILD_COPY.summary} ${child.ticket_key}`,
|
|
138
|
-
}, "skip", [{ choice: "keep", flags: ["--keep-child", child.ticket_key] }]));
|
|
139
|
-
}
|
|
140
|
-
for (const child of children.children) {
|
|
141
|
-
if (!isObject(child) || child.classification !== "probably_done" || child.will_skip !== false ||
|
|
142
|
-
typeof child.ticket_key !== "string" || !EPIC_KEY_PATTERN.test(child.ticket_key))
|
|
143
|
-
continue;
|
|
144
|
-
add(item(`probably-done-${child.ticket_key}`, "probably_done", {
|
|
145
|
-
...LAUNCH_PLAN_CHILD_COPY, summary: `${LAUNCH_PLAN_CHILD_COPY.summary} ${child.ticket_key}`,
|
|
146
|
-
}, "run it", [{ choice: "skip", flags: ["--skip-child", child.ticket_key] }]));
|
|
276
|
+
alreadyMerged.push({ ticket_key: child.ticket_key, keep_flags: ["--keep-child", child.ticket_key] });
|
|
147
277
|
}
|
|
148
278
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
279
|
+
// --- verdict ---------------------------------------------------------------------
|
|
280
|
+
const blocked = refusal !== null;
|
|
281
|
+
const verdict = blocked
|
|
282
|
+
? "blocked"
|
|
283
|
+
: items.needs_choice.length > 0 || items.worth_knowing.length > 0 ? "ready_with_notes" : "ready";
|
|
284
|
+
// --- numbered options ------------------------------------------------------------
|
|
285
|
+
const options = [];
|
|
286
|
+
const actions = [];
|
|
287
|
+
let recommendation;
|
|
288
|
+
let reason;
|
|
289
|
+
const push = (option, action) => {
|
|
290
|
+
const number = options.length + 1;
|
|
291
|
+
options.push({ number, ...option });
|
|
292
|
+
actions.push({ number, action, argv: [] });
|
|
154
293
|
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
addNeed(row, "worker_db_role");
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
if (typeof row.id !== "string" || !Object.hasOwn(LAUNCH_PLAN_DB_COPY, row.id) ||
|
|
163
|
-
!["warn", "fail", "unverified"].includes(row.status) || row.blocking !== false)
|
|
164
|
-
continue;
|
|
165
|
-
const id = row.id;
|
|
166
|
-
const coverage = id === "worker-db-harness" ? sanitizeHarnessCoverage(row.harness_coverage) : undefined;
|
|
167
|
-
if (coverage && coverage.total > 0 && coverage.activity === "known" && coverage.uncovered === 0) {
|
|
168
|
-
add(item(id, "worker_db", {
|
|
169
|
-
summary: "Harness databases in use or CI-owned",
|
|
170
|
-
remedy: "Proceed; no harness cleanup is requested by launch.",
|
|
171
|
-
reason: "Every harness database is in use or CI-owned; no harness cleanup is requested by launch.",
|
|
172
|
-
}, "proceed", []));
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
add(item(id, "worker_db", { ...LAUNCH_PLAN_DB_COPY[id], remedy: workerDatabaseRemedy(id, row) }, "fix first", [{ choice: "launch anyway", flags: [] }]));
|
|
294
|
+
if (blocked) {
|
|
295
|
+
push(nothingOption(1, "Don't launch yet", true), "create_nothing");
|
|
296
|
+
recommendation = "don't launch yet, and fix the problem below.";
|
|
297
|
+
reason = "Bridge found a proven problem. Nothing has been created.";
|
|
176
298
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
299
|
+
else if (boundaryProven) {
|
|
300
|
+
push(launchOption(1, "Launch anyway", local, false), "launch");
|
|
301
|
+
if (missingCore.length > 0)
|
|
302
|
+
push(nothingOption(options.length + 1, "Stop so you can supply what's missing", false), "create_nothing");
|
|
303
|
+
push(nothingOption(options.length + 1, "Don't launch yet", true), "create_nothing");
|
|
304
|
+
recommendation = "don't launch yet, and fix the worker database role.";
|
|
305
|
+
reason = "The worker role can reach a protected database. That is proven, and fixing it is quick.";
|
|
183
306
|
}
|
|
184
|
-
|
|
307
|
+
else {
|
|
308
|
+
const missing = missingCore.length > 0;
|
|
309
|
+
push(launchOption(1, missing ? "Launch now and supply it later" : "Launch now", local, true), "launch");
|
|
310
|
+
if (missing)
|
|
311
|
+
push(nothingOption(options.length + 1, "Stop so you can supply it", false), "create_nothing");
|
|
312
|
+
push(nothingOption(options.length + 1, "Don't launch yet", false), "create_nothing");
|
|
313
|
+
recommendation = "launch now.";
|
|
314
|
+
reason = verdict === "ready"
|
|
315
|
+
? "Every check that protects your code passed."
|
|
316
|
+
: missing
|
|
317
|
+
? "Every check that protects your code passed. Some children need something you can supply later."
|
|
318
|
+
: "Every check that protects your code passed. A few things are worth knowing.";
|
|
319
|
+
}
|
|
320
|
+
const plan = {
|
|
321
|
+
version: 2,
|
|
322
|
+
verdict,
|
|
323
|
+
summary: summaryLine(preview, blocked),
|
|
324
|
+
recommendation,
|
|
325
|
+
reason,
|
|
326
|
+
items,
|
|
327
|
+
options,
|
|
328
|
+
details: {
|
|
329
|
+
items: detailItems,
|
|
330
|
+
options: actions,
|
|
331
|
+
handoff: {
|
|
332
|
+
effective: effectiveHandoff(facts.handoff),
|
|
333
|
+
project_default: facts.handoff.projectDefault,
|
|
334
|
+
explicit: facts.handoff.explicit !== null,
|
|
335
|
+
},
|
|
336
|
+
already_merged: alreadyMerged,
|
|
337
|
+
},
|
|
338
|
+
...(local && !blocked ? { local_handoff: LAUNCH_PLAN_LOCAL_HANDOFF } : {}),
|
|
339
|
+
...(!blocked ? { health_check_failed: healthCheckFailedFragment(local) } : {}),
|
|
340
|
+
};
|
|
341
|
+
return { launch_plan: plan };
|
|
185
342
|
}
|