@bridge_gpt/mcp-server 0.2.74 → 0.2.76
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 +14 -7
- package/build/agent-launchers/prompt.js +9 -21
- package/build/agents.generated.js +6 -6
- package/build/authored-plan.js +542 -0
- package/build/bridge-permissions.js +8 -0
- package/build/codex-auto-recovery.js +25 -7
- package/build/commands.generated.js +7 -7
- package/build/conductor/bridge-api-client.js +807 -52
- package/build/conductor/declare-blocked.js +4 -0
- package/build/conductor/driver-pass.js +8 -0
- package/build/conductor/epic-implementer-cli.js +341 -96
- package/build/conductor/epic-server-journal.js +13 -0
- package/build/conductor/epic-server-recipe.js +15 -5
- package/build/conductor/epic-server-runtime.js +163 -45
- package/build/conductor/epic-server.js +13 -6
- package/build/conductor/gate-discovery.js +209 -9
- package/build/conductor/gate-settings-review.js +7 -11
- package/build/conductor/install-doctor.js +30 -2
- package/build/conductor/launch-plan.js +58 -12
- package/build/conductor/local-merge.js +54 -12
- package/build/conductor/open-decision-phrases.js +50 -0
- package/build/conductor/pr-ci-producer.js +12 -3
- package/build/conductor/prerequisite-inputs.js +181 -14
- package/build/conductor/readiness-sections.js +46 -13
- package/build/conductor/readiness.js +3 -40
- package/build/conductor/recovery-cli.js +12 -12
- package/build/conductor/repository-workflow-remedy.js +147 -7
- package/build/conductor/ui-readiness.js +224 -0
- package/build/conductor/wait-run-attention.js +9 -4
- package/build/conductor/wait-run-cli.js +9 -2
- package/build/connect-github-api.js +18 -0
- package/build/connect-github.js +35 -18
- package/build/docs.generated.js +3 -3
- package/build/drive-epic.js +787 -37
- package/build/epic-ci-workflow.js +3 -2
- package/build/epic-implementer-bin.js +200 -66
- package/build/epic-implementer-bundle-cli.js +61 -0
- package/build/epic-implementer-claude-hook-bin.js +1 -1
- package/build/epic-implementer-env.js +3 -4
- package/build/epic-integration-pr.js +5 -2
- package/build/epic-launch-context.js +8 -1
- package/build/epic-shared/cut-protocol.js +55 -3
- package/build/executor/completion-contract.js +24 -1
- package/build/executor/failure-reason-codes.js +2 -0
- package/build/executor/gate-qualification-job.js +193 -23
- package/build/executor/gate-qualification-tests-ran.js +232 -0
- package/build/executor/integration-job.js +56 -2
- package/build/executor/job-runner.js +13 -723
- package/build/executor/job-type-wrappers.js +734 -0
- package/build/executor/merge-job.js +45 -1
- package/build/executor/permissions.js +187 -2
- package/build/executor/preflight.js +6 -2
- package/build/executor/process-containment.js +8 -1
- package/build/executor/provider-checks.js +28 -5
- package/build/executor/reconcile-overlap-job.js +70 -17
- package/build/executor/required-verification.js +28 -2
- package/build/executor/required-work-ledger.js +7 -2
- package/build/executor/resume-pre-spawn.js +32 -8
- package/build/executor/runner.js +30 -5
- package/build/executor/types.js +9 -0
- package/build/executor/worker-database.js +6 -1
- package/build/executor/worker-guard-hook.js +24 -2
- package/build/executor/worktree.js +12 -1
- package/build/generated/ticket-status.js +20 -0
- package/build/index.js +627 -551
- package/build/init.js +16 -0
- package/build/install-bridge-conductor-answers.js +32 -1
- package/build/install-bridge-conductor-apply.js +21 -3
- package/build/install-bridge-conductor-assessment.js +185 -12
- package/build/install-bridge-conductor-compact.js +2 -0
- package/build/install-bridge-conductor-contracts.js +9 -1
- package/build/install-bridge-conductor-gate.js +257 -80
- package/build/install-bridge-conductor-setup.js +106 -6
- package/build/install-bridge-conductor-trial-report.js +170 -0
- package/build/install-bridge-conductor.js +740 -124
- package/build/mcp-host-config.js +54 -37
- package/build/phase-context-git-probe.js +16 -0
- package/build/pipelines.generated.js +15 -15
- package/build/plan-execution-ledger.js +27 -0
- package/build/plan-generation.js +17 -0
- package/build/plane/plane-freshness.js +43 -26
- package/build/printed-remedy-commands.js +62 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-toolchains.js +11 -5
- package/build/scripts/saved-commands-config-field-driver.js +65 -0
- package/build/secret-redaction.js +3 -0
- package/build/setup-epic.js +51 -9
- package/build/test-support/create-preview-world.js +232 -0
- package/build/test-support/executor-source-files.js +1 -1
- package/build/ticket-delivery.js +65 -0
- package/build/v2-readiness-requirements.js +13 -4
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktree-core.js +51 -7
- package/docs/EPIC-IMPLEMENTER.md +83 -4
- package/docs/epic-implementer/getting-started.md +1 -1
- package/docs/install/github-app.md +79 -92
- package/package.json +1 -1
- package/pipelines/implement-ticket.json +2 -2
- package/build/conductor/epic-reconcile.js +0 -603
- package/build/conductor/epic-runtime.js +0 -2020
- package/build/conductor/epic-state.js +0 -774
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
* an empty `workerEnv` list is a deliberate removal of every stored variable.
|
|
39
39
|
*/
|
|
40
40
|
import { redactSecretString } from "./redaction.js";
|
|
41
|
-
import { LOCAL_COMMAND_TIMEOUT_SECONDS, } from "./gate-discovery.js";
|
|
41
|
+
import { dependencyInstallNoteSentences, LOCAL_COMMAND_TIMEOUT_SECONDS, } from "./gate-discovery.js";
|
|
42
42
|
import { CI_DATABASE_DEFAULT, MAX_DEPENDENCY_INSTALL_ENTRIES, MAX_DEPENDENCY_INSTALL_LOCKFILES, MAX_MUST_ORDER_PATHS, admitDependencyInstallDeclarations, canonicalMustOrderPaths, dependencyInstallEntryIdentity, isCiDatabase, isSafeRepoRelativePath, sameDependencyInstall, sameMustOrderPaths, } from "../dependency-install-declarations.js";
|
|
43
43
|
/** Limits that mirror `gate_profile.py` for hand-typed hints. */
|
|
44
44
|
const MAX_HINT_WORDS = 32;
|
|
@@ -263,7 +263,7 @@ export function hasDeclarationsToReview(proposal, stored) {
|
|
|
263
263
|
function hasDependencyOrCiToReview(proposal, stored) {
|
|
264
264
|
return ((stored?.dependency_install?.length ?? 0) > 0 ||
|
|
265
265
|
newDependencyProposals(proposal, stored).length > 0 ||
|
|
266
|
-
(proposal.
|
|
266
|
+
dependencyInstallNoteSentences(proposal).length > 0 ||
|
|
267
267
|
storedCiDatabase(stored) !== CI_DATABASE_DEFAULT ||
|
|
268
268
|
proposedCiDatabase(proposal) !== CI_DATABASE_DEFAULT);
|
|
269
269
|
}
|
|
@@ -421,7 +421,7 @@ export function renderSettingsReview(io, proposal, stored, providerChecks, showV
|
|
|
421
421
|
// Shown only when there is something to say, so a review without either
|
|
422
422
|
// declaration renders exactly as it did before BAPI-1551.
|
|
423
423
|
if (hasDeclarationsToReview(proposal, stored) ||
|
|
424
|
-
(proposal.
|
|
424
|
+
dependencyInstallNoteSentences(proposal).length > 0 ||
|
|
425
425
|
mustOrderOffer(proposal, stored).notOffered > 0) {
|
|
426
426
|
renderDeclarationsReview(io, proposal, stored, showValues);
|
|
427
427
|
}
|
|
@@ -452,11 +452,6 @@ const CI_DATABASE_TEXT = Object.freeze({
|
|
|
452
452
|
provided: "provided — CI provides a database",
|
|
453
453
|
unknown: "unknown — not declared",
|
|
454
454
|
});
|
|
455
|
-
const DEPENDENCY_NOTE_TEXT = Object.freeze({
|
|
456
|
-
dependency_install_pip_not_proposed: "A pip requirements file was found. It is not proposed: a bare pip install would use whatever " +
|
|
457
|
-
"Python is first on the executor's PATH, not this worktree's environment. Add an entry by hand if you need one.",
|
|
458
|
-
dependency_install_toolchain_unresolved: "The repository's toolchains could not be read with certainty, so nothing is proposed.",
|
|
459
|
-
});
|
|
460
455
|
/** One entry as a person reads it: where it runs and what it watches first, then the command. */
|
|
461
456
|
function describeDependencyEntry(entry, label, showValues) {
|
|
462
457
|
const where = entry.cwd === "." ? "repository root" : terminalSafe(entry.cwd);
|
|
@@ -512,8 +507,9 @@ function renderDependencyAndCiReview(io, proposal, stored, showValues) {
|
|
|
512
507
|
for (const line of rest)
|
|
513
508
|
io.log(line);
|
|
514
509
|
});
|
|
515
|
-
|
|
516
|
-
|
|
510
|
+
// BAPI-1698: the same sentences every setup surface shows, each fact once. Advisory only.
|
|
511
|
+
for (const sentence of dependencyInstallNoteSentences(proposal))
|
|
512
|
+
io.log(` ${plainDisplayText(sentence)}`);
|
|
517
513
|
for (const line of proposal.dependencyInstallLimitations ?? [])
|
|
518
514
|
io.log(` Could not check: ${plainDisplayText(line)}`);
|
|
519
515
|
io.log(" Each command runs in every fresh worker worktree, and again only when a file it names changes.");
|
|
@@ -728,7 +724,7 @@ async function reviewDependencyInstall(io, proposal, stored) {
|
|
|
728
724
|
const prompt = io.promptLine;
|
|
729
725
|
const storedList = (stored?.dependency_install ?? []).map(entryOf);
|
|
730
726
|
const proposals = newDependencyProposals(proposal, stored);
|
|
731
|
-
if (storedList.length === 0 && proposals.length === 0 && (proposal.
|
|
727
|
+
if (storedList.length === 0 && proposals.length === 0 && dependencyInstallNoteSentences(proposal).length === 0) {
|
|
732
728
|
return undefined;
|
|
733
729
|
}
|
|
734
730
|
const letters = [
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
* workflow scaffold, no schema migration, no hook installation. It is invoked
|
|
31
31
|
* from a write-capable installer, so that boundary is pinned by tests.
|
|
32
32
|
*/
|
|
33
|
-
import { readdir as fsReaddir, readFile as fsReadFile, stat as fsStat } from "node:fs/promises";
|
|
33
|
+
import { readdir as fsReaddir, readFile as fsReadFile, stat as fsStat, lstat as fsLstat } from "node:fs/promises";
|
|
34
|
+
import { readEpicServerRecord } from "../epic-server-record.js";
|
|
34
35
|
import os from "node:os";
|
|
35
36
|
import { buildConductorDoctorReport, formatConductorDoctorReport, } from "./doctor.js";
|
|
36
37
|
import { inspectBridgeApiProfileToken, } from "../mcp-host-config.js";
|
|
@@ -56,6 +57,25 @@ async function settle(collect) {
|
|
|
56
57
|
return { value: null, failed: true };
|
|
57
58
|
}
|
|
58
59
|
}
|
|
60
|
+
/** A usable repository-scoped epic-server record, read through the shared validator. Never throws. */
|
|
61
|
+
async function epicServerRecordUsable(deps) {
|
|
62
|
+
const repoName = deps.access?.repoName;
|
|
63
|
+
if (repoName === undefined || repoName === "")
|
|
64
|
+
return false;
|
|
65
|
+
try {
|
|
66
|
+
const read = deps.readEpicServerRecord ??
|
|
67
|
+
((name) => readEpicServerRecord(name, {
|
|
68
|
+
env: process.env,
|
|
69
|
+
homedir: os.homedir,
|
|
70
|
+
readFile: (filePath) => fsReadFile(filePath, "utf-8"),
|
|
71
|
+
lstat: (filePath) => fsLstat(filePath),
|
|
72
|
+
}));
|
|
73
|
+
return (await read(repoName)).state === "ok";
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
59
79
|
/**
|
|
60
80
|
* Build the unified report. Never throws: every probe failure becomes a section.
|
|
61
81
|
*/
|
|
@@ -244,7 +264,15 @@ export async function runConductorInstallDoctor(deps) {
|
|
|
244
264
|
// collection gap rather than losing the section.
|
|
245
265
|
}
|
|
246
266
|
const conductorContext = detectConductorContext(legacyConductor, profileToken);
|
|
247
|
-
|
|
267
|
+
// BAPI-1719: the profile section also reads RECORDED setup, because a missing group is exactly
|
|
268
|
+
// what keeps the conductor-context detection above from firing. The hook-target section keeps
|
|
269
|
+
// `conductorContext` unchanged. A usable repository-scoped epic-server record is read only when
|
|
270
|
+
// readiness itself is unavailable; any missing, unusable, or throwing read is "not recorded".
|
|
271
|
+
let setupRecorded = readiness?.supervisor?.setup_present === true;
|
|
272
|
+
if (!setupRecorded && readiness === null)
|
|
273
|
+
setupRecorded = await epicServerRecordUsable(deps);
|
|
274
|
+
const profileContext = conductorContext || setupRecorded;
|
|
275
|
+
sections.push(conductorProfileTokenSection(profileToken, profileContext));
|
|
248
276
|
sections.push(conductorHookTargetsSection(legacyConductor, conductorContext));
|
|
249
277
|
sections.push(conductorLedgerLoadabilitySection(legacyConductor));
|
|
250
278
|
// BAPI-1135 — this HOST's ability to observe the merge capability, beside the
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EPIC_KEY_PATTERN } from "../drive-epic-key.js";
|
|
2
2
|
import { WORKER_DATABASE_DOCTOR_OWNER, WORKER_DATABASE_DOCTOR_RUNBOOK_SECTION } from "./doctor.js";
|
|
3
|
+
import { redactSecrets } from "../secret-redaction.js";
|
|
3
4
|
import { LAUNCH_NEED_REMEDIES, LAUNCH_NEED_ROW_IDS, LAUNCH_NEEDS } from "./readiness-sections.js";
|
|
4
5
|
export const NO_LAUNCH_PLAN_FACTS = Object.freeze({
|
|
5
6
|
prerequisites: { status: "not_collected" },
|
|
@@ -112,13 +113,16 @@ function summaryLine(preview, blocked) {
|
|
|
112
113
|
parts.push(where);
|
|
113
114
|
return `${preview.epic_key} is ready to launch: ${parts.join(", ")}.`;
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
+
/** BAPI-1704 — appended to the ready branch's launch option when open decisions exist. */
|
|
117
|
+
const OPEN_DECISION_LAUNCH_SENTENCE = "If an open decision blocks a child, the driver may settle it by council.";
|
|
118
|
+
function launchOption(number, label, local, recommended, extra) {
|
|
119
|
+
const base = local
|
|
120
|
+
? "Creates the run and starts it on your local plane."
|
|
121
|
+
: "Creates the run and starts it on the server.";
|
|
116
122
|
return {
|
|
117
123
|
number,
|
|
118
124
|
label,
|
|
119
|
-
description:
|
|
120
|
-
? "Creates the run and starts it on your local plane."
|
|
121
|
-
: "Creates the run and starts it on the server.",
|
|
125
|
+
description: extra === undefined ? base : `${base} ${extra}`,
|
|
122
126
|
duration: local ? LAUNCH_PLAN_DURATION.local : LAUNCH_PLAN_DURATION.remote,
|
|
123
127
|
recommended,
|
|
124
128
|
};
|
|
@@ -169,7 +173,8 @@ function generatedPlanItem(preview) {
|
|
|
169
173
|
const source = plan.inline ?? plan.generation;
|
|
170
174
|
if (source === undefined)
|
|
171
175
|
return null;
|
|
172
|
-
|
|
176
|
+
// BAPI-1706 — a server plan's inline nodes carry no summary; read as unusable.
|
|
177
|
+
const summary = source.summary ?? null;
|
|
173
178
|
const parts = [];
|
|
174
179
|
if (summary?.serialized_reason) {
|
|
175
180
|
parts.push(SERIALIZED_REASON_COPY[summary.serialized_reason]?.(summary.unknown_files) ?? "It runs one child at a time.");
|
|
@@ -178,6 +183,9 @@ function generatedPlanItem(preview) {
|
|
|
178
183
|
parts.push(summary.order_source === "epic_manifest"
|
|
179
184
|
? "Order and dependencies come from the epic's ordered child manifest."
|
|
180
185
|
: "Order is ascending ticket key.");
|
|
186
|
+
if (summary.order_fallback_reason === "manifest_unreadable") {
|
|
187
|
+
parts.push("The epic has an ordered child manifest section, but it could not be read, so the plan uses ascending ticket-key order.");
|
|
188
|
+
}
|
|
181
189
|
for (const entry of summary.excluded) {
|
|
182
190
|
parts.push(`Left out: ${entry.ticket_key} (${entry.reason}; the Epic Implementer cannot run an unfinished spike).`);
|
|
183
191
|
}
|
|
@@ -245,6 +253,18 @@ export function buildLaunchPlan(preview, facts = NO_LAUNCH_PLAN_FACTS) {
|
|
|
245
253
|
reason: `${entry.dependents} will stop without it. Tickets that don't depend on it keep going.${sure}`,
|
|
246
254
|
}, entry.name);
|
|
247
255
|
}
|
|
256
|
+
// BAPI-1704 — open decisions follow the missing-core items. Display text is redacted
|
|
257
|
+
// here; the raw facts stay untouched. Detail ids count from one per child.
|
|
258
|
+
const openDecisions = refusal === null && prerequisiteFacts.status === "collected" ? prerequisiteFacts.openDecisions : [];
|
|
259
|
+
const openDecisionCounts = new Map();
|
|
260
|
+
for (const entry of openDecisions) {
|
|
261
|
+
const n = (openDecisionCounts.get(entry.child) ?? 0) + 1;
|
|
262
|
+
openDecisionCounts.set(entry.child, n);
|
|
263
|
+
add("needs_choice", {
|
|
264
|
+
summary: `${entry.child} leaves a decision open: "${redactSecrets(entry.clause)}"`,
|
|
265
|
+
reason: "Settling it now avoids an overnight decision.",
|
|
266
|
+
}, `open-decision-${entry.child}-${n}`);
|
|
267
|
+
}
|
|
248
268
|
// --- worth knowing: surviving non-blocking evidence ------------------------------
|
|
249
269
|
if (refusal === null) {
|
|
250
270
|
const roleRow = presentNeed(rows, "worker_db_role");
|
|
@@ -306,16 +326,42 @@ export function buildLaunchPlan(preview, facts = NO_LAUNCH_PLAN_FACTS) {
|
|
|
306
326
|
}
|
|
307
327
|
else {
|
|
308
328
|
const missing = missingCore.length > 0;
|
|
309
|
-
|
|
310
|
-
|
|
329
|
+
const decisions = openDecisions.length > 0;
|
|
330
|
+
push(launchOption(1, missing ? "Launch now and supply it later" : "Launch now", local, !decisions, decisions ? OPEN_DECISION_LAUNCH_SENTENCE : undefined), "launch");
|
|
331
|
+
if (decisions) {
|
|
332
|
+
push(nothingOption(options.length + 1, missing ? "Stop so you can supply or settle it" : "Stop so you can settle it first", true), "create_nothing");
|
|
333
|
+
}
|
|
334
|
+
else if (missing) {
|
|
311
335
|
push(nothingOption(options.length + 1, "Stop so you can supply it", false), "create_nothing");
|
|
336
|
+
}
|
|
312
337
|
push(nothingOption(options.length + 1, "Don't launch yet", false), "create_nothing");
|
|
313
|
-
recommendation =
|
|
314
|
-
|
|
315
|
-
? "Every check that protects your code passed."
|
|
338
|
+
recommendation = !decisions
|
|
339
|
+
? "launch now."
|
|
316
340
|
: missing
|
|
317
|
-
? "
|
|
318
|
-
: "
|
|
341
|
+
? "stop so you can supply or settle it."
|
|
342
|
+
: "stop so you can settle it first.";
|
|
343
|
+
// BAPI-1694 — the positive claim is made only when nothing in the preview is unverified.
|
|
344
|
+
const partialValidation = preview.summary?.server_validation === "partial";
|
|
345
|
+
const tallyLines = Array.isArray(preview.tally_lines) ? preview.tally_lines : [];
|
|
346
|
+
const unprovenTally = tallyLines.some((line) => isObject(line) && typeof line.code === "string" && line.code.endsWith("_unproven"));
|
|
347
|
+
const unverifiableNeed = rows.some((row) => isObject(row.launch_need) && row.launch_need.state === "unverifiable");
|
|
348
|
+
const uncertain = partialValidation || unprovenTally || unverifiableNeed;
|
|
349
|
+
const tail = verdict === "ready"
|
|
350
|
+
? null
|
|
351
|
+
: decisions && missing
|
|
352
|
+
? "Some children need something you can supply later or leave a decision open."
|
|
353
|
+
: decisions
|
|
354
|
+
? "Some children leave a decision open."
|
|
355
|
+
: missing
|
|
356
|
+
? "Some children need something you can supply later."
|
|
357
|
+
: "A few things are worth knowing.";
|
|
358
|
+
reason = [
|
|
359
|
+
uncertain
|
|
360
|
+
? "Some checks returned no verifiable result; no check that protects your code failed."
|
|
361
|
+
: "Every check that protects your code passed.",
|
|
362
|
+
partialValidation ? "The server checks again when it creates the run." : null,
|
|
363
|
+
tail,
|
|
364
|
+
].filter((sentence) => sentence !== null).join(" ");
|
|
319
365
|
}
|
|
320
366
|
const plan = {
|
|
321
367
|
version: 2,
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
* module answers only the first.
|
|
55
55
|
*/
|
|
56
56
|
import { spawn } from "child_process";
|
|
57
|
-
import { pollCiChecksForCommit, ConductorBridgeApiError, safeDiagnosticMessage, } from "./bridge-api-client.js";
|
|
57
|
+
import { pollCiChecksForCommit, classifyCiPollAvailability, isFallbackWithNoObservedChecks, CiPollTransientUnavailableError, ConductorBridgeApiError, safeDiagnosticMessage, } from "./bridge-api-client.js";
|
|
58
58
|
import { isLikelyGhMergeConflictOutput, isPrMergeConflict, parseGhPrMergeabilityFields, } from "./github-mergeability.js";
|
|
59
59
|
import { normalizeSelectorCheckName, selectLatestChecksByName } from "./latest-check-selector.js";
|
|
60
60
|
const MERGE_METHODS = new Set(["squash", "merge", "rebase"]);
|
|
@@ -594,6 +594,20 @@ function isAmbiguousCiPollFailureReason(reason) {
|
|
|
594
594
|
* detail on the result. `ci_not_green` is returned only after the budget is exhausted.
|
|
595
595
|
* Never polls the branch name or PR head alias — only `expectedSha`.
|
|
596
596
|
*
|
|
597
|
+
* BAPI-1527: every poll carries `requiredChecks`, so a repository whose CI check
|
|
598
|
+
* configuration was never resolved is judged on live provider evidence. Two named
|
|
599
|
+
* outcomes keep that evidence honest, and both are reported only at the budget
|
|
600
|
+
* boundary, exactly when `ci_not_green` would be. `ci_checks_unavailable` replaces
|
|
601
|
+
* `ci_not_green` when the latest poll said the check configuration or provider
|
|
602
|
+
* access could not be read. An unavailable poll is never green evidence: the loop
|
|
603
|
+
* skips the green test for it and keeps waiting, so a read that recovers inside the
|
|
604
|
+
* budget is judged on the evidence it then returns. The server retries a
|
|
605
|
+
* `ci_checks_unavailable` merge through the same re-fire and retry budget as
|
|
606
|
+
* `ci_not_green`, and parks only once that budget is spent.
|
|
607
|
+
* `ci_no_checks_observed` replaces `ci_not_green` at the budget boundary only when
|
|
608
|
+
* the latest poll was a fallback over an empty required list that saw no check at
|
|
609
|
+
* all; failing, pending, or missing named checks still end as `ci_not_green`.
|
|
610
|
+
*
|
|
597
611
|
* BAPI-572 abort-awareness: the CI-wait loop is the longest-running,
|
|
598
612
|
* non-`gh`-subprocess phase of a merge. It must short-circuit with `merge_aborted`
|
|
599
613
|
* as soon as the injected abort signal fires — otherwise a merge job the executor
|
|
@@ -602,24 +616,44 @@ function isAmbiguousCiPollFailureReason(reason) {
|
|
|
602
616
|
*/
|
|
603
617
|
async function waitForRequiredChecksGreen(pollCi, access, expectedSha, requiredChecks, timeoutMs, pollIntervalMs, sleep, now, signal) {
|
|
604
618
|
const start = now();
|
|
619
|
+
let lastPollSawNoChecks = false;
|
|
620
|
+
let lastPollUnavailable = false;
|
|
605
621
|
for (;;) {
|
|
606
622
|
if (signal?.aborted)
|
|
607
623
|
return { ok: false, reason: "merge_aborted" };
|
|
608
624
|
let pollResponse;
|
|
609
625
|
try {
|
|
610
|
-
pollResponse = await pollCi(access, expectedSha);
|
|
626
|
+
pollResponse = await pollCi(access, expectedSha, requiredChecks);
|
|
611
627
|
}
|
|
612
628
|
catch (err) {
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
629
|
+
if (err instanceof CiPollTransientUnavailableError) {
|
|
630
|
+
// BAPI-1527 decision A: the route's transient envelope is the same
|
|
631
|
+
// provider exception that, before the opt-in, came back as a plain
|
|
632
|
+
// not-green envelope. Keep waiting exactly as before: a null response is
|
|
633
|
+
// never green and ends as `ci_not_green` at the budget boundary.
|
|
634
|
+
pollResponse = null;
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
// Preserve the caught bridge poll error's coarse kind/status instead of
|
|
638
|
+
// flattening every failure to an opaque `ci_poll_failed` (BAPI-577 Part A).
|
|
639
|
+
// Unknown/non-bridge throws yield `undefined` detail → legacy `ci_poll_failed`.
|
|
640
|
+
const pollFailure = ciPollFailureDetailFromError(err);
|
|
641
|
+
return { ok: false, reason: ciPollFailureReasonFromDetail(pollFailure), pollFailure };
|
|
642
|
+
}
|
|
618
643
|
}
|
|
619
|
-
|
|
644
|
+
// Unreadable configuration is not a failed check and never green evidence:
|
|
645
|
+
// skip the green test (it could read `detail: null` as red CI) and keep waiting
|
|
646
|
+
// like any other not-green poll. The name is reported at the budget boundary.
|
|
647
|
+
lastPollUnavailable = classifyCiPollAvailability(pollResponse) === "configuration_unavailable";
|
|
648
|
+
if (!lastPollUnavailable && allRequiredChecksGreen(pollResponse, requiredChecks))
|
|
620
649
|
return { ok: true };
|
|
621
|
-
|
|
622
|
-
|
|
650
|
+
lastPollSawNoChecks =
|
|
651
|
+
!lastPollUnavailable && requiredChecks.length === 0 && isFallbackWithNoObservedChecks(pollResponse);
|
|
652
|
+
if (now() - start >= timeoutMs) {
|
|
653
|
+
if (lastPollUnavailable)
|
|
654
|
+
return { ok: false, reason: "ci_checks_unavailable" };
|
|
655
|
+
return { ok: false, reason: lastPollSawNoChecks ? "ci_no_checks_observed" : "ci_not_green" };
|
|
656
|
+
}
|
|
623
657
|
await sleep(pollIntervalMs);
|
|
624
658
|
// Re-check after the sleep so an abort during the interval stops the loop
|
|
625
659
|
// before the next poll (and, critically, before any provider merge).
|
|
@@ -643,7 +677,8 @@ export function makeLocalMergeExecutor(options = {}, deps = {}) {
|
|
|
643
677
|
// signal is threaded to the default runner so an overall merge timeout can
|
|
644
678
|
// cancel in-flight subprocess work.
|
|
645
679
|
const run = (cmd, args, env) => Promise.resolve(rawRun(cmd, args, env, deps.signal));
|
|
646
|
-
const pollCi = deps.pollCi ??
|
|
680
|
+
const pollCi = deps.pollCi ??
|
|
681
|
+
((pollAccess, commitRef, checks) => pollCiChecksForCommit(pollAccess, commitRef, undefined, checks));
|
|
647
682
|
const sleep = deps.sleep ?? defaultSleep;
|
|
648
683
|
const now = deps.now ?? (() => Date.now());
|
|
649
684
|
const signal = deps.signal;
|
|
@@ -760,7 +795,10 @@ export function makeLocalMergeExecutor(options = {}, deps = {}) {
|
|
|
760
795
|
// for transient post-remediation CI to turn green before failing ci_not_green.
|
|
761
796
|
// Skipped under `skipCiWait` (BAPI-832), where the server's approval tail
|
|
762
797
|
// revalidated these same checks for this same head moments ago.
|
|
763
|
-
|
|
798
|
+
// Also skipped (BAPI-1724) for a run that declared no CI gate, with an
|
|
799
|
+
// empty check list; a non-empty list always waits.
|
|
800
|
+
const noCiGateSkip = options.noCiGateDeclared === true && requiredChecks.length === 0;
|
|
801
|
+
if (!options.skipCiWait && !noCiGateSkip) {
|
|
764
802
|
const ciWait = await waitForRequiredChecksGreen(pollCi, access, expectedSha, requiredChecks, ciWaitTimeoutMs, ciWaitPollIntervalMs, sleep, now, signal);
|
|
765
803
|
if (!ciWait.ok) {
|
|
766
804
|
// Any `ci_poll_*` reason (the legacy `ci_poll_failed` plus the distinct
|
|
@@ -776,6 +814,8 @@ export function makeLocalMergeExecutor(options = {}, deps = {}) {
|
|
|
776
814
|
}
|
|
777
815
|
return fail(ciWait.reason, ciWait.pollFailure);
|
|
778
816
|
}
|
|
817
|
+
// 3b/3c rereads protect the CI-wait INTERVAL. A no-wait merge has no such
|
|
818
|
+
// interval: the first PR read above and `--match-head-commit` protect it.
|
|
779
819
|
// 3b. Re-read PR head/state after the CI wait — the head can drift, the PR can
|
|
780
820
|
// close, or the merge can already have landed while we waited for CI.
|
|
781
821
|
const secondRead = await readPrMergeState(run, ghEnv, pr);
|
|
@@ -876,6 +916,8 @@ export function makeLocalMergeExecutor(options = {}, deps = {}) {
|
|
|
876
916
|
}
|
|
877
917
|
const succeededDetails = {
|
|
878
918
|
...baseDetails,
|
|
919
|
+
// BAPI-1724: success-only. A refusal or failure keeps the plain details.
|
|
920
|
+
...(noCiGateSkip && !options.skipCiWait ? { ci_wait: "skipped_no_ci_gate_declared" } : {}),
|
|
879
921
|
...(mergeCommitSha ? { merge_commit_sha: mergeCommitSha } : {}),
|
|
880
922
|
};
|
|
881
923
|
return buildResponse(request, "succeeded", null, true, [
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The open-decision phrase list and its pure matcher (BAPI-1704).
|
|
3
|
+
*
|
|
4
|
+
* The list is an exact, ordered, case-sensitive copy of the canonical block in
|
|
5
|
+
* `docs/bridge-ticket-authoring.md` (BAPI-1703). `tests/pytest/static/
|
|
6
|
+
* test_open_decision_phrases_parity.py` fails if the two drift. A match is an
|
|
7
|
+
* advisory signal for a person to review; it never decides anything here.
|
|
8
|
+
*/
|
|
9
|
+
/** The canonical phrases, in canonical order. Order is the tie-breaker. */
|
|
10
|
+
export const OPEN_DECISION_PHRASES = Object.freeze([
|
|
11
|
+
"must settle",
|
|
12
|
+
"settle this before",
|
|
13
|
+
"before planning",
|
|
14
|
+
"the caller must",
|
|
15
|
+
"owner confirms",
|
|
16
|
+
"owner must confirm",
|
|
17
|
+
"confirm with the owner",
|
|
18
|
+
"stop if not met",
|
|
19
|
+
"check the precondition first",
|
|
20
|
+
"TBD",
|
|
21
|
+
"to be decided",
|
|
22
|
+
]);
|
|
23
|
+
function escapeRegExp(text) {
|
|
24
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25
|
+
}
|
|
26
|
+
const PHRASE_PATTERNS = OPEN_DECISION_PHRASES.map((phrase) => ({
|
|
27
|
+
phrase,
|
|
28
|
+
// Whole-phrase boundaries at both ends: no word character may touch either end.
|
|
29
|
+
pattern: new RegExp(`(?<![\\p{L}\\p{N}_])${escapeRegExp(phrase)}(?![\\p{L}\\p{N}_])`, "iu"),
|
|
30
|
+
}));
|
|
31
|
+
/**
|
|
32
|
+
* Find the earliest open-decision phrase in one line.
|
|
33
|
+
*
|
|
34
|
+
* Matching is case-insensitive and whole-phrase. The result carries the phrase as
|
|
35
|
+
* spelled in {@link OPEN_DECISION_PHRASES} and `index`, a position usable to slice
|
|
36
|
+
* the original JavaScript string. Matches at the same position go to the phrase
|
|
37
|
+
* that comes first in the canonical list. Pure: no normalization, environment
|
|
38
|
+
* access, logging, or policy decision.
|
|
39
|
+
*/
|
|
40
|
+
export function findOpenDecisionPhrase(line) {
|
|
41
|
+
let best;
|
|
42
|
+
for (const { phrase, pattern } of PHRASE_PATTERNS) {
|
|
43
|
+
const match = pattern.exec(line);
|
|
44
|
+
if (match === null)
|
|
45
|
+
continue;
|
|
46
|
+
if (best === undefined || match.index < best.index)
|
|
47
|
+
best = { phrase, index: match.index };
|
|
48
|
+
}
|
|
49
|
+
return best;
|
|
50
|
+
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import { GIT_CI_PRODUCER, REVIEW_STATE, } from "./git-ci-types.js";
|
|
13
13
|
import { evaluateDoneGate, normalizeCiSnapshot, parseDoneGateConfig } from "./done-gate.js";
|
|
14
14
|
import { observeReviewWithResolved } from "./pr-review-producer.js";
|
|
15
|
-
import { fetchEffectiveSupervisorSetup, fetchActiveEpicRuns, fetchEpicRunState, pollCiChecksForCommit, resolveConductorBridgeApiAccess, } from "./bridge-api-client.js";
|
|
15
|
+
import { fetchEffectiveSupervisorSetup, fetchActiveEpicRuns, fetchEpicRunState, pollCiChecksForCommit, classifyCiPollAvailability, resolveConductorBridgeApiAccess, } from "./bridge-api-client.js";
|
|
16
16
|
/** Default gate-config fetcher: reads done_gate_config from the supervisor setup. */
|
|
17
17
|
async function _fetchGateConfigDefault(access) {
|
|
18
18
|
const setup = await fetchEffectiveSupervisorSetup(access);
|
|
@@ -138,7 +138,8 @@ async function observeWithResolved(binding, access, gateConfig, deps, expectedBa
|
|
|
138
138
|
((input, dimensions) => emitConductorEventIfNew(input, dimensions, {
|
|
139
139
|
emitEvent: emitConductorEventFn,
|
|
140
140
|
}));
|
|
141
|
-
const pollCi = deps.pollCi ??
|
|
141
|
+
const pollCi = deps.pollCi ??
|
|
142
|
+
((pollAccess, commitRef, requiredChecks) => pollCiChecksForCommit(pollAccess, commitRef, undefined, requiredChecks));
|
|
142
143
|
const now = deps.now ?? (() => new Date().toISOString());
|
|
143
144
|
// Resolve run_id/worker_id for attribution. Env takes precedence; fall back
|
|
144
145
|
// to the injected resolution seam when the env identity is absent.
|
|
@@ -191,13 +192,21 @@ async function observeWithResolved(binding, access, gateConfig, deps, expectedBa
|
|
|
191
192
|
// 2. Poll CI for the bound head SHA. A poll failure is NOT a CI failure event.
|
|
192
193
|
let rawPoll;
|
|
193
194
|
try {
|
|
194
|
-
rawPoll = await pollCi(access, binding.head_sha);
|
|
195
|
+
rawPoll = await pollCi(access, binding.head_sha, []);
|
|
195
196
|
}
|
|
196
197
|
catch {
|
|
197
198
|
result.ci_status = "unavailable";
|
|
198
199
|
result.reason = "ci-poll-failed";
|
|
199
200
|
return result;
|
|
200
201
|
}
|
|
202
|
+
// BAPI-1527: unreadable check configuration or provider access is a missing
|
|
203
|
+
// capability, not a CI result. Report it as unavailable BEFORE snapshot
|
|
204
|
+
// normalization, so no CI-failure telemetry and no `gate.met` can follow.
|
|
205
|
+
if (classifyCiPollAvailability(rawPoll) === "configuration_unavailable") {
|
|
206
|
+
result.ci_status = "unavailable";
|
|
207
|
+
result.reason = "ci-checks-unavailable: required-check configuration or provider access could not be read";
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
201
210
|
const snapshot = normalizeCiSnapshot(rawPoll);
|
|
202
211
|
// 3. CI observation telemetry (only for terminal states).
|
|
203
212
|
const ciEvent = buildCiObservationEventInput(binding, snapshot, run_id, worker_id);
|