@jbkjr/relay 0.0.0-stage → 1.2.1

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 (296) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSES/Apache-2.0.txt +201 -0
  3. package/LICENSES/README.md +19 -0
  4. package/LICENSES/codex-NOTICE.txt +6 -0
  5. package/README.md +386 -2
  6. package/SECURITY.md +145 -0
  7. package/adapters/briefs/claude.md +43 -0
  8. package/adapters/briefs/codex.md +56 -0
  9. package/adapters/briefs/models.json +33 -0
  10. package/adapters/build.mjs +8 -0
  11. package/adapters/claude/.claude-plugin/marketplace.json +13 -0
  12. package/adapters/claude/relay/.claude-plugin/plugin.json +5 -0
  13. package/adapters/claude/relay/agents/codex.md +21 -0
  14. package/adapters/claude/relay/agents/operator.md +21 -0
  15. package/adapters/claude/relay/skills/ask/SKILL.md +20 -0
  16. package/adapters/claude/relay/skills/chat/SKILL.md +13 -0
  17. package/adapters/claude/relay/skills/delegate/SKILL.md +21 -0
  18. package/adapters/claude/relay/skills/discuss/SKILL.md +19 -0
  19. package/adapters/claude/relay/skills/review/SKILL.md +21 -0
  20. package/adapters/claude/relay/skills/tree/SKILL.md +10 -0
  21. package/adapters/claude/relay/skills/write-for-codex/SKILL.md +78 -0
  22. package/adapters/codex/.agents/plugins/marketplace.json +20 -0
  23. package/adapters/codex/AGENTS.snippet.md +5 -0
  24. package/adapters/codex/relay/.codex-plugin/plugin.json +6 -0
  25. package/adapters/codex/relay/skills/relay-ask/SKILL.md +20 -0
  26. package/adapters/codex/relay/skills/relay-chat/SKILL.md +13 -0
  27. package/adapters/codex/relay/skills/relay-delegate/SKILL.md +21 -0
  28. package/adapters/codex/relay/skills/relay-discuss/SKILL.md +19 -0
  29. package/adapters/codex/relay/skills/relay-review/SKILL.md +21 -0
  30. package/adapters/codex/relay/skills/relay-tree/SKILL.md +10 -0
  31. package/adapters/codex/relay/skills/relay-write-for-claude/SKILL.md +66 -0
  32. package/adapters/generate.mjs +124 -0
  33. package/bin/relay +59 -0
  34. package/codex-pin.json +12 -0
  35. package/dist/backends/acp.js +1424 -0
  36. package/dist/backends/claude.js +890 -0
  37. package/dist/backends/cli-version.js +112 -0
  38. package/dist/backends/codex-app.js +1525 -0
  39. package/dist/backends/codex-daybreak.js +75 -0
  40. package/dist/backends/codex-env.js +656 -0
  41. package/dist/backends/codex-network.js +304 -0
  42. package/dist/backends/codex-pin.js +320 -0
  43. package/dist/backends/codex-shell-policy.js +182 -0
  44. package/dist/backends/codex-stage2.js +998 -0
  45. package/dist/backends/codex-subagents.js +47 -0
  46. package/dist/backends/codex.js +637 -0
  47. package/dist/backends/copilot.js +246 -0
  48. package/dist/backends/env.js +147 -0
  49. package/dist/backends/gemini.js +607 -0
  50. package/dist/backends/grok.js +337 -0
  51. package/dist/backends/index.js +8 -0
  52. package/dist/backends/native-temp.js +187 -0
  53. package/dist/backends/never-admission.js +90 -0
  54. package/dist/backends/run.js +67 -0
  55. package/dist/backends/stream.js +230 -0
  56. package/dist/backends/tool-discovery.js +15 -0
  57. package/dist/backends/types.js +264 -0
  58. package/dist/build-info.json +5 -0
  59. package/dist/cli.js +344 -0
  60. package/dist/confine/bridge.js +113 -0
  61. package/dist/confine/broker-core.js +76 -0
  62. package/dist/confine/broker-http.js +650 -0
  63. package/dist/confine/broker-names.js +9 -0
  64. package/dist/confine/broker.js +258 -0
  65. package/dist/confine/canary.js +380 -0
  66. package/dist/confine/diagnostics.js +122 -0
  67. package/dist/confine/gemini-tools-main.js +8 -0
  68. package/dist/confine/gemini-tools.js +181 -0
  69. package/dist/confine/hardlinks.js +58 -0
  70. package/dist/confine/harness-config.js +16 -0
  71. package/dist/confine/index.js +117 -0
  72. package/dist/confine/leases.js +217 -0
  73. package/dist/confine/paths.js +6 -0
  74. package/dist/confine/peer.js +115 -0
  75. package/dist/confine/port-policy.js +8 -0
  76. package/dist/confine/ports.js +365 -0
  77. package/dist/confine/private-root.js +208 -0
  78. package/dist/confine/probe-stage2.js +501 -0
  79. package/dist/confine/probe.js +1109 -0
  80. package/dist/confine/proxy.js +783 -0
  81. package/dist/confine/sbcheck.js +208 -0
  82. package/dist/confine/seatbelt-never.js +41 -0
  83. package/dist/confine/seatbelt-stage2.js +139 -0
  84. package/dist/confine/seatbelt.js +1129 -0
  85. package/dist/confine/sockets.js +36 -0
  86. package/dist/confine/turn-probe.js +19 -0
  87. package/dist/confine/turn.js +86 -0
  88. package/dist/core/adoption.js +124 -0
  89. package/dist/core/api-keys.js +423 -0
  90. package/dist/core/approvals.js +740 -0
  91. package/dist/core/build-identity.js +248 -0
  92. package/dist/core/caller.js +749 -0
  93. package/dist/core/calls.js +102 -0
  94. package/dist/core/claude-settings.js +1045 -0
  95. package/dist/core/config.js +453 -0
  96. package/dist/core/context.js +186 -0
  97. package/dist/core/db.js +753 -0
  98. package/dist/core/dispatch.js +110 -0
  99. package/dist/core/env-broker.js +505 -0
  100. package/dist/core/env-policy.js +182 -0
  101. package/dist/core/escalation-authority.js +76 -0
  102. package/dist/core/escalation-contract.js +13 -0
  103. package/dist/core/escalation-person-path.js +131 -0
  104. package/dist/core/escalation-policy.js +79 -0
  105. package/dist/core/escalation-runtime.js +135 -0
  106. package/dist/core/escalation-state.js +42 -0
  107. package/dist/core/escalations.js +191 -0
  108. package/dist/core/events.js +235 -0
  109. package/dist/core/executables.js +147 -0
  110. package/dist/core/extensions.js +645 -0
  111. package/dist/core/families.js +204 -0
  112. package/dist/core/git.js +657 -0
  113. package/dist/core/identity.js +113 -0
  114. package/dist/core/liveness.js +68 -0
  115. package/dist/core/mediated-network-provider.js +81 -0
  116. package/dist/core/never-checkpoint.js +76 -0
  117. package/dist/core/never-coverage.js +97 -0
  118. package/dist/core/never-network.js +49 -0
  119. package/dist/core/never-policy.js +302 -0
  120. package/dist/core/never-proxy-policy.js +109 -0
  121. package/dist/core/never-schema.js +61 -0
  122. package/dist/core/never-tools.js +56 -0
  123. package/dist/core/notices.js +48 -0
  124. package/dist/core/ops.js +959 -0
  125. package/dist/core/outcome.js +224 -0
  126. package/dist/core/params.js +32 -0
  127. package/dist/core/presence.js +174 -0
  128. package/dist/core/procs.js +546 -0
  129. package/dist/core/prompts.js +363 -0
  130. package/dist/core/protected-config.js +238 -0
  131. package/dist/core/raw-network.js +192 -0
  132. package/dist/core/redact.js +152 -0
  133. package/dist/core/refusal.js +33 -0
  134. package/dist/core/relay-command.js +310 -0
  135. package/dist/core/reported.js +3 -0
  136. package/dist/core/restart-overlay.js +651 -0
  137. package/dist/core/retention.js +1135 -0
  138. package/dist/core/secrets.js +329 -0
  139. package/dist/core/session-token.js +175 -0
  140. package/dist/core/session.js +744 -0
  141. package/dist/core/shell.js +2 -0
  142. package/dist/core/shipped-pin.js +47 -0
  143. package/dist/core/shown.js +42 -0
  144. package/dist/core/slots.js +67 -0
  145. package/dist/core/stage2-executors.js +453 -0
  146. package/dist/core/stage2-switch.js +5 -0
  147. package/dist/core/steering.js +149 -0
  148. package/dist/core/storage.js +358 -0
  149. package/dist/core/toml.js +175 -0
  150. package/dist/core/views.js +324 -0
  151. package/dist/core/wait.js +114 -0
  152. package/dist/core/wake.js +207 -0
  153. package/dist/core/watch.js +247 -0
  154. package/dist/core/worktree.js +213 -0
  155. package/dist/hosts/claude-desktop.js +274 -0
  156. package/dist/hosts/claude.js +249 -0
  157. package/dist/hosts/codex.js +329 -0
  158. package/dist/hosts/desktop-shared.js +20 -0
  159. package/dist/hosts/index.js +11 -0
  160. package/dist/hosts/types.js +4 -0
  161. package/dist/install/basics.js +18 -0
  162. package/dist/install/claude-init.js +133 -0
  163. package/dist/install/common.js +655 -0
  164. package/dist/install/doctor.js +629 -0
  165. package/dist/install/qualify-codex.js +205 -0
  166. package/dist/install.js +524 -0
  167. package/dist/mcp/elicit.js +209 -0
  168. package/dist/mcp/gateway.js +218 -0
  169. package/dist/mcp/host.js +253 -0
  170. package/dist/mcp/server.js +1124 -0
  171. package/dist/mcp/stdio.js +37 -0
  172. package/dist/modes/discussion.js +393 -0
  173. package/dist/modes/review.js +722 -0
  174. package/dist/native/relay-sbcheck +0 -0
  175. package/dist/targets/briefs.js +86 -0
  176. package/dist/targets/claude.js +94 -0
  177. package/dist/targets/codex.js +66 -0
  178. package/dist/targets/copilot.js +93 -0
  179. package/dist/targets/gemini.js +119 -0
  180. package/dist/targets/grok.js +126 -0
  181. package/dist/targets/index.js +192 -0
  182. package/dist/targets/types.js +18 -0
  183. package/dist/targets/verified.js +35 -0
  184. package/dist/worker.js +113 -0
  185. package/docs/UPGRADING.md +1502 -0
  186. package/docs/pinned-codex.md +321 -0
  187. package/experiments/stage2-redteam/lib/oracles.mjs +214 -0
  188. package/experiments/stage2-redteam/lib/report.mjs +35 -0
  189. package/npm-shrinkwrap.json +1632 -0
  190. package/package.json +82 -4
  191. package/scripts/codex-qualify/codex-pin-store.mjs +353 -0
  192. package/scripts/codex-qualify/codex-qualifier-process.mjs +265 -0
  193. package/scripts/codex-qualify/codex-qualifier.example.json +5 -0
  194. package/scripts/codex-qualify/codex-qualifier.mjs +281 -0
  195. package/scripts/codex-qualify/codex-shipped-pin.mjs +158 -0
  196. package/scripts/codex-qualify/codex-stage2-pin.mjs +48 -0
  197. package/scripts/codex-qualify/codex-stage2.mjs +2381 -0
  198. package/scripts/codex-qualify/install-codex-qualifier.mjs +98 -0
  199. package/scripts/codex-qualify/main-module.mjs +14 -0
  200. package/scripts/codex-qualify/relay-codex-qualifier.plist +37 -0
  201. package/scripts/codex-qualify/scratch-env.mjs +31 -0
  202. package/scripts/codex-qualify/session.mjs +96 -0
  203. package/scripts/codex-qualify/stage2-escalation-cases.mjs +125 -0
  204. package/test/codex-permissions.test.ts +875 -0
  205. package/test/fixtures/boundary-probes.mjs +17 -0
  206. package/test/fixtures/denial-stream-host.mjs +7 -0
  207. package/test/fixtures/families.json +246 -0
  208. package/test/fixtures/install-snapshots/claude-desktop-foreign.txt +158 -0
  209. package/test/fixtures/install-snapshots/claude-desktop-fresh.txt +101 -0
  210. package/test/fixtures/install-snapshots/claude-desktop-installed.txt +161 -0
  211. package/test/fixtures/install-snapshots/claude-foreign.txt +133 -0
  212. package/test/fixtures/install-snapshots/claude-fresh.txt +77 -0
  213. package/test/fixtures/install-snapshots/claude-installed.txt +133 -0
  214. package/test/fixtures/install-snapshots/codex-foreign.txt +159 -0
  215. package/test/fixtures/install-snapshots/codex-fresh.txt +107 -0
  216. package/test/fixtures/install-snapshots/codex-installed.txt +161 -0
  217. package/test/fixtures/link-parent.mjs +6 -0
  218. package/test/fixtures/mediated-command.cjs +72 -0
  219. package/test/fixtures/native-skill-isolation.json +280 -0
  220. package/test/fixtures/pinned-codex-app-server.mjs +25 -0
  221. package/test/fixtures/qualified-ext-adapters.mjs +36 -0
  222. package/test/fixtures/refusals/README.md +52 -0
  223. package/test/fixtures/refusals/claude-source-result.json +7 -0
  224. package/test/fixtures/refusals/openai-app-capacity.json +24 -0
  225. package/test/fixtures/refusals/openai-app-cyberPolicy.json +24 -0
  226. package/test/fixtures/refusals/openai-gpt-6-astra-max.json +12 -0
  227. package/test/fixtures/refusals/openai-gpt-6.1-sol-xhigh.json +12 -0
  228. package/test/fixtures/refusals/openai-review-capacity.json +24 -0
  229. package/test/fixtures/relay-0.2.0.sql +57 -0
  230. package/test/fixtures/relay-0.9.1.gen.mjs +212 -0
  231. package/test/fixtures/relay-0.9.1.sql +340 -0
  232. package/test/fixtures/slow-boundary-probes.mjs +37 -0
  233. package/test/fixtures/stable-surfaces/config.json +1122 -0
  234. package/test/fixtures/stable-surfaces/escalation.json +128 -0
  235. package/test/fixtures/stable-surfaces/events.json +37 -0
  236. package/test/fixtures/stable-surfaces/gemini-native-resume.json +4 -0
  237. package/test/fixtures/stable-surfaces/inbox.jsonl +2 -0
  238. package/test/fixtures/stable-surfaces/notice.txt +1 -0
  239. package/test/fixtures/stable-surfaces/refusal-item.json +28 -0
  240. package/test/fixtures/stable-surfaces/refusal-review.json +23 -0
  241. package/test/fixtures/stable-surfaces/registry.json +49 -0
  242. package/test/fixtures/stable-surfaces/tools-desktop.json +575 -0
  243. package/test/fixtures/stable-surfaces/tools.json +716 -0
  244. package/test/fixtures/stable-surfaces/usage.txt +46 -0
  245. package/test/fixtures/stage2-acp-native.mjs +138 -0
  246. package/test/fixtures/stage2-app-server.mjs +23 -0
  247. package/test/fixtures/stage2-catalog.json +91 -0
  248. package/test/fixtures/stage2-hostile-web.mjs +35 -0
  249. package/test/fixtures/stage2-native-network.mjs +62 -0
  250. package/test/fixtures/stage2-worker.ts +87 -0
  251. package/test/fixtures/status-views/expected.json +7825 -0
  252. package/test/fixtures/status-views/registries.json +1 -0
  253. package/test/fixtures/steering.json +209 -0
  254. package/test/helpers.ts +740 -0
  255. package/test/host-env.ts +7 -0
  256. package/test/keychain-decoy.ts +197 -0
  257. package/test/live-scope.ts +44 -0
  258. package/test/mediated-network.test.ts +192 -0
  259. package/test/mediated-proxy.test.ts +264 -0
  260. package/test/native-temp-alias.ts +10 -0
  261. package/test/never-policy.test.ts +629 -0
  262. package/test/never-tools.test.ts +136 -0
  263. package/test/process-home.ts +18 -0
  264. package/test/proxy.test.ts +531 -0
  265. package/test/restart-overlay-live.test.ts +85 -0
  266. package/test/restart-overlay-profile.test.ts +66 -0
  267. package/test/restart-overlay.test.ts +416 -0
  268. package/test/stable-surfaces.test.ts +249 -0
  269. package/test/stage2-escalation-live.test.ts +544 -0
  270. package/test/stage2-escalation-qualification.test.ts +170 -0
  271. package/test/stage2-escalation.test.ts +747 -0
  272. package/test/stage2-executor.test.ts +849 -0
  273. package/test/stage2-grant.test.ts +603 -0
  274. package/test/stage2-native-live.test.ts +647 -0
  275. package/test/stage2-network-decisions.test.ts +70 -0
  276. package/test/stage2-probe.test.ts +845 -0
  277. package/test/stage2-standing-live.test.ts +203 -0
  278. package/test/stubs/broker-host.mjs +59 -0
  279. package/test/stubs/broker-peer.mjs +20 -0
  280. package/test/stubs/confined-harness.mjs +91 -0
  281. package/test/stubs/ext-broken-server.mjs +2 -0
  282. package/test/stubs/ext-odd-server.mjs +21 -0
  283. package/test/stubs/ext-server.mjs +31 -0
  284. package/test/stubs/fake-host-cli.mjs +218 -0
  285. package/test/stubs/procargs.mjs +30 -0
  286. package/test/stubs/stub-acp +4 -0
  287. package/test/stubs/stub-agent.mjs +322 -0
  288. package/test/stubs/stub-claude +4 -0
  289. package/test/stubs/stub-codex +4 -0
  290. package/test/stubs/targets/acp.mjs +307 -0
  291. package/test/stubs/targets/claude.mjs +149 -0
  292. package/test/stubs/targets/codex.mjs +479 -0
  293. package/test/stubs/targets/gemini.mjs +604 -0
  294. package/test/temp-root.ts +11 -0
  295. package/test/wp4-adapters.test.ts +353 -0
  296. package/test/wp4-interlock.test.ts +136 -0
