@bridge_gpt/mcp-server 0.2.72 → 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 +15 -0
- package/build/agents.generated.js +6 -6
- package/build/bridge-config.js +7 -1
- package/build/bridge-permissions.js +30 -0
- package/build/ci-system-detection.js +50 -0
- package/build/ci-trigger-adapters.js +631 -0
- package/build/ci-trigger-install.js +106 -0
- package/build/codex-launcher-pin.js +33 -2
- package/build/codex-skill-adapter.js +3 -1
- package/build/command-host.js +33 -0
- package/build/command-provisioning.js +4 -3
- package/build/commands.generated.js +7 -6
- package/build/conductor/bridge-api-client.js +867 -35
- package/build/conductor/bring-up-facts.js +18 -5
- package/build/conductor/command-drift-production.js +42 -17
- package/build/conductor/command-drift.js +48 -1
- package/build/conductor/declare-blocked.js +554 -0
- package/build/conductor/declared-extras.js +335 -0
- package/build/conductor/doctor.js +108 -21
- package/build/conductor/driver-commands.js +141 -0
- package/build/conductor/driver-guard.js +277 -0
- package/build/conductor/driver-lapse.js +321 -0
- package/build/conductor/driver-pass-output.js +104 -0
- package/build/conductor/driver-pass.js +571 -0
- package/build/conductor/driver-register.js +176 -0
- package/build/conductor/driver-release.js +174 -0
- package/build/conductor/driver-session-state.js +315 -0
- package/build/conductor/epic-branch-ci-inspection.js +281 -43
- package/build/conductor/epic-implementer-cli.js +199 -15
- package/build/conductor/epic-server-database.js +162 -0
- package/build/conductor/epic-server-guidance.js +278 -0
- package/build/conductor/epic-server-journal.js +239 -0
- package/build/conductor/epic-server-processes.js +324 -0
- package/build/conductor/epic-server-recipe.js +397 -0
- package/build/conductor/epic-server-runtime.js +1207 -0
- package/build/conductor/epic-server-sfcc-upload.js +1567 -0
- package/build/conductor/epic-server-sfcc.js +85 -0
- package/build/conductor/epic-server-state.js +427 -0
- package/build/conductor/epic-server.js +647 -0
- package/build/conductor/gate-discovery.js +196 -11
- package/build/conductor/gate-settings-review.js +261 -4
- package/build/conductor/launch-need-probes.js +6 -53
- package/build/conductor/launch-plan.js +313 -156
- package/build/conductor/prerequisite-inputs.js +879 -45
- package/build/conductor/readiness-assessment.js +16 -1
- package/build/conductor/readiness-cli.js +20 -9
- package/build/conductor/readiness-prerequisites.js +28 -9
- package/build/conductor/readiness-sections.js +133 -126
- package/build/conductor/readiness.js +1 -1
- package/build/conductor/recovery-cli.js +13 -2
- package/build/conductor/tools.js +6 -5
- package/build/conductor/wait-run-attention.js +2 -2
- package/build/conductor/wait-run-cli.js +208 -22
- package/build/conductor/worker-database-doctor-inspector.js +33 -2
- package/build/conductor/worker-setup-tally.js +27 -0
- 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 +121 -1
- package/build/credentials-cli.js +252 -3
- package/build/dependency-install-declarations.js +102 -1
- package/build/docs.generated.js +10 -3
- package/build/doctor.js +95 -3
- package/build/drive-epic-help.js +21 -2
- package/build/drive-epic.js +2095 -375
- package/build/engine-paths.js +20 -0
- package/build/epic-branch-ci-summary.js +157 -0
- package/build/epic-capability-statement.js +175 -0
- package/build/epic-ci-workflow-drift.js +77 -23
- package/build/epic-ci-workflow-install.js +137 -44
- package/build/epic-ci-workflow-v2.js +274 -0
- package/build/epic-ci-workflow-v3.js +273 -0
- package/build/epic-ci-workflow.js +165 -18
- package/build/epic-implementer-bin.js +2204 -56
- package/build/epic-launch-context.js +702 -0
- package/build/epic-server-record.js +288 -0
- package/build/epic-shared/bridge-client.js +11 -3
- package/build/escalation-reachability.js +43 -0
- package/build/executor/ci-fix-test-runs.js +334 -0
- package/build/executor/completion-contract.js +8 -1
- package/build/executor/credential-delivery-step.js +168 -0
- package/build/executor/deps.js +3 -1
- package/build/executor/env.js +98 -23
- package/build/executor/epic-server-context.js +157 -0
- package/build/executor/gate-qualification-job.js +127 -26
- package/build/executor/guarded-fast-forward-push.js +13 -8
- package/build/executor/http-client.js +52 -5
- package/build/executor/job-runner.js +577 -81
- package/build/executor/observation.js +8 -0
- package/build/executor/permissions.js +85 -3
- package/build/executor/pre-pr-checks.js +363 -0
- package/build/executor/prompt-spec.js +149 -3
- package/build/executor/reconcile-overlap-job.js +5 -3
- package/build/executor/required-work-diagnostics.js +4 -2
- package/build/executor/required-work-ledger.js +936 -38
- package/build/executor/results.js +58 -0
- package/build/executor/terminal-mutation.js +8 -0
- package/build/executor/worker-command.js +72 -3
- package/build/executor/worker-database-config.js +281 -0
- package/build/executor/worker-database-target.js +16 -12
- package/build/executor/worker-database.js +320 -101
- package/build/executor/worker-finalization.js +7 -1
- package/build/executor/worker-resources.js +25 -3
- package/build/executor/worker-verification-guidance.js +18 -3
- package/build/executor/worktree.js +20 -1
- package/build/executor-launch.js +58 -4
- package/build/generated-assets-catalog.js +2 -2
- package/build/git-exclude-lock.js +187 -0
- package/build/index.js +824 -366
- package/build/init.js +26 -11
- package/build/install-bridge-conductor-answers.js +528 -0
- package/build/install-bridge-conductor-apply.js +288 -0
- package/build/install-bridge-conductor-assessment.js +1222 -0
- package/build/install-bridge-conductor-compact.js +186 -0
- package/build/install-bridge-conductor-contracts.js +72 -0
- package/build/install-bridge-conductor-gate.js +1312 -198
- package/build/install-bridge-conductor-setup.js +577 -83
- package/build/install-bridge-conductor.js +3381 -544
- package/build/install-bridge.js +280 -25
- package/build/install-doctor.js +38 -8
- package/build/install-maintenance.js +26 -3
- package/build/install-sfcc-detection.js +120 -0
- package/build/install-sfcc-setup.js +185 -0
- package/build/launcher-config-inspection.js +162 -1
- package/build/mcp-grant-candidates.js +779 -0
- package/build/mcp-grant-doctor.js +63 -0
- package/build/mcp-grant.js +288 -0
- package/build/mcp-host-targets.js +8 -0
- package/build/mcp-identity.js +23 -0
- package/build/mcp-invoke.js +292 -15
- package/build/mcp-presets.js +107 -0
- package/build/mcp-provisioning.js +155 -6
- package/build/mcp-registration-doctor.js +31 -2
- package/build/mcp-server-invocation.js +19 -1
- package/build/merge-workflow-install.js +243 -110
- package/build/pipelines.generated.js +7 -6
- package/build/plan-discovery.js +97 -4
- package/build/plan-execution-ledger.js +100 -7
- package/build/plan-generation-io.js +262 -0
- package/build/plan-generation.js +424 -0
- package/build/plane/build-freshness.js +6 -1
- package/build/plane/cli.js +75 -9
- package/build/plane/plane-freshness.js +17 -0
- package/build/plane/preflight.js +50 -10
- package/build/plane/shutdown.js +19 -0
- package/build/plane/status.js +8 -2
- package/build/plane/terminal-run-cleanup.js +18 -4
- package/build/printed-remedy-commands.js +211 -12
- package/build/project-root.js +40 -0
- package/build/readiness-check.js +77 -0
- package/build/readiness-prerequisites.generated.js +122 -14
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +41 -0
- package/build/repository-toolchains.js +6 -3
- package/build/run-unit-tests-launcher.js +8 -1
- package/build/setup-epic.js +1305 -210
- package/build/setup-progress.js +44 -0
- package/build/setup-question.js +122 -4
- 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 +63 -2
- package/build/ticket-delivery-enrollment.js +9 -0
- package/build/upgrade-cli.js +85 -2
- package/build/v2-readiness-requirements.js +28 -1
- package/build/version.generated.js +3 -3
- package/build/with-credentials.js +208 -0
- package/build/worktree-credential-delivery.js +340 -0
- package/docs/EPIC-IMPLEMENTER-INSTALL.md +9 -1
- package/docs/epic-implementer/getting-started.md +3 -1
- package/docs/epic-implementer/self-hosting.md +14 -1
- package/package.json +2 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BAPI-1594 — the engine's own paths. A local launch runs engine code from this
|
|
3
|
+
* checkout, so an uncommitted change under any of them is code CI has not seen;
|
|
4
|
+
* a clean status here means the checkout is what CI verified.
|
|
5
|
+
*/
|
|
6
|
+
export const ENGINE_PATHS = [
|
|
7
|
+
"mcp_server/src/",
|
|
8
|
+
"mcp_server/tsconfig.json",
|
|
9
|
+
"mcp_server/package.json",
|
|
10
|
+
"mcp_server/package-lock.json",
|
|
11
|
+
"api/library/epic_implementer/",
|
|
12
|
+
"api/library/db/epic_runs.py",
|
|
13
|
+
"api/library/github/merge_execution_eligibility.py",
|
|
14
|
+
"api/routes/epic_runs.py",
|
|
15
|
+
"db/alembic/",
|
|
16
|
+
"requirements.txt",
|
|
17
|
+
"scripts/conductor_health_check.py",
|
|
18
|
+
"tests/integration/conductor_harness/",
|
|
19
|
+
"tests/pytest/db/test_executor_protocol_contract_fidelity.py",
|
|
20
|
+
];
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BAPI-1654 — the owner-facing words about checks on epic branches.
|
|
3
|
+
*
|
|
4
|
+
* Pure. It turns the collected evidence (coverage, the CI change on offer, the
|
|
5
|
+
* detected CI systems, and whether CI runs on the final integration pull
|
|
6
|
+
* request) into plain sentences, one distinct text per state:
|
|
7
|
+
*
|
|
8
|
+
* - confirmed coverage;
|
|
9
|
+
* - confirmed exclusion, naming the workflow and its filter;
|
|
10
|
+
* - unknown;
|
|
11
|
+
* - a CI change on offer (a trigger edit, or Bridge's managed workflow);
|
|
12
|
+
* - a proposed but unmerged change: proposed, not coverage;
|
|
13
|
+
* - no offer, or a declined one: child pull requests merge without checks;
|
|
14
|
+
* - a CI system Bridge has no adapter for, named.
|
|
15
|
+
*
|
|
16
|
+
* Two rules hold everywhere:
|
|
17
|
+
* - "child pull requests merge into the epic branch without checks" is said
|
|
18
|
+
* only when no check is confirmed to run there and no managed workflow is on
|
|
19
|
+
* offer; for unreadable coverage the words are "could not be confirmed".
|
|
20
|
+
* - "CI runs on the final integration pull request" is said only when the
|
|
21
|
+
* workflows were confirmed to run on pull requests into that base branch.
|
|
22
|
+
*
|
|
23
|
+
* No internal key, id, reason token, or stage name appears in the text.
|
|
24
|
+
*/
|
|
25
|
+
const GITHUB_ACTIONS = "GitHub Actions";
|
|
26
|
+
/** At most this many excluded workflows are named one by one. */
|
|
27
|
+
const MAX_NAMED_WORKFLOWS = 5;
|
|
28
|
+
function quoteList(branches) {
|
|
29
|
+
return branches.map((b) => `'${b}'`).join(", ");
|
|
30
|
+
}
|
|
31
|
+
/** "A", "A and B", "A, B, and C". */
|
|
32
|
+
export function joinNames(names) {
|
|
33
|
+
if (names.length <= 1)
|
|
34
|
+
return names[0] ?? "";
|
|
35
|
+
if (names.length === 2)
|
|
36
|
+
return `${names[0]} and ${names[1]}`;
|
|
37
|
+
return `${names.slice(0, -1).join(", ")}, and ${names[names.length - 1]}`;
|
|
38
|
+
}
|
|
39
|
+
/** The sentence about the final integration pull request, by what was confirmed. */
|
|
40
|
+
export function finalIntegrationSentence(target) {
|
|
41
|
+
if (target !== null && target !== undefined && target.coverage === "covers") {
|
|
42
|
+
return `CI runs on the final integration pull request into ${target.branch}.`;
|
|
43
|
+
}
|
|
44
|
+
return "Bridge could not confirm that CI runs on the final integration pull request either.";
|
|
45
|
+
}
|
|
46
|
+
/** The sentence naming detected CI systems Bridge cannot change, or "". */
|
|
47
|
+
export function unsupportedSystemsSentence(systems) {
|
|
48
|
+
const names = (systems ?? []).map((s) => s.name).filter((n) => n !== GITHUB_ACTIONS);
|
|
49
|
+
const unique = [...new Set(names)];
|
|
50
|
+
if (unique.length === 0)
|
|
51
|
+
return "";
|
|
52
|
+
return `This repository also uses ${joinNames(unique)}. Bridge can't safely change ${unique.length === 1 ? "its" : "their"} config yet.`;
|
|
53
|
+
}
|
|
54
|
+
function onlyUnsupportedSystems(systems) {
|
|
55
|
+
const all = systems ?? [];
|
|
56
|
+
if (all.some((s) => s.name === GITHUB_ACTIONS))
|
|
57
|
+
return [];
|
|
58
|
+
return [...new Set(all.map((s) => s.name))];
|
|
59
|
+
}
|
|
60
|
+
function exclusionSentence(excluded) {
|
|
61
|
+
const named = (excluded ?? []).filter((w) => w.branches !== null && w.branches.length > 0);
|
|
62
|
+
if (named.length === 0)
|
|
63
|
+
return "No workflow runs on pull requests into epic branches.";
|
|
64
|
+
if (named.length === 1) {
|
|
65
|
+
return `${named[0].path} runs only on pull requests into ${quoteList(named[0].branches)}, not into epic branches.`;
|
|
66
|
+
}
|
|
67
|
+
// Each workflow with its own filter, bounded so a large repository stays readable.
|
|
68
|
+
const shown = named.slice(0, MAX_NAMED_WORKFLOWS).map((w) => `${w.path} runs only on pull requests into ${quoteList(w.branches)}`);
|
|
69
|
+
const more = named.length - shown.length;
|
|
70
|
+
return `${shown.join("; ")}${more > 0 ? `; and ${more} more workflow${more === 1 ? "" : "s"} like them` : ""}. None of them runs on pull requests into epic branches.`;
|
|
71
|
+
}
|
|
72
|
+
/** The plain text for the current state, before any apply. */
|
|
73
|
+
export function describeEpicBranchCi(input) {
|
|
74
|
+
const parts = [];
|
|
75
|
+
const unsupported = unsupportedSystemsSentence(input.ciSystems);
|
|
76
|
+
if (input.coverage === "covers") {
|
|
77
|
+
parts.push("A workflow is configured to start on pull requests into epic branches, so each child can wait for its checks to run before it merges.");
|
|
78
|
+
if (unsupported)
|
|
79
|
+
parts.push(unsupported);
|
|
80
|
+
return parts.join(" ");
|
|
81
|
+
}
|
|
82
|
+
const offer = input.offer ?? null;
|
|
83
|
+
if (offer !== null && offer.actionClass === "trigger_edit") {
|
|
84
|
+
const filter = offer.branchesBefore !== undefined && offer.branchesBefore.length > 0 ? ` (today: ${quoteList(offer.branchesBefore)})` : "";
|
|
85
|
+
parts.push(`${offer.path} does not run on pull requests into epic branches${filter}. Adding 'epic/**' to its pull_request branch list would fix that, and only that list would change.`);
|
|
86
|
+
parts.push("Until that change is merged, child pull requests merge into the epic branch without checks.");
|
|
87
|
+
parts.push(finalIntegrationSentence(input.integrationTarget));
|
|
88
|
+
if (unsupported)
|
|
89
|
+
parts.push(unsupported);
|
|
90
|
+
return parts.join(" ");
|
|
91
|
+
}
|
|
92
|
+
if (offer !== null && offer.actionClass === "managed_workflow") {
|
|
93
|
+
parts.push(`No workflow can be changed safely to run on pull requests into epic branches. Bridge's epic workflow (${offer.path}) would run your test command on each child pull request once it is merged.`);
|
|
94
|
+
if (unsupported)
|
|
95
|
+
parts.push(unsupported);
|
|
96
|
+
return parts.join(" ");
|
|
97
|
+
}
|
|
98
|
+
const only = onlyUnsupportedSystems(input.ciSystems);
|
|
99
|
+
if (input.coverage === null && only.length > 0) {
|
|
100
|
+
parts.push(`This repository uses ${joinNames(only)}. Bridge can't safely change ${only.length === 1 ? "its" : "their"} config yet, so child pull requests merge into the epic branch without checks.`);
|
|
101
|
+
parts.push(finalIntegrationSentence(input.integrationTarget));
|
|
102
|
+
return parts.join(" ");
|
|
103
|
+
}
|
|
104
|
+
if (input.coverage === "does_not_cover") {
|
|
105
|
+
parts.push(exclusionSentence(input.excluded));
|
|
106
|
+
parts.push("Child pull requests merge into the epic branch without checks.");
|
|
107
|
+
parts.push(finalIntegrationSentence(input.integrationTarget));
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
parts.push("Bridge could not confirm that checks run on pull requests into epic branches, so child pull requests may merge into the epic branch without checks.");
|
|
111
|
+
parts.push(finalIntegrationSentence(input.integrationTarget));
|
|
112
|
+
}
|
|
113
|
+
if (unsupported)
|
|
114
|
+
parts.push(unsupported);
|
|
115
|
+
return parts.join(" ");
|
|
116
|
+
}
|
|
117
|
+
/** The text for a declined CI change: honest about what stays without checks. */
|
|
118
|
+
export function describeDeclinedCiChange(input) {
|
|
119
|
+
if (input.coverageViaApprovedSetup === true) {
|
|
120
|
+
// The setup pull request you approved adds the same workflow, so declining this one loses nothing.
|
|
121
|
+
return [
|
|
122
|
+
"You declined this CI pull request, but the setup pull request you approved also adds Bridge's epic workflow.",
|
|
123
|
+
"Its checks start on child pull requests once you merge it. Until then, child pull requests merge into the epic branch without checks.",
|
|
124
|
+
finalIntegrationSentence(input.integrationTarget),
|
|
125
|
+
].join(" ");
|
|
126
|
+
}
|
|
127
|
+
return [
|
|
128
|
+
"You declined the CI change, so child pull requests merge into the epic branch without checks.",
|
|
129
|
+
finalIntegrationSentence(input.integrationTarget),
|
|
130
|
+
].join(" ");
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* BAPI-1679 — the text for a recommended `include` that lost its only support: the setup pull
|
|
134
|
+
* request did not open on this apply, or setup could not confirm that it did.
|
|
135
|
+
*/
|
|
136
|
+
export function describeUnopenedSetupCredit(input) {
|
|
137
|
+
return [
|
|
138
|
+
input.confirmed
|
|
139
|
+
? "The setup pull request did not open, so it adds no checks."
|
|
140
|
+
: "Setup could not confirm that the setup pull request opened, so it does not count on its checks.",
|
|
141
|
+
"Setup recorded decline for epic-branch CI instead of the recommended include.",
|
|
142
|
+
input.coverage === "does_not_cover"
|
|
143
|
+
? "Child pull requests merge into the epic branch without checks."
|
|
144
|
+
: "Child pull requests may merge into the epic branch without checks.",
|
|
145
|
+
finalIntegrationSentence(input.integrationTarget),
|
|
146
|
+
"Once a workflow runs on pull requests into epic branches, run setup again and it records include.",
|
|
147
|
+
].join(" ");
|
|
148
|
+
}
|
|
149
|
+
/** The text for an opened or reused CI pull request: proposed, not coverage. */
|
|
150
|
+
export function describeProposedCiChange(actionClass, path, url) {
|
|
151
|
+
const where = url !== null ? ` in ${url}` : "";
|
|
152
|
+
return actionClass === "trigger_edit"
|
|
153
|
+
? `The CI change to ${path} is proposed${where} and not merged yet. Until you merge it, child pull requests ` +
|
|
154
|
+
"merge into the epic branch without checks. Nothing waits for it."
|
|
155
|
+
: `Bridge's epic workflow (${path}) is proposed${where} and not merged yet. Its checks start on child pull ` +
|
|
156
|
+
"requests once you merge it. Nothing waits for it.";
|
|
157
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The advisory capability statement (BAPI-1545).
|
|
3
|
+
*
|
|
4
|
+
* Every non-dry-run `install epic-implementer` builds this short, non-secret
|
|
5
|
+
* summary from the current MCP grant and the epic-server record and writes it to
|
|
6
|
+
* the server (`PUT /jira/epic-runs/capability-statement`). Plan generation and
|
|
7
|
+
* the implement-worker prompt include it, so the planner stops writing tests
|
|
8
|
+
* nobody can run.
|
|
9
|
+
*
|
|
10
|
+
* It is ADVISORY and NEVER an authorization source: nothing may read it to
|
|
11
|
+
* decide what a worker can load. It says what the owner configured, not that
|
|
12
|
+
* any of it works at runtime.
|
|
13
|
+
*
|
|
14
|
+
* Version 1 holds names and closed-vocabulary values only — no commands,
|
|
15
|
+
* arguments, paths, environment values, or credential references. The Python
|
|
16
|
+
* twin (`src/python/llms/agents/epic_capability_statement.py`) applies the same
|
|
17
|
+
* rules; keep the two in step.
|
|
18
|
+
*
|
|
19
|
+
* BAPI-1546: `recipe` says whether repository epic-server GUIDANCE was found at
|
|
20
|
+
* setup. It never means a run recipe was proven or that an epic server is live:
|
|
21
|
+
* the driver proves its recipe per run, and a missing server is a hand-off.
|
|
22
|
+
*
|
|
23
|
+
* BAPI-1668: the stored payload stays value-only. It gains one optional,
|
|
24
|
+
* closed-vocabulary flag, `sfcc_upload` ("available" | "absent"), published only
|
|
25
|
+
* when the epic-server record carries an approved SFCC sandbox. This module also
|
|
26
|
+
* exports the planner-facing verification guidance text
|
|
27
|
+
* (`EPIC_SERVER_VERIFICATION_LEAD`, `EPIC_SERVER_VERIFICATION_GUIDANCE`,
|
|
28
|
+
* `EPIC_SERVER_LOCAL_SFCC_UPLOAD_GUIDANCE`) and `renderEpicServerVerificationGuidance`.
|
|
29
|
+
* Planners read the Python renderer; this TypeScript copy is the contract both
|
|
30
|
+
* runtimes are tested against, and a parity test compares the literals.
|
|
31
|
+
* The guidance is advisory configured capability, never runtime proof or
|
|
32
|
+
* authorization.
|
|
33
|
+
*/
|
|
34
|
+
import { isGrantableServerName, MCP_GRANT_MAX_SERVERS } from "./mcp-grant.js";
|
|
35
|
+
export const EPIC_CAPABILITY_STATEMENT_VERSION = 1;
|
|
36
|
+
const MODES = ["none", "local", "sfcc_shared_active", "unknown"];
|
|
37
|
+
const RECIPES = ["present", "absent", "unknown"];
|
|
38
|
+
const GRANT_STATES = ["present", "absent", "unusable"];
|
|
39
|
+
const KEYS = [
|
|
40
|
+
"version",
|
|
41
|
+
"approved_servers",
|
|
42
|
+
"epic_server_mode",
|
|
43
|
+
"recipe",
|
|
44
|
+
"grant_state",
|
|
45
|
+
"written_at",
|
|
46
|
+
"sfcc_upload",
|
|
47
|
+
];
|
|
48
|
+
const SFCC_UPLOAD_STATES = ["available", "absent"];
|
|
49
|
+
/**
|
|
50
|
+
* Planner-facing verification guidance. This is the TypeScript copy of the
|
|
51
|
+
* contract the Python renderer emits. Do NOT append it to the implement-worker
|
|
52
|
+
* prompt: the existing epic-server worker builders own those instructions, and a
|
|
53
|
+
* second copy would let the two drift. Each value is one single-line
|
|
54
|
+
* double-quoted literal so the parity test can extract it.
|
|
55
|
+
*/
|
|
56
|
+
export const EPIC_SERVER_VERIFICATION_LEAD = "How e2e_tests and rendered_ui_review steps are verified in this mode:";
|
|
57
|
+
export const EPIC_SERVER_VERIFICATION_GUIDANCE = {
|
|
58
|
+
none: "No epic server is configured for this repository. A step that needs the running application cannot run here. Plan it as a recorded, visible hand-off item, and still write its test code.",
|
|
59
|
+
local: "The run has one local epic server, shared by turns. Plan these steps as runnable. The worker takes a turn at its own head with epic-implementer epic-server turn acquire, runs the check against the address that turn prints, then releases the turn. Do not plan steps that install, build, start, or stop a dev server, or that choose a port or origin. The recipe line above does not change this, because the driver proves the recipe at run start. If the server is unavailable at run time, the worker records the hand-off itself.",
|
|
60
|
+
sfcc_shared_active: "The run uses one shared SFCC sandbox and one shared code version for the whole epic. Plan these steps as runnable. Before each check, the worker uploads only the cartridge files its ticket changed with epic-implementer epic-server sfcc-upload, then runs the check against the sandbox storefront origin it is given at run time. Do not plan a whole-cartridge upload, a new or per-ticket code version, a code version switch, a Managed Runtime (MRT) push, or the repository deploy workflow. Storefront Next React code outside the cartridges is not uploaded. If the upload fails, the worker records the hand-off itself.",
|
|
61
|
+
unknown: "The epic server setting could not be read. Treat it as not configured. Plan a step that needs the running application as a recorded, visible hand-off item, and still write its test code.",
|
|
62
|
+
};
|
|
63
|
+
export const EPIC_SERVER_LOCAL_SFCC_UPLOAD_GUIDANCE = "This repository also has an approved SFCC sandbox. Before each turn, the worker uploads only the cartridge files its ticket changed with epic-implementer epic-server sfcc-upload, so the local app, which calls the sandbox APIs, sees them. Do not plan a whole-cartridge upload, a new or per-ticket code version, a code version switch, or a Managed Runtime (MRT) push. If the upload fails, the worker records the hand-off itself.";
|
|
64
|
+
/**
|
|
65
|
+
* Build the statement from what was read. A usable grant is `present` even when
|
|
66
|
+
* it approves no extra server; an absent or unusable grant lists no servers.
|
|
67
|
+
*/
|
|
68
|
+
export function buildEpicCapabilityStatement(grant, epicServer, now) {
|
|
69
|
+
const approved = grant.state === "ok"
|
|
70
|
+
? [...new Set(grant.grant.servers.map((s) => s.name).filter((n) => isGrantableServerName(n)))]
|
|
71
|
+
.sort()
|
|
72
|
+
.slice(0, MCP_GRANT_MAX_SERVERS)
|
|
73
|
+
: [];
|
|
74
|
+
const grantState = grant.state === "ok" ? "present" : grant.state === "absent" ? "absent" : "unusable";
|
|
75
|
+
let mode;
|
|
76
|
+
let recipe;
|
|
77
|
+
if (epicServer.state === "absent") {
|
|
78
|
+
mode = "none";
|
|
79
|
+
recipe = "unknown";
|
|
80
|
+
}
|
|
81
|
+
else if (epicServer.state === "unusable") {
|
|
82
|
+
mode = "unknown";
|
|
83
|
+
recipe = "unknown";
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
mode = epicServer.record.mode;
|
|
87
|
+
recipe = epicServer.record.recipe ?? "unknown";
|
|
88
|
+
}
|
|
89
|
+
const statement = {
|
|
90
|
+
version: EPIC_CAPABILITY_STATEMENT_VERSION,
|
|
91
|
+
approved_servers: approved,
|
|
92
|
+
epic_server_mode: mode,
|
|
93
|
+
recipe,
|
|
94
|
+
grant_state: grantState,
|
|
95
|
+
written_at: now.toISOString(),
|
|
96
|
+
};
|
|
97
|
+
// Independent of mode. Omitted (never "absent" or null) when no sandbox is recorded.
|
|
98
|
+
if (epicServer.state === "ok" && epicServer.record.sfcc !== undefined) {
|
|
99
|
+
statement.sfcc_upload = "available";
|
|
100
|
+
}
|
|
101
|
+
return statement;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Strictly validate a statement (unknown keys, an unsupported version, a bad
|
|
105
|
+
* timestamp, an unknown vocabulary value, an unsafe or Bridge name, or an
|
|
106
|
+
* unsorted or duplicated list are all rejected). Returns null when invalid.
|
|
107
|
+
*/
|
|
108
|
+
export function validateEpicCapabilityStatement(raw) {
|
|
109
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
110
|
+
return null;
|
|
111
|
+
const doc = raw;
|
|
112
|
+
for (const key of Object.keys(doc))
|
|
113
|
+
if (!KEYS.includes(key))
|
|
114
|
+
return null;
|
|
115
|
+
if (doc.version !== EPIC_CAPABILITY_STATEMENT_VERSION)
|
|
116
|
+
return null;
|
|
117
|
+
const servers = doc.approved_servers;
|
|
118
|
+
if (!Array.isArray(servers) || servers.length > MCP_GRANT_MAX_SERVERS)
|
|
119
|
+
return null;
|
|
120
|
+
for (let i = 0; i < servers.length; i++) {
|
|
121
|
+
if (!isGrantableServerName(servers[i]))
|
|
122
|
+
return null;
|
|
123
|
+
if (i > 0 && !(servers[i - 1] < servers[i]))
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
if (typeof doc.epic_server_mode !== "string" || !MODES.includes(doc.epic_server_mode))
|
|
127
|
+
return null;
|
|
128
|
+
if (typeof doc.recipe !== "string" || !RECIPES.includes(doc.recipe))
|
|
129
|
+
return null;
|
|
130
|
+
if (typeof doc.grant_state !== "string" || !GRANT_STATES.includes(doc.grant_state))
|
|
131
|
+
return null;
|
|
132
|
+
const writtenAt = doc.written_at;
|
|
133
|
+
if (typeof writtenAt !== "string" ||
|
|
134
|
+
writtenAt.length > 64 ||
|
|
135
|
+
!/^\d{4}-\d{2}-\d{2}T.*(Z|[+-]\d{2}:\d{2})$/.test(writtenAt) ||
|
|
136
|
+
Number.isNaN(Date.parse(writtenAt))) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const hasUpload = Object.prototype.hasOwnProperty.call(doc, "sfcc_upload");
|
|
140
|
+
if (hasUpload &&
|
|
141
|
+
(typeof doc.sfcc_upload !== "string" || !SFCC_UPLOAD_STATES.includes(doc.sfcc_upload))) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const result = {
|
|
145
|
+
version: EPIC_CAPABILITY_STATEMENT_VERSION,
|
|
146
|
+
approved_servers: [...servers],
|
|
147
|
+
epic_server_mode: doc.epic_server_mode,
|
|
148
|
+
recipe: doc.recipe,
|
|
149
|
+
grant_state: doc.grant_state,
|
|
150
|
+
written_at: writtenAt,
|
|
151
|
+
};
|
|
152
|
+
if (hasUpload)
|
|
153
|
+
result.sfcc_upload = doc.sfcc_upload;
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The lead line plus the validated mode's guidance paragraph, joined by one
|
|
158
|
+
* newline, or null when the statement is invalid. In `local` mode with
|
|
159
|
+
* `sfcc_upload` "available", the local upload sentence follows the paragraph
|
|
160
|
+
* after one space. No capability bullets, leading blank line, or trailing newline.
|
|
161
|
+
*
|
|
162
|
+
* This is the TypeScript copy of the planner-facing contract. It must NOT be
|
|
163
|
+
* appended to the implement-worker prompt: the epic-server worker instruction
|
|
164
|
+
* builders own those instructions.
|
|
165
|
+
*/
|
|
166
|
+
export function renderEpicServerVerificationGuidance(statement) {
|
|
167
|
+
const valid = validateEpicCapabilityStatement(statement);
|
|
168
|
+
if (valid === null)
|
|
169
|
+
return null;
|
|
170
|
+
let paragraph = EPIC_SERVER_VERIFICATION_GUIDANCE[valid.epic_server_mode];
|
|
171
|
+
if (valid.epic_server_mode === "local" && valid.sfcc_upload === "available") {
|
|
172
|
+
paragraph = `${paragraph} ${EPIC_SERVER_LOCAL_SFCC_UPLOAD_GUIDANCE}`;
|
|
173
|
+
}
|
|
174
|
+
return `${EPIC_SERVER_VERIFICATION_LEAD}\n${paragraph}`;
|
|
175
|
+
}
|
|
@@ -6,31 +6,42 @@
|
|
|
6
6
|
* recognition cannot be a fixed SHA list. Instead a file is recognized as
|
|
7
7
|
* Bridge-rendered only when its ENTIRE bytes equal a re-render: of the current
|
|
8
8
|
* proposal, of the command extracted from the file's own fixed stored-command
|
|
9
|
-
* step by a renderer version Bridge actually published
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* step by a renderer version Bridge actually published (with the toolchain set
|
|
10
|
+
* from the file's own header, for the versions that wrote one), or of the command
|
|
11
|
+
* AND the toolchain set extracted from a current-version file's own header. A
|
|
12
|
+
* version marker alone proves nothing; a hand-edited or hostile file can claim any
|
|
12
13
|
* version it likes, and a marker that does not reproduce the whole file is
|
|
13
14
|
* refused.
|
|
14
15
|
*
|
|
15
16
|
* Leaf module: no filesystem, network, or subprocess access, and no YAML parser.
|
|
16
17
|
* Nothing here logs file content.
|
|
17
18
|
*/
|
|
18
|
-
import { EPIC_CI_COMMAND_LINE_PREFIX, EPIC_CI_COMMAND_STEP_NAME, EPIC_CI_WORKFLOW_PATH, EPIC_CI_WORKFLOW_TOOLCHAINS_MARKER_KEY, renderEpicImplementerCiWorkflow, } from "./epic-ci-workflow.js";
|
|
19
|
+
import { EPIC_CI_COMMAND_LINE_PREFIX, EPIC_CI_COMMAND_STEP_NAME, EPIC_CI_WORKFLOW_DEPENDENCY_INSTALL_MARKER_KEY, EPIC_CI_WORKFLOW_PATH, EPIC_CI_WORKFLOW_TOOLCHAINS_MARKER_KEY, renderEpicImplementerCiWorkflow, serializeEpicCiDependencyInstall, } from "./epic-ci-workflow.js";
|
|
19
20
|
import { renderEpicCiWorkflowV1 } from "./epic-ci-workflow-v1.js";
|
|
21
|
+
import { renderEpicCiWorkflowV2 } from "./epic-ci-workflow-v2.js";
|
|
22
|
+
import { renderEpicCiWorkflowV3 } from "./epic-ci-workflow-v3.js";
|
|
23
|
+
import { parseDependencyInstallStrict } from "./dependency-install-declarations.js";
|
|
20
24
|
import { parseRepositoryToolchains, } from "./repository-toolchains.js";
|
|
21
25
|
import { TestCommandValidationError, validateTestCommand } from "./test-command-validation.js";
|
|
22
26
|
/**
|
|
23
27
|
* Renderers for every OLDER published version, keyed by version.
|
|
24
28
|
*
|
|
25
|
-
* Version 1 is frozen in `epic-ci-workflow-v1.ts`,
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* shipped
|
|
29
|
+
* Version 1 is frozen in `epic-ci-workflow-v1.ts`, version 2 in
|
|
30
|
+
* `epic-ci-workflow-v2.ts`, and version 3 in `epic-ci-workflow-v3.ts`, each unchanged,
|
|
31
|
+
* so their exact bytes stay recognizable. Version 1 uses only a command, because it
|
|
32
|
+
* provisioned no toolchain; versions 2 and 3 also need the toolchain set their header
|
|
33
|
+
* records. This map
|
|
34
|
+
* is the published-version preservation contract: a version is added here only
|
|
35
|
+
* by freezing the renderer that shipped, and an entry is never edited or removed,
|
|
36
|
+
* or customers' installed files would stop being recognized as upgradeable.
|
|
37
|
+
* Inventing an entry for a version that never shipped would let a file Bridge
|
|
38
|
+
* never wrote be "upgraded".
|
|
32
39
|
*/
|
|
33
|
-
export const EPIC_CI_WORKFLOW_HISTORICAL_RENDERERS = new Map([
|
|
40
|
+
export const EPIC_CI_WORKFLOW_HISTORICAL_RENDERERS = new Map([
|
|
41
|
+
[1, (command) => renderEpicCiWorkflowV1(command)],
|
|
42
|
+
[2, (command, toolchains) => (toolchains === null ? null : renderEpicCiWorkflowV2(command, toolchains))],
|
|
43
|
+
[3, (command, toolchains) => (toolchains === null ? null : renderEpicCiWorkflowV3(command, toolchains))],
|
|
44
|
+
]);
|
|
34
45
|
/**
|
|
35
46
|
* Extract and validate the command from the fixed stored-command step; `null`
|
|
36
47
|
* if the step is absent, duplicated, malformed, or its command is invalid.
|
|
@@ -90,28 +101,71 @@ export function extractEpicCiWorkflowToolchains(content) {
|
|
|
90
101
|
return null;
|
|
91
102
|
return parseRepositoryToolchains(markers[0].slice(prefix.length));
|
|
92
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* BAPI-1677 — extract the approved install entries from a version-4 header; `null` if
|
|
106
|
+
* the marker is absent, duplicated, malformed, not in the one canonical form, or
|
|
107
|
+
* refused by the shared rules. A marker-only claim is not enough: the caller must
|
|
108
|
+
* still reproduce the whole file from it.
|
|
109
|
+
*/
|
|
110
|
+
export function extractEpicCiWorkflowDependencyInstall(content) {
|
|
111
|
+
const prefix = "# " + EPIC_CI_WORKFLOW_DEPENDENCY_INSTALL_MARKER_KEY + ": ";
|
|
112
|
+
const markers = content.split("\n").filter((line) => line.startsWith(prefix));
|
|
113
|
+
if (markers.length !== 1)
|
|
114
|
+
return null;
|
|
115
|
+
const raw = markers[0].slice(prefix.length);
|
|
116
|
+
let parsed;
|
|
117
|
+
try {
|
|
118
|
+
parsed = JSON.parse(raw);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
if (!Array.isArray(parsed))
|
|
124
|
+
return null;
|
|
125
|
+
const entries = parseDependencyInstallStrict(parsed);
|
|
126
|
+
if (entries === null || serializeEpicCiDependencyInstall(entries) !== raw)
|
|
127
|
+
return null;
|
|
128
|
+
return entries;
|
|
129
|
+
}
|
|
93
130
|
/**
|
|
94
131
|
* Classify `existing` (`null` when absent) against the proposal for
|
|
95
|
-
* `proposedCommand` and `
|
|
96
|
-
* line-ending differences are differences.
|
|
132
|
+
* `proposedCommand`, `proposedToolchains`, and `proposedDependencyInstall`. Comparison
|
|
133
|
+
* is on raw bytes; line-ending differences are differences.
|
|
97
134
|
*/
|
|
98
|
-
export function classifyEpicCiWorkflowContent(existing, proposedCommand, proposedToolchains) {
|
|
135
|
+
export function classifyEpicCiWorkflowContent(existing, proposedCommand, proposedToolchains, proposedDependencyInstall = []) {
|
|
99
136
|
if (existing === null)
|
|
100
137
|
return "not_installed";
|
|
101
|
-
if (existing === renderEpicImplementerCiWorkflow(proposedCommand, proposedToolchains))
|
|
138
|
+
if (existing === renderEpicImplementerCiWorkflow(proposedCommand, proposedToolchains, proposedDependencyInstall))
|
|
102
139
|
return "identical";
|
|
103
140
|
const extracted = extractEpicCiWorkflowCommand(existing);
|
|
104
141
|
if (extracted === null)
|
|
105
142
|
return "modified_or_unrecognized";
|
|
143
|
+
// Both inputs of a rendering come from the file itself, and the whole file must
|
|
144
|
+
// reproduce from them. The header marker is untrusted until that is true.
|
|
145
|
+
const toolchains = extractEpicCiWorkflowToolchains(existing);
|
|
106
146
|
for (const render of EPIC_CI_WORKFLOW_HISTORICAL_RENDERERS.values()) {
|
|
107
|
-
|
|
147
|
+
let rendered;
|
|
148
|
+
try {
|
|
149
|
+
rendered = render(extracted, toolchains);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (rendered !== null && existing === rendered)
|
|
108
155
|
return "managed_version_older";
|
|
109
156
|
}
|
|
110
|
-
// Another version
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
157
|
+
// Another current-version rendering of a different command, toolchain set, or install list.
|
|
158
|
+
const dependencyInstall = extractEpicCiWorkflowDependencyInstall(existing);
|
|
159
|
+
if (toolchains !== null && dependencyInstall !== null) {
|
|
160
|
+
let rendered = null;
|
|
161
|
+
try {
|
|
162
|
+
rendered = renderEpicImplementerCiWorkflow(extracted, toolchains, dependencyInstall);
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
rendered = null;
|
|
166
|
+
}
|
|
167
|
+
if (rendered === existing)
|
|
168
|
+
return "managed_command_differs";
|
|
115
169
|
}
|
|
116
170
|
return "modified_or_unrecognized";
|
|
117
171
|
}
|
|
@@ -120,6 +174,6 @@ export const EPIC_CI_WORKFLOW_CLASSIFICATION_TEXT = {
|
|
|
120
174
|
not_installed: `${EPIC_CI_WORKFLOW_PATH} is not installed`,
|
|
121
175
|
identical: `${EPIC_CI_WORKFLOW_PATH} already matches the stored test command`,
|
|
122
176
|
managed_version_older: `${EPIC_CI_WORKFLOW_PATH} is an older Bridge-managed version and can be upgraded`,
|
|
123
|
-
managed_command_differs: `${EPIC_CI_WORKFLOW_PATH} was rendered by Bridge for a different test command or toolchain set and can be updated`,
|
|
177
|
+
managed_command_differs: `${EPIC_CI_WORKFLOW_PATH} was rendered by Bridge for a different test command or toolchain set, or a different install list, and can be updated`,
|
|
124
178
|
modified_or_unrecognized: `${EPIC_CI_WORKFLOW_PATH} has been modified or is not a file Bridge rendered`,
|
|
125
179
|
};
|