@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.
Files changed (181) hide show
  1. package/README.md +5 -5
  2. package/build/agent-launchers/claude-executor-adapter.js +15 -0
  3. package/build/agents.generated.js +6 -6
  4. package/build/bridge-config.js +7 -1
  5. package/build/bridge-permissions.js +30 -0
  6. package/build/ci-system-detection.js +50 -0
  7. package/build/ci-trigger-adapters.js +631 -0
  8. package/build/ci-trigger-install.js +106 -0
  9. package/build/codex-launcher-pin.js +33 -2
  10. package/build/codex-skill-adapter.js +3 -1
  11. package/build/command-host.js +33 -0
  12. package/build/command-provisioning.js +4 -3
  13. package/build/commands.generated.js +7 -6
  14. package/build/conductor/bridge-api-client.js +867 -35
  15. package/build/conductor/bring-up-facts.js +18 -5
  16. package/build/conductor/command-drift-production.js +42 -17
  17. package/build/conductor/command-drift.js +48 -1
  18. package/build/conductor/declare-blocked.js +554 -0
  19. package/build/conductor/declared-extras.js +335 -0
  20. package/build/conductor/doctor.js +108 -21
  21. package/build/conductor/driver-commands.js +141 -0
  22. package/build/conductor/driver-guard.js +277 -0
  23. package/build/conductor/driver-lapse.js +321 -0
  24. package/build/conductor/driver-pass-output.js +104 -0
  25. package/build/conductor/driver-pass.js +571 -0
  26. package/build/conductor/driver-register.js +176 -0
  27. package/build/conductor/driver-release.js +174 -0
  28. package/build/conductor/driver-session-state.js +315 -0
  29. package/build/conductor/epic-branch-ci-inspection.js +281 -43
  30. package/build/conductor/epic-implementer-cli.js +199 -15
  31. package/build/conductor/epic-server-database.js +162 -0
  32. package/build/conductor/epic-server-guidance.js +278 -0
  33. package/build/conductor/epic-server-journal.js +239 -0
  34. package/build/conductor/epic-server-processes.js +324 -0
  35. package/build/conductor/epic-server-recipe.js +397 -0
  36. package/build/conductor/epic-server-runtime.js +1207 -0
  37. package/build/conductor/epic-server-sfcc-upload.js +1567 -0
  38. package/build/conductor/epic-server-sfcc.js +85 -0
  39. package/build/conductor/epic-server-state.js +427 -0
  40. package/build/conductor/epic-server.js +647 -0
  41. package/build/conductor/gate-discovery.js +196 -11
  42. package/build/conductor/gate-settings-review.js +261 -4
  43. package/build/conductor/launch-need-probes.js +6 -53
  44. package/build/conductor/launch-plan.js +313 -156
  45. package/build/conductor/prerequisite-inputs.js +879 -45
  46. package/build/conductor/readiness-assessment.js +16 -1
  47. package/build/conductor/readiness-cli.js +20 -9
  48. package/build/conductor/readiness-prerequisites.js +28 -9
  49. package/build/conductor/readiness-sections.js +133 -126
  50. package/build/conductor/readiness.js +1 -1
  51. package/build/conductor/recovery-cli.js +13 -2
  52. package/build/conductor/tools.js +6 -5
  53. package/build/conductor/wait-run-attention.js +2 -2
  54. package/build/conductor/wait-run-cli.js +208 -22
  55. package/build/conductor/worker-database-doctor-inspector.js +33 -2
  56. package/build/conductor/worker-setup-tally.js +27 -0
  57. package/build/credential-delivery.js +280 -0
  58. package/build/credential-launch-safety.js +142 -0
  59. package/build/credential-materialization.js +91 -16
  60. package/build/credential-references-node-deps.js +29 -0
  61. package/build/credential-references.js +1394 -0
  62. package/build/credential-references.test-fixtures.js +211 -0
  63. package/build/credential-scan-conventions.js +145 -0
  64. package/build/credential-scan.js +517 -0
  65. package/build/credential-store.js +121 -1
  66. package/build/credentials-cli.js +252 -3
  67. package/build/dependency-install-declarations.js +102 -1
  68. package/build/docs.generated.js +10 -3
  69. package/build/doctor.js +95 -3
  70. package/build/drive-epic-help.js +21 -2
  71. package/build/drive-epic.js +2095 -375
  72. package/build/engine-paths.js +20 -0
  73. package/build/epic-branch-ci-summary.js +157 -0
  74. package/build/epic-capability-statement.js +175 -0
  75. package/build/epic-ci-workflow-drift.js +77 -23
  76. package/build/epic-ci-workflow-install.js +137 -44
  77. package/build/epic-ci-workflow-v2.js +274 -0
  78. package/build/epic-ci-workflow-v3.js +273 -0
  79. package/build/epic-ci-workflow.js +165 -18
  80. package/build/epic-implementer-bin.js +2204 -56
  81. package/build/epic-launch-context.js +702 -0
  82. package/build/epic-server-record.js +288 -0
  83. package/build/epic-shared/bridge-client.js +11 -3
  84. package/build/escalation-reachability.js +43 -0
  85. package/build/executor/ci-fix-test-runs.js +334 -0
  86. package/build/executor/completion-contract.js +8 -1
  87. package/build/executor/credential-delivery-step.js +168 -0
  88. package/build/executor/deps.js +3 -1
  89. package/build/executor/env.js +98 -23
  90. package/build/executor/epic-server-context.js +157 -0
  91. package/build/executor/gate-qualification-job.js +127 -26
  92. package/build/executor/guarded-fast-forward-push.js +13 -8
  93. package/build/executor/http-client.js +52 -5
  94. package/build/executor/job-runner.js +577 -81
  95. package/build/executor/observation.js +8 -0
  96. package/build/executor/permissions.js +85 -3
  97. package/build/executor/pre-pr-checks.js +363 -0
  98. package/build/executor/prompt-spec.js +149 -3
  99. package/build/executor/reconcile-overlap-job.js +5 -3
  100. package/build/executor/required-work-diagnostics.js +4 -2
  101. package/build/executor/required-work-ledger.js +936 -38
  102. package/build/executor/results.js +58 -0
  103. package/build/executor/terminal-mutation.js +8 -0
  104. package/build/executor/worker-command.js +72 -3
  105. package/build/executor/worker-database-config.js +281 -0
  106. package/build/executor/worker-database-target.js +16 -12
  107. package/build/executor/worker-database.js +320 -101
  108. package/build/executor/worker-finalization.js +7 -1
  109. package/build/executor/worker-resources.js +25 -3
  110. package/build/executor/worker-verification-guidance.js +18 -3
  111. package/build/executor/worktree.js +20 -1
  112. package/build/executor-launch.js +58 -4
  113. package/build/generated-assets-catalog.js +2 -2
  114. package/build/git-exclude-lock.js +187 -0
  115. package/build/index.js +824 -366
  116. package/build/init.js +26 -11
  117. package/build/install-bridge-conductor-answers.js +528 -0
  118. package/build/install-bridge-conductor-apply.js +288 -0
  119. package/build/install-bridge-conductor-assessment.js +1222 -0
  120. package/build/install-bridge-conductor-compact.js +186 -0
  121. package/build/install-bridge-conductor-contracts.js +72 -0
  122. package/build/install-bridge-conductor-gate.js +1312 -198
  123. package/build/install-bridge-conductor-setup.js +577 -83
  124. package/build/install-bridge-conductor.js +3381 -544
  125. package/build/install-bridge.js +280 -25
  126. package/build/install-doctor.js +38 -8
  127. package/build/install-maintenance.js +26 -3
  128. package/build/install-sfcc-detection.js +120 -0
  129. package/build/install-sfcc-setup.js +185 -0
  130. package/build/launcher-config-inspection.js +162 -1
  131. package/build/mcp-grant-candidates.js +779 -0
  132. package/build/mcp-grant-doctor.js +63 -0
  133. package/build/mcp-grant.js +288 -0
  134. package/build/mcp-host-targets.js +8 -0
  135. package/build/mcp-identity.js +23 -0
  136. package/build/mcp-invoke.js +292 -15
  137. package/build/mcp-presets.js +107 -0
  138. package/build/mcp-provisioning.js +155 -6
  139. package/build/mcp-registration-doctor.js +31 -2
  140. package/build/mcp-server-invocation.js +19 -1
  141. package/build/merge-workflow-install.js +243 -110
  142. package/build/pipelines.generated.js +7 -6
  143. package/build/plan-discovery.js +97 -4
  144. package/build/plan-execution-ledger.js +100 -7
  145. package/build/plan-generation-io.js +262 -0
  146. package/build/plan-generation.js +424 -0
  147. package/build/plane/build-freshness.js +6 -1
  148. package/build/plane/cli.js +75 -9
  149. package/build/plane/plane-freshness.js +17 -0
  150. package/build/plane/preflight.js +50 -10
  151. package/build/plane/shutdown.js +19 -0
  152. package/build/plane/status.js +8 -2
  153. package/build/plane/terminal-run-cleanup.js +18 -4
  154. package/build/printed-remedy-commands.js +211 -12
  155. package/build/project-root.js +40 -0
  156. package/build/readiness-check.js +77 -0
  157. package/build/readiness-prerequisites.generated.js +122 -14
  158. package/build/readme.generated.js +1 -1
  159. package/build/repository-state-paths.js +41 -0
  160. package/build/repository-toolchains.js +6 -3
  161. package/build/run-unit-tests-launcher.js +8 -1
  162. package/build/setup-epic.js +1305 -210
  163. package/build/setup-progress.js +44 -0
  164. package/build/setup-question.js +122 -4
  165. package/build/sfcc/credentials.js +3 -2
  166. package/build/sfcc/hostname.js +98 -2
  167. package/build/sfcc/tool-wrapper.js +6 -95
  168. package/build/start-tickets.js +193 -29
  169. package/build/test-support/executor-source-files.js +200 -0
  170. package/build/testing-config-client.js +25 -2
  171. package/build/third-party-mcp-targets.js +63 -2
  172. package/build/ticket-delivery-enrollment.js +9 -0
  173. package/build/upgrade-cli.js +85 -2
  174. package/build/v2-readiness-requirements.js +28 -1
  175. package/build/version.generated.js +3 -3
  176. package/build/with-credentials.js +208 -0
  177. package/build/worktree-credential-delivery.js +340 -0
  178. package/docs/EPIC-IMPLEMENTER-INSTALL.md +9 -1
  179. package/docs/epic-implementer/getting-started.md +3 -1
  180. package/docs/epic-implementer/self-hosting.md +14 -1
  181. package/package.json +2 -2
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Shared, value-free fixtures for the worker credential references tests
3
+ * (BAPI-1646). Later tickets import these rather than building their own.
4
+ *
5
+ * The record builder points every source at paths that do not exist. Sentinel
6
+ * strings go ONLY into fake source contents, never into a record: a test then
7
+ * searches record bytes, CLI output, doctor output, refusals, and statuses for
8
+ * them.
9
+ */
10
+ export const REPO = "catalog-service";
11
+ export const HOME = "/home/tester";
12
+ export const RECORD_PATH = `${HOME}/.config/bridge/worker-credentials/${REPO}.json`;
13
+ export const STORE_PATH = `${HOME}/.config/bridge/credentials.json`;
14
+ export const FALLBACK_STORE_PATH = `${HOME}/.bridge/credentials.json`;
15
+ export const CLAUDE_CONFIG_PATH = `${HOME}/.claude.json`;
16
+ export const CURSOR_CONFIG_PATH = `${HOME}/.cursor/mcp.json`;
17
+ /** Strings that must never appear in any output; they live only in fake sources. */
18
+ export const SENTINELS = {
19
+ value: "SENTINEL-VALUE-7f3a91c2",
20
+ ambient: "SENTINEL-AMBIENT-52be08d4",
21
+ host: "SENTINEL-HOST-c61d77e0",
22
+ store: "SENTINEL-STORE-0a94f3b8",
23
+ path: "/sentinel/secret-path-e1c4",
24
+ selector: "SENTINEL_SELECTOR_9b2d",
25
+ parser: "SENTINEL-PARSER-MESSAGE-4d8f",
26
+ };
27
+ export const ALL_SENTINELS = Object.values(SENTINELS);
28
+ /** One entry per source kind and per level; every source path is absent. */
29
+ export function buildMissingSourceEntries() {
30
+ return [
31
+ {
32
+ name: "sb_file",
33
+ level: "sandbox",
34
+ source: { kind: "file", path: "/srv/creds/dw.json" },
35
+ consumers: [{ kind: "worktree_file", dest: "config/dw.json" }],
36
+ },
37
+ {
38
+ name: "sb_keys",
39
+ level: "sandbox",
40
+ source: { kind: "file_keys", path: "/srv/creds/sandbox.env", format: "dotenv", keys: { SAFE_TOKEN: "SAFE_TOKEN" } },
41
+ consumers: [{ kind: "env" }],
42
+ },
43
+ {
44
+ name: "sb_host",
45
+ level: "sandbox",
46
+ source: { kind: "host_mcp_env", host: "claude", server: "sfcc", keys: { SFCC_CLIENT: "CLIENT_ID" } },
47
+ consumers: [{ kind: "mcp_server", server: "sfcc" }],
48
+ },
49
+ {
50
+ name: "sb_store",
51
+ level: "sandbox",
52
+ source: { kind: "store_bundle", target: "sfcc-sandbox", keys: ["STORE_TOKEN"] },
53
+ consumers: [{ kind: "env" }, { kind: "mcp_server", server: "bridge" }],
54
+ },
55
+ {
56
+ name: "rs_keys",
57
+ level: "restricted",
58
+ source: { kind: "file_keys", path: "/srv/creds/restricted.json", format: "json", keys: { RS_ID: "/client-id" } },
59
+ consumers: [{ kind: "mcp_server", server: "sfcc" }],
60
+ },
61
+ {
62
+ name: "rs_host",
63
+ level: "restricted",
64
+ source: { kind: "host_mcp_env", host: "cursor", server: "other", keys: { RS_HOST: "HOST_KEY" } },
65
+ consumers: [{ kind: "mcp_server", server: "other" }],
66
+ },
67
+ {
68
+ name: "rs_store",
69
+ level: "restricted",
70
+ source: { kind: "store_bundle", target: "rs-target", keys: ["RS_STORE"] },
71
+ consumers: [{ kind: "mcp_server", server: "bridge" }],
72
+ },
73
+ {
74
+ name: "prod_keys",
75
+ level: "production",
76
+ source: { kind: "file_keys", path: "/srv/creds/prod.env", format: "dotenv", keys: { PROD_TOKEN: "PROD_TOKEN" } },
77
+ consumers: [],
78
+ },
79
+ ];
80
+ }
81
+ export function buildMissingSourceRecord(entries = buildMissingSourceEntries(), repoName = REPO) {
82
+ return { version: 1, repo_name: repoName, approved_at: "2026-10-30T12:00:00.000Z", credentials: entries };
83
+ }
84
+ export function recordBytes(record, spaced = true) {
85
+ return spaced ? `${JSON.stringify(record, null, 4)}\n` : JSON.stringify(record);
86
+ }
87
+ export function fsError(code) {
88
+ return Object.assign(new Error(`SENTINEL-PARSER-MESSAGE-${code}`), { code });
89
+ }
90
+ export function createMemoryFs(initial = {}) {
91
+ const files = new Map();
92
+ for (const [p, content] of Object.entries(initial)) {
93
+ files.set(p, { content: Buffer.from(content), mode: 0o600, kind: "file" });
94
+ }
95
+ return { files, dangling: new Set(), errors: new Map(), reads: [] };
96
+ }
97
+ export function putFile(fs, p, content, mode = 0o600, kind = "file") {
98
+ fs.files.set(p, { content: typeof content === "string" ? Buffer.from(content) : content, mode, kind });
99
+ }
100
+ function toStat(entry) {
101
+ return { isFile: () => entry.kind === "file", size: entry.content.length, mode: entry.mode };
102
+ }
103
+ export function createMemoryDeps(fs, overrides = {}) {
104
+ const lookup = (p) => {
105
+ const code = fs.errors.get(p);
106
+ if (code)
107
+ throw fsError(code);
108
+ const entry = fs.files.get(p);
109
+ if (!entry)
110
+ throw fsError("ENOENT");
111
+ return entry;
112
+ };
113
+ return {
114
+ env: {},
115
+ homedir: () => HOME,
116
+ platform: "linux",
117
+ readFile: async (p) => {
118
+ fs.reads.push(p);
119
+ return Buffer.from(lookup(p).content).toString("utf-8");
120
+ },
121
+ readBytes: async (p) => {
122
+ fs.reads.push(p);
123
+ return lookup(p).content;
124
+ },
125
+ lstat: async (p) => {
126
+ if (fs.dangling.has(p))
127
+ return { isFile: () => false, size: 0, mode: 0o777 };
128
+ return toStat(lookup(p));
129
+ },
130
+ stat: async (p) => {
131
+ if (fs.dangling.has(p))
132
+ throw fsError("ENOENT");
133
+ return toStat(lookup(p));
134
+ },
135
+ ...overrides,
136
+ };
137
+ }
138
+ /** Apply deps over the memory fs, recording each durable-write step. */
139
+ export function createMemoryApplyDeps(fs, log = { events: [] }, options = {}) {
140
+ const fail = (step) => {
141
+ if (options.failAt === step)
142
+ throw fsError("EIO");
143
+ };
144
+ const handles = new Map();
145
+ return {
146
+ ...createMemoryDeps(fs),
147
+ approvedAt: () => new Date("2026-10-31T09:30:00.000Z"),
148
+ tempSuffix: () => "t1",
149
+ writeFile: async () => undefined,
150
+ mkdir: async (p) => {
151
+ log.events.push(`mkdir ${p}`);
152
+ return undefined;
153
+ },
154
+ chmod: async (p, mode) => {
155
+ fail("chmod");
156
+ log.events.push(`chmod ${p} ${mode.toString(8)}`);
157
+ const entry = fs.files.get(p);
158
+ if (entry)
159
+ entry.mode = mode;
160
+ },
161
+ rename: async (from, to) => {
162
+ fail("rename");
163
+ log.events.push(`rename ${from} ${to}`);
164
+ const entry = fs.files.get(from);
165
+ if (!entry)
166
+ throw fsError("ENOENT");
167
+ fs.files.delete(from);
168
+ fs.files.set(to, entry);
169
+ },
170
+ unlink: async (p) => {
171
+ log.events.push(`unlink ${p}`);
172
+ fs.files.delete(p);
173
+ },
174
+ open: async (p, flags, mode) => {
175
+ if (flags === "r") {
176
+ log.events.push(`open-dir ${p}`);
177
+ return {
178
+ writeFile: async () => undefined,
179
+ sync: async () => {
180
+ fail("dirsync");
181
+ log.events.push(`dirsync ${p}`);
182
+ },
183
+ close: async () => undefined,
184
+ };
185
+ }
186
+ fail("open");
187
+ if (flags === "wx" && fs.files.has(p))
188
+ throw fsError("EEXIST");
189
+ log.events.push(`open ${p} ${flags} ${mode?.toString(8)}`);
190
+ const state = { data: "" };
191
+ handles.set(p, state);
192
+ fs.files.set(p, { content: Buffer.from(""), mode: mode ?? 0o644, kind: "file" });
193
+ return {
194
+ writeFile: async (data) => {
195
+ fail("write");
196
+ state.data = data;
197
+ fs.files.set(p, { content: Buffer.from(data), mode: mode ?? 0o644, kind: "file" });
198
+ log.events.push(`write ${p}`);
199
+ },
200
+ sync: async () => {
201
+ fail("sync");
202
+ log.events.push(`sync ${p}`);
203
+ },
204
+ close: async () => {
205
+ fail("close");
206
+ log.events.push(`close ${p}`);
207
+ },
208
+ };
209
+ },
210
+ };
211
+ }
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Declarative convention hints for the credential scan (BAPI-1648).
3
+ *
4
+ * A convention is DATA, not code: a filename pattern, the file format, the
5
+ * output variable names a known file's keys are usually delivered as, the
6
+ * consumers it suggests, and a default level. The scanner turns a hint into a
7
+ * "candidate mapping" for the owner to confirm. A hint is never a fact about a
8
+ * file the scanner did not open, and no value, hostname, account, or level is
9
+ * ever inferred from file content, with ONE ratified exception: a row may carry
10
+ * a `hostProbe`, which lets the scanner open an ignored-or-untracked root file
11
+ * and report only a closed host class and which selectors are present (never a
12
+ * value, hostname, or failure detail). The classifier vocabulary has exactly one
13
+ * member, `sfcc_sandbox_host`. Convention metadata is proposal data, never
14
+ * delivery authority. There is no other stack-specific branching: adding a stack
15
+ * means adding a row.
16
+ *
17
+ * Every suggestion a row produces must still pass the credential-reference
18
+ * record validation (`credential-references.ts`) before it can be applied; the
19
+ * table is only a source of proposals, never of authority.
20
+ */
21
+ import { CREDENTIAL_REFERENCES_VERSION, validateCredentialReferenceRecord } from "./credential-references.js";
22
+ import { validateWorktreeRelativeCredentialPath } from "./credential-materialization.js";
23
+ /** The suffixes that mark a tracked template (a file that holds names, not values). */
24
+ export const TEMPLATE_SUFFIXES = [".example", ".sample", ".template"];
25
+ export const CREDENTIAL_CONVENTIONS = [
26
+ {
27
+ id: "sfcc-dw-json",
28
+ filename: "dw.json",
29
+ format: "json",
30
+ mappings: [
31
+ { variable: "SFCC_SERVER", selector: "/hostname" },
32
+ { variable: "SFCC_HOSTNAME", selector: "/hostname" },
33
+ { variable: "SFCC_USERNAME", selector: "/username" },
34
+ { variable: "SFCC_PASSWORD", selector: "/password" },
35
+ { variable: "SFCC_CODE_VERSION", selector: "/code-version" },
36
+ { variable: "SFCC_CLIENT_ID", selector: "/client-id" },
37
+ { variable: "SFCC_CLIENT_SECRET", selector: "/client-secret" },
38
+ { variable: "SFCC_SHORTCODE", selector: "/short-code" },
39
+ { variable: "SFCC_TENANT_ID", selector: "/tenant-id" },
40
+ ],
41
+ suggestedConsumers: [],
42
+ defaultLevel: "restricted",
43
+ hostProbe: { selector: "/hostname", classifier: "sfcc_sandbox_host" },
44
+ sandboxWholeFileDest: "dw.json",
45
+ },
46
+ ];
47
+ const VARIABLE_RE = /^[A-Z_][A-Z0-9_]{0,63}$/;
48
+ const JSON_POINTER_RE = /^(\/[^/\u0000-\u001f]+)+$/;
49
+ const DOTENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_.-]{0,127}$/;
50
+ const LEVELS = ["sandbox", "restricted", "production"];
51
+ /**
52
+ * Check a table's shape. Returns fixed problem labels (row id plus a closed
53
+ * reason), never table content. An empty list means the table is well formed.
54
+ */
55
+ export function validateConventionTable(table) {
56
+ const problems = [];
57
+ const seen = new Set();
58
+ table.forEach((row, index) => {
59
+ const label = typeof row?.id === "string" && row.id.length > 0 ? row.id : `row ${index + 1}`;
60
+ const bad = (reason) => problems.push(`${label}: ${reason}`);
61
+ if (typeof row?.id !== "string" || row.id.length === 0)
62
+ bad("id is missing");
63
+ else if (seen.has(row.id))
64
+ bad("id is duplicated");
65
+ else
66
+ seen.add(row.id);
67
+ if (typeof row?.filename !== "string" || row.filename.length === 0 || /[/\\*?\u0000-\u001f]/.test(row.filename)) {
68
+ bad("filename pattern is invalid");
69
+ }
70
+ if (row?.format !== "json" && row?.format !== "dotenv")
71
+ bad("format is invalid");
72
+ if (!LEVELS.includes(row?.defaultLevel))
73
+ bad("level is invalid");
74
+ if (!Array.isArray(row?.mappings) || row.mappings.length === 0) {
75
+ bad("mappings are missing");
76
+ }
77
+ else {
78
+ const variables = new Set();
79
+ for (const mapping of row.mappings) {
80
+ const selectorOk = typeof mapping?.selector === "string" &&
81
+ (row.format === "json" ? JSON_POINTER_RE.test(mapping.selector) : DOTENV_KEY_RE.test(mapping.selector));
82
+ if (typeof mapping?.variable !== "string" || !VARIABLE_RE.test(mapping.variable) || !selectorOk) {
83
+ bad("a mapping is invalid");
84
+ }
85
+ else if (variables.has(mapping.variable)) {
86
+ bad("a mapping variable is duplicated");
87
+ }
88
+ else {
89
+ variables.add(mapping.variable);
90
+ }
91
+ }
92
+ }
93
+ if (row?.hostProbe !== undefined) {
94
+ const probe = row.hostProbe;
95
+ const probeOk = probe !== null &&
96
+ typeof probe === "object" &&
97
+ !Array.isArray(probe) &&
98
+ probe.selector === "/hostname" &&
99
+ probe.classifier === "sfcc_sandbox_host";
100
+ if (!probeOk)
101
+ bad("host probe is invalid");
102
+ }
103
+ if (row?.sandboxWholeFileDest !== undefined) {
104
+ const dest = row.sandboxWholeFileDest;
105
+ if (typeof dest !== "string" || !validateWorktreeRelativeCredentialPath(dest).ok) {
106
+ bad("sandbox destination is invalid");
107
+ }
108
+ }
109
+ if (!Array.isArray(row?.suggestedConsumers)) {
110
+ bad("consumers are invalid");
111
+ }
112
+ else if (row.suggestedConsumers.some((c) => c === null || typeof c !== "object" || typeof c.kind !== "string")) {
113
+ bad("a consumer is invalid");
114
+ }
115
+ });
116
+ return problems;
117
+ }
118
+ /** The row for a file's base name (template suffix already removed), or undefined. */
119
+ export function findConvention(baseName, table = CREDENTIAL_CONVENTIONS) {
120
+ return table.find((row) => row.filename === baseName);
121
+ }
122
+ /**
123
+ * Whether a convention's suggestion would be accepted as a record entry for the
124
+ * given repository and absolute source path. Used to keep generated proposals
125
+ * inside the child-1 validator; it adds no rule of its own.
126
+ */
127
+ export function conventionProposalIsValid(row, repoName, absoluteSourcePath) {
128
+ const keys = {};
129
+ for (const mapping of row.mappings)
130
+ keys[mapping.variable] = mapping.selector;
131
+ const validation = validateCredentialReferenceRecord({
132
+ version: CREDENTIAL_REFERENCES_VERSION,
133
+ repo_name: repoName,
134
+ approved_at: new Date(0).toISOString(),
135
+ credentials: [
136
+ {
137
+ name: row.id,
138
+ level: row.defaultLevel,
139
+ source: { kind: "file_keys", path: absoluteSourcePath, format: row.format, keys },
140
+ consumers: row.suggestedConsumers.map((c) => ({ ...c })),
141
+ },
142
+ ],
143
+ }, repoName);
144
+ return validation.ok;
145
+ }