@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
|
@@ -94,32 +94,80 @@ export const PR_DEPENDENCY_VALUES = [
|
|
|
94
94
|
"pr_preview_environment",
|
|
95
95
|
];
|
|
96
96
|
/**
|
|
97
|
-
* BAPI-1492: the verification hand-off vocabulary. Mirrored from
|
|
98
|
-
* `HANDOFF_ELIGIBLE_CLASSES`, and `HANDOFF_FIELDS` in
|
|
97
|
+
* BAPI-1492 / BAPI-1544: the verification hand-off vocabulary. Mirrored from
|
|
98
|
+
* `HANDOFF_CAUSES`, `HANDOFF_ELIGIBLE_CLASSES`, and `HANDOFF_FIELDS` in
|
|
99
99
|
* `api/library/vcs/ticket_delivery_identity.py`; both sides must agree.
|
|
100
100
|
*
|
|
101
101
|
* A hand-off is additive metadata on an escalated `pre_pr_verification` record for
|
|
102
|
-
*
|
|
103
|
-
* missing. It is never a disposition and never a `prDependency`
|
|
104
|
-
* may satisfy the step is decided only by the server, from
|
|
102
|
+
* a unit-test, E2E, or rendered-UI step whose check could not run because a
|
|
103
|
+
* prerequisite was missing. It is never a disposition and never a `prDependency`
|
|
104
|
+
* value. Whether it may satisfy the step is decided only by the server, from
|
|
105
|
+
* persisted run state.
|
|
106
|
+
*
|
|
107
|
+
* The contract has six fields. `cause` is a missing-capability cause only.
|
|
108
|
+
* `observation` is what the first attempt hit, and `corrected_invocation` is the
|
|
109
|
+
* corrected rerun and what it hit, so a zero-test selector or a wrong command can
|
|
110
|
+
* never pass for a missing capability. Both are secret-free narrative; for example
|
|
111
|
+
* a unit step whose acquire command timed out names the command and the timeout,
|
|
112
|
+
* never a token. `observed_head_sha` is the full head SHA the observation ran
|
|
113
|
+
* against, and the server requires it to equal the submission's own tested head.
|
|
114
|
+
* The narrative is a worker attestation: the server validates structure,
|
|
115
|
+
* vocabulary, sanitized non-blank text, eligibility, and head identity, and does
|
|
116
|
+
* not judge whether the prose proves a capability was missing.
|
|
105
117
|
*/
|
|
106
118
|
export const HANDOFF_CAUSES = [
|
|
107
119
|
"no_live_server",
|
|
108
120
|
"no_database",
|
|
109
121
|
"toolchain_unavailable",
|
|
110
122
|
"credential_unavailable",
|
|
123
|
+
"mcp_unavailable",
|
|
124
|
+
"preexisting_at_base",
|
|
125
|
+
];
|
|
126
|
+
/**
|
|
127
|
+
* BAPI-1552: the one cause that is not a missing capability. The step ran and
|
|
128
|
+
* failed, and the same tests already fail at the base commit. Only this cause
|
|
129
|
+
* carries `base_reproduction`, and it must carry it. Mirrors
|
|
130
|
+
* `HANDOFF_CAUSE_PREEXISTING_AT_BASE` and its neighbours in
|
|
131
|
+
* `api/library/vcs/ticket_delivery_identity.py`, with identical wording.
|
|
132
|
+
*/
|
|
133
|
+
export const HANDOFF_CAUSE_PREEXISTING_AT_BASE = "preexisting_at_base";
|
|
134
|
+
export const BASE_REPRODUCTION_FIELDS = [
|
|
135
|
+
"base_sha",
|
|
136
|
+
"command",
|
|
137
|
+
"failing_ids_head",
|
|
138
|
+
"failing_ids_base",
|
|
111
139
|
];
|
|
112
|
-
export const
|
|
140
|
+
export const MAX_BASE_REPRODUCTION_IDS = 200;
|
|
141
|
+
export const MAX_BASE_REPRODUCTION_ID_CHARS = 500;
|
|
142
|
+
export const REFUSAL_BASE_REPRODUCTION_INCOMPLETE = "base_reproduction_incomplete";
|
|
143
|
+
export const REFUSAL_HEAD_FAILURES_NOT_IN_BASE = "head_failures_not_in_base";
|
|
144
|
+
export const REFUSAL_BASE_SHA_NOT_BINDING_BASE = "base_sha_not_binding_base";
|
|
145
|
+
export const PREEXISTING_REFUSAL_CODES = [
|
|
146
|
+
REFUSAL_BASE_REPRODUCTION_INCOMPLETE,
|
|
147
|
+
REFUSAL_HEAD_FAILURES_NOT_IN_BASE,
|
|
148
|
+
REFUSAL_BASE_SHA_NOT_BINDING_BASE,
|
|
149
|
+
];
|
|
150
|
+
export const PREEXISTING_INCOMPLETE_MESSAGE = "handoff preexisting_at_base needs the six handoff fields plus base_reproduction " +
|
|
151
|
+
"with exactly base_sha (a full commit SHA), a non-blank command, a non-empty " +
|
|
152
|
+
"failing_ids_head, and failing_ids_base; each list holds at most 200 non-blank " +
|
|
153
|
+
"test IDs of at most 500 characters";
|
|
154
|
+
export const PREEXISTING_RECORD_MESSAGE = "handoff preexisting_at_base is accepted only on an escalated pre_pr_verification record";
|
|
155
|
+
export const PREEXISTING_NOT_FAILED_MESSAGE = "handoff preexisting_at_base needs a step that ran and failed: name it in " +
|
|
156
|
+
"verification failures, or submit at the head of its recorded failure";
|
|
157
|
+
export const PREEXISTING_NOT_IN_BASE_MESSAGE = "handoff preexisting_at_base requires every failing_ids_head entry to also " +
|
|
158
|
+
"appear in failing_ids_base";
|
|
159
|
+
export const HANDOFF_ELIGIBLE_CLASSES = ["unit_tests", "e2e_tests", "rendered_ui_review"];
|
|
113
160
|
export const HANDOFF_FIELDS = [
|
|
114
161
|
"cause",
|
|
115
162
|
"criterion",
|
|
116
163
|
"observation",
|
|
164
|
+
"corrected_invocation",
|
|
117
165
|
"observed_head_sha",
|
|
118
166
|
"next_action",
|
|
119
167
|
];
|
|
120
168
|
/** Mirrors the server's `MAX_EVIDENCE_TEXT`: longer text is truncated, not refused. */
|
|
121
169
|
export const HANDOFF_MAX_TEXT = 4000;
|
|
122
|
-
const HANDOFF_TEXT_FIELDS = ["criterion", "observation", "next_action"];
|
|
170
|
+
const HANDOFF_TEXT_FIELDS = ["criterion", "observation", "corrected_invocation", "next_action"];
|
|
123
171
|
const FULL_SHA_PATTERN = /^[0-9a-f]{40}$/;
|
|
124
172
|
/**
|
|
125
173
|
* Change categories that may never be adapted. Meeting one of these means the step's
|
|
@@ -172,9 +220,13 @@ export const PRE_PR_VERIFICATION_LIMITS = Object.freeze({
|
|
|
172
220
|
/** The plan-authored rendered-UI remediation loop's hard cycle cap. */
|
|
173
221
|
export const RENDERED_UI_MAX_CYCLES = 3;
|
|
174
222
|
export class PlanLedgerError extends Error {
|
|
175
|
-
|
|
223
|
+
/** BAPI-1552: a closed refusal code, set only by a `preexisting_at_base` refusal. */
|
|
224
|
+
code;
|
|
225
|
+
constructor(message, code) {
|
|
176
226
|
super(message);
|
|
177
227
|
this.name = "PlanLedgerError";
|
|
228
|
+
if (code !== undefined)
|
|
229
|
+
this.code = code;
|
|
178
230
|
}
|
|
179
231
|
}
|
|
180
232
|
// ---------------------------------------------------------------------------
|
|
@@ -502,6 +554,14 @@ function validateRecordShape(record, metadata, phase) {
|
|
|
502
554
|
if (!PLAN_STEP_DISPOSITIONS.includes(record.disposition)) {
|
|
503
555
|
throw new PlanLedgerError(`step ${record.stepId} has unsupported disposition '${String(record.disposition)}'; expected one of ${PLAN_STEP_DISPOSITIONS.join(", ")}`);
|
|
504
556
|
}
|
|
557
|
+
// BAPI-1552: mirrors the server, which refuses this cause on a non-escalated
|
|
558
|
+
// record before any generic disposition check can hide the closed code.
|
|
559
|
+
const handoffValue = record.handoff;
|
|
560
|
+
if (record.disposition !== "escalated" &&
|
|
561
|
+
isRecordObject(handoffValue) &&
|
|
562
|
+
handoffValue.cause === HANDOFF_CAUSE_PREEXISTING_AT_BASE) {
|
|
563
|
+
throw new PlanLedgerError(`step ${record.stepId}: ${PREEXISTING_RECORD_MESSAGE}`, REFUSAL_BASE_REPRODUCTION_INCOMPLETE);
|
|
564
|
+
}
|
|
505
565
|
if (record.disposition === "adapted") {
|
|
506
566
|
const adaptation = record.adaptation;
|
|
507
567
|
if (!adaptation) {
|
|
@@ -594,6 +654,10 @@ export function validateHandoff(record, metadata, phase) {
|
|
|
594
654
|
};
|
|
595
655
|
const value = record.handoff;
|
|
596
656
|
const isObject = typeof value === "object" && value !== null && !Array.isArray(value);
|
|
657
|
+
if (isObject && value.cause === HANDOFF_CAUSE_PREEXISTING_AT_BASE) {
|
|
658
|
+
validatePreexistingHandoff(record, metadata, phase);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
597
661
|
const keys = isObject ? Object.keys(value).sort() : [];
|
|
598
662
|
const expected = [...HANDOFF_FIELDS].sort();
|
|
599
663
|
if (!isObject || keys.length !== expected.length || keys.some((k, i) => k !== expected[i])) {
|
|
@@ -623,22 +687,119 @@ export function validateHandoff(record, metadata, phase) {
|
|
|
623
687
|
fail("handoff is accepted only on a pre_pr_verification record");
|
|
624
688
|
}
|
|
625
689
|
if (!HANDOFF_ELIGIBLE_CLASSES.includes(owningPart.provenance_class)) {
|
|
626
|
-
fail("handoff is accepted only for e2e_tests or rendered_ui_review steps; review
|
|
690
|
+
fail("handoff is accepted only for unit_tests, e2e_tests, or rendered_ui_review steps; review steps always run");
|
|
627
691
|
}
|
|
628
692
|
if (record.prDependency !== undefined) {
|
|
629
693
|
fail("handoff cannot be combined with prDependency");
|
|
630
694
|
}
|
|
631
695
|
}
|
|
696
|
+
function isRecordObject(value) {
|
|
697
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
698
|
+
}
|
|
699
|
+
function hasExactKeys(value, expected) {
|
|
700
|
+
const keys = Object.keys(value).sort();
|
|
701
|
+
const want = [...expected].sort();
|
|
702
|
+
return keys.length === want.length && keys.every((k, i) => k === want[i]);
|
|
703
|
+
}
|
|
704
|
+
/** Trimmed raw IDs, or null when the list breaks a rule. Mirrors `_raw_id_list`. */
|
|
705
|
+
function rawIdList(value, nonEmpty) {
|
|
706
|
+
if (!Array.isArray(value) || value.length > MAX_BASE_REPRODUCTION_IDS)
|
|
707
|
+
return null;
|
|
708
|
+
if (nonEmpty && value.length === 0)
|
|
709
|
+
return null;
|
|
710
|
+
const out = [];
|
|
711
|
+
for (const item of value) {
|
|
712
|
+
if (typeof item !== "string")
|
|
713
|
+
return null;
|
|
714
|
+
const text = item.trim();
|
|
715
|
+
if (text === "" || text.length > MAX_BASE_REPRODUCTION_ID_CHARS)
|
|
716
|
+
return null;
|
|
717
|
+
out.push(text);
|
|
718
|
+
}
|
|
719
|
+
return out;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* BAPI-1552: the `preexisting_at_base` rules, mirroring the server's
|
|
723
|
+
* `_validate_preexisting_handoff` with the same wording, codes, and precedence:
|
|
724
|
+
* the existing `prDependency` refusal first, then `base_reproduction_incomplete`
|
|
725
|
+
* for any shape, proof, or record problem, then `head_failures_not_in_base`,
|
|
726
|
+
* decided on the trimmed raw IDs, case-sensitively. The class and
|
|
727
|
+
* "named in verification failures" gates do not apply to this cause. The
|
|
728
|
+
* ran-and-failed tie, the prior `remote_ci` refusal, and the head identity read
|
|
729
|
+
* server state, so the server decides them; redaction is server-side too.
|
|
730
|
+
*/
|
|
731
|
+
function validatePreexistingHandoff(record, metadata, phase) {
|
|
732
|
+
const refuse = (reason, code) => {
|
|
733
|
+
throw new PlanLedgerError(`step ${record.stepId}: ${reason}`, code);
|
|
734
|
+
};
|
|
735
|
+
const incomplete = () => refuse(PREEXISTING_INCOMPLETE_MESSAGE, REFUSAL_BASE_REPRODUCTION_INCOMPLETE);
|
|
736
|
+
if (record.prDependency !== undefined) {
|
|
737
|
+
refuse("handoff cannot be combined with prDependency");
|
|
738
|
+
}
|
|
739
|
+
const handoff = record.handoff;
|
|
740
|
+
if (!hasExactKeys(handoff, [...HANDOFF_FIELDS, "base_reproduction"]))
|
|
741
|
+
incomplete();
|
|
742
|
+
for (const field of HANDOFF_TEXT_FIELDS) {
|
|
743
|
+
const text = handoff[field];
|
|
744
|
+
if (typeof text !== "string" || text.trim() === "")
|
|
745
|
+
incomplete();
|
|
746
|
+
}
|
|
747
|
+
const sha = handoff.observed_head_sha;
|
|
748
|
+
if (typeof sha !== "string" || !FULL_SHA_PATTERN.test(sha.trim().toLowerCase()))
|
|
749
|
+
incomplete();
|
|
750
|
+
const proof = handoff.base_reproduction;
|
|
751
|
+
if (!isRecordObject(proof) || !hasExactKeys(proof, BASE_REPRODUCTION_FIELDS))
|
|
752
|
+
incomplete();
|
|
753
|
+
const proofObject = proof;
|
|
754
|
+
const baseSha = proofObject.base_sha;
|
|
755
|
+
if (typeof baseSha !== "string" || !FULL_SHA_PATTERN.test(baseSha.trim().toLowerCase())) {
|
|
756
|
+
incomplete();
|
|
757
|
+
}
|
|
758
|
+
const command = proofObject.command;
|
|
759
|
+
if (typeof command !== "string" || command.trim() === "")
|
|
760
|
+
incomplete();
|
|
761
|
+
const headIds = rawIdList(proofObject.failing_ids_head, true);
|
|
762
|
+
const baseIds = rawIdList(proofObject.failing_ids_base, false);
|
|
763
|
+
if (headIds === null || baseIds === null)
|
|
764
|
+
incomplete();
|
|
765
|
+
const owningPart = metadata.parts.find((part) => record.stepId >= part.start_step && record.stepId <= part.end_step);
|
|
766
|
+
if (record.disposition !== "escalated" ||
|
|
767
|
+
phase !== "pre_pr_verification" ||
|
|
768
|
+
!owningPart ||
|
|
769
|
+
PLAN_CLASS_OWNERSHIP[owningPart.provenance_class] !== "pre_pr_verification") {
|
|
770
|
+
refuse(PREEXISTING_RECORD_MESSAGE, REFUSAL_BASE_REPRODUCTION_INCOMPLETE);
|
|
771
|
+
}
|
|
772
|
+
const baseSet = new Set(baseIds);
|
|
773
|
+
if (headIds.some((id) => !baseSet.has(id))) {
|
|
774
|
+
refuse(PREEXISTING_NOT_IN_BASE_MESSAGE, REFUSAL_HEAD_FAILURES_NOT_IN_BASE);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
/** Trim, deduplicate, and sort IDs. Redaction stays server-side. */
|
|
778
|
+
function normalizeIdList(ids) {
|
|
779
|
+
return [...new Set(ids.map((id) => id.trim()))].sort();
|
|
780
|
+
}
|
|
632
781
|
/** Trim, bound, and lowercase a validated hand-off the way the server stores it. */
|
|
633
782
|
function normalizeHandoff(handoff) {
|
|
634
783
|
const bound = (text) => text.trim().slice(0, HANDOFF_MAX_TEXT);
|
|
635
|
-
|
|
784
|
+
const normalized = {
|
|
636
785
|
cause: handoff.cause,
|
|
637
786
|
criterion: bound(handoff.criterion),
|
|
638
787
|
observation: bound(handoff.observation),
|
|
788
|
+
corrected_invocation: bound(handoff.corrected_invocation),
|
|
639
789
|
observed_head_sha: handoff.observed_head_sha.trim().toLowerCase(),
|
|
640
790
|
next_action: bound(handoff.next_action),
|
|
641
791
|
};
|
|
792
|
+
// BAPI-1552: carry the proof through explicitly, or the local ledger drops it.
|
|
793
|
+
const proof = handoff.base_reproduction;
|
|
794
|
+
if (proof !== undefined) {
|
|
795
|
+
normalized.base_reproduction = {
|
|
796
|
+
base_sha: proof.base_sha.trim().toLowerCase(),
|
|
797
|
+
command: bound(proof.command),
|
|
798
|
+
failing_ids_head: normalizeIdList(proof.failing_ids_head),
|
|
799
|
+
failing_ids_base: normalizeIdList(proof.failing_ids_base),
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
return normalized;
|
|
642
803
|
}
|
|
643
804
|
/**
|
|
644
805
|
* Validate one phase's reported outcome against the steps it owns.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isTerminalRunCleanupStatus } from "./terminal-run-status.js";
|
|
2
|
+
import { monotonicNow, elapsedMs } from "../conductor/precheck-timings.js";
|
|
1
3
|
/**
|
|
2
4
|
* Local-plane freshness evidence (BAPI-1476).
|
|
3
5
|
*
|
|
@@ -61,8 +63,6 @@ const BOUND_RUN_STATUSES = new Set([
|
|
|
61
63
|
"abandoned",
|
|
62
64
|
"done",
|
|
63
65
|
]);
|
|
64
|
-
/** The run statuses after which nothing more will happen (as `wait-run` uses). */
|
|
65
|
-
const BOUND_RUN_TERMINAL_STATUSES = new Set(["done", "abandoned"]);
|
|
66
66
|
/** A run id is rendered only when it has a plain, bounded identifier shape. */
|
|
67
67
|
const BOUND_RUN_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
|
|
68
68
|
/**
|
|
@@ -71,8 +71,8 @@ const BOUND_RUN_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
|
|
|
71
71
|
* - Non-terminal and unknown status: inspect the run and the plane. It NEVER
|
|
72
72
|
* recommends `plane down`, because that would stop a run that may still be
|
|
73
73
|
* working, and an unknown status is not evidence that it is finished.
|
|
74
|
-
* - Terminal status (`done`/`abandoned`):
|
|
75
|
-
*
|
|
74
|
+
* - Terminal status (`done`/`abandoned`): this launch's create attempts guarded cleanup
|
|
75
|
+
* of the plane; if that cleanup reports it was incomplete, inspect with
|
|
76
76
|
* `plane status` before any manual wind-down.
|
|
77
77
|
*
|
|
78
78
|
* Pure and secret-free: the output names only the run id and a closed status.
|
|
@@ -82,10 +82,10 @@ export function formatBoundPlaneStaleRemedy(input) {
|
|
|
82
82
|
? `run ${input.epicRunId}`
|
|
83
83
|
: "its bound run";
|
|
84
84
|
const status = typeof input.status === "string" && BOUND_RUN_STATUSES.has(input.status) ? input.status : null;
|
|
85
|
-
if (
|
|
85
|
+
if (isTerminalRunCleanupStatus(status)) {
|
|
86
86
|
return (`this plane is bound to ${runLabel}, which is ${status}. Bring the main checkout up to ` +
|
|
87
|
-
"`origin/main`;
|
|
88
|
-
"
|
|
87
|
+
"`origin/main`; this launch's create attempts guarded cleanup of this plane " +
|
|
88
|
+
"before starting a fresh one. If that cleanup reports it was incomplete, inspect the plane " +
|
|
89
89
|
"with `plane status` before winding it down by hand. This CLI does not update the " +
|
|
90
90
|
`checkout. ${PLANE_BOUND_STALE_OVERRIDE_NOTE}`);
|
|
91
91
|
}
|
|
@@ -199,12 +199,15 @@ export async function checkPlaneFreshness(repoRoot, deps, checkout, options) {
|
|
|
199
199
|
? manifestRead.manifest.snapshotPath
|
|
200
200
|
: checkout;
|
|
201
201
|
const guarded = async (run, fallback) => {
|
|
202
|
+
const started = monotonicNow();
|
|
203
|
+
let report;
|
|
202
204
|
try {
|
|
203
|
-
|
|
205
|
+
report = await run();
|
|
204
206
|
}
|
|
205
207
|
catch {
|
|
206
|
-
|
|
208
|
+
report = fallback();
|
|
207
209
|
}
|
|
210
|
+
return { ...report, duration_ms: elapsedMs(started) };
|
|
208
211
|
};
|
|
209
212
|
const [snapshot, database] = await Promise.all([
|
|
210
213
|
guarded(() => checkSnapshot(repoRoot, deps, options, timeoutMs, manifestRead), () => unverifiedSnapshot("the check did not complete")),
|
package/build/plane/preflight.js
CHANGED
|
@@ -21,6 +21,25 @@ import { detectClaudeLogin, formatClaudeLoginAdvisory } from "../claude-login.js
|
|
|
21
21
|
import { createReadinessCheck, createReadinessCheckSafely, } from "../readiness-check.js";
|
|
22
22
|
/** Files that must exist for a path to be this repository's root. */
|
|
23
23
|
const REQUIRED_REPO_FILES = ["main.py", "worker.py", "alembic.ini"];
|
|
24
|
+
/** Applicability only. Plane startup has additional, independent prerequisites. */
|
|
25
|
+
export async function isBridgeEngineRepository(repoRoot, fs) {
|
|
26
|
+
let missing = false;
|
|
27
|
+
for (const marker of [...REQUIRED_REPO_FILES, "scripts/conductor_health_check.py"]) {
|
|
28
|
+
try {
|
|
29
|
+
const entry = await fs.stat(path.join(repoRoot, marker));
|
|
30
|
+
if (entry.mode !== undefined && (entry.mode & 0o170000) !== 0o100000)
|
|
31
|
+
missing = true;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
const code = error.code;
|
|
35
|
+
if (code === "ENOENT" || code === "ENOTDIR")
|
|
36
|
+
missing = true;
|
|
37
|
+
else
|
|
38
|
+
throw new Error("repository_identity_unverifiable");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return !missing;
|
|
42
|
+
}
|
|
24
43
|
/** Phases in which a plane already serving a BOUND run can be re-attached to it. */
|
|
25
44
|
const BOUND_RUN_ATTACHABLE_PHASES = [
|
|
26
45
|
"lanes-starting",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isTerminalRunCleanupStatus } from "./terminal-run-status.js";
|
|
1
2
|
/**
|
|
2
3
|
* Terminal-run plane cleanup (BAPI-1496).
|
|
3
4
|
*
|
|
@@ -133,7 +134,7 @@ export async function cleanupTerminalRunPlane(input, overrides = {}) {
|
|
|
133
134
|
// Only the statuses after which nothing more will happen (the set `wait-run`
|
|
134
135
|
// uses). Every other status, known or not, leaves the plane alone.
|
|
135
136
|
const status = runState.state.status;
|
|
136
|
-
if (status
|
|
137
|
+
if (!isTerminalRunCleanupStatus(status)) {
|
|
137
138
|
return { kind: "ineligible", reason: "not-terminal" };
|
|
138
139
|
}
|
|
139
140
|
// The executor registry below is this checkout's only. A run launched from a
|
|
@@ -299,5 +300,8 @@ function runLabel(epicRunId) {
|
|
|
299
300
|
}
|
|
300
301
|
/** Exported for callers that render a cleanup outcome: the stderr line, or `null` when silent. */
|
|
301
302
|
export function terminalRunCleanupStderrLine(result) {
|
|
303
|
+
if (result.kind === "completed") {
|
|
304
|
+
return `plane cleanup for finished ${runLabel(result.epicRunId)} completed; the plane manifest was cleared.`;
|
|
305
|
+
}
|
|
302
306
|
return result.kind === "incomplete" || result.kind === "ownership_aborted" ? result.message : null;
|
|
303
307
|
}
|
|
@@ -37,13 +37,20 @@ export const CONSUMER_GUIDE_POINTER = `${CONSUMER_GUIDE_PATH} (write or refresh
|
|
|
37
37
|
* confirmed gate (provider, local, mixed, or none) replaces the old "at least
|
|
38
38
|
* one --required-check" rule; a provider check is still the common scripted form.
|
|
39
39
|
*/
|
|
40
|
-
export const PRINTED_CONDUCTOR_INSTALL_COMMAND = `${LAUNCHER} install
|
|
40
|
+
export const PRINTED_CONDUCTOR_INSTALL_COMMAND = `${LAUNCHER} install epic-implementer --required-check "${EPIC_IMPLEMENTER_CI_CHECK_NAME}"`;
|
|
41
41
|
/** Conductor bootstrap that also provisions a repository-wide executor service. */
|
|
42
42
|
export const PRINTED_CONDUCTOR_EXECUTOR_INSTALL_COMMAND = `${PRINTED_CONDUCTOR_INSTALL_COMMAND} --executor-id <id> --repo-wide`;
|
|
43
43
|
/** Read-only readiness diagnostics. */
|
|
44
44
|
export const PRINTED_DOCTOR_COMMAND = `${LAUNCHER} doctor`;
|
|
45
45
|
/** Sessionless GitHub App connection. `--repo` is optional for this command. */
|
|
46
46
|
export const PRINTED_CONNECT_GITHUB_COMMAND = `${LAUNCHER} connect-github`;
|
|
47
|
+
/**
|
|
48
|
+
* BAPI-1536 — save or replace the repository's stored test command. The flag is
|
|
49
|
+
* the consent for that one write; the placeholder is never filled in here.
|
|
50
|
+
*/
|
|
51
|
+
export const PRINTED_TEST_COMMAND_INSTALL_COMMAND = `${LAUNCHER} install epic-implementer --test-command "<command>"`;
|
|
52
|
+
/** Explains the `<command>` placeholder; print it beside the test-command remedy. */
|
|
53
|
+
export const PRINTED_TEST_COMMAND_INSTRUCTION = "Replace <command> with the one command that runs your tests.";
|
|
47
54
|
/** Explains the `<check-name>` placeholder; print it beside a conductor command. */
|
|
48
55
|
export const PRINTED_CHECK_NAME_INSTRUCTION = "Run setup to create the workflow and store the required check.";
|
|
49
56
|
/** Explains the `<id>` placeholder of the executor command. */
|
|
@@ -53,9 +60,9 @@ export const PRINTED_EXECUTOR_ID_INSTRUCTION = "Replace <id> with a name for the
|
|
|
53
60
|
* qualification job and drain it with a short-lived repository-wide executor.
|
|
54
61
|
* The remedy for `local_command_unqualified`.
|
|
55
62
|
*/
|
|
56
|
-
export const PRINTED_QUALIFY_GATE_COMMAND = `${LAUNCHER} install-
|
|
63
|
+
export const PRINTED_QUALIFY_GATE_COMMAND = `${LAUNCHER} install epic-implementer --qualify-gate`;
|
|
57
64
|
/** A persistent repository-wide executor service, which also drains qualification jobs. */
|
|
58
|
-
export const PRINTED_REPO_WIDE_EXECUTOR_COMMAND = `${LAUNCHER} install
|
|
65
|
+
export const PRINTED_REPO_WIDE_EXECUTOR_COMMAND = `${LAUNCHER} install epic-implementer --executor-id <id> --repo-wide`;
|
|
59
66
|
/** The lifecycle-free executor service-unit generator. */
|
|
60
67
|
export const PRINTED_EXECUTOR_INSTALL_SERVICE_COMMAND = `${LAUNCHER} executor install-service`;
|
|
61
68
|
/** Fixed public actions; generated into Python from this source at build time. */
|
|
@@ -65,10 +72,30 @@ export const READINESS_PREREQUISITE_FIXES = {
|
|
|
65
72
|
no_index: "Re-index the repository, then retry readiness.",
|
|
66
73
|
pending_index: "Wait for indexing to finish, then retry readiness.",
|
|
67
74
|
missing_workflow: `Run ${PRINTED_CONDUCTOR_INSTALL_COMMAND}, merge the workflow changes, then re-index the repository.`,
|
|
68
|
-
explicit_command:
|
|
75
|
+
explicit_command: `Run ${PRINTED_TEST_COMMAND_INSTALL_COMMAND}. ${PRINTED_TEST_COMMAND_INSTRUCTION}`,
|
|
69
76
|
escalation: "Declare a notify webhook, or verify the account email with live email delivery.",
|
|
70
77
|
self_host: "Check the self-host installation guide, then retry readiness.",
|
|
71
78
|
consent: "Turn on Allow unattended Epic Implementer runs on the repository Setup page, or use --attended.",
|
|
72
79
|
github: `Run ${PRINTED_CONNECT_GITHUB_COMMAND}, then retry readiness.`,
|
|
73
80
|
none: "",
|
|
74
81
|
};
|
|
82
|
+
/** Structured explanations are descriptive and never grant effect consent. */
|
|
83
|
+
export function assessmentRemedyQuestion(remedy, evidence) {
|
|
84
|
+
const hosted = !['repository_admin', 'local_user', 'bridge_support', 'self_host_operator'].includes(remedy.audience ?? '') || remedy.audience === 'bridge_support' ||
|
|
85
|
+
(remedy.reference === 'self_host' && remedy.audience !== 'self_host_operator');
|
|
86
|
+
const actions = {
|
|
87
|
+
none: 'No action required.', retry: READINESS_PREREQUISITE_FIXES.retry,
|
|
88
|
+
setup: READINESS_PREREQUISITE_FIXES.setup, github: READINESS_PREREQUISITE_FIXES.github,
|
|
89
|
+
index: READINESS_PREREQUISITE_FIXES.no_index, workflow: READINESS_PREREQUISITE_FIXES.missing_workflow,
|
|
90
|
+
escalation: READINESS_PREREQUISITE_FIXES.escalation,
|
|
91
|
+
support: 'Contact Bridge support to investigate service availability.',
|
|
92
|
+
self_host: READINESS_PREREQUISITE_FIXES.self_host,
|
|
93
|
+
local_login: 'Sign in locally, then retry readiness.',
|
|
94
|
+
};
|
|
95
|
+
const action = hosted ? actions.support : actions[remedy.reference] ?? actions.support;
|
|
96
|
+
return { purpose: action, evidence: [...evidence],
|
|
97
|
+
options: [{ id: 'act', label: 'Review and perform the named remedy' }, { id: 'defer', label: 'Keep this prerequisite unresolved' }],
|
|
98
|
+
consequences: ['Performing the remedy may make fresh evidence available. Readiness will be checked again; this report does not authorize an operation or launch.'],
|
|
99
|
+
deferred: 'Independent completed work is retained. The affected prerequisite remains unresolved.',
|
|
100
|
+
recovery: 'Rerun setup or read-only readiness after the remedy. Existing consent checks still apply.' };
|
|
101
|
+
}
|
package/build/readiness-check.js
CHANGED
|
@@ -1,80 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The canonical shared readiness-check contract (BAPI-1055, AC-6).
|
|
3
|
-
*
|
|
4
|
-
* Conductor prerequisite probing is spread across five loci — `bridge doctor`
|
|
5
|
-
* ({@link file:./install-doctor.ts}), `epic-implementer doctor`
|
|
6
|
-
* ({@link file:./conductor/doctor.ts}), `plane` preflight
|
|
7
|
-
* ({@link file:./plane/preflight.ts}), the server `conductor-readiness`
|
|
8
|
-
* collector, and the unified install doctor
|
|
9
|
-
* ({@link file:./conductor/install-doctor.ts}) that already composes four of
|
|
10
|
-
* them. Each speaks its own status vocabulary. This module is the ONE record
|
|
11
|
-
* shape they are all projected into, so a consolidated report can say
|
|
12
|
-
* pass/fail and name exactly one remediation per failure without any locus
|
|
13
|
-
* having to abandon its own verdicts.
|
|
14
|
-
*
|
|
15
|
-
* DEPENDENCY-NEUTRAL LEAF. It imports nothing: no fs, no network, no CLI, no
|
|
16
|
-
* sibling diagnostic. That is what makes it safe to import from every surface,
|
|
17
|
-
* including ones pinned to issue zero probes.
|
|
18
|
-
*
|
|
19
|
-
* ## Exhaustive source-status mapping (the accepted four-state vocabulary)
|
|
20
|
-
*
|
|
21
|
-
* The shared vocabulary has FOUR states, not three, because four is the
|
|
22
|
-
* minimum that lets every source verdict round-trip without a lossy merge.
|
|
23
|
-
* Collapsing `degraded` onto `fail` would make a fallback npm channel read
|
|
24
|
-
* identically to an unusable ledger, which would contradict the rule that each
|
|
25
|
-
* section's own advisory semantics stay unchanged.
|
|
26
|
-
*
|
|
27
|
-
* | Source | Source verdict | Canonical |
|
|
28
|
-
* | ----------------------------------- | ----------------------------- | --------- |
|
|
29
|
-
* | `install-doctor` `InstallCheckStatus` | `PASS` | `pass` |
|
|
30
|
-
* | `install-doctor` `InstallCheckStatus` | `WARN` | `warn` |
|
|
31
|
-
* | `install-doctor` `InstallCheckStatus` | `SKIP` | `skip` |
|
|
32
|
-
* | `install-doctor` `InstallCheckStatus` | `INFO` | see below |
|
|
33
|
-
* | `conductor/install-doctor` section | `ok` | `pass` |
|
|
34
|
-
* | `conductor/install-doctor` section | `degraded` | `warn` |
|
|
35
|
-
* | `conductor/install-doctor` section | `fatal` | `fail` |
|
|
36
|
-
* | `conductor/doctor` inspection | `degraded: true` | `warn` |
|
|
37
|
-
* | `plane` diagnostic | `severity: "warning"` | `warn` |
|
|
38
|
-
* | `plane` diagnostic | `severity: "blocking"` | `fail` |
|
|
39
|
-
* | server readiness | unreadable / `null` / missing | `fail` |
|
|
40
|
-
*
|
|
41
|
-
* `INFO` never becomes a canonical status. It is informational by definition,
|
|
42
|
-
* so its content is preserved in {@link ReadinessCheck.detail} while the check
|
|
43
|
-
* takes `pass`, `warn`, or `skip` according to that check's own established
|
|
44
|
-
* semantics — chosen per check id by the adapter, never guessed here.
|
|
45
|
-
*
|
|
46
|
-
* Three states are deliberately NOT interchangeable:
|
|
47
|
-
*
|
|
48
|
-
* - `fail` means a prerequisite is not satisfied, INCLUDING the case where its
|
|
49
|
-
* state could not be established. An unreadable liveness read, a failed
|
|
50
|
-
* permission probe, `executor.ready === null`, and a field a newer server
|
|
51
|
-
* would have sent are all `fail` with a remediation for restoring the probe.
|
|
52
|
-
* Uncertainty must never appear healthy.
|
|
53
|
-
* - `warn` means the prerequisite is degraded but usable, or a launch-permitting
|
|
54
|
-
* plane warning. It is not a soft failure and is never derived from silence.
|
|
55
|
-
* - `skip` means the check genuinely did not apply or a dependency prevented it
|
|
56
|
-
* from running. It is never used to hide an unknown.
|
|
57
|
-
*
|
|
58
|
-
* ## The failure/remediation invariant
|
|
59
|
-
*
|
|
60
|
-
* AC-6 requires exactly ONE named remediation on every failure, so the union
|
|
61
|
-
* below makes that a property of the type: the `fail` variant REQUIRES one
|
|
62
|
-
* non-empty scalar remediation and the `pass` variant PROHIBITS one. `warn` and
|
|
63
|
-
* `skip` may each carry at most one, because an actionable warning and the
|
|
64
|
-
* actionable deny-probe skip both have a named next step, while a
|
|
65
|
-
* dependency-driven skip has none.
|
|
66
|
-
*
|
|
67
|
-
* ## Secret discipline
|
|
68
|
-
*
|
|
69
|
-
* Every `detail` and `remediation` is fixed prose plus non-secret facts: a
|
|
70
|
-
* label, a closed enum, a count, a boolean, a timestamp, a relative identifier,
|
|
71
|
-
* or an approved base/setup URL. The helpers here cap length, strip control
|
|
72
|
-
* characters, and refuse obvious absolute paths — but they are a last line of
|
|
73
|
-
* defence, NOT permission to pass a raw exception, subprocess output, a request
|
|
74
|
-
* header, a response body, or a credential into the constructor. Projecting
|
|
75
|
-
* source data into safe prose is the adapter's job; this module only refuses
|
|
76
|
-
* the most obvious leaks.
|
|
77
|
-
*/
|
|
78
1
|
/** Every valid status, for exhaustive validation and test enumeration. */
|
|
79
2
|
export const READINESS_CHECK_STATUSES = [
|
|
80
3
|
"pass",
|
|
@@ -281,7 +204,7 @@ export function createReadinessCheck(input) {
|
|
|
281
204
|
/** Fixed prose for a check that had to be replaced because it was malformed. */
|
|
282
205
|
export const READINESS_MALFORMED_CHECK_DETAIL = "this prerequisite reported a result that failed the readiness contract, so its real state is unknown";
|
|
283
206
|
/** Fixed remediation for a replaced malformed check. */
|
|
284
|
-
export const READINESS_MALFORMED_CHECK_REMEDIATION = "re-run `epic-implementer readiness`; if it persists, run `epic-implementer doctor` and `install
|
|
207
|
+
export const READINESS_MALFORMED_CHECK_REMEDIATION = "re-run `epic-implementer readiness`; if it persists, run `epic-implementer doctor` and `install epic-implementer` to re-collect this locus.";
|
|
285
208
|
/** Fixed label for a replaced malformed check. */
|
|
286
209
|
export const READINESS_MALFORMED_CHECK_LABEL = "Unreadable prerequisite";
|
|
287
210
|
/**
|