@sema-agent/settings-schema 31.0.1 → 32.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 (65) hide show
  1. package/CHANGELOG.md +894 -0
  2. package/README.md +88 -19
  3. package/conformance/VERSION +1 -1
  4. package/conformance/cases/c97-roles-own-proto-key-entry-dropped/expected.json +105 -0
  5. package/conformance/cases/c97-roles-own-proto-key-entry-dropped/input.json +26 -0
  6. package/conformance/cases/c97-roles-own-proto-key-entry-dropped/meta.json +6 -0
  7. package/dist/api/auth.d.ts +1 -1
  8. package/dist/api/feedback.d.ts +3 -3
  9. package/dist/api/feedback.js +3 -2
  10. package/dist/atomic-write.d.ts +4 -1
  11. package/dist/atomic-write.js +15 -2
  12. package/dist/center-refs.d.ts +1 -1
  13. package/dist/center-refs.js +1 -1
  14. package/dist/config-d-file.d.ts +22 -4
  15. package/dist/config-d-file.js +12 -3
  16. package/dist/config-document-refusal.d.ts +13 -2
  17. package/dist/config-document-refusal.js +2 -0
  18. package/dist/config-fns.d.ts +14 -3
  19. package/dist/config-fns.js +49 -12
  20. package/dist/config-root-documents.js +1 -1
  21. package/dist/conformance/contract-adapter.js +18 -1
  22. package/dist/declared-capture.d.ts +1 -1
  23. package/dist/declared-capture.js +5 -1
  24. package/dist/device-lane-knobs.d.ts +57 -0
  25. package/dist/device-lane-knobs.js +127 -0
  26. package/dist/execution-lanes.d.ts +3 -1
  27. package/dist/execution-lanes.js +3 -1
  28. package/dist/file-store.js +2 -2
  29. package/dist/fleet.d.ts +5 -5
  30. package/dist/fleet.js +4 -3
  31. package/dist/hooks-config.d.ts +47 -23
  32. package/dist/hooks-config.js +93 -134
  33. package/dist/hooks.d.ts +26 -22
  34. package/dist/hooks.js +17 -8
  35. package/dist/host-path.d.ts +9 -5
  36. package/dist/host-path.js +9 -20
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.js +3 -1
  39. package/dist/ip-address.d.ts +19 -0
  40. package/dist/ip-address.js +28 -0
  41. package/dist/loopback.d.ts +3 -11
  42. package/dist/loopback.js +11 -12
  43. package/dist/mcp-request-entry.js +4 -6
  44. package/dist/migration-receipt.d.ts +1 -1
  45. package/dist/migration-receipt.js +1 -1
  46. package/dist/one-time-migrations.d.ts +1 -1
  47. package/dist/one-time-migrations.js +257 -62
  48. package/dist/plain-json-object.d.ts +5 -8
  49. package/dist/plain-json-object.js +5 -8
  50. package/dist/record-seat.d.ts +35 -0
  51. package/dist/record-seat.js +97 -0
  52. package/dist/reserved-member-name.d.ts +8 -3
  53. package/dist/reserved-member-name.js +10 -3
  54. package/dist/retired-envs.js +13 -2
  55. package/dist/safety-merge-spec.d.ts +11 -3
  56. package/dist/safety-merge-spec.js +3 -2
  57. package/dist/types.d.ts +404 -112
  58. package/dist/types.js +132 -73
  59. package/docs/API-SURFACE.md +25 -6
  60. package/docs/CC-DIVERGENCE.md +11 -2
  61. package/docs/CONFORMANCE.md +2 -2
  62. package/docs/CONSUMER-INTEGRATION.md +177 -6
  63. package/llms-full.txt +35 -21
  64. package/llms.txt +12 -8
  65. package/package.json +7 -6
@@ -11,6 +11,15 @@
11
11
  * **迁移只认形、不认义**:每一步的输入形在新契约下非法、输出形合法 ⇒ 重跑恒等,新写入的数据永远不会被当成旧数据再改一次,不需要版本围栏;
12
12
  * 同一串字节换意思的改动一律**换表示**(11.0.0 的 SS-M6 因此是「`atModelAllowlist` → `atMention`」换字段,而不是翻 `[]` 的义)。
13
13
  *
14
+ * ## 读法(一条,所有改写步共用:SS-M12 / SS-M13 / SS-M14 读调用方交来的容器只有这一种读法)
15
+ * **每只容器(文档树里的每一个位置)只读一次**:文档、一层对象、一只座,各**整只**读一次 —— 每只自有键一份描述符、值只从描述符里取(不走 `[[Get]]`、不调 getter、不问 `get` 陷阱);
16
+ * 数组按下标读一次(内建 `forEach` 的读法:`length` 与在场的下标各一次 `[[Get]]`,下标上的访问器调一次 —— 数组读法的既有形,见 {@link rowsByIndex};副本与原数组同长,有洞的数组不迁);
17
+ * 同一只对象挂在两个位置,就按位置各读一次、各铸各的(JSON 里没有共享引用);没有要改的容器也照读
18
+ * (读法不看「这次有没有要改的」,所以没有哪一步靠「只读它要判的那几把键」省读)。**判与写回都用这一份读数**:写回的新对象由读数铸(`objectFrom`),不展开调用方的对象、不回头再读它 ——
19
+ * 嵌入方的 Proxy 在两次读之间换答案、或 `get` 陷阱另给一份,都进不来。**读不出**(撤销的 Proxy、陷阱抛)或**不是纯数据**(对象容器上的访问器、不可枚举的自有键)⇒ **抛**,不当「不适用」悄悄跳过
20
+ * (数组读里陷阱抛出的值原样出来,不是包里那一句);「不适用」只给形状(不是对象 / 不是数组 / 不是朴素对象 / 有洞的数组 —— 迁移只改它点名的键,读不懂的容器形不替调用方改,原样留给读面判)。三只小件各管一件:{@link snapshotOf}(对象容器 ⇒ 一份读数)· {@link rowsOf}(数组容器 ⇒ 按下标读一次的副本)·
21
+ * {@link objectFrom}(读数 ⇒ 新对象);步只许经它们读调用方的容器。JSON 解析出来的文档(纯数据)读不出也没有访问器,所以每一步的结果与读法无关;只有 JS 调用方交来的非纯数据会碰到抛。
22
+ *
14
23
  * ## 第二种机制:在配置根上铸一次事实(只有 SS-M11)
15
24
  * 上面的「只认形」律管的是**改写存储文档**的迁移。SS-M11 不改写任何存储形:它在一份文档**缺席**处铸一份部署决定(配置根的 `config.env-models.json`,收据词 `minted`),
16
25
  * 而「缺席」本身没有形可认 —— 所以它不归上面的律,另有三条:① 它读 env、碰文件系统,住 `./node`(`migrateEnvModelsDecision`),不在下面的纯函数入口里;
@@ -35,7 +44,7 @@
35
44
  */
36
45
  import { outgoingPath, redactSecrets } from "./config-fns.js";
37
46
  import { LANE_ENV_OWNER, LATE_LANE_ENV_KEYS } from "./execution-lane-index.js";
