@bridge_gpt/mcp-server 0.2.71 → 0.2.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -17
- package/build/agent-launchers/claude-executor-adapter.js +22 -3
- package/build/agent-notes.js +171 -95
- package/build/agents.generated.js +7 -7
- package/build/bridge-permissions.js +31 -0
- package/build/bridge-worktree-inspection.js +237 -0
- package/build/check-evidence.js +6 -0
- package/build/ci-system-detection.js +50 -0
- package/build/ci-trigger-adapters.js +631 -0
- package/build/ci-trigger-install.js +106 -0
- package/build/claude-review-workflow.js +1 -1
- package/build/cli-help.js +6 -0
- package/build/codex-auto-recovery.js +126 -0
- package/build/codex-launcher-pin.js +33 -2
- package/build/codex-skill-adapter.js +5 -1
- package/build/command-host.js +33 -0
- package/build/commands.generated.js +7 -6
- package/build/conductor/bridge-api-client.js +1352 -50
- package/build/conductor/bring-up-facts.js +18 -5
- package/build/conductor/command-drift-production.js +42 -17
- package/build/conductor/command-drift.js +47 -0
- package/build/conductor/declare-blocked.js +554 -0
- package/build/conductor/doctor.js +187 -28
- package/build/conductor/driver-commands.js +141 -0
- package/build/conductor/driver-guard.js +277 -0
- package/build/conductor/driver-lapse.js +321 -0
- package/build/conductor/driver-register.js +176 -0
- package/build/conductor/driver-release.js +174 -0
- package/build/conductor/driver-session-state.js +315 -0
- package/build/conductor/epic-branch-ci-inspection.js +222 -29
- package/build/conductor/epic-implementer-cli.js +213 -13
- package/build/conductor/epic-server-database.js +162 -0
- package/build/conductor/epic-server-guidance.js +278 -0
- package/build/conductor/epic-server-journal.js +239 -0
- package/build/conductor/epic-server-processes.js +324 -0
- package/build/conductor/epic-server-recipe.js +397 -0
- package/build/conductor/epic-server-runtime.js +1207 -0
- package/build/conductor/epic-server-sfcc.js +107 -0
- package/build/conductor/epic-server-state.js +427 -0
- package/build/conductor/epic-server.js +594 -0
- package/build/conductor/gate-discovery.js +281 -10
- package/build/conductor/gate-settings-review.js +525 -5
- package/build/conductor/git-hooks-uninstall.js +112 -0
- package/build/conductor/git-hooks.js +81 -15
- package/build/conductor/guided-repair.js +10 -1
- package/build/conductor/install-doctor.js +2 -4
- package/build/conductor/launch-need-probes.js +6 -53
- package/build/conductor/launch-plan.js +318 -121
- package/build/conductor/local-merge.js +12 -1
- package/build/conductor/merge-execution-contract.js +1 -1
- package/build/conductor/merged-child-check.js +2 -1
- package/build/conductor/prerequisite-inputs.js +1213 -0
- package/build/conductor/readiness-assessment.js +93 -0
- package/build/conductor/readiness-cli.js +30 -9
- package/build/conductor/readiness-prerequisites.js +77 -5
- package/build/conductor/readiness-sections.js +146 -126
- package/build/conductor/readiness.js +21 -3
- package/build/conductor/recovery-cli.js +236 -15
- package/build/conductor/recovery-operations.js +34 -4
- package/build/conductor/repair-contract.js +33 -0
- package/build/conductor/tools.js +36 -4
- package/build/conductor/wait-run-attention.js +115 -0
- package/build/conductor/wait-run-cli.js +300 -21
- package/build/conductor/worker-database-doctor-inspector.js +34 -2
- package/build/conductor/worker-setup-tally.js +27 -0
- package/build/credential-store.js +96 -21
- package/build/dependency-install-declarations.js +212 -0
- package/build/docs.generated.js +4 -4
- package/build/doctor.js +91 -8
- package/build/drive-epic-help.js +23 -4
- package/build/drive-epic.js +1841 -340
- package/build/engine-paths.js +20 -0
- package/build/epic-branch-ci-summary.js +140 -0
- package/build/epic-capability-statement.js +107 -0
- package/build/epic-ci-workflow-drift.js +30 -15
- package/build/epic-ci-workflow-install.js +110 -42
- package/build/epic-ci-workflow-v2.js +274 -0
- package/build/epic-ci-workflow.js +38 -12
- package/build/epic-implementer-bin.js +2184 -52
- package/build/epic-launch-context.js +607 -0
- package/build/epic-launch-profile.js +1 -1
- package/build/epic-server-record.js +273 -0
- package/build/epic-shared/bridge-client.js +11 -3
- package/build/escalation-reachability.js +43 -0
- package/build/executor/ci-fix-test-runs.js +334 -0
- package/build/executor/cli.js +2 -0
- package/build/executor/completion-contract.js +24 -1
- package/build/executor/credentials.js +1 -1
- package/build/executor/delivery-observations.js +113 -0
- package/build/executor/delivery-outcome.js +30 -0
- package/build/executor/dependency-refresh-runner.js +132 -0
- package/build/executor/dependency-refresh.js +530 -0
- package/build/executor/deps.js +4 -0
- package/build/executor/env.js +119 -17
- package/build/executor/epic-server-context.js +141 -0
- package/build/executor/gate-qualification-job.js +127 -26
- package/build/executor/harness-coverage.js +19 -0
- package/build/executor/http-client.js +87 -6
- package/build/executor/index.js +2 -1
- package/build/executor/install-preflight.js +1 -1
- package/build/executor/job-runner.js +659 -87
- package/build/executor/likely-tests.js +94 -97
- package/build/executor/observation.js +8 -0
- package/build/executor/pre-pr-checks.js +363 -0
- package/build/executor/prompt-spec.js +127 -5
- package/build/executor/reconcile-overlap-job.js +5 -3
- package/build/executor/required-verification.js +28 -0
- package/build/executor/required-work-diagnostics.js +32 -0
- package/build/executor/required-work-ledger.js +955 -39
- package/build/executor/results.js +100 -0
- package/build/executor/service-discovery.js +42 -0
- package/build/executor/service-lifecycle.js +109 -2
- package/build/executor/service-uninstall.js +205 -0
- package/build/executor/service-unit.js +5 -3
- package/build/executor/terminal-mutation.js +8 -0
- package/build/executor/test-clock.js +3 -0
- package/build/executor/verification-hints.js +179 -0
- package/build/executor/worker-command.js +126 -5
- package/build/executor/worker-database-config.js +281 -0
- package/build/executor/worker-database-target.js +16 -12
- package/build/executor/worker-database.js +575 -116
- package/build/executor/worker-finalization.js +71 -10
- package/build/executor/worker-guard-hook.js +10 -2
- package/build/executor/worker-resources.js +25 -3
- package/build/executor/worker-verification-guidance.js +55 -5
- package/build/executor/worktree-inspection.js +42 -0
- package/build/executor/worktree.js +20 -1
- package/build/executor-launch.js +54 -2
- package/build/generated-assets-catalog.js +2 -2
- package/build/github-sign-in.js +1 -1
- package/build/index.js +1111 -381
- package/build/init.js +29 -14
- package/build/install-bridge-conductor-answers.js +465 -0
- package/build/install-bridge-conductor-apply.js +259 -0
- package/build/install-bridge-conductor-assessment.js +895 -0
- package/build/install-bridge-conductor-compact.js +161 -0
- package/build/install-bridge-conductor-contracts.js +63 -0
- package/build/install-bridge-conductor-gate.js +1383 -188
- package/build/install-bridge-conductor-setup.js +637 -92
- package/build/install-bridge-conductor.js +3163 -740
- package/build/install-bridge.js +601 -128
- package/build/install-maintenance.js +127 -0
- package/build/install-reexec.js +1 -1
- package/build/launcher-config-inspection.js +162 -1
- package/build/local-cleanup.js +59 -0
- package/build/mcp-grant-candidates.js +767 -0
- package/build/mcp-grant-doctor.js +63 -0
- package/build/mcp-grant.js +288 -0
- package/build/mcp-host-targets.js +8 -0
- package/build/mcp-identity.js +23 -0
- package/build/mcp-install-state.js +68 -2
- package/build/mcp-invoke.js +126 -13
- package/build/mcp-presets.js +107 -0
- package/build/mcp-provisioning.js +134 -2
- package/build/mcp-registration-doctor.js +31 -2
- package/build/mcp-server-invocation.js +6 -1
- package/build/merge-workflow-install.js +236 -111
- package/build/package-script-semantics.js +10 -0
- package/build/pipeline-utils.js +1 -1
- package/build/pipelines.generated.js +6 -6
- package/build/plan-discovery.js +97 -4
- package/build/plan-execution-ledger.js +248 -9
- package/build/plan-generation-io.js +262 -0
- package/build/plan-generation.js +424 -0
- package/build/plane/build-freshness.js +6 -1
- package/build/plane/cli.js +75 -9
- package/build/plane/plane-freshness.js +23 -7
- package/build/plane/preflight.js +50 -10
- package/build/plane/shutdown.js +19 -0
- package/build/plane/terminal-run-cleanup.js +23 -5
- package/build/plane/terminal-run-status.js +4 -0
- package/build/printed-remedy-commands.js +229 -15
- package/build/readiness-check.js +1 -1
- package/build/readiness-prerequisites.generated.js +311 -4
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +38 -0
- package/build/repository-toolchains.js +50 -8
- package/build/run-unit-tests-launcher.js +8 -1
- package/build/setup-change-policy.js +32 -0
- package/build/setup-epic.js +1192 -198
- package/build/setup-progress.js +44 -0
- package/build/setup-question.js +180 -0
- package/build/start-tickets.js +4 -0
- package/build/test-command-detection.js +32 -88
- package/build/test-support/notes-fs.js +40 -0
- package/build/third-party-mcp-targets.js +30 -0
- package/build/ticket-delivery-enrollment.js +30 -8
- package/build/ticket-delivery-run-scope.js +128 -0
- package/build/upgrade-cli.js +85 -2
- package/build/v2-readiness-requirements.js +28 -1
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktrees.js +105 -0
- package/docs/EPIC-IMPLEMENTER-INSTALL.md +9 -1
- package/docs/EPIC-IMPLEMENTER.md +5 -0
- package/docs/epic-implementer/getting-started.md +42 -15
- package/docs/epic-implementer/self-hosting.md +14 -1
- package/package.json +2 -2
|
@@ -1,145 +1,342 @@
|
|
|
1
1
|
import { EPIC_KEY_PATTERN } from "../drive-epic-key.js";
|
|
2
|
-
import { ESCALATION_REACHABILITY_CHECK_ID } from "../escalation-reachability.js";
|
|
3
|
-
import { LAUNCH_NEEDS, LAUNCH_NEED_ROW_IDS, LAUNCH_NEED_REMEDIES } from "./readiness-sections.js";
|
|
4
2
|
import { WORKER_DATABASE_DOCTOR_OWNER, WORKER_DATABASE_DOCTOR_RUNBOOK_SECTION } from "./doctor.js";
|
|
5
|
-
import {
|
|
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";
|
|
6
23
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* applicable relevant role / other unhealthy DB | fix first | [] | launch anyway: []
|
|
11
|
-
* asked/present runner | fix first | [] | launch anyway: []
|
|
12
|
-
* asked/present power | proceed, keep the lid open | [] | fix first: []
|
|
13
|
-
* asked/present usage | proceed | [] | fix first: []
|
|
14
|
-
* Fix-first acceptance accepts unresolved risk; it never performs remediation.
|
|
15
|
-
* 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`.
|
|
16
27
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (!applicable || !Array.isArray(nodes))
|
|
21
|
-
return "unknown";
|
|
22
|
-
let declared = false;
|
|
23
|
-
let malformed = false;
|
|
24
|
-
let relevant = false;
|
|
25
|
-
for (const node of nodes) {
|
|
26
|
-
if (!isObject(node)) {
|
|
27
|
-
malformed = true;
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (!("touched_files" in node))
|
|
31
|
-
continue;
|
|
32
|
-
if (!Array.isArray(node.touched_files)) {
|
|
33
|
-
malformed = true;
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
declared = true;
|
|
37
|
-
for (const raw of node.touched_files) {
|
|
38
|
-
const path = normalizeRepoRelativePath(raw);
|
|
39
|
-
if (path === null) {
|
|
40
|
-
malformed = true;
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
if (DB_OR_HARNESS_PATH_HINTS.some((hint) => path.startsWith(hint)) || path.includes("/migrations/"))
|
|
44
|
-
relevant = true;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return relevant ? true : malformed || !declared ? "unknown" : false;
|
|
48
|
-
}
|
|
49
|
-
export const LAUNCH_PLAN_REACHABILITY_COPY = {
|
|
50
|
-
summary: "Escalation reachability",
|
|
51
|
-
reason: "Live delivery is not confirmed; escalations are also shown in the driving session.",
|
|
52
|
-
remedy: "Declare notify.webhook_url in the run policy, or configure live email.",
|
|
53
|
-
};
|
|
54
|
-
export const LAUNCH_PLAN_CHILD_COPY = {
|
|
55
|
-
summary: "Probably done child",
|
|
56
|
-
reason: "The child is on the indexed commit but has no confirmed delivery record; run it to be sure.",
|
|
57
|
-
remedy: "Run the child, or explicitly skip it in this plan.",
|
|
28
|
+
export const LAUNCH_PRE_CREATE_CODES = {
|
|
29
|
+
ESCALATION_WEBHOOK_UNREACHABLE: "escalation_webhook_unreachable",
|
|
30
|
+
PROVIDER_DEFAULT_BRANCH_UNREADABLE: "provider_default_branch_unreadable",
|
|
58
31
|
};
|
|
59
|
-
export const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
+
},
|
|
71
62
|
};
|
|
72
63
|
function isObject(value) {
|
|
73
64
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
74
65
|
}
|
|
75
|
-
/**
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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 };
|
|
128
|
+
}
|
|
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
|
+
};
|
|
86
147
|
}
|
|
87
|
-
|
|
88
|
-
|
|
148
|
+
/**
|
|
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.
|
|
152
|
+
*/
|
|
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(" ") };
|
|
89
195
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
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)
|
|
93
199
|
return undefined;
|
|
200
|
+
const local = preview.target.kind === "local_plane";
|
|
94
201
|
const rows = Array.isArray(preview.launch_checks) ? preview.launch_checks.filter(isObject) : [];
|
|
95
|
-
const items = [];
|
|
96
|
-
const
|
|
97
|
-
const add = (entry) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
items.push(entry);
|
|
101
|
-
}
|
|
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);
|
|
102
207
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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);
|
|
106
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
|
+
}
|
|
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 = [];
|
|
107
270
|
const children = preview.already_done_children;
|
|
108
271
|
if (isObject(children) && children.status === "checked" && Array.isArray(children.children)) {
|
|
109
272
|
for (const child of children.children) {
|
|
110
|
-
if (!isObject(child) || child.classification !== "
|
|
273
|
+
if (!isObject(child) || child.classification !== "done" || child.will_skip !== true ||
|
|
111
274
|
typeof child.ticket_key !== "string" || !EPIC_KEY_PATTERN.test(child.ticket_key))
|
|
112
275
|
continue;
|
|
113
|
-
|
|
114
|
-
...LAUNCH_PLAN_CHILD_COPY, summary: `${LAUNCH_PLAN_CHILD_COPY.summary} ${child.ticket_key}`,
|
|
115
|
-
}, "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] });
|
|
116
277
|
}
|
|
117
278
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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: [] });
|
|
123
293
|
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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.";
|
|
298
|
+
}
|
|
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.";
|
|
306
|
+
}
|
|
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 };
|
|
145
342
|
}
|
|
@@ -1342,7 +1342,18 @@ export async function runApprovedLocalMerge(request, options = {}, deps = {}) {
|
|
|
1342
1342
|
},
|
|
1343
1343
|
]);
|
|
1344
1344
|
}
|
|
1345
|
-
|
|
1345
|
+
// BAPI-1564 — a `merge-child --carry-gaps` approval forwards the server-resolved
|
|
1346
|
+
// base, so the ordered ref guard refuses `ref_mismatch` for a retargeted PR
|
|
1347
|
+
// before any merge subprocess. `--match-head-commit` still pins the head. The
|
|
1348
|
+
// guard cannot pin the base atomically for `gh`; a retarget in that last window
|
|
1349
|
+
// is caught at completion, which re-reads the provider base and head.
|
|
1350
|
+
const executor = makeLocalMergeExecutor({
|
|
1351
|
+
method: options.method,
|
|
1352
|
+
skipCiWait: true,
|
|
1353
|
+
...(options.expectedBaseBranch !== undefined
|
|
1354
|
+
? { expectedBaseBranch: options.expectedBaseBranch }
|
|
1355
|
+
: {}),
|
|
1356
|
+
}, { ...deps, credential });
|
|
1346
1357
|
// `access` is only ever used by the CI poll, which `skipCiWait` bypasses. The
|
|
1347
1358
|
// throwing stub makes that structural, not a comment: if a future edit ever
|
|
1348
1359
|
// reaches the poll from this path, it fails loudly in tests instead of
|
|
@@ -84,7 +84,7 @@ export function mergeWorkflowVersionSupportsIntegrationActions(version) {
|
|
|
84
84
|
* (`install`), not the launcher that starts it. The Python mirror derives its
|
|
85
85
|
* command head from this value.
|
|
86
86
|
*/
|
|
87
|
-
export const MERGE_WORKFLOW_SUBCOMMAND = "install
|
|
87
|
+
export const MERGE_WORKFLOW_SUBCOMMAND = "install epic-implementer --merge-workflow";
|
|
88
88
|
/**
|
|
89
89
|
* The complete, copy-ready command that generates the merge workflow and opens
|
|
90
90
|
* its pull request. Every refusal, remediation, and readiness line imports this
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* file, or touches the network except through the injected `classify` function.
|
|
6
6
|
*
|
|
7
7
|
* The posture is conservative: only a current server verdict of `done` (completed
|
|
8
|
-
* delivery binding,
|
|
8
|
+
* delivery binding, or an active binding with no live executor whose own branch
|
|
9
|
+
* merged outside this run, plus a confirmed merge commit covered by the indexed cut) is ever
|
|
9
10
|
* skipped on its own. `probably_done` needs the operator's explicit `--skip-child`.
|
|
10
11
|
* Every uncertain, failed, or malformed result keeps the child in the plan.
|
|
11
12
|
*/
|