@sema-agent/settings-schema 34.0.0 → 35.0.0

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 (76) hide show
  1. package/CHANGELOG.md +648 -0
  2. package/README.md +86 -39
  3. package/conformance/VERSION +1 -1
  4. package/conformance/cases/c100-a2a-inside-stale-fingerprint-dropped/expected.json +101 -0
  5. package/conformance/cases/c100-a2a-inside-stale-fingerprint-dropped/input.json +28 -0
  6. package/conformance/cases/c100-a2a-inside-stale-fingerprint-dropped/meta.json +6 -0
  7. package/conformance/cases/c101-a2a-inside-incomplete-dropped/expected.json +113 -0
  8. package/conformance/cases/c101-a2a-inside-incomplete-dropped/input.json +38 -0
  9. package/conformance/cases/c101-a2a-inside-incomplete-dropped/meta.json +6 -0
  10. package/conformance/cases/c102-a2a-inside-incomplete-zero-survivors/expected.json +85 -0
  11. package/conformance/cases/c102-a2a-inside-incomplete-zero-survivors/input.json +34 -0
  12. package/conformance/cases/c102-a2a-inside-incomplete-zero-survivors/meta.json +6 -0
  13. package/conformance/cases/c103-mcp-caller-meta-declared/expected.json +106 -0
  14. package/conformance/cases/c103-mcp-caller-meta-declared/input.json +28 -0
  15. package/conformance/cases/c103-mcp-caller-meta-declared/meta.json +6 -0
  16. package/conformance/cases/c98-a2a-registration-keys-carried/expected.json +163 -0
  17. package/conformance/cases/c98-a2a-registration-keys-carried/input.json +42 -0
  18. package/conformance/cases/c98-a2a-registration-keys-carried/meta.json +6 -0
  19. package/conformance/cases/c99-a2a-preapproval-on-outside-peer-dropped/expected.json +100 -0
  20. package/conformance/cases/c99-a2a-preapproval-on-outside-peer-dropped/input.json +23 -0
  21. package/conformance/cases/c99-a2a-preapproval-on-outside-peer-dropped/meta.json +6 -0
  22. package/dist/a2a-peer-identity.d.ts +116 -0
  23. package/dist/a2a-peer-identity.js +182 -0
  24. package/dist/api/credentials.d.ts +94 -14
  25. package/dist/api/credentials.js +33 -8
  26. package/dist/atomic-write.d.ts +9 -3
  27. package/dist/atomic-write.js +14 -6
  28. package/dist/catalog-manages.js +2 -2
  29. package/dist/config-d-file.d.ts +0 -3
  30. package/dist/config-d-file.js +1 -6
  31. package/dist/config-dir-migration.js +0 -1
  32. package/dist/config-document-refusal.d.ts +1 -1
  33. package/dist/config-fns.d.ts +21 -8
  34. package/dist/config-fns.js +16 -3
  35. package/dist/config-root-documents.d.ts +3 -54
  36. package/dist/config-root-documents.js +24 -21
  37. package/dist/config-root-node.d.ts +2 -96
  38. package/dist/config-root-node.js +15 -163
  39. package/dist/conformance/warnings.js +1 -1
  40. package/dist/conformance/web-admin-credential-lock.js +3 -2
  41. package/dist/cross-session.d.ts +2 -2
  42. package/dist/env-model-table.d.ts +3 -3
  43. package/dist/env-model-table.js +5 -5
  44. package/dist/fleet.d.ts +5 -5
  45. package/dist/index.d.ts +3 -1
  46. package/dist/index.js +3 -1
  47. package/dist/mcp-request-entry.d.ts +19 -0
  48. package/dist/mcp-request-entry.js +15 -13
  49. package/dist/migration-receipt.d.ts +9 -11
  50. package/dist/migration-receipt.js +4 -5
  51. package/dist/node.d.ts +3 -3
  52. package/dist/node.js +3 -3
  53. package/dist/one-time-migrations.d.ts +3 -4
  54. package/dist/one-time-migrations.js +3 -28
  55. package/dist/plugin-id-segment.d.ts +15 -0
  56. package/dist/plugin-id-segment.js +15 -0
  57. package/dist/plugin-settings.d.ts +61 -0
  58. package/dist/plugin-settings.js +111 -0
  59. package/dist/retired-envs.js +5 -0
  60. package/dist/safety-merge-spec.d.ts +23 -2
  61. package/dist/safety-merge-spec.js +13 -0
  62. package/dist/scheduler-store-node.d.ts +14 -11
  63. package/dist/scheduler-store-node.js +22 -34
  64. package/dist/scheduler-store.d.ts +21 -6
  65. package/dist/scheduler-store.js +100 -19
  66. package/dist/settings-units.d.ts +9 -0
  67. package/dist/settings-units.js +12 -7
  68. package/dist/types.d.ts +53 -4
  69. package/dist/types.js +79 -4
  70. package/docs/API-SURFACE.md +51 -11
  71. package/docs/CC-DIVERGENCE.md +2 -1
  72. package/docs/CONFORMANCE.md +4 -4
  73. package/docs/CONSUMER-INTEGRATION.md +158 -13
  74. package/llms-full.txt +47 -18
  75. package/llms.txt +18 -7
  76. package/package.json +7 -3
@@ -1,39 +1,34 @@
1
1
  /**
2
- * 配置根两份根级文档的**读写函数**与一次性迁移 SS-M11 的迁移体(Node 专用,经 `./node` 出口;名字、形与闭集答案表在 `./config-root-documents`)。
2
+ * 配置根上决定文档的**读写函数**(Node 专用,经 `./node` 出口;名字、形与闭集答案表在 `./config-root-documents`)。
3
+ * (35.0.0 起这里没有迁移体:一次性迁移 SS-M11 与它的运行记录读者窗关删了,决定缺席 ≡ `kept`。)
3
4
  *
4
5
  * 读写都经一只注入的 I/O 座 {@link ConfigRootIo}(真绑定 {@link nodeConfigRootIo}:读走 `node:fs/promises`,写走本包唯一的原子写器与它的模式表),
5
6
  * 所以单元层能把任意读写失败造出来;调用方不传就是真文件系统。
6
7
  *
7
- * · {@link readEnvModelsDecision} / {@link readMigrationMarker} —— 唯一的读者:不存在(`ENOENT`)⇒ `absent`;别的读错(权限 —— 可信属主的 0000 文件过得了引擎的目录信任判官、
8
- * 读恒 `EACCES`,是**持久**的 —— 不是常规文件、悬空符号链接、瞬时错)⇒ `unreadable io`;字节在 ⇒ 文本读法(`./config-root-documents`;决定的答案带同一次读的 `digest`)。
9
- * 读数从不抛(`readMigrationMarker` 只对不写运行记录的 id 抛 `TypeError` —— 调用方的错,不拿它拼路径)。**引擎在读之前先过它自己的目录信任判官**(属主 / 写位 / 常规文件);
8
+ * · {@link readEnvModelsDecision} —— 唯一的读者:不存在(`ENOENT`)⇒ `absent`;别的读错(权限 —— 可信属主的 0000 文件过得了引擎的目录信任判官、
9
+ * 读恒 `EACCES`,是**持久**的 —— 不是常规文件、悬空符号链接、瞬时错)⇒ `unreadable io`;字节在 ⇒ 文本读法(`./config-root-documents`;答案带同一次读的 `digest`)。
10
+ * 读数从不抛。**引擎在读之前先过它自己的目录信任判官**(属主 / 写位 / 常规文件);
10
11
  * 本函数不判属主。确认文件的字节只在这里被打开。
11
12
  * · {@link readEnvModelsDecisionSync} / {@link writeEnvModelsDecisionSync} —— 决定文档读 / 写的**同步孪生**(壳在同步具名锁里写模型池:先写决定 `replaced`、再写目录,两次写在同一把锁里 —— 要在锁里读、在锁里写):
12
13
  * 同一个字节读法、同一个缺席律、同一份答案表、同一份写计划、同一对同步原子写原语(异步座的写本来就是它们的异步包装);读写真文件系统,不收注入座(注入座是异步的,`ConfigRootIo` 不动)。
13
- * · {@link writeEnvModelsDecision} —— 决定文件的唯一写函数(迁移铸确认也经它):写者(用户确认之后)用 `overwrite`(原子改名覆盖,读不懂的旧文件整份换掉);
14
- * `createIfAbsent` 不存在才建(已在 ⇒ `present`;迁移铸确认用的就是这一种)。运行记录不经它 —— 由迁移独占创建。
14
+ * · {@link writeEnvModelsDecision} —— 决定文件的唯一写函数:写者(用户确认之后)用 `overwrite`(原子改名覆盖,读不懂的旧文件整份换掉);
15
+ * `createIfAbsent` 不存在才建(已在 ⇒ `present`)。
15
16
  * 模式与 `config.d` 域文档同一条规则(原子写器的 `config-document` 类:新建 0o644 经进程 umask、更严的 umask 只会更严;已有的文件沿用它原来的模式)—— 写者不要自己写这份文件:
16
17
  * 自写在 umask 002 下落 0664,引擎的目录信任判官会拒。
17
- * · {@link migrateEnvModelsDecision} —— SS-M11(窗与删法见 `ONE_TIME_MIGRATIONS` 登记表那一行)。**先读后选举**:先读决定与 models.json,再以「不存在才建」写
18
- * 运行记录 `config.migration.SS-M11.json` —— 建成的那个进程是本根唯一的铸造者,且只按它选举之前读到的决定铸;别的进程见记录已在即停、永不铸。
19
- * 撤销的终局按创建者算(见 {@link migrateEnvModelsDecision}):运行记录在场、创建者的结局落定之后,删掉决定文件与写 `kept` 同义、是终局(删掉运行记录再起服会重跑迁移);其它副本的返回不构成终局。
20
18
  */
21
19
  import { readFileSync, statSync } from "node:fs";
22
20
  import { readFile, stat } from "node:fs/promises";
23
21
  import path from "node:path";
24
- import { createFileExclusive, ensureOwnerOnlyDirectory, resolveSymlinkTarget, writeFileAtomic } from "./atomic-write.js";
25
- import { catalogManagesModelPlane } from "./catalog-manages.js";
26
- import { configDDocumentText, configDPath, judgeConfigDText } from "./config-d-file.js";
27
- import { ENV_MODELS_DECISIONS, ENV_MODELS_DOCUMENT, decodeRootBytes, ioDecision, isDecisionWord, isMarkedMigrationId, migrationMarkerDocument, migrationMarkerValue, readEnvModelsDecisionBytes, readMigrationMarkerBytes, } from "./config-root-documents.js";
28
- import { ENV_MODEL_TABLE_KEYS, buildEnvModelBaseline, snapshotEnvModelTable } from "./env-model-table.js";
29
- import { FsFailure, fsFailureMessage } from "./fs-failure.js";
22
+ import { createFileExclusive, resolveSymlinkTarget, writeFileAtomic } from "./atomic-write.js";
23
+ import { configDDocumentText } from "./config-d-file.js";
24
+ import { ENV_MODELS_DECISIONS, ENV_MODELS_DOCUMENT, ioDecision, isDecisionWord, readEnvModelsDecisionBytes, } from "./config-root-documents.js";
25
+ import { FsFailure } from "./fs-failure.js";
30
26
  import { readKey } from "./own-key-read.js";
31
27
  import { jsonShapeOf } from "./plain-json-object.js";
32
28
  import { deepFreeze } from "./deep-freeze.js";
33
- /** 根级文档 → 原子写器的模式类(穷举:加一份根级文档不补这一行 ⇒ 编译红,逼着为它选一类)。两份现有的根级文档都是契约文档(只带固定词,不带秘密值),与 `config.d` 域文档同属 `config-document`。 */
29
+ /** 根级文档 → 原子写器的模式类(穷举:加一份根级文档不补这一行 ⇒ 编译红,逼着为它选一类)。决定文档是契约文档(只带固定词,不带秘密值),与 `config.d` 域文档同属 `config-document`。 */
34
30
  const ROOT_DOCUMENT_CLASS = {
35
31
  [ENV_MODELS_DOCUMENT]: "config-document",
36
- [migrationMarkerDocument("SS-M11")]: "config-document",
37
32
  };
38
33
  /** 「不是常规文件」的拒句(异步读座与同步读口共用一句)。 */
39
34
  const notRegularFile = (file) => new Error(`${file} is not a regular file`);
@@ -52,7 +47,6 @@ export const nodeConfigRootIo = deepFreeze({
52
47
  },
53
48
  writeDocument: async (document, file, text) => writeRootDocumentSync(document, file, text),
54
49
  createDocument: async (document, file, text) => createRootDocumentSync(document, file, text),
55
- ensureDirectory: async (dir) => ensureOwnerOnlyDirectory(dir),
56
50
  });
57
51
  /** {@link nodeConfigRootIo}`.readFile` 的同步孪生(同步读口 {@link readEnvModelsDecisionSync} 用):同一条判法(符号链接 ⇒ 真文件,悬空抛;只读常规文件),只有读字节那一步同步。 */
58
52
  function readRootFileSync(file) {
@@ -62,7 +56,6 @@ function readRootFileSync(file) {
62
56
  return readFileSync(real);
63
57
  }
64
58
  const decisionFile = (root) => path.join(root, `${ENV_MODELS_DOCUMENT}.json`);
65
- const markerFile = (root, id) => path.join(root, `${migrationMarkerDocument(id)}.json`);
66
59
  /** 一个被抛出的东西的 errno:**只认自有的**字符串 `code`(经内核的键读法);读不出(会抛的 `code` getter、已撤销的 Proxy)、只靠继承、不是串 ⇒ `undefined`。从不抛(读者「从不抛」靠它)。 */
67
60
  const errnoOf = (e) => {
68
61
  const shape = jsonShapeOf(e); // 形状只问座位(总、不抛);穷举 switch:座位加一个词这里编译红
@@ -83,10 +76,10 @@ const errnoOf = (e) => {
83
76
  }
84
77
  }
85
78
  };
86
- /** 读字节失败之后怎么答 —— 本文件唯一的缺席律(异步 {@link readRootBytes} 与同步 {@link readRootBytesSync} 共用):不存在(只有 `ENOENT`)⇒ `absent`;别的读不出 ⇒ `io`(带 errno 与捕获的错,调用方要句子时据它铸)。 */
79
+ /** 读字节失败之后怎么答 —— 本文件唯一的缺席律(异步 {@link readRootBytes} 与同步 {@link readRootBytesSync} 共用):不存在(只有 `ENOENT`)⇒ `absent`;别的读不出 ⇒ `io`(带 errno;决定读数只要 errno —— 35.0.0 前还带捕获的错,给 SS-M11 读 models.json 时铸句用,随它删)。 */
87
80
  function rootBytesFailure(e) {
88
81
  const errno = errnoOf(e);
89
- return errno === "ENOENT" ? { kind: "absent" } : { kind: "io", errno, cause: e };
82
+ return errno === "ENOENT" ? { kind: "absent" } : { kind: "io", errno };
90
83
  }
91
84
  /** 经注入座读一份文件的字节(异步);失败的分类是 {@link rootBytesFailure}。 */
