@bridge_gpt/mcp-server 0.2.50 → 0.2.52
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 +24 -8
- package/build/agent-capabilities/probe-context.js +15 -7
- package/build/agent-capabilities/probes.js +42 -6
- package/build/agent-launchers/claude-executor-adapter.js +98 -14
- package/build/commands.generated.js +1 -1
- package/build/conduct-epic/bridge-client.js +115 -1
- package/build/conduct-epic/cli.js +351 -33
- package/build/conduct-epic/cut-protocol.js +65 -0
- package/build/conductor/bridge-api-client.js +171 -5
- package/build/conductor/deny-enforcement-preflight.js +107 -10
- package/build/conductor/local-merge.js +170 -11
- package/build/conductor-bin.js +2 -2
- package/build/connect-bitbucket-api.js +370 -0
- package/build/connect-bitbucket.js +437 -0
- package/build/docs.generated.js +1 -1
- package/build/doctor.js +230 -1
- package/build/drive-epic.js +423 -11
- package/build/env-file-link.js +164 -0
- package/build/epic-integration-pr.js +290 -0
- package/build/executor/cli.js +41 -6
- package/build/executor/deps.js +5 -1
- package/build/executor/env-file-guard.js +113 -0
- package/build/executor/env.js +78 -1
- package/build/executor/heartbeat.js +9 -0
- package/build/executor/http-client.js +90 -22
- package/build/executor/job-errors.js +43 -2
- package/build/executor/job-runner.js +137 -29
- package/build/executor/merge-job.js +102 -6
- package/build/executor/permissions.js +106 -0
- package/build/executor/preflight.js +38 -13
- package/build/executor/resume-pre-spawn.js +2 -1
- package/build/executor/runner.js +175 -4
- package/build/executor/service-unit.js +15 -0
- package/build/executor/terminal-mutation.js +22 -1
- package/build/executor/types.js +86 -0
- package/build/executor/worker-command.js +21 -5
- package/build/executor/worker-guard-hook.js +939 -0
- package/build/executor/worker-log.js +56 -0
- package/build/executor/worktree.js +11 -0
- package/build/git-reachability.js +147 -0
- package/build/index.js +535 -95
- package/build/install-bridge.js +95 -0
- package/build/pipelines.generated.js +10 -2
- package/build/plan-epic-conductor-eligibility.js +213 -0
- package/build/plane/cli.js +78 -15
- package/build/plane/defaults.js +165 -0
- package/build/plane/manifest.js +63 -8
- package/build/plane/member-logs.js +6 -0
- package/build/plane/member-roster.js +195 -11
- package/build/plane/preflight.js +43 -0
- package/build/plane/shutdown.js +25 -3
- package/build/plane/status.js +11 -0
- package/build/plane/supervisor.js +343 -14
- package/build/plane/test-fakes.js +43 -0
- package/build/plane/types.js +82 -11
- package/build/pr-base-contract.js +20 -0
- package/build/readme.generated.js +1 -1
- package/build/review-synthesis-config.js +60 -0
- package/build/scripts/executor-protocol-contract-driver.js +311 -0
- package/build/setup-epic.js +592 -139
- package/build/sfcc/log-query.js +2 -1
- package/build/sfcc/reads-custom-object-def.js +10 -13
- package/build/sfcc/reads-site-preference.js +5 -5
- package/build/sfcc/reads-system-object.js +4 -4
- package/build/sfcc/writes-custom-object-def.js +7 -7
- package/build/sfcc/writes-site-preference.js +4 -3
- package/build/sfcc/writes-system-object.js +7 -6
- package/build/start-tickets-conductor.js +11 -2
- package/build/start-tickets.js +69 -2
- package/build/version.generated.js +3 -3
- package/build/worker-containment-diagnostic.js +97 -0
- package/build/worker-guard-hook-bin.js +6 -0
- package/docs/CONDUCTOR.md +27 -0
- package/docs/install/mcp-tool-integrations.md +3 -2
- package/package.json +5 -3
- package/pipelines/plan-epic.json +5 -0
|
@@ -35,20 +35,26 @@
|
|
|
35
35
|
import { spawn } from "child_process";
|
|
36
36
|
import { pollCiChecksForCommit, ConductorBridgeApiError, safeDiagnosticMessage, } from "./bridge-api-client.js";
|
|
37
37
|
import { isLikelyGhMergeConflictOutput, isPrMergeConflict, parseGhPrMergeabilityFields, } from "./github-mergeability.js";
|
|
38
|
-
import { selectLatestChecksByName } from "./latest-check-selector.js";
|
|
38
|
+
import { normalizeSelectorCheckName, selectLatestChecksByName } from "./latest-check-selector.js";
|
|
39
39
|
const MERGE_METHODS = new Set(["squash", "merge", "rebase"]);
|
|
40
40
|
/**
|
|
41
41
|
* `gh pr view` field set for a merged-state / head-drift read. Includes
|
|
42
42
|
* `mergeCommit` so an already-merged PR can be detected (and its merge commit
|
|
43
43
|
* SHA recorded) directly from the same read that guards head drift.
|
|
44
|
+
*
|
|
45
|
+
* BAPI-1021: also includes `baseRefName`/`headRefName` so the ref-verification
|
|
46
|
+
* guard (AC-11) can compare the PR's CURRENT base/head branches against the
|
|
47
|
+
* caller's expectations from the same single read — no extra `gh pr view`
|
|
48
|
+
* subprocess is added solely for ref verification.
|
|
44
49
|
*/
|
|
45
|
-
const PR_STATE_JSON = "headRefOid,state,mergeCommit";
|
|
50
|
+
const PR_STATE_JSON = "headRefOid,state,mergeCommit,baseRefName,headRefName";
|
|
46
51
|
/**
|
|
47
52
|
* Broader `gh pr view` field set used only for the post-merge-failure re-read:
|
|
48
53
|
* it must detect BOTH "already merged at the expected head" and a merge conflict
|
|
49
|
-
* (`mergeable` / `mergeStateStatus`) from a single read.
|
|
54
|
+
* (`mergeable` / `mergeStateStatus`) from a single read. BAPI-1021: also carries
|
|
55
|
+
* `baseRefName`/`headRefName` for the same ref-verification reason as above.
|
|
50
56
|
*/
|
|
51
|
-
const PR_STATE_MERGEABILITY_JSON = "headRefOid,state,mergeCommit,mergeable,mergeStateStatus";
|
|
57
|
+
const PR_STATE_MERGEABILITY_JSON = "headRefOid,state,mergeCommit,mergeable,mergeStateStatus,baseRefName,headRefName";
|
|
52
58
|
/**
|
|
53
59
|
* Hard wall-clock cap on every `gh` subprocess. The epic-tick runs in a single
|
|
54
60
|
* stateless process — a `gh` call that hangs (network stall, an auth prompt that
|
|
@@ -166,12 +172,50 @@ function buildResponse(request, status, reason, terminal, ledgerEvents) {
|
|
|
166
172
|
ledger_events: ledgerEvents,
|
|
167
173
|
};
|
|
168
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* BAPI-1001 — check-run conclusions GitHub itself treats as NEUTRAL. A required
|
|
177
|
+
* check concluding `skipped` or `neutral` does not hold a pull request back on
|
|
178
|
+
* GitHub, which reports it CLEAN/MERGEABLE. Deliberately NOT a catch-all for
|
|
179
|
+
* "not success": `failure`, `cancelled`, `timed_out`, `action_required`, every
|
|
180
|
+
* pending/queued state, and every unrecognized conclusion stay non-green.
|
|
181
|
+
*
|
|
182
|
+
* Kept LOCAL to merge admission rather than pushed into the shared selector: the
|
|
183
|
+
* selector's other consumers render CI state for humans, where a skipped check
|
|
184
|
+
* is worth showing as skipped rather than silently folded into "pass".
|
|
185
|
+
*/
|
|
186
|
+
const NEUTRAL_CHECK_CONCLUSIONS = new Set(["skipped", "neutral"]);
|
|
187
|
+
/** True when a check record's `conclusion` is one GitHub treats as neutral. */
|
|
188
|
+
function isNeutralCheckRecord(record) {
|
|
189
|
+
if (!record)
|
|
190
|
+
return false;
|
|
191
|
+
const conclusion = typeof record.conclusion === "string" ? record.conclusion.trim().toLowerCase() : "";
|
|
192
|
+
return NEUTRAL_CHECK_CONCLUSIONS.has(conclusion);
|
|
193
|
+
}
|
|
169
194
|
/**
|
|
170
195
|
* Decide whether every required CI check is green for the polled head SHA. When
|
|
171
196
|
* the gate lists no required checks, fall back to the poll's `all_passed` flag.
|
|
172
197
|
* Defensive against the poll response's exact shape: a check counts as green if
|
|
173
198
|
* any of `conclusion==="success"`, `status==="success"`, `green===true`, or
|
|
174
199
|
* `bucket==="pass"`.
|
|
200
|
+
*
|
|
201
|
+
* BAPI-1001 adds neutral arbitration AHEAD of the BAPI-933 latest-wins selection.
|
|
202
|
+
* Four outcomes, and each is a distinct case:
|
|
203
|
+
*
|
|
204
|
+
* - `success` (by any of the four spellings above) — green, unchanged.
|
|
205
|
+
* - `skipped` / `neutral` — non-blocking. It never becomes the selected record
|
|
206
|
+
* for a name that also carries a meaningful observation, and when it is the
|
|
207
|
+
* ONLY observation for a required name it passes, because GitHub admits it.
|
|
208
|
+
* - a meaningful failure (`failure`, `cancelled`, `timed_out`,
|
|
209
|
+
* `action_required`, an unorderable conflict) — non-green, unchanged. A
|
|
210
|
+
* neutral duplicate can never hide one, because neutral records are the ones
|
|
211
|
+
* dropped, never the meaningful ones.
|
|
212
|
+
* - pending, queued, missing, malformed — non-green, unchanged.
|
|
213
|
+
*
|
|
214
|
+
* The defect this closes: BAPI-996's PR #1177 carried two `claude-review`
|
|
215
|
+
* check-runs at the head, one `success` and one NEWER `skipped`. Latest-wins
|
|
216
|
+
* selected the `skipped` record, `isGreen` read it as not-green, and the bounded
|
|
217
|
+
* CI-green wait refused a CLEAN/MERGEABLE pull request with `ci_not_green` until
|
|
218
|
+
* the merge re-fire budget parked the ticket.
|
|
175
219
|
*/
|
|
176
220
|
export function allRequiredChecksGreen(pollResponse, requiredChecks) {
|
|
177
221
|
if (pollResponse === null || typeof pollResponse !== "object")
|
|
@@ -198,14 +242,43 @@ export function allRequiredChecksGreen(pollResponse, requiredChecks) {
|
|
|
198
242
|
// reported MERGEABLE/CLEAN (BAPI-912 / PR #1107, three parked attempts).
|
|
199
243
|
// `selectLatestChecksByName` also OMITS a name whose duplicates could not be
|
|
200
244
|
// ordered, so the `every(...)` below fails it closed as a missing context.
|
|
201
|
-
|
|
245
|
+
// Neutral arbitration runs BEFORE selection, because recency cannot arbitrate
|
|
246
|
+
// between "a verdict" and "no verdict". A neutral duplicate is withheld from
|
|
247
|
+
// the selector whenever the same name also carries a meaningful observation,
|
|
248
|
+
// so latest-wins then arbitrates only among records that actually decided
|
|
249
|
+
// something. Names with nothing but neutral records keep them and are judged
|
|
250
|
+
// by `isGreen` below; every meaningful record is passed through untouched, so
|
|
251
|
+
// the selector's ambiguity/fail-closed handling is unchanged.
|
|
252
|
+
const meaningfulNames = new Set();
|
|
253
|
+
for (const record of rawChecks) {
|
|
254
|
+
if (record === null || typeof record !== "object" || Array.isArray(record))
|
|
255
|
+
continue;
|
|
256
|
+
const name = normalizeSelectorCheckName(record.name);
|
|
257
|
+
if (name !== null && !isNeutralCheckRecord(record))
|
|
258
|
+
meaningfulNames.add(name);
|
|
259
|
+
}
|
|
260
|
+
const arbitrated = rawChecks.filter((record) => {
|
|
261
|
+
if (record === null || typeof record !== "object" || Array.isArray(record))
|
|
262
|
+
return true;
|
|
263
|
+
const name = normalizeSelectorCheckName(record.name);
|
|
264
|
+
if (name === null)
|
|
265
|
+
return true;
|
|
266
|
+
return !(isNeutralCheckRecord(record) && meaningfulNames.has(name));
|
|
267
|
+
});
|
|
268
|
+
const { byName } = selectLatestChecksByName(arbitrated);
|
|
202
269
|
const isGreen = (c) => {
|
|
203
270
|
if (!c)
|
|
204
271
|
return false;
|
|
205
272
|
const conclusion = typeof c.conclusion === "string" ? c.conclusion.toLowerCase() : "";
|
|
206
273
|
const status = typeof c.status === "string" ? c.status.toLowerCase() : "";
|
|
207
274
|
const bucket = typeof c.bucket === "string" ? c.bucket.toLowerCase() : "";
|
|
208
|
-
return c.green === true ||
|
|
275
|
+
return (c.green === true ||
|
|
276
|
+
conclusion === "success" ||
|
|
277
|
+
status === "success" ||
|
|
278
|
+
bucket === "pass" ||
|
|
279
|
+
// Only reachable when the name carried no meaningful observation at all;
|
|
280
|
+
// otherwise the arbitration above already removed this record.
|
|
281
|
+
isNeutralCheckRecord(c));
|
|
209
282
|
};
|
|
210
283
|
return requiredChecks.every((name) => isGreen(byName.get(name)));
|
|
211
284
|
}
|
|
@@ -229,11 +302,26 @@ function isMergedAtExpectedHead(state, headOid, expectedSha) {
|
|
|
229
302
|
headOid.toLowerCase() === expectedSha.toLowerCase());
|
|
230
303
|
}
|
|
231
304
|
/**
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
305
|
+
* Coerce a parsed `gh pr view` field to a bounded, nonblank ref name, or
|
|
306
|
+
* `undefined` when the field is absent, not a string, or whitespace-only.
|
|
307
|
+
* BAPI-1021: an unusable observed ref must be treated by the ref-verification
|
|
308
|
+
* guard as a MISMATCH when the caller supplied an expectation, never silently
|
|
309
|
+
* skipped — this coercion just normalizes the raw value, it does not decide
|
|
310
|
+
* that policy.
|
|
311
|
+
*/
|
|
312
|
+
function readBoundedRefName(value) {
|
|
313
|
+
if (typeof value !== "string")
|
|
314
|
+
return undefined;
|
|
315
|
+
const trimmed = value.trim();
|
|
316
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Read the PR's `headRefOid` + `state` + `mergeCommit` + `baseRefName` +
|
|
320
|
+
* `headRefName` via `gh pr view`. Extracted so the head-drift / not-open /
|
|
321
|
+
* already-merged / ref-mismatch guard can run BOTH before the CI wait and
|
|
322
|
+
* again right before provider merge (BAPI-566 Bug B: the head can drift while
|
|
323
|
+
* we wait for CI). Returns the raw parsed values; the caller applies the
|
|
324
|
+
* MERGED-at-head / OPEN / exact-head / matching-ref checks.
|
|
237
325
|
*/
|
|
238
326
|
async function readPrMergeState(run, ghEnv, pr, json = PR_STATE_JSON) {
|
|
239
327
|
const view = await run("gh", ["pr", "view", String(pr), "--json", json], ghEnv);
|
|
@@ -248,6 +336,8 @@ async function readPrMergeState(run, ghEnv, pr, json = PR_STATE_JSON) {
|
|
|
248
336
|
headOid: parsed.headRefOid,
|
|
249
337
|
state: parsed.state,
|
|
250
338
|
mergeCommitOid: extractMergeCommitOid(parsed),
|
|
339
|
+
baseRefName: readBoundedRefName(parsed.baseRefName),
|
|
340
|
+
headRefName: readBoundedRefName(parsed.headRefName),
|
|
251
341
|
raw: parsed,
|
|
252
342
|
};
|
|
253
343
|
}
|
|
@@ -381,6 +471,8 @@ async function waitForRequiredChecksGreen(pollCi, access, expectedSha, requiredC
|
|
|
381
471
|
*/
|
|
382
472
|
export function makeLocalMergeExecutor(options = {}, deps = {}) {
|
|
383
473
|
const method = resolveLocalMergeMethod(options.method);
|
|
474
|
+
const expectedBaseBranch = readBoundedRefName(options.expectedBaseBranch);
|
|
475
|
+
const expectedHeadBranch = readBoundedRefName(options.expectedHeadBranch);
|
|
384
476
|
const rawRun = deps.runCommand ?? defaultRunCommand;
|
|
385
477
|
// Always await the runner: the production default is async (a hung `gh` would
|
|
386
478
|
// otherwise block the event loop and starve the executor heartbeat), and
|
|
@@ -479,6 +571,15 @@ export function makeLocalMergeExecutor(options = {}, deps = {}) {
|
|
|
479
571
|
if (isMergedAtExpectedHead(firstRead.state, firstRead.headOid, expectedSha)) {
|
|
480
572
|
return buildAlreadyMergedResponse(request, baseDetails, firstRead.mergeCommitOid);
|
|
481
573
|
}
|
|
574
|
+
// 2b. BAPI-1021 (AC-11) — refuse before any provider merge if the PR's current
|
|
575
|
+
// base or head branch does not match the caller's expectation. Ordered
|
|
576
|
+
// after the already-merged short-circuit (an idempotent success must not
|
|
577
|
+
// be turned into a refusal by a since-changed ref) and before the
|
|
578
|
+
// head-drift / pr_not_open guards below.
|
|
579
|
+
const firstRefMismatch = findRefMismatch(expectedBaseBranch, expectedHeadBranch, firstRead);
|
|
580
|
+
if (firstRefMismatch) {
|
|
581
|
+
return buildRefMismatchResponse(request, baseDetails, firstRefMismatch);
|
|
582
|
+
}
|
|
482
583
|
if (typeof firstRead.headOid !== "string" || firstRead.headOid.toLowerCase() !== expectedSha.toLowerCase()) {
|
|
483
584
|
return fail("head_drift");
|
|
484
585
|
}
|
|
@@ -517,6 +618,13 @@ export function makeLocalMergeExecutor(options = {}, deps = {}) {
|
|
|
517
618
|
if (isMergedAtExpectedHead(secondRead.state, secondRead.headOid, expectedSha)) {
|
|
518
619
|
return buildAlreadyMergedResponse(request, baseDetails, secondRead.mergeCommitOid);
|
|
519
620
|
}
|
|
621
|
+
// 3c. BAPI-1021 (AC-11) — repeat the ordered ref guard here too, so a PR
|
|
622
|
+
// retargeted while CI was pending cannot reach the merge command. Same
|
|
623
|
+
// ordering rationale as the first-read guard above.
|
|
624
|
+
const secondRefMismatch = findRefMismatch(expectedBaseBranch, expectedHeadBranch, secondRead);
|
|
625
|
+
if (secondRefMismatch) {
|
|
626
|
+
return buildRefMismatchResponse(request, baseDetails, secondRefMismatch);
|
|
627
|
+
}
|
|
520
628
|
if (typeof secondRead.headOid !== "string" || secondRead.headOid.toLowerCase() !== expectedSha.toLowerCase()) {
|
|
521
629
|
return fail("head_drift");
|
|
522
630
|
}
|
|
@@ -625,6 +733,57 @@ function buildConflictResponse(request, baseDetails, expectedSha, mergeability)
|
|
|
625
733
|
{ type: "merge.conflict", status: "failed", reason, details: conflictDetails },
|
|
626
734
|
]);
|
|
627
735
|
}
|
|
736
|
+
/**
|
|
737
|
+
* Compare the PR's CURRENT base/head refs (from a {@link readPrMergeState}
|
|
738
|
+
* read) against the caller's supplied expectations. Returns the first
|
|
739
|
+
* mismatch found (base checked before head), or `undefined` when every
|
|
740
|
+
* supplied expectation matches.
|
|
741
|
+
*
|
|
742
|
+
* An expectation with no corresponding usable actual ref — absent, not a
|
|
743
|
+
* string, or whitespace-only, already normalized to `undefined` by
|
|
744
|
+
* {@link readBoundedRefName} — counts as a MISMATCH, never a skip. Silently
|
|
745
|
+
* treating an unreadable ref as "nothing to check" would let exactly the
|
|
746
|
+
* unverifiable case slip through the guard it exists to provide.
|
|
747
|
+
*/
|
|
748
|
+
function findRefMismatch(expectedBaseBranch, expectedHeadBranch, actual) {
|
|
749
|
+
if (expectedBaseBranch !== undefined && actual.baseRefName !== expectedBaseBranch) {
|
|
750
|
+
return { field: "base", expected: expectedBaseBranch, actual: actual.baseRefName ?? "" };
|
|
751
|
+
}
|
|
752
|
+
if (expectedHeadBranch !== undefined && actual.headRefName !== expectedHeadBranch) {
|
|
753
|
+
return { field: "head", expected: expectedHeadBranch, actual: actual.headRefName ?? "" };
|
|
754
|
+
}
|
|
755
|
+
return undefined;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Build a `ref_mismatch` failure (AC-11): a deliberate, terminal safety
|
|
759
|
+
* refusal issued BEFORE any provider-merge subprocess when the PR's current
|
|
760
|
+
* base or head branch does not match the caller's expectation.
|
|
761
|
+
*
|
|
762
|
+
* Details are allowlisted to the expected/actual branch values only — never
|
|
763
|
+
* raw `gh` output, stderr, response bodies, credentials, or exception text,
|
|
764
|
+
* mirroring {@link buildConflictResponse}'s secret-safety contract. The
|
|
765
|
+
* message states plainly that no provider merge was attempted and directs the
|
|
766
|
+
* operator to rebuild or cherry-pick the change against the expected run base
|
|
767
|
+
* — retargeting the pull request in the GitHub UI would only relabel a branch
|
|
768
|
+
* that has already drifted from what the run actually intends to merge, not
|
|
769
|
+
* fix it.
|
|
770
|
+
*/
|
|
771
|
+
function buildRefMismatchResponse(request, baseDetails, mismatch) {
|
|
772
|
+
const reason = "ref_mismatch";
|
|
773
|
+
const details = {
|
|
774
|
+
...baseDetails,
|
|
775
|
+
mismatched_field: mismatch.field,
|
|
776
|
+
[`expected_${mismatch.field}_branch`]: mismatch.expected,
|
|
777
|
+
[`actual_${mismatch.field}_branch`]: mismatch.actual,
|
|
778
|
+
message: `No provider merge was attempted: the pull request's current ${mismatch.field} branch ` +
|
|
779
|
+
`does not match the run's expected ${mismatch.field} branch. Rebuild or cherry-pick the ` +
|
|
780
|
+
"change against the expected run base rather than retargeting the pull request in the " +
|
|
781
|
+
"GitHub UI.",
|
|
782
|
+
};
|
|
783
|
+
return buildResponse(request, "failed", reason, false, [
|
|
784
|
+
{ type: "merge.failed", status: "failed", reason, details },
|
|
785
|
+
]);
|
|
786
|
+
}
|
|
628
787
|
/**
|
|
629
788
|
* Probe whether this host can merge with `gh` at all, BEFORE any merge is
|
|
630
789
|
* attempted.
|