@bridge_gpt/mcp-server 0.2.73 → 0.2.74
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 +5 -5
- package/build/agent-launchers/claude-executor-adapter.js +12 -0
- package/build/agents.generated.js +3 -3
- package/build/bridge-config.js +7 -1
- package/build/bridge-permissions.js +3 -0
- package/build/command-provisioning.js +4 -3
- package/build/commands.generated.js +5 -5
- package/build/conductor/bridge-api-client.js +26 -1
- package/build/conductor/command-drift.js +1 -1
- package/build/conductor/declared-extras.js +335 -0
- package/build/conductor/doctor.js +2 -0
- package/build/conductor/driver-pass-output.js +104 -0
- package/build/conductor/driver-pass.js +571 -0
- package/build/conductor/epic-branch-ci-inspection.js +61 -16
- package/build/conductor/epic-implementer-cli.js +33 -0
- package/build/conductor/epic-server-sfcc-upload.js +1567 -0
- package/build/conductor/epic-server-sfcc.js +58 -80
- package/build/conductor/epic-server.js +57 -4
- package/build/conductor/gate-discovery.js +46 -6
- package/build/conductor/gate-settings-review.js +51 -14
- package/build/credential-delivery.js +280 -0
- package/build/credential-launch-safety.js +142 -0
- package/build/credential-materialization.js +91 -16
- package/build/credential-references-node-deps.js +29 -0
- package/build/credential-references.js +1394 -0
- package/build/credential-references.test-fixtures.js +211 -0
- package/build/credential-scan-conventions.js +145 -0
- package/build/credential-scan.js +517 -0
- package/build/credential-store.js +50 -0
- package/build/credentials-cli.js +252 -3
- package/build/dependency-install-declarations.js +47 -1
- package/build/docs.generated.js +8 -1
- package/build/doctor.js +41 -0
- package/build/drive-epic.js +297 -37
- package/build/epic-branch-ci-summary.js +18 -1
- package/build/epic-capability-statement.js +71 -3
- package/build/epic-ci-workflow-drift.js +52 -13
- package/build/epic-ci-workflow-install.js +31 -6
- package/build/epic-ci-workflow-v3.js +273 -0
- package/build/epic-ci-workflow.js +128 -7
- package/build/epic-implementer-bin.js +161 -70
- package/build/epic-launch-context.js +102 -7
- package/build/epic-server-record.js +30 -15
- package/build/executor/credential-delivery-step.js +168 -0
- package/build/executor/deps.js +3 -1
- package/build/executor/env.js +39 -1
- package/build/executor/epic-server-context.js +23 -7
- package/build/executor/guarded-fast-forward-push.js +13 -8
- package/build/executor/job-runner.js +159 -17
- package/build/executor/permissions.js +85 -3
- package/build/executor/prompt-spec.js +37 -3
- package/build/executor-launch.js +4 -2
- package/build/git-exclude-lock.js +187 -0
- package/build/index.js +398 -269
- package/build/install-bridge-conductor-answers.js +84 -21
- package/build/install-bridge-conductor-apply.js +30 -1
- package/build/install-bridge-conductor-assessment.js +375 -48
- package/build/install-bridge-conductor-compact.js +27 -2
- package/build/install-bridge-conductor-contracts.js +10 -1
- package/build/install-bridge-conductor-gate.js +124 -11
- package/build/install-bridge-conductor-setup.js +46 -8
- package/build/install-bridge-conductor.js +625 -113
- package/build/install-bridge.js +88 -11
- package/build/install-doctor.js +38 -8
- package/build/install-sfcc-detection.js +120 -0
- package/build/install-sfcc-setup.js +185 -0
- package/build/mcp-grant-candidates.js +108 -96
- package/build/mcp-invoke.js +168 -4
- package/build/mcp-provisioning.js +21 -4
- package/build/mcp-server-invocation.js +13 -0
- package/build/merge-workflow-install.js +9 -1
- package/build/pipelines.generated.js +2 -1
- package/build/plane/status.js +8 -2
- package/build/printed-remedy-commands.js +5 -0
- package/build/project-root.js +40 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +5 -2
- package/build/repository-toolchains.js +6 -3
- package/build/setup-epic.js +116 -15
- package/build/sfcc/credentials.js +3 -2
- package/build/sfcc/hostname.js +98 -2
- package/build/sfcc/tool-wrapper.js +6 -95
- package/build/start-tickets.js +193 -29
- package/build/test-support/executor-source-files.js +200 -0
- package/build/testing-config-client.js +25 -2
- package/build/third-party-mcp-targets.js +35 -4
- package/build/version.generated.js +3 -3
- package/build/with-credentials.js +208 -0
- package/build/worktree-credential-delivery.js +340 -0
- package/package.json +1 -1
|
@@ -1,11 +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, epicBranchCiStateText, indexDisplayStatus, } from './install-bridge-conductor-assessment.js';
|
|
3
|
+
import { buildInstallAssessment, buildInstallChoices, recommendEpicServer, buildInstallVerdict, buildProposalPresentation, classifyMergeTestProtection, dependencyInstallDetails, epicBranchCiIncludeRestsOnSetupPr, epicBranchCiStateText, indexDisplayStatus, } from './install-bridge-conductor-assessment.js';
|
|
4
4
|
import { GITHUB_ACTIONS_TRIGGER_ADAPTER, recognizeAppliedEdit, selectTriggerEdit, sha256Hex, } from './ci-trigger-adapters.js';
|
|
5
5
|
import { detectCiSystems } from './ci-system-detection.js';
|
|
6
|
-
import { describeDeclinedCiChange, describeProposedCiChange } from './epic-branch-ci-summary.js';
|
|
6
|
+
import { describeDeclinedCiChange, describeProposedCiChange, describeUnopenedSetupCredit } from './epic-branch-ci-summary.js';
|
|
7
7
|
import { buildCompactApply, buildCompactAssessment, buildCompactProposal } from './install-bridge-conductor-compact.js';
|
|
8
|
-
import { decisionFor, normalizeInstallAnswers, parseAnswersText, readAnswersSource, } from './install-bridge-conductor-answers.js';
|
|
8
|
+
import { decisionFor, normalizeInstallAnswers, parseAnswerValue, parseAnswersText, readAnswersSource, } from './install-bridge-conductor-answers.js';
|
|
9
9
|
import { applyInstallProposal, } from './install-bridge-conductor-apply.js';
|
|
10
10
|
import { previewConductorSetupPolicy, applyConductorSetupPolicy, fetchConductorSetupPolicy, fetchConductorGateProfile, fetchConductorRepositoryLearning, ConductorSetupPolicyError, SETUP_POLICY_PROTOCOL } from "./conductor/bridge-api-client.js";
|
|
11
11
|
import { askPlainConsent, askPlainSetupQuestion, askSetupQuestion, createPlainInputSession, setupConsentQuestion, } from "./setup-question.js";
|
|
@@ -130,7 +130,7 @@ import { withSetupProgress } from "./setup-progress.js";
|
|
|
130
130
|
* stop; everything else it adds only warns.
|
|
131
131
|
*/
|
|
132
132
|
import { PRINTED_INSTALL_COMMAND, PRINTED_QUALIFY_GATE_COMMAND } from "./printed-remedy-commands.js";
|
|
133
|
-
import { collectEpicBranchCi, confirmRequestFor,
|
|
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";
|
|
134
134
|
import { classifyEpicPullRequestTrigger, readDefaultBranchRequiredChecksViaGh, readPullRequestBranchFilters, } from "./conductor/epic-branch-ci-inspection.js";
|
|
135
135
|
import { describeGateConsequence } from "./conductor/readiness-sections.js";
|
|
136
136
|
import { fetchConductorReadiness, } from "./conductor/bridge-api-client.js";
|
|
@@ -143,11 +143,17 @@ import { describeToolchainResolution, resolveRepositoryToolchains, } from "./rep
|
|
|
143
143
|
import { detectTestCommand } from "./test-command-detection.js";
|
|
144
144
|
import { TestCommandValidationError, validateTestCommand, } from "./test-command-validation.js";
|
|
145
145
|
import { EPIC_CI_WORKFLOW_PATH, EPIC_IMPLEMENTER_CI_CHECK_NAME, renderEpicImplementerCiWorkflow } from "./epic-ci-workflow.js";
|
|
146
|
+
import { parseDependencyInstallStrict, sameDependencyInstall, } from "./dependency-install-declarations.js";
|
|
147
|
+
import { pyprojectPathFor, scanDeclaredExtras } from "./conductor/declared-extras.js";
|
|
148
|
+
import { discoverLocalTestCandidates } from "./conductor/gate-discovery.js";
|
|
149
|
+
import { readLearnedInstructions } from "./testing-config-client.js";
|
|
146
150
|
import { normalizeStorefrontOrigin, isValidCredentialReference, isValidSfccSandboxId, sameEpicServerRecord, } from "./epic-server-record.js";
|
|
151
|
+
import { detectSfccRepository } from "./install-sfcc-detection.js";
|
|
152
|
+
import { SANDBOX_SKIPPED_LINE, WORKER_UPLOAD_ADVISORY, collectCredentialEvidence, credentialQuestionLines, credentialReferenceAdvisories, describeSfccUpload, isSfccUploadCapable, recheckSfccSandboxId, runSfccUploadCheck, sfccRecommendedDefinitionIds, suggestedCredentialEntry, } from "./install-sfcc-setup.js";
|
|
147
153
|
import { CANDIDATE_EXCLUSION_TEXT, CANDIDATE_ORIGIN_LABEL, describeInventoryExclusions, GRANT_SELECTION_PROMPT, parseGrantSelection, } from "./mcp-grant-candidates.js";
|
|
148
154
|
import { buildEpicCapabilityStatement } from "./epic-capability-statement.js";
|
|
149
155
|
import { MCP_GRANT_MAX_SERVERS } from "./mcp-grant.js";
|
|
150
|
-
import { advisoryFindingLines, assessIndexFreshness, assessSetupIndex, catalogLabel, NPM_SETUP_LAUNCHER, closedSetupPullRequestNotice, compareIndexedToMerge, planSetupFixes, projectSetupItems, readSetupPullRequest, renderSetupAssessment, setupItemRemedy, setupVerdictLine, unmetBlockingItems, } from "./install-bridge-conductor-setup.js";
|
|
156
|
+
import { advisoryFindingLines, assessIndexFreshness, assessSetupIndex, catalogLabel, NPM_SETUP_LAUNCHER, closedSetupPullRequestNotice, compareIndexedToMerge, planSetupFixes, projectSetupItems, readSetupPullRequest, renderSetupAssessment, deriveCompactReadiness, setupItemRemedy, setupVerdictLine, unmetBlockingItems, } from "./install-bridge-conductor-setup.js";
|
|
151
157
|
import { CONDUCTOR_BIN_UNRESOLVED_ERROR, MANAGED_HOOK_NAMES, } from "./conductor/git-hooks.js";
|
|
152
158
|
import os from "node:os";
|
|
153
159
|
import path from "node:path";
|
|
@@ -843,6 +849,53 @@ export function parseInstallBridgeConductorArgs(argv) {
|
|
|
843
849
|
},
|
|
844
850
|
};
|
|
845
851
|
}
|
|
852
|
+
/** Collect the snapshot. Nothing here throws, refuses, or writes. */
|
|
853
|
+
export async function collectEpicServerSnapshot(deps, epicDeps, repoName, inventory) {
|
|
854
|
+
const fs = deps.gate?.discoveryFs;
|
|
855
|
+
const check = epicDeps.sfccUploadCheck;
|
|
856
|
+
const detection = fs === undefined || check === undefined ? null : await detectSfccRepository(fs, inventory);
|
|
857
|
+
const readCredentials = epicDeps.readCredentialReferences;
|
|
858
|
+
const credentials = readCredentials === undefined ? null : await collectCredentialEvidence(() => readCredentials(repoName));
|
|
859
|
+
let guidancePresent = false;
|
|
860
|
+
try {
|
|
861
|
+
guidancePresent = await epicDeps.guidancePresent();
|
|
862
|
+
}
|
|
863
|
+
catch {
|
|
864
|
+
guidancePresent = false;
|
|
865
|
+
}
|
|
866
|
+
let existingSandbox = null;
|
|
867
|
+
try {
|
|
868
|
+
const read = await epicDeps.readRecord(repoName);
|
|
869
|
+
if (read.state === "ok")
|
|
870
|
+
existingSandbox = read.record.sfcc ?? null;
|
|
871
|
+
}
|
|
872
|
+
catch {
|
|
873
|
+
existingSandbox = null;
|
|
874
|
+
}
|
|
875
|
+
const uploadCheck = detection?.detected === true && check !== undefined
|
|
876
|
+
? await runSfccUploadCheck(check, { approvedSandboxId: existingSandbox?.sandbox_id ?? null, credentials })
|
|
877
|
+
: null;
|
|
878
|
+
return { detection, uploadCheck, credentials, guidancePresent, existingSandbox };
|
|
879
|
+
}
|
|
880
|
+
/** The same evidence for both setup paths, so their recommendation cannot differ. */
|
|
881
|
+
export function epicServerDecisionEvidence(current, applicable, snapshot, sandboxRecorded) {
|
|
882
|
+
if (snapshot === null)
|
|
883
|
+
return { current, applicable };
|
|
884
|
+
return {
|
|
885
|
+
current,
|
|
886
|
+
applicable,
|
|
887
|
+
guidancePresent: snapshot.guidancePresent,
|
|
888
|
+
...(snapshot.detection !== null
|
|
889
|
+
? { devScript: snapshot.detection.dev_script === true, sfcc: { detected: snapshot.detection.detected, uploadCheck: snapshot.uploadCheck } }
|
|
890
|
+
: {}),
|
|
891
|
+
...(snapshot.credentials !== null ? { credentialReferences: snapshot.credentials.rows } : {}),
|
|
892
|
+
...(sandboxRecorded ? { sandboxRecorded: true } : {}),
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
/** The definition ids to recommend, only for a confirmed SFCC repository. */
|
|
896
|
+
export function sfccGrantIds(snapshot, inventory) {
|
|
897
|
+
return snapshot?.detection?.detected === true && inventory !== null ? sfccRecommendedDefinitionIds(inventory) : [];
|
|
898
|
+
}
|
|
846
899
|
/** Real host-local implementations of the launch-profile seams. */
|
|
847
900
|
export function createDefaultLaunchProfileDeps(env) {
|
|
848
901
|
const store = createNodeEpicLaunchStoreDeps(env);
|
|
@@ -2124,6 +2177,11 @@ export async function runInstallBridgeConductorCli(argv, deps) {
|
|
|
2124
2177
|
...(parts.digest !== undefined ? { proposal_digest: parts.digest } : {}),
|
|
2125
2178
|
...(parts.refusal !== undefined ? { refusal: parts.refusal } : {}),
|
|
2126
2179
|
...(parts.apply !== undefined ? { apply: parts.apply } : {}),
|
|
2180
|
+
...(parts.proposalPresentation !== undefined ? { proposal_presentation: parts.proposalPresentation } : {}),
|
|
2181
|
+
...(parts.applyPresentation !== undefined ? { apply_presentation: parts.applyPresentation } : {}),
|
|
2182
|
+
...(namedOutcome === REPOSITORY_NOT_LEARNED_OUTCOME && parts.missingLearnedFields !== undefined && parts.missingLearnedFields.length > 0
|
|
2183
|
+
? { missing_learned_fields: parts.missingLearnedFields }
|
|
2184
|
+
: {}),
|
|
2127
2185
|
};
|
|
2128
2186
|
// BAPI-1653: the compact view is chosen here, at the JSON-output boundary, from the
|
|
2129
2187
|
// invocation mode. A refused apply still gets the apply view.
|
|
@@ -2664,7 +2722,7 @@ async function collectSetupEvidence(deps, setup, access, readiness, inputs) {
|
|
|
2664
2722
|
let toolchains = null;
|
|
2665
2723
|
if (storedCommand !== null && inputs.githubSignIn === "signed_in") {
|
|
2666
2724
|
toolchains = await inputs.readToolchains();
|
|
2667
|
-
workflow = await assessWorkflow(setup, storedCommand, toolchains, inputs.snapshot, workflowWanted);
|
|
2725
|
+
workflow = await assessWorkflow(setup, storedCommand, toolchains, inputs.snapshot, workflowWanted, inputs.dependencyInstall ?? []);
|
|
2668
2726
|
}
|
|
2669
2727
|
// The setup pull request and, once it merged, the index.
|
|
2670
2728
|
let setupPullRequest = { state: "unknown" };
|
|
@@ -2763,7 +2821,9 @@ function toolchainInspectionRemedy(resolution) {
|
|
|
2763
2821
|
* want it is not blocked because its dependency files could not be read, since no
|
|
2764
2822
|
* workflow is going to be generated from them.
|
|
2765
2823
|
*/
|
|
2766
|
-
async function assessWorkflow(setup, testCommand, toolchains, snapshot, workflowWanted
|
|
2824
|
+
async function assessWorkflow(setup, testCommand, toolchains, snapshot, workflowWanted,
|
|
2825
|
+
/** BAPI-1677 — the sealed install entries. Never derived here. */
|
|
2826
|
+
dependencyInstall = []) {
|
|
2767
2827
|
// No snapshot (or no way to read it) is uncertainty, never a reason to guess
|
|
2768
2828
|
// the toolchains from the person's folder.
|
|
2769
2829
|
if (toolchains === null || snapshot === null)
|
|
@@ -2773,7 +2833,7 @@ async function assessWorkflow(setup, testCommand, toolchains, snapshot, workflow
|
|
|
2773
2833
|
}
|
|
2774
2834
|
let result;
|
|
2775
2835
|
try {
|
|
2776
|
-
result = await setup.installCiWorkflow(testCommand, toolchains.toolchains, { dryRun: true, quiet: true, snapshot });
|
|
2836
|
+
result = await setup.installCiWorkflow(testCommand, toolchains.toolchains, { dryRun: true, quiet: true, snapshot, ...dependencyInstallOption(dependencyInstall) });
|
|
2777
2837
|
}
|
|
2778
2838
|
catch {
|
|
2779
2839
|
return { state: "unknown" };
|
|
@@ -3154,10 +3214,16 @@ function logStoredCommandAndToolchains(deps, storedCommand, toolchains) {
|
|
|
3154
3214
|
deps.log(` ${line}`);
|
|
3155
3215
|
}
|
|
3156
3216
|
}
|
|
3217
|
+
/** The installer option for sealed entries. None means the workflow's toolchain install lines. */
|
|
3218
|
+
function dependencyInstallOption(entries) {
|
|
3219
|
+
return entries.length > 0 ? { dependencyInstall: entries } : {};
|
|
3220
|
+
}
|
|
3157
3221
|
/** Fix: open the one setup pull request through the artifact-set installer. */
|
|
3158
3222
|
async function fixSetupPullRequest(deps, setup, testCommand, toolchains, snapshot, repository,
|
|
3159
3223
|
/** BAPI-1638 — the approved `setup_pr` answer, which stands in for the installer's own question. */
|
|
3160
|
-
consent
|
|
3224
|
+
consent,
|
|
3225
|
+
/** BAPI-1677 — the sealed install entries, read back from the stored gate. */
|
|
3226
|
+
dependencyInstall = []) {
|
|
3161
3227
|
deps.log("");
|
|
3162
3228
|
deps.log("CI workflow");
|
|
3163
3229
|
if (toolchains === null || snapshot === null) {
|
|
@@ -3175,7 +3241,7 @@ consent) {
|
|
|
3175
3241
|
let result;
|
|
3176
3242
|
try {
|
|
3177
3243
|
// The setup pull request has its OWN consent: it pushes a branch and opens a PR.
|
|
3178
|
-
result = await setup.installCiWorkflow(testCommand, toolchains.toolchains, { dryRun: false, snapshot }, (promptText) => askConsent(deps, promptText, "opening the setup pull request", undefined, consent));
|
|
3244
|
+
result = await setup.installCiWorkflow(testCommand, toolchains.toolchains, { dryRun: false, snapshot, ...dependencyInstallOption(dependencyInstall) }, (promptText) => askConsent(deps, promptText, "opening the setup pull request", undefined, consent));
|
|
3179
3245
|
}
|
|
3180
3246
|
catch {
|
|
3181
3247
|
deps.log(" the setup pull request could not be prepared; re-run setup.");
|
|
@@ -3629,14 +3695,42 @@ function reportCredentialEndpointUnapproved(deps) {
|
|
|
3629
3695
|
deps.errorLog(CREDENTIAL_ENDPOINT_UNAPPROVED_OUTCOME);
|
|
3630
3696
|
deps.errorLog("Your saved Bridge key has not been approved for this address yet.");
|
|
3631
3697
|
}
|
|
3698
|
+
/** Plain labels for the ten learned instruction identifiers (BAPI-1680). */
|
|
3699
|
+
const LEARNED_FIELD_LABELS = {
|
|
3700
|
+
architecture_instructions: "Architecture instructions",
|
|
3701
|
+
design_principles: "Design principles",
|
|
3702
|
+
review_instructions: "Code review instructions",
|
|
3703
|
+
documentation_instructions: "Documentation instructions",
|
|
3704
|
+
unit_testing_instructions: "Unit testing instructions",
|
|
3705
|
+
e2e_testing_instructions: "End-to-end testing instructions",
|
|
3706
|
+
frontend_correctness_standards: "Front-end code standards",
|
|
3707
|
+
backend_correctness_standards: "Back-end code standards",
|
|
3708
|
+
template_correctness_standards: "Template standards",
|
|
3709
|
+
style_correctness_standards: "Code style standards",
|
|
3710
|
+
};
|
|
3711
|
+
/** A plain label for a learned field identifier; a valid unknown one reads with spaces. */
|
|
3712
|
+
function learnedFieldLabel(name) {
|
|
3713
|
+
return Object.prototype.hasOwnProperty.call(LEARNED_FIELD_LABELS, name)
|
|
3714
|
+
? LEARNED_FIELD_LABELS[name]
|
|
3715
|
+
: name.replace(/_/g, " ");
|
|
3716
|
+
}
|
|
3632
3717
|
/** Print the plain stop for a repository that has not been (fully) learned. */
|
|
3633
|
-
function reportRepositoryNotLearned(deps, fieldsSet) {
|
|
3718
|
+
function reportRepositoryNotLearned(deps, fieldsSet, missingFields = []) {
|
|
3634
3719
|
deps.errorLog(REPOSITORY_NOT_LEARNED_OUTCOME);
|
|
3635
3720
|
deps.errorLog(fieldsSet > 0
|
|
3636
3721
|
? "Bridge has not finished learning this repository."
|
|
3637
3722
|
: "Bridge has not learned this repository yet.");
|
|
3638
3723
|
deps.errorLog(`${fieldsSet > 0 ? "Finish" : "Run"} /learn-repository in Claude Code, wait for it to finish, then run this ` +
|
|
3639
3724
|
"setup again. Bridge needs your project's standards to write useful code.");
|
|
3725
|
+
if (missingFields.length > 0) {
|
|
3726
|
+
deps.errorLog("These instructions are still missing:");
|
|
3727
|
+
for (const name of missingFields)
|
|
3728
|
+
deps.errorLog(` - ${learnedFieldLabel(name)}`);
|
|
3729
|
+
}
|
|
3730
|
+
deps.errorLog("Bridge uses its stored copy of these instructions. Editing local standards files, such as " +
|
|
3731
|
+
"docs/standards/*.md, does not update that copy.");
|
|
3732
|
+
deps.errorLog("To fill in one item by hand instead, use /teach-bridge and explain it in plain words. " +
|
|
3733
|
+
"Then run this setup again.");
|
|
3640
3734
|
}
|
|
3641
3735
|
/**
|
|
3642
3736
|
* Read whether the repository has been learned. Returns `true` only for a
|
|
@@ -3653,7 +3747,10 @@ async function repositoryNotLearned(deps, access) {
|
|
|
3653
3747
|
}
|
|
3654
3748
|
if (learning.learned)
|
|
3655
3749
|
return false;
|
|
3656
|
-
reportRepositoryNotLearned(deps, learning.learned_fields_set);
|
|
3750
|
+
reportRepositoryNotLearned(deps, learning.learned_fields_set, learning.missing_fields);
|
|
3751
|
+
if (learning.missing_fields.length > 0) {
|
|
3752
|
+
deps.installDocumentSink?.({ missingLearnedFields: [...learning.missing_fields] });
|
|
3753
|
+
}
|
|
3657
3754
|
return true;
|
|
3658
3755
|
}
|
|
3659
3756
|
// ---------------------------------------------------------------------------
|
|
@@ -3680,6 +3777,40 @@ async function learnedCommandHints(setup, access) {
|
|
|
3680
3777
|
: candidate.provenance,
|
|
3681
3778
|
}));
|
|
3682
3779
|
}
|
|
3780
|
+
/**
|
|
3781
|
+
* BAPI-1677 — whether a test trial can be offered. The candidates are the ones the
|
|
3782
|
+
* client can see: file detection first, then the repository's local commands, in
|
|
3783
|
+
* their fixed order. With none, no trial is recommended. A failed trial stores
|
|
3784
|
+
* nothing, so it never stops a later offer, and a stored command is never cleared.
|
|
3785
|
+
*/
|
|
3786
|
+
async function resolveTestCommandTrial(deps, setup, access, gatePlan, storedCommand) {
|
|
3787
|
+
const none = { eligible: false, candidates: [] };
|
|
3788
|
+
const inferred = gatePlan.inferred;
|
|
3789
|
+
const storedGateRetry = inferred === undefined && gatePlan.origin === "stored" && gatePlan.current.confirmed &&
|
|
3790
|
+
storedCommand === null && (gatePlan.current.profile?.local_commands.length ?? 0) === 0;
|
|
3791
|
+
if (!storedGateRetry && inferred?.trialEligible !== true)
|
|
3792
|
+
return none;
|
|
3793
|
+
const candidates = [];
|
|
3794
|
+
const add = (candidate) => {
|
|
3795
|
+
if (!candidates.some((c) => c.command === candidate.command))
|
|
3796
|
+
candidates.push(candidate);
|
|
3797
|
+
};
|
|
3798
|
+
if (inferred !== undefined && storedCommand !== null)
|
|
3799
|
+
add({ command: storedCommand, source: "stored configuration" });
|
|
3800
|
+
for (const hint of await learnedCommandHints(setup, access))
|
|
3801
|
+
add(hint);
|
|
3802
|
+
const fs = deps.gate?.discoveryFs;
|
|
3803
|
+
if (fs !== undefined) {
|
|
3804
|
+
try {
|
|
3805
|
+
for (const local of await discoverLocalTestCandidates(fs))
|
|
3806
|
+
add({ command: local.argv.join(" "), source: "repository files" });
|
|
3807
|
+
}
|
|
3808
|
+
catch {
|
|
3809
|
+
// An unreadable file adds no candidate. It is never a stop.
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
return { eligible: candidates.length > 0, candidates };
|
|
3813
|
+
}
|
|
3683
3814
|
/**
|
|
3684
3815
|
* Ask the server for the learned (or the owner's) test command and prove it.
|
|
3685
3816
|
*
|
|
@@ -3700,7 +3831,7 @@ answer) {
|
|
|
3700
3831
|
if (answer !== undefined && (answer.decision === "skip" || answer.decision === "keep"))
|
|
3701
3832
|
return;
|
|
3702
3833
|
const ownerCommand = answer?.decision === "command" ? answer.command : options.testCommand;
|
|
3703
|
-
const automatic = ownerCommand === undefined && gatePlan?.
|
|
3834
|
+
const automatic = ownerCommand === undefined && gatePlan?.testCommandTrial?.eligible === true;
|
|
3704
3835
|
if (ownerCommand === undefined && !automatic)
|
|
3705
3836
|
return;
|
|
3706
3837
|
deps.log("");
|
|
@@ -3719,7 +3850,7 @@ answer) {
|
|
|
3719
3850
|
deps.log(" skipped — the gate and defaults were not stored, so there is no stored gate to attach a proven command to.");
|
|
3720
3851
|
return;
|
|
3721
3852
|
}
|
|
3722
|
-
const candidates = automatic ?
|
|
3853
|
+
const candidates = automatic ? gatePlan?.testCommandTrial?.candidates : undefined;
|
|
3723
3854
|
const io = gateIoFor(deps);
|
|
3724
3855
|
const trialGateDeps = deps.gate !== undefined && deps.progressTimer !== undefined && deps.gate.progressTimer === undefined
|
|
3725
3856
|
? { ...deps.gate, progressTimer: deps.progressTimer }
|
|
@@ -3932,6 +4063,10 @@ setupPrDecision) {
|
|
|
3932
4063
|
}
|
|
3933
4064
|
if (profile === null || !profile.confirmed || profile.profile === null)
|
|
3934
4065
|
return none;
|
|
4066
|
+
// BAPI-1677: the read-back is what the workflow installs, not what discovery found.
|
|
4067
|
+
const sealedChanged = !sameDependencyInstall(profile.profile.dependency_install ?? [], state.sealedDependencyInstall);
|
|
4068
|
+
const sealedDependencyInstall = profile.profile.dependency_install ?? [];
|
|
4069
|
+
state.sealedDependencyInstall = sealedDependencyInstall;
|
|
3935
4070
|
// The command the workflow runs is the one the server proved this run, else the stored one.
|
|
3936
4071
|
let command = state.promotedCommands?.length === 1 ? state.promotedCommands[0].command : null;
|
|
3937
4072
|
if (command === null) {
|
|
@@ -3950,9 +4085,9 @@ setupPrDecision) {
|
|
|
3950
4085
|
state.toolchains = toolchains;
|
|
3951
4086
|
// The first read already assessed the workflow against this very command when no
|
|
3952
4087
|
// trial changed it this run; only a command that may have changed is assessed again.
|
|
3953
|
-
const assessed = state.trial === null && command === state.storedCommand && state.evidence.workflow.state !== "unknown"
|
|
4088
|
+
const assessed = state.trial === null && !sealedChanged && command === state.storedCommand && state.evidence.workflow.state !== "unknown"
|
|
3954
4089
|
? state.evidence.workflow
|
|
3955
|
-
: await assessWorkflow(setup, command, toolchains, state.snapshot, true);
|
|
4090
|
+
: await assessWorkflow(setup, command, toolchains, state.snapshot, true, sealedDependencyInstall);
|
|
3956
4091
|
state.evidence = { ...state.evidence, workflow: assessed };
|
|
3957
4092
|
const localOnly = profile.profile.kind === "local" &&
|
|
3958
4093
|
profile.profile.provider_checks.length === 0 &&
|
|
@@ -3992,7 +4127,7 @@ setupPrDecision) {
|
|
|
3992
4127
|
}
|
|
3993
4128
|
if (!install)
|
|
3994
4129
|
return setupPrDecision === "decline" ? { status: "declined" } : none;
|
|
3995
|
-
const outcome = await fixSetupPullRequest(deps, setup, command, toolchains, state.snapshot, state.repository, setupPrDecision === undefined ? undefined : setupPrDecision === "approve");
|
|
4130
|
+
const outcome = await fixSetupPullRequest(deps, setup, command, toolchains, state.snapshot, state.repository, setupPrDecision === undefined ? undefined : setupPrDecision === "approve", sealedDependencyInstall);
|
|
3996
4131
|
state.evidence = { ...state.evidence, workflow: outcome.workflow };
|
|
3997
4132
|
const result = outcome.result;
|
|
3998
4133
|
const opened = result !== null &&
|
|
@@ -4053,7 +4188,7 @@ function renderDryRunCiPlan(deps, options, gatePlan) {
|
|
|
4053
4188
|
deps.log(" Test command: a real run offers your --test-command to Bridge's server and proves it by running it once on " +
|
|
4054
4189
|
"this computer. Dry run requested nothing and started nothing.");
|
|
4055
4190
|
}
|
|
4056
|
-
else if (gatePlan?.
|
|
4191
|
+
else if (gatePlan?.testCommandTrial?.eligible === true) {
|
|
4057
4192
|
deps.log(" Test command: a real run asks Bridge's server to learn it from this repository and proves it by running it " +
|
|
4058
4193
|
"once on this computer, and nobody is asked for it. Dry run requested nothing and started nothing.");
|
|
4059
4194
|
}
|
|
@@ -4191,7 +4326,7 @@ async function collectCiOffer(input) {
|
|
|
4191
4326
|
const managed = await managedWorkflowIdentity(input, "absent");
|
|
4192
4327
|
if (managed !== null) {
|
|
4193
4328
|
evidence.ciOffer = { identity: managed.identity, applicable: true };
|
|
4194
|
-
return { evidence, delivery: { kind: "managed_workflow", command: managed.command, toolchains: managed.toolchains } };
|
|
4329
|
+
return { evidence, delivery: { kind: "managed_workflow", command: managed.command, toolchains: managed.toolchains, dependencyInstall: input.dependencyInstall ?? [] } };
|
|
4195
4330
|
}
|
|
4196
4331
|
return { evidence, delivery: null };
|
|
4197
4332
|
}
|
|
@@ -4228,7 +4363,8 @@ async function managedWorkflowIdentity(input, wanted) {
|
|
|
4228
4363
|
return null;
|
|
4229
4364
|
let rendered;
|
|
4230
4365
|
try {
|
|
4231
|
-
|
|
4366
|
+
// The same entries are delivered, so the approved hash matches the delivered bytes.
|
|
4367
|
+
rendered = renderEpicImplementerCiWorkflow(command, resolution.toolchains, input.dependencyInstall ?? []);
|
|
4232
4368
|
}
|
|
4233
4369
|
catch {
|
|
4234
4370
|
return null;
|
|
@@ -4272,7 +4408,22 @@ async function collectDecisionEvidence(input) {
|
|
|
4272
4408
|
currentKind: gatePlan.current.profile?.kind ?? null,
|
|
4273
4409
|
};
|
|
4274
4410
|
const stored = gatePlan?.current.profile ?? null;
|
|
4275
|
-
const
|
|
4411
|
+
const installFacts = input.dependencyInstallFacts ?? null;
|
|
4412
|
+
const installDetails = installFacts === null ? undefined : dependencyInstallDetails({
|
|
4413
|
+
commands: input.correctedDependencyInstall === true ? input.effectiveDependencyInstall ?? [] : installFacts.planned,
|
|
4414
|
+
stored: installFacts.stored,
|
|
4415
|
+
differs: input.correctedDependencyInstall === true || installFacts.drift !== "same",
|
|
4416
|
+
evidence: input.correctedDependencyInstall === true ? [] : installFacts.evidence,
|
|
4417
|
+
limitations: installFacts.limitations,
|
|
4418
|
+
});
|
|
4419
|
+
const declarations = input.declarationPlan.map((entry) => ({
|
|
4420
|
+
key: entry.key,
|
|
4421
|
+
summary: entry.summary,
|
|
4422
|
+
value: declarationValue(entry.fields),
|
|
4423
|
+
...(entry.key === "dependency_install" && installFacts !== null
|
|
4424
|
+
? { recommendDecline: installFacts.drift === "replacing", ...(installDetails !== undefined ? { dependencyInstall: installDetails } : {}) }
|
|
4425
|
+
: {}),
|
|
4426
|
+
}));
|
|
4276
4427
|
// A settled declaration still names its stored value, so a replay hashes the same.
|
|
4277
4428
|
for (const [key, value] of [
|
|
4278
4429
|
["dependency_install", stored?.dependency_install],
|
|
@@ -4281,11 +4432,19 @@ async function collectDecisionEvidence(input) {
|
|
|
4281
4432
|
["worker_database", stored?.worker_database],
|
|
4282
4433
|
]) {
|
|
4283
4434
|
const empty = value === undefined || value === null || (Array.isArray(value) && value.length === 0) || value === "unknown";
|
|
4284
|
-
if (!empty && !declarations.some((d) => d.key === key))
|
|
4285
|
-
declarations.push({
|
|
4435
|
+
if (!empty && !declarations.some((d) => d.key === key)) {
|
|
4436
|
+
declarations.push({
|
|
4437
|
+
key, summary: [], value: declarationValue({ [declarationField(key)]: value }), applicable: false,
|
|
4438
|
+
...(key === "dependency_install" && installDetails !== undefined ? { dependencyInstall: installDetails } : {}),
|
|
4439
|
+
});
|
|
4440
|
+
}
|
|
4441
|
+
}
|
|
4442
|
+
// Nothing stored and nothing on offer can still have something to say, such as a failed read.
|
|
4443
|
+
if (installDetails !== undefined && !declarations.some((d) => d.key === "dependency_install") && installDetails.limitations.length > 0) {
|
|
4444
|
+
declarations.push({ key: "dependency_install", summary: [], value: null, applicable: false, dependencyInstall: installDetails });
|
|
4286
4445
|
}
|
|
4287
4446
|
const workflowState = state.evidence.workflow.state;
|
|
4288
|
-
const trialEligible = gatePlan?.
|
|
4447
|
+
const trialEligible = gatePlan?.testCommandTrial?.eligible === true;
|
|
4289
4448
|
const recovery = state.evidence.recovery?.supported ? state.evidence.recovery.evidence : undefined;
|
|
4290
4449
|
const branchQuestion = fixes.includes("reindex") && recovery !== undefined && recovery.destination_branch
|
|
4291
4450
|
&& (!["equal", "contains_target"].includes(recovery.configured_relation) || recovery.canonical_relation === "diverged")
|
|
@@ -4297,10 +4456,12 @@ async function collectDecisionEvidence(input) {
|
|
|
4297
4456
|
? { requestId: recovery.request.id, generation: recovery.retry_generation }
|
|
4298
4457
|
: undefined;
|
|
4299
4458
|
const label = (origin) => CANDIDATE_ORIGIN_LABEL[origin];
|
|
4459
|
+
const epicServerSnapshot = input.epicServerSnapshot ?? null;
|
|
4460
|
+
const sfccGrant = new Set(sfccGrantIds(epicServerSnapshot, grantInventory));
|
|
4300
4461
|
const mcpGrant = grantInventory === null ? null : {
|
|
4301
4462
|
current: state.evidence.mcpGrant?.state === "needs_action" ? state.evidence.mcpGrant.reason : state.evidence.mcpGrant?.state ?? "unknown",
|
|
4302
4463
|
applicable: fixes.includes("mcp_grant"),
|
|
4303
|
-
candidates: grantInventory.candidates.flatMap((c) => c.definitions.map((d) => ({ id: d.id, name: c.name, origins: d.origins.map(label) }))),
|
|
4464
|
+
candidates: grantInventory.candidates.flatMap((c) => c.definitions.map((d) => ({ id: d.id, name: c.name, origins: d.origins.map(label), ...(sfccGrant.has(d.id) ? { sfcc_recommended: true } : {}) }))),
|
|
4304
4465
|
excluded: grantInventory.exclusions.map((e) => ({ name: e.name, origin: label(e.origin), reason: CANDIDATE_EXCLUSION_TEXT[e.reason] })),
|
|
4305
4466
|
invalidExisting: grantInventory.existingGrant?.state === "ok"
|
|
4306
4467
|
? grantInventory.existingGrant.findings.map((f) => ({ name: f.name, reason: CANDIDATE_EXCLUSION_TEXT[f.reason] }))
|
|
@@ -4314,7 +4475,12 @@ async function collectDecisionEvidence(input) {
|
|
|
4314
4475
|
identity,
|
|
4315
4476
|
gate,
|
|
4316
4477
|
declarations,
|
|
4317
|
-
testCommand: {
|
|
4478
|
+
testCommand: {
|
|
4479
|
+
stored: state.storedCommand !== null,
|
|
4480
|
+
trialEligible,
|
|
4481
|
+
candidate: gatePlan?.testCommandTrial?.candidates[0]?.command ?? null,
|
|
4482
|
+
ownerCommandSupplied: options.testCommand !== undefined,
|
|
4483
|
+
},
|
|
4318
4484
|
setupPr: {
|
|
4319
4485
|
applicable: setupPrOffersWorkflow(input),
|
|
4320
4486
|
workflowState,
|
|
@@ -4331,10 +4497,7 @@ async function collectDecisionEvidence(input) {
|
|
|
4331
4497
|
...(branchQuestion ? { branchQuestion } : {}), ...(retryQuestion ? { retryQuestion } : {}),
|
|
4332
4498
|
},
|
|
4333
4499
|
mcpGrant,
|
|
4334
|
-
epicServer: epicServerEvidence === undefined ? null :
|
|
4335
|
-
current: epicServerEvidence.state === "met" ? epicServerEvidence.mode : null,
|
|
4336
|
-
applicable: fixes.includes("epic_server"),
|
|
4337
|
-
},
|
|
4500
|
+
epicServer: epicServerEvidence === undefined ? null : epicServerDecisionEvidence(epicServerEvidence.state === "met" ? epicServerEvidence.mode : null, fixes.includes("epic_server"), epicServerSnapshot, epicServerSnapshot?.existingSandbox !== null && epicServerSnapshot?.existingSandbox !== undefined),
|
|
4338
4501
|
// The decision readiness reports as recorded is shown on the choice only; it never sets
|
|
4339
4502
|
// `recommended` or `applicable`, so it cannot move a digest.
|
|
4340
4503
|
epicBranchCi: collected === undefined || collected.status === "skipped_no_seams" ? null : {
|
|
@@ -4351,6 +4514,17 @@ async function collectDecisionEvidence(input) {
|
|
|
4351
4514
|
...(state.ciSystems !== undefined
|
|
4352
4515
|
? { ci_systems: state.ciSystems === null ? null : state.ciSystems.map((c) => ({ name: c.name, path: c.path })) }
|
|
4353
4516
|
: {}),
|
|
4517
|
+
// BAPI-1667: from the same snapshot, so nothing is read or checked a second time.
|
|
4518
|
+
...(epicServerSnapshot?.detection !== null && epicServerSnapshot?.detection !== undefined
|
|
4519
|
+
? {
|
|
4520
|
+
sfcc: {
|
|
4521
|
+
detected: epicServerSnapshot.detection.detected,
|
|
4522
|
+
signals: epicServerSnapshot.detection.signals,
|
|
4523
|
+
dev_script: epicServerSnapshot.detection.dev_script,
|
|
4524
|
+
upload_check: epicServerSnapshot.uploadCheck,
|
|
4525
|
+
},
|
|
4526
|
+
}
|
|
4527
|
+
: {}),
|
|
4354
4528
|
},
|
|
4355
4529
|
};
|
|
4356
4530
|
}
|
|
@@ -4363,7 +4537,7 @@ async function collectDecisionEvidence(input) {
|
|
|
4363
4537
|
function setupPrOffersWorkflow(input) {
|
|
4364
4538
|
const { options, gatePlan, state, fixes } = input;
|
|
4365
4539
|
const workflowState = state.evidence.workflow.state;
|
|
4366
|
-
const trialEligible = gatePlan?.
|
|
4540
|
+
const trialEligible = gatePlan?.testCommandTrial?.eligible === true;
|
|
4367
4541
|
return state.evidence.githubSignIn === "signed_in" && state.repository !== null
|
|
4368
4542
|
&& (fixes.includes("setup_pr") || (trialEligible && gatePlan?.inferred?.ciPlan === "none" && !hasExplicitGateInput(options.gate)
|
|
4369
4543
|
&& (workflowState === "absent" || workflowState === "unknown")));
|
|
@@ -4434,6 +4608,41 @@ async function collectRepositoryFacts(deps, grantInventory, readToolchains) {
|
|
|
4434
4608
|
}
|
|
4435
4609
|
return { ci_workflows: ciWorkflows, package_manager: packageManager, mcp_configs: mcpConfigs };
|
|
4436
4610
|
}
|
|
4611
|
+
/**
|
|
4612
|
+
* BAPI-1677 — one plain note when the default branch, which a workflow is committed
|
|
4613
|
+
* onto, lacks a named lockfile or a kept extra. Only a file proven absent counts: an
|
|
4614
|
+
* unreadable one is unknown. A note changes nothing and stops nothing.
|
|
4615
|
+
*/
|
|
4616
|
+
async function defaultBranchInstallNote(setup, snapshot, facts) {
|
|
4617
|
+
const read = setup.readSnapshotFile;
|
|
4618
|
+
if (snapshot === null || read === undefined)
|
|
4619
|
+
return null;
|
|
4620
|
+
const textOf = async (relPath) => {
|
|
4621
|
+
try {
|
|
4622
|
+
return await read(snapshot, relPath);
|
|
4623
|
+
}
|
|
4624
|
+
catch (err) {
|
|
4625
|
+
return err?.code === "ENOENT" ? null : undefined;
|
|
4626
|
+
}
|
|
4627
|
+
};
|
|
4628
|
+
const lacking = "Your default branch does not have everything these install commands use yet, so CI could fail there until it does.";
|
|
4629
|
+
for (const entry of facts.planned) {
|
|
4630
|
+
for (const lockfile of entry.lockfiles) {
|
|
4631
|
+
if ((await textOf(lockfile)) === null)
|
|
4632
|
+
return lacking;
|
|
4633
|
+
}
|
|
4634
|
+
}
|
|
4635
|
+
if (facts.evidence.length === 0)
|
|
4636
|
+
return null;
|
|
4637
|
+
const pyproject = await textOf(pyprojectPathFor("."));
|
|
4638
|
+
if (typeof pyproject !== "string")
|
|
4639
|
+
return pyproject === null ? lacking : null;
|
|
4640
|
+
const manager = facts.planned.some((e) => e.argv[0] === "poetry") ? "poetry" : "uv";
|
|
4641
|
+
const declared = scanDeclaredExtras(pyproject, manager);
|
|
4642
|
+
if (declared.status !== "known")
|
|
4643
|
+
return null;
|
|
4644
|
+
return facts.evidence.every((e) => declared.extras.includes(e.extra)) ? null : lacking;
|
|
4645
|
+
}
|
|
4437
4646
|
/** Merge the approved declarations into the gate plan, rebuilding its PUT from the same desired gate. */
|
|
4438
4647
|
function applyApprovedDeclarations(plan, approved) {
|
|
4439
4648
|
if (approved.length === 0)
|
|
@@ -4448,7 +4657,9 @@ function settledGateResults(proposal) {
|
|
|
4448
4657
|
.map((a) => ({ key: a.key, status: "unchanged", target: a.effect?.target ?? "repository_gate" }));
|
|
4449
4658
|
}
|
|
4450
4659
|
const DECLARATION_KEYS = ["dependency_install", "ci_database", "must_order_paths", "worker_database"];
|
|
4451
|
-
function gateWriteResults(result, proposal, plan
|
|
4660
|
+
function gateWriteResults(result, proposal, plan,
|
|
4661
|
+
/** BAPI-1677 — the install commands read back after the write; `null` when they could not be confirmed. */
|
|
4662
|
+
installReadBack) {
|
|
4452
4663
|
const readBack = result.current !== undefined ? { revision: result.current.state.revision } : undefined;
|
|
4453
4664
|
const status = result.status === "completed" ? "written"
|
|
4454
4665
|
: result.status === "unchanged" ? "unchanged"
|
|
@@ -4466,12 +4677,16 @@ function gateWriteResults(result, proposal, plan) {
|
|
|
4466
4677
|
return [gate];
|
|
4467
4678
|
const declarations = plan.map((entry) => {
|
|
4468
4679
|
const decision = decisionFor(proposal, entry.key);
|
|
4469
|
-
const approved = decision?.kind === "option" && decision.option === "approve";
|
|
4680
|
+
const approved = (decision?.kind === "option" && decision.option === "approve") || decision?.kind === "dependency_install_entries";
|
|
4681
|
+
const inPlace = status === "written" || status === "unchanged";
|
|
4682
|
+
const install = approved && entry.key === "dependency_install" && inPlace && installReadBack !== undefined;
|
|
4470
4683
|
return {
|
|
4471
4684
|
key: entry.key,
|
|
4472
|
-
status: !approved ? "declined" : status === "declined" ? "unattempted" : status,
|
|
4685
|
+
status: !approved ? "declined" : status === "declined" ? "unattempted" : install && installReadBack === null ? "uncertain" : status,
|
|
4473
4686
|
target: `repository_gate.${entry.key}`,
|
|
4474
4687
|
...(approved && status === "declined" ? { reason: "the gate it is stored with was declined" } : {}),
|
|
4688
|
+
...(install && installReadBack === null ? { reason: "the install commands could not be read back after the write", fix: "Read the gate with `epic-implementer doctor` before retrying." } : {}),
|
|
4689
|
+
...(install && installReadBack !== null ? { read_back: { commands: installReadBack ?? [] } } : {}),
|
|
4475
4690
|
};
|
|
4476
4691
|
});
|
|
4477
4692
|
return [gate, ...declarations];
|
|
@@ -4523,7 +4738,7 @@ export function trialWriteResult(trial, asked, launcher) {
|
|
|
4523
4738
|
fix: `Child pull requests merge into the epic branch without a test gate. In your own terminal, run \`${launcher ?? NPM_SETUP_LAUNCHER.base} install epic-implementer --test-command "<your command>"\` with your test command.`,
|
|
4524
4739
|
};
|
|
4525
4740
|
case "promoted":
|
|
4526
|
-
return { key: "test_command", status: "written", target, phase, read_back: { commands: trial.commands.map((c) => c.name) } };
|
|
4741
|
+
return { key: "test_command", status: "written", target, phase, read_back: { commands: trial.commands.map((c) => c.name), ran: trial.commands.map((c) => c.command) } };
|
|
4527
4742
|
case "not_needed":
|
|
4528
4743
|
return { key: "test_command", status: "unchanged", target };
|
|
4529
4744
|
case "uncertain":
|
|
@@ -4536,8 +4751,13 @@ export function trialWriteResult(trial, asked, launcher) {
|
|
|
4536
4751
|
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`." };
|
|
4537
4752
|
}
|
|
4538
4753
|
}
|
|
4539
|
-
function workflowWriteResult(outcome, asked) {
|
|
4754
|
+
export function workflowWriteResult(outcome, asked, decision) {
|
|
4540
4755
|
const target = "github.default_branch";
|
|
4756
|
+
// BAPI-1678: the owner's decline stands, whatever the phase found to do. A write or a
|
|
4757
|
+
// failure that really happened still reports as itself below.
|
|
4758
|
+
if (decision === "decline" && (outcome.status === "none" || outcome.status === "unchanged")) {
|
|
4759
|
+
return { key: "setup_pr", status: "declined", target };
|
|
4760
|
+
}
|
|
4541
4761
|
switch (outcome.status) {
|
|
4542
4762
|
case "none":
|
|
4543
4763
|
return asked ? { key: "setup_pr", status: "unchanged", target, reason: "no setup pull request was needed" } : null;
|
|
@@ -4552,9 +4772,12 @@ function workflowWriteResult(outcome, asked) {
|
|
|
4552
4772
|
}
|
|
4553
4773
|
}
|
|
4554
4774
|
function fixOutcomeResult(key, target, outcome) {
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4775
|
+
if (outcome.status === "failed") {
|
|
4776
|
+
return { key, status: "failed", target, reason: outcome.reason, fix: "Fix the cause above, then rerun setup with the same answers." };
|
|
4777
|
+
}
|
|
4778
|
+
// BAPI-1667: fixed advisory text only. It reports; it never changes the status.
|
|
4779
|
+
const advisories = [...new Set(outcome.advisories ?? [])];
|
|
4780
|
+
return { key, status: outcome.status, target, ...(advisories.length > 0 ? { reason: advisories.join(" ") } : {}) };
|
|
4558
4781
|
}
|
|
4559
4782
|
function indexProgress(index) {
|
|
4560
4783
|
if (index.state === "reached")
|
|
@@ -4578,23 +4801,42 @@ function reindexWriteResult(index) {
|
|
|
4578
4801
|
}
|
|
4579
4802
|
return { key: "reindex", status: "uncertain", target, reason: "the index state could not be read", fix: "Rerun setup to read it again." };
|
|
4580
4803
|
}
|
|
4581
|
-
/**
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4804
|
+
/**
|
|
4805
|
+
* The approved epic-server answer as a record. A local mode records whether guidance
|
|
4806
|
+
* is present. BAPI-1667: a plain `local` or `none` keeps an approved sandbox, because
|
|
4807
|
+
* upload needs it in every mode; only a structured answer replaces it. An entered
|
|
4808
|
+
* sandbox id is re-checked, and a mismatch only adds an advisory.
|
|
4809
|
+
*/
|
|
4810
|
+
export async function epicServerAnswer(epicDeps, d, snapshot = null) {
|
|
4811
|
+
const recipeOf = async () => {
|
|
4588
4812
|
try {
|
|
4589
|
-
|
|
4813
|
+
return (await epicDeps.guidancePresent()) ? "present" : "absent";
|
|
4590
4814
|
}
|
|
4591
4815
|
catch {
|
|
4592
|
-
|
|
4816
|
+
return "absent";
|
|
4593
4817
|
}
|
|
4594
|
-
|
|
4818
|
+
};
|
|
4819
|
+
const kept = snapshot?.existingSandbox ?? null;
|
|
4820
|
+
if (d.kind === "epic_server_sfcc") {
|
|
4821
|
+
const { mode, sandbox_id, credential_ref, storefront_origin } = d.value;
|
|
4822
|
+
const check = epicDeps.sfccUploadCheck;
|
|
4823
|
+
const credentials = snapshot?.credentials ?? null;
|
|
4824
|
+
const mismatch = snapshot?.detection?.detected === true && check !== undefined
|
|
4825
|
+
? await recheckSfccSandboxId(check, sandbox_id, { credentials })
|
|
4826
|
+
: [];
|
|
4827
|
+
const sfcc = { sandbox_id, credential_ref, ...(storefront_origin !== undefined ? { storefront_origin } : {}) };
|
|
4828
|
+
return {
|
|
4829
|
+
decision: "record",
|
|
4830
|
+
record: { version: 1, mode, ...(mode === "local" ? { recipe: await recipeOf() } : {}), sfcc },
|
|
4831
|
+
advisories: [...mismatch, ...credentialReferenceAdvisories(credentials, credential_ref)],
|
|
4832
|
+
};
|
|
4833
|
+
}
|
|
4834
|
+
if (d.kind === "option" && d.option === "local") {
|
|
4835
|
+
return { decision: "record", record: { version: 1, mode: "local", recipe: await recipeOf(), ...(kept !== null ? { sfcc: kept } : {}) } };
|
|
4836
|
+
}
|
|
4837
|
+
if (d.kind === "option" && d.option === "none") {
|
|
4838
|
+
return { decision: "record", record: { version: 1, mode: "none", ...(kept !== null ? { sfcc: kept } : {}) } };
|
|
4595
4839
|
}
|
|
4596
|
-
if (d.kind === "option" && d.option === "none")
|
|
4597
|
-
return { decision: "record", record: { version: 1, mode: "none" } };
|
|
4598
4840
|
return { decision: "keep" };
|
|
4599
4841
|
}
|
|
4600
4842
|
/**
|
|
@@ -4635,7 +4877,7 @@ function ciChangeWriteResult(actionClass, target, result) {
|
|
|
4635
4877
|
return { key, status: "failed", target, reason: `the CI pull request could not be opened (${result.reason.replace(/_/g, " ")})`, fix: result.remediation };
|
|
4636
4878
|
}
|
|
4637
4879
|
}
|
|
4638
|
-
function epicBranchWriteResults(step, report) {
|
|
4880
|
+
function epicBranchWriteResults(step, report, note) {
|
|
4639
4881
|
if (!report)
|
|
4640
4882
|
return null;
|
|
4641
4883
|
const results = [];
|
|
@@ -4644,16 +4886,11 @@ function epicBranchWriteResults(step, report) {
|
|
|
4644
4886
|
results.push(step.decision === null
|
|
4645
4887
|
? { key: "epic_branch_ci", status: "declined", target: "epic_branch_ci", reason: "no decision was recorded; runs behave as include" }
|
|
4646
4888
|
: step.recorded
|
|
4647
|
-
? { key: "epic_branch_ci", status: step.unchanged ? "unchanged" : "written", target: "epic_branch_ci", read_back: { decision: step.decision } }
|
|
4889
|
+
? { key: "epic_branch_ci", status: step.unchanged ? "unchanged" : "written", target: "epic_branch_ci", read_back: { decision: step.decision }, ...(note !== undefined ? { reason: note } : {}) }
|
|
4648
4890
|
: { key: "epic_branch_ci", status: "failed", target: "epic_branch_ci", reason: "the decision could not be recorded", fix: step.manualAction ?? "Rerun setup." });
|
|
4649
4891
|
const outcome = step.exemptionOutcome;
|
|
4650
4892
|
if (outcome !== null) {
|
|
4651
|
-
results.push(outcome
|
|
4652
|
-
: outcome === "declined" ? { key: "approval_exemption", status: "declined", target: "github.rulesets" }
|
|
4653
|
-
: outcome === "not_needed" ? { key: "approval_exemption", status: "unchanged", target: "github.rulesets" }
|
|
4654
|
-
: outcome === "could_not_tell"
|
|
4655
|
-
? { key: "approval_exemption", status: "uncertain", target: "github.rulesets", reason: "the ruleset change could not be confirmed", fix: "Check the ruleset yourself; setup will not retry it blindly." }
|
|
4656
|
-
: { key: "approval_exemption", status: "refused", target: "github.rulesets", reason: "the approval rule is not safe to change automatically", fix: "Follow the manual steps printed above." });
|
|
4893
|
+
results.push(mapExemptionOutcomeToWriteResult(outcome));
|
|
4657
4894
|
}
|
|
4658
4895
|
return results;
|
|
4659
4896
|
}
|
|
@@ -4802,6 +5039,15 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
4802
5039
|
// BAPI-1638: the answers path plans the gate without a terminal, so no discovered
|
|
4803
5040
|
// declaration joins it unless its own answer approves it below.
|
|
4804
5041
|
const planIo = options.answers !== undefined ? { ...gateIo, isTTY: false, promptLine: undefined } : gateIo;
|
|
5042
|
+
// BAPI-1677: one read of the learned text per run, shared by everything that needs it.
|
|
5043
|
+
if (deps.gate !== undefined && deps.gate.learnedInstructions === undefined) {
|
|
5044
|
+
let learned;
|
|
5045
|
+
const readLearned = () => {
|
|
5046
|
+
learned ??= readLearnedInstructions(setup.testingConfig(access)).catch(() => null);
|
|
5047
|
+
return learned;
|
|
5048
|
+
};
|
|
5049
|
+
deps = { ...deps, gate: { ...deps.gate, learnedInstructions: readLearned } };
|
|
5050
|
+
}
|
|
4805
5051
|
const gatePhase = await resolveConductorGate(planIo, access, options.gate, deps.gate, {
|
|
4806
5052
|
dryRun: options.dryRun,
|
|
4807
5053
|
planningOnly: true,
|
|
@@ -4819,7 +5065,8 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
4819
5065
|
const setupPath = collectDecisions ? "agent" : "terminal";
|
|
4820
5066
|
// BAPI-1657: the gate plan is resolved above, so its planned write is known before any setup item is projected.
|
|
4821
5067
|
const plannedGateWrite = gatePlan !== null && gatePlan.write !== null;
|
|
4822
|
-
const
|
|
5068
|
+
const storedDependencyInstall = gatePlan?.current.profile?.dependency_install ?? [];
|
|
5069
|
+
const collectInputs = { claudeLoggedIn, githubSignIn, localRemote, snapshot, readToolchains, gateRequiresManagedCheck, plannedGateWrite, path: setupPath, dependencyInstall: storedDependencyInstall };
|
|
4823
5070
|
const first = await progress("checking readiness", () => collectSetupEvidence(deps, setup, access, firstReport.readiness, { ...collectInputs, advisories }));
|
|
4824
5071
|
const state = {
|
|
4825
5072
|
evidence: first.evidence,
|
|
@@ -4833,7 +5080,11 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
4833
5080
|
trial: null,
|
|
4834
5081
|
promotedCommands: null,
|
|
4835
5082
|
failedOperations: [],
|
|
5083
|
+
sealedDependencyInstall: storedDependencyInstall,
|
|
4836
5084
|
};
|
|
5085
|
+
// BAPI-1677: whether a test trial can be offered, known before anything reads it.
|
|
5086
|
+
if (gatePlan !== null)
|
|
5087
|
+
gatePlan.testCommandTrial = await resolveTestCommandTrial(deps, setup, access, gatePlan, state.storedCommand);
|
|
4837
5088
|
// BAPI-1654: which CI systems the repository's files configure, read-only, independent of the remote host.
|
|
4838
5089
|
if (deps.gate?.discoveryFs !== undefined) {
|
|
4839
5090
|
const detected = await detectCiSystems(deps.gate.discoveryFs);
|
|
@@ -4875,24 +5126,52 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
4875
5126
|
...(options.epicServerChange === true ? { epicServerChangeRequested: true } : {}),
|
|
4876
5127
|
};
|
|
4877
5128
|
const fixes = planSetupFixes(state.evidence, planContext);
|
|
5129
|
+
// BAPI-1667: one read-only snapshot for both setup paths. An ordinary interactive run
|
|
5130
|
+
// reads it only when it will ask a question that uses it.
|
|
5131
|
+
const epicServerSnapshot = setup.epicServer !== undefined && (collectDecisions || fixes.includes("epic_server") || fixes.includes("mcp_grant"))
|
|
5132
|
+
? await collectEpicServerSnapshot(deps, setup.epicServer, access.repoName, grantInventory)
|
|
5133
|
+
: null;
|
|
4878
5134
|
// ---- BAPI-1638: the decision evidence behind every open choice (read-only) ----
|
|
4879
5135
|
// Collected for `--json` and `--answers` only: an ordinary interactive run asks at
|
|
4880
5136
|
// each decision point exactly as before and needs no catalog.
|
|
4881
5137
|
const epicBranchCiWanted = options.epicBranchCiDecision !== undefined || deps.gate?.epicBranchCi !== undefined;
|
|
4882
5138
|
const epicBranchCollected = collectDecisions && epicBranchCiWanted ? await collectEpicBranchCi(deps.gate) : undefined;
|
|
4883
|
-
const
|
|
4884
|
-
? await
|
|
4885
|
-
: [];
|
|
5139
|
+
const declarationPlanning = collectDecisions && gatePlan !== null
|
|
5140
|
+
? await planDeclarations(gatePlan.current, gatePlan.desired, deps.gate)
|
|
5141
|
+
: { entries: [], dependencyInstall: null };
|
|
5142
|
+
const declarationPlan = declarationPlanning.entries;
|
|
5143
|
+
// BAPI-1677: the install answer is resolved here, before anything hashes the workflow,
|
|
5144
|
+
// so the approved hash and the delivered bytes come from one list. A refused value
|
|
5145
|
+
// reads as no answer; normalization refuses the whole file below.
|
|
5146
|
+
const dependencyAnswerParsed = answersEnvelope !== null && answersEnvelope.dependency_install !== undefined
|
|
5147
|
+
? parseAnswerValue("dependency_install", answersEnvelope.dependency_install)
|
|
5148
|
+
: null;
|
|
5149
|
+
const dependencyCorrection = dependencyAnswerParsed?.ok === true && dependencyAnswerParsed.decision.kind === "dependency_install_entries"
|
|
5150
|
+
? dependencyAnswerParsed.decision.entries
|
|
5151
|
+
: null;
|
|
5152
|
+
const effectiveDependencyInstall = resolveEffectiveDependencyInstall(declarationPlanning.dependencyInstall, storedDependencyInstall, dependencyCorrection !== null
|
|
5153
|
+
? { entries: dependencyCorrection }
|
|
5154
|
+
: dependencyAnswerParsed?.ok === true ? answersEnvelope?.dependency_install : undefined);
|
|
5155
|
+
if (declarationPlanning.dependencyInstall !== null) {
|
|
5156
|
+
const note = await defaultBranchInstallNote(setup, state.snapshot, declarationPlanning.dependencyInstall);
|
|
5157
|
+
if (note !== null)
|
|
5158
|
+
declarationPlanning.dependencyInstall.limitations.push(note);
|
|
5159
|
+
if (parseDependencyInstallStrict(effectiveDependencyInstall) === null) {
|
|
5160
|
+
declarationPlanning.dependencyInstall.limitations.push("Bridge will not offer its CI workflow, because an install command cannot be written into it safely.");
|
|
5161
|
+
}
|
|
5162
|
+
}
|
|
4886
5163
|
// BAPI-1654: the one CI change on offer, from the default-branch snapshot (read-only).
|
|
4887
5164
|
const ciOfferCollection = collectDecisions && epicBranchCollected !== undefined
|
|
4888
5165
|
? await collectCiOffer({
|
|
4889
|
-
setup, state, collected: epicBranchCollected, readToolchains,
|
|
5166
|
+
setup, state, collected: epicBranchCollected, readToolchains, dependencyInstall: effectiveDependencyInstall,
|
|
4890
5167
|
})
|
|
4891
5168
|
: null;
|
|
4892
5169
|
const decisionEvidence = collectDecisions
|
|
4893
5170
|
? await collectDecisionEvidence({
|
|
4894
5171
|
deps, options, access, gatePlan, state, fixes, grantInventory, firstReport,
|
|
4895
|
-
declarationPlan, epicBranchCollected, readToolchains, firstItems, ciOffer: ciOfferCollection,
|
|
5172
|
+
declarationPlan, epicBranchCollected, readToolchains, firstItems, ciOffer: ciOfferCollection, epicServerSnapshot,
|
|
5173
|
+
dependencyInstallFacts: declarationPlanning.dependencyInstall, effectiveDependencyInstall,
|
|
5174
|
+
correctedDependencyInstall: dependencyCorrection !== null,
|
|
4896
5175
|
})
|
|
4897
5176
|
: null;
|
|
4898
5177
|
const choices = decisionEvidence === null ? [] : buildInstallChoices(decisionEvidence);
|
|
@@ -4921,6 +5200,9 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
4921
5200
|
items: firstItems,
|
|
4922
5201
|
decisions: decisionEvidence,
|
|
4923
5202
|
choices: normalized.choices,
|
|
5203
|
+
...(normalized.proposal !== undefined
|
|
5204
|
+
? { proposalPresentation: plannedPresentation(normalized.proposal, gatePlan, fixes.includes("gate_and_defaults"), decisionEvidence.gate?.consequence ?? "", firstReport.readiness ?? null, state.evidence) }
|
|
5205
|
+
: {}),
|
|
4924
5206
|
...(normalized.proposal !== undefined ? { proposal: normalized.proposal } : {}),
|
|
4925
5207
|
...(normalized.digest !== undefined ? { digest: normalized.digest } : {}),
|
|
4926
5208
|
...(!normalized.ok ? { refusal: normalized.refusal } : {}),
|
|
@@ -5032,14 +5314,23 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5032
5314
|
};
|
|
5033
5315
|
// BAPI-1659: whether the setup pull request really opened this run. Only then may a declined CI
|
|
5034
5316
|
// change say the workflow still arrives through it; an approved answer alone proves nothing.
|
|
5035
|
-
|
|
5317
|
+
// BAPI-1679: `opened` covers a pull request this run opened or found already open, and
|
|
5318
|
+
// `in_place` a workflow already identical on the default branch. A rerun must not read either as nothing.
|
|
5319
|
+
let setupWorkflowDelivery = "none";
|
|
5036
5320
|
const operations = [
|
|
5037
5321
|
{
|
|
5038
5322
|
key: "gate",
|
|
5039
5323
|
run: async () => {
|
|
5040
5324
|
if (gatePlan === null)
|
|
5041
5325
|
return null;
|
|
5042
|
-
|
|
5326
|
+
// BAPI-1677: a correction replaces the planned list before the PUT is built. It is
|
|
5327
|
+
// validated already, and it never merges with what discovery found.
|
|
5328
|
+
const corrected = answerOf("dependency_install");
|
|
5329
|
+
const correctionEntry = corrected?.kind === "dependency_install_entries"
|
|
5330
|
+
? { key: "dependency_install", proposalKeys: [], fields: { dependencyInstall: corrected.entries }, summary: [] }
|
|
5331
|
+
: null;
|
|
5332
|
+
const resultPlan = correctionEntry === null ? declarationPlan : [...declarationPlan.filter((e) => e.key !== "dependency_install"), correctionEntry];
|
|
5333
|
+
const approvedDeclarations = proposal === null ? [] : resultPlan.filter((e) => optionOf(e.key) === "approve" || e === correctionEntry);
|
|
5043
5334
|
const gateOpen = fixes.includes("gate_and_defaults");
|
|
5044
5335
|
if (!gateOpen && approvedDeclarations.length === 0) {
|
|
5045
5336
|
if (proposal === null)
|
|
@@ -5049,7 +5340,23 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5049
5340
|
const gateAnswer = proposal === null ? undefined : gateOpen ? (optionOf("gate") === "decline" ? "decline" : "approve") : "approve";
|
|
5050
5341
|
const plan = applyApprovedDeclarations(gatePlan, approvedDeclarations);
|
|
5051
5342
|
policyResult = await fixGateAndDefaults(deps, options, access, plan, reviewDefault, true, gateAnswer);
|
|
5052
|
-
|
|
5343
|
+
// BAPI-1677: what is stored is read back; what discovery found never stands in for it.
|
|
5344
|
+
let installReadBack;
|
|
5345
|
+
const installApproved = approvedDeclarations.some((e) => e.key === "dependency_install");
|
|
5346
|
+
if (installApproved && (policyResult.status === "completed" || policyResult.status === "unchanged")) {
|
|
5347
|
+
try {
|
|
5348
|
+
const back = await fetchConductorGateProfile(access, deps.fetchJson);
|
|
5349
|
+
const entries = back.profile?.dependency_install ?? [];
|
|
5350
|
+
state.sealedDependencyInstall = entries;
|
|
5351
|
+
const wanted = approvedDeclarations.find((e) => e.key === "dependency_install")?.fields.dependencyInstall ?? [];
|
|
5352
|
+
installReadBack = !sameDependencyInstall(entries, wanted) ? null
|
|
5353
|
+
: entries.map((e) => `${e.argv.join(" ")} (in ${e.cwd}; runs again when ${e.lockfiles.join(", ")} changes)`);
|
|
5354
|
+
}
|
|
5355
|
+
catch {
|
|
5356
|
+
installReadBack = null;
|
|
5357
|
+
}
|
|
5358
|
+
}
|
|
5359
|
+
return gateWriteResults(policyResult, proposal, resultPlan, installReadBack);
|
|
5053
5360
|
},
|
|
5054
5361
|
},
|
|
5055
5362
|
{
|
|
@@ -5062,7 +5369,14 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5062
5369
|
settleCiPlan(deps, state, gatePlan);
|
|
5063
5370
|
// BAPI-1657: only the no-command remedy needs the launcher text, so detection runs only for that outcome.
|
|
5064
5371
|
const launcher = state.trial?.status === "no_command" ? await detectedLauncherBase(deps, access.repoName) : undefined;
|
|
5065
|
-
|
|
5372
|
+
const trialResult = trialWriteResult(state.trial, proposal !== null && answer !== undefined && answer.decision !== "skip" && answer.decision !== "keep", launcher);
|
|
5373
|
+
// BAPI-1677: a replay names what the trial proved, so the setup record reads the same. The
|
|
5374
|
+
// gate's local commands are that proof. The separate stored test command can still be unset.
|
|
5375
|
+
const proven = gatePlan?.current.profile?.local_commands.map((c) => c.argv.join(" ")) ?? [];
|
|
5376
|
+
const ran = proven.length > 0 ? proven : state.storedCommand !== null ? [state.storedCommand] : [];
|
|
5377
|
+
return trialResult?.status === "unchanged" && ran.length > 0
|
|
5378
|
+
? { ...trialResult, read_back: { ran } }
|
|
5379
|
+
: trialResult;
|
|
5066
5380
|
},
|
|
5067
5381
|
},
|
|
5068
5382
|
{
|
|
@@ -5083,8 +5397,14 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5083
5397
|
const outcome = await runWorkflowPhase(deps, options, setup, access, baseUrl, state, readToolchains, gateRequiresManagedCheck, setupPr);
|
|
5084
5398
|
if (managedWorkflowInPlay(state, gateRequiresManagedCheck))
|
|
5085
5399
|
await warnDefaultBranchRequiresManagedCheck(setup, state);
|
|
5086
|
-
const written = workflowWriteResult(outcome, proposal !== null && setupPr !== undefined);
|
|
5087
|
-
|
|
5400
|
+
const written = workflowWriteResult(outcome, proposal !== null && setupPr !== undefined, setupPr);
|
|
5401
|
+
if (written?.status === "written")
|
|
5402
|
+
setupWorkflowDelivery = "opened";
|
|
5403
|
+
else if (written?.status === "unchanged" && outcome.status === "unchanged")
|
|
5404
|
+
setupWorkflowDelivery = outcome.url !== undefined ? "opened" : "in_place";
|
|
5405
|
+
// A creation with an uncertain result is read again; an open pull request is a fact.
|
|
5406
|
+
else if (outcome.status === "failed" && state.evidence.workflow.state === "pr_open")
|
|
5407
|
+
setupWorkflowDelivery = "opened";
|
|
5088
5408
|
return written;
|
|
5089
5409
|
},
|
|
5090
5410
|
},
|
|
@@ -5144,7 +5464,7 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5144
5464
|
const d = answerOf("worker_mcp_grant");
|
|
5145
5465
|
const answer = proposal === null || d === undefined ? undefined
|
|
5146
5466
|
: d.kind === "selection" ? { decision: "select", ids: d.ids } : { decision: "decline" };
|
|
5147
|
-
const outcome = await fixMcpGrant(deps, setup.mcpGrant, access.repoName, grantInventory, answer);
|
|
5467
|
+
const outcome = await fixMcpGrant(deps, setup.mcpGrant, access.repoName, grantInventory, answer, sfccGrantIds(epicServerSnapshot, grantInventory));
|
|
5148
5468
|
return fixOutcomeResult("worker_mcp_grant", "mcp_grant", outcome);
|
|
5149
5469
|
},
|
|
5150
5470
|
},
|
|
@@ -5158,21 +5478,36 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5158
5478
|
if (proposal === null || d === undefined || (d.kind === "option" && d.option === "keep"))
|
|
5159
5479
|
return null;
|
|
5160
5480
|
}
|
|
5161
|
-
const answer = proposal === null || d === undefined ? undefined : await epicServerAnswer(setup.epicServer, d);
|
|
5162
|
-
const outcome = await fixEpicServer(deps, setup.epicServer, access.repoName, answer);
|
|
5481
|
+
const answer = proposal === null || d === undefined ? undefined : await epicServerAnswer(setup.epicServer, d, epicServerSnapshot);
|
|
5482
|
+
const outcome = await fixEpicServer(deps, setup.epicServer, access.repoName, answer, epicServerSnapshot);
|
|
5163
5483
|
epicServerChanged = outcome.status === "written";
|
|
5164
5484
|
return fixOutcomeResult("epic_server", "epic_server_record", outcome);
|
|
5165
5485
|
},
|
|
5166
5486
|
},
|
|
5167
5487
|
{
|
|
5168
5488
|
key: "epic_branch_ci",
|
|
5169
|
-
run: async () => {
|
|
5489
|
+
run: async (completed) => {
|
|
5170
5490
|
// The inspection runs once on every ordinary run: an explicit flag wins, a confirmed
|
|
5171
5491
|
// workflow on epic-branch PRs is recorded as include, and anything else is only reported.
|
|
5172
5492
|
if (!epicBranchCiWanted)
|
|
5173
5493
|
return null;
|
|
5174
|
-
const ci = optionOf("epic_branch_ci");
|
|
5175
5494
|
const exemption = optionOf("approval_exemption");
|
|
5495
|
+
// BAPI-1679: a recommended `include` whose only support was the setup pull request stands
|
|
5496
|
+
// only if that pull request delivered. A stated answer or flag is never touched, and the
|
|
5497
|
+
// proposal and its digest stay as approved: only what this step stores changes.
|
|
5498
|
+
const lostSetupCredit = proposal !== null && resolvedChoices !== undefined && setupWorkflowDelivery === "none"
|
|
5499
|
+
&& proposal.decisions.find((d) => d.key === "epic_branch_ci")?.source === "recommended"
|
|
5500
|
+
&& optionOf("epic_branch_ci") === "include"
|
|
5501
|
+
&& epicBranchCiIncludeRestsOnSetupPr(resolvedChoices, optionOf, { setupSuppliesWorkflow: decisionEvidence?.epicBranchCi?.managedWorkflowViaSetupPr === true });
|
|
5502
|
+
const setupPrStatus = completed.get("setup_pr")?.status;
|
|
5503
|
+
const creditNote = lostSetupCredit
|
|
5504
|
+
? describeUnopenedSetupCredit({
|
|
5505
|
+
confirmed: setupPrStatus !== "failed" && setupPrStatus !== "uncertain",
|
|
5506
|
+
coverage: decisionEvidence?.epicBranchCi?.coverage ?? null,
|
|
5507
|
+
integrationTarget: ciOfferCollection?.evidence.integrationTarget ?? null,
|
|
5508
|
+
})
|
|
5509
|
+
: undefined;
|
|
5510
|
+
const ci = lostSetupCredit ? "decline" : optionOf("epic_branch_ci");
|
|
5176
5511
|
const epicBranchCi = await runEpicBranchCiInspection(gateIo, access, deps.gate, {
|
|
5177
5512
|
decisionFlag: proposal !== null && (ci === "include" || ci === "decline") ? ci : options.epicBranchCiDecision ?? null,
|
|
5178
5513
|
dryRun: false,
|
|
@@ -5181,6 +5516,7 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5181
5516
|
...(proposal !== null ? { exemptionDecision: exemption === "approve" ? "approve" : "decline" } : {}),
|
|
5182
5517
|
// On the answers path a decision readiness already reports is not written again.
|
|
5183
5518
|
...(proposal !== null ? { recordedDecision: firstReport.readiness?.epic_branch_ci?.decision ?? null } : {}),
|
|
5519
|
+
...(creditNote !== undefined ? { decisionNote: creditNote } : {}),
|
|
5184
5520
|
});
|
|
5185
5521
|
if (epicBranchCi.manualAction !== null)
|
|
5186
5522
|
state.evidence.advisories.push(epicBranchCi.manualAction);
|
|
@@ -5188,9 +5524,10 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5188
5524
|
await runGateConsequenceSummary(gateIo, access, deps.gate);
|
|
5189
5525
|
// BAPI-1654: the plain state, in the same words the choice used.
|
|
5190
5526
|
const stateText = epicBranchCiStateText(decisionEvidence?.epicBranchCi ?? null);
|
|
5191
|
-
|
|
5527
|
+
// The note already replaced it when the credit fell through: this text is from before the apply.
|
|
5528
|
+
if (proposal !== null && stateText !== null && creditNote === undefined)
|
|
5192
5529
|
deps.log(` ${stateText}`);
|
|
5193
|
-
return epicBranchWriteResults(epicBranchCi, proposal !== null);
|
|
5530
|
+
return epicBranchWriteResults(epicBranchCi, proposal !== null, creditNote);
|
|
5194
5531
|
},
|
|
5195
5532
|
},
|
|
5196
5533
|
{
|
|
@@ -5209,7 +5546,7 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5209
5546
|
const text = describeDeclinedCiChange({
|
|
5210
5547
|
coverage: decisionEvidence?.epicBranchCi?.coverage ?? null,
|
|
5211
5548
|
integrationTarget: ciOfferCollection?.evidence.integrationTarget ?? null,
|
|
5212
|
-
coverageViaApprovedSetup: decisionEvidence?.epicBranchCi?.managedWorkflowViaSetupPr === true &&
|
|
5549
|
+
coverageViaApprovedSetup: decisionEvidence?.epicBranchCi?.managedWorkflowViaSetupPr === true && setupWorkflowDelivery === "opened",
|
|
5213
5550
|
});
|
|
5214
5551
|
deps.log("");
|
|
5215
5552
|
deps.log("CI change for epic branches");
|
|
@@ -5238,7 +5575,11 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5238
5575
|
result = await setup.installCiTriggerEdit(delivery.edit, { dryRun: false, ...snapshotOption }, approved);
|
|
5239
5576
|
}
|
|
5240
5577
|
else {
|
|
5241
|
-
|
|
5578
|
+
// BAPI-1677: a workflow never installs commands the gate did not store.
|
|
5579
|
+
if (!sameDependencyInstall(delivery.dependencyInstall, state.sealedDependencyInstall)) {
|
|
5580
|
+
return { key: "epic_ci_change", status: "unattempted", target, reason: "the install commands this workflow uses were not stored", fix: "Rerun setup; nothing was opened." };
|
|
5581
|
+
}
|
|
5582
|
+
result = await setup.installCiWorkflow(delivery.command, delivery.toolchains, { dryRun: false, createOnly: true, ...snapshotOption, ...dependencyInstallOption(delivery.dependencyInstall) }, approved);
|
|
5242
5583
|
}
|
|
5243
5584
|
}
|
|
5244
5585
|
catch {
|
|
@@ -5322,6 +5663,7 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5322
5663
|
// toolchains it already has, and never repeats a trial or an offer.
|
|
5323
5664
|
const closing = await progress("checking readiness", () => collectSetupEvidence(deps, setup, access, finalReadiness, {
|
|
5324
5665
|
...collectInputs,
|
|
5666
|
+
dependencyInstall: state.sealedDependencyInstall,
|
|
5325
5667
|
// BAPI-1657: after an apply, approval has already happened, so a gate still unknown is not
|
|
5326
5668
|
// "stored on approval". Only a dry run's closing preview keeps that promise.
|
|
5327
5669
|
plannedGateWrite: plannedGateWrite && options.dryRun === true,
|
|
@@ -5459,7 +5801,7 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5459
5801
|
...(resolvedChoices !== undefined ? { choices: resolvedChoices } : {}),
|
|
5460
5802
|
...(proposal !== null ? { proposal } : {}),
|
|
5461
5803
|
...(proposalDigest !== null ? { digest: proposalDigest } : {}),
|
|
5462
|
-
...(proposal !== null ? { apply: applyResult } : {}),
|
|
5804
|
+
...(proposal !== null ? { apply: applyResult, applyPresentation: confirmedPresentation(finalReadiness, closing.evidence, items, unmet, applyResult) } : {}),
|
|
5463
5805
|
});
|
|
5464
5806
|
deps.log("");
|
|
5465
5807
|
const ready = unmet.length === 0 && (proposal === null || applyResult.complete);
|
|
@@ -5469,6 +5811,89 @@ async function runConvergingSetup(options, deps, setup) {
|
|
|
5469
5811
|
deps.log(ready ? "complete" : "complete-with-manual-steps");
|
|
5470
5812
|
return ready ? conductorInstallDoctorExitCode(finalReport) : 1;
|
|
5471
5813
|
}
|
|
5814
|
+
/** BAPI-1678 — a readable stored gate, with required and watched checks apart. Anything else is unknown. */
|
|
5815
|
+
function storedGateEvidence(profile) {
|
|
5816
|
+
if (profile === null || profile === undefined || profile.read_failed || profile.stored_malformed || profile.kind === null)
|
|
5817
|
+
return null;
|
|
5818
|
+
if (profile.source !== "stored" && profile.source !== "legacy")
|
|
5819
|
+
return null;
|
|
5820
|
+
return {
|
|
5821
|
+
kind: profile.kind,
|
|
5822
|
+
requiredChecks: profile.provider_checks.filter((c) => c.watched !== true).map((c) => c.name),
|
|
5823
|
+
watchedChecks: profile.provider_checks.filter((c) => c.watched === true).map((c) => c.name),
|
|
5824
|
+
};
|
|
5825
|
+
}
|
|
5826
|
+
function storedCommandEvidence(evidence, profile) {
|
|
5827
|
+
if ((profile?.local_commands.length ?? 0) > 0)
|
|
5828
|
+
return true;
|
|
5829
|
+
return evidence.testCommand.state === "unknown" ? null : evidence.testCommand.state === "stored";
|
|
5830
|
+
}
|
|
5831
|
+
function managedWorkflowEvidence(evidence) {
|
|
5832
|
+
const { state } = evidence.workflow;
|
|
5833
|
+
return state === "unknown" || state === "blocked" ? null : state === "installed";
|
|
5834
|
+
}
|
|
5835
|
+
/** BAPI-1678 — the proposal's wording, from evidence this run already read. No further read. */
|
|
5836
|
+
function plannedPresentation(proposal, gatePlan, gateWriteNeeded, plannedConsequence, readiness, evidence) {
|
|
5837
|
+
const stored = readiness?.gate_profile;
|
|
5838
|
+
const gateDecision = decisionFor(proposal, "gate");
|
|
5839
|
+
const approved = gatePlan !== null && gateWriteNeeded && gateDecision?.kind === "option" && gateDecision.option === "approve";
|
|
5840
|
+
const desired = approved ? gatePlan.desired : null;
|
|
5841
|
+
const gate = desired === null
|
|
5842
|
+
? storedGateEvidence(stored)
|
|
5843
|
+
: {
|
|
5844
|
+
kind: desired.kind,
|
|
5845
|
+
requiredChecks: desired.providerChecks.filter((c) => !(desired.watchedChecks ?? []).includes(c)),
|
|
5846
|
+
watchedChecks: [...(desired.watchedChecks ?? [])],
|
|
5847
|
+
};
|
|
5848
|
+
// A command this gate write would add is not stored yet, and it is not proof of absence either.
|
|
5849
|
+
const storedCommand = storedCommandEvidence(evidence, stored);
|
|
5850
|
+
const localCommandStored = storedCommand !== true && (desired?.localCommands.length ?? 0) > 0 ? null : storedCommand;
|
|
5851
|
+
const ciFacts = readiness?.epic_branch_ci ?? null;
|
|
5852
|
+
const ciDecision = decisionFor(proposal, "epic_branch_ci");
|
|
5853
|
+
const decision = ciDecision?.kind === "decline" || (ciDecision?.kind === "option" && ciDecision.option === "decline")
|
|
5854
|
+
? "decline"
|
|
5855
|
+
: ciDecision?.kind === "option" && ciDecision.option === "include" ? "include" : ciFacts?.decision ?? null;
|
|
5856
|
+
const testDecision = decisionFor(proposal, "test_command");
|
|
5857
|
+
const trialSelected = testDecision?.kind === "command" || (testDecision?.kind === "option" && testDecision.option === "learn");
|
|
5858
|
+
const consequence = desired !== null
|
|
5859
|
+
? plannedConsequence
|
|
5860
|
+
: gate === null ? "" : describeGateConsequence({ kind: gate.kind, hasWatchedChecks: gate.watchedChecks.length > 0 }, ciFacts);
|
|
5861
|
+
return buildProposalPresentation({
|
|
5862
|
+
evidence: {
|
|
5863
|
+
gate,
|
|
5864
|
+
localCommandStored,
|
|
5865
|
+
managedWorkflowInstalled: managedWorkflowEvidence(evidence),
|
|
5866
|
+
// A stated decline is known without the server's facts. Anything else needs them.
|
|
5867
|
+
epicBranchCi: ciFacts !== null
|
|
5868
|
+
? { decision, noCiReasons: ciFacts.no_ci_reasons }
|
|
5869
|
+
: decision === "decline" ? { decision, noCiReasons: [] } : null,
|
|
5870
|
+
},
|
|
5871
|
+
trialPending: trialSelected && storedCommand !== true,
|
|
5872
|
+
consequence,
|
|
5873
|
+
});
|
|
5874
|
+
}
|
|
5875
|
+
/** BAPI-1678 — the verdict, from the readiness and evidence the closing check already captured. */
|
|
5876
|
+
function confirmedPresentation(readiness, evidence, items, unmet, applyResult) {
|
|
5877
|
+
const ready = deriveCompactReadiness({ readinessObserved: readiness !== null, items });
|
|
5878
|
+
const stored = readiness?.gate_profile;
|
|
5879
|
+
const ciFacts = readiness?.epic_branch_ci ?? null;
|
|
5880
|
+
const protection = classifyMergeTestProtection({
|
|
5881
|
+
gate: storedGateEvidence(stored),
|
|
5882
|
+
localCommandStored: storedCommandEvidence(evidence, stored),
|
|
5883
|
+
managedWorkflowInstalled: managedWorkflowEvidence(evidence),
|
|
5884
|
+
epicBranchCi: ciFacts === null ? null : { decision: ciFacts.decision, noCiReasons: ciFacts.no_ci_reasons },
|
|
5885
|
+
});
|
|
5886
|
+
return {
|
|
5887
|
+
verdict: buildInstallVerdict({
|
|
5888
|
+
ready,
|
|
5889
|
+
blockers: unmet.map((item) => ({ label: item.label, fix: setupItemRemedy(item) })),
|
|
5890
|
+
results: applyResult.results,
|
|
5891
|
+
protection,
|
|
5892
|
+
}),
|
|
5893
|
+
...(ready !== undefined ? { ready } : {}),
|
|
5894
|
+
...(protection !== undefined ? { merge_test_protection: protection } : {}),
|
|
5895
|
+
};
|
|
5896
|
+
}
|
|
5472
5897
|
/** The deny probe could not answer: an advisory, never readiness. */
|
|
5473
5898
|
function deniesEnforcementUnknown(report) {
|
|
5474
5899
|
const deny = report.legacyConductor?.deny_enforcement;
|
|
@@ -5504,7 +5929,7 @@ async function closingMcpGrantState(grantDeps, repoName, inventory) {
|
|
|
5504
5929
|
? { state: "met" }
|
|
5505
5930
|
: { state: "needs_action", reason: "changed" };
|
|
5506
5931
|
}
|
|
5507
|
-
async function fixMcpGrant(deps, grantDeps, repoName, inventory, answer) {
|
|
5932
|
+
export async function fixMcpGrant(deps, grantDeps, repoName, inventory, answer, sfccRecommendedIds = []) {
|
|
5508
5933
|
deps.log("");
|
|
5509
5934
|
deps.log("Worker MCP servers");
|
|
5510
5935
|
deps.log(` Epic Implementer workers in ${repoName} always get Bridge. You can approve extra MCP servers for them, ` +
|
|
@@ -5542,6 +5967,10 @@ async function fixMcpGrant(deps, grantDeps, repoName, inventory, answer) {
|
|
|
5542
5967
|
deps.log(" skipped approving MCP servers: there is no interactive terminal, so this counts as declined. Nothing changed.");
|
|
5543
5968
|
return { status: "declined" };
|
|
5544
5969
|
}
|
|
5970
|
+
// BAPI-1667: a pointer to the numbers. How an answer is read does not change.
|
|
5971
|
+
const recommendedNumbers = offered.flatMap((candidate, index) => candidate.definitions.some((definition) => sfccRecommendedIds.includes(definition.id)) ? [index + 1] : []);
|
|
5972
|
+
if (recommendedNumbers.length > 0)
|
|
5973
|
+
deps.log(` Recommended for this SFCC repository: ${recommendedNumbers.join(", ")}`);
|
|
5545
5974
|
let positions = [];
|
|
5546
5975
|
if (offered.length > 0) {
|
|
5547
5976
|
const answer = await deps.promptLine(GRANT_SELECTION_PROMPT);
|
|
@@ -5684,7 +6113,7 @@ const EPIC_SERVER_MODE_ANSWERS = Object.freeze({
|
|
|
5684
6113
|
sfcc: "sfcc_shared_active",
|
|
5685
6114
|
sfcc_shared_active: "sfcc_shared_active",
|
|
5686
6115
|
});
|
|
5687
|
-
async function fixEpicServer(deps, epicDeps, repoName, answer) {
|
|
6116
|
+
export async function fixEpicServer(deps, epicDeps, repoName, answer, snapshot = null) {
|
|
5688
6117
|
deps.log("");
|
|
5689
6118
|
deps.log("Epic server for UI checks");
|
|
5690
6119
|
deps.log(` An Epic Implementer run in ${repoName} can get one epic server: the driver starts the epic's code with a ` +
|
|
@@ -5694,25 +6123,40 @@ async function fixEpicServer(deps, epicDeps, repoName, answer) {
|
|
|
5694
6123
|
deps.log(" kept — nothing changed. Any earlier choice stays in force.");
|
|
5695
6124
|
return { status: "declined" };
|
|
5696
6125
|
}
|
|
5697
|
-
if (answer?.decision === "record")
|
|
5698
|
-
|
|
6126
|
+
if (answer?.decision === "record") {
|
|
6127
|
+
// The apply summary prints these from the write's `reason`, so they appear once.
|
|
6128
|
+
const outcome = await writeApprovedEpicServer(deps, epicDeps, repoName, answer.record);
|
|
6129
|
+
return outcome.status === "failed" || answer.advisories === undefined ? outcome : { ...outcome, advisories: answer.advisories };
|
|
6130
|
+
}
|
|
5699
6131
|
if (!deps.promptLine) {
|
|
5700
6132
|
deps.log(" skipped configuring the epic server: there is no interactive terminal, so this counts as declined. Nothing changed.");
|
|
5701
6133
|
return { status: "declined" };
|
|
5702
6134
|
}
|
|
5703
|
-
let
|
|
6135
|
+
let stored = null;
|
|
5704
6136
|
try {
|
|
5705
|
-
|
|
6137
|
+
const read = await epicDeps.readRecord(repoName);
|
|
6138
|
+
stored = read.state === "ok" ? read.record : null;
|
|
5706
6139
|
}
|
|
5707
6140
|
catch {
|
|
5708
|
-
|
|
5709
|
-
}
|
|
6141
|
+
stored = null;
|
|
6142
|
+
}
|
|
6143
|
+
const hasRecord = stored !== null;
|
|
6144
|
+
const existingSandbox = stored?.sfcc ?? null;
|
|
6145
|
+
const recommendation = recommendEpicServer(epicServerDecisionEvidence(stored?.mode ?? null, true, snapshot, existingSandbox !== null));
|
|
6146
|
+
const detected = snapshot?.detection?.detected === true;
|
|
6147
|
+
// The worker advisory prints once, in the sandbox follow-up, so it is left out of these two lines.
|
|
6148
|
+
const uploadText = detected && snapshot?.uploadCheck?.state !== "possible_with_advisory" ? describeSfccUpload(snapshot?.uploadCheck ?? { state: "unknown", missing: [] }) : "";
|
|
6149
|
+
const canAddSandbox = detected && isSfccUploadCapable(snapshot?.uploadCheck);
|
|
6150
|
+
const sandboxNext = canAddSandbox ? " You can approve a sandbox next, so cartridge changes upload in this mode too." : "";
|
|
6151
|
+
// A recommendation other than the safe default says why, and what is still owed, up front.
|
|
6152
|
+
if (!hasRecord && recommendation.recommended !== "none")
|
|
6153
|
+
deps.log(` Recommended: ${recommendation.recommended}. ${recommendation.why.replace(` ${WORKER_UPLOAD_ADVISORY}`, "")}`);
|
|
5710
6154
|
const decision = await askPlainSetupQuestion({
|
|
5711
6155
|
question: `Which epic server mode should Epic Implementer runs in ${repoName} use?`,
|
|
5712
6156
|
options: [
|
|
5713
|
-
{ id: "none", label:
|
|
5714
|
-
{ id: "local", label:
|
|
5715
|
-
{ id: "sfcc_shared_active", label:
|
|
6157
|
+
{ id: "none", label: `none: no epic server. Choose this if you have no running app to test against. UI checks are handed off to you.${sandboxNext}` },
|
|
6158
|
+
{ id: "local", label: `local: the driver starts this epic's code with a throwaway test login. Choose this if the app can run on this machine; workers borrow it for browser tests.${sandboxNext}` },
|
|
6159
|
+
{ id: "sfcc_shared_active", label: `sfcc_shared_active: one approved shared SFCC sandbox. Choose this for SFCC storefronts; you will name the sandbox next.${uploadText !== "" ? ` ${uploadText}` : ""}`, aliases: ["sfcc"] },
|
|
5716
6160
|
{
|
|
5717
6161
|
id: "keep",
|
|
5718
6162
|
label: hasRecord
|
|
@@ -5721,12 +6165,14 @@ async function fixEpicServer(deps, epicDeps, repoName, answer) {
|
|
|
5721
6165
|
aliases: ["skip", "n", "no"],
|
|
5722
6166
|
},
|
|
5723
6167
|
],
|
|
5724
|
-
recommended:
|
|
6168
|
+
recommended: recommendation.recommended,
|
|
5725
6169
|
recordingFlag: "no flag records this choice; rerun setup in an interactive terminal.",
|
|
5726
6170
|
evidence: ["A missing epic server only hands UI checks off; it never blocks a run.", "Selecting a mode records it. It does not install tools, create a sandbox, or grant an MCP server."],
|
|
5727
6171
|
consequences: [hasRecord
|
|
5728
6172
|
? "keep is recommended because a choice is already stored and pressing Enter should not replace it."
|
|
5729
|
-
:
|
|
6173
|
+
: recommendation.recommended === "none"
|
|
6174
|
+
? "none is recommended because it needs nothing set up and is the safe default."
|
|
6175
|
+
: `${recommendation.recommended} is recommended: ${recommendation.why}`,
|
|
5730
6176
|
"Nothing changes if you stop here."],
|
|
5731
6177
|
recovery: "Rerun setup to choose again. Any earlier choice stays in force until then.",
|
|
5732
6178
|
}, plainTerminalFor(deps));
|
|
@@ -5746,27 +6192,93 @@ async function fixEpicServer(deps, epicDeps, repoName, answer) {
|
|
|
5746
6192
|
}
|
|
5747
6193
|
record.recipe = present ? "present" : "absent";
|
|
5748
6194
|
}
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
return { status: "declined" };
|
|
5755
|
-
}
|
|
5756
|
-
const credentialRef = (await deps.promptLine(" Credential-store reference for its sandbox-only test account: ")).trim();
|
|
5757
|
-
if (!isValidCredentialReference(credentialRef)) {
|
|
5758
|
-
deps.log(" That is not a usable credential-store reference. Nothing changed; re-run setup to try again.");
|
|
5759
|
-
return { status: "declined" };
|
|
5760
|
-
}
|
|
5761
|
-
const origin = normalizeStorefrontOrigin((await deps.promptLine(" Approved storefront origin (for example https://sandbox.example.com): ")).trim());
|
|
5762
|
-
if (origin === null) {
|
|
5763
|
-
deps.log(" That is not an http or https origin without a path, query, or credentials. Nothing changed.");
|
|
5764
|
-
return { status: "declined" };
|
|
5765
|
-
}
|
|
5766
|
-
record.sfcc = { sandbox_id: sandboxId, credential_ref: credentialRef, storefront_origin: origin };
|
|
5767
|
-
}
|
|
6195
|
+
const sandbox = await askApprovedSandbox(deps, epicDeps, mode, existingSandbox, snapshot);
|
|
6196
|
+
if (sandbox === "declined")
|
|
6197
|
+
return { status: "declined" };
|
|
6198
|
+
if (sandbox !== null)
|
|
6199
|
+
record.sfcc = sandbox;
|
|
5768
6200
|
return writeApprovedEpicServer(deps, epicDeps, repoName, record);
|
|
5769
6201
|
}
|
|
6202
|
+
/**
|
|
6203
|
+
* BAPI-1667 — the sandbox follow-up, after the mode. `sfcc_shared_active` always asks
|
|
6204
|
+
* and needs all three fields. `local` and `none` ask when upload can work or a sandbox
|
|
6205
|
+
* is already recorded, and Enter keeps a recorded one or skips. A failed check is
|
|
6206
|
+
* never consent to drop a recorded sandbox. Returns the target to store, null for no
|
|
6207
|
+
* sandbox, or "declined" when an answer was unusable.
|
|
6208
|
+
*/
|
|
6209
|
+
async function askApprovedSandbox(deps, epicDeps, mode, existing, snapshot) {
|
|
6210
|
+
const required = mode === "sfcc_shared_active";
|
|
6211
|
+
const detected = snapshot?.detection?.detected === true;
|
|
6212
|
+
if (!required && existing === null && !(detected && isSfccUploadCapable(snapshot?.uploadCheck)))
|
|
6213
|
+
return null;
|
|
6214
|
+
const promptLine = deps.promptLine;
|
|
6215
|
+
const credentials = snapshot?.credentials ?? null;
|
|
6216
|
+
deps.log(" Approved sandbox");
|
|
6217
|
+
deps.log(" Only non-secret values are asked for here. The sandbox account's secret stays in the credential store.");
|
|
6218
|
+
deps.log(" The id is the sandbox host's first DNS label (for example zzzz-001 in zzzz-001.dx.commercecloud.salesforce.com).");
|
|
6219
|
+
if (detected && snapshot?.uploadCheck?.state === "possible_with_advisory")
|
|
6220
|
+
deps.log(` ${WORKER_UPLOAD_ADVISORY}`);
|
|
6221
|
+
const idHint = existing !== null
|
|
6222
|
+
? required ? ` [Enter keeps ${existing.sandbox_id}]` : ` [Enter keeps ${existing.sandbox_id}, "remove" drops it]`
|
|
6223
|
+
: required ? "" : " (Enter skips)";
|
|
6224
|
+
const typedId = (await promptLine(` Approved sandbox instance id${idHint}: `)).trim();
|
|
6225
|
+
if (!required && typedId === "") {
|
|
6226
|
+
if (existing !== null)
|
|
6227
|
+
return existing;
|
|
6228
|
+
deps.log(` ${SANDBOX_SKIPPED_LINE}`);
|
|
6229
|
+
return null;
|
|
6230
|
+
}
|
|
6231
|
+
if (!required && existing !== null && typedId === "remove") {
|
|
6232
|
+
deps.log(` ${SANDBOX_SKIPPED_LINE}`);
|
|
6233
|
+
return null;
|
|
6234
|
+
}
|
|
6235
|
+
const sandboxId = typedId === "" && existing !== null ? existing.sandbox_id : typedId;
|
|
6236
|
+
if (!isValidSfccSandboxId(sandboxId)) {
|
|
6237
|
+
deps.log(" That is not a usable sandbox id. Nothing changed; re-run setup to try again.");
|
|
6238
|
+
return "declined";
|
|
6239
|
+
}
|
|
6240
|
+
// After the prompt, never inside it: a mismatch advises and the id is stored as entered.
|
|
6241
|
+
if (typedId !== "" && detected && epicDeps.sfccUploadCheck !== undefined) {
|
|
6242
|
+
for (const line of await recheckSfccSandboxId(epicDeps.sfccUploadCheck, sandboxId, { credentials }))
|
|
6243
|
+
deps.log(` ${line}`);
|
|
6244
|
+
}
|
|
6245
|
+
const defaultRef = existing?.credential_ref ?? suggestedCredentialEntry(credentials);
|
|
6246
|
+
for (const line of credentialQuestionLines(credentials, defaultRef))
|
|
6247
|
+
deps.log(` ${line}`);
|
|
6248
|
+
const typedRef = (await promptLine(" Worker credential entry: ")).trim();
|
|
6249
|
+
const credentialRef = typedRef === "" ? defaultRef : typedRef;
|
|
6250
|
+
if (credentialRef === null && !required) {
|
|
6251
|
+
deps.log(` ${SANDBOX_SKIPPED_LINE}`);
|
|
6252
|
+
return null;
|
|
6253
|
+
}
|
|
6254
|
+
if (!isValidCredentialReference(credentialRef)) {
|
|
6255
|
+
deps.log(" That is not a usable credential reference. Nothing changed; re-run setup to try again.");
|
|
6256
|
+
return "declined";
|
|
6257
|
+
}
|
|
6258
|
+
// An absent or unusable record was already said once, above the question.
|
|
6259
|
+
if (credentials?.recordState === "ok") {
|
|
6260
|
+
for (const line of credentialReferenceAdvisories(credentials, credentialRef))
|
|
6261
|
+
deps.log(` ${line}`);
|
|
6262
|
+
}
|
|
6263
|
+
const sameSandbox = existing !== null && existing.sandbox_id === sandboxId;
|
|
6264
|
+
if (!required) {
|
|
6265
|
+
return {
|
|
6266
|
+
sandbox_id: sandboxId,
|
|
6267
|
+
credential_ref: credentialRef,
|
|
6268
|
+
...(sameSandbox && existing.storefront_origin !== undefined ? { storefront_origin: existing.storefront_origin } : {}),
|
|
6269
|
+
};
|
|
6270
|
+
}
|
|
6271
|
+
const originDefault = sameSandbox ? existing.storefront_origin ?? null : null;
|
|
6272
|
+
const typedOrigin = (await promptLine(originDefault !== null
|
|
6273
|
+
? ` Approved storefront origin [Enter keeps ${originDefault}]: `
|
|
6274
|
+
: " Approved storefront origin (for example https://sandbox.example.com): ")).trim();
|
|
6275
|
+
const origin = normalizeStorefrontOrigin(typedOrigin === "" && originDefault !== null ? originDefault : typedOrigin);
|
|
6276
|
+
if (origin === null) {
|
|
6277
|
+
deps.log(" That is not an http or https origin without a path, query, or credentials. Nothing changed.");
|
|
6278
|
+
return "declined";
|
|
6279
|
+
}
|
|
6280
|
+
return { sandbox_id: sandboxId, credential_ref: credentialRef, storefront_origin: origin };
|
|
6281
|
+
}
|
|
5770
6282
|
/** Write one approved record through `writeEpicServerRecord`, after the no-change check. */
|
|
5771
6283
|
async function writeApprovedEpicServer(deps, epicDeps, repoName, record) {
|
|
5772
6284
|
try {
|