@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,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The epic-server record contract (BAPI-1545 defined the minimal reader; BAPI-1546
|
|
3
|
+
* owns the schema and adds the one writer).
|
|
4
|
+
*
|
|
5
|
+
* The record lives at `~/.config/bridge/epic-server/<repo>.json`, outside every
|
|
6
|
+
* worktree, in its own file beside the MCP grant. Version 1:
|
|
7
|
+
*
|
|
8
|
+
* required version: 1
|
|
9
|
+
* required mode: "none" | "local" | "sfcc_shared_active"
|
|
10
|
+
* optional recipe: "present" | "absent"
|
|
11
|
+
* sfcc_shared_active, required:
|
|
12
|
+
* sfcc: { sandbox_id, credential_ref, storefront_origin }
|
|
13
|
+
* local / none, optional (BAPI-1669):
|
|
14
|
+
* sfcc: { sandbox_id, credential_ref, storefront_origin? }
|
|
15
|
+
*
|
|
16
|
+
* An approved sandbox is allowed beside every mode: the upload verb needs only
|
|
17
|
+
* the approved sandbox, and the mode only picks where browser checks run. The
|
|
18
|
+
* version stays 1. An older reader rejects `sfcc` on a local or none record, so
|
|
19
|
+
* it reads one as `unusable` (fail-safe: no server). Reader and writer ship
|
|
20
|
+
* together.
|
|
21
|
+
*
|
|
22
|
+
* `sandbox_id` is a non-secret instance identifier. `credential_ref` is the name
|
|
23
|
+
* of an entry in this repository's worker credential record (BAPI-1667), the one
|
|
24
|
+
* for the sandbox account; a legacy credential-store target such as `sfcc:<id>`
|
|
25
|
+
* still validates and reads as before. Nothing resolves it yet, so it is
|
|
26
|
+
* informational. The record NEVER holds a secret value. `storefront_origin` is the approved http(s) origin
|
|
27
|
+
* the browser is limited to; it is required for `sfcc_shared_active` and optional
|
|
28
|
+
* otherwise, but must normalize when present. A `local` record with `sfcc` is
|
|
29
|
+
* still local to the local-helper verbs.
|
|
30
|
+
*
|
|
31
|
+
* Unknown top-level keys are tolerated, matching the grant's schema rule. This
|
|
32
|
+
* module is the ONLY reader and writer of the record: the setup item, the
|
|
33
|
+
* capability statement, the driver's helper, and the executor all import from
|
|
34
|
+
* here (coherence finding F-1).
|
|
35
|
+
*
|
|
36
|
+
* Install reads the record to build the advisory capability statement:
|
|
37
|
+
*
|
|
38
|
+
* - no file → epic_server_mode "none", recipe "unknown"
|
|
39
|
+
* - unreadable / bad → epic_server_mode "unknown", recipe "unknown"
|
|
40
|
+
* - valid → its mode, and its recipe or "unknown" when omitted
|
|
41
|
+
*
|
|
42
|
+
* The statement's `recipe` value says whether repository guidance was found at
|
|
43
|
+
* setup. It is never proof that a run recipe was proven or that a server is live.
|
|
44
|
+
* Recipe availability is never inferred from worktree files.
|
|
45
|
+
*/
|
|
46
|
+
import path from "path";
|
|
47
|
+
import { repositoryStateRecordPath } from "./repository-state-paths.js";
|
|
48
|
+
export const EPIC_SERVER_RECORD_VERSION = 1;
|
|
49
|
+
export const EPIC_SERVER_MODES = ["none", "local", "sfcc_shared_active"];
|
|
50
|
+
/** The record path for a repository, or null when the name is unusable. */
|
|
51
|
+
export function epicServerRecordPath(repoName, deps) {
|
|
52
|
+
const resolved = repositoryStateRecordPath("epic-server", repoName, deps);
|
|
53
|
+
return resolved.ok ? resolved.path : null;
|
|
54
|
+
}
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
// Field rules
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
const SANDBOX_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
59
|
+
/** A credential-store target: printable, no whitespace, bounded. */
|
|
60
|
+
const CREDENTIAL_REF_RE = /^[A-Za-z0-9][A-Za-z0-9._:@/+-]{0,199}$/;
|
|
61
|
+
const MAX_ORIGIN_CHARS = 2048;
|
|
62
|
+
/** True for a usable non-secret sandbox identifier. */
|
|
63
|
+
export function isValidSfccSandboxId(value) {
|
|
64
|
+
return typeof value === "string" && SANDBOX_ID_RE.test(value);
|
|
65
|
+
}
|
|
66
|
+
/** True for a usable credential-store reference. It names a secret; it is never one. */
|
|
67
|
+
export function isValidCredentialReference(value) {
|
|
68
|
+
return typeof value === "string" && CREDENTIAL_REF_RE.test(value) && !value.includes("//");
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Normalize an approved storefront origin. Only an http or https origin with no
|
|
72
|
+
* credentials, query, fragment, or path beyond `/` is accepted. Returns the
|
|
73
|
+
* normalized origin (no trailing slash), or null.
|
|
74
|
+
*/
|
|
75
|
+
export function normalizeStorefrontOrigin(value) {
|
|
76
|
+
if (typeof value !== "string" || value.length === 0 || value.length > MAX_ORIGIN_CHARS)
|
|
77
|
+
return null;
|
|
78
|
+
if (/\s/.test(value))
|
|
79
|
+
return null;
|
|
80
|
+
let url;
|
|
81
|
+
try {
|
|
82
|
+
url = new URL(value);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
88
|
+
return null;
|
|
89
|
+
if (url.username !== "" || url.password !== "")
|
|
90
|
+
return null;
|
|
91
|
+
if (url.search !== "" || url.hash !== "" || value.includes("?") || value.includes("#"))
|
|
92
|
+
return null;
|
|
93
|
+
if (url.pathname !== "/" && url.pathname !== "")
|
|
94
|
+
return null;
|
|
95
|
+
if (url.hostname === "")
|
|
96
|
+
return null;
|
|
97
|
+
// The parsed origin is the normalized form (lowercase host, no default port).
|
|
98
|
+
return url.origin;
|
|
99
|
+
}
|
|
100
|
+
function isPlainObject(value) {
|
|
101
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
102
|
+
}
|
|
103
|
+
function validateSfccTarget(raw, originRequired) {
|
|
104
|
+
if (!isPlainObject(raw))
|
|
105
|
+
return null;
|
|
106
|
+
if (!isValidSfccSandboxId(raw.sandbox_id))
|
|
107
|
+
return null;
|
|
108
|
+
if (!isValidCredentialReference(raw.credential_ref))
|
|
109
|
+
return null;
|
|
110
|
+
const target = { sandbox_id: raw.sandbox_id, credential_ref: raw.credential_ref };
|
|
111
|
+
if (raw.storefront_origin === undefined) {
|
|
112
|
+
if (originRequired)
|
|
113
|
+
return null;
|
|
114
|
+
return target;
|
|
115
|
+
}
|
|
116
|
+
// A supplied origin must normalize in every mode; it is never treated as omitted.
|
|
117
|
+
const origin = normalizeStorefrontOrigin(raw.storefront_origin);
|
|
118
|
+
if (origin === null)
|
|
119
|
+
return null;
|
|
120
|
+
target.storefront_origin = origin;
|
|
121
|
+
return target;
|
|
122
|
+
}
|
|
123
|
+
/** Validate a parsed record. Unknown top-level keys are dropped. */
|
|
124
|
+
export function validateEpicServerRecord(raw) {
|
|
125
|
+
if (!isPlainObject(raw))
|
|
126
|
+
return null;
|
|
127
|
+
const doc = raw;
|
|
128
|
+
if (doc.version !== EPIC_SERVER_RECORD_VERSION)
|
|
129
|
+
return null;
|
|
130
|
+
if (typeof doc.mode !== "string" || !EPIC_SERVER_MODES.includes(doc.mode))
|
|
131
|
+
return null;
|
|
132
|
+
const record = { version: EPIC_SERVER_RECORD_VERSION, mode: doc.mode };
|
|
133
|
+
if (doc.recipe !== undefined) {
|
|
134
|
+
if (doc.recipe !== "present" && doc.recipe !== "absent")
|
|
135
|
+
return null;
|
|
136
|
+
record.recipe = doc.recipe;
|
|
137
|
+
}
|
|
138
|
+
if (record.mode === "sfcc_shared_active" || doc.sfcc !== undefined) {
|
|
139
|
+
const sfcc = validateSfccTarget(doc.sfcc, record.mode === "sfcc_shared_active");
|
|
140
|
+
if (sfcc === null)
|
|
141
|
+
return null;
|
|
142
|
+
record.sfcc = sfcc;
|
|
143
|
+
}
|
|
144
|
+
return record;
|
|
145
|
+
}
|
|
146
|
+
// ---------------------------------------------------------------------------
|
|
147
|
+
// Reader
|
|
148
|
+
// ---------------------------------------------------------------------------
|
|
149
|
+
/** Read the record. Only `ENOENT` is `absent`; anything else unusable is `unusable`. */
|
|
150
|
+
export async function readEpicServerRecord(repoName, deps) {
|
|
151
|
+
const resolved = repositoryStateRecordPath("epic-server", repoName, deps);
|
|
152
|
+
if (!resolved.ok)
|
|
153
|
+
return { state: "unusable" };
|
|
154
|
+
if (deps.lstat) {
|
|
155
|
+
try {
|
|
156
|
+
const st = await deps.lstat(resolved.path);
|
|
157
|
+
if (st.isSymbolicLink() || !st.isFile())
|
|
158
|
+
return { state: "unusable" };
|
|
159
|
+
if ((deps.platform ?? process.platform) !== "win32" && (st.mode & 0o077) !== 0)
|
|
160
|
+
return { state: "unusable" };
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
const code = err && typeof err === "object" ? err.code : undefined;
|
|
164
|
+
return code === "ENOENT" ? { state: "absent" } : { state: "unusable" };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
let text;
|
|
168
|
+
try {
|
|
169
|
+
text = await deps.readFile(resolved.path);
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
const code = err && typeof err === "object" ? err.code : undefined;
|
|
173
|
+
return code === "ENOENT" ? { state: "absent" } : { state: "unusable" };
|
|
174
|
+
}
|
|
175
|
+
let parsed;
|
|
176
|
+
try {
|
|
177
|
+
parsed = JSON.parse(text);
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
return { state: "unusable" };
|
|
181
|
+
}
|
|
182
|
+
const record = validateEpicServerRecord(parsed);
|
|
183
|
+
return record === null ? { state: "unusable" } : { state: "ok", record };
|
|
184
|
+
}
|
|
185
|
+
let tempCounter = 0;
|
|
186
|
+
function defaultTempSuffix() {
|
|
187
|
+
tempCounter += 1;
|
|
188
|
+
return `${process.pid}.${tempCounter}.${Date.now().toString(36)}`;
|
|
189
|
+
}
|
|
190
|
+
/** Serialize a record deterministically: 2-space indent and a trailing newline. */
|
|
191
|
+
export function formatEpicServerRecord(record) {
|
|
192
|
+
const out = { version: record.version, mode: record.mode };
|
|
193
|
+
if (record.recipe !== undefined)
|
|
194
|
+
out.recipe = record.recipe;
|
|
195
|
+
if (record.sfcc !== undefined) {
|
|
196
|
+
out.sfcc = {
|
|
197
|
+
sandbox_id: record.sfcc.sandbox_id,
|
|
198
|
+
credential_ref: record.sfcc.credential_ref,
|
|
199
|
+
...(record.sfcc.storefront_origin !== undefined ? { storefront_origin: record.sfcc.storefront_origin } : {}),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
return `${JSON.stringify(out, null, 2)}\n`;
|
|
203
|
+
}
|
|
204
|
+
async function isSymlink(deps, filePath) {
|
|
205
|
+
if (!deps.lstat)
|
|
206
|
+
return false;
|
|
207
|
+
try {
|
|
208
|
+
return (await deps.lstat(filePath)).isSymbolicLink();
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Publish a record durably, following `writeMcpGrant()`: an exclusively created
|
|
216
|
+
* same-directory temp file with mode `0600`, write, fsync, close, chmod `0600`,
|
|
217
|
+
* atomic rename, then a best-effort directory fsync. The `epic-server` directory
|
|
218
|
+
* is created and held at mode `0700`. A symbolic link at the directory or record
|
|
219
|
+
* path is refused. A failure leaves any previous record in place and returns a
|
|
220
|
+
* fixed error that never echoes a field value.
|
|
221
|
+
*/
|
|
222
|
+
export async function writeEpicServerRecord(repoName, record, deps) {
|
|
223
|
+
const validated = validateEpicServerRecord(record);
|
|
224
|
+
if (validated === null)
|
|
225
|
+
return { ok: false, error: "the epic-server record to write is not valid" };
|
|
226
|
+
const resolved = repositoryStateRecordPath("epic-server", repoName, deps);
|
|
227
|
+
if (!resolved.ok)
|
|
228
|
+
return { ok: false, error: "the repository name is not usable as a record name" };
|
|
229
|
+
const isPosix = deps.platform !== "win32";
|
|
230
|
+
const dir = resolved.dir;
|
|
231
|
+
const tempPath = path.join(dir, `${path.basename(resolved.path)}.${(deps.tempSuffix ?? defaultTempSuffix)()}.tmp`);
|
|
232
|
+
let handle;
|
|
233
|
+
try {
|
|
234
|
+
await deps.mkdir(dir, { recursive: true });
|
|
235
|
+
if (await isSymlink(deps, dir))
|
|
236
|
+
return { ok: false, error: "the epic-server record directory is a symbolic link" };
|
|
237
|
+
if (await isSymlink(deps, resolved.path))
|
|
238
|
+
return { ok: false, error: "the epic-server record path is a symbolic link" };
|
|
239
|
+
if (isPosix)
|
|
240
|
+
await deps.chmod(dir, 0o700);
|
|
241
|
+
handle = await deps.open(tempPath, "wx", isPosix ? 0o600 : undefined);
|
|
242
|
+
await handle.writeFile(formatEpicServerRecord(validated), { encoding: "utf-8" });
|
|
243
|
+
await handle.sync();
|
|
244
|
+
await handle.close();
|
|
245
|
+
handle = undefined;
|
|
246
|
+
if (isPosix)
|
|
247
|
+
await deps.chmod(tempPath, 0o600);
|
|
248
|
+
await deps.rename(tempPath, resolved.path);
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
if (handle) {
|
|
252
|
+
try {
|
|
253
|
+
await handle.close();
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
/* a close failure must not mask the write failure */
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (deps.unlink) {
|
|
260
|
+
try {
|
|
261
|
+
await deps.unlink(tempPath);
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
/* best-effort temp cleanup; the previous record is untouched */
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return { ok: false, error: "the epic-server record could not be written" };
|
|
268
|
+
}
|
|
269
|
+
if (isPosix) {
|
|
270
|
+
try {
|
|
271
|
+
const dirHandle = await deps.open(dir, "r");
|
|
272
|
+
try {
|
|
273
|
+
await dirHandle.sync();
|
|
274
|
+
}
|
|
275
|
+
finally {
|
|
276
|
+
await dirHandle.close();
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
/* best-effort: the file itself was fsynced and renamed */
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return { ok: true, path: resolved.path };
|
|
284
|
+
}
|
|
285
|
+
/** True when two records select the same configuration (the setup item's convergence test). */
|
|
286
|
+
export function sameEpicServerRecord(a, b) {
|
|
287
|
+
return formatEpicServerRecord(a) === formatEpicServerRecord(b);
|
|
288
|
+
}
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* No MCP tool is registered from this module — the `tools/list` token budget is
|
|
29
29
|
* effectively frozen.
|
|
30
30
|
*/
|
|
31
|
-
import { buildConductorJiraUrl, buildConductorVcsUrl, fetchConductorJsonPostWithTimeout, fetchConductorJsonPutWithTimeout, fetchConductorJsonWithTimeout, fetchConductorReadiness, fetchEffectiveSupervisorConfig, fetchEffectiveSupervisorSetup, fetchEpicRunState, fetchParseStatus, fetchPrReviewStatus, pollCiChecksForCommit, ConductorBridgeApiError, CONDUCTOR_FETCH_TIMEOUT_MS, } from "../conductor/bridge-api-client.js";
|
|
31
|
+
import { acquireConductorReadiness, buildConductorJiraUrl, buildConductorVcsUrl, fetchConductorJsonPostWithTimeout, fetchConductorJsonPutWithTimeout, fetchConductorJsonWithTimeout, fetchConductorReadiness, fetchEffectiveSupervisorConfig, fetchEffectiveSupervisorSetup, fetchEpicRunState, fetchParseStatus, fetchPrReviewStatus, pollCiChecksForCommit, ConductorBridgeApiError, CONDUCTOR_FETCH_TIMEOUT_MS, } from "../conductor/bridge-api-client.js";
|
|
32
32
|
/**
|
|
33
33
|
* The one message returned for any failure whose cause cannot be described
|
|
34
34
|
* without risking the credential. Stable so callers can match on it.
|
|
@@ -142,8 +142,16 @@ export async function getEffectiveSupervisorSetup(access, fetchImpl = globalThis
|
|
|
142
142
|
* missing `required_checks_empty` becomes a failure here rather than an
|
|
143
143
|
* apparently-healthy report.
|
|
144
144
|
*/
|
|
145
|
-
export async function getConductorReadiness(access, fetchImpl = globalThis.fetch) {
|
|
146
|
-
|
|
145
|
+
export async function getConductorReadiness(access, fetchImpl = globalThis.fetch, options = {}) {
|
|
146
|
+
// BAPI-1593 — the shared acquisition policy: one attempt plus at most one retry.
|
|
147
|
+
// The last sanitized failure travels through `wrap`, so the non-throwing
|
|
148
|
+
// `BridgeResult` contract and its redaction are unchanged.
|
|
149
|
+
return wrap(access, async () => {
|
|
150
|
+
const acquired = await acquireConductorReadiness(() => fetchConductorReadiness(access, fetchImpl), options);
|
|
151
|
+
if (acquired.kind === "ready")
|
|
152
|
+
return acquired.readiness;
|
|
153
|
+
throw acquired.error;
|
|
154
|
+
});
|
|
147
155
|
}
|
|
148
156
|
/**
|
|
149
157
|
* `POST /jira/resolve-ci-checks` — discover and classify the repository's CI
|
|
@@ -132,3 +132,46 @@ export function buildEscalationReachabilityCheck(report, callerChannel) {
|
|
|
132
132
|
}
|
|
133
133
|
return warn(uncertain);
|
|
134
134
|
}
|
|
135
|
+
function emailTransportState(report) {
|
|
136
|
+
const diagnostics = report === null || report.unavailableSources?.includes("server") === true
|
|
137
|
+
? null
|
|
138
|
+
: report.diagnostics ?? null;
|
|
139
|
+
if (diagnostics === null)
|
|
140
|
+
return "unknown";
|
|
141
|
+
const observed = diagnostics.filter((entry) => entry.id === EMAIL_TRANSPORT_LIVE_DIAGNOSTIC_ID);
|
|
142
|
+
if (observed.length !== 1)
|
|
143
|
+
return "unknown";
|
|
144
|
+
const [observation] = observed;
|
|
145
|
+
if (isFailedEmailTransportDiagnostic(observation))
|
|
146
|
+
return "not_live";
|
|
147
|
+
return observation.severity === "advisory" &&
|
|
148
|
+
observation.applicability === "applicable" &&
|
|
149
|
+
observation.verdict === "passed"
|
|
150
|
+
? "live"
|
|
151
|
+
: "unknown";
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Classify what the reachability output may claim (BAPI-1595). Pure.
|
|
155
|
+
*
|
|
156
|
+
* The confirmed "no reachable channel" line needs BOTH facts established. An unknown
|
|
157
|
+
* webhook declaration (an unknown channel) or an unknown email transport yields
|
|
158
|
+
* `uncertain`, which is a warning that makes no "no channel" claim. A declared
|
|
159
|
+
* webhook that did not answer stays a warning (`webhook_warning`), including when
|
|
160
|
+
* email is live. Everything else is `omitted`.
|
|
161
|
+
*/
|
|
162
|
+
export function classifyEscalationReachabilityPresentation(report, callerChannel) {
|
|
163
|
+
const channel = resolveEffectiveEscalationChannel(report, callerChannel);
|
|
164
|
+
if (channel === "webhook") {
|
|
165
|
+
const last = report?.webhook_last_delivery;
|
|
166
|
+
return last === "failed" || last === "unknown" ? "webhook_warning" : "omitted";
|
|
167
|
+
}
|
|
168
|
+
if (channel === "unknown")
|
|
169
|
+
return "uncertain";
|
|
170
|
+
// No webhook is declared (the channel is email, or none). The email transport decides.
|
|
171
|
+
const transport = emailTransportState(report);
|
|
172
|
+
if (transport === "not_live")
|
|
173
|
+
return "confirmed_no_channel";
|
|
174
|
+
if (transport === "live")
|
|
175
|
+
return channel === "email" ? "omitted" : "uncertain";
|
|
176
|
+
return "uncertain";
|
|
177
|
+
}
|