@bridge_gpt/mcp-server 0.2.74 → 0.2.75
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 +2 -2
- package/build/authored-plan.js +542 -0
- package/build/bridge-permissions.js +8 -0
- package/build/commands.generated.js +5 -5
- package/build/conductor/bridge-api-client.js +666 -46
- package/build/conductor/epic-implementer-cli.js +337 -93
- package/build/conductor/gate-discovery.js +209 -9
- package/build/conductor/gate-settings-review.js +7 -11
- package/build/conductor/launch-plan.js +58 -12
- package/build/conductor/open-decision-phrases.js +50 -0
- package/build/conductor/prerequisite-inputs.js +181 -14
- package/build/connect-github-api.js +18 -0
- package/build/connect-github.js +35 -18
- package/build/docs.generated.js +2 -2
- package/build/drive-epic.js +387 -12
- package/build/epic-ci-workflow.js +3 -2
- package/build/epic-implementer-bin.js +152 -38
- 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/executor/completion-contract.js +24 -1
- package/build/executor/gate-qualification-job.js +193 -23
- package/build/executor/gate-qualification-tests-ran.js +232 -0
- package/build/executor/job-runner.js +9 -722
- package/build/executor/job-type-wrappers.js +734 -0
- package/build/executor/preflight.js +6 -2
- package/build/executor/process-containment.js +8 -1
- package/build/executor/required-verification.js +28 -2
- package/build/executor/runner.js +4 -1
- 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/generated/ticket-status.js +20 -0
- package/build/index.js +391 -257
- package/build/install-bridge-conductor-answers.js +28 -1
- package/build/install-bridge-conductor-apply.js +11 -3
- package/build/install-bridge-conductor-assessment.js +114 -12
- package/build/install-bridge-conductor-compact.js +2 -0
- package/build/install-bridge-conductor-gate.js +257 -80
- package/build/install-bridge-conductor-setup.js +4 -4
- package/build/install-bridge-conductor-trial-report.js +170 -0
- package/build/install-bridge-conductor.js +303 -31
- package/build/pipelines.generated.js +7 -7
- package/build/plan-generation.js +17 -0
- package/build/printed-remedy-commands.js +54 -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/setup-epic.js +10 -1
- package/build/test-support/executor-source-files.js +1 -1
- package/build/v2-readiness-requirements.js +5 -1
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/docs/EPIC-IMPLEMENTER.md +4 -4
- package/docs/install/github-app.md +79 -92
- package/package.json +1 -1
- package/build/conductor/epic-reconcile.js +0 -603
- package/build/conductor/epic-runtime.js +0 -2020
- package/build/conductor/epic-state.js +0 -774
|
@@ -49,8 +49,9 @@ import { askSetupQuestion, setupConsentQuestion } from "./setup-question.js";
|
|
|
49
49
|
*/
|
|
50
50
|
import { ConductorBridgeApiError, GATE_PROFILE_CAPABILITY_TOKEN, enqueueConductorGateQualification, fetchConductorGateCheckHistory, fetchConductorGateProfile, fetchConductorGateQualificationJob, fetchConductorReadiness, probeConductorGateProfileCapability, probeConductorGateProfileWatchedCapability, probeConductorGateProfileWorkerSetupCapability, putConductorGateProfile, requestConductorLearnedTestCommand, putEpicBranchCiDecision, } from "./conductor/bridge-api-client.js";
|
|
51
51
|
import { describeGateConsequence } from "./conductor/readiness-sections.js";
|
|
52
|
+
import { CHANGE_TEST_COMMAND_TEXT, PASSED_TRIAL_RUN_TEXT, presentTrialResult, renderTrialReport, sanitizeCommandText, trialCommandLines, } from "./install-bridge-conductor-trial-report.js";
|
|
52
53
|
import { applyApprovalExemption, assessApprovalExemptionScope, buildEpicBranchCiEvidence, exemptionManualSteps, inspectEpicBranchWorkflowCoverage, readEpicBranchRulesViaGh, } from "./conductor/epic-branch-ci-inspection.js";
|
|
53
|
-
import { describeEvidence, discoverDeclarations, discoverGate, LOCAL_COMMAND_TIMEOUT_SECONDS, reportedProviderChecks, } from "./conductor/gate-discovery.js";
|
|
54
|
+
import { dependencyInstallNoteSentences, describeEvidence, discoverDeclarations, discoverGate, discoverLocalTestCandidates, LOCAL_COMMAND_TIMEOUT_SECONDS, reportedProviderChecks, } from "./conductor/gate-discovery.js";
|
|
54
55
|
import { dependencyInstallEqual, mergeDependencyProposal, describeSettingsEdit, hasSettingsToReview, hasUnstoredDeclarationProposal, hintEqual, mustOrderOffer, mustOrderShortfallWarning, recommendedSettingsSelection, renderDeclarationsOnly, renderSettingsReview, reviewDeclarations, reviewDiscoveredSettings, settingsMatchStored, storedCiDatabase, terminalSafe, workerDatabaseEqual, workerEnvEqual, } from "./conductor/gate-settings-review.js";
|
|
55
56
|
import { canonicalMustOrderPaths, sameMustOrderPaths, } from "./dependency-install-declarations.js";
|
|
56
57
|
import { PRINTED_EXECUTOR_INSTALL_SERVICE_COMMAND, PRINTED_EXECUTOR_ID_INSTRUCTION, PRINTED_QUALIFY_GATE_COMMAND, PRINTED_REPO_WIDE_EXECUTOR_COMMAND, } from "./printed-remedy-commands.js";
|
|
@@ -987,7 +988,12 @@ export async function runGateDiscovery(io, access, gateDeps) {
|
|
|
987
988
|
if (!fs)
|
|
988
989
|
return emptyProposal();
|
|
989
990
|
const learned = await learnedInstructionsFor(gateDeps);
|
|
990
|
-
return discoverGate({
|
|
991
|
+
return discoverGate({
|
|
992
|
+
fs,
|
|
993
|
+
lookupHistory: historyLookupFor(io, access),
|
|
994
|
+
...(learned !== undefined ? { learned } : {}),
|
|
995
|
+
...(gateDeps?.platform !== undefined ? { platform: gateDeps.platform } : {}),
|
|
996
|
+
});
|
|
991
997
|
}
|
|
992
998
|
/** The learned snapshot, `undefined` when no reader was given. A failing reader is a limitation, never a throw. */
|
|
993
999
|
async function learnedInstructionsFor(gateDeps) {
|
|
@@ -1272,7 +1278,12 @@ allowUnstored = false) {
|
|
|
1272
1278
|
let declarations;
|
|
1273
1279
|
try {
|
|
1274
1280
|
const learned = await learnedInstructionsFor(gateDeps);
|
|
1275
|
-
declarations = await discoverDeclarations({
|
|
1281
|
+
declarations = await discoverDeclarations({
|
|
1282
|
+
fs,
|
|
1283
|
+
providerChecks: desired.providerChecks,
|
|
1284
|
+
...(learned !== undefined ? { learned } : {}),
|
|
1285
|
+
...(gateDeps?.platform !== undefined ? { platform: gateDeps.platform } : {}),
|
|
1286
|
+
});
|
|
1276
1287
|
}
|
|
1277
1288
|
catch {
|
|
1278
1289
|
return null;
|
|
@@ -1295,6 +1306,12 @@ allowUnstored = false) {
|
|
|
1295
1306
|
...(candidates.length > 0 ? { dependencyInstallCandidates: candidates } : {}),
|
|
1296
1307
|
...(declarations.dependencyInstallNotes ? { dependencyInstallNotes: declarations.dependencyInstallNotes } : {}),
|
|
1297
1308
|
...(declarations.dependencyInstallLimitations ? { dependencyInstallLimitations: declarations.dependencyInstallLimitations } : {}),
|
|
1309
|
+
...(declarations.dependencyInstallPipReason !== undefined
|
|
1310
|
+
? { dependencyInstallPipReason: declarations.dependencyInstallPipReason }
|
|
1311
|
+
: {}),
|
|
1312
|
+
...(declarations.dependencyInstallUncoveredManifests !== undefined
|
|
1313
|
+
? { dependencyInstallUncoveredManifests: declarations.dependencyInstallUncoveredManifests }
|
|
1314
|
+
: {}),
|
|
1298
1315
|
...(declarations.dependencyInstallUnknown === true ? { dependencyInstallUnknown: true } : {}),
|
|
1299
1316
|
...(ci !== undefined && !declined?.has(ciDatabaseProposalKey(ci.value)) ? { ciDatabaseProposal: ci } : {}),
|
|
1300
1317
|
...(mustOrder.length > 0 ? { mustOrderPathCandidates: mustOrder } : {}),
|
|
@@ -1323,6 +1340,12 @@ export async function planDeclarations(current, desired, gateDeps) {
|
|
|
1323
1340
|
const storedDeps = current.profile?.dependency_install ?? [];
|
|
1324
1341
|
const candidates = proposal.dependencyInstallCandidates ?? [];
|
|
1325
1342
|
const limitations = [...(proposal.dependencyInstallLimitations ?? [])];
|
|
1343
|
+
// BAPI-1698: the discovery notes and every uncovered root manifest, as the same
|
|
1344
|
+
// plain sentences the terminal review prints. Advisory: never a stop or consent.
|
|
1345
|
+
for (const sentence of dependencyInstallNoteSentences(proposal)) {
|
|
1346
|
+
if (!limitations.includes(sentence))
|
|
1347
|
+
limitations.push(sentence);
|
|
1348
|
+
}
|
|
1326
1349
|
const merge = mergeDependencyProposal(storedDeps, candidates);
|
|
1327
1350
|
if (!merge.withinBounds) {
|
|
1328
1351
|
limitations.push("Adding what setup found would make too many install commands, so the stored ones stay. You can replace the whole list by correcting it.");
|
|
@@ -1612,7 +1635,8 @@ async function inferredCiPlan(io, access, current, currentDesired, gateDeps, opt
|
|
|
1612
1635
|
plan: { current, desired, write, removals: [], origin: "inferred", inferred },
|
|
1613
1636
|
});
|
|
1614
1637
|
if (current.stored_malformed) {
|
|
1615
|
-
io.log(" The stored repository gate could not be read, so setup leaves it alone and plans nothing."
|
|
1638
|
+
io.log(" The stored repository gate could not be read, so setup leaves it alone and plans nothing. " +
|
|
1639
|
+
"Running setup again will not change that; ask Bridge support or follow the operator runbook's `stored_malformed: true` recovery.");
|
|
1616
1640
|
return plan(emptyDesiredGate(), null, {
|
|
1617
1641
|
ciPlan: "none",
|
|
1618
1642
|
reportedChecks: [],
|
|
@@ -1629,13 +1653,14 @@ async function inferredCiPlan(io, access, current, currentDesired, gateDeps, opt
|
|
|
1629
1653
|
// Unknown is not absent: a stored `none` would be kept on every rerun and
|
|
1630
1654
|
// hide the repository's real CI for good. Store nothing and say why.
|
|
1631
1655
|
io.log(" Bridge could not read this repository's CI history, so it cannot tell whether there is CI to watch. " +
|
|
1632
|
-
"It stores no gate now
|
|
1656
|
+
"It stores no gate now. Check GitHub access, sign-in, or the app installation for this repository, then run setup again.");
|
|
1633
1657
|
return plan(emptyDesiredGate(), null, {
|
|
1634
1658
|
ciPlan: "none",
|
|
1635
1659
|
reportedChecks: [],
|
|
1636
1660
|
watchedWritable: false,
|
|
1637
1661
|
watchedUnsupported: false,
|
|
1638
1662
|
storedUnreadable: false,
|
|
1663
|
+
historyUnavailable: true,
|
|
1639
1664
|
trialEligible: false,
|
|
1640
1665
|
reasons: [],
|
|
1641
1666
|
});
|
|
@@ -1685,6 +1710,52 @@ async function inferredCiPlan(io, access, current, currentDesired, gateDeps, opt
|
|
|
1685
1710
|
],
|
|
1686
1711
|
});
|
|
1687
1712
|
}
|
|
1713
|
+
/** The fix for a write whose effect could not be read back. It never recommends writing again first. */
|
|
1714
|
+
const UNCERTAIN_POLICY_FIX = "Read the gate with `epic-implementer doctor` first. Retry only after it shows what was stored; setup did not retry blindly.";
|
|
1715
|
+
/**
|
|
1716
|
+
* BAPI-1701 — sanitized reason and fix for an unsuccessful combined-policy write.
|
|
1717
|
+
* Input is the closed category and whether the outcome is uncertain, so no response
|
|
1718
|
+
* body, header, submitted value, or exception text can reach the output.
|
|
1719
|
+
* A write that could not be confirmed always leads with `doctor`, whatever its category.
|
|
1720
|
+
*/
|
|
1721
|
+
export function formatSetupPolicyRefusal(category, uncertain = false) {
|
|
1722
|
+
if (uncertain || category === "uncertain") {
|
|
1723
|
+
return { reason: "the policy write could not be confirmed by reading it back", fix: UNCERTAIN_POLICY_FIX };
|
|
1724
|
+
}
|
|
1725
|
+
switch (category) {
|
|
1726
|
+
case "unavailable":
|
|
1727
|
+
return {
|
|
1728
|
+
reason: "unavailable: the server could not take the policy write right now",
|
|
1729
|
+
fix: "Nothing was written. Try setup once more shortly; if it fails again, check that the Bridge API is reachable.",
|
|
1730
|
+
};
|
|
1731
|
+
case "stale":
|
|
1732
|
+
return {
|
|
1733
|
+
reason: "stale: the policy changed after the preview",
|
|
1734
|
+
fix: "Nothing was written. Rerun setup to review and approve a fresh proposal.",
|
|
1735
|
+
};
|
|
1736
|
+
case "refused":
|
|
1737
|
+
return {
|
|
1738
|
+
reason: "refused: the server did not accept the policy",
|
|
1739
|
+
fix: "Nothing was written. Check that your key is an administrator key for this repository, then rerun setup for a fresh proposal.",
|
|
1740
|
+
};
|
|
1741
|
+
case "unsupported":
|
|
1742
|
+
return {
|
|
1743
|
+
reason: "unsupported: this server cannot take the combined policy",
|
|
1744
|
+
fix: "Nothing was written. Update the Bridge API, then rerun setup; a rerun on this server fails the same way.",
|
|
1745
|
+
};
|
|
1746
|
+
case "malformed":
|
|
1747
|
+
return {
|
|
1748
|
+
reason: "malformed: the server answered in a form this installer cannot verify",
|
|
1749
|
+
fix: "Nothing was confirmed. Read the gate with `epic-implementer doctor`; if it shows the same, ask Bridge support. A plain rerun will not repair it.",
|
|
1750
|
+
};
|
|
1751
|
+
default:
|
|
1752
|
+
// No validated category: the bounded fallback.
|
|
1753
|
+
return {
|
|
1754
|
+
reason: "the policy was refused or changed after the preview",
|
|
1755
|
+
fix: "Rerun setup for a fresh proposal; nothing in the gate was written.",
|
|
1756
|
+
};
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1688
1759
|
const GATE_WRITE_REFUSAL_TEXT = Object.freeze({
|
|
1689
1760
|
"stale-revision": "the stored gate changed since it was read. Re-run to see the current gate.",
|
|
1690
1761
|
unauthorized: "the API key was rejected, or it is not an admin key for this repository.",
|
|
@@ -1986,40 +2057,29 @@ function reportJob(io, job) {
|
|
|
1986
2057
|
io.log(` Qualified — the local gate passed under the executor at revision ${job.revision}.`);
|
|
1987
2058
|
return "qualified";
|
|
1988
2059
|
}
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
return "failed";
|
|
2010
|
-
}
|
|
2011
|
-
io.errorLog(" Failed — a confirmed command did not pass under the executor. The installation itself " +
|
|
2012
|
-
"succeeded, but the local gate stays unqualified, so unattended auto-merge stays closed.");
|
|
2013
|
-
io.errorLog(` Fix the command, then qualify again: ${PRINTED_QUALIFY_GATE_COMMAND}`);
|
|
2014
|
-
if (job.phase === "ran_and_failed" && job.dependency_install_declared === false) {
|
|
2015
|
-
io.errorLog(` ${MISSING_INSTALL_TEXT}`);
|
|
2016
|
-
}
|
|
2017
|
-
return "failed";
|
|
2060
|
+
// BAPI-1698: one shared presentation for every finished, non-qualified job. The
|
|
2061
|
+
// phase is the server's reading of the stored result; per-command statuses are
|
|
2062
|
+
// shown by position only (this path has no command text), and only when the
|
|
2063
|
+
// server's validated list is available.
|
|
2064
|
+
const interrupted = job.job_status !== "succeeded";
|
|
2065
|
+
const presentation = presentTrialResult({
|
|
2066
|
+
phase: job.phase,
|
|
2067
|
+
dependencyInstallDeclared: job.dependency_install_declared,
|
|
2068
|
+
interrupted,
|
|
2069
|
+
commandResults: job.command_results,
|
|
2070
|
+
});
|
|
2071
|
+
const ordinals = (job.command_results ?? []).map((_, index) => `command ${index + 1}`);
|
|
2072
|
+
for (const line of renderTrialReport({
|
|
2073
|
+
presentation,
|
|
2074
|
+
consequence: interrupted
|
|
2075
|
+
? `Job ${job.job_id} recorded nothing. The local gate stays unqualified.`
|
|
2076
|
+
: "The local gate stays unqualified, so unattended auto-merge stays closed.",
|
|
2077
|
+
commands: trialCommandLines({ commands: ordinals, commandResults: job.command_results, interrupted }),
|
|
2078
|
+
})) {
|
|
2079
|
+
io.errorLog(line);
|
|
2018
2080
|
}
|
|
2019
|
-
io.errorLog(`
|
|
2020
|
-
|
|
2021
|
-
io.errorLog(` Qualify again: ${PRINTED_QUALIFY_GATE_COMMAND}`);
|
|
2022
|
-
return "could_not_run";
|
|
2081
|
+
io.errorLog(` Qualify again when ready: ${PRINTED_QUALIFY_GATE_COMMAND}`);
|
|
2082
|
+
return interrupted ? "could_not_run" : "failed";
|
|
2023
2083
|
}
|
|
2024
2084
|
/**
|
|
2025
2085
|
* Enqueue the qualification for `revision` and drain it with the short-lived
|
|
@@ -2117,6 +2177,10 @@ export async function runConductorGateQualification(io, access, gateDeps, input)
|
|
|
2117
2177
|
// before anything else happens, and the request is never repeated automatically.
|
|
2118
2178
|
/** How often a running trial prints one plain progress line. */
|
|
2119
2179
|
export const LEARNED_TRIAL_PROGRESS_INTERVAL_MS = 10_000;
|
|
2180
|
+
/** The display rows for saved commands, named the way the server names a sealed set. */
|
|
2181
|
+
function savedCommandDisplay(commands) {
|
|
2182
|
+
return (commands ?? []).map((command, index) => ({ name: index === 0 ? "tests" : `tests-${index + 1}`, command }));
|
|
2183
|
+
}
|
|
2120
2184
|
/** The commands a profile's local members run, by digest, in order. */
|
|
2121
2185
|
function localDigests(profile) {
|
|
2122
2186
|
return (profile?.local_commands ?? []).map((c) => c.digest).join(",");
|
|
@@ -2135,6 +2199,9 @@ function promotionObserved(read, input) {
|
|
|
2135
2199
|
return false;
|
|
2136
2200
|
if (read.revision <= input.current.revision)
|
|
2137
2201
|
return false;
|
|
2202
|
+
// A saved-command trial may re-qualify the same commands; the new qualified revision is the proof.
|
|
2203
|
+
if (input.expectedGeneration !== undefined)
|
|
2204
|
+
return true;
|
|
2138
2205
|
return localDigests(read.profile) !== localDigests(input.current.profile);
|
|
2139
2206
|
}
|
|
2140
2207
|
async function readGateProfileOrNull(io, access) {
|
|
@@ -2157,6 +2224,7 @@ export async function runLearnedTestCommandTrial(io, access, gateDeps, input) {
|
|
|
2157
2224
|
expectedRevision: input.current.revision,
|
|
2158
2225
|
...(input.candidates !== undefined ? { candidates: input.candidates } : {}),
|
|
2159
2226
|
...(input.ownerCommand !== undefined ? { ownerCommand: input.ownerCommand } : {}),
|
|
2227
|
+
...(input.expectedGeneration !== undefined ? { expectedGeneration: input.expectedGeneration } : {}),
|
|
2160
2228
|
}, io.postJson);
|
|
2161
2229
|
switch (posted.kind) {
|
|
2162
2230
|
case "not_needed":
|
|
@@ -2175,9 +2243,14 @@ export async function runLearnedTestCommandTrial(io, access, gateDeps, input) {
|
|
|
2175
2243
|
// authoritative profile before anything else.
|
|
2176
2244
|
const read = await readGateProfileOrNull(io, access);
|
|
2177
2245
|
if (promotionObserved(read, input)) {
|
|
2178
|
-
return { status: "promoted", source: requestedSource, commands:
|
|
2246
|
+
return { status: "promoted", source: requestedSource, commands: savedCommandDisplay(input.savedCommands), profile: read };
|
|
2179
2247
|
}
|
|
2180
|
-
return {
|
|
2248
|
+
return {
|
|
2249
|
+
status: "uncertain",
|
|
2250
|
+
reason: "request_unclear",
|
|
2251
|
+
profile: read,
|
|
2252
|
+
...(input.savedCommands !== undefined ? { commands: savedCommandDisplay(input.savedCommands) } : {}),
|
|
2253
|
+
};
|
|
2181
2254
|
}
|
|
2182
2255
|
case "qualification_queued":
|
|
2183
2256
|
break;
|
|
@@ -2187,7 +2260,7 @@ export async function runLearnedTestCommandTrial(io, access, gateDeps, input) {
|
|
|
2187
2260
|
const read = await readGateProfileOrNull(io, access);
|
|
2188
2261
|
if (promotionObserved(read, input))
|
|
2189
2262
|
return { status: "promoted", source, commands, profile: read };
|
|
2190
|
-
return { status: "uncertain", reason, profile: read };
|
|
2263
|
+
return { status: "uncertain", reason, profile: read, commands };
|
|
2191
2264
|
};
|
|
2192
2265
|
let job = await readJob(io, access, jobId);
|
|
2193
2266
|
if (job === null)
|
|
@@ -2246,35 +2319,96 @@ export async function runLearnedTestCommandTrial(io, access, gateDeps, input) {
|
|
|
2246
2319
|
const evidence = {
|
|
2247
2320
|
phase: job.phase,
|
|
2248
2321
|
dependencyInstallDeclared: job.dependency_install_declared,
|
|
2322
|
+
commandResults: job.command_results,
|
|
2323
|
+
};
|
|
2324
|
+
const promoted = async (profile) => {
|
|
2325
|
+
const omittedSuites = await omittedTestSuites(gateDeps, commands);
|
|
2326
|
+
return {
|
|
2327
|
+
status: "promoted",
|
|
2328
|
+
source,
|
|
2329
|
+
commands,
|
|
2330
|
+
profile,
|
|
2331
|
+
evidence,
|
|
2332
|
+
...(omittedSuites.length > 0 ? { omittedSuites } : {}),
|
|
2333
|
+
};
|
|
2249
2334
|
};
|
|
2250
2335
|
if (job.qualification_state === "stale" || job.failure === "stale") {
|
|
2251
|
-
return { status: "stale", source, profile: read, evidence };
|
|
2336
|
+
return { status: "stale", source, profile: read, evidence, commands };
|
|
2252
2337
|
}
|
|
2253
2338
|
if (job.job_status === "succeeded" && job.qualification_state === "qualified") {
|
|
2254
2339
|
if (promotionObserved(read, input))
|
|
2255
|
-
return
|
|
2256
|
-
return { status: "uncertain", reason: "result_unreadable", profile: read, evidence };
|
|
2340
|
+
return promoted(read);
|
|
2341
|
+
return { status: "uncertain", reason: "result_unreadable", profile: read, evidence, commands };
|
|
2257
2342
|
}
|
|
2258
2343
|
if (job.job_status === "succeeded" && job.qualification_state === "unqualified") {
|
|
2259
|
-
return { status: "unqualified", source, profile: read, evidence };
|
|
2344
|
+
return { status: "unqualified", source, profile: read, evidence, commands };
|
|
2260
2345
|
}
|
|
2261
2346
|
if (job.job_status === "succeeded") {
|
|
2262
2347
|
// Finished without a verdict: only a promotion the profile shows can settle it.
|
|
2263
2348
|
if (promotionObserved(read, input))
|
|
2264
|
-
return
|
|
2265
|
-
return { status: "uncertain", reason: "result_unreadable", profile: read, evidence };
|
|
2266
|
-
}
|
|
2267
|
-
return { status: "could_not_run", source, profile: read, evidence };
|
|
2268
|
-
}
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
const
|
|
2276
|
-
|
|
2277
|
-
|
|
2349
|
+
return promoted(read);
|
|
2350
|
+
return { status: "uncertain", reason: "result_unreadable", profile: read, evidence, commands };
|
|
2351
|
+
}
|
|
2352
|
+
return { status: "could_not_run", source, profile: read, evidence, commands };
|
|
2353
|
+
}
|
|
2354
|
+
/**
|
|
2355
|
+
* BAPI-1698 — one comparable key per test suite, so `pytest -q`, `python -m
|
|
2356
|
+
* pytest`, and `.venv/bin/pytest` read as the same suite. Informational only.
|
|
2357
|
+
*/
|
|
2358
|
+
export function testSuiteKey(argv) {
|
|
2359
|
+
let tokens = argv.filter((token) => token.length > 0);
|
|
2360
|
+
const base = (token) => token.split("/").pop() ?? token;
|
|
2361
|
+
if (tokens.length === 0)
|
|
2362
|
+
return null;
|
|
2363
|
+
if (base(tokens[0]) === "npx")
|
|
2364
|
+
tokens = tokens.slice(1);
|
|
2365
|
+
else if (["uv", "poetry", "pipenv"].includes(base(tokens[0])) && tokens[1] === "run")
|
|
2366
|
+
tokens = tokens.slice(2);
|
|
2367
|
+
if (tokens.length === 0)
|
|
2368
|
+
return null;
|
|
2369
|
+
const program = base(tokens[0]);
|
|
2370
|
+
if (program === "pytest" || program === "py.test")
|
|
2371
|
+
return "pytest";
|
|
2372
|
+
if (/^python(?:3(?:\.\d+)?)?$/.test(program) && tokens[1] === "-m" && tokens[2] === "pytest")
|
|
2373
|
+
return "pytest";
|
|
2374
|
+
if (["npm", "yarn", "pnpm"].includes(program)) {
|
|
2375
|
+
const script = tokens[1] === "run" || tokens[1] === "run-script" ? tokens[2] : tokens[1];
|
|
2376
|
+
return script === undefined ? null : `package script ${script === "t" ? "test" : script}`;
|
|
2377
|
+
}
|
|
2378
|
+
return tokens.slice(0, 2).map(base).join(" ");
|
|
2379
|
+
}
|
|
2380
|
+
/**
|
|
2381
|
+
* BAPI-1698 — the test suites the repository's own files name (the high-
|
|
2382
|
+
* confidence local candidates) that none of the passing commands appears to run.
|
|
2383
|
+
* Never throws; an unreadable tree means nothing to say. Informational only.
|
|
2384
|
+
*/
|
|
2385
|
+
async function omittedTestSuites(gateDeps, commands) {
|
|
2386
|
+
const fs = gateDeps?.discoveryFs;
|
|
2387
|
+
if (!fs || commands.length === 0)
|
|
2388
|
+
return [];
|
|
2389
|
+
try {
|
|
2390
|
+
const tried = new Set(commands.map((c) => testSuiteKey(c.command.trim().split(/\s+/))).filter((key) => key !== null));
|
|
2391
|
+
const omitted = [];
|
|
2392
|
+
for (const candidate of await discoverLocalTestCandidates(fs)) {
|
|
2393
|
+
if (candidate.confidence !== "high")
|
|
2394
|
+
continue;
|
|
2395
|
+
const key = testSuiteKey(candidate.argv);
|
|
2396
|
+
if (key === null || tried.has(key))
|
|
2397
|
+
continue;
|
|
2398
|
+
const line = sanitizeCommandText(candidate.argv.join(" "));
|
|
2399
|
+
if (!omitted.includes(line))
|
|
2400
|
+
omitted.push(line);
|
|
2401
|
+
}
|
|
2402
|
+
return omitted;
|
|
2403
|
+
}
|
|
2404
|
+
catch {
|
|
2405
|
+
return [];
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
// BAPI-1698 — the wording for every completed phase lives in one place,
|
|
2409
|
+
// `install-bridge-conductor-trial-report.ts`. None of it names an install step,
|
|
2410
|
+
// a path, or any output: the server's phase token selects the text.
|
|
2411
|
+
/** The instruction every successful trial line ends with. */
|
|
2278
2412
|
const CHANGE_TEST_COMMAND_HINT = 'Change it with --test-command "<your command>".';
|
|
2279
2413
|
/**
|
|
2280
2414
|
* Print one trial outcome in plain words. The validated command is named ONLY on
|
|
@@ -2285,47 +2419,72 @@ export function reportLearnedCommandTrial(io, result) {
|
|
|
2285
2419
|
const learned = (source) => source === "owner" ? "you gave it with --test-command" : "it learned from your repository";
|
|
2286
2420
|
switch (result.status) {
|
|
2287
2421
|
case "promoted": {
|
|
2288
|
-
const named = result.commands.map((c) => `\`${c.command
|
|
2422
|
+
const named = result.commands.map((c) => `\`${sanitizeCommandText(c.command)}\``).join(", ");
|
|
2289
2423
|
io.log(named.length > 0
|
|
2290
|
-
? ` Bridge will run ${named} before each merge. It is the command ${learned(result.source)}, and
|
|
2291
|
-
|
|
2292
|
-
: ` Bridge stored a test command ${learned(result.source)}
|
|
2424
|
+
? ` Bridge will run ${named} before each merge. It is the command ${learned(result.source)}, and it ` +
|
|
2425
|
+
`${PASSED_TRIAL_RUN_TEXT}. ${CHANGE_TEST_COMMAND_HINT}`
|
|
2426
|
+
: ` Bridge stored a test command ${learned(result.source)}; it ${PASSED_TRIAL_RUN_TEXT}. ` +
|
|
2293
2427
|
CHANGE_TEST_COMMAND_HINT);
|
|
2428
|
+
// BAPI-1698: informational only. The pass stands; nothing is retried.
|
|
2429
|
+
for (const suite of result.omittedSuites ?? []) {
|
|
2430
|
+
io.log(` Note: your repository also names \`${suite}\`, which the stored command does not appear to run. ` +
|
|
2431
|
+
`If it is part of your test suite, ${CHANGE_TEST_COMMAND_TEXT}.`);
|
|
2432
|
+
}
|
|
2294
2433
|
return;
|
|
2295
2434
|
}
|
|
2296
2435
|
case "not_needed":
|
|
2297
2436
|
io.log(" Bridge already has a test command for this repository, so it did not look for another.");
|
|
2298
2437
|
return;
|
|
2299
2438
|
case "no_command":
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
case "unqualified": {
|
|
2304
|
-
const { phase, dependencyInstallDeclared } = result.evidence ?? { phase: null, dependencyInstallDeclared: null };
|
|
2305
|
-
if (phase === "dependency_preparation_failed") {
|
|
2306
|
-
io.log(` ${DEPENDENCY_INSTALL_FAILED_TEXT} Bridge stored no learned command. ${DEPENDENCY_INSTALL_REPAIR_TEXT}`);
|
|
2439
|
+
// BAPI-1701: a genuine absence is information. It names no command to enter.
|
|
2440
|
+
if (isInformationalNoCommandReason(result.reason)) {
|
|
2441
|
+
io.log(` ${NO_COMMAND_INFORMATION_TEXT}`);
|
|
2307
2442
|
return;
|
|
2308
2443
|
}
|
|
2309
|
-
if (
|
|
2310
|
-
io.log(` ${
|
|
2444
|
+
if (result.reason === "generation_superseded") {
|
|
2445
|
+
io.log(` Bridge found no test command to try (${NO_COMMAND_TEXT[result.reason]}). It stored none. ` +
|
|
2446
|
+
"Run setup again to review and approve a fresh proposal.");
|
|
2311
2447
|
return;
|
|
2312
2448
|
}
|
|
2313
|
-
if (
|
|
2314
|
-
io.log(` ${
|
|
2449
|
+
if (result.reason !== "llm_unavailable" && result.reason !== "llm_output_invalid") {
|
|
2450
|
+
io.log(` Bridge found a test command but could not use it (${NO_COMMAND_TEXT[result.reason]}). It stored none. ` +
|
|
2451
|
+
`${CANDIDATE_REJECTION_FIX[result.reason]}`);
|
|
2315
2452
|
return;
|
|
2316
2453
|
}
|
|
2317
|
-
io.log(
|
|
2318
|
-
"
|
|
2319
|
-
|
|
2320
|
-
|
|
2454
|
+
io.log(` Bridge found no test command to try (${NO_COMMAND_TEXT[result.reason]}). It stored none. ` +
|
|
2455
|
+
"Give one with --test-command \"<your command>\" and Bridge will check it by running it once.");
|
|
2456
|
+
return;
|
|
2457
|
+
case "unqualified": {
|
|
2458
|
+
// BAPI-1698: headline, consequence, the commands (with their own statuses
|
|
2459
|
+
// only when the server's facts line up one for one), then ONE remedy.
|
|
2460
|
+
const evidence = result.evidence ?? { phase: null, dependencyInstallDeclared: null, commandResults: null };
|
|
2461
|
+
for (const line of renderTrialReport({
|
|
2462
|
+
presentation: presentTrialResult({
|
|
2463
|
+
phase: evidence.phase,
|
|
2464
|
+
dependencyInstallDeclared: evidence.dependencyInstallDeclared,
|
|
2465
|
+
commandResults: evidence.commandResults ?? null,
|
|
2466
|
+
}),
|
|
2467
|
+
consequence: "Bridge stored no test command.",
|
|
2468
|
+
commands: trialCommandLines({
|
|
2469
|
+
commands: (result.commands ?? []).map((c) => c.command),
|
|
2470
|
+
commandResults: evidence.commandResults ?? null,
|
|
2471
|
+
}),
|
|
2472
|
+
})) {
|
|
2473
|
+
io.log(line);
|
|
2474
|
+
}
|
|
2321
2475
|
return;
|
|
2322
2476
|
}
|
|
2323
2477
|
case "stale":
|
|
2324
2478
|
io.log(" The gate changed while the test command was being checked, so Bridge stored none. Run setup again.");
|
|
2325
2479
|
return;
|
|
2326
2480
|
case "could_not_run":
|
|
2327
|
-
|
|
2328
|
-
|
|
2481
|
+
for (const line of renderTrialReport({
|
|
2482
|
+
presentation: presentTrialResult({ phase: null, dependencyInstallDeclared: null, interrupted: true }),
|
|
2483
|
+
consequence: "Bridge stored no test command.",
|
|
2484
|
+
commands: trialCommandLines({ commands: (result.commands ?? []).map((c) => c.command), interrupted: true }),
|
|
2485
|
+
})) {
|
|
2486
|
+
io.log(line);
|
|
2487
|
+
}
|
|
2329
2488
|
return;
|
|
2330
2489
|
case "stale_revision":
|
|
2331
2490
|
io.log(" The gate changed before the test command could be checked, so nothing was started. Run setup again.");
|
|
@@ -2347,6 +2506,23 @@ export function reportLearnedCommandTrial(io, result) {
|
|
|
2347
2506
|
return;
|
|
2348
2507
|
}
|
|
2349
2508
|
}
|
|
2509
|
+
/**
|
|
2510
|
+
* BAPI-1701 — the only two no-command reasons that are information, not a failure:
|
|
2511
|
+
* the repository names no command, or has no learned testing instructions. Every other
|
|
2512
|
+
* reason is a failed extraction, a rejected candidate, or a superseded generation.
|
|
2513
|
+
*/
|
|
2514
|
+
export function isInformationalNoCommandReason(reason) {
|
|
2515
|
+
return reason === "no_candidates" || reason === "no_testing_instructions";
|
|
2516
|
+
}
|
|
2517
|
+
/** BAPI-1701 — what an informational no-command result tells the owner. It says "local", never "all protection". */
|
|
2518
|
+
export const NO_COMMAND_INFORMATION_TEXT = "Bridge found no test command. Epics will run without a local test gate; no command is needed from you.";
|
|
2519
|
+
/** BAPI-1701 — the constraint to correct for each rejected candidate. Closed over the rejection reasons. */
|
|
2520
|
+
export const CANDIDATE_REJECTION_FIX = Object.freeze({
|
|
2521
|
+
working_directory_unsupported: "Give a command that runs from the repository root; a gate cannot run from a subdirectory.",
|
|
2522
|
+
not_plain_argv: "Replace the shell syntax with a plain program and its arguments.",
|
|
2523
|
+
command_not_allowed: "Give a command Bridge allows; the one it found is not on the allowed list.",
|
|
2524
|
+
invalid_command: "Give a valid command: a plain program and its arguments.",
|
|
2525
|
+
});
|
|
2350
2526
|
const NO_COMMAND_TEXT = Object.freeze({
|
|
2351
2527
|
no_testing_instructions: "the repository has no learned testing instructions",
|
|
2352
2528
|
llm_unavailable: "the server could not read them just now",
|
|
@@ -2356,6 +2532,7 @@ const NO_COMMAND_TEXT = Object.freeze({
|
|
|
2356
2532
|
not_plain_argv: "the command is not a plain program and arguments",
|
|
2357
2533
|
command_not_allowed: "the command is not allowed",
|
|
2358
2534
|
invalid_command: "the command is not valid",
|
|
2535
|
+
generation_superseded: "the saved commands changed after you approved them",
|
|
2359
2536
|
});
|
|
2360
2537
|
const UNCERTAIN_TEXT = Object.freeze({
|
|
2361
2538
|
request_unclear: "the request did not answer clearly",
|
|
@@ -21,7 +21,7 @@ import { formatReadinessAssessment } from './conductor/readiness-prerequisites.j
|
|
|
21
21
|
* row for the same fact. An unmet blocking item is counted once.
|
|
22
22
|
*/
|
|
23
23
|
import { READINESS_PREREQUISITE_BY_ID, READINESS_PREREQUISITE_CATALOG, } from "./readiness-prerequisites.generated.js";
|
|
24
|
-
import { READINESS_PREREQUISITE_FIXES, assessmentRemedyQuestion, formatProfilePolicyRemedy, resolveReadinessRemedy, PRE_SETUP_READINESS_REMEDY, } from "./printed-remedy-commands.js";
|
|
24
|
+
import { READINESS_PREREQUISITE_FIXES, assessmentRemedyQuestion, formatProfilePolicyRemedy, indexedWorkflowsDisplayRemedy, resolveReadinessRemedy, PRE_SETUP_READINESS_REMEDY, } from "./printed-remedy-commands.js";
|
|
25
25
|
import { COMMAND_DRIFT_DIVERGENT_REMEDIATION, COMMAND_DRIFT_UNASSESSABLE_REMEDIATION } from "./conductor/command-drift.js";
|
|
26
26
|
import { shellQuote } from "./epic-launch-profile.js";
|
|
27
27
|
import { decodeCanonicalProvenance } from "./conductor/bridge-api-client.js";
|
|
@@ -136,7 +136,7 @@ const ACTIVE_INDEX_STATES = ["in_progress", "queued_by_setup", "recovery_pending
|
|
|
136
136
|
function needsSetupFirst(setupPresent, id, scope) {
|
|
137
137
|
return setupPresent === false && (scope === "self_host" || id === "server.service-availability");
|
|
138
138
|
}
|
|
139
|
-
export function fromServerPrerequisite(p, isProduction, setupPresent) {
|
|
139
|
+
export function fromServerPrerequisite(p, isProduction, setupPresent, report) {
|
|
140
140
|
if (p.check_status === "met" || p.check_status === "not_applicable") {
|
|
141
141
|
return { id: p.id, label: p.label, state: "met", blocking: p.impact === "blocking", remedy: null };
|
|
142
142
|
}
|
|
@@ -158,7 +158,7 @@ export function fromServerPrerequisite(p, isProduction, setupPresent) {
|
|
|
158
158
|
label: p.label,
|
|
159
159
|
state: p.check_status === "unknown" ? "unknown" : "needs_action",
|
|
160
160
|
blocking,
|
|
161
|
-
remedy: preSetup ? PRE_SETUP_READINESS_REMEDY : p.fix.length > 0 ? p
|
|
161
|
+
remedy: preSetup ? PRE_SETUP_READINESS_REMEDY : p.fix.length > 0 ? indexedWorkflowsDisplayRemedy(p, report) : READINESS_PREREQUISITE_FIXES.retry,
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
164
|
function upsert(items, item) {
|
|
@@ -193,7 +193,7 @@ export function projectSetupItems(evidence) {
|
|
|
193
193
|
}
|
|
194
194
|
else if (readiness.prerequisites !== undefined) {
|
|
195
195
|
for (const p of readiness.prerequisites) {
|
|
196
|
-
const item = fromServerPrerequisite(p, isProduction, readiness.supervisor?.setup_present);
|
|
196
|
+
const item = fromServerPrerequisite(p, isProduction, readiness.supervisor?.setup_present, readiness);
|
|
197
197
|
if (item !== null)
|
|
198
198
|
items.push(item);
|
|
199
199
|
}
|