@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
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { writeJsonDocument, flushProcessStdout } from './conductor/json-output.js';
|
|
2
2
|
import { INSTALL_ASSESSMENT_SCHEMA_VERSION, } from './install-bridge-conductor-contracts.js';
|
|
3
|
-
import { buildInstallAssessment, buildInstallChoices, recommendEpicServer, buildInstallVerdict, buildProposalPresentation, classifyMergeTestProtection, dependencyInstallDetails, epicBranchCiIncludeRestsOnSetupPr, epicBranchCiStateText, indexDisplayStatus, } from './install-bridge-conductor-assessment.js';
|
|
3
|
+
import { buildInstallAssessment, buildInstallChoices, recommendEpicServer, buildInstallVerdict, buildProposalPresentation, classifyMergeTestProtection, dependencyInstallDetails, epicBranchCiIncludeRestsOnSetupPr, epicBranchCiStateText, indexDisplayStatus, savedStatusLabel, } from './install-bridge-conductor-assessment.js';
|
|
4
|
+
import { sanitizeCommandText } from './install-bridge-conductor-trial-report.js';
|
|
5
|
+
import { readConductorSavedTestCommands, saveConductorSavedTestCommands, } from './conductor/bridge-api-client.js';
|
|
4
6
|
import { GITHUB_ACTIONS_TRIGGER_ADAPTER, recognizeAppliedEdit, selectTriggerEdit, sha256Hex, } from './ci-trigger-adapters.js';
|
|
5
7
|
import { detectCiSystems } from './ci-system-detection.js';
|
|
8
|
+
import { presentTrialResult } from './install-bridge-conductor-trial-report.js';
|
|
6
9
|
import { describeDeclinedCiChange, describeProposedCiChange, describeUnopenedSetupCredit } from './epic-branch-ci-summary.js';
|
|
7
10
|
import { buildCompactApply, buildCompactAssessment, buildCompactProposal } from './install-bridge-conductor-compact.js';
|
|
8
11
|
import { decisionFor, normalizeInstallAnswers, parseAnswerValue, parseAnswersText, readAnswersSource, } from './install-bridge-conductor-answers.js';
|
|
@@ -130,7 +133,7 @@ import { withSetupProgress } from "./setup-progress.js";
|
|
|
130
133
|
* stop; everything else it adds only warns.
|
|
131
134
|
*/
|
|
132
135
|
import { PRINTED_INSTALL_COMMAND, PRINTED_QUALIFY_GATE_COMMAND } from "./printed-remedy-commands.js";
|
|
133
|
-
import { collectEpicBranchCi, confirmRequestFor, planDeclarations, resolveEffectiveDependencyInstall, describeGateRestoration, desiredFromStored, emptyConductorGateFlags, hasExplicitGateInput, parseLocalCommandFlag, parseEpicBranchCiDecisionFlag, parseMigrationGuardFlag, planManagedProviderGate, reportLearnedCommandTrial, describePolicyChanges, resolveConductorGate, runEpicBranchCiInspection, runGateConsequenceSummary, runClearConductorGate, mapExemptionOutcomeToWriteResult, runConductorGateQualification, runLearnedTestCommandTrial, runQualifyConductorGate, validateConductorGateFlags, } from "./install-bridge-conductor-gate.js";
|
|
136
|
+
import { collectEpicBranchCi, confirmRequestFor, planDeclarations, resolveEffectiveDependencyInstall, describeGateRestoration, desiredFromStored, emptyConductorGateFlags, hasExplicitGateInput, parseLocalCommandFlag, parseEpicBranchCiDecisionFlag, parseMigrationGuardFlag, planManagedProviderGate, reportLearnedCommandTrial, isInformationalNoCommandReason, NO_COMMAND_INFORMATION_TEXT, CANDIDATE_REJECTION_FIX, formatSetupPolicyRefusal, describePolicyChanges, resolveConductorGate, runEpicBranchCiInspection, runGateConsequenceSummary, runClearConductorGate, mapExemptionOutcomeToWriteResult, runConductorGateQualification, runLearnedTestCommandTrial, runQualifyConductorGate, validateConductorGateFlags, } from "./install-bridge-conductor-gate.js";
|
|
134
137
|
import { classifyEpicPullRequestTrigger, readDefaultBranchRequiredChecksViaGh, readPullRequestBranchFilters, } from "./conductor/epic-branch-ci-inspection.js";
|
|
135
138
|
import { describeGateConsequence } from "./conductor/readiness-sections.js";
|
|
136
139
|
import { fetchConductorReadiness, } from "./conductor/bridge-api-client.js";
|
|
@@ -226,7 +229,7 @@ export function getInstallBridgeConductorUsage() {
|
|
|
226
229
|
" - which indexing branch to use, only when an existing different branch makes",
|
|
227
230
|
" the choice unclear;",
|
|
228
231
|
" - adding Bridge's own GitHub workflow, once, only for a repository with no CI of",
|
|
229
|
-
" its own and a test command Bridge
|
|
232
|
+
" its own and a test command that passed Bridge's trial run (then the setup pull request has",
|
|
230
233
|
" its own consent);",
|
|
231
234
|
" - storing a GitHub merge token on this computer (read with no echo).",
|
|
232
235
|
"Setup never asks for a test command. The destination is displayed without a",
|
|
@@ -267,8 +270,8 @@ export function getInstallBridgeConductorUsage() {
|
|
|
267
270
|
"stored as watched members of the gate. A red watched check stops a merge; a",
|
|
268
271
|
"missing one only warns. A gate you already confirmed is kept as it is.",
|
|
269
272
|
"",
|
|
270
|
-
"Bridge's workflow is optional: for a repository with no CI of its own and a
|
|
271
|
-
"
|
|
273
|
+
"Bridge's workflow is optional: for a repository with no CI of its own and a test",
|
|
274
|
+
"command that passed the trial run, setup offers it once (default no). It runs only for pull requests",
|
|
272
275
|
"into epic/** branches, and its check is added to the gate only after the setup",
|
|
273
276
|
"pull request is open. The pull request is built from a clean copy of your default",
|
|
274
277
|
"branch, so uncommitted or unpushed changes in your folder never block it or enter it.",
|
|
@@ -280,7 +283,7 @@ export function getInstallBridgeConductorUsage() {
|
|
|
280
283
|
"are unchanged.",
|
|
281
284
|
"",
|
|
282
285
|
"Options:",
|
|
283
|
-
" --test-command <command> Offer your own test command for Bridge to
|
|
286
|
+
" --test-command <command> Offer your own test command for Bridge to try once;",
|
|
284
287
|
" it replaces the stored local command only if it passes.",
|
|
285
288
|
" Not combinable with --remove-merge-token or",
|
|
286
289
|
" --clear-gate; may be given once.",
|
|
@@ -302,7 +305,7 @@ export function getInstallBridgeConductorUsage() {
|
|
|
302
305
|
"Explicit gate flags are the complete requested gate. Otherwise a confirmed gate",
|
|
303
306
|
"already stored is used unchanged; otherwise setup decides from facts, with no",
|
|
304
307
|
"question: checks your CI has really reported become watched members, and the",
|
|
305
|
-
"server adds a
|
|
308
|
+
"server adds a local command that passed the trial run. Nothing is stored until you authorize the",
|
|
306
309
|
"combined policy change that setup previews.",
|
|
307
310
|
" --provider-check <name> An exact provider-reported check name (repeatable).",
|
|
308
311
|
" Admission refuses one that has never reported.",
|
|
@@ -3086,9 +3089,9 @@ decision) {
|
|
|
3086
3089
|
try {
|
|
3087
3090
|
preview = await previewConductorSetupPolicy(access, request, deps.postJson);
|
|
3088
3091
|
}
|
|
3089
|
-
catch {
|
|
3092
|
+
catch (error) {
|
|
3090
3093
|
deps.log("Deferred: combined setup policy is unavailable or unsupported. Rerun with a compatible server; ask a bootstrap administrator if this persists.");
|
|
3091
|
-
return { status: "deferred" };
|
|
3094
|
+
return { status: "deferred", ...(error instanceof ConductorSetupPolicyError ? { refusal: error.reason } : {}) };
|
|
3092
3095
|
}
|
|
3093
3096
|
// One plain line per changed setting. The before → after JSON is a diagnostic, shown only under --verbose.
|
|
3094
3097
|
const logEffects = (effects) => {
|
|
@@ -3165,7 +3168,7 @@ decision) {
|
|
|
3165
3168
|
}
|
|
3166
3169
|
if (error instanceof ConductorSetupPolicyError && ["refused", "stale", "unsupported"].includes(error.reason)) {
|
|
3167
3170
|
deps.log("Deferred: policy was refused or changed. Rerun for a fresh preview.");
|
|
3168
|
-
return { status: "deferred" };
|
|
3171
|
+
return { status: "deferred", refusal: error.reason };
|
|
3169
3172
|
}
|
|
3170
3173
|
}
|
|
3171
3174
|
try {
|
|
@@ -3173,14 +3176,14 @@ decision) {
|
|
|
3173
3176
|
}
|
|
3174
3177
|
catch {
|
|
3175
3178
|
deps.log("Unknown—verify before retrying: policy apply could not be confirmed. Ask the bootstrap administrator.");
|
|
3176
|
-
return { status: "unknown" };
|
|
3179
|
+
return { status: "unknown", refusal: "uncertain" };
|
|
3177
3180
|
}
|
|
3178
3181
|
if (uncertain
|
|
3179
3182
|
|| (appliedState !== undefined && !policyMatches(appliedState, current.state))
|
|
3180
3183
|
|| !policyMatches(preview.after, current.policy) || current.state.generation <= preview.state.generation
|
|
3181
3184
|
|| current.state.revision < preview.state.revision) {
|
|
3182
3185
|
deps.log("Unknown—verify before retrying: coherent read-back does not confirm the intended complete policy.");
|
|
3183
|
-
return { status: "unknown" };
|
|
3186
|
+
return { status: "unknown", refusal: "uncertain" };
|
|
3184
3187
|
}
|
|
3185
3188
|
if (applyWithoutQuestion) {
|
|
3186
3189
|
deps.log("Policy applied (confirmed by reading it back).");
|
|
@@ -3777,6 +3780,38 @@ async function learnedCommandHints(setup, access) {
|
|
|
3777
3780
|
: candidate.provenance,
|
|
3778
3781
|
}));
|
|
3779
3782
|
}
|
|
3783
|
+
/**
|
|
3784
|
+
* BAPI-1699 — the saved selection as assessment evidence, or `undefined`. Never throws:
|
|
3785
|
+
* an older server, a transport failure, an unreadable body, or a fake transport that
|
|
3786
|
+
* does not know the URL all mean "no saved evidence", and the plan continues unchanged.
|
|
3787
|
+
*/
|
|
3788
|
+
async function readSavedTestCommandsEvidence(deps, access) {
|
|
3789
|
+
try {
|
|
3790
|
+
const read = await readConductorSavedTestCommands(access, deps.fetchJson);
|
|
3791
|
+
if (read.kind !== "saved")
|
|
3792
|
+
return undefined;
|
|
3793
|
+
return {
|
|
3794
|
+
commands: read.record.commands,
|
|
3795
|
+
generation: read.record.generation,
|
|
3796
|
+
trialState: read.trialState,
|
|
3797
|
+
commandsInForce: read.commandsInForce,
|
|
3798
|
+
setBy: read.record.set_by,
|
|
3799
|
+
};
|
|
3800
|
+
}
|
|
3801
|
+
catch {
|
|
3802
|
+
return undefined;
|
|
3803
|
+
}
|
|
3804
|
+
}
|
|
3805
|
+
/**
|
|
3806
|
+
* BAPI-1699 — whether the saved commands are, in order, the commands the stored gate already
|
|
3807
|
+
* runs. The comparison splits each saved line on whitespace; a quoted command that does not
|
|
3808
|
+
* split to the stored argv counts as different, which is the safe direction (it is offered as
|
|
3809
|
+
* a pending selection, never silently skipped).
|
|
3810
|
+
*/
|
|
3811
|
+
export function savedCommandsEqualStoredGate(saved, stored) {
|
|
3812
|
+
return (saved.length === stored.length &&
|
|
3813
|
+
stored.every((command, index) => JSON.stringify(command.argv) === JSON.stringify(saved[index].trim().split(/\s+/))));
|
|
3814
|
+
}
|
|
3780
3815
|
/**
|
|
3781
3816
|
* BAPI-1677 — whether a test trial can be offered. The candidates are the ones the
|
|
3782
3817
|
* client can see: file detection first, then the repository's local commands, in
|
|
@@ -3785,6 +3820,17 @@ async function learnedCommandHints(setup, access) {
|
|
|
3785
3820
|
*/
|
|
3786
3821
|
async function resolveTestCommandTrial(deps, setup, access, gatePlan, storedCommand) {
|
|
3787
3822
|
const none = { eligible: false, candidates: [] };
|
|
3823
|
+
// BAPI-1699: one read of the saved field. A saved selection wins over every discovery
|
|
3824
|
+
// below, even when a local gate is already stored (a pending replacement is still offered).
|
|
3825
|
+
// Unsupported, failed, or unreadable reads are no evidence and change nothing else.
|
|
3826
|
+
const saved = await readSavedTestCommandsEvidence(deps, access);
|
|
3827
|
+
if (saved !== undefined && saved.trialState === "passed")
|
|
3828
|
+
return { eligible: false, candidates: [], saved };
|
|
3829
|
+
// Saved commands that already ARE the stored gate's local commands are not a replacement. An
|
|
3830
|
+
// unqualified stored gate keeps its own qualification flow, exactly as before saving existed.
|
|
3831
|
+
if (saved !== undefined && !savedCommandsEqualStoredGate(saved.commands, gatePlan.current.profile?.local_commands ?? [])) {
|
|
3832
|
+
return { eligible: true, candidates: saved.commands.map((command) => ({ command, source: "saved commands" })), saved };
|
|
3833
|
+
}
|
|
3788
3834
|
const inferred = gatePlan.inferred;
|
|
3789
3835
|
const storedGateRetry = inferred === undefined && gatePlan.origin === "stored" && gatePlan.current.confirmed &&
|
|
3790
3836
|
storedCommand === null && (gatePlan.current.profile?.local_commands.length ?? 0) === 0;
|
|
@@ -3811,6 +3857,94 @@ async function resolveTestCommandTrial(deps, setup, access, gatePlan, storedComm
|
|
|
3811
3857
|
}
|
|
3812
3858
|
return { eligible: candidates.length > 0, candidates };
|
|
3813
3859
|
}
|
|
3860
|
+
/** Read the stored gate once for a trial; `null` (already reported) when it cannot be read. */
|
|
3861
|
+
async function readGateForTrial(deps, access, policyResult) {
|
|
3862
|
+
let current;
|
|
3863
|
+
try {
|
|
3864
|
+
current = await fetchConductorGateProfile(access, deps.fetchJson);
|
|
3865
|
+
}
|
|
3866
|
+
catch {
|
|
3867
|
+
deps.log(" skipped — the stored gate could not be read, so nothing was started.");
|
|
3868
|
+
return null;
|
|
3869
|
+
}
|
|
3870
|
+
if ((policyResult?.status === "deferred" || policyResult?.status === "unknown") && !current.confirmed) {
|
|
3871
|
+
deps.log(" skipped — the gate and defaults were not stored, so there is no stored gate for a tested command to attach to.");
|
|
3872
|
+
return null;
|
|
3873
|
+
}
|
|
3874
|
+
return current;
|
|
3875
|
+
}
|
|
3876
|
+
/**
|
|
3877
|
+
* BAPI-1699 — give exactly the saved commands (one generation) their trial run through
|
|
3878
|
+
* the existing POST and executor path. Nothing here writes a gate or saves a command;
|
|
3879
|
+
* the server promotes only a passing trial of the current generation, and a replacement
|
|
3880
|
+
* leaves the previously qualified guard in force until it does.
|
|
3881
|
+
*/
|
|
3882
|
+
async function runSavedTrial(deps, access, baseUrl, state, policyResult, commands, generation) {
|
|
3883
|
+
deps.log("");
|
|
3884
|
+
deps.log("Test command");
|
|
3885
|
+
const current = await readGateForTrial(deps, access, policyResult);
|
|
3886
|
+
if (current === null)
|
|
3887
|
+
return;
|
|
3888
|
+
const io = gateIoFor(deps);
|
|
3889
|
+
const trialGateDeps = deps.gate !== undefined && deps.progressTimer !== undefined && deps.gate.progressTimer === undefined
|
|
3890
|
+
? { ...deps.gate, progressTimer: deps.progressTimer }
|
|
3891
|
+
: deps.gate;
|
|
3892
|
+
const result = await runLearnedTestCommandTrial(io, access, trialGateDeps, {
|
|
3893
|
+
baseUrl,
|
|
3894
|
+
current,
|
|
3895
|
+
expectedGeneration: generation,
|
|
3896
|
+
savedCommands: commands,
|
|
3897
|
+
});
|
|
3898
|
+
reportLearnedCommandTrial(io, result);
|
|
3899
|
+
if (result.status !== "promoted" && (current.profile?.local_commands.length ?? 0) > 0) {
|
|
3900
|
+
deps.log(" The guard you had before stays in force until the saved commands pass the trial run.");
|
|
3901
|
+
}
|
|
3902
|
+
state.trial = result;
|
|
3903
|
+
if (result.status === "uncertain")
|
|
3904
|
+
state.commandUncertain = true;
|
|
3905
|
+
if (result.status === "promoted")
|
|
3906
|
+
state.promotedCommands = result.commands;
|
|
3907
|
+
}
|
|
3908
|
+
/**
|
|
3909
|
+
* BAPI-1699 — save an approved `{"commands": [...]}` answer through the config field, then
|
|
3910
|
+
* try the generation the save returned. Returns `single_fallback` only when an older server
|
|
3911
|
+
* refused the field (400 or 404) and exactly one command was approved: the caller then uses
|
|
3912
|
+
* today's owner-command request. Anything else is reported here and the phase ends.
|
|
3913
|
+
*/
|
|
3914
|
+
async function saveApprovedCommands(deps, access, baseUrl, state, gatePlan, policyResult, commands) {
|
|
3915
|
+
deps.log("");
|
|
3916
|
+
deps.log("Test command");
|
|
3917
|
+
const io = gateIoFor(deps);
|
|
3918
|
+
const write = await saveConductorSavedTestCommands(access, commands, io.postJson);
|
|
3919
|
+
switch (write.kind) {
|
|
3920
|
+
case "saved": {
|
|
3921
|
+
deps.log(` Saved ${commands.length} test command${commands.length === 1 ? "" : "s"}: ` +
|
|
3922
|
+
`${commands.map((c) => `\`${sanitizeCommandText(c)}\``).join(", ")} (${savedStatusLabel(write.trialState)}). ` +
|
|
3923
|
+
"Saving does not put them in force: they are relied on only after they pass the trial run.");
|
|
3924
|
+
await runSavedTrial(deps, access, baseUrl, state, policyResult, commands, write.record.generation);
|
|
3925
|
+
return "done";
|
|
3926
|
+
}
|
|
3927
|
+
case "unsupported":
|
|
3928
|
+
if (commands.length === 1)
|
|
3929
|
+
return "single_fallback";
|
|
3930
|
+
deps.log(" This Bridge server cannot save several test commands yet, so none were saved or tried. " +
|
|
3931
|
+
"Update the Bridge API and run setup again.");
|
|
3932
|
+
state.trial = { status: "unsupported" };
|
|
3933
|
+
return "done";
|
|
3934
|
+
case "refused":
|
|
3935
|
+
deps.log(write.reason === "unauthorized"
|
|
3936
|
+
? " This key cannot save test commands (an administrator key is needed), so Bridge skipped them."
|
|
3937
|
+
: " Bridge's server refused the test commands, so none were saved or tried.");
|
|
3938
|
+
state.trial = { status: "refused", reason: write.reason };
|
|
3939
|
+
return "done";
|
|
3940
|
+
case "uncertain":
|
|
3941
|
+
deps.log(" Bridge cannot tell whether the test commands were saved. It will not try again on its own. " +
|
|
3942
|
+
"Run setup again to read what the server holds.");
|
|
3943
|
+
state.commandUncertain = true;
|
|
3944
|
+
state.trial = { status: "uncertain", reason: "request_unclear", profile: null };
|
|
3945
|
+
return "done";
|
|
3946
|
+
}
|
|
3947
|
+
}
|
|
3814
3948
|
/**
|
|
3815
3949
|
* Ask the server for the learned (or the owner's) test command and prove it.
|
|
3816
3950
|
*
|
|
@@ -3830,7 +3964,26 @@ async function runTestCommandPhase(deps, options, setup, access, baseUrl, state,
|
|
|
3830
3964
|
answer) {
|
|
3831
3965
|
if (answer !== undefined && (answer.decision === "skip" || answer.decision === "keep"))
|
|
3832
3966
|
return;
|
|
3833
|
-
|
|
3967
|
+
// BAPI-1699: an approved `commands` answer is saved once through the config field, and
|
|
3968
|
+
// only the generation that save returned is tried. An older server falls back to today's
|
|
3969
|
+
// single owner command; several commands are never cut down to the first.
|
|
3970
|
+
let commandsAnswer = answer?.decision === "commands" ? answer.commands : undefined;
|
|
3971
|
+
let fallbackOwnerCommand;
|
|
3972
|
+
if (commandsAnswer !== undefined) {
|
|
3973
|
+
const saved = await saveApprovedCommands(deps, access, baseUrl, state, gatePlan, policyResult, commandsAnswer);
|
|
3974
|
+
if (saved !== "single_fallback")
|
|
3975
|
+
return;
|
|
3976
|
+
fallbackOwnerCommand = commandsAnswer[0];
|
|
3977
|
+
commandsAnswer = undefined;
|
|
3978
|
+
}
|
|
3979
|
+
const ownerCommand = fallbackOwnerCommand ?? (answer?.decision === "command" ? answer.command : options.testCommand);
|
|
3980
|
+
// BAPI-1699: pending saved commands are tried exactly as assessed: no model, no candidates,
|
|
3981
|
+
// no owner command, and no PUT. The request is bound to the assessed generation.
|
|
3982
|
+
const pendingSaved = gatePlan?.testCommandTrial?.saved;
|
|
3983
|
+
if (ownerCommand === undefined && pendingSaved !== undefined && pendingSaved.trialState !== "passed") {
|
|
3984
|
+
await runSavedTrial(deps, access, baseUrl, state, policyResult, pendingSaved.commands, pendingSaved.generation);
|
|
3985
|
+
return;
|
|
3986
|
+
}
|
|
3834
3987
|
const automatic = ownerCommand === undefined && gatePlan?.testCommandTrial?.eligible === true;
|
|
3835
3988
|
if (ownerCommand === undefined && !automatic)
|
|
3836
3989
|
return;
|
|
@@ -3847,7 +4000,7 @@ answer) {
|
|
|
3847
4000
|
// A policy change the owner deferred only holds the trial back when it WAS the gate the
|
|
3848
4001
|
// command attaches to; an unrelated deferral never stops a confirmed gate's command proof.
|
|
3849
4002
|
if ((policyResult?.status === "deferred" || policyResult?.status === "unknown") && !current.confirmed) {
|
|
3850
|
-
deps.log(" skipped — the gate and defaults were not stored, so there is no stored gate
|
|
4003
|
+
deps.log(" skipped — the gate and defaults were not stored, so there is no stored gate for a tested command to attach to.");
|
|
3851
4004
|
return;
|
|
3852
4005
|
}
|
|
3853
4006
|
const candidates = automatic ? gatePlan?.testCommandTrial?.candidates : undefined;
|
|
@@ -3902,12 +4055,16 @@ function settleCiPlan(deps, state, gatePlan) {
|
|
|
3902
4055
|
deps.log("");
|
|
3903
4056
|
// BAPI-1654: "no CI" is said only when no CI files exist. No reported checks is not no CI.
|
|
3904
4057
|
const systems = state.ciSystems ?? [];
|
|
4058
|
+
// BAPI-1701: a test command that was never found did not "fail a trial run"; say which it was.
|
|
4059
|
+
const noCommandFound = state.trial?.status === "no_command" && isInformationalNoCommandReason(state.trial.reason);
|
|
4060
|
+
const commandFact = noCommandFound ? "Bridge found no test command" : "no test command passed the trial run";
|
|
4061
|
+
const gateWord = noCommandFound ? "local test gate" : "test gate";
|
|
3905
4062
|
deps.log(systems.length > 0
|
|
3906
4063
|
? `Bridge found CI configuration (${[...new Set(systems.map((s) => s.name))].join(", ")}) but no checks have ` +
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
:
|
|
3910
|
-
|
|
4064
|
+
`reported from it yet, and ${commandFact}. Child pull requests will merge into the epic ` +
|
|
4065
|
+
`branch without a ${gateWord}. You review everything in the final pull request.`
|
|
4066
|
+
: `Bridge found no CI and ${noCommandFound ? "no test command" : commandFact}. Child pull requests will merge into the epic ` +
|
|
4067
|
+
`branch without a ${gateWord}. You review everything in the final pull request.`);
|
|
3911
4068
|
}
|
|
3912
4069
|
}
|
|
3913
4070
|
// ---------------------------------------------------------------------------
|
|
@@ -3933,7 +4090,7 @@ async function offerManagedWorkflow(deps) {
|
|
|
3933
4090
|
recommended: "no",
|
|
3934
4091
|
recordingFlag: "no flag records this choice; rerun setup in an interactive terminal to be asked again.",
|
|
3935
4092
|
evidence: [
|
|
3936
|
-
"Bridge already runs your
|
|
4093
|
+
"Bridge already runs your test command, which passed the trial run, before each merge, so the gate works without it.",
|
|
3937
4094
|
"The workflow runs the same command on GitHub, only for pull requests into epic branches.",
|
|
3938
4095
|
],
|
|
3939
4096
|
consequences: [
|
|
@@ -4188,6 +4345,10 @@ function renderDryRunCiPlan(deps, options, gatePlan) {
|
|
|
4188
4345
|
deps.log(" Test command: a real run offers your --test-command to Bridge's server and proves it by running it once on " +
|
|
4189
4346
|
"this computer. Dry run requested nothing and started nothing.");
|
|
4190
4347
|
}
|
|
4348
|
+
else if (gatePlan?.testCommandTrial?.saved !== undefined) {
|
|
4349
|
+
deps.log(" Test command: a real run gives the saved test commands a trial run in a clean checkout and relies on them " +
|
|
4350
|
+
"only once they passed the trial run. The model is not consulted. Dry run requested nothing and started nothing.");
|
|
4351
|
+
}
|
|
4191
4352
|
else if (gatePlan?.testCommandTrial?.eligible === true) {
|
|
4192
4353
|
deps.log(" Test command: a real run asks Bridge's server to learn it from this repository and proves it by running it " +
|
|
4193
4354
|
"once on this computer, and nobody is asked for it. Dry run requested nothing and started nothing.");
|
|
@@ -4199,7 +4360,7 @@ function renderDryRunCiPlan(deps, options, gatePlan) {
|
|
|
4199
4360
|
"is added only if the command passes."
|
|
4200
4361
|
: " CI plan: no CI reported. A local test gate is stored only if the command passes; otherwise the gate has " +
|
|
4201
4362
|
"no members.");
|
|
4202
|
-
deps.log(" Bridge's workflow: offered once, only for a
|
|
4363
|
+
deps.log(" Bridge's workflow: offered once, only for a local plan whose command passed the trial run, and only added if you say yes and the setup " +
|
|
4203
4364
|
"pull request opens. Dry run asked nothing and opened nothing.");
|
|
4204
4365
|
}
|
|
4205
4366
|
}
|
|
@@ -4480,6 +4641,7 @@ async function collectDecisionEvidence(input) {
|
|
|
4480
4641
|
trialEligible,
|
|
4481
4642
|
candidate: gatePlan?.testCommandTrial?.candidates[0]?.command ?? null,
|
|
4482
4643
|
ownerCommandSupplied: options.testCommand !== undefined,
|
|
4644
|
+
...(gatePlan?.testCommandTrial?.saved !== undefined ? { saved: gatePlan.testCommandTrial.saved } : {}),
|
|
4483
4645
|
},
|
|
4484
4646
|
setupPr: {
|
|
4485
4647
|
applicable: setupPrOffersWorkflow(input),
|
|
@@ -4656,8 +4818,44 @@ function settledGateResults(proposal) {
|
|
|
4656
4818
|
.filter((a) => (a.key === "gate" || DECLARATION_KEYS.includes(a.key)) && a.intent === "write")
|
|
4657
4819
|
.map((a) => ({ key: a.key, status: "unchanged", target: a.effect?.target ?? "repository_gate" }));
|
|
4658
4820
|
}
|
|
4821
|
+
/** BAPI-1701: the runbook section that names the `stored_malformed: true` recovery. */
|
|
4822
|
+
const MALFORMED_GATE_FIX = "Ask Bridge support, or follow the operator runbook's `stored_malformed: true` recovery. " +
|
|
4823
|
+
"The stored value is kept as it is. Rerunning setup will not repair it.";
|
|
4824
|
+
/**
|
|
4825
|
+
* BAPI-1701: a setup that ends with no stored gate says why, with a remedy that can make progress.
|
|
4826
|
+
* Only an inferred plan with no write and no confirmed gate qualifies. A plan with `write: null`
|
|
4827
|
+
* is never read as a stored gate, and a confirmed stored gate never reaches this.
|
|
4828
|
+
*/
|
|
4829
|
+
export function unresolvedGateResult(plan) {
|
|
4830
|
+
const inferred = plan.inferred;
|
|
4831
|
+
if (inferred === undefined || plan.write !== null || plan.current.confirmed)
|
|
4832
|
+
return null;
|
|
4833
|
+
const target = "repository_gate";
|
|
4834
|
+
if (inferred.storedUnreadable) {
|
|
4835
|
+
return { key: "gate", status: "unattempted", target, reason: "the stored gate could not be read, so setup left it alone", fix: MALFORMED_GATE_FIX };
|
|
4836
|
+
}
|
|
4837
|
+
if (inferred.historyUnavailable === true) {
|
|
4838
|
+
return {
|
|
4839
|
+
key: "gate",
|
|
4840
|
+
status: "unattempted",
|
|
4841
|
+
target,
|
|
4842
|
+
reason: "Bridge could not read this repository's CI history, so it stored no gate",
|
|
4843
|
+
fix: "Check GitHub access, sign-in, or the app installation for this repository, then rerun setup.",
|
|
4844
|
+
};
|
|
4845
|
+
}
|
|
4846
|
+
if (inferred.watchedUnsupported) {
|
|
4847
|
+
return {
|
|
4848
|
+
key: "gate",
|
|
4849
|
+
status: "unattempted",
|
|
4850
|
+
target,
|
|
4851
|
+
reason: "this server cannot store the watched CI checks Bridge found, so it stored no gate",
|
|
4852
|
+
fix: "Update the Bridge API, then rerun setup. Nothing was replaced.",
|
|
4853
|
+
};
|
|
4854
|
+
}
|
|
4855
|
+
return null;
|
|
4856
|
+
}
|
|
4659
4857
|
const DECLARATION_KEYS = ["dependency_install", "ci_database", "must_order_paths", "worker_database"];
|
|
4660
|
-
function gateWriteResults(result, proposal, plan,
|
|
4858
|
+
export function gateWriteResults(result, proposal, plan,
|
|
4661
4859
|
/** BAPI-1677 — the install commands read back after the write; `null` when they could not be confirmed. */
|
|
4662
4860
|
installReadBack) {
|
|
4663
4861
|
const readBack = result.current !== undefined ? { revision: result.current.state.revision } : undefined;
|
|
@@ -4670,8 +4868,9 @@ installReadBack) {
|
|
|
4670
4868
|
status,
|
|
4671
4869
|
target: "repository_gate",
|
|
4672
4870
|
...(readBack !== undefined ? { read_back: readBack } : {}),
|
|
4673
|
-
|
|
4674
|
-
...(status === "
|
|
4871
|
+
// BAPI-1701: the validated category picks the reason and the one fix. No category keeps the bounded fallback.
|
|
4872
|
+
...(status === "refused" ? formatSetupPolicyRefusal(result.refusal) : {}),
|
|
4873
|
+
...(status === "uncertain" ? formatSetupPolicyRefusal(result.refusal, true) : {}),
|
|
4675
4874
|
};
|
|
4676
4875
|
if (proposal === null)
|
|
4677
4876
|
return [gate];
|
|
@@ -4696,6 +4895,8 @@ function testCommandAnswer(d) {
|
|
|
4696
4895
|
return undefined;
|
|
4697
4896
|
if (d.kind === "command")
|
|
4698
4897
|
return { decision: "command", command: d.command };
|
|
4898
|
+
if (d.kind === "commands")
|
|
4899
|
+
return { decision: "commands", commands: d.commands };
|
|
4699
4900
|
if (d.kind === "option" && (d.option === "learn" || d.option === "skip" || d.option === "keep"))
|
|
4700
4901
|
return { decision: d.option };
|
|
4701
4902
|
return undefined;
|
|
@@ -4704,6 +4905,13 @@ function testCommandAnswer(d) {
|
|
|
4704
4905
|
export const NO_TEST_COMMAND_REASON = "Bridge found no test command in this repository";
|
|
4705
4906
|
/** BAPI-1657: the plain owner-facing reason when the server could not read the testing instructions. */
|
|
4706
4907
|
export const NO_COMMAND_RETRY_REASON = "the server could not read the repository's testing instructions just now";
|
|
4908
|
+
/** BAPI-1701: why a found candidate was not usable, one plain line per rejection reason. */
|
|
4909
|
+
const NO_COMMAND_REJECTION_REASON = Object.freeze({
|
|
4910
|
+
working_directory_unsupported: "the test command has to run from a subdirectory, which a gate cannot do",
|
|
4911
|
+
not_plain_argv: "the test command is not a plain program and arguments",
|
|
4912
|
+
command_not_allowed: "the test command is not one Bridge allows",
|
|
4913
|
+
invalid_command: "the test command is not valid",
|
|
4914
|
+
});
|
|
4707
4915
|
/**
|
|
4708
4916
|
* BAPI-1657: the launcher text for an owner-run command. The detected launcher wins,
|
|
4709
4917
|
* then the published package. A detection failure falls back to the published package.
|
|
@@ -4718,6 +4926,10 @@ async function detectedLauncherBase(deps, repoName) {
|
|
|
4718
4926
|
}
|
|
4719
4927
|
return (detected ?? NPM_SETUP_LAUNCHER).base;
|
|
4720
4928
|
}
|
|
4929
|
+
/** BAPI-1701: whether this no-command reason's remedy runs `install epic-implementer --test-command`. */
|
|
4930
|
+
function needsLauncherRemedy(reason) {
|
|
4931
|
+
return reason === "working_directory_unsupported" || reason === "not_plain_argv" || reason === "command_not_allowed" || reason === "invalid_command";
|
|
4932
|
+
}
|
|
4721
4933
|
/** The learned check's own entry, carrying child 3's phase. `null` when no trial ran and none was asked for. */
|
|
4722
4934
|
export function trialWriteResult(trial, asked, launcher) {
|
|
4723
4935
|
const target = "repository_gate.local_commands";
|
|
@@ -4725,18 +4937,41 @@ export function trialWriteResult(trial, asked, launcher) {
|
|
|
4725
4937
|
return asked ? { key: "test_command", status: "unchanged", target, reason: "no trial was needed for the stored gate" } : null;
|
|
4726
4938
|
const phase = "evidence" in trial && trial.evidence !== undefined ? trial.evidence.phase : null;
|
|
4727
4939
|
switch (trial.status) {
|
|
4728
|
-
case "no_command":
|
|
4729
|
-
// BAPI-
|
|
4940
|
+
case "no_command": {
|
|
4941
|
+
// BAPI-1701: a genuine absence is information. The local gate is simply not there; setup is not incomplete for it.
|
|
4942
|
+
if (isInformationalNoCommandReason(trial.reason)) {
|
|
4943
|
+
return { key: "test_command", status: "unchanged", target, reason: NO_COMMAND_INFORMATION_TEXT };
|
|
4944
|
+
}
|
|
4730
4945
|
if (trial.reason === "llm_unavailable") {
|
|
4731
4946
|
return { key: "test_command", status: "failed", target, reason: NO_COMMAND_RETRY_REASON, fix: "Rerun setup to try reading the repository's testing instructions again." };
|
|
4732
4947
|
}
|
|
4948
|
+
if (trial.reason === "llm_output_invalid") {
|
|
4949
|
+
return {
|
|
4950
|
+
key: "test_command",
|
|
4951
|
+
status: "failed",
|
|
4952
|
+
target,
|
|
4953
|
+
reason: "the server could not turn the repository's testing instructions into a command",
|
|
4954
|
+
fix: "Rerun setup to try again. If it fails again, update the repository's testing instructions (run /learn-repository) so a command can be read from them.",
|
|
4955
|
+
};
|
|
4956
|
+
}
|
|
4957
|
+
if (trial.reason === "generation_superseded") {
|
|
4958
|
+
return {
|
|
4959
|
+
key: "test_command",
|
|
4960
|
+
status: "failed",
|
|
4961
|
+
target,
|
|
4962
|
+
reason: "the saved test commands changed after you approved them",
|
|
4963
|
+
fix: "Rerun setup to review and approve a fresh proposal; nothing was stored from the old one.",
|
|
4964
|
+
};
|
|
4965
|
+
}
|
|
4966
|
+
// BAPI-1657: the owner-facing remedy names the launcher the owner runs in their own terminal.
|
|
4733
4967
|
return {
|
|
4734
4968
|
key: "test_command",
|
|
4735
4969
|
status: "failed",
|
|
4736
4970
|
target,
|
|
4737
|
-
reason:
|
|
4738
|
-
fix:
|
|
4971
|
+
reason: NO_COMMAND_REJECTION_REASON[trial.reason],
|
|
4972
|
+
fix: `${CANDIDATE_REJECTION_FIX[trial.reason]} In your own terminal, run \`${launcher ?? NPM_SETUP_LAUNCHER.base} install epic-implementer --test-command "<your command>"\` with a command that meets this.`,
|
|
4739
4973
|
};
|
|
4974
|
+
}
|
|
4740
4975
|
case "promoted":
|
|
4741
4976
|
return { key: "test_command", status: "written", target, phase, read_back: { commands: trial.commands.map((c) => c.name), ran: trial.commands.map((c) => c.command) } };
|
|
4742
4977
|
case "not_needed":
|
|
@@ -4745,8 +4980,20 @@ export function trialWriteResult(trial, asked, launcher) {
|
|
|
4745
4980
|
return { key: "test_command", status: "uncertain", target, phase, reason: `the trial's completion is unknown (${trial.reason})`, fix: "Rerun setup to read the trial again; it is not started twice." };
|
|
4746
4981
|
case "unqualified":
|
|
4747
4982
|
case "stale":
|
|
4748
|
-
case "could_not_run":
|
|
4749
|
-
|
|
4983
|
+
case "could_not_run": {
|
|
4984
|
+
// BAPI-1698: the remedy names what to change for THIS result. A deterministic
|
|
4985
|
+
// failure never gets "rerun setup" on its own: an unchanged retry fails again.
|
|
4986
|
+
const presentation = presentTrialResult({
|
|
4987
|
+
phase,
|
|
4988
|
+
dependencyInstallDeclared: trial.evidence?.dependencyInstallDeclared ?? null,
|
|
4989
|
+
interrupted: trial.status === "could_not_run",
|
|
4990
|
+
commandResults: trial.evidence?.commandResults ?? null,
|
|
4991
|
+
});
|
|
4992
|
+
const fix = trial.status === "stale"
|
|
4993
|
+
? "The gate changed while the trial ran; run setup again to try the current gate."
|
|
4994
|
+
: presentation.remedy ?? "Run setup again to read the trial result.";
|
|
4995
|
+
return { key: "test_command", status: "failed", target, phase, reason: `the check did not pass (${trial.status})`, fix };
|
|
4996
|
+
}
|
|
4750
4997
|
default:
|
|
4751
4998
|
return { key: "test_command", status: "failed", target, phase: null, reason: `the trial did not run (${trial.status})`, fix: "Rerun setup; if this persists, run `epic-implementer doctor`." };
|
|
4752
4999
|
}
|
|
@@ -5335,6 +5582,10 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5335
5582
|
if (!gateOpen && approvedDeclarations.length === 0) {
|
|
5336
5583
|
if (proposal === null)
|
|
5337
5584
|
return null;
|
|
5585
|
+
// BAPI-1701: no planned write is not a stored gate. An unresolved plan says why, with its own fix.
|
|
5586
|
+
const unresolved = unresolvedGateResult(gatePlan);
|
|
5587
|
+
if (unresolved !== null)
|
|
5588
|
+
return [unresolved];
|
|
5338
5589
|
return settledGateResults(proposal);
|
|
5339
5590
|
}
|
|
5340
5591
|
const gateAnswer = proposal === null ? undefined : gateOpen ? (optionOf("gate") === "decline" ? "decline" : "approve") : "approve";
|
|
@@ -5368,7 +5619,10 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5368
5619
|
await runTestCommandPhase(deps, options, setup, access, baseUrl, state, gatePlan, policyResult, answer);
|
|
5369
5620
|
settleCiPlan(deps, state, gatePlan);
|
|
5370
5621
|
// BAPI-1657: only the no-command remedy needs the launcher text, so detection runs only for that outcome.
|
|
5371
|
-
|
|
5622
|
+
// BAPI-1701: and only for a rejected candidate. Informational and retry results name no command to enter.
|
|
5623
|
+
const launcher = state.trial?.status === "no_command" && needsLauncherRemedy(state.trial.reason)
|
|
5624
|
+
? await detectedLauncherBase(deps, access.repoName)
|
|
5625
|
+
: undefined;
|
|
5372
5626
|
const trialResult = trialWriteResult(state.trial, proposal !== null && answer !== undefined && answer.decision !== "skip" && answer.decision !== "keep", launcher);
|
|
5373
5627
|
// BAPI-1677: a replay names what the trial proved, so the setup record reads the same. The
|
|
5374
5628
|
// gate's local commands are that proof. The separate stored test command can still be unset.
|
|
@@ -5807,10 +6061,28 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5807
6061
|
const ready = unmet.length === 0 && (proposal === null || applyResult.complete);
|
|
5808
6062
|
deps.log(setupVerdictLine(items));
|
|
5809
6063
|
// Exactly one next step: the first unmet blocking item's remedy, or the start command.
|
|
5810
|
-
|
|
6064
|
+
// BAPI-1701: when nothing blocks readiness but a write did not finish, the next step is that write's own
|
|
6065
|
+
// fix (the gate's first), the same one the structured verdict carries. The generic rerun is only the fallback.
|
|
6066
|
+
const writeNextStep = unmet.length === 0 && !ready && proposal !== null
|
|
6067
|
+
? applyResultNextStep(applyResult)
|
|
6068
|
+
: undefined;
|
|
6069
|
+
deps.log(writeNextStep ??
|
|
6070
|
+
`Next step: ${unmet.length === 0 ? (ready ? "Run drive-epic to start your first epic" : "Rerun setup with the same answers to finish the writes listed above") : setupItemRemedy(unmet[0])}`);
|
|
5811
6071
|
deps.log(ready ? "complete" : "complete-with-manual-steps");
|
|
5812
6072
|
return ready ? conductorInstallDoctorExitCode(finalReport) : 1;
|
|
5813
6073
|
}
|
|
6074
|
+
/**
|
|
6075
|
+
* BAPI-1701: the one next step drawn from the first incomplete write's own fix, the gate's before any other.
|
|
6076
|
+
* `undefined` when no incomplete write carries a fix. Pure text from the result; nothing is parsed.
|
|
6077
|
+
*/
|
|
6078
|
+
export function applyResultNextStep(applyResult) {
|
|
6079
|
+
const incomplete = applyResult.results.filter((r) => r.status === "failed" || r.status === "refused" || r.status === "uncertain" || r.status === "unattempted");
|
|
6080
|
+
const fix = (incomplete.find((r) => r.key === "gate" && r.fix !== undefined) ?? incomplete.find((r) => r.fix !== undefined))?.fix;
|
|
6081
|
+
if (fix === undefined)
|
|
6082
|
+
return undefined;
|
|
6083
|
+
const line = fix.replace(/\s+/g, " ").trim();
|
|
6084
|
+
return line.startsWith("Next step:") ? line : `Next step: ${line}`;
|
|
6085
|
+
}
|
|
5814
6086
|
/** BAPI-1678 — a readable stored gate, with required and watched checks apart. Anything else is unknown. */
|
|
5815
6087
|
function storedGateEvidence(profile) {
|
|
5816
6088
|
if (profile === null || profile === undefined || profile.read_failed || profile.stored_malformed || profile.kind === null)
|