38
- import { NOT_PLAIN_DATA, UNINSPECTABLE, UninspectableError, captureJson, dataDescriptor, emptyDocument, ownEntriesOf, ownOrThrow, readDeclaredKey, sentenceOfMinted } from "./own-key-read.js";
47
+ import { UNINSPECTABLE, UninspectableError, captureJson, dataDescriptor, emptyDocument, ownEntriesOf, ownOrThrow, sentenceOfMinted } from "./own-key-read.js";
39
48
  import { isJsonArray, isPlainJsonObject, jsonShapeOf } from "./plain-json-object.js";
40
49
  import { isDomainName, isRetiredDomainName } from "./types.js";
41
50
  import { workerRowVerdict } from "./worker-row-verdict.js";
@@ -100,6 +109,26 @@ export const ONE_TIME_MIGRATIONS = deepFreeze([
100
109
  "degrades to its default when no entry survives); residual authForm / entryKind keys are unknown keys — stripped on write, the entry dropped " +
101
110
  "on read (entry-unknown-key)",
102
111
  },
112
+ {
113
+ id: "SS-M14",
114
+ oldForm: "refused",
115
+ introducedIn: "32.0.0",
116
+ releasedOn: "2026-11-21",
117
+ removableAfter: "2026-12-21",
118
+ rewrites: "entitlement: the two runtime caps removed in 32.0.0, on both runtimeCaps seats a stored document holds (defaults.runtimeCaps and every " +
119
+ "tiers[].runtimeCaps) — allowAutoMode false ⇒ autoMode false (moved; the deny wins: an autoMode true beside it becomes false, as the 31.x " +
120
+ "reading already denied auto mode when either key said false), allowAutoMode true ⇒ deleted (dropped-inert: it was only a ceiling, true = " +
121
+ "no ceiling), allowUltracode true or false ⇒ deleted (dropped-inert: no consumer ever enforced it). Every other key of the seat is kept " +
122
+ "verbatim and in place; autoMode lands where allowAutoMode stood unless the seat already has one. Refused and kept verbatim, the whole " +
123
+ "seat: a seat carrying an old key whose allowAutoMode, allowUltracode or autoMode is neither a boolean nor absent (31.x could not read that " +
124
+ "document either; an explicit undefined reads as absent). The caps wire (PrincipalCapsWire.runtimeCaps) is minted " +
125
+ "from these two seats and has no stored form of its own",
126
+ removal: "the next major after the window: delete the SS-M14 step and SS-M14 from ONE_TIME_MIGRATION_IDS; the runtimeCaps.allowAutoMode / " +
127
+ "runtimeCaps.allowUltracode tombstone fields stay — their SS-M14 clause goes",
128
+ afterRemoval: "the runtimeCaps.allowAutoMode / runtimeCaps.allowUltracode tombstone fields on the three seats (permanent): a residual key is refused on " +
129
+ "write, the entitlement domain does not read on the view face (DomainReadRefusedError), and a caps wire body carrying one fails " +
130
+ "PrincipalCapsWire",
131
+ },
103
132
  ]);
