@bridge_gpt/mcp-server 0.2.69 → 0.2.71
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 +140 -292
- package/build/agent-launchers/claude-executor-adapter.js +27 -5
- package/build/agent-registry.js +5 -5
- package/build/agents.generated.js +15 -5
- package/build/artifact-diff.js +110 -0
- package/build/bin-entrypoint.js +36 -0
- package/build/bounded-wait.js +9 -1
- package/build/bridge-permissions.js +36 -9
- package/build/claude-review-workflow-drift.js +3 -3
- package/build/codex-bridge-profile.js +1 -1
- package/build/commands.generated.js +6 -6
- package/build/conductor/bridge-api-client.js +858 -21
- package/build/conductor/bring-up-facts.js +9 -9
- package/build/conductor/command-drift-production.js +7 -2
- package/build/conductor/doctor.js +472 -18
- package/build/conductor/epic-child-continuation.js +54 -3
- package/build/conductor/epic-implementer-cli.js +136 -34
- package/build/conductor/epic-runtime.js +2 -2
- package/build/conductor/epic-state.js +1 -1
- package/build/conductor/gate-discovery.js +524 -10
- package/build/conductor/gate-settings-review.js +451 -0
- package/build/conductor/hook-runtime-qualification.js +1 -1
- package/build/conductor/install-doctor.js +4 -2
- package/build/conductor/launch-need-probes.js +342 -0
- package/build/conductor/launch-plan.js +145 -0
- package/build/conductor/local-merge.js +241 -56
- package/build/conductor/merge-credential.js +172 -0
- package/build/conductor/merge-execution-eligibility.js +1 -1
- package/build/conductor/merged-child-check.js +95 -0
- package/build/conductor/plan-trim.js +30 -0
- package/build/conductor/pr-ci-producer.js +1 -1
- package/build/conductor/precheck-timings.js +14 -0
- package/build/conductor/preview-observations.js +10 -0
- package/build/conductor/readiness-cli.js +11 -6
- package/build/conductor/readiness-prerequisites.js +41 -0
- package/build/conductor/readiness-sections.js +348 -55
- package/build/conductor/readiness.js +99 -87
- package/build/conductor/recovery-cli.js +665 -23
- package/build/conductor/recovery-operations.js +350 -8
- package/build/conductor/repair-contract.js +47 -2
- package/build/conductor/repository-workflow-remedy.js +8 -6
- package/build/conductor/stored-merge-credential.js +76 -0
- package/build/conductor/stored-merge-token-probe.js +28 -0
- package/build/conductor/temporary-plan.js +50 -0
- package/build/conductor/wait-run-cli.js +759 -0
- package/build/conductor/worker-database-doctor-inspector.js +49 -0
- package/build/conductor-bin.js +2 -2
- package/build/conductor-claude-hook-bin.js +2 -2
- package/build/conductor-claude-hook-removed-stub-bin.js +2 -5
- package/build/conductor-removed-stub-bin.js +2 -5
- package/build/credential-store.js +356 -13
- package/build/docs.generated.js +26 -13
- package/build/doctor.js +94 -32
- package/build/drive-epic-help.js +212 -0
- package/build/drive-epic.js +1989 -379
- package/build/epic-ci-workflow-drift.js +125 -0
- package/build/epic-ci-workflow-install.js +240 -0
- package/build/epic-ci-workflow-v1.js +132 -0
- package/build/epic-ci-workflow.js +318 -0
- package/build/epic-contract-context.js +326 -0
- package/build/epic-implementer-bin.js +58 -42
- package/build/epic-implementer-claude-hook-bin.js +2 -2
- package/build/escalation-reachability.js +134 -0
- package/build/executor/ci-rerun-job.js +220 -14
- package/build/executor/cleanup-report.js +99 -0
- package/build/executor/cli.js +12 -1
- package/build/executor/completion-contract.js +66 -11
- package/build/executor/completion-supervision.js +99 -0
- package/build/executor/delivery-outcome.js +179 -0
- package/build/executor/deps.js +3 -0
- package/build/executor/env.js +276 -1
- package/build/executor/failure-reason-codes.js +126 -0
- package/build/executor/gate-qualification-job.js +20 -5
- package/build/executor/heartbeat.js +38 -0
- package/build/executor/http-client.js +72 -0
- package/build/executor/integration-job.js +298 -5
- package/build/executor/job-errors.js +36 -6
- package/build/executor/job-runner.js +830 -45
- package/build/executor/likely-tests.js +42 -3
- package/build/executor/merge-job.js +145 -2
- package/build/executor/observation.js +73 -4
- package/build/executor/permissions.js +193 -97
- package/build/executor/preflight.js +19 -3
- package/build/executor/process-containment.js +46 -2
- package/build/executor/prompt-spec.js +113 -9
- package/build/executor/rebase-finalization.js +38 -3
- package/build/executor/reconcile-overlap-job.js +41 -8
- package/build/executor/required-work-ledger.js +236 -81
- package/build/executor/resume-pre-spawn.js +38 -1
- package/build/executor/runner.js +91 -3
- package/build/executor/test-clock.js +8 -0
- package/build/executor/types.js +37 -2
- package/build/executor/worker-cli-launcher.js +259 -0
- package/build/executor/worker-command.js +177 -5
- package/build/executor/worker-database-target.js +91 -0
- package/build/executor/worker-database.js +927 -0
- package/build/executor/worker-finalization.js +106 -0
- package/build/executor/worker-guard-hook.js +203 -0
- package/build/executor/worker-resources.js +58 -0
- package/build/executor/worker-verification-guidance.js +44 -2
- package/build/executor/worktree.js +303 -15
- package/build/executor-launch.js +11 -1
- package/build/generated-assets-doctor.js +9 -1
- package/build/generated-assets-health.js +13 -4
- package/build/generated-assets-legacy.js +39 -0
- package/build/generated-assets-paths.js +12 -1
- package/build/generated-assets-repair.js +4 -1
- package/build/generated-assets-test-support.js +12 -0
- package/build/github-remote.js +33 -0
- package/build/github-sign-in.js +62 -0
- package/build/index.js +1133 -546
- package/build/init.js +39 -1
- package/build/install-bridge-conductor-gate.js +270 -11
- package/build/install-bridge-conductor-setup.js +427 -0
- package/build/install-bridge-conductor.js +1545 -268
- package/build/install-bridge.js +376 -60
- package/build/mcp-install-state.js +8 -2
- package/build/merge-pull-request.js +6 -0
- package/build/merge-workflow-install.js +782 -344
- package/build/phase-result-artifacts.js +75 -20
- package/build/pipeline-orchestrator.js +247 -4
- package/build/pipelines.generated.js +35 -35
- package/build/plan-discovery.js +15 -2
- package/build/plan-execution-ledger.js +321 -17
- package/build/plan-phase-routing.js +48 -13
- package/build/plane/cli.js +105 -51
- package/build/plane/defaults.js +3 -0
- package/build/plane/plane-freshness.js +298 -0
- package/build/plane/preflight.js +19 -0
- package/build/plane/schema-compatibility.js +137 -0
- package/build/plane/shutdown-deps.js +38 -0
- package/build/plane/shutdown.js +83 -8
- package/build/plane/terminal-run-cleanup.js +303 -0
- package/build/printed-remedy-commands.js +33 -4
- package/build/readiness-check.js +6 -2
- package/build/readiness-prerequisites.generated.js +532 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-toolchains.js +581 -0
- package/build/setup-epic.js +421 -34
- package/build/shared-resources.generated.js +5 -0
- package/build/start-tickets.js +28 -15
- package/build/test-command-detection.js +284 -0
- package/build/test-command-validation.js +73 -0
- package/build/testing-config-client.js +150 -0
- package/build/ticket-delivery-artifacts.js +265 -0
- package/build/ticket-delivery-enrollment.js +369 -0
- package/build/ticket-delivery.js +205 -0
- package/build/ticket-review-summary.js +14 -0
- package/build/upgrade-cli.js +13 -0
- package/build/v2-readiness-requirements.js +552 -0
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktree-core.js +22 -7
- package/docs/BRIDGE-DIRECTORY-README.md +48 -0
- package/docs/EPIC-IMPLEMENTER-INSTALL.md +12 -867
- package/docs/EPIC-IMPLEMENTER.md +142 -63
- package/docs/epic-implementer/getting-started.md +187 -0
- package/docs/epic-implementer/self-hosting.md +133 -0
- package/package.json +4 -4
- package/pipelines/idea-to-ticket.json +1 -1
- package/pipelines/implement-ticket.json +8 -8
- package/pipelines/review-ticket.json +2 -2
- package/design-assets/favicon/favicon-32x32.png +0 -0
- package/design-assets/just-logo-rough-draft.png +0 -0
package/build/init.js
CHANGED
|
@@ -9,12 +9,14 @@
|
|
|
9
9
|
* import `runInit` back from `index.ts`). This module has no top-level side
|
|
10
10
|
* effects and depends only on leaf modules.
|
|
11
11
|
*/
|
|
12
|
-
import { writeFile, mkdir, readFile, stat } from "fs/promises";
|
|
12
|
+
import { writeFile, mkdir, readFile, stat, lstat, access, realpath } from "fs/promises";
|
|
13
13
|
import { execFile } from "child_process";
|
|
14
14
|
import path from "path";
|
|
15
15
|
import os from "os";
|
|
16
16
|
import { buildPackagedAssetCatalog } from "./generated-assets-catalog.js";
|
|
17
17
|
import { recordProvisionedAssets } from "./generated-assets-inventory.js";
|
|
18
|
+
import { inspectAssetPath } from "./generated-assets-paths.js";
|
|
19
|
+
import { LEGACY_DOC_DESTINATIONS } from "./docs.generated.js";
|
|
18
20
|
import { VERSION, LAUNCHER_ARGS } from "./version.generated.js";
|
|
19
21
|
import { BRIDGE_CONFIG_TEAMMATE_NOTICE_LINES, validateBridgeConfigRepoNameRepresentability, validateRepoName, resolveRepoNameForProjectRoot, } from "./bridge-config.js";
|
|
20
22
|
import { ensureGitignored as ensureGitignoredShared } from "./git-ignore-utils.js";
|
|
@@ -888,6 +890,40 @@ export async function runInit(cwd, options = {}) {
|
|
|
888
890
|
}
|
|
889
891
|
if (scaffoldFailed)
|
|
890
892
|
throw new Error("Some packaged workflow assets could not be scaffolded.");
|
|
893
|
+
// ---- Phase 5b: Advisory probe for old procedure copies (BAPI-1470) ----
|
|
894
|
+
// The six machine-read procedures moved from docs/install/ to
|
|
895
|
+
// .bridge/procedures/. Report old copies that are still there. This only
|
|
896
|
+
// inspects metadata: it never reads, rewrites, or deletes an old file, and no
|
|
897
|
+
// outcome changes `ok` or the exit behavior.
|
|
898
|
+
const legacyProcedureCopies = [];
|
|
899
|
+
const legacyProcedureProbeWarnings = [];
|
|
900
|
+
const inspectionFs = options.assetInspectionFs ?? { lstat, access };
|
|
901
|
+
const probeRoot = await realpath(cwd).catch(() => path.resolve(cwd));
|
|
902
|
+
for (const relPath of Object.values(LEGACY_DOC_DESTINATIONS)) {
|
|
903
|
+
try {
|
|
904
|
+
const finding = await inspectAssetPath(probeRoot, relPath, inspectionFs);
|
|
905
|
+
if (finding.status === "present")
|
|
906
|
+
legacyProcedureCopies.push(relPath);
|
|
907
|
+
else if (finding.status !== "missing") {
|
|
908
|
+
legacyProcedureProbeWarnings.push({ relPath, status: finding.status, reason: finding.reason.slice(0, 64) });
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
catch {
|
|
912
|
+
legacyProcedureProbeWarnings.push({ relPath, status: "indeterminate", reason: "probe-failed" });
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
if (legacyProcedureCopies.length > 0) {
|
|
916
|
+
say([
|
|
917
|
+
"Old procedure copies found:",
|
|
918
|
+
...legacyProcedureCopies.map((p) => ` ${p}`),
|
|
919
|
+
"These are old fallback copies. Bridge now reads `.bridge/procedures/` first. " +
|
|
920
|
+
"You can delete the listed copies once the new `.bridge/procedures/` files are committed.",
|
|
921
|
+
].join("\n"));
|
|
922
|
+
}
|
|
923
|
+
for (const w of legacyProcedureProbeWarnings) {
|
|
924
|
+
warn(` Could not confirm whether the old procedure copy ${w.relPath} exists (${w.status}: ${w.reason}). ` +
|
|
925
|
+
"Check that path by hand.");
|
|
926
|
+
}
|
|
891
927
|
// ---- Phase 6: Scaffold custom pipeline directories ----
|
|
892
928
|
// BAPI-708: shared with `resolveInitScaffoldAssets`, so a `BAPI_PIPELINES_DIR`
|
|
893
929
|
// override moves the scaffold and the commit-safe manifest in lockstep.
|
|
@@ -1086,5 +1122,7 @@ says to serialize structured output.
|
|
|
1086
1122
|
targetVersion,
|
|
1087
1123
|
bridgeConfigCreated,
|
|
1088
1124
|
...(bridgeConfigRepoName !== undefined ? { bridgeConfigRepoName } : {}),
|
|
1125
|
+
legacyProcedureCopies,
|
|
1126
|
+
legacyProcedureProbeWarnings,
|
|
1089
1127
|
};
|
|
1090
1128
|
}
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
import { ConductorBridgeApiError, GATE_PROFILE_CAPABILITY_TOKEN, enqueueConductorGateQualification, fetchConductorGateCheckHistory, fetchConductorGateProfile, fetchConductorGateQualificationJob, probeConductorGateProfileCapability, putConductorGateProfile, putEpicBranchCiDecision, } from "./conductor/bridge-api-client.js";
|
|
43
43
|
import { applyApprovalExemption, assessApprovalExemptionScope, buildEpicBranchCiEvidence, exemptionManualSteps, inspectEpicBranchWorkflowCoverage, readEpicBranchRulesViaGh, } from "./conductor/epic-branch-ci-inspection.js";
|
|
44
44
|
import { describeEvidence, discoverGate, LOCAL_COMMAND_TIMEOUT_SECONDS, } from "./conductor/gate-discovery.js";
|
|
45
|
+
import { describeSettingsEdit, hasSettingsToReview, hintEqual, renderSettingsReview, reviewDiscoveredSettings, settingsMatchStored, terminalSafe, workerEnvEqual, } from "./conductor/gate-settings-review.js";
|
|
45
46
|
import { PRINTED_EXECUTOR_INSTALL_SERVICE_COMMAND, PRINTED_EXECUTOR_ID_INSTRUCTION, PRINTED_QUALIFY_GATE_COMMAND, PRINTED_REPO_WIDE_EXECUTOR_COMMAND, } from "./printed-remedy-commands.js";
|
|
46
47
|
export function emptyConductorGateFlags() {
|
|
47
48
|
return {
|
|
@@ -261,7 +262,7 @@ function sameCommand(a, b) {
|
|
|
261
262
|
a.argv.every((w, i) => w === b.argv[i]));
|
|
262
263
|
}
|
|
263
264
|
/** Whether `desired` is exactly what `stored` already holds (no write needed). */
|
|
264
|
-
export function gateMatchesStored(desired, stored) {
|
|
265
|
+
export function gateMatchesStored(desired, stored, storedProfile) {
|
|
265
266
|
const sameGuard = desired.migrationGuard === null
|
|
266
267
|
? stored.migrationGuard === null
|
|
267
268
|
: stored.migrationGuard !== null &&
|
|
@@ -277,7 +278,16 @@ export function gateMatchesStored(desired, stored) {
|
|
|
277
278
|
desired.localCommands.length === stored.localCommands.length &&
|
|
278
279
|
desired.localCommands.every((c, i) => sameCommand(c, stored.localCommands[i])) &&
|
|
279
280
|
sameGuard &&
|
|
280
|
-
sameCustomized
|
|
281
|
+
sameCustomized &&
|
|
282
|
+
// BAPI-1520: omitted settings and per-check hints resolve against what is stored.
|
|
283
|
+
settingsMatchStored(settingsOf(desired), storedProfile ?? null));
|
|
284
|
+
}
|
|
285
|
+
/** The settings edit a desired gate carries; empty when it carries none. */
|
|
286
|
+
function settingsOf(desired) {
|
|
287
|
+
return {
|
|
288
|
+
...(desired.workerEnv !== undefined ? { workerEnv: desired.workerEnv } : {}),
|
|
289
|
+
...(desired.reproduce !== undefined ? { reproduce: desired.reproduce } : {}),
|
|
290
|
+
};
|
|
281
291
|
}
|
|
282
292
|
/** Human descriptions of every member `next` removes from `prior`. */
|
|
283
293
|
export function gateRemovals(prior, next) {
|
|
@@ -299,14 +309,29 @@ export function gateRemovals(prior, next) {
|
|
|
299
309
|
return removed;
|
|
300
310
|
}
|
|
301
311
|
/** The PUT body for a confirm of `desired` against the revision the server reported. */
|
|
302
|
-
export function confirmRequestFor(desired, expectedRevision) {
|
|
312
|
+
export function confirmRequestFor(desired, expectedRevision, stored) {
|
|
303
313
|
const guard = desired.migrationGuard === null ? null : { kind: desired.migrationGuard.kind, id: desired.migrationGuard.name };
|
|
314
|
+
// BAPI-1520: a setting is sent only when it effectively changes what is stored.
|
|
315
|
+
// An unchanged hint is omitted (the server keeps it); `reproduce: null` is sent
|
|
316
|
+
// only to remove a hint that is actually stored.
|
|
317
|
+
const providerChecks = desired.providerChecks.map((name) => {
|
|
318
|
+
const edit = desired.reproduce?.get(name);
|
|
319
|
+
if (edit === undefined)
|
|
320
|
+
return { name };
|
|
321
|
+
const current = stored?.reproduction_hints?.get(name) ?? null;
|
|
322
|
+
if (edit === null)
|
|
323
|
+
return current !== null ? { name, reproduce: null } : { name };
|
|
324
|
+
if (current !== null && hintEqual(edit, current))
|
|
325
|
+
return { name };
|
|
326
|
+
return { name, reproduce: { argv: [...edit.argv], timeout_seconds: edit.timeout_seconds } };
|
|
327
|
+
});
|
|
328
|
+
const sendWorkerEnv = desired.workerEnv !== undefined && !workerEnvEqual(desired.workerEnv, stored?.worker_env);
|
|
304
329
|
return {
|
|
305
330
|
action: "confirm",
|
|
306
331
|
confirm: true,
|
|
307
332
|
expected_revision: expectedRevision,
|
|
308
333
|
kind: desired.kind,
|
|
309
|
-
provider_checks:
|
|
334
|
+
provider_checks: providerChecks,
|
|
310
335
|
local_commands: desired.localCommands.map((c) => ({
|
|
311
336
|
name: c.name,
|
|
312
337
|
argv: [...c.argv],
|
|
@@ -314,6 +339,9 @@ export function confirmRequestFor(desired, expectedRevision) {
|
|
|
314
339
|
})),
|
|
315
340
|
migration_guard: guard,
|
|
316
341
|
...(desired.customizedCommands !== undefined ? { customized_commands: desired.customizedCommands } : {}),
|
|
342
|
+
...(sendWorkerEnv && desired.workerEnv !== undefined
|
|
343
|
+
? { worker_env: desired.workerEnv.map((e) => ({ ...e })) }
|
|
344
|
+
: {}),
|
|
317
345
|
};
|
|
318
346
|
}
|
|
319
347
|
function resolveLocalCommand(flag, proposal) {
|
|
@@ -548,6 +576,13 @@ export function renderGateComparison(io, current, desired, removals) {
|
|
|
548
576
|
io.log(" Proposed gate:");
|
|
549
577
|
for (const line of describeGate(desired))
|
|
550
578
|
io.log(line);
|
|
579
|
+
// BAPI-1520: names only here; values were shown once, in the interactive review.
|
|
580
|
+
const settingsLines = describeSettingsEdit(settingsOf(desired), current.profile);
|
|
581
|
+
if (settingsLines.length > 0) {
|
|
582
|
+
io.log(" CI settings to store with this gate (names only; hint-only settings never gate a merge):");
|
|
583
|
+
for (const line of settingsLines)
|
|
584
|
+
io.log(line);
|
|
585
|
+
}
|
|
551
586
|
if (removals.length > 0) {
|
|
552
587
|
io.log(` ⚠ This REMOVES ${removals.length} member(s) from the confirmed gate: ${removals.join("; ")}.`);
|
|
553
588
|
io.log(" Unattended runs then merge with fewer checks.");
|
|
@@ -585,6 +620,12 @@ export async function runGateDiscovery(io, access, gateDeps) {
|
|
|
585
620
|
history: { status: "not_queried" },
|
|
586
621
|
proposed: { kind: "none", providerChecks: [], localCommandIds: [] },
|
|
587
622
|
noCandidates: true,
|
|
623
|
+
workerEnvCandidates: [],
|
|
624
|
+
workerEnvConflicts: [],
|
|
625
|
+
workerEnvSkipped: [],
|
|
626
|
+
workerEnvOverflow: 0,
|
|
627
|
+
reproductionHints: [],
|
|
628
|
+
reproductionHintsSkipped: [],
|
|
588
629
|
};
|
|
589
630
|
}
|
|
590
631
|
return discoverGate({ fs, lookupHistory: historyLookupFor(io, access) });
|
|
@@ -668,6 +709,29 @@ async function editProposalInteractively(io, proposal, numbered, gateDeps) {
|
|
|
668
709
|
}
|
|
669
710
|
return desired;
|
|
670
711
|
}
|
|
712
|
+
/**
|
|
713
|
+
* BAPI-1520 — the interactive review of discovered CI settings, folded into a
|
|
714
|
+
* desired gate. Runs only in a terminal and never under `--dry-run`, so a run
|
|
715
|
+
* without explicit, interactive confirmation sends neither new setting. Nothing
|
|
716
|
+
* is shown or asked when there is nothing stored and nothing proposed.
|
|
717
|
+
*
|
|
718
|
+
* Returns the desired gate carrying the owner's decisions (settings the owner
|
|
719
|
+
* left alone stay `undefined`, so they are omitted from the write) and whether
|
|
720
|
+
* any setting changed.
|
|
721
|
+
*/
|
|
722
|
+
async function reviewSettingsInto(io, proposal, current, desired) {
|
|
723
|
+
const prompt = io.promptLine;
|
|
724
|
+
if (!prompt || !hasSettingsToReview(proposal, current.profile, desired.providerChecks)) {
|
|
725
|
+
return { desired, changed: false };
|
|
726
|
+
}
|
|
727
|
+
const edit = await reviewDiscoveredSettings({ log: io.log, promptLine: prompt }, proposal, current.profile, desired.providerChecks);
|
|
728
|
+
const merged = {
|
|
729
|
+
...desired,
|
|
730
|
+
...(edit.workerEnv !== undefined ? { workerEnv: edit.workerEnv } : {}),
|
|
731
|
+
...(edit.reproduce !== undefined ? { reproduce: edit.reproduce } : {}),
|
|
732
|
+
};
|
|
733
|
+
return { desired: merged, changed: !settingsMatchStored(edit, current.profile) };
|
|
734
|
+
}
|
|
671
735
|
/**
|
|
672
736
|
* Decide the repository gate for this run (BEFORE any write).
|
|
673
737
|
*
|
|
@@ -705,15 +769,33 @@ export async function resolveConductorGate(io, access, flags, gateDeps, options)
|
|
|
705
769
|
io.errorLog("Nothing was written.");
|
|
706
770
|
return { kind: "exit", code: 1 };
|
|
707
771
|
}
|
|
708
|
-
|
|
772
|
+
let desired = built.desired;
|
|
773
|
+
// BAPI-1520: in a terminal, review the discovered CI settings before the
|
|
774
|
+
// comparison. A non-interactive run, and a dry run, send neither new setting.
|
|
775
|
+
let settingsChanged = false;
|
|
776
|
+
if (io.promptLine && !options.dryRun) {
|
|
777
|
+
const reviewProposal = proposal ?? (await runGateDiscovery(io, access, gateDeps));
|
|
778
|
+
const reviewed = await reviewSettingsInto(io, reviewProposal, current, desired);
|
|
779
|
+
desired = reviewed.desired;
|
|
780
|
+
settingsChanged = reviewed.changed;
|
|
781
|
+
}
|
|
709
782
|
const removals = gateRemovals(currentDesired, desired);
|
|
710
|
-
const unchanged = current.source === "stored" &&
|
|
783
|
+
const unchanged = current.source === "stored" &&
|
|
784
|
+
currentDesired !== null &&
|
|
785
|
+
gateMatchesStored(desired, currentDesired, current.profile);
|
|
711
786
|
io.log(" Gate flags supplied: they are your explicit gate input.");
|
|
712
787
|
renderGateComparison(io, current, desired, removals);
|
|
713
788
|
if (unchanged) {
|
|
714
789
|
io.log(" The confirmed gate already matches — no gate write is needed.");
|
|
715
790
|
return { kind: "plan", plan: { current, desired: currentDesired, write: null, removals: [], origin: "stored" } };
|
|
716
791
|
}
|
|
792
|
+
if (settingsChanged && !options.dryRun) {
|
|
793
|
+
const ok = await ask(io, "Store these CI settings with the gate? [y/N]: ");
|
|
794
|
+
if (!ok) {
|
|
795
|
+
io.errorLog("CI settings not confirmed — nothing was written, and the stored gate is unchanged.");
|
|
796
|
+
return { kind: "exit", code: 1 };
|
|
797
|
+
}
|
|
798
|
+
}
|
|
717
799
|
if (removals.length > 0 && !flags.confirmGate && !options.dryRun) {
|
|
718
800
|
const ok = await ask(io, "Confirm this gate, including the removals above? [y/N]: ");
|
|
719
801
|
if (!ok) {
|
|
@@ -724,9 +806,18 @@ export async function resolveConductorGate(io, access, flags, gateDeps, options)
|
|
|
724
806
|
}
|
|
725
807
|
return {
|
|
726
808
|
kind: "plan",
|
|
727
|
-
plan: {
|
|
809
|
+
plan: {
|
|
810
|
+
current,
|
|
811
|
+
desired,
|
|
812
|
+
write: confirmRequestFor(desired, current.revision, current.profile),
|
|
813
|
+
removals,
|
|
814
|
+
origin: "flags",
|
|
815
|
+
},
|
|
728
816
|
};
|
|
729
817
|
}
|
|
818
|
+
if (options.ensureProviderCheck !== undefined) {
|
|
819
|
+
return ensureProviderCheckPlan(io, access, current, currentDesired, options.ensureProviderCheck, gateDeps, options);
|
|
820
|
+
}
|
|
730
821
|
if (currentDesired !== null) {
|
|
731
822
|
io.log(current.source === "legacy"
|
|
732
823
|
? " Using the confirmed gate from this repository's existing --required-check setup."
|
|
@@ -738,6 +829,10 @@ export async function resolveConductorGate(io, access, flags, gateDeps, options)
|
|
|
738
829
|
const proposal = await runGateDiscovery(io, access, gateDeps);
|
|
739
830
|
const numbered = renderGateProposal(io, proposal);
|
|
740
831
|
if (options.dryRun) {
|
|
832
|
+
// BAPI-1520: a read-only preview. Values are shown only in a terminal.
|
|
833
|
+
if (hasSettingsToReview(proposal, current.profile, proposal.proposed.providerChecks)) {
|
|
834
|
+
renderSettingsReview(io, proposal, current.profile, proposal.proposed.providerChecks, io.promptLine !== undefined);
|
|
835
|
+
}
|
|
741
836
|
io.log(" Dry run — a real run asks you to confirm or edit this proposal. Nothing was stored.");
|
|
742
837
|
return { kind: "unconfirmed-preview", current };
|
|
743
838
|
}
|
|
@@ -748,11 +843,13 @@ export async function resolveConductorGate(io, access, flags, gateDeps, options)
|
|
|
748
843
|
"or --gate-none). Nothing was written.");
|
|
749
844
|
return { kind: "exit", code: 1 };
|
|
750
845
|
}
|
|
751
|
-
const
|
|
752
|
-
if (
|
|
846
|
+
const chosen = await editProposalInteractively(io, proposal, numbered, gateDeps);
|
|
847
|
+
if (chosen === null) {
|
|
753
848
|
io.errorLog("No gate was chosen. Nothing was written.");
|
|
754
849
|
return { kind: "exit", code: 1 };
|
|
755
850
|
}
|
|
851
|
+
// BAPI-1520: worker variables and reproduction hints, decided one at a time.
|
|
852
|
+
const { desired } = await reviewSettingsInto(io, proposal, current, chosen);
|
|
756
853
|
renderGateComparison(io, current, desired, []);
|
|
757
854
|
const confirmed = await ask(io, "Store this repository gate? [y/N]: ");
|
|
758
855
|
if (!confirmed) {
|
|
@@ -761,7 +858,92 @@ export async function resolveConductorGate(io, access, flags, gateDeps, options)
|
|
|
761
858
|
}
|
|
762
859
|
return {
|
|
763
860
|
kind: "plan",
|
|
764
|
-
plan: {
|
|
861
|
+
plan: {
|
|
862
|
+
current,
|
|
863
|
+
desired,
|
|
864
|
+
write: confirmRequestFor(desired, current.revision, current.profile),
|
|
865
|
+
removals: [],
|
|
866
|
+
origin: "interactive",
|
|
867
|
+
},
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
/** BAPI-1461 — `desired` with `check` added as a provider member (kept when present). */
|
|
871
|
+
function withProviderCheck(desired, check) {
|
|
872
|
+
if (desired.providerChecks.includes(check))
|
|
873
|
+
return desired;
|
|
874
|
+
const providerChecks = [...desired.providerChecks, check];
|
|
875
|
+
return {
|
|
876
|
+
...desired,
|
|
877
|
+
providerChecks,
|
|
878
|
+
localCommands: desired.localCommands.map((c) => ({ ...c, argv: [...c.argv] })),
|
|
879
|
+
kind: kindForMembers(providerChecks, desired.localCommands),
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* BAPI-1461 — the converging setup's gate decision when no gate flag was given.
|
|
884
|
+
*
|
|
885
|
+
* - A confirmed gate that already requires the check: used unchanged, no write.
|
|
886
|
+
* - A confirmed provider or mixed gate without it: the check is ADDED (every
|
|
887
|
+
* member kept), shown against the stored gate, and stored later under the
|
|
888
|
+
* combined gate-and-defaults consent.
|
|
889
|
+
* - A confirmed local-only or `none` gate: changing its kind is a policy change,
|
|
890
|
+
* so the comparison is shown and the owner is asked here. A decline keeps the
|
|
891
|
+
* stored gate and is reported as an outstanding blocking fix.
|
|
892
|
+
* - No confirmed gate: the discovery proposal plus the check, shown for the
|
|
893
|
+
* combined consent. Nothing is stored here.
|
|
894
|
+
*/
|
|
895
|
+
async function ensureProviderCheckPlan(io, access, current, currentDesired, check, gateDeps, options) {
|
|
896
|
+
if (currentDesired !== null) {
|
|
897
|
+
if (currentDesired.providerChecks.includes(check)) {
|
|
898
|
+
io.log(current.source === "legacy"
|
|
899
|
+
? " Using the confirmed gate from this repository's existing --required-check setup."
|
|
900
|
+
: ` Using the confirmed gate (revision ${current.revision}).`);
|
|
901
|
+
for (const line of describeGate(currentDesired))
|
|
902
|
+
io.log(line);
|
|
903
|
+
return { kind: "plan", plan: { current, desired: currentDesired, write: null, removals: [], origin: "stored" } };
|
|
904
|
+
}
|
|
905
|
+
const desired = withProviderCheck(currentDesired, check);
|
|
906
|
+
renderGateComparison(io, current, desired, []);
|
|
907
|
+
if (currentDesired.kind === "local" || currentDesired.kind === "none") {
|
|
908
|
+
if (options.dryRun) {
|
|
909
|
+
io.log(" Dry run — a real run asks before adding the CI check to this gate.");
|
|
910
|
+
}
|
|
911
|
+
else {
|
|
912
|
+
const ok = await ask(io, "Add the CI workflow check to this repository gate? [y/N]: ");
|
|
913
|
+
if (!ok) {
|
|
914
|
+
io.log(" Kept the stored gate unchanged; the CI check is listed as a step left.");
|
|
915
|
+
return {
|
|
916
|
+
kind: "plan",
|
|
917
|
+
plan: { current, desired: currentDesired, write: null, removals: [], origin: "stored" },
|
|
918
|
+
ensureDeclined: true,
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
return {
|
|
924
|
+
kind: "plan",
|
|
925
|
+
plan: {
|
|
926
|
+
current,
|
|
927
|
+
desired,
|
|
928
|
+
write: confirmRequestFor(desired, current.revision, current.profile),
|
|
929
|
+
removals: [],
|
|
930
|
+
origin: "stored",
|
|
931
|
+
},
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
const proposal = await runGateDiscovery(io, access, gateDeps);
|
|
935
|
+
renderGateProposal(io, proposal);
|
|
936
|
+
const desired = withProviderCheck(desiredFromProposalSelection(proposal, proposal.proposed.providerChecks, proposal.proposed.localCommandIds), check);
|
|
937
|
+
renderGateComparison(io, current, desired, []);
|
|
938
|
+
return {
|
|
939
|
+
kind: "plan",
|
|
940
|
+
plan: {
|
|
941
|
+
current,
|
|
942
|
+
desired,
|
|
943
|
+
write: confirmRequestFor(desired, current.revision, current.profile),
|
|
944
|
+
removals: [],
|
|
945
|
+
origin: "interactive",
|
|
946
|
+
},
|
|
765
947
|
};
|
|
766
948
|
}
|
|
767
949
|
const GATE_WRITE_REFUSAL_TEXT = Object.freeze({
|
|
@@ -775,7 +957,32 @@ const GATE_WRITE_REFUSAL_TEXT = Object.freeze({
|
|
|
775
957
|
timeout: "the Bridge API did not answer in time.",
|
|
776
958
|
server: "the Bridge API reported an internal error.",
|
|
777
959
|
rejected: "the Bridge API rejected the request.",
|
|
960
|
+
"extension-unsupported": "this server is older than the installer and cannot store worker variables or reproduction hints.",
|
|
778
961
|
});
|
|
962
|
+
/** Plain-language text for each closed `worker_env` refusal reason (BAPI-1520). */
|
|
963
|
+
const WORKER_ENV_REASON_TEXT = Object.freeze({
|
|
964
|
+
worker_env_reserved_name: "is reserved by Bridge and cannot be a worker variable. Remove it, then confirm again; " +
|
|
965
|
+
"nothing was removed or retried automatically.",
|
|
966
|
+
worker_env_secret_name: "looks secret. Drop it, or confirm its committed-literal assertion individually, then confirm again.",
|
|
967
|
+
worker_env_duplicate: "appears more than once. Keep one entry, then confirm again.",
|
|
968
|
+
});
|
|
969
|
+
/** The request without BAPI-1520's extension fields, and the NAMES it dropped. */
|
|
970
|
+
function withoutExtensions(request) {
|
|
971
|
+
const workerEnvNames = (request.worker_env ?? []).map((e) => e.name);
|
|
972
|
+
const hintChecks = (request.provider_checks ?? [])
|
|
973
|
+
.filter((c) => c.reproduce !== undefined)
|
|
974
|
+
.map((c) => c.name);
|
|
975
|
+
const { worker_env: _dropped, ...rest } = request;
|
|
976
|
+
void _dropped;
|
|
977
|
+
return {
|
|
978
|
+
request: {
|
|
979
|
+
...rest,
|
|
980
|
+
...(request.provider_checks ? { provider_checks: request.provider_checks.map((c) => ({ name: c.name })) } : {}),
|
|
981
|
+
},
|
|
982
|
+
workerEnvNames,
|
|
983
|
+
hintChecks,
|
|
984
|
+
};
|
|
985
|
+
}
|
|
779
986
|
/**
|
|
780
987
|
* Send the plan's PUT. On a refusal, print the reason and the PRIOR gate as
|
|
781
988
|
* what is in force (property 4) and return null.
|
|
@@ -783,9 +990,46 @@ const GATE_WRITE_REFUSAL_TEXT = Object.freeze({
|
|
|
783
990
|
export async function storeConductorGate(io, access, plan) {
|
|
784
991
|
if (plan.write === null)
|
|
785
992
|
return plan.current;
|
|
786
|
-
|
|
993
|
+
// BAPI-1461: a stored gate that already equals the desired one is never
|
|
994
|
+
// rewritten, whatever the caller planned.
|
|
995
|
+
if (plan.current.source === "stored" &&
|
|
996
|
+
plan.current.confirmed &&
|
|
997
|
+
plan.current.profile !== null &&
|
|
998
|
+
gateMatchesStored(plan.desired, desiredFromStored(plan.current.profile), plan.current.profile)) {
|
|
999
|
+
return plan.current;
|
|
1000
|
+
}
|
|
1001
|
+
let outcome = await putConductorGateProfile(access, plan.write, io.postJson);
|
|
1002
|
+
// BAPI-1520: an older server rejects exactly the extension fields it does not
|
|
1003
|
+
// know. Retry ONCE without them, keep everything else the owner approved, and
|
|
1004
|
+
// report what was not stored by name.
|
|
1005
|
+
let unsaved = null;
|
|
1006
|
+
if (!outcome.ok && outcome.refusal === "extension-unsupported") {
|
|
1007
|
+
const stripped = withoutExtensions(plan.write);
|
|
1008
|
+
unsaved = { workerEnvNames: stripped.workerEnvNames, hintChecks: stripped.hintChecks };
|
|
1009
|
+
const storedDesired = plan.current.profile !== null ? desiredFromStored(plan.current.profile) : null;
|
|
1010
|
+
const membersUnchanged = plan.current.source === "stored" &&
|
|
1011
|
+
storedDesired !== null &&
|
|
1012
|
+
gateMatchesStored({ ...plan.desired, workerEnv: undefined, reproduce: undefined }, storedDesired);
|
|
1013
|
+
if (membersUnchanged) {
|
|
1014
|
+
reportUnsavedSettings(io, unsaved);
|
|
1015
|
+
io.log(" The gate itself already matched, so nothing was written.");
|
|
1016
|
+
return plan.current;
|
|
1017
|
+
}
|
|
1018
|
+
outcome = await putConductorGateProfile(access, stripped.request, io.postJson);
|
|
1019
|
+
}
|
|
787
1020
|
if (!outcome.ok) {
|
|
788
1021
|
io.errorLog(`Repository gate not stored (${outcome.refusal}): ${GATE_WRITE_REFUSAL_TEXT[outcome.refusal]}`);
|
|
1022
|
+
const reason = outcome.detail?.reason;
|
|
1023
|
+
if (outcome.refusal === "validation" && reason !== undefined) {
|
|
1024
|
+
const name = outcome.detail?.name !== undefined ? ` ${terminalSafe(outcome.detail.name)}` : "";
|
|
1025
|
+
io.errorLog(` Worker variable${name} ${WORKER_ENV_REASON_TEXT[reason] ?? "was refused."} (${reason})`);
|
|
1026
|
+
}
|
|
1027
|
+
else if (outcome.refusal === "validation" && outcome.detail?.field === "provider_checks") {
|
|
1028
|
+
io.errorLog(" A reproduction hint was refused. Correct or remove it, then confirm again.");
|
|
1029
|
+
}
|
|
1030
|
+
else if (outcome.refusal === "validation" && outcome.detail?.field === "worker_env") {
|
|
1031
|
+
io.errorLog(" A worker variable was refused. Correct it, then confirm again; nothing was truncated or written.");
|
|
1032
|
+
}
|
|
789
1033
|
io.errorLog(` Nothing was written. ${describeStoredHeading(plan.current)}`);
|
|
790
1034
|
if (plan.current.confirmed && plan.current.profile !== null) {
|
|
791
1035
|
for (const line of describeGate(desiredFromStored(plan.current.profile)))
|
|
@@ -794,8 +1038,23 @@ export async function storeConductorGate(io, access, plan) {
|
|
|
794
1038
|
return null;
|
|
795
1039
|
}
|
|
796
1040
|
io.log(` stored repository gate: ${outcome.profile.profile?.kind ?? "none"} (revision ${outcome.profile.revision})`);
|
|
1041
|
+
if (unsaved !== null)
|
|
1042
|
+
reportUnsavedSettings(io, unsaved);
|
|
797
1043
|
return outcome.profile;
|
|
798
1044
|
}
|
|
1045
|
+
/** BAPI-1520 — name the settings an older server could not store. Never a value. */
|
|
1046
|
+
function reportUnsavedSettings(io, unsaved) {
|
|
1047
|
+
if (unsaved.workerEnvNames.length === 0 && unsaved.hintChecks.length === 0)
|
|
1048
|
+
return;
|
|
1049
|
+
io.log(" ⚠ Partly stored: this server is older than the installer and cannot store these settings.");
|
|
1050
|
+
if (unsaved.workerEnvNames.length > 0) {
|
|
1051
|
+
io.log(` Not stored — worker variables: ${unsaved.workerEnvNames.map(terminalSafe).join(", ")}`);
|
|
1052
|
+
}
|
|
1053
|
+
if (unsaved.hintChecks.length > 0) {
|
|
1054
|
+
io.log(` Not stored — reproduction hints for: ${unsaved.hintChecks.map(terminalSafe).join(", ")}`);
|
|
1055
|
+
}
|
|
1056
|
+
io.log(" Upgrade the Bridge API deployment, then re-run to store them.");
|
|
1057
|
+
}
|
|
799
1058
|
// ---------------------------------------------------------------------------
|
|
800
1059
|
// Qualification (property 5)
|
|
801
1060
|
// ---------------------------------------------------------------------------
|