92
85
  async function readRootBytes(io, file) {
@@ -129,28 +122,6 @@ export async function readEnvModelsDecision(root, io = nodeConfigRootIo) {
129
122
  export function readEnvModelsDecisionSync(root) {
130
123
  return decisionOfBytes(readRootBytesSync(decisionFile(root)));
131
124
  }
132
- /**
133
- * 一条一次性迁移的运行记录的**唯一读者**(文件 `<根>/config.migration.<id>.json`):不存在 ⇒ `absent`;`{"migration":<id>}` ⇒ `present`;别的 ⇒ `unreadable`
134
- * (坏 JSON / 坏形 —— id 对不上也算 / 读不出)。「跑过」只问这一份文件在不在、读不读得懂,不读任何聚合文件。读数从不抛;`id` 不是写运行记录的迁移(根级文档名单里没有它的记录)⇒
135
- * `TypeError`,不拿它拼路径。
136
- */
137
- export async function readMigrationMarker(root, id, io = nodeConfigRootIo) {
138
- if (!isMarkedMigrationId(id))
139
- throw new TypeError(`readMigrationMarker: ${JSON.stringify(id)} is not a migration that writes a run marker (the root documents list it) — no path is built from it`);
140
- const bytes = await readRootBytes(io, markerFile(root, id));
141
- switch (bytes.kind) {
142
- case "absent":
143
- return { kind: "absent" };
144
- case "io":
145
- return { kind: "unreadable", reason: "io" };
146
- case "bytes":
147
- return readMigrationMarkerBytes(id, bytes.bytes);
148
- default: {
149
- const unhandled = bytes;
150
- throw new Error(`readMigrationMarker: unhandled reading ${JSON.stringify(unhandled)}`);
151
- }
152
- }
153
- }
154
125
  /** 写决定的**计划**(异步 {@link writeEnvModelsDecision} 与同步 {@link writeEnvModelsDecisionSync} 共用,三件事只在这里):决定词与写法都在闭集里(不在 ⇒ `TypeError`,调用方的错,一字不写)· 铸文本 · 写失败 ⇒ 本包的文件系统失败句(点名路径)。
155
126
  * `who` 只用来在 `TypeError` 里点名调用的是哪一只。 */
156
127
  function planDecisionWrite(who, root, decision, opts) {
@@ -175,7 +146,7 @@ function planDecisionWrite(who, root, decision, opts) {
175
146
  return { write, file, text, loud };
176
147
  }
177
148
  /**
178
- * 写配置根上的 env 模型表决定 —— 决定文件的**唯一写函数**(迁移铸确认也经它的 `createIfAbsent`;运行记录不归它,见文件头)。`overwrite` 恒答 `written`;`createIfAbsent` 在文档已在(`EEXIST`)时答 `present`(一字不动)。
149
+ * 写配置根上的 env 模型表决定 —— 决定文件的**唯一写函数**。`overwrite` 恒答 `written`;`createIfAbsent` 在文档已在(`EEXIST`)时答 `present`(一字不动)。
179
150
  * 决定词 / 写法不在闭集 ⇒ `TypeError`(一字不写)。写失败 ⇒ 抛本包的文件系统失败句(点名路径)。根须已存在。
180
151
  */
181
152
  export async function writeEnvModelsDecision(root, decision, opts, io = nodeConfigRootIo) {
@@ -223,122 +194,3 @@ export function writeEnvModelsDecisionSync(root, decision, opts) {
223
194
  }
224
195
  }
225
196
  }
226
- /** 手工恢复句(迁移建不成收据 / 建不成决定时随结局交出;调用方原样放进它那一行告警):点名决定文件与两种写法。 */
227
- const wayOutFor = (root) => `write ${decisionFile(root)} by hand — {"envModels":"replaced"} lets the catalog replace the env models, {"envModels":"kept"} keeps them`;
228
- /** 读 `config.d/models.json` 一次(字节经 {@link readRootBytes} —— 与两份根级文档同一条缺席律;文本过 `config.d` 文档的那一只文本判 —— 与文件仓库同一读法):
229
- * 缺席 / 坏文件 ⇒ 不管;别的读错 ⇒ 读不出(不折成不管)。 */
230
- async function readModelsDocument(io, root) {
231
- const file = configDPath(root, "models");
232
- const read = await readRootBytes(io, file);
233
- let bytes;
234
- switch (read.kind) {
235
- case "absent":
236
- return { kind: "not_managing" };
237
- case "io":
238
- return { kind: "unreadable", errno: read.errno, error: fsFailureMessage({ landing: "read", path: file, of: "file" }, read.cause) };
239
- case "bytes":
240
- bytes = read.bytes;
241
- break;
242
- default: {
243
- const unhandled = read;
244
- throw new Error(`readModelsDocument: unhandled reading ${JSON.stringify(unhandled)}`);
245
- }
246
- }
247
- let doc;
248
- try {
249
- doc = judgeConfigDText("models", decodeRootBytes(bytes), file);
250
- }
251
- catch {
252
- return { kind: "not_managing" }; // a bad file manages nothing; the file store refuses it loudly on its own read
253
- }
254
- return catalogManagesModelPlane(doc) ? { kind: "manages" } : { kind: "not_managing" }; // JSON 解析出来的值恒是纯数据:判官不会抛
255
- }
256
- /**
257
- * **一次性迁移 SS-M11**(登记见 `ONE_TIME_MIGRATIONS`;起服、第一次读本地配置之前调,只在配置源是本地时):
258
- * 1. 读运行记录:`present` ⇒ `already_ran`;读不懂 ⇒ `marker_unreadable`(按已跑处理)。
259
- * 2. **先读**:决定 D0 = `readEnvModelsDecision`,M0 = `config.d/models.json` 管不管模型面(管 / 不管 / 读不出)。此后的铸只按 D0 / M0 决定,不再读决定 ——
260
- * D0 是 replaced(预置)而它在选举之后被删 ⇒ 不重铸;D0 是 absent 而选举之后有人写了决定 ⇒ 第 5 步的独占创建守住它。
261
- * 3. 根缺席 ⇒ 建(仅属主可进,连同缺的上级,模式恰是 0o700);**不建 `config.d`**。
262
- * 4. **独占创建运行记录** `{"migration":"SS-M11"}`:建成 ⇒ 本进程是本根**唯一的铸造者**;已在(`EEXIST`)⇒ `not_minter`,永不铸;别的失败 ⇒ `marker_write_failed`,不铸。
263
- * 5. 仅铸造者:D0 不是 `absent` ⇒ 不铸(读不懂的也不覆盖);M0 不管 ⇒ 不铸;M0 读不出 ⇒ 不铸(`models_unreadable`,带 errno(若有)与手工恢复句);否则**独占创建** `{"envModels":"replaced"}` —— 结局三词:`minted` / `exists`(只有 `EEXIST`)/
264
- * `failed`(带 errno 与手工恢复句)。铸不铸不看 env;env 只在铸成之后读一次、只读两槽,用来点名被顶替的 env 模型。
265
- * 运行记录在场之后,确认缺席 ≡ kept(读这份决定的一律这么读:服务端的本地配置腿、迁移、写者)。
266
- * 撤销的终局按运行记录的创建者算:只有创建者能写确认;以运行记录在场为前提,创建者写完 / 判定不写 / 失败(结局 `minted` / `exists` / `skipped` / `models_unreadable` / `failed`,调用方各记一行)之后,删掉决定文件就是撤销且是终局(删掉运行记录再起服 ⇒ 迁移重跑,决定缺席即重铸);其它副本读到记录在场 = 已跑、跳过(或得 `EEXIST` 答 `not_minter`),它们的返回不构成终局;创建者当选到结局落定之间的窗口在挂起 / I/O 卡顿下无上界,窗口内唯一安全的撤销是写 `kept`(独占创建护住它;删掉的会被创建者照它先读的 D0 铸回);创建者在写确认之前崩溃 ⇒ 永久 `kept`(fail-closed,披露)。
267
- */
268
- export async function migrateEnvModelsDecision(input) {
269
- const { root, env } = input;
270
- const io = input.io ?? nodeConfigRootIo;
271
- const marker = await readMigrationMarker(root, "SS-M11", io);
272
- switch (marker.kind) {
273
- case "present":
274
- return { kind: "already_ran" };
275
- case "unreadable":
276
- return { kind: "marker_unreadable", reason: marker.reason };
277
- case "absent":
278
- break;
279
- default: {
280
- const unhandled = marker;
281
- throw new Error(`migrateEnvModelsDecision: unhandled marker ${JSON.stringify(unhandled)}`);
282
- }
283
- }
284
- const decision = await readEnvModelsDecision(root, io);
285
- const models = await readModelsDocument(io, root);
286
- const file = markerFile(root, "SS-M11");
287
- let createdRoot;
288
- let created;
289
- try {
290
- // 一次操作一条路径串:建的目录是随后要写的那份文件的路径串的 dirname(原子写器的文件头「一次操作一条路径串」)—— 配置根下的文件一向是 `path.join(根, 文件名)`
291
- createdRoot = (await io.ensureDirectory(path.dirname(file))) === "created";
292
- created = await io.createDocument(migrationMarkerDocument("SS-M11"), file, configDDocumentText(migrationMarkerValue("SS-M11")));
293
- }
294
- catch (e) {
295
- return { kind: "marker_write_failed", errno: errnoOf(e), error: fsFailureMessage({ landing: "write", path: file }, e), wayOut: wayOutFor(root) };
296
- }
297
- if (created === "present")
298
- return { kind: "not_minter" };
299
- return { kind: "recorded", createdRoot, decision, mint: await mintDecision(io, root, env, decision, models) };
300
- }
301
- async function mintDecision(io, root, env, decision, models) {
302
- switch (decision.kind) {
303
- case "absent":
304
- break;
305
- case "replaced":
306
- case "kept":
307
- case "unreadable":
308
- return { kind: "skipped", why: "decision_present" };
309
- default: {
310
- const unhandled = decision;
311
- throw new Error(`migrateEnvModelsDecision: unhandled decision ${JSON.stringify(unhandled)}`);
312
- }
313
- }
314
- switch (models.kind) {
315
- case "manages":
316
- break;
317
- case "not_managing":
318
- return { kind: "skipped", why: "not_managing" };
319
- case "unreadable":
320
- return { kind: "models_unreadable", errno: models.errno, error: models.error, wayOut: wayOutFor(root) };
321
- default: {
322
- const unhandled = models;
323
- throw new Error(`migrateEnvModelsDecision: unhandled models reading ${JSON.stringify(unhandled)}`);
324
- }
325
- }
326
- let wrote;
327
- try {
328
- wrote = await writeEnvModelsDecision(root, "replaced", { write: "createIfAbsent" }, io);
329
- }
330
- catch (e) {
331
- // the write function throws only its file-system failure (it names the decision file and carries the errno)
332
- return { kind: "failed", errno: errnoOf(e), error: fsFailureMessage({ landing: "write", path: decisionFile(root) }, e), wayOut: wayOutFor(root) };
333
- }
334
- if (wrote === "present")
335
- return { kind: "exists" };
336
- // env is read only now, once, and only the two slot keys: it names the env models the minted decision replaces (none when no table is declared);
337
- // a run that stops earlier reads no env at all
338
- const slots = snapshotEnvModelTable(env, [ENV_MODEL_TABLE_KEYS.mainId, ENV_MODEL_TABLE_KEYS.cheapId]);
339
- return {
340
- kind: "minted",
341
- receipt: { migration: "SS-M11", document: ENV_MODELS_DOCUMENT, path: ["envModels"], appliedAs: "minted" },
342
- replacedEnvModels: buildEnvModelBaseline(slots).entries,
343
- };
344
- }
@@ -124,7 +124,7 @@ export function findSecretLeaks(warnings, secrets) {
124
124
  const hay = warnings.map((w) => `${stableKey(projectWarning(w))}${JOINER}${stableKey(fieldsBesideError(w))}${JOINER}${errorText(w)}`).join(JOINER);
125
125
  return secrets.filter((s) => s.length > 0 && hay.includes(s));
126
126
  }
127
- /** 一条告警除 `error` 外的**每一只**键(扫描用,不是投影):投影只留比对用的键(每臂声明的诊断键不进投影 —— `domain-defaulted` 的 `path` / `identity` / `reasonCode` / `unknownKeys` / `truncatedFrom`、`entry-dropped` 的 `unknownKeys` / `truncatedFrom`;见 `WarningProjection`),
127
+ /** 一条告警除 `error` 外的**每一只**键(扫描用,不是投影):投影只留比对用的键(每臂声明的诊断键不进投影 —— `domain-defaulted` 的 `path` / `identity` / `reasonCode` / `unknownKeys` / `truncatedFrom` / `registrationProblems`、`entry-dropped` 的 `unknownKeys` / `truncatedFrom` / `registrationProblems`;见 `WarningProjection`),
128
128
  * 扫描却要看告警带出门的一切 —— 每个 kind 同一个读法,新加的键不会因为不在投影里就躲过扫描。 */
129
129
  function fieldsBesideError(w) {
130
130
  return Object.fromEntries(Object.entries(w).filter(([k]) => k !== "error")); // fromEntries(不是逐键赋值):键名不走原型 setter
@@ -10,8 +10,9 @@
10
10
  * 看不到的东西不判:只试一次的「次数」、收残留的交错、身份取自 fd 且 fd 钉到放锁 —— 这些要注入系统调用才能排出来,在本包自己的白盒钉里(黑盒里只量「忙时不等待」的耗时上界)。
11
11
  * 「失锁」两格(锁被换成继任者)对一只不钉 fd 的实现是概率性的:继任者的锁恰好复用了持有者那只的 inode 号时,那样的实现会读成「仍是自己的」。
12
12
  * 锁名被命名管道 / 悬空软链占着的两种形在本包自己的白盒钉里(命名管道要放进可超时终止的子进程,黑盒格里不造);黑盒里用目录代表「锁名上不是普通文件」那一类,答案是同一个。
13
- * 悬空软链(链接在、目标不在 —— 经软链到达的凭据文件登出之后的样子)是**失败关闭**:`unreadable`、不建文件、不写。这是本版协议的答案,也是已知限制(登出后再登录写不进去;出路 = 删掉悬空链接或先重建目标),
14
- * 根修后这一格翻成「写穿」。
13
+ * 悬空软链(链接在、目标不在 —— 经软链到达的凭据文件登出之后的样子)是**失败关闭**:`unreadable`、不建文件、不写。这是本版协议的答案,也是已知限制(登出后再登录写不进去;出路 = 删掉悬空链接或先重建目标):
14
+ * 本版不解析悬空链接的落点 —— 要做就得改原子写器对悬空链接的拒律(不替链接建它指向的文件),那是另一份设计、按大版本排。
15
+ * 本包原语对这一形答的 `unreadable` 多一个可缺的诊断位 `ioKind`(`dangling_symlink`),这份 kit 不判它:别的实现不带这一键也过。
15
16
  * 已知范围:软链两格(写穿 · 悬空)要求宿主允许建符号链接(Windows 上普通用户默认不允许,那两格会以「建链接失败」红)。
16
17
  */
17
18
  import { closeSync, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, statSync, symlinkSync, utimesSync, writeFileSync } from "node:fs";
@@ -64,8 +64,8 @@ export type DialogExpiryValue = (typeof DIALOG_EXPIRY_VALUES)[number];
64
64
  export declare const DIALOG_EXPIRY_DEFAULT: DialogExpiryValue;
65
65
  /** 文件层受理面:四个值 + `"default"`(未设 ⇒ 落 {@link DIALOG_EXPIRY_DEFAULT})。 */
66
66
  export declare const DialogExpirySetting: z.ZodEnum<{
67
- never: "never";
68
67
  default: "default";
68
+ never: "never";
69
69
  "60s": "60s";
70
70
  "5m": "5m";
71
71
  "10m": "10m";
@@ -85,8 +85,8 @@ export declare const CrossSessionSettings: z.ZodObject<{
85
85
  hold: "hold";
86
86
  }>>;
87
87
  dialogExpiry: z.ZodOptional<z.ZodEnum<{
88
- never: "never";
89
88
  default: "default";
89
+ never: "never";
90
90
  "60s": "60s";
91
91
  "5m": "5m";
92
92
  "10m": "10m";
@@ -29,10 +29,10 @@ export type EnvCheapSlot = {
29
29
  /** cheap 槽铸出来的 id(不铸 ⇒ `undefined`)。 */
30
30
  export declare function mintedCheapId(slot: EnvCheapSlot): string | undefined;
31
31
  /**
32
- * 包内(不进包根):把 env 模型表的键(缺省四把;调用方只要两槽时只拍两把)**读一次**进一份快照(下标读,同「读到即算」)。计划助手与一次性迁移在**要用的那一刻**拍、
33
- * 此后的每个读法都答自同一份 —— 一只 getter 两次读答两个值时,判「env 表已声明」与列 env 模型不会各读到一个(那样结局与回执自相矛盾);用不到的键不读。
32
+ * 包内(不进包根):把 env 模型表的四把键**读一次**进一份快照(下标读,同「读到即算」)。计划助手在**要用的那一刻**拍、
33
+ * 此后的每个读法都答自同一份 —— 一只 getter 两次读答两个值时,判「env 表已声明」与列 env 模型不会各读到一个(那样结局与回执自相矛盾);表外的键不读。
34
34
  */
35
- export declare function snapshotEnvModelTable(env: EnvSnapshot, keys?: readonly EnvModelTableKey[]): EnvSnapshot;
35
+ export declare function snapshotEnvModelTable(env: EnvSnapshot): EnvSnapshot;
36
36
  /** env 两槽的**唯一读口**(见文件头)。`mainId` = `MODEL_ID`(空串 = 没有主槽)。 */
37
37
  export declare function readEnvModelSlots(env: EnvSnapshot): {
38
38
  readonly mainId: string;
@@ -5,7 +5,7 @@
5
5
  * ## 律
6
6
  * · **env 两槽只在这里读一次**({@link readEnvModelSlots}):`MODEL_ID` 缺席或空串 = 没有主槽(纯空白算在场 —— 与引擎的 env 路由读口同尺);
7
7
  * cheap 槽四态({@link EnvCheapSlot})。「env 模型表已声明」({@link envModelTableDeclared})与角色底({@link buildEnvModelBaseline})都由它派生 ——
8
- * 这道闸的执行方(服务端的本地配置腿)与写者的计划助手调同一份(一次性迁移 SS-M11 只用两槽点名被顶替的 env 模型,铸不铸不看它),不各写一份。env 快照按「读到即算」(下标读;原型分层的快照里继承来的键算在场)。
8
+ * 这道闸的执行方(服务端的本地配置腿)与写者的计划助手调同一份,不各写一份。env 快照按「读到即算」(下标读;原型分层的快照里继承来的键算在场)。
9
9
  * 引擎另有「名册占位 ⇒ env 表算空」一格,那是引擎自己的部署事实,不在本包。
10
10
  * · **计划助手判序**({@link planEnvModelTableWrite}):目标腿不读 `config.d`(remote / none)⇒ 照写 → 候选不管模型面 ⇒ 照写 →
11
11
  * env 表未声明 ⇒ 照写、**不写确认** → 配置根的决定是 `replaced` ⇒ 照写 →
@@ -47,12 +47,12 @@ export function mintedCheapId(slot) {
47
47
  }
48
48
  }
49
49
  /**
50
- * 包内(不进包根):把 env 模型表的键(缺省四把;调用方只要两槽时只拍两把)**读一次**进一份快照(下标读,同「读到即算」)。计划助手与一次性迁移在**要用的那一刻**拍、
51
- * 此后的每个读法都答自同一份 —— 一只 getter 两次读答两个值时,判「env 表已声明」与列 env 模型不会各读到一个(那样结局与回执自相矛盾);用不到的键不读。
50
+ * 包内(不进包根):把 env 模型表的四把键**读一次**进一份快照(下标读,同「读到即算」)。计划助手在**要用的那一刻**拍、
51
+ * 此后的每个读法都答自同一份 —— 一只 getter 两次读答两个值时,判「env 表已声明」与列 env 模型不会各读到一个(那样结局与回执自相矛盾);表外的键不读。
52
52
  */
53
- export function snapshotEnvModelTable(env, keys = Object.values(ENV_MODEL_TABLE_KEYS)) {
53
+ export function snapshotEnvModelTable(env) {
54
54
  const snapshot = isolatedObject(); // the package's copy container (no inherited members to read)
55
- for (const key of keys)
55
+ for (const key of Object.values(ENV_MODEL_TABLE_KEYS))
56
56
  Object.defineProperty(snapshot, key, dataDescriptor(env[key]));
57
57
  return snapshot;
58
58
  }
package/dist/fleet.d.ts CHANGED
@@ -110,8 +110,8 @@ export declare function compareGeneration(a: string, b: string): -1 | 0 | 1;
110
110
  */
111
111
  export declare const LEASE_STATES: readonly ["none", "granted", "expired", "denied"];
112
112
  export declare const LeaseState: z.ZodEnum<{
113
- expired: "expired";
114
113
  none: "none";
114
+ expired: "expired";
115
115
  granted: "granted";
116
116
  denied: "denied";
117
117
  }>;
@@ -343,8 +343,8 @@ export declare const EngineSignal: z.ZodObject<{
343
343
  }, z.core.$strip>>;
344
344
  generation: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
345
345
  leaseState: z.ZodOptional<z.ZodEnum<{
346
- expired: "expired";
347
346
  none: "none";
347
+ expired: "expired";
348
348
  granted: "granted";
349
349
  denied: "denied";
350
350
  }>>;
@@ -386,8 +386,8 @@ export declare const InstanceHealth: z.ZodObject<{
386
386
  }, z.core.$strip>>;
387
387
  generation: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
388
388
  leaseState: z.ZodOptional<z.ZodEnum<{
389
- expired: "expired";
390
389
  none: "none";
390
+ expired: "expired";
391
391
  granted: "granted";
392
392
  denied: "denied";
393
393
  }>>;
@@ -458,8 +458,8 @@ export declare const InstanceAnnouncement: z.ZodObject<{
458
458
  }, z.core.$strip>>;
459
459
  generation: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
460
460
  leaseState: z.ZodOptional<z.ZodEnum<{
461
- expired: "expired";
462
461
  none: "none";
462
+ expired: "expired";
463
463
  granted: "granted";
464
464
  denied: "denied";
465
465
  }>>;
@@ -507,8 +507,8 @@ export declare const InstanceRegistration: z.ZodObject<{
507
507
  }, z.core.$strip>>;
508
508
  generation: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
509
509
  leaseState: z.ZodOptional<z.ZodEnum<{
510
- expired: "expired";
511
510
  none: "none";
511
+ expired: "expired";
512
512
  granted: "granted";
513
513
  denied: "denied";
514
514
  }>>;
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * web-admin, the worker service, and the TOC desktop/CLI.
4
4
  */
5
5
  export * from "./types.js";
6
+ export { A2A_PEER_BOUNDARIES, A2A_PEER_ENTRY_PROBLEMS, A2A_PEER_FINGERPRINT_RE, A2aPeerFingerprint, a2aPeerBoundaryOf, a2aPeerFingerprintDigest, mintA2aPeerFingerprint, pairA2aPeers, type A2aPeerBoundary, type A2aPeerEntryProblem, type A2aPeerFields, type A2aPeerIdentitySource, type A2aPeerPairable, type A2aPeerPairing, } from "./a2a-peer-identity.js";
6
7
  export * from "./execution-lanes.js";
7
8
  export * from "./config-document-refusal.js";
8
9
  export * from "./url-shape.js";
@@ -13,7 +14,7 @@ export * from "./url-credential.js";
13
14
  export * from "./default-model.js";
14
15
  export { catalogManagesModelPlane, enabledEntryCount, isExplicitlyDisabledEntry } from "./catalog-manages.js";
15
16
  export { DEFAULT_MODEL_KEY, ENV_MODEL_TABLE_KEYS, buildEnvModelBaseline, envModelTableDeclared, envModelTableWriteRefusal, mintedCheapId, planEnvModelTableWrite, readEnvModelSlots, type EnvCheapSlot, type EnvModelBaseline, type EnvModelTableEntry, type EnvModelTableKey, type EnvModelTableLanding, type EnvModelTableReceipt, type EnvModelTableRoleRow, type EnvModelTableTarget, type EnvModelTableWriteInput, type EnvModelTableWriteIntent, type EnvModelTableWritePlan, type EnvRoleBinding, type EnvSnapshot, } from "./env-model-table.js";
16
- export { CONFIG_ROOT_DOCUMENTS, ENV_MODELS_DECISIONS, ENV_MODELS_DOCUMENT, ROOT_DOCUMENT_UNREADABLE_REASONS, envModelsDecisionTag, type ConfigRootDocument, type EnvModelsDecision, type EnvModelsDecisionWord, type MarkedMigrationId, type MigrationMarker, type RootDocumentUnreadableReason } from "./config-root-documents.js";
17
+ export { CONFIG_ROOT_DOCUMENTS, ENV_MODELS_DECISIONS, ENV_MODELS_DOCUMENT, ROOT_DOCUMENT_UNREADABLE_REASONS, envModelsDecisionTag, type ConfigRootDocument, type EnvModelsDecision, type EnvModelsDecisionWord, type RootDocumentUnreadableReason } from "./config-root-documents.js";
17
18
  export * from "./loopback.js";
18
19
  export * from "./hash.js";
19
20
  export * from "./sha256.js";
@@ -29,6 +30,7 @@ export * from "./settings-units.js";
29
30
  export * from "./scheduler-store.js";
30
31
  export * from "./cross-session.js";
31
32
  export * from "./hooks.js";
33
+ export * from "./plugin-settings.js";
32
34
  export * from "./fleet.js";
33
35
  export * from "./workers-rows.js";
34
36
  export * from "./api/auth.js";
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  * web-admin, the worker service, and the TOC desktop/CLI.
4
4
  */
5
5
  export * from "./types.js";
6
+ export { A2A_PEER_BOUNDARIES, A2A_PEER_ENTRY_PROBLEMS, A2A_PEER_FINGERPRINT_RE, A2aPeerFingerprint, a2aPeerBoundaryOf, a2aPeerFingerprintDigest, mintA2aPeerFingerprint, pairA2aPeers, } from "./a2a-peer-identity.js"; // (named: the entry judge, its member table and the issue-word reading stay package-private — A2aPeerSpec is the one place an entry is judged): the a2a peer's identity and registration — boundary words A2A_PEER_BOUNDARIES + their one reading a2aPeerBoundaryOf (absent = outside); the entry-problem closed set A2A_PEER_ENTRY_PROBLEMS (the engine primitives' registration words + fingerprint_stale / id_missing); the identity stamp: its one spelling A2A_PEER_FINGERPRINT_RE / A2aPeerFingerprint, the one digest recompute a2aPeerFingerprintDigest, the one mint mintA2aPeerFingerprint (this package mints, everyone else compares); the one pairing of a stored roster with a submitted one pairA2aPeers (id first, then name among the unpaired); Web Crypto random, no node:crypto — pure/browser-safe
6
7
  export * from "./execution-lanes.js"; // 7.0.0 M-R2: the ONE lane / store vocabulary (EXECUTION_LANE_WORDS / EXECUTION_LANES / STORE_BACKENDS / SESSION_BACKENDS / MEMORY_ENGINE_BACKENDS) + THE lane-coordinate blank judge isBlankCoordinate (empty or whitespace-only = absent; the write gate and every consumer ask this one function; whether a key is set, and whether an optional key may be empty, stays the caller's call; the same function object as on the `./execution-lanes` subpath) — a leaf whose only import is the package-private zero-import freezer, pure/browser-safe
7
8
  export * from "./config-document-refusal.js"; // 15.2.0: the typed refusal of one config.d document (CONFIG_DOCUMENT_REFUSAL_REASONS = empty / invalid_json / not_object / io / too_deep / retired_domain; ConfigDocumentRefusal { document, reason, error }; its file-level arm carries an optional ioKind on io refusals — CONFIG_DOCUMENT_IO_KINDS = dangling_symlink / read_error, 31.1.0) — the reading is `FileConfigStore.read()` in ./node; pure/browser-safe
8
9
  export * from "./url-shape.js"; // 11.0.0: THE URL shape judge (httpUrlFlaws / httpUrlRule / isHierarchicalUrl; 16.0.0 + wsUrlFlaws), pure/browser-safe
@@ -13,7 +14,7 @@ export * from "./url-credential.js"; // 14.5.0: THE "does this URL carry a crede
13
14
  export * from "./default-model.js"; // 11.0.0: THE catalog-default resolver (roles.default → active tier ladder → fallback), pure/browser-safe
14
15
  export { catalogManagesModelPlane, enabledEntryCount, isExplicitlyDisabledEntry } from "./catalog-manages.js"; // THE "does this models document manage the model plane" judge (raw half: at least one entry not explicitly disabled) + the log count it is derived from + THE "is this one entry explicitly disabled" predicate they (and every per-entry consumer) read (the three-state `enabled` reading stays package-private), pure/browser-safe
15
16
  export { DEFAULT_MODEL_KEY, ENV_MODEL_TABLE_KEYS, buildEnvModelBaseline, envModelTableDeclared, envModelTableWriteRefusal, mintedCheapId, planEnvModelTableWrite, readEnvModelSlots, } from "./env-model-table.js"; // the env model table (MODEL_ID / MODEL_CHEAP_ID) read once: readEnvModelSlots / envModelTableDeclared / buildEnvModelBaseline + the writer's plan planEnvModelTableWrite (receipt by id, confirmKey) + envModelTableWriteRefusal, pure/browser-safe (named: the env snapshot helper stays package-private)
16
- export { CONFIG_ROOT_DOCUMENTS, ENV_MODELS_DECISIONS, ENV_MODELS_DOCUMENT, ROOT_DOCUMENT_UNREADABLE_REASONS, envModelsDecisionTag } from "./config-root-documents.js"; // the config-root documents (config.env-models.json + the per-id migration marker config.migration.<id>.json): names + closed answer tables + the one tagged identity of a decision reading (envModelsDecisionTag); the readers / writer are in ./node
17
+ export { CONFIG_ROOT_DOCUMENTS, ENV_MODELS_DECISIONS, ENV_MODELS_DOCUMENT, ROOT_DOCUMENT_UNREADABLE_REASONS, envModelsDecisionTag } from "./config-root-documents.js"; // the config-root document (config.env-models.json): names + closed answer tables + the one tagged identity of a decision reading (envModelsDecisionTag); the readers / writer are in ./node
17
18
  export * from "./loopback.js"; // 11.0.0: the two「本机」predicates (auth relaxation — narrow / connection routing — wide), pure/browser-safe
18
19
  export * from "./hash.js";
19
20
  export * from "./sha256.js";
@@ -29,6 +30,7 @@ export * from "./settings-units.js"; // 14.6.0: SETTINGS_UNITS — the settings-
29
30
  export * from "./scheduler-store.js"; // R7 self-wake scheduler store CONTRACT (pure: type + parse/serialize + SchedulerStore interface; fs binding in ./node)
30
31
  export * from "./cross-session.js"; // CC-parity `settings.json` cross-session keys (crossSessionInbound / dialogExpiry) — pure/browser-safe
31
32
  export * from "./hooks.js"; // CC-parity hooks contract (33-event set + owner map + per-event input/output shapes + the config surface: classifyHooksConfig and its zod faces HooksConfig / HookEntry …) & stop attribution (stoppedBy) — pure/browser-safe
33
+ export * from "./plugin-settings.js"; // the three pure readings of the plugin settings values — readEnabledPluginsValue (one `enabledPlugins` value: on / off / versions / unreadable) + readPluginId (`<name>@<marketplace>`, exactly one `@`, both halves read the one segment grammar PLUGIN_ID_SEGMENT_REGEX, re-exported by ./types from a package-private zero-import leaf; the scoped npm source id `@<scope>/<pkg>@npm` is read too — its name carries `@` and `/`, so it is not a valid `PluginSpec.name`) + the four marketplace sentinel words PLUGIN_MARKETPLACE_SENTINELS / isPluginMarketplaceSentinel; values only — how the central layer and the settings layers combine is not here; the same function objects as on the `./plugin-settings` subpath, pure/browser-safe
32
34
  export * from "./fleet.js"; // scheduling/fleet contract (drain protocol · instance discovery · dispatch policy · quota lease · usage report · quota reset event) — CONTROL-PLANE-SCHEDULING-DESIGN, pure/browser-safe
33
35
  export * from "./workers-rows.js"; // 11.0.0 the workers domain's per-row verdict (readWorkersRows: a row that does not read is held, the rest read on) — permanent read semantics, pure
34
36
  export * from "./api/auth.js"; // /api/v1/auth/* wire contract (RFC 8628 device flow + rotating refresh + logout + approve) — REGISTRY-REBUILD-DESIGN §2, M1 shipped shapes frozen, pure/browser-safe
@@ -71,6 +71,25 @@ export type McpRequestCredentialKind = McpRequestCredential["kind"];
71
71
  * 读器对一个值的准入问的是同一只谓词,所以表与读器不会各说各的。表里每个种类都是 `own_entry`、引擎的 `own_entry` 种类都在表里,由测试两向对拍(引擎再认一种而判口不收 ⇒ 红,逼着有人表态 http 收不收)。
72
72
  */
73
73
  export declare const MCP_REQUEST_CREDENTIAL_KINDS: readonly McpRequestCredentialKind[];
74
+ /** {@link readRequestMcpCredentials} 的答案:缺席 / 收下(带判口新造的冻结副本)/ 拒(带机读词 `credentials_not_carried` 与原因句)。三臂均深冻结。 */
75
+ export type RequestMcpCredentialsVerdict = {
76
+ readonly kind: "absent";
77
+ } | {
78
+ readonly kind: "taken";
79
+ readonly credential: McpRequestCredential;
80
+ } | {
81
+ readonly kind: "refused";
82
+ readonly refusal: Extract<McpRequestKeyRefusal, "credentials_not_carried">;
83
+ readonly reason: string;
84
+ };
85
+ /**
86
+ * 请求面「这一个已读出的 `credentials` 值收不收」的**唯一判口**:传输读器 {@link readRequestMcpTransport} 调的就是这一只。
87
+ * **只判值**:「键只靠继承可见 ⇒ 不读、进 `lost`」与「`assertionHeader` 在场 ⇒ 整条先拒、不判 `credentials`」是读器读整条传输时的律,判口没有这些上下文 —— 两者在同一个已读出的值上同答,不在整条传输的读法与判序上同答。
88
+ * **调用方的值只读一次**(原语包读法 `readCredentialRef`,本模块的唯一调用处):读得出且准入表对请求面拒这个种类(`env` / `handle` / `assertion`)⇒ 拒,点名种类(两种传输同句);
89
+ * 否则 stdio ⇒ 拒(没有座位);http 上把读出的安全副本问判口 {@link readHookPluginOptionRef}(「是不是保险库类引用」整个包里只此一只判口),判口收且引擎准入表对请求面仍是 `own_entry` ⇒ 收下 —— 交出的是判口新造的冻结副本,不是调用方的对象;其余 ⇒ 拒(说清收什么)。
90
+ * 三臂答案均深冻结;拒臂的 `refusal` 与读器放进 `issue.refusal` 的是同一个机读词({@link MCP_REQUEST_KEY_REFUSALS} 的 `credentials_not_carried`);句子都不回显值。
91
+ */
92
+ export declare function readRequestMcpCredentials(transport: "stdio" | "http", value: unknown): RequestMcpCredentialsVerdict;
74
93
  /**
75
94
  * 请求面一条 MCP 条目的传输形。与引擎传输形的关系逐键一句(处置表,对拍 = 上游漂移门 ⑧):
76
95
  * · `kind` / `command` / `args` / `url` / `principalHeader` —— 与引擎同键同型;
@@ -203,7 +203,7 @@ const ASSERTION_HEADER_RETIRED_ON_REQUEST = retiredFormSentence("transport.asser
203
203
  const KIND_PROBE_ENTRY = "probe";
204
204
  /**
205
205
  * 请求面 **http** 传输收不收一个值 —— **准入的唯一一处合取**:判口 {@link readHookPluginOptionRef} 收它 ∧ 引擎准入表对请求面仍是 `own_entry`(引擎哪天收回某种类的准入,读器随它拒,读器表也随它空)。
206
- * 收 ⇒ 判口新造的引用(尚未冻结);不收 ⇒ `undefined`。读器表({@link MCP_REQUEST_CREDENTIAL_KINDS})与读器({@link judgeCredentials})都问它,谁也不另写这个合取。
206
+ * 收 ⇒ 判口新造的引用(尚未冻结);不收 ⇒ `undefined`。读器表({@link MCP_REQUEST_CREDENTIAL_KINDS})与读器({@link readRequestMcpCredentials})都问它,谁也不另写这个合取。
207
207
  */
208
208
  function requestPlaneTakes(value) {
209
209
  const ref = readHookPluginOptionRef(value);
@@ -215,28 +215,30 @@ function requestPlaneTakes(value) {
215
215
  * 读器对一个值的准入问的是同一只谓词,所以表与读器不会各说各的。表里每个种类都是 `own_entry`、引擎的 `own_entry` 种类都在表里,由测试两向对拍(引擎再认一种而判口不收 ⇒ 红,逼着有人表态 http 收不收)。
216
216
  */
217
217
  export const MCP_REQUEST_CREDENTIAL_KINDS = deepFreeze(CREDENTIAL_REF_KINDS.filter((kind) => requestPlaneTakes({ kind, entry: KIND_PROBE_ENTRY }) !== undefined));
218
- const CREDENTIALS_ABSENT = { kind: "absent" };
219
- const credentialsRefused = (reason) => ({ kind: "refused", reason });
218
+ const CREDENTIALS_ABSENT = deepFreeze({ kind: "absent" });
219
+ const credentialsRefused = (reason) => deepFreeze({ kind: "refused", refusal: "credentials_not_carried", reason });
220
220
  /** http 传输上「不是读器收的引用」的原因句:说清收什么(种类取自读器表),不回显值。 */
221
221
  const HTTP_CREDENTIALS_NOT_TAKEN = `an MCP http entry in a request takes a credential reference of kind ${MCP_REQUEST_CREDENTIAL_KINDS.map((k) => `"${k}"`).join(" or ")} only — this value is not one (every other kind is declared by the deployment); correct transport.credentials or remove it from the request`;
222
222
  /** stdio 传输上一切 `credentials` 的原因句(它没有凭据引用的座位)。 */
223
223
  const STDIO_CREDENTIALS_NO_SEAT = "an MCP server entry in a request carries no credential reference (its transport has no seat for one; the deployment declares it) — remove transport.credentials from the request";
224
224
  /**
225
- * 请求里一个 `credentials` 值(自有键、已读出)的判。**调用方的值只读一次**(原语包读法 `readCredentialRef`,本模块的唯一调用处):读得出且准入表对请求面拒这个种类(`env` / `handle` / `assertion`)⇒ 拒,点名种类(两种传输同句);
226
- * 否则 stdio ⇒ 拒(没有座位);http 上把读出的安全副本问判口 {@link readHookPluginOptionRef}(「是不是保险库类引用」整个包里只此一只判口),判口收且引擎准入表对请求面仍是 `own_entry` ⇒ 收下 —— 交出的是判口新造的冻结副本,
227
- * 不是调用方的对象;其余 ⇒ 拒(说清收什么)。句子都不回显值。
225
+ * 请求面「这一个已读出的 `credentials` 值收不收」的**唯一判口**:传输读器 {@link readRequestMcpTransport} 调的就是这一只。
226
+ * **只判值**:「键只靠继承可见 ⇒ 不读、进 `lost`」与「`assertionHeader` 在场 ⇒ 整条先拒、不判 `credentials`」是读器读整条传输时的律,判口没有这些上下文 —— 两者在同一个已读出的值上同答,不在整条传输的读法与判序上同答。
227
+ * **调用方的值只读一次**(原语包读法 `readCredentialRef`,本模块的唯一调用处):读得出且准入表对请求面拒这个种类(`env` / `handle` / `assertion`)⇒ 拒,点名种类(两种传输同句);
228
+ * 否则 stdio ⇒ 拒(没有座位);http 上把读出的安全副本问判口 {@link readHookPluginOptionRef}(「是不是保险库类引用」整个包里只此一只判口),判口收且引擎准入表对请求面仍是 `own_entry` ⇒ 收下 —— 交出的是判口新造的冻结副本,不是调用方的对象;其余 ⇒ 拒(说清收什么)。
229
+ * 三臂答案均深冻结;拒臂的 `refusal` 与读器放进 `issue.refusal` 的是同一个机读词({@link MCP_REQUEST_KEY_REFUSALS} 的 `credentials_not_carried`);句子都不回显值。
228
230
  */
229
- function judgeCredentials(transport, raw) {
230
- if (raw === undefined)
231
+ export function readRequestMcpCredentials(transport, value) {
232
+ if (value === undefined)
231
233
  return CREDENTIALS_ABSENT;
232
- const read = readCredentialRef(raw);
234
+ const read = readCredentialRef(value);
233
235
  if (read.ok && CREDENTIAL_REF_TRUST[read.ref.kind].request === "refused") {
234
236
  return credentialsRefused(`a credential reference of kind "${read.ref.kind}" is never taken from a request (the deployment declares it for this server) — remove transport.credentials from the request`);
235
237
  }
236
238
  if (transport === "stdio")
237
239
  return credentialsRefused(STDIO_CREDENTIALS_NO_SEAT);
238
240
  const taken = read.ok ? requestPlaneTakes(read.ref) : undefined;
239
- return taken !== undefined ? { kind: "taken", credential: deepFreeze(taken) } : credentialsRefused(HTTP_CREDENTIALS_NOT_TAKEN);
241
+ return taken !== undefined ? deepFreeze({ kind: "taken", credential: deepFreeze(taken) }) : credentialsRefused(HTTP_CREDENTIALS_NOT_TAKEN);
240
242
  }
241
243
  /** 点名拒的硬坏形(机读词在 `refusal`)。 */
242
244
  const keyRefused = (path, reason, refusal) => ({ ok: false, issue: { path, reason, refusal } });
@@ -245,7 +247,7 @@ function refusedKeyOf(assertionHeader, credentials) {
245
247
  if (assertionHeader !== undefined)
246
248
  return keyRefused("transport.assertionHeader", ASSERTION_HEADER_RETIRED_ON_REQUEST, "key_retired");
247
249
  if (credentials.kind === "refused")
248
- return keyRefused("transport.credentials", credentials.reason, "credentials_not_carried");
250
+ return keyRefused("transport.credentials", credentials.reason, credentials.refusal);
249
251
  return undefined;
250
252
  }
251
253
  const transportBad = (path, reason) => ({ ok: false, issue: { path, reason } });
@@ -363,7 +365,7 @@ function snapshotTransport(tr) {
363
365
  const credentials = axis("credentials");
364
366
  if (!credentials.ok)
365
367
  return credentials;
366
- const refused = refusedKeyOf(undefined, judgeCredentials("stdio", credentials.value));
368
+ const refused = refusedKeyOf(undefined, readRequestMcpCredentials("stdio", credentials.value));
367
369
  if (refused !== undefined)
368
370
  return { ok: true, value: { kind: "refused", read: refused } };
369
371
  const fields = ownFieldsOf(tr, ["command", "args", "env"]);
@@ -379,7 +381,7 @@ function snapshotTransport(tr) {
379
381
  if (!credentials.ok)
380
382
  return credentials;
381
383
  // 判序 = 读序:`assertionHeader` 在场 ⇒ 先答 `key_retired`,调用方交来的 `credentials` 值一个成员都不碰(不为一个注定要拒的条目多跑调用方的代码);不在场才判它
382
- const verdict = assertionHeader.value === undefined ? judgeCredentials("http", credentials.value) : CREDENTIALS_ABSENT;
384
+ const verdict = assertionHeader.value === undefined ? readRequestMcpCredentials("http", credentials.value) : CREDENTIALS_ABSENT;
383
385
  const refused = refusedKeyOf(assertionHeader.value, verdict);
384
386
  if (refused !== undefined)
385
387
  return { ok: true, value: { kind: "refused", read: refused } };
@@ -1,27 +1,25 @@
1
1
  /**
2
2
  * 一次性迁移的**收据形**与两张闭集(11.0.0)—— 叶子模块(运行期零依赖;除包内私有的零 import 叶 `./deep-freeze` 外只有型导入),由 `./one-time-migrations` 再导出(不进主桶)。
3
- * 单拆出来只为一件事:读迁移 id 闭集的叶子(墓碑句 `./retired-form`、车道表 `./execution-lane-index`、配置根文档 `./config-root-documents`)
3
+ * 单拆出来只为一件事:读迁移 id 闭集的叶子(墓碑句 `./retired-form`、车道表 `./execution-lane-index`)
4
4
  * 不该为一个型把整套迁移体与域 schema 拉进来。(26.0.0 起调度店的读口不再带收据 —— 它的读时改写到期删了。)
5
5
  */
6
- import type { ENV_MODELS_DOCUMENT } from "./config-root-documents.js";
7
6
  import type { DomainName } from "./types.js";
8
7
  /** 本版登记的一次性迁移 id(闭集;每个 id 在 `ONE_TIME_MIGRATIONS` 登记表里恰一行)。收据只许这些 id。 */
9
- export declare const ONE_TIME_MIGRATION_IDS: readonly ["SS-M11", "SS-M12", "SS-M13", "SS-M14"];
8
+ export declare const ONE_TIME_MIGRATION_IDS: readonly ["SS-M12", "SS-M13", "SS-M14"];
10
9
  export type OneTimeMigrationId = (typeof ONE_TIME_MIGRATION_IDS)[number];
11
10
  /**
12
11
  * 一条收据说迁移**对一个坐标做了什么**(闭集,每词一义):
13
12
  * - `moved` — 值搬到新位(`to`),义不变;
14
13
  * - `rewritten` — 同一坐标上的值换成今天的生效读法(例:15.x worker 行的记忆方言词 `tidb` ⇒ `mysql`);
15
14
  * - `dropped-inert` — 删掉;今天的读法本就不让它生效(例:不声明那条车道的行上的车道键、mcp 条目上从没有读者的 `authForm` / `entryKind`);
16
- * - `refused` — 不改:要改就得替运维猜(或旧文档今天本就读不进);原样留着,读侧照旧响亮拒,`reason` 说为什么;
17
- * - `minted` — 在**缺席处**写下一份新事实(一份部署决定),不改任何已有的值 —— 只有 SS-M11 铸(配置根的 `config.env-models.json`:
18
- * 升级前「管模型面的目录整表顶替 env 模型」的读法,写成 `replaced`;不存在才建)。
15
+ * - `refused` — 不改:要改就得替运维猜(或旧文档今天本就读不进);原样留着,读侧照旧响亮拒,`reason` 说为什么。
16
+ * (35.0.0 起没有 `minted`:唯一铸它的 SS-M11 窗关删了。)
19
17
  */
20
- export declare const MIGRATION_APPLIED_AS: readonly ["moved", "rewritten", "dropped-inert", "refused", "minted"];
18
+ export declare const MIGRATION_APPLIED_AS: readonly ["moved", "rewritten", "dropped-inert", "refused"];
21
19
  export type MigrationAppliedAs = (typeof MIGRATION_APPLIED_AS)[number];
22
- /** 收据指向的那份文档:配置域名,或配置根上的 env 模型表决定(`config.env-models`,SS-M11 铸)。
23
- * (26.0.0 起没有一步给 retired 域 `runtime`、`config.d/remote-exec.json` 或调度店出收据 —— 那三只文档的迁移步到期删了。) */
24
- export type MigrationDocument = DomainName | typeof ENV_MODELS_DOCUMENT;
20
+ /** 收据指向的那份文档:配置域名。
21
+ * (26.0.0 起没有一步给 retired 域 `runtime`、`config.d/remote-exec.json` 或调度店出收据 —— 那三只文档的迁移步到期删了;35.0.0 起也没有给配置根上的 `config.env-models` 的 —— SS-M11 删了。) */
22
+ export type MigrationDocument = DomainName;
25
23
  /** 文档里的段坐标(字符串段 = 对象键,数字段 = 数组下标;与告警坐标同一形)。 */
26
24
  export type MigrationPath = readonly (string | number)[];
27
25
  interface ReceiptBase {
@@ -37,7 +35,7 @@ export type MigrationReceipt = (ReceiptBase & {
37
35
  readonly path: MigrationPath;
38
36
  };
39
37
  }) | (ReceiptBase & {
40
- readonly appliedAs: "rewritten" | "dropped-inert" | "minted";
38
+ readonly appliedAs: "rewritten" | "dropped-inert";
41
39
  }) | (ReceiptBase & {
42
40
  readonly appliedAs: "refused";
43
41
  readonly reason: string;