104
133
  /**
105
134
  * 迁移一组存储文档(见文件头「入口」)。纯函数;没改的文档原样返回;**不抬任何版本号**(结果里没有版本 —— 那是调用方的)。
@@ -123,7 +152,8 @@ export function migrateStoredDocuments(docs) {
123
152
  }
124
153
  }
125
154
  // 工作副本是**隔离原型**(`COPY_PROTOTYPE`,没有继承来的成员)的袋(它的读没有继承可说:`Object.prototype.models` 被污染成数据值时,`out.models` 不会读到一份「存储文档」),文档集只读一次(每个域文档一个值);
126
- // 之后每一步对文档里固定键的读都经内核的自有键读(`ownOrThrow`),读不出的存储文档 ⇒ 下面那一处统一抛 TypeError(带全包唯一那一句)—— 迁移本来就是抛的读口,不另造失败臂
155
+ // 之后每一步从这只袋里取自己的域文档(`ownOrThrow`:读的是包自己的袋),再按文件头「读法」读那份文档(`snapshotOf` / `rowsOf`);读不出 / 不是纯数据 ⇒ 下面那一处统一抛 TypeError(带全包唯一那一句,
156
+ // 或坏形自己的句子;数组按下标读里陷阱抛出的值原样出来 —— 既有的、有钉)—— 迁移本来就是抛的读口,不另造失败臂
127
157
  const entries = ownEntriesOf(docs);
128
158
  if (!entries.ok)
129
159
  throw new TypeError(`migrateStoredDocuments: the stored documents could not be read — ${entries.sentence}`);
@@ -134,6 +164,7 @@ export function migrateStoredDocuments(docs) {
134
164
  // 步序的律:纯改写步在前,拿新 schema 终判改写结果的 workers 行步最后 —— 它判的是**全部**改写之后的行(否则一跑 refused、二跑才过:既不是一次完成,也不幂等)。
135
165
  try {
136
166
  stepMcpServers(out, receipts);
167
+ stepEntitlementRuntimeCaps(out, receipts);
137
168
  stepWorkersRows(out, receipts);
138
169
  }
139
170
  catch (e) {
@@ -190,43 +221,87 @@ export function migrateEffectiveSnapshot(effective) {
190
221
  Object.defineProperty(next, k, dataDescriptor(v));
191
222
  return { effective: { ...next }, receipts: m.receipts };
192
223
  }
193
- /** `o` 是朴素对象且**自有**键 `k` 在场(描述符律,与 `ownOrThrow` 同一只核:访问器 / 不可枚举的自有键不当缺席 ⇒ 抛带「不是纯数据」那一句;读不出 ⇒ 抛;迁移本来就抛)。 */
194
- const has = (o, k) => {
195
- if (!isPlainJsonObject(o))
196
- return false;
197
- const read = readDeclaredKey(o, k);
198
- switch (read.presence) {
199
- case "own":
200
- return true;
201
- case "inherited":
202
- case "absent":
203
- return false;
204
- case "hidden":
205
- throw new UninspectableError(NOT_PLAIN_DATA);
206
- case "unreadable":
224
+ /**
225
+ * 读一只对象容器,**只读一次**(内核的整容器读 `ownEntriesOf`:每只键恰一份描述符、值只从它里面取,不走 `[[Get]]`);之后判与写回都用这一份读数,
226
+ * 嵌入方的 Proxy 在两次读之间换答案、或 get 陷阱另给一份,都进不来。朴素对象 ⇒ 读数;别的形(数组 / `null` / 原始值 / 非朴素对象)⇒ `undefined`(判形是读者的事);
227
+ * **读不出**(撤销的 Proxy、陷阱抛;访问器 / 不可枚举的自有键 = 不是纯数据)⇒ 抛 —— 不是「不适用」,迁移本来就是抛的读口(入口那一处收成全包那一句)。
228
+ */
229
+ function snapshotOf(v) {
230
+ const shape = jsonShapeOf(v);
231
+ switch (shape) {
232
+ case "plain": {
233
+ const entries = ownEntriesOf(v);
234
+ if (!entries.ok)
235
+ throw new UninspectableError(entries.sentence);
236
+ return new Map(entries.value);
237
+ }
238
+ case "uninspectable":
207
239
  throw new UninspectableError();
240
+ case "non_plain_object":
241
+ case "array":
242
+ case "null":
243
+ case "primitive":
244
+ return undefined;
208
245
  default: {
209
- const unhandled = read;
210
- throw new Error(`has: unhandled presence ${String(unhandled.presence)}`);
246
+ const unhandled = shape;
247
+ throw new Error(`one-time-migrations: unhandled shape ${String(unhandled)}`);
211
248
  }
212
249
  }
213
- };
214
- const without = (o, k) => {
215
- const { [k]: _gone, ...rest } = o;
216
- return rest;
217
- };
250
+ }
251
+ /**
252
+ * 读一只数组容器(workers 行 / mcp 条目 / 权益档位),**按下标读一次**,答包自己的副本:没有洞的数组 ⇒ 同长的副本(读法见 {@link rowsByIndex});
253
+ * 有洞的数组与别的形 ⇒ `undefined`(这只容器的形迁移读不懂 —— 步不迁它,原样留给读面判);
254
+ * **读不出**(撤销的 Proxy 连「是不是数组」都问不出)⇒ 抛,与 {@link snapshotOf} 同一条。
255
+ */
256
+ function rowsOf(v) {
257
+ const shape = jsonShapeOf(v);
258
+ switch (shape) {
259
+ case "array":
260
+ return rowsByIndex(v);
261
+ case "uninspectable":
262
+ throw new UninspectableError();
263
+ case "plain":
264
+ case "non_plain_object":
265
+ case "null":
266
+ case "primitive":
267
+ return undefined;
268
+ default: {
269
+ const unhandled = shape;
270
+ throw new Error(`one-time-migrations: unhandled shape ${String(unhandled)}`);
271
+ }
272
+ }
273
+ }
218
274
  /**
219
- * 一只存储文档里的数组(workers 行 / mcp 条目)的行,**按下标读一次**:内建 `Array.prototype.forEach` 的读法(`length` 一次;`0 … length-1` 里在场的下标各一次 `[[HasProperty]]` + `[[Get]]`,洞不读)——
220
- * v28.0.0 调的是数组实例上的 `forEach` 且边判边写回(写回时走迭代器把各下标再读一次),自此只有这一次读;不走调用方数组自己的迭代器(展开 / `for…of` 会)、不调它自己的成员(实例上的 `forEach`、`slice` 经 `constructor` 取的 species 都会)。
221
- * 读到的值按原下标**定义**进一只包自己的数组(洞留洞;定义语义:`Array.prototype` 上被污染出数字键的 setter 吞不掉它)。行步判的与写回的都是这一份副本(拒的行原样就是这一次读到的值)。
275
+ * 一只存储文档里的数组(workers 行 / mcp 条目 / 权益档位)的行,**按下标读一次**:内建 `Array.prototype.forEach` 的读法(`length` 一次 `[[Get]]`、按 `ToLength` 取整;`0 … length-1` 逐位一次
276
+ * `[[HasProperty]]`,在场的再一次 `[[Get]]`)—— v28.0.0 调的是数组实例上的 `forEach` 且边判边写回(写回时走迭代器把各下标再读一次),自此只有这一次读;不走调用方数组自己的迭代器(展开 / `for…of` 会)、
277
+ * 不调它自己的成员(实例上的 `forEach`、`slice` 经 `constructor` 取的 species 都会)。读到的值按原下标**定义**进一只包自己的数组(定义语义:`Array.prototype` 上被污染出数字键的 setter 吞不掉它),
278
+ * 副本与原数组同长。行步判的与写回的都是这一份副本(拒的行原样就是这一次读到的值)。
279
+ * **遇到洞 ⇒ `undefined`**(洞本身不读,其后的下标也不再读):JSON 里没有洞,有洞的数组是迁移读不懂的容器形 —— 迁移只改它点名的键,不替调用方把容器改形
280
+ * (此前从 `[]` 起只定义在场的下标:尾部的洞被丢、副本变短,写回的展开又把内部的洞写成显式的 `undefined`;一份读面本来要拒的文档迁后变收)。
281
+ * 只由 {@link rowsOf} 调(形状先判)。
222
282
  */
223
283
  function rowsByIndex(array) {
284
+ const length = toLength(array.length);
224
285
  const rows = [];
225
- Array.prototype.forEach.call(array, (row, index) => {
226
- Object.defineProperty(rows, index, dataDescriptor(row));
227
- });
286
+ for (let index = 0; index < length; index++) {
287
+ if (!(index in array))
288
+ return undefined;
289
+ Object.defineProperty(rows, index, dataDescriptor(array[index]));
290
+ }
228
291
  return rows;
229
292
  }
293
+ /** 内建数组方法读 `length` 的取整(规范的 `ToLength`):转数、截成整数,`NaN` 与负数作 0,上限 2^53 − 1。 */
294
+ const toLength = (v) => {
295
+ const n = Math.trunc(+v);
296
+ return Number.isNaN(n) || n <= 0 ? 0 : Math.min(n, Number.MAX_SAFE_INTEGER);
297
+ };
298
+ /** 由一份读数铸寻常对象,原序逐只**定义**(自有 `__proto__` 数据键照样是数据键,不当原型写);`replace` 里的键换成新值、位置不动。写回的新对象只由这一只铸。 */
299
+ function objectFrom(snapshot, replace = new Map()) {
300
+ const o = {};
301
+ for (const [k, v] of snapshot)
302
+ Object.defineProperty(o, k, dataDescriptor(replace.has(k) ? replace.get(k) : v));
303
+ return o;
304
+ }
230
305
  // 收据的三只铸点。坐标里的键段是用户写的(未知键名、zod issue 路径里的 Record 键),完全可能就是一条粘错位置的凭据 ⇒ 与读侧告警坐标
231
306
  // 走同一道出门(`outgoingPath`,codex r1 F1);拒因句过 `redactSecrets`。收据从不带值。
232
307
  function receipt(migration, document, path, appliedAs) {
@@ -242,24 +317,40 @@ function refused(migration, document, path, reason) {
242
317
  const SS_M12_ENV_KEYS = [...LATE_LANE_ENV_KEYS].filter(([, m]) => m.migration === "SS-M12").map(([k]) => k);
243
318
  /**
244
319
  * 一行的 15.x 改写(规则见登记表 SS-M12 行)。只认 7.0+ 行上的三种形 —— `runtime.execution.lane`、`runtime.store.memory.backend: "tidb"`、带 `runtime.execution` 的行
245
- * 逃生口里的晚登记车道键 —— 逐字段改,每改一处一张收据。先浅读判要不要迁(没有这三种形的行一个字段都不动、不拷);要迁才拍快照改副本。
320
+ * 逃生口里的晚登记车道键 —— 逐字段改,每改一处一张收据。读法见文件头「读法」:判要读的容器 —— 行、`runtime`、`execution`、`store`、`memory`、`env`、`secretEnv` —— 各读一次(没有这三种形的行读到这里为止,
321
+ * 不拷、不碰行上别的容器的内容);要迁才把这几份读数铸回一棵树、整棵拍成工作副本改 —— 读过的位置不被第二次读(判的读数就是改写的读数),行上别的容器在这一拍第一次也只一次被读。
322
+ * 同一只对象若还挂在行上别的位置(`note: runtime` 那样的别名,只有程序造得出),那个位置按位置自己读一次、得到自己的副本 —— 与 SS-M14 对共享引用的口径同(各位置各读各铸)。
246
323
  * 改完的行不在这里判:读侧那一只(`workerRowVerdict`)在 workers 行步里判一次(`stepWorkersRows`)。
247
324
  */
248
325
  function migrateWorkerRow15(row) {
249
326
  const refuse = (field, reason) => ({ kind: "refused", field, reason });
250
- const peek = (o, k) => (isPlainJsonObject(o) ? ownOrThrow(o, k) : undefined);
251
- const rawRuntime = peek(row, "runtime");
252
- const rawExecution = peek(rawRuntime, "execution");
253
- const laneOld = has(rawExecution, "lane");
254
- const memoryTidb = peek(peek(peek(rawRuntime, "store"), "memory"), "backend") === "tidb";
255
- const lateKeysAt = (slot) => (isPlainJsonObject(rawExecution) ? SS_M12_ENV_KEYS.filter((k) => has(peek(row, slot), k)) : []);
327
+ const readRuntime = snapshotOf(row.get("runtime"));
328
+ const readExecution = snapshotOf(readRuntime?.get("execution"));
329
+ const readStore = snapshotOf(readRuntime?.get("store"));
330
+ const readMemory = snapshotOf(readStore?.get("memory"));
331
+ // 车道键只在声明了 `runtime.execution` 的行上才有意义:那时才读两只逃生口
332
+ const readSlots = { env: readExecution === undefined ? undefined : snapshotOf(row.get("env")), secretEnv: readExecution === undefined ? undefined : snapshotOf(row.get("secretEnv")) };
333
+ const laneOld = readExecution?.has("lane") === true;
334
+ const memoryTidb = readMemory?.get("backend") === "tidb";
335
+ const lateKeysAt = (slot) => {
336
+ const read = readSlots[slot];
337
+ return read === undefined ? [] : SS_M12_ENV_KEYS.filter((k) => read.has(k));
338
+ };
256
339
  const late = { env: lateKeysAt("env"), secretEnv: lateKeysAt("secretEnv") };
257
340
  if (!laneOld && !memoryTidb && late.env.length + late.secretEnv.length === 0)
258
341
  return { kind: "unchanged" };
259
- if (laneOld && has(rawExecution, "lanes")) {
342
+ if (laneOld && readExecution?.has("lanes") === true) {
260
343
  return refuse(["runtime", "execution", "lane"], "declares runtime.execution.lane (the 15.x single lane) AND runtime.execution.lanes (the 16.0.0 lane set) — keep one form; the migration does not pick a winner");
261
344
  }
262
- const working = captureJson(row);
345
+ // 铸回:读过的容器由各自的读数铸(没读到的键不进 `replace`),别的成员原样挂着由下面这一拍第一次读
346
+ const mintedKids = (kids) => new Map(Object.entries(kids).filter(([, v]) => v !== undefined));
347
+ const again = (read, kids = {}) => (read === undefined ? undefined : objectFrom(read, mintedKids(kids)));
348
+ const whole = objectFrom(row, mintedKids({
349
+ runtime: again(readRuntime, { execution: again(readExecution), store: again(readStore, { memory: again(readMemory) }) }),
350
+ env: again(readSlots.env),
351
+ secretEnv: again(readSlots.secretEnv),
352
+ }));
353
+ const working = captureJson(whole);
263
354
  if (!working.ok)
264
355
  throw new UninspectableError(working.sentence);
265
356
  const w = working.value;
@@ -323,19 +414,19 @@ function migrateWorkerRow15(row) {
323
414
  * · 读得进 ⇒ 写回寻常对象(工作副本隔离原型,只是副本),逐字段收据。
324
415
  */
325
416
  function stepWorkersRows(out, receipts) {
326
- const doc = ownOrThrow(out, "workers");
327
- if (!isPlainJsonObject(doc))
417
+ const doc = snapshotOf(ownOrThrow(out, "workers"));
418
+ if (doc === undefined)
328
419
  return;
329
- const workerRows = ownOrThrow(doc, "workers");
330
- if (!isJsonArray(workerRows))
420
+ const rows = rowsOf(doc.get("workers")); // 每一行只读一次:判与写回用同一份读数(拒的行原样就是这一份)
421
+ if (rows === undefined)
331
422
  return;
332
- const rows = rowsByIndex(workerRows); // 每一行只读一次:判与写回用同一份读数(拒的行原样就是这一份)
333
423
  let next;
334
424
  rows.forEach((row, index) => {
335
- if (!isPlainJsonObject(row) || typeof ownOrThrow(row, "name") !== "string")
425
+ const entry = snapshotOf(row);
426
+ if (entry === undefined || typeof entry.get("name") !== "string")
336
427
  return; // 认不出名字:整域读侧判
337
428
  const at = (path) => ["workers", index, ...path];
338
- const r12 = migrateWorkerRow15(row);
429
+ const r12 = migrateWorkerRow15(entry);
339
430
  if (r12.kind === "refused") {
340
431
  receipts.push(refused("SS-M12", "workers", at(r12.field), r12.reason));
341
432
  return;
@@ -356,7 +447,7 @@ function stepWorkersRows(out, receipts) {
356
447
  receipts.push(c.appliedAs === "moved" ? moved("SS-M12", "workers", at(c.path), { document: "workers", path: at(c.to) }) : receipt("SS-M12", "workers", at(c.path), c.appliedAs));
357
448
  });
358
449
  if (next !== undefined)
359
- out.workers = { ...doc, workers: next };
450
+ out.workers = objectFrom(doc, new Map([["workers", next]]));
360
451
  }
361
452
  // ── SS-M13:mcp 条目的两只惰性键与退役的断言头 ──────────────────────────────────────────────────────────────────
362
453
  /** SS-M13 拒一条带 `assertionHeader` 的 http 条目时的理由句(点名新位与连接器 id 的出处;不回显值)。 */
@@ -368,36 +459,140 @@ const SS_M13_INERT_KEYS = ["authForm", "entryKind"];
368
459
  * SS-M13(只认形):`mcp.servers[]` 逐条 ——
369
460
  * · http 条目的传输带 `assertionHeader`(自有键,任何值)⇒ 一张拒收据(坐标 = 那把键),**整条原样**(同一条上的惰性键也不动:拒的行什么都不写);
370
461
  * · 否则条目上的 `authForm` / `entryKind` ⇒ 删掉,每键一张 `dropped-inert` 收据。
371
- * 认不出的形(`mcp` 不是对象、`servers` 不是数组、条目不是对象)⇒ 不动(判形是读者的事)。
462
+ * 认不出的形(`mcp` 不是对象、`servers` 不是数组或有洞、条目不是对象)⇒ 不动(判形是读者的事);读不出 ⇒ 抛。读法见文件头「读法」:文档、每一条、每一条的传输各读一次,改了的条目由读数铸(不经 `[[Get]]`、不改入参)。
372
463
  */
373
464
  function stepMcpServers(out, receipts) {
374
- const doc = ownOrThrow(out, "mcp");
375
- if (!isPlainJsonObject(doc))
465
+ const doc = snapshotOf(ownOrThrow(out, "mcp"));
466
+ if (doc === undefined)
376
467
  return;
377
- const servers = ownOrThrow(doc, "servers");
378
- if (!isJsonArray(servers))
468
+ const rows = rowsOf(doc.get("servers")); // 每一条只读一次:判与写回用同一份读数(拒的那条原样就是这一份)
469
+ if (rows === undefined)
379
470
  return;
380
- const rows = rowsByIndex(servers); // 每一条只读一次:判与写回用同一份读数(拒的那条原样就是这一份)
381
471
  let next;
382
472
  rows.forEach((row, index) => {
383
- if (!isPlainJsonObject(row))
473
+ const entry = snapshotOf(row);
474
+ if (entry === undefined)
384
475
  return;
385
- const transport = ownOrThrow(row, "transport");
386
- if (isPlainJsonObject(transport) && ownOrThrow(transport, "kind") === "http" && has(transport, "assertionHeader")) {
476
+ const transport = snapshotOf(entry.get("transport"));
477
+ if (transport !== undefined && transport.get("kind") === "http" && transport.has("assertionHeader")) {
387
478
  receipts.push(refused("SS-M13", "mcp", ["servers", index, "transport", "assertionHeader"], SS_M13_ASSERTION_HEADER_REFUSAL));
388
479
  return;
389
480
  }
390
- const inert = SS_M13_INERT_KEYS.filter((k) => has(row, k));
481
+ const inert = SS_M13_INERT_KEYS.filter((k) => entry.has(k));
391
482
  if (inert.length === 0)
392
483
  return;
393
- let rewritten = row;
394
- for (const k of inert) {
395
- rewritten = without(rewritten, k);
484
+ const dropped = new Set(inert);
485
+ for (const k of inert)
396
486
  receipts.push(receipt("SS-M13", "mcp", ["servers", index, k], "dropped-inert"));
397
- }
398
487
  next ??= [...rows];
399
- next[index] = rewritten;
488
+ next[index] = objectFrom(new Map([...entry].filter(([k]) => !dropped.has(k))));
400
489
  });
401
490
  if (next !== undefined)
402
- out.mcp = { ...doc, servers: next };
491
+ out.mcp = objectFrom(doc, new Map([["servers", next]]));
492
+ }
493
+ // ── SS-M14:entitlement 能力位座上 32.0.0 删去的两只旧键 ─────────────────────────────────────────────────────────
494
+ /** SS-M14 认的两只旧键,与拒位折进去的那一只现行键。 */
495
+ const SS_M14_AUTO = "allowAutoMode";
496
+ const SS_M14_ULTRACODE = "allowUltracode";
497
+ const SS_M14_INTO = "autoMode";
498
+ /** SS-M14 拒一只座时的理由句(逐键;不回显值)。只认形:31.x 自己就读不进的值,迁移不猜它的意思。 */
499
+ const SS_M14_REFUSALS = {
500
+ [SS_M14_AUTO]: "allowAutoMode is not a boolean — 31.x could not read this runtimeCaps either, and the migration does not guess what it meant: write autoMode " +
501
+ "by hand (false = the org denies auto mode) and delete allowAutoMode",
502
+ [SS_M14_ULTRACODE]: "allowUltracode is not a boolean — 31.x could not read this runtimeCaps either: delete allowUltracode by hand (no consumer ever enforced it)",
503
+ [SS_M14_INTO]: "autoMode is not a boolean on a runtimeCaps that still carries an old key — 31.x could not read it either, and the fold would overwrite a " +
504
+ "value it cannot read: write autoMode by hand (true / false) and delete the old keys",
505
+ };
506
+ /** 31.x 读一格能力位的形(`z.boolean().optional()`):布尔或缺席(`undefined` 只有 JS 调用方给得出,JSON 带不了)读得进;别的 31.x 也读不进。 */
507
+ const readableIn31 = (v) => v === undefined || typeof v === "boolean";
508
+ /**
509
+ * 一只能力位座的折法(规则见登记表 SS-M14 行;唯一一份),只看这只座的一次读数:`allowAutoMode: false` ⇒ `autoMode: false`(拒胜)· `allowAutoMode: true` ⇒ 删 ·
510
+ * `allowUltracode` ⇒ 删。新座是寻常对象、原序;`autoMode` 落在 `allowAutoMode` 原来的位置上,座上已有就留在它自己的位置。
511
+ */
512
+ function foldRetiredCaps(caps) {
513
+ const hasAuto = caps.has(SS_M14_AUTO);
514
+ const hasUltracode = caps.has(SS_M14_ULTRACODE);
515
+ if (!hasAuto && !hasUltracode)
516
+ return { kind: "unchanged" };
517
+ const unreadable = [SS_M14_AUTO, SS_M14_ULTRACODE, SS_M14_INTO].filter((k) => caps.has(k) && !readableIn31(caps.get(k)));
518
+ if (unreadable.length > 0)
519
+ return { kind: "refused", keys: unreadable };
520
+ const deny = caps.get(SS_M14_AUTO) === false;
521
+ const hasInto = caps.has(SS_M14_INTO);
522
+ const next = {};
523
+ for (const [k, v] of caps) {
524
+ if (k === SS_M14_AUTO) {
525
+ if (deny && !hasInto)
526
+ Object.defineProperty(next, SS_M14_INTO, dataDescriptor(false));
527
+ continue;
528
+ }
529
+ if (k === SS_M14_ULTRACODE)
530
+ continue;
531
+ Object.defineProperty(next, k, dataDescriptor(k === SS_M14_INTO && deny ? false : v));
532
+ }
533
+ const changes = [];
534
+ if (hasAuto)
535
+ changes.push({ key: SS_M14_AUTO, appliedAs: deny ? "moved" : "dropped-inert" });
536
+ if (hasUltracode)
537
+ changes.push({ key: SS_M14_ULTRACODE, appliedAs: "dropped-inert" });
538
+ return { kind: "rewritten", caps: next, changes };
539
+ }
540
+ /**
541
+ * SS-M14(只认形):`entitlement` 文档里存着的两只能力位座 —— `defaults.runtimeCaps` 与每一个 `tiers[].runtimeCaps` —— 各折一次,每个旧键一张收据
542
+ * (`moved` 到 `autoMode` / `dropped-inert`);拒的座一张拒收据一只键、整只座原样。没改的档与没改的文档同一引用;改了的由各层的一次读数铸新对象(不经 `[[Get]]`、不改入参)。
543
+ * 认不出的形(文档不是对象、`tiers` 不是数组或有洞、档或座不是对象)⇒ 不动(判形是读者的事);读不出 ⇒ 抛。caps wire 不在这里:它是按这两座铸出来的体,没有存储形。
544
+ */
545
+ function stepEntitlementRuntimeCaps(out, receipts) {
546
+ const doc = snapshotOf(ownOrThrow(out, "entitlement"));
547
+ if (doc === undefined)
548
+ return;
549
+ /** 折一只座、出收据;改了 ⇒ 新座,没改 / 拒 ⇒ `undefined`。 */
550
+ const seat = (value, at) => {
551
+ const caps = snapshotOf(value);
552
+ if (caps === undefined)
553
+ return undefined;
554
+ const r = foldRetiredCaps(caps);
555
+ switch (r.kind) {
556
+ case "unchanged":
557
+ return undefined;
558
+ case "refused":
559
+ for (const k of r.keys)
560
+ receipts.push(refused("SS-M14", "entitlement", [...at, k], SS_M14_REFUSALS[k]));
561
+ return undefined;
562
+ case "rewritten":
563
+ for (const c of r.changes) {
564
+ receipts.push(c.appliedAs === "moved" ? moved("SS-M14", "entitlement", [...at, c.key], { document: "entitlement", path: [...at, SS_M14_INTO] }) : receipt("SS-M14", "entitlement", [...at, c.key], c.appliedAs));
565
+ }
566
+ return r.caps;
567
+ default: {
568
+ const unhandled = r;
569
+ throw new Error(`SS-M14: unhandled outcome ${String(unhandled.kind)}`);
570
+ }
571
+ }
572
+ };
573
+ const changed = new Map();
574
+ const defaults = snapshotOf(doc.get("defaults"));
575
+ if (defaults !== undefined) {
576
+ const caps = seat(defaults.get("runtimeCaps"), ["defaults", "runtimeCaps"]);
577
+ if (caps !== undefined)
578
+ changed.set("defaults", objectFrom(defaults, new Map([["runtimeCaps", caps]])));
579
+ }
580
+ const rows = rowsOf(doc.get("tiers")); // 每一档只读一次:判与写回用同一份读数
581
+ if (rows !== undefined) {
582
+ let next;
583
+ rows.forEach((row, index) => {
584
+ const tier = snapshotOf(row);
585
+ if (tier === undefined)
586
+ return;
587
+ const caps = seat(tier.get("runtimeCaps"), ["tiers", index, "runtimeCaps"]);
588
+ if (caps === undefined)
589
+ return;
590
+ next ??= [...rows];
591
+ next[index] = objectFrom(tier, new Map([["runtimeCaps", caps]]));
592
+ });
593
+ if (next !== undefined)
594
+ changed.set("tiers", next);
595
+ }
596
+ if (changed.size > 0)
597
+ out.entitlement = objectFrom(doc, changed);
403
598
  }
@@ -5,17 +5,15 @@
5
5
  * 原型是**那个 realm** 的 `Object.prototype`,按恒等判会被读成非朴素;而任何 realm 的 `Object.prototype` 自身原型都是 `null`,所以链上第二环是 `null` 这一条与 realm 无关,不需要为 realm 加特例。包里凡要问「这个值是不是一个 JSON 对象」的地方都读它,不各写一份:读域文档的键集对比(`./config-fns`)、一次性迁移的文档形判
6
6
  * (`./one-time-migrations`)、`config.d` 文档形(`./config-d-file`)、`extraBody` 的形闸与秘密走查(`./types`)、settings 单元读法与严格 JSON 深度判(`./settings-units` / `./safety-merge-spec`)、
7
7
  * 请求面传输的记录读法与描述件(`./mcp-request-entry`)、workers 行读口(`./workers-rows`)、有效配置线上载荷读口(`./config-fns` 的 `readEffectiveWire`)、http hook 名单的设置袋(`./http-hook-allowlists`)、
8
- * fleet 线上载荷的受护判(`./fleet`)、符合性语料的比较器 / 派生 / 语料读口 / 元数据拆分(`./conformance/*`)。零 import。
9
- * **形状分类核 {@link jsonShapeOf} 是座位的本体**,`isPlainJsonObject` 由它派生(`plain` 那一格);本模块里读原型的只有它与安全轴的朴素数组判据 {@link isPlainJsonArray}(全包另有两处读原型,见下)。**总(不抛)**:检视就抛的对象(已撤销的 Proxy、`getPrototypeOf` 陷阱抛)
8
+ * fleet 线上载荷的受护判(`./fleet`)、符合性语料的比较器 / 派生 / 语料读口 / 元数据拆分(`./conformance/*`)、hooks 分类器(`./hooks-config`:闭包经登记名读本模块的三只 ——
9
+ * `jsonShapeOf` / `isPlainJsonObject` / `isJsonArray`;抄走分类器的消费方把本模块在旁边抄一份,不在分类器里另写)。零 import。
10
+ * **形状分类核 {@link jsonShapeOf} 是座位的本体**,`isPlainJsonObject` 由它派生(`plain` 那一格);本模块里读原型的只有它与安全轴的朴素数组判据 {@link isPlainJsonArray}(全包另有一处读原型,见下)。**总(不抛)**:检视就抛的对象(已撤销的 Proxy、`getPrototypeOf` 陷阱抛)
10
11
  * 核答 `uninspectable`、判官答 `false`,不抛出去 —— 全包经座位的读口因此拒而不抛,律在座位上收一处,不在每个读器各包一个 `try`;读者对 `uninspectable` 一律按最严处置(hooks ⇒ 拒整份文档;名单 ⇒ `malformed`;传输 ⇒ 整只不交)。
11
12
  *
12
- * **形状判的第二处是 `./hooks-config` 的 `hookShapeOf` / `hookIsRecord`,与 {@link jsonShapeOf} / 本函数逐字同文(调用名归一后)**:hooks 分类器的闭包要被消费方生成器整函数抄走(闭包除内建外只读登记名,本模块的函数不在其中),闭包里不能 import 本模块 ——
13
- * 同文由 `test/plain-json-object-single-seat-14.6.0.test.ts` 逐字证明(漂开即红),闭包契约多注入一个名字时(S-2133)把它并回这里
14
- * (31.0.0 起闭包已多注入三只登记名 —— 插件列的三样判法 —— S-2133 的触发条件已到,收口本身另车)。
15
- * **第三处是包内冻结助手 `./deep-freeze` 的 `freezeGraph`**:它也问「是不是数组」「原型是什么」,但它只接触包自己的闭集常量(不读嵌入方传来的值),判「朴素对象」用的是原型恒等 `Object.prototype`(或 `null`),
13
+ * **另一处读原型是包内冻结助手 `./deep-freeze` 的 `freezeGraph`**:它也问「是不是数组」「原型是什么」,但它只接触包自己的闭集常量(不读嵌入方传来的值),判「朴素对象」用的是原型恒等 `Object.prototype`(或 `null`),
16
14
  * 与本模块的判法(原型是 `null`,或原型自己的原型是 `null`)不同 —— 它不是本模块的副本,没有「同文」的要求。助手保持零 import 是一个选择(叶性钉与消费方抄本组不必跟着变),不是做不到:本模块自己零 import,引它不成环。
17
15
  * 两种「朴素对象」读法收成一种是后续的设计事项,这条注释不改判据。
18
- * 同一个门也数全包:返回类型是 `x is Record<string, unknown>` 的函数,除本模块与 `./hooks-config` 那一份这两处之外一处不许有;读原型的调用点,除这两处与冻结助手一处之外一处不许有;内联的「typeof 对象 ∧ 非 null ∧ 非数组」合取则**一处都不许有**(座位里它是分开的 `if` 臂,不是合取)。
16
+ * 同一个门也数全包:返回类型是 `x is Record<string, unknown>` 的函数,除本模块之外一处不许有;读原型的调用点,除本模块与冻结助手一处之外一处不许有;内联的「typeof 对象 ∧ 非 null ∧ 非数组」合取则**一处都不许有**(座位里它是分开的 `if` 臂,不是合取)。
19
17
  *
20
18
  * **读者要的答案不只是「是不是朴素对象」时,调本模块的 {@link jsonShapeOf}**(六词形状分类),不在读者里再推一遍形状:例如托管层的 http hook 名单,非朴素的**对象**袋必须 fail-closed(读成空名单并告警),
21
19
  * 而 `null` / 原始值 / 数组仍是「整份设置不是对象 ⇒ 两键都缺」—— 两种不同的答案,只能由形状分类给。`isPlainJsonObject` 就是 `jsonShapeOf` 的「朴素」那一格。
@@ -30,7 +28,6 @@ export type JsonShape = ReturnType<typeof jsonShapeOf>;
30
28
  export declare function jsonShapeOf(v: unknown): "plain" | "non_plain_object" | "array" | "null" | "primitive" | "uninspectable";
31
29
  /**
32
30
  * `Array.isArray` 的**总**版(不抛):已撤销的 Proxy 连「是不是数组」都读不出 ⇒ 不是数组。读者要问「这个值是不是数组」且值可能来自嵌入方(非 JSON)时调它,不直接 `Array.isArray`。
33
- * 分类器闭包里不能 import,`./hooks-config` 的 `hookIsArray` 与本函数**逐字同文**(同一个门证明,与 `hookIsRecord` 同律)。
34
31
  */
35
32
  export declare function isJsonArray(v: unknown): v is unknown[];
36
33
  /**
@@ -5,17 +5,15 @@
5
5
  * 原型是**那个 realm** 的 `Object.prototype`,按恒等判会被读成非朴素;而任何 realm 的 `Object.prototype` 自身原型都是 `null`,所以链上第二环是 `null` 这一条与 realm 无关,不需要为 realm 加特例。包里凡要问「这个值是不是一个 JSON 对象」的地方都读它,不各写一份:读域文档的键集对比(`./config-fns`)、一次性迁移的文档形判
6
6
  * (`./one-time-migrations`)、`config.d` 文档形(`./config-d-file`)、`extraBody` 的形闸与秘密走查(`./types`)、settings 单元读法与严格 JSON 深度判(`./settings-units` / `./safety-merge-spec`)、
7
7
  * 请求面传输的记录读法与描述件(`./mcp-request-entry`)、workers 行读口(`./workers-rows`)、有效配置线上载荷读口(`./config-fns` 的 `readEffectiveWire`)、http hook 名单的设置袋(`./http-hook-allowlists`)、
8
- * fleet 线上载荷的受护判(`./fleet`)、符合性语料的比较器 / 派生 / 语料读口 / 元数据拆分(`./conformance/*`)。零 import。
9
- * **形状分类核 {@link jsonShapeOf} 是座位的本体**,`isPlainJsonObject` 由它派生(`plain` 那一格);本模块里读原型的只有它与安全轴的朴素数组判据 {@link isPlainJsonArray}(全包另有两处读原型,见下)。**总(不抛)**:检视就抛的对象(已撤销的 Proxy、`getPrototypeOf` 陷阱抛)
8
+ * fleet 线上载荷的受护判(`./fleet`)、符合性语料的比较器 / 派生 / 语料读口 / 元数据拆分(`./conformance/*`)、hooks 分类器(`./hooks-config`:闭包经登记名读本模块的三只 ——
9
+ * `jsonShapeOf` / `isPlainJsonObject` / `isJsonArray`;抄走分类器的消费方把本模块在旁边抄一份,不在分类器里另写)。零 import。
10
+ * **形状分类核 {@link jsonShapeOf} 是座位的本体**,`isPlainJsonObject` 由它派生(`plain` 那一格);本模块里读原型的只有它与安全轴的朴素数组判据 {@link isPlainJsonArray}(全包另有一处读原型,见下)。**总(不抛)**:检视就抛的对象(已撤销的 Proxy、`getPrototypeOf` 陷阱抛)
10
11
  * 核答 `uninspectable`、判官答 `false`,不抛出去 —— 全包经座位的读口因此拒而不抛,律在座位上收一处,不在每个读器各包一个 `try`;读者对 `uninspectable` 一律按最严处置(hooks ⇒ 拒整份文档;名单 ⇒ `malformed`;传输 ⇒ 整只不交)。
11
12
  *
12
- * **形状判的第二处是 `./hooks-config` 的 `hookShapeOf` / `hookIsRecord`,与 {@link jsonShapeOf} / 本函数逐字同文(调用名归一后)**:hooks 分类器的闭包要被消费方生成器整函数抄走(闭包除内建外只读登记名,本模块的函数不在其中),闭包里不能 import 本模块 ——
13
- * 同文由 `test/plain-json-object-single-seat-14.6.0.test.ts` 逐字证明(漂开即红),闭包契约多注入一个名字时(S-2133)把它并回这里
14
- * (31.0.0 起闭包已多注入三只登记名 —— 插件列的三样判法 —— S-2133 的触发条件已到,收口本身另车)。
15
- * **第三处是包内冻结助手 `./deep-freeze` 的 `freezeGraph`**:它也问「是不是数组」「原型是什么」,但它只接触包自己的闭集常量(不读嵌入方传来的值),判「朴素对象」用的是原型恒等 `Object.prototype`(或 `null`),
13
+ * **另一处读原型是包内冻结助手 `./deep-freeze` 的 `freezeGraph`**:它也问「是不是数组」「原型是什么」,但它只接触包自己的闭集常量(不读嵌入方传来的值),判「朴素对象」用的是原型恒等 `Object.prototype`(或 `null`),
16
14
  * 与本模块的判法(原型是 `null`,或原型自己的原型是 `null`)不同 —— 它不是本模块的副本,没有「同文」的要求。助手保持零 import 是一个选择(叶性钉与消费方抄本组不必跟着变),不是做不到:本模块自己零 import,引它不成环。
17
15
  * 两种「朴素对象」读法收成一种是后续的设计事项,这条注释不改判据。
18
- * 同一个门也数全包:返回类型是 `x is Record<string, unknown>` 的函数,除本模块与 `./hooks-config` 那一份这两处之外一处不许有;读原型的调用点,除这两处与冻结助手一处之外一处不许有;内联的「typeof 对象 ∧ 非 null ∧ 非数组」合取则**一处都不许有**(座位里它是分开的 `if` 臂,不是合取)。
16
+ * 同一个门也数全包:返回类型是 `x is Record<string, unknown>` 的函数,除本模块之外一处不许有;读原型的调用点,除本模块与冻结助手一处之外一处不许有;内联的「typeof 对象 ∧ 非 null ∧ 非数组」合取则**一处都不许有**(座位里它是分开的 `if` 臂,不是合取)。
19
17
  *
20
18
  * **读者要的答案不只是「是不是朴素对象」时,调本模块的 {@link jsonShapeOf}**(六词形状分类),不在读者里再推一遍形状:例如托管层的 http hook 名单,非朴素的**对象**袋必须 fail-closed(读成空名单并告警),
21
19
  * 而 `null` / 原始值 / 数组仍是「整份设置不是对象 ⇒ 两键都缺」—— 两种不同的答案,只能由形状分类给。`isPlainJsonObject` 就是 `jsonShapeOf` 的「朴素」那一格。
@@ -44,7 +42,6 @@ export function jsonShapeOf(v) {
44
42
  }
45
43
  /**
46
44
  * `Array.isArray` 的**总**版(不抛):已撤销的 Proxy 连「是不是数组」都读不出 ⇒ 不是数组。读者要问「这个值是不是数组」且值可能来自嵌入方(非 JSON)时调它,不直接 `Array.isArray`。
47
- * 分类器闭包里不能 import,`./hooks-config` 的 `hookIsArray` 与本函数**逐字同文**(同一个门证明,与 `hookIsRecord` 同律)。
48
45
  */
49
46
  export function isJsonArray(v) {
50
47
  try {
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 包内私有(不进 `package.json` 的 exports、不进主桶):**记录座位**的唯一铸法 —— 包里每一只「名 → 值」记录(zod 的 `record` / `partialRecord`)都由这里的
3
+ * {@link recordOf} / {@link partialRecordOf} 铸出;`src/` 别处不许出现记录构造(源码门:test 的 record-seat-single-site,按检查器解析符号数,不按行匹配)。
4
+ *
5
+ * 律(一条):记录的成员按**自有属性名**读 —— 名字是保留成员名({@link RESERVED_MEMBER_NAMES},一张表,记录读器与中心引用解析口问同一个谓词)⇒ 这只座位拒。
6
+ * 一个名一条 custom issue,路径停在记录本身:句子是记录读器那一句({@link reservedMemberSentence}),机读词 `params.flaw` = `member_name_reserved`
7
+ * (记录读器的原因词表里那一只,不新铸)。为什么要在 zod 之前读:zod 的 record 读键前先跳过自有键 `__proto__`(键不判、值不判、输出里没有它、不报 issue)——
8
+ * 只靠 record 判,一份带它的文档被读成「没有这一键」:键形门不触发、值 schema 不跑(密钥字面值扫描、授权值的严判),读 parse 结果的消费方看不见它。
9
+ * `constructor` / `prototype` zod 照常判、照常带出,与凭据引用集合、记录读器同表同拒:一只守卫,一个名单。
10
+ * 成员不是纯数据或读不出(不可枚举的自有串键 / 访问器 / 陷阱抛)⇒ 同样判坏,句子是内核那一句(fail-closed:守卫看不清就不担保,也不调 getter);
11
+ * 是对象却不是本包认的朴素对象(原型链更深、类实例、读形状就抛)⇒ 拒(zod 的记录按另一套判法收下其中一部分 —— 守卫让路就是让它在没读过名字的对象上跳过 `__proto__`);
12
+ * `null` / 数组 / 原始值 ⇒ 原样交给 record,拒句不变。
13
+ * 守卫有一条就使这只座位判不过:管道在输入侧停住,record 与挂在座位上的检查都不再跑(一条结论,不叠第二条)。
14
+ * 边界(如实):守卫读的是**输入**键 —— 键 schema 若改写键(`.trim()` 一类),改写后才成为 `__proto__` 的键仍被 zod 跳过;所以记录座位的键 schema 不许改写键(今天 23 座都不改写)。
15
+ *
16
+ * 同一条律的另三处读者:能当记录键的名字的判官(worker 名、目录条目名、HTTP 头名都从 {@link RECORD_MEMBER_NAME} 起步:名字在建的那一刻就拒,与以它作键的座位同答)·
17
+ * 逐条抢救的键判(config-fns 的 `judgeKey` 先问 {@link RECORD_MEMBER_NAME}:Record 条目集合里名叫保留名的那一格整条丢,与座位同答)·
18
+ * 按声明键投影的校验(`./declared-capture` 的白名单门按守卫函数的**身份**认座位 —— {@link isRecordSeat} —— 放行到里面的 record:守卫只读自有名,
19
+ * 那里交给校验器的深拷副本保留自有 `__proto__`、拒隐藏 / 访问器成员,两边同答)。
20
+ */
21
+ import { z } from "zod";
22
+ /** 一只记录座位:键 schema × 值 schema(与 zod 的 `record` 同参;`params` 原样交给它)。 */
23
+ export declare function recordOf<K extends z.core.$ZodRecordKey, V extends z.core.SomeType>(key: K, value: V, params?: string | z.core.$ZodRecordParams): z.ZodPreprocess<z.ZodRecord<K, V>, z.core.$InferZodRecordInput<K, V>>;
24
+ /** 一只键可缺席的记录座位(枚举键:写哪个键就是哪个键,其余缺席;与 zod 的 `partialRecord` 同参)。 */
25
+ export declare function partialRecordOf<K extends z.core.$ZodRecordKey, V extends z.core.SomeType>(key: K, value: V, params?: string | z.core.$ZodRecordParams): z.ZodPreprocess<z.ZodRecord<K & z.core.$partial, V>, z.core.$InferZodRecordInput<K & z.core.$partial, V>>;
26
+ /** 这只 schema 是不是记录座位:输入侧恰是座位守卫本身(按函数的**身份**认,且输入侧没有挂别的检查 —— 挂上去的检查能看见调用方的值)、出侧是 record。
27
+ * 别的输入侧变换、守卫外面再挂检查的管道、出侧不是 record 的管道,都不是座位。 */
28
+ export declare function isRecordSeat(schema: unknown): boolean;
29
+ /**
30
+ * 记录成员名的判官:保留名 ⇒ 与座位守卫同一条 issue,且是这一判的唯一结论(issue 不续:后面挂的形状判不再跑,不叠第二条)。
31
+ * 两种读者,同一只:逐条抢救的键判先问它,再问记录自己的键 schema;**能当记录键的名字**的判官从它起步(`RECORD_MEMBER_NAME.min(1).regex(…)`)——
32
+ * worker 名、目录条目名、HTTP 头名:名字在建的那一刻就拒,不会建得出、到了以它作键的座位才被拒。座位 × 键判官的对齐由 test 的
33
+ * record-seat-key-judges 两向核(座位表 = 普查到的座位;每只键判官读这里)。
34
+ */
35
+ export declare const RECORD_MEMBER_NAME: z.ZodString;