@@ -0,0 +1,113 @@
1
+ // The 1.0 seam: request evidence and contribution identity, resolved once before dispatch.
2
+ // It deliberately does not turn a host conversation key into authority or durable membership.
3
+ import crypto from "node:crypto";
4
+ import { callerLabel } from "./families.js";
5
+ import { familyOf, SINGLETON_REASON } from "./caller.js";
6
+ export const SHARED_REASON = "Desktop chats in the main window share one relay process. Cowork, the Code tab's in-app bridge, remote Cowork and widgets share a second. Within each process every conversation carries its own session token, which keeps its jobs, approval requests and events apart from the others'. Code-tab sessions also have their own dedicated relay registration.";
7
+ /** A conversation's scope on a shared process (session-token.ts). */
8
+ export const TOKEN_REASON = "This relay process is shared by several conversations (desktop chats share one; Cowork, the Code tab's in-app bridge, remote Cowork and widgets share another). Relay keeps this conversation's jobs, approval requests and events apart by the session token it carries. The token is a bearer key: it separates conversations that use relay honestly, and anyone who sees it can act as this conversation.";
9
+ /** An OpenCode 2 process, before a call names its session. */
10
+ export const HOST_PROCESS_REASON = "OpenCode serves the sessions of its background service from one relay process, and puts each call's session on it. Relay keeps each session's jobs, approval requests and events apart by that session ID; a call that carries none does nothing.";
11
+ /** A session's scope on an OpenCode 2 process. */
12
+ export const HOST_KEY_REASON = "This relay process serves several OpenCode sessions (subagent sessions are sessions of their own). Relay keeps this session's jobs, approval requests and events apart by the session ID OpenCode puts on each call. That separates sessions OpenCode stamps faithfully; it is not authentication. The scope lasts as long as this relay process: after OpenCode restarts it, earlier work is recovered with relay adopt from a terminal.";
13
+ export const fingerprint = (inst) => crypto.createHash("sha256").update(inst.token).digest("hex").slice(0, 24);
14
+ export function sessionDiagnostic(inst) {
15
+ const name = inst.clientName ?? "";
16
+ const child = inst.ctx.kind === "child";
17
+ if (!child && inst.carried)
18
+ return { scope: "conversation-token", source: "session-token", topology: "shared", reason: TOKEN_REASON, fingerprint: fingerprint(inst) };
19
+ if (!child && inst.keyed)
20
+ return { scope: "host-session", source: "host-key", topology: "shared", reason: HOST_KEY_REASON, fingerprint: fingerprint(inst) };
21
+ const keyedProcess = !child && Boolean(inst.hostKey);
22
+ const shared = !child && (inst.desktopEntry || /^local-agent-mode-/i.test(name) || keyedProcess);
23
+ const dedicated = !child && !shared && /^(claude-code|codex-mcp-client)$/i.test(name) && !inst.registration;
24
+ return {
25
+ scope: child ? "child-run" : shared ? "shared-process" : dedicated ? "dedicated-process" : "unqualified-process",
26
+ source: child ? "child-context" : inst.desktopEntry ? "desktop-entry" : dedicated ? "native-registration" : shared ? "client-profile" : "none",
27
+ topology: child || dedicated ? "dedicated" : shared ? "shared" : "unknown",
28
+ reason: inst.singletonViolation ? SINGLETON_REASON
29
+ : child ? "Authority comes from the launched turn's run context; host metadata cannot widen it."
30
+ : keyedProcess ? HOST_PROCESS_REASON : shared ? SHARED_REASON : dedicated ? "Qualified native registration: one conversation per relay process. Restart recovery requires explicit adoption."
31
+ : "Conversation topology is unqualified. This process is one authority domain; host metadata provides no session isolation.",
32
+ fingerprint: fingerprint(inst),
33
+ };
34
+ }
35
+ function freeze(v) {
36
+ if (v && typeof v === "object") {
37
+ for (const child of Object.values(v))
38
+ freeze(child);
39
+ Object.freeze(v);
40
+ }
41
+ return v;
42
+ }
43
+ const OPENCODE_SESSION = "ai.opencode/sessionID";
44
+ /**
45
+ * The OpenCode session a call comes from, as OpenCode 2 stamps it (_meta["ai.opencode/sessionID"]),
46
+ * validated as callIdentity validates it; undefined when the call carries none.
47
+ */
48
+ export function opencodeSession(meta) {
49
+ if (!meta || !Object.hasOwn(meta, OPENCODE_SESSION))
50
+ return undefined;
51
+ const v = meta[OPENCODE_SESSION];
52
+ if (typeof v !== "string" || !v.trim() || v.length > 4096)
53
+ throw new Error("malformed session metadata");
54
+ return v;
55
+ }
56
+ /** Recognized session fields are validated even on unqualified hosts. Raw keys never leave here. */
57
+ export function callIdentity(inst, meta, protocol, client) {
58
+ const evidence = [];
59
+ const field = (obj, key, path = key) => {
60
+ if (!Object.hasOwn(obj, key))
61
+ return undefined;
62
+ const v = obj[key];
63
+ if (typeof v !== "string" || !v.trim() || v.length > 4096)
64
+ throw new Error("malformed session metadata");
65
+ evidence.push(path);
66
+ return v;
67
+ };
68
+ const m = meta ?? {};
69
+ // The token itself never enters the snapshot: only that this call's scope came from one.
70
+ if (inst.carried)
71
+ evidence.push("argument:session_token");
72
+ const topThread = field(m, "threadId"), topSession = field(m, "sessionId");
73
+ field(m, "windowId");
74
+ const conversation = field(m, "anthropic/conversationUuid"), opencodeKey = field(m, OPENCODE_SESSION);
75
+ let turn = {};
76
+ if (Object.hasOwn(m, "x-codex-turn-metadata")) {
77
+ const v = m["x-codex-turn-metadata"];
78
+ if (!v || typeof v !== "object" || Array.isArray(v))
79
+ throw new Error("malformed session metadata");
80
+ turn = v;
81
+ }
82
+ const nestedThread = field(turn, "thread_id", "x-codex-turn-metadata.thread_id");
83
+ const nestedSession = field(turn, "session_id", "x-codex-turn-metadata.session_id");
84
+ if ((topThread && nestedThread && topThread !== nestedThread) || (topSession && nestedSession && topSession !== nestedSession))
85
+ throw new Error("conflicting session metadata");
86
+ const model = field(turn, "model", "x-codex-turn-metadata.model");
87
+ const source = field(turn, "thread_source", "x-codex-turn-metadata.thread_source");
88
+ const codexSubagent = source === "subagent";
89
+ if (inst.ctx.kind === "root" && sessionDiagnostic(inst).topology === "dedicated") {
90
+ inst.singletonStamps ??= new Map();
91
+ for (const [kind, key] of [["codex-thread", topThread ?? nestedThread], ["anthropic-conversation", conversation], ["opencode-session", opencodeKey]]) {
92
+ if (!key)
93
+ continue;
94
+ const hash = crypto.createHash("sha256").update(JSON.stringify([kind, key])).digest("hex");
95
+ const previous = inst.singletonStamps.get(kind);
96
+ if (previous && previous !== hash)
97
+ inst.singletonViolation = true;
98
+ else
99
+ inst.singletonStamps.set(kind, hash);
100
+ }
101
+ }
102
+ const contribution = callerLabel(inst, { hostModel: model, codexSubagent });
103
+ const session = sessionDiagnostic(inst);
104
+ const { fingerprint: _fingerprint, reason: _reason, ...diagnostic } = session;
105
+ const snapshot = {
106
+ call_id: crypto.randomUUID(),
107
+ harness: (client?.name ?? inst.clientName)?.slice(0, 256) ?? null, version: client?.version.slice(0, 256) ?? null, protocol,
108
+ session: { ...diagnostic, reason_code: inst.singletonViolation ? "singleton-violation" : session.scope, evidence, assurance: inst.ctx.kind === "child" ? "injected-context" : inst.carried ? "relay-capability" : inst.keyed ? "host-correlation" : session.topology === "dedicated" ? "dedicated-process-assumption" : session.topology === "shared" ? "shared-authority" : "unqualified" }, model: model ?? null,
109
+ family_label: contribution.label, routing_family: familyOf(inst), subagent: codexSubagent,
110
+ parent: inst.ctx.kind === "child" ? inst.ctx.nodeId : null,
111
+ };
112
+ return freeze({ snapshot, contribution: { ...contribution, snapshot }, session, codexSubagent, ...(model ? { hostModel: model } : {}) });
113
+ }
@@ -0,0 +1,68 @@
1
+ // What a running item is doing, for status: when its agent last did anything, how long it has
2
+ // been quiet, what it last started, and for a write job the files changed so far. Report-only:
3
+ // nothing here stops or limits anything (no timeouts by default; decided 2026-10-15).
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import { nodeDir } from "./config.js";
7
+ import { db, now, runConfig } from "./db.js";
8
+ import { filterRefusal, git, jobTree } from "./git.js";
9
+ /** Files listed at most; the rest are counted. */
10
+ const MAX_FILES = 50;
11
+ /** Paths changed in a write job's worktree since its base: committed, uncommitted and new. */
12
+ function filesTouched(n) {
13
+ if (!n.worktree || !n.repo || !n.base_sha || !fs.existsSync(n.worktree))
14
+ return null;
15
+ // The agent is running in the worktree and can write its `.git` file: git is given the git
16
+ // directory the repository records for it (jobTree), and nothing is said where that fails.
17
+ const tree = jobTree(n.repo, n.worktree);
18
+ if ("error" in tree)
19
+ return null;
20
+ // Comparing the worktree with a commit can run the clean filter on files git is unsure of.
21
+ if (filterRefusal(tree, runConfig(n.run_id).trust_git_filters))
22
+ return null;
23
+ // --no-optional-locks: relay must not take the index lock while the agent may be running git itself.
24
+ const changed = git(tree, ["--no-optional-locks", "diff", "--no-ext-diff", "--no-textconv", "--name-only", "-z", n.base_sha]);
25
+ const created = git(tree, ["--no-optional-locks", "ls-files", "--others", "--exclude-standard", "-z"]);
26
+ if (!changed.ok || !created.ok)
27
+ return null;
28
+ return [...new Set([...changed.raw.split("\0"), ...created.raw.split("\0")].filter(Boolean))].sort();
29
+ }
30
+ /**
31
+ * Liveness of a running item, or null when it has no turn running. What the agent last started
32
+ * (a command, a tool, a file) is the running turn's own record, which every backend keeps as it
33
+ * goes (session.ts onActivity); it is left out when the backend has recorded nothing yet, and when
34
+ * `activity: false` (a reviewer whose result is withheld).
35
+ */
36
+ export function liveness(n, opts = {}) {
37
+ if (n.status !== "running")
38
+ return null;
39
+ const turn = db().prepare("SELECT * FROM turns WHERE node_id = ? AND status = 'running' ORDER BY id DESC LIMIT 1").get(n.id);
40
+ if (!turn?.started_at)
41
+ return null;
42
+ let last = Math.max(turn.started_at, turn.activity_at ?? 0);
43
+ try {
44
+ // Anything the agent's harness writes counts, not only the tool calls it starts.
45
+ last = Math.max(last, Math.round(fs.statSync(n.log_path ?? path.join(nodeDir(n.run_id, n.id), "agent.log")).mtimeMs));
46
+ }
47
+ catch {
48
+ // No log yet: the agent is still starting.
49
+ }
50
+ const out = {
51
+ last_activity_at: new Date(last).toISOString(),
52
+ quiet_s: Math.max(0, Math.round((now() - last) / 1000)),
53
+ };
54
+ if (opts.activity !== false && turn.activity) {
55
+ out.activity = turn.activity;
56
+ if (turn.activity_at)
57
+ out.activity_at = new Date(turn.activity_at).toISOString();
58
+ }
59
+ if (n.kind === "job" && n.mode === "write" && turn.access === "write") {
60
+ const files = filesTouched(n);
61
+ if (files) {
62
+ out.files_touched = files.slice(0, MAX_FILES);
63
+ if (files.length > MAX_FILES)
64
+ out.files_touched_more = files.length - MAX_FILES;
65
+ }
66
+ }
67
+ return out;
68
+ }
@@ -0,0 +1,81 @@
1
+ import { neverProxyInputs } from "./never-policy.js";
2
+ import { createNeverProxyPolicy } from "./never-proxy-policy.js";
3
+ export { mediatedLookup } from "./never-proxy-policy.js";
4
+ import { openProxy as openTurnProxy } from "../confine/proxy.js";
5
+ import { checkStage2Network } from "../confine/seatbelt-stage2.js";
6
+ /** child_network is standing network consent too, without manufacturing a stored grant. */
7
+ export const mediatedBaseline = (grant, cfg) => cfg.child_network ? { ...grant, network: true } : grant ?? undefined;
8
+ export const NO_MEDIATED_PROVIDER = "no qualified mediated provider is available";
9
+ export function needsMediatedNetwork(capabilities, baseline, policy) {
10
+ return capabilities.some(c => c.kind === "network" && c.mode === "mediated"
11
+ || c.kind === "localhost" && c.operation === "connect" && !!policy?.hosts.length) || !!(baseline?.network && !baseline.raw_network);
12
+ }
13
+ /** Public HTTP(S)/TCP only. No raw fallback, local route, Codex proxy or trust daemon. */
14
+ export const MEDIATED_NETWORK_EFFECT = "Public hosts through the turn's HTTP(S)/SOCKS5 proxy only; the proxy refuses local, private, on-link and this-machine destinations. Tools must honour proxy settings; tools that ignore proxy variables fail closed. Direct TCP, UDP and DNS remain denied except separately approved localhost capabilities. Each requested authority and checked numeric endpoint passes never. Opaque tunnels have no TLS/SNI inspection. No Go/Swift TLS for these jobs until Release B: Security.framework certificate trust stays disabled.";
15
+ /** Code-only fixture dependencies; neither config nor a child environment can select these. */
16
+ export function createMediatedNetworkProvider(deps = {}) {
17
+ const qualify = (c) => {
18
+ if (!c.baseline?.network && !c.capabilities.some(x => x.kind === "network" && x.mode === "mediated"))
19
+ return "mediated provider requires a standing network grant or an explicit one-turn mediated capability";
20
+ if (c.baseline?.raw_network || c.baseline?.local_network || c.capabilities.some(x => x.kind === "network" && x.mode !== "mediated"))
21
+ return "mediated networking cannot be combined with raw or local networking";
22
+ if (c.policy.hosts.length && c.capabilities.some(x => x.kind === "localhost" && x.operation === "connect"))
23
+ return "localhost connect is unavailable with never.hosts: the direct IPv4 allowance cannot screen forbidden DNS endpoints";
24
+ return null;
25
+ };
26
+ return { qualify, async prepare(c) {
27
+ const problem = qualify(c);
28
+ if (problem)
29
+ throw new Error(problem);
30
+ if (!c.proxyPort)
31
+ throw new Error("mediated networking requires a stage-2 leased proxy port");
32
+ const network = { ...c.network, egress: "none", mediatedPort: c.proxyPort };
33
+ checkStage2Network(network);
34
+ // A final never deny cannot be lifted even for the proxy's transport port.
35
+ const inputs = neverProxyInputs(c.policy);
36
+ if (inputs.ports.some(p => p.port === c.proxyPort && p.transport !== "udp"))
37
+ throw new Error("never refuses the leased proxy transport port");
38
+ const controller = new AbortController(), signal = controller.signal;
39
+ const abort = () => controller.abort(new Error("mediated turn ended"));
40
+ c.spec.signal?.addEventListener("abort", abort, { once: true });
41
+ if (c.spec.signal?.aborted)
42
+ abort();
43
+ const lookup = deps.lookup ? host => deps.lookup(host, signal) : undefined;
44
+ const publicPolicy = createNeverProxyPolicy(c.policy, { signal, lookup, now: deps.now });
45
+ let proxy;
46
+ let closing;
47
+ const close = () => closing ??= (async () => {
48
+ abort();
49
+ c.spec.signal?.removeEventListener("abort", abort);
50
+ await proxy?.close();
51
+ })();
52
+ try {
53
+ await publicPolicy.refresh();
54
+ proxy = await (deps.open ?? openTurnProxy)({ mode: "public", allow: [],
55
+ listen: { port: c.proxyPort, ipv4Only: true },
56
+ publicPolicy,
57
+ });
58
+ signal.throwIfAborted();
59
+ const url = `http://127.0.0.1:${proxy.port}`;
60
+ return { network, executorEnv: { HTTP_PROXY: url, HTTPS_PROXY: url, ALL_PROXY: url,
61
+ http_proxy: url, https_proxy: url, all_proxy: url, NO_PROXY: "", no_proxy: "" }, close };
62
+ }
63
+ catch (e) {
64
+ await close();
65
+ throw e;
66
+ }
67
+ } };
68
+ }
69
+ const builtin = createMediatedNetworkProvider();
70
+ let provider = builtin;
71
+ export const mediatedNetworkProvider = () => provider;
72
+ /** Code-only fixture seam, like the executor dependency seam. No environment/config override. */
73
+ export function setMediatedNetworkProviderForTests(value) { provider = value === null ? builtin : value; }
74
+ export function mediatedNetworkProblem(context) {
75
+ if (context.policy.hosts.length && context.capabilities.some(c => c.kind === "localhost" && c.operation === "connect"))
76
+ return "localhost connect is unavailable with never.hosts: the direct IPv4 allowance cannot screen forbidden DNS endpoints";
77
+ if (!needsMediatedNetwork(context.capabilities, context.baseline, context.policy))
78
+ return null;
79
+ const selected = mediatedNetworkProvider();
80
+ return selected ? selected.qualify(context) : NO_MEDIATED_PROVIDER;
81
+ }
@@ -0,0 +1,76 @@
1
+ import fs from "node:fs";
2
+ import { configPath, validateConfig, withDefaults } from "./config.js";
3
+ import { db, getRun, runConfig, tx } from "./db.js";
4
+ import { mergeNeverPolicies, neverIdentityProblem, resolveNeverPolicy, validateNeverPolicy } from "./never-policy.js";
5
+ function floorOf(runId) {
6
+ const run = getRun(runId);
7
+ if (!run)
8
+ throw new Error(`unknown run ${runId}`);
9
+ const params = JSON.parse(run.config_json).params_json;
10
+ if (params === undefined)
11
+ return null; // Existing schema-4 runs have no private params.
12
+ if (!params || typeof params !== "object" || Array.isArray(params))
13
+ throw new Error("malformed private run params");
14
+ if (!Object.hasOwn(params, "never_floor"))
15
+ return null;
16
+ const saved = params.never_floor;
17
+ if (!saved || typeof saved.configRequired !== "boolean")
18
+ throw new Error("malformed durable never floor");
19
+ return { policy: validateNeverPolicy(saved.policy), configRequired: saved.configRequired };
20
+ }
21
+ export const readNeverFloor = (runId) => floorOf(runId)?.policy ?? null;
22
+ /** Recheck under the consumer's transaction / last prelaunch gate, after asynchronous work. */
23
+ export function assertNeverCurrent(runId, expectedHash) {
24
+ const floor = readNeverFloor(runId);
25
+ if (!floor || floor.hash !== expectedHash)
26
+ throw new Error("never policy changed after the checkpoint; rebuild the launch plan or request a fresh decision");
27
+ const why = neverIdentityProblem(floor);
28
+ if (why)
29
+ throw new Error(why);
30
+ return floor;
31
+ }
32
+ /**
33
+ * The launch gate. A turn's proxy keeps the addresses it was launched with, so a plan built before
34
+ * the floor gained an address would permit it once it stops being local, which the floor refuses.
35
+ * Link-local addresses are left out: macOS rotates them by itself and proxies never dial them.
36
+ */
37
+ export function assertNeverLaunchCurrent(runId, captured) {
38
+ const added = assertNeverCurrent(runId, captured.hash).localAddresses.filter(a => !captured.localAddresses.includes(a) && !/^(fe[89ab]|169\.254\.)/i.test(a));
39
+ if (added.length)
40
+ throw new Error(`this Mac gained ${added.join(", ")} after the launch plan was built, so nothing was started; send the turn again`);
41
+ }
42
+ /**
43
+ * A checkpoint commits the observed union BEFORE a caller's approval/launch transaction. BEGIN
44
+ * IMMEDIATE serializes processes, including reload, so concurrent observations cannot lose entries.
45
+ * Failures never update the floor. Do not call from inside another registry transaction.
46
+ */
47
+ export function checkpointNever(runId, _phase) {
48
+ return tx(() => {
49
+ const previous = floorOf(runId);
50
+ let configRequired = previous?.configRequired ?? false;
51
+ let current;
52
+ try {
53
+ const text = fs.readFileSync(configPath(), "utf8");
54
+ current = withDefaults(validateConfig(JSON.parse(text), configPath()));
55
+ configRequired = true;
56
+ }
57
+ catch (err) {
58
+ // A never-created optional config is valid; a disappearing observed config is not.
59
+ if (err.code !== "ENOENT" || configRequired)
60
+ throw new Error(`never checkpoint cannot load config ${configPath()}: ${err.message}`);
61
+ current = withDefaults({});
62
+ }
63
+ const observed = resolveNeverPolicy({ never: current.never, codexHome: current.targets.codex.home });
64
+ // A run's captured additions count even before its first live checkpoint; edited removals do
65
+ // not replace them. Eligible removals must already be present when the run starts.
66
+ const baseline = previous?.policy ?? (() => {
67
+ const cfg = runConfig(runId);
68
+ return resolveNeverPolicy({ never: cfg.never, codexHome: cfg.targets.codex.home });
69
+ })();
70
+ const policy = mergeNeverPolicies(baseline, observed);
71
+ // Only the private params member changes; the captured config and other state stay intact.
72
+ db().prepare("UPDATE runs SET config_json = json_set(config_json, '$.params_json.never_floor', json(?)) WHERE id = ?")
73
+ .run(JSON.stringify({ policy, configRequired }), runId);
74
+ return policy;
75
+ });
76
+ }
@@ -0,0 +1,97 @@
1
+ import { stage2Enabled } from "./stage2-switch.js";
2
+ /**
3
+ * When a target's jobs get the floor in their sandbox: "always", or only while stage 2 is on.
4
+ * Codex and Claude always (Claude since the decision of 2026-11-04: its variant gates, managed
5
+ * settings refusal and command-approval refusal then apply with stage 2 off too). Relay-owned
6
+ * Seatbelt profiles (Copilot, Gemini, Grok) get it with stage 2 only: the floor is part of Release
7
+ * A's experimental wiring there, and Copilot's and Grok's released login routes (keychain, token
8
+ * store, certificate trust) conflict with its denies.
9
+ */
10
+ export const NEVER_FLOOR_WHEN = {
11
+ codex: "always",
12
+ claude: "always",
13
+ copilot: "stage2",
14
+ gemini: "stage2",
15
+ grok: "stage2",
16
+ };
17
+ /** Targets whose released login route conflicts with the floor: refused whenever it applies. */
18
+ export const NEVER_FLOOR_CONFLICT = {
19
+ copilot: "never: Copilot's current KEYCHAIN/TRUST login route bypasses credential/network isolation. Use a qualified store-denying target; credential separation is deferred.",
20
+ grok: "never: Grok's current token-store/TRUST route bypasses credential/network isolation. Use a qualified store-denying target; credential separation is deferred.",
21
+ };
22
+ /** Settings under which a floored Claude job is refused (never-admission.ts): each can take the job around the checked sandbox or tool route. allow_dangerous refuses write jobs only. */
23
+ export function claudeFloorVariants(cfg) {
24
+ return [
25
+ ...(cfg.child_settings !== "isolated" ? [`child_settings "${cfg.child_settings ?? "unset"}"`] : []),
26
+ ...(cfg.child_hooks ? ["child_hooks true"] : []),
27
+ ...(cfg.child_mcp !== "relay-only" ? [`child_mcp "${cfg.child_mcp ?? "unset"}"`] : []),
28
+ ...(cfg.allow_dangerous ? ["allow_dangerous (write jobs)"] : []),
29
+ ];
30
+ }
31
+ /** Whether relay applies the never floor to this target's jobs under this config. An unknown id gets it. */
32
+ export function neverFloorApplies(target, cfg, env = process.env) {
33
+ const when = NEVER_FLOOR_WHEN[target] ?? "always";
34
+ return when === "always" || stage2Enabled(env, cfg);
35
+ }
36
+ /** What happens to this target's jobs: the floor enforced, not applied, or the job refused because its login route conflicts with it. */
37
+ export function neverFloorCoverage(target, cfg, env = process.env) {
38
+ if (!neverFloorApplies(target, cfg, env))
39
+ return "not enforced";
40
+ return NEVER_FLOOR_CONFLICT[target] ? "refused" : "enforced";
41
+ }
42
+ export function neverKeychainIpc(target, cfg, env = process.env) {
43
+ if (neverFloorCoverage(target, cfg, env) !== "enforced")
44
+ return null;
45
+ if (target === "claude")
46
+ return { networkOff: "open", networkOn: "open" };
47
+ if (target === "codex")
48
+ return { networkOff: "closed", networkOn: stage2Enabled(env, cfg) ? "closed" : "open" };
49
+ return { networkOff: "closed", networkOn: "closed" }; // Relay's own Seatbelt (ACP targets).
50
+ }
51
+ const keychainText = (k) => k.networkOff === k.networkOn
52
+ ? `keychain IPC ${k.networkOff}`
53
+ : `keychain IPC ${k.networkOff} on network-off turns, ${k.networkOn} on network-on turns`;
54
+ /**
55
+ * Doctor's "never enforced" block, from the same predicate the launches use: a heading, one line
56
+ * per target (all of them, enabled or not) with its path entries and keychain IPC, what "not
57
+ * enforced" and an open keychain IPC leave reachable, and the proxy screen that holds for every
58
+ * agent. The only description of per-target enforcement doctor prints.
59
+ */
60
+ export function neverFloorReport(targets, cfg, env = process.env) {
61
+ const on = stage2Enabled(env, cfg);
62
+ const lines = [`the floor in each agent's sandbox, with stage 2 ${on ? "on" : "off"} (targets.codex.stage2): its path entries (never.paths and the built-ins, keychain files among them), and keychain IPC (the security daemons) separately:`];
63
+ for (const t of targets) {
64
+ const now = neverFloorCoverage(t.id, cfg, env);
65
+ const stage2Only = NEVER_FLOOR_WHEN[t.id] === "stage2";
66
+ const conflict = Boolean(NEVER_FLOOR_CONFLICT[t.id]);
67
+ let text = now;
68
+ if (now === "refused")
69
+ text = "refused: its login route conflicts with the floor";
70
+ else if (stage2Only && on)
71
+ text = "path entries enforced, only while stage 2 is on";
72
+ else if (stage2Only)
73
+ text = conflict ? "not enforced; refused with stage 2 on (its login route conflicts with the floor)" : "not enforced; enforced only with stage 2 on";
74
+ else if (t.id === "codex")
75
+ text = `path entries enforced in every sandboxed turn's profile${on ? ", and in relay's stage-2 executor" : ""}`;
76
+ else
77
+ text = "path entries enforced, whatever stage 2 says";
78
+ const keychain = neverKeychainIpc(t.id, cfg, env);
79
+ if (keychain)
80
+ text += `; ${keychainText(keychain)}`;
81
+ if (t.id === "claude" && now === "enforced") {
82
+ const variants = claudeFloorVariants(cfg);
83
+ text += variants.length ? `; this config's ${variants.join(", ")} refuses its jobs` : "; no inherited settings, hooks or MCP, managed settings, allow_dangerous writes or unsandboxed-command approvals";
84
+ }
85
+ if (t.id === "codex" && cfg.allow_dangerous)
86
+ text += on ? "; allow_dangerous write jobs refused outside the stage-2 route" : "; not in allow_dangerous write turns, which run without a sandbox";
87
+ lines.push(`${t.label}, ${t.enabled ? "enabled" : "not enabled"}: ${text}`);
88
+ }
89
+ if (targets.some(t => neverFloorCoverage(t.id, cfg, env) === "not enforced")) {
90
+ lines.push("not enforced: that sandbox does not apply the floor's denies, so the agent can read the credential paths (~/.ssh, ~/.aws, CLI logins), keychain files and any never.paths of yours; relay's own config, install and key files stay protected there regardless.");
91
+ }
92
+ if (targets.some(t => { const k = neverKeychainIpc(t.id, cfg, env); return k?.networkOff === "open" || k?.networkOn === "open"; })) {
93
+ lines.push("keychain IPC open: the agent's own sandbox lets its commands reach the security daemons. Items in file-based keychains (the login keychain, where gh's keyring token and git's osxkeychain credentials live) still stay out of reach, since reading one also needs its keychain file, which the floor denies (checked each release: qualification item 33 for Codex, release check claude-floor for Claude). What the daemons serve without that file, such as data-protection keychain items, is not covered, nor is a copy of a keychain file kept outside the denied directories. Only relay's own Seatbelt keeps the daemons closed.");
94
+ }
95
+ lines.push("for every agent, relay's network proxy, where a turn uses one (a Claude network grant, the ACP network-off route), still screens never hosts and ports.");
96
+ return lines;
97
+ }
@@ -0,0 +1,49 @@
1
+ import net from "node:net";
2
+ import { neverEndpointProblem } from "./never-policy.js";
3
+ import { normalizeNeverHost } from "./never-schema.js";
4
+ /** Provider-owned DNS, never a model-supplied DNS snapshot. Refresh before new connections. */
5
+ export async function resolveNeverEndpoints(policy, lookup, o = {}) {
6
+ const ttl = o.ttlMs ?? 30_000;
7
+ if (!Number.isFinite(ttl) || ttl <= 0)
8
+ throw new Error("never endpoint TTL must be finite and positive");
9
+ const addresses = new Set(), cnames = new Set();
10
+ for (const h of policy.hosts) {
11
+ if (net.isIP(h.host)) {
12
+ addresses.add(h.host);
13
+ continue;
14
+ }
15
+ const found = await lookup(h.host);
16
+ if (!found.addresses.length)
17
+ throw new Error(`never cannot resolve required authority ${h.host}; mediated provider unavailable`);
18
+ for (const address of found.addresses) {
19
+ const a = normalizeNeverHost(address);
20
+ if (!net.isIP(a))
21
+ throw new Error(`never resolver returned a nonnumeric endpoint for ${h.host}`);
22
+ addresses.add(a);
23
+ }
24
+ for (const name of found.cnames)
25
+ cnames.add(normalizeNeverHost(name));
26
+ }
27
+ return { policyHash: policy.hash, expiresAt: (o.now ?? Date.now()) + ttl, addresses: [...addresses].sort(), cnames: [...cnames].sort() };
28
+ }
29
+ /** Screen the requested authority AND all checked numeric endpoints, then dial only those. */
30
+ export function neverConnectionProblem(policy, endpoint, checked, now = Date.now()) {
31
+ const direct = neverEndpointProblem(policy, endpoint);
32
+ if (direct)
33
+ return direct;
34
+ if (policy.hosts.length) {
35
+ if (!checked || checked.policyHash !== policy.hash || checked.expiresAt <= now)
36
+ return "never requires a fresh validated forbidden endpoint set before a mediated connection";
37
+ const host = normalizeNeverHost(endpoint.host);
38
+ if ([host, ...(endpoint.cnames ?? []).map(normalizeNeverHost)].some(h => checked.cnames.includes(h)))
39
+ return `never refuses forbidden CNAME authority ${host}`;
40
+ const ips = [...(net.isIP(host) ? [host] : []), ...(endpoint.addresses ?? [])].map(normalizeNeverHost);
41
+ if (ips.some(ip => checked.addresses.includes(ip)))
42
+ return `never refuses an endpoint alias of a forbidden authority (${host})`;
43
+ }
44
+ if (!net.isIP(normalizeNeverHost(endpoint.host)) && !endpoint.addresses?.length)
45
+ return "never requires checked numeric endpoints; an independent later DNS lookup is not allowed";
46
+ if ((endpoint.addresses ?? []).some(a => !net.isIP(normalizeNeverHost(a))))
47
+ return "never connection endpoints must be numeric";
48
+ return null;
49
+ }