@sema-agent/settings-schema 22.0.0 → 24.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.
@@ -23,7 +23,7 @@ import { isJsonArray, isPlainJsonObject, jsonShapeOf } from "./plain-json-object
23
23
  import { carriesUserinfo, secretScanForms } from "./secret-scan.js"; // package-private normalization (both scanners read it) + the userinfo judgement (not in the barrel)
24
24
  import { sha256Hex } from "./sha256.js";
25
25
  import { unwrapSchema } from "./zod-unwrap.js"; // package-private: the ONE reading of zod's wrapper layers (salvage + the one-time migrations share it)
26
- import { ATOMIC_SALVAGE, DOMAIN_SCHEMAS, InfraCostRates, LimitsConfig, PRIVATE_KEY_PEM_HEADER, RETIRED_DOMAINS, SkillsManifestSchema, WIRE_CARRIED_DOMAINS, containsSecretToken, isDomainName, isRetiredDomainName, renderQuotedSentence, retiredDomainSentence } from "./types.js";
26
+ import { DOMAIN_SCHEMAS, InfraCostRates, LimitsConfig, PRIVATE_KEY_PEM_HEADER, RETIRED_DOMAINS, SkillsManifestSchema, WIRE_CARRIED_DOMAINS, containsSecretToken, isDomainName, isRetiredDomainName, renderQuotedSentence, retiredDomainSentence } from "./types.js";
27
27
  /** Redact secret-shaped tokens from a validation MESSAGE — a zod error echoes the offending value (e.g.
28
28
  * `received 'sk-live-…'`), so a secret pasted into the WRONG field would leak via the error string. Redacts
29
29
  * space-spanning auth credentials (`Bearer <token>`) FIRST (the token pass can't see across the space), then
@@ -239,24 +239,30 @@ export function refuseRetiredDomain(domain, raw) {
239
239
  if (carriesFacts(raw))
240
240
  throw new RetiredDomainError(domain);
241
241
  }
242
- /** Validate + fill defaults for a domain payload (or the schema's empty default when absent/invalid). */
243
- export function parseDomain(domain, raw) {
244
- // A retired domain is refused by its tombstone (one sentence naming the one-time migration), not as "not a domain":
245
- // a writer still submitting it needs to know where its keys went.
242
+ /**
243
+ * 「这个名字判哪张 schema」只有这一只判官 —— 文档面({@link parseDomain})与视图面({@link domainSeat})共用,两面对同一个名字说同一句话。
244
+ * A retired domain is refused by its tombstone (one sentence naming the one-time migration), not as "not a domain":
245
+ * a writer still submitting it needs to know where its keys went. A name that is not a domain is refused for what it is —
246
+ * before, `DOMAIN_SCHEMAS[name]` was undefined and the TypeError surfaced through the read guard as "a value could not be
247
+ * read", which names the wrong failure. The strict-write face hands {@link parseDomain} every key of a submitted document
248
+ * set, so the name is user text: it leaves through the same outgoing redaction as a warning coordinate segment.
249
+ */
250
+ function domainSchemaOf(domain) {
246
251
  if (isRetiredDomainName(domain))
247
252
  throw new RetiredDomainError(domain);
248
- // A name that is not a domain is refused for what it is — before, `DOMAIN_SCHEMAS[name]` was undefined and the
249
- // TypeError surfaced through the guard below as "a value could not be read", which names the wrong failure. The
250
- // strict-write face hands this function every key of a submitted document set, so the name is user text: it leaves
251
- // through the same outgoing redaction as a warning coordinate segment.
252
253
  if (!isDomainName(domain))
253
254
  throw new Error(`"${outgoingSegment(String(domain))}" is not a config domain`);
255
+ return DOMAIN_SCHEMAS[domain];
256
+ }
257
+ /** Validate + fill defaults for a domain payload (or the schema's empty default when absent/invalid). */
258
+ export function parseDomain(domain, raw) {
259
+ const schema = domainSchemaOf(domain);
254
260
  // ONLY true absence (undefined) defaults; an explicit `null` (e.g. a `config.d/<d>.json` containing JSON
255
261
  // `null`) is corrupt input → let zod reject it ("expected object, received null"), not silently default. R4.
256
- return strictParse(DOMAIN_SCHEMAS[domain], domain, raw === undefined ? emptyDocument() : raw);
262
+ return strictParse(schema, domain, raw === undefined ? emptyDocument() : raw);
257
263
  }
258
264
  /**
259
- * 一次**整份严判**(域文档与 wire 上的 skills 清单共用这一只 —— 清单的读法与非门控域同一臂,见 `readSkillsManifest`):过 ⇒ 数据;
265
+ * 一次**整份严判**(域文档与 wire 上的 skills 清单共用这一只 —— 清单是 skills 域的线上形,读法与域文档同一只,见 {@link readViewOr}):过 ⇒ 数据;
260
266
  * 不过 ⇒ 抛脱敏后的 ZodError(逐字段递归脱敏,不回显秘密;R13/R14);校验过程抛(含首读 `error` 时抛,见 {@link guardedSafeParse})⇒ 抛 {@link unreadableDomainError}
261
267
  * (抛出值的文案可能带秘密,从不转述;R13)。
262
268
  */
@@ -439,7 +445,7 @@ function judgeKey(keySchema, key) {
439
445
  * 登记的键不算(按条目在域文档里的原文坐标 `from` 判 —— models 条目上壳写的 `sema*` 是契约,不是拼错)。有 ⇒ `entry-unknown-key`,`error` 是
440
446
  * zod 自己的 `.strict()` 会说的那种(每个持键层一条 `unrecognized_keys`,坐标相对条目,见 {@link strippedKeysError})。
441
447
  * 比键集的那一遍读原文时抛了(第二次读才抛的访问器)⇒ `entry-unreadable`:决策面不许把读不出当没看见。
442
- * 只在 {@link salvageEntries} 里调 —— 逐条丢弃只发生在视图面的逐条丢弃域(与 wire 上的 skills 清单);文档面与不逐条丢的域里,条目体内的
448
+ * 只在 {@link salvageEntries} 里调 —— 逐条丢弃只发生在视图面的逐条丢弃域;文档面与不逐条丢的域里,条目体内的
443
449
  * 未知键照旧剥键 + `unknown-keys-dropped`。 */
444
450
  function judgeEntry(element, entry, domain, from) {
445
451
  const judged = judgeAgainst(element, entry, "entry-schema-invalid");
@@ -457,19 +463,26 @@ function judgeEntry(element, entry, domain, from) {
457
463
  /**
458
464
  * 从**schema 自身**派生条目集合(数组字段 / Record 字段),逐条判,坏的丢掉并逐条记账。
459
465
  *
460
- * 入参是 **schema 而不是域名**:`skills` 在 wire 上不是域 schema 而是 manifest(`SkillsManifestSchema`),
461
- * 在 `buildEffective` 之外单独判 —— 只吃域名的抢救点会把那条腿漏在门外,同一份病只因为换了张 schema
462
- * 就没被覆盖。吃 schema ⇒ 域面与 wire 面共用同一条律,没有第二实现。
466
+ * **诊断口,不是读腿**:本函数不查 {@link DOMAIN_ENTRY_SALVAGE} / {@link DOMAIN_READ_FALLBACK} —— 它回答「这份文档里哪几条判不过、为什么」,
467
+ * 不回答「读方该怎么读」。读腿只在表判 `"salvage"` 的域里拿它的结果({@link readView});对 `"none"` 域直接调它照样逐条报。
468
+ * 把它的 `value` 当文档再交给读口,是调用方自己在 `"none"` 域丢了条目,读法没有这一步。
469
+ *
470
+ * 入参是 **schema 而不是域名**:同一个域可以有不止一种文档表示(`skills` 在 wire 上是 manifest,`SkillsManifestSchema`)——
471
+ * 只吃域名的抢救点会把另一种表示漏在门外。吃 schema ⇒ 每种表示同一条律,没有第二实现。
463
472
  *
464
473
  * 为什么从 schema 派生而不是写一张「域 → 条目字段」表:那张表是第二份真源,开新域必漏。schema 里
465
474
  * 「这个字段是一组条目」这件事本来就写着,读它即可 —— 新域天然被覆盖,零登记动作。
466
475
  *
476
+ * 🔴 **条目是对象,一张值名单是一个值**(24.0.0):条目集合 = 元素(数组元素 / Record 值)是对象(或全由对象组成的联合)的集合,见 {@link isEntrySchema}。
477
+ * 元素是串 / 数 / 枚举 / 字面量的集合 —— 工具名单(`allowTools` / `disallowedTools`)、范围名单(`scenarios` / `rosters`)、凭据引用(名 → env-NAME)—— 是
478
+ * 作者写下的**一个值**:不下钻、不逐元素剔。剔掉一个元素读出来的就不是作者写的那张名单(拒绝名单被截短 = 更松;凭据引用被截短 = 带着一半凭据去拨远端),
479
+ * 所以坏一个元素 ⇒ 持有它的那一条条目在上一层整条判不过、整条丢;在域顶层 ⇒ 没有可丢的条目,整域读不进。判据只读 schema 的形,不读名字、不登记身份。
480
+ *
467
481
  * 🔴 **零幸存者不算「部分损坏」**:一个集合如果所有条目都坏,那它不是「部分损坏的集合」,而是**整个坏掉
468
482
  * 的集合** —— 本函数对这种字段**一条都不丢**,原样留着让整域档位去裁。这条不是特判,是「抢救」的定义:
469
- * 没有要抢救的东西。它同时把一整类 fail-open 陷阱一次性挡住 —— 本 schema 里有若干字段**空 = 不设限**
470
- * (最典型的 `models.atModelAllowlist`:空/缺席 = 所有模型都可 @),把一份「全是坏值」的限制清单抢救成
471
- * 空数组,等于把运维的限制悄悄删了。这里不去枚举「哪些字段空了等于放权」(枚举必漏),而是**从不凭空
472
- * 造出一个空集合**。
483
+ * 没有要抢救的东西。它同时把一整类 fail-open 陷阱一次性挡住 —— 一个集合**空 = 不设限**时,把「全是坏条目」的集合抢救成
484
+ * 空集合,等于把运维的限制悄悄删了。这里不去枚举「哪些字段空了等于放权」(枚举必漏),而是**从不凭空造出一个空集合**。
485
+ * (「空 = 不设限」最常见的是值名单 —— 它们根本不被逐元素抢救,见上一条;零幸存者律守的是对象集合。)
473
486
  *
474
487
  * 🔴 **告警不许比它诊断的东西更危险**(复审 R1 两条,红先复现):① Record 的键是用户写的,完全可能就是
475
488
  * 一条粘错位置的凭据,所以路径里的键段过 {@link redactSecrets} 才出门(6.3.0 起经 `outgoingPath` 这一道;不变量①:secret 值永不随错误外流,
@@ -481,19 +494,19 @@ function judgeEntry(element, entry, domain, from) {
481
494
  * 没有任何域专用分支),再拿抢救后的那一条去判整条。体内丢的子条目以父坐标为前缀上账(`["projects", <id>, "contextItems", 1]`),
482
495
  * 体内压缩过的数组以全路径进位移表({@link EntryKeptIndex});整条最终仍判不过 ⇒ 整条丢,它体内的半路账一并作废(一条一个结论),
483
496
  * 记账行的判决取**原文**的(拒句坐标是原文档的,不是抢救形里压缩过的下标)。
484
- * 零幸存者律在**每一层**成立 —— 体内的集合全坏 ⇒ 不压成空集合,那一条照原样去判(于是整条丢):嵌套里同样有「空 = 不设限」的字段
485
- * (`skills[].scenarios` / `mcp.servers[].allowTools` …),抢救成 `[]` 就是把限定范围放成全开。账按文档序排(父条目丢在哪个位置,
497
+ * 零幸存者律在**每一层**成立 —— 体内的条目集合全坏 ⇒ 不压成空集合,那一条照原样去判(于是整条丢)。账按文档序排(父条目丢在哪个位置,
486
498
  * 体内的子条目就排在哪个位置)。
487
499
  *
488
500
  * **条目好坏只有一条判据**({@link judgeEntry};22.0.0):过它自己的 schema,**且体内没有键被剥**。带未知键的条目(拼错的收紧键、比本包新的
489
501
  * 写者写的前瞻键)是坏条目,与坏形条目同一条律处置 —— 丢它自己、`entry-dropped` 点名(词 `entry-unknown-key`)、零幸存者不丢、体内的嵌套集合先抢救。
490
502
  * 第三个参数 `domain` 说**哪个域的扩展命名空间生效**({@link EXTENSION_NAMESPACES}:models 条目上壳写的 `sema*` 不是未知键);必填 ——
491
- * 缺了就只能把壳写的每一条目录条目当带未知键丢掉,所以不是域名 ⇒ 响亮拒(TypeError),不替调用方猜。wire 上的 skills 清单传 `"skills"`。
503
+ * 缺了就只能把壳写的每一条目录条目当带未知键丢掉,所以不是域名 ⇒ 响亮拒(TypeError),不替调用方猜。
492
504
  *
493
505
  * 边界(如实登记):① 只下钻**条目**(集合的元素 / 值),不下钻顶层的普通对象字段(`models.atMention` 不是条目 —— 它里面的未知键不让任何条目丢,
494
506
  * 照旧剥键 + `unknown-keys-dropped`);② raw 不是纯 JSON 对象、字段值与 schema 形状对不上(schema 说数组、文档给对象)⇒ 原样返回,交给整域档位裁;
495
507
  * ③ 域级判据(重名 / 悬空 ref)不在本函数视野内 —— 丢条目救不了它们,调用方据此回落整域档位;
496
- * ④ 只认 `ZodArray` / `ZodRecord` 两种条目集合形 —— 别的形(元组等)不抢救,退回整域档位(保守方向);⑤ 递归深度止于 schema
508
+ * ④ 只认 `ZodArray` / `ZodRecord` 两种条目集合形、只认对象(与全由对象组成的联合)作条目 —— 别的形(元组、值名单、`z.lazy` 包着的元素等)
509
+ * 不抢救,退回上一层 / 整域档位(保守方向);⑤ 递归深度止于 schema
497
510
  * (本包没有自引用 schema);`z.lazy` 包着的 schema 不展开(`unwrapSchema` 不认它)⇒ 不下钻,那一条按原样判;⑥ 被剥键的扫描与告警面同一只
498
511
  * ({@link visitStripped}),同一个深度上界 —— 逐条丢弃域的 schema 里,能被剥键的那一层最深在第 6 段(collab 槽位成员),在上界之内。
499
512
  */
@@ -511,23 +524,31 @@ function salvageLayer(schema, raw, domain, origin) {
511
524
  return layer.ok ? layer.value : { raw, dropped: [], shifts: [] };
512
525
  }
513
526
  /** 「哪些字段是一组条目」的**唯一**派生(逐条抢救 {@link salvageLayerUnsafe} 与视图面判官 {@link entryHeldStrippedKeys} 同读这一只):
514
- * 根(拆掉包装层后)是对象 ⇒ 它的每个数组 / Record 字段;凭据引用集合(按 schema 身份,见 ATOMIC_SALVAGE)除外 —— 它是一个值,坏一项 ⇒
515
- * 它所属的条目在上一层整条判不过、整条丢。根不是对象 ⇒ 没有条目集合。只读 schema,不读文档。 */
527
+ * 根(拆掉包装层后)是对象 ⇒ 它的每个元素是条目({@link isEntrySchema})的数组 / Record 字段。元素不是条目的集合(值名单、凭据引用)是一个值,
528
+ * 不在其列 —— 坏一项 ⇒ 它所属的条目在上一层整条判不过、整条丢。根不是对象 ⇒ 没有条目集合。只读 schema,不读文档。 */
516
529
  function entryCollectionsOf(schema) {
517
530
  const root = unwrapSchema(schema);
518
531
  if (!(root instanceof z.ZodObject))
519
532
  return [];
520
533
  return Object.entries(root.shape).flatMap(([field, fieldSchema]) => {
521
534
  const collection = unwrapSchema(fieldSchema);
522
- if (ATOMIC_SALVAGE.has(collection))
523
- return [];
524
- if (collection instanceof z.ZodArray)
535
+ if (collection instanceof z.ZodArray && isEntrySchema(collection.element))
525
536
  return [{ field, isArray: true, element: collection.element, keySchema: undefined }];
526
- if (collection instanceof z.ZodRecord)
537
+ if (collection instanceof z.ZodRecord && isEntrySchema(collection.valueType))
527
538
  return [{ field, isArray: false, element: collection.valueType, keySchema: collection.keyType }];
528
- return []; // 不是条目集合:连读都不读(少触发一次访问器)
539
+ return []; // 不是条目集合(值名单、普通字段):连读都不读(少触发一次访问器)
529
540
  });
530
541
  }
542
+ /** 一个集合元素的 schema 是不是**条目**:拆掉包装层后是对象,或是每个选项都是条目的联合(判别联合同,`models.roles` 的值、projects 的上下文条目)。
543
+ * 其余一切(串 / 数 / 枚举 / 字面量 / 嵌套的数组 / 认不出的形)⇒ 不是:那个集合是一个值,整只判。认不出就不是条目 —— 逐元素抢救是放宽方向,只给认得出的对象开门。 */
544
+ function isEntrySchema(schema) {
545
+ const s = unwrapSchema(schema);
546
+ if (s instanceof z.ZodObject)
547
+ return true;
548
+ if (s instanceof z.ZodUnion)
549
+ return s.options.every(isEntrySchema);
550
+ return false;
551
+ }
531
552
  /** 集合字段的值 → 它的位置表;值的形与 schema 对不上(schema 说数组、文档给对象)⇒ `undefined`(不抢救,交给整域档位)。
532
553
  * 数组走 `forEach`(不是手写 `for (i < value.length)`):它在**进入时**就钉死了长度,而重读 `value.length` 会跟着一个在校验期间
533
554
  * 自我增殖的数组一路跑下去(病态 getter 在 zod 读字段时往同一个数组里再 push 一条)—— 抢救是尽力而为的旁路,绝不许把同步读挂死;
@@ -957,7 +978,7 @@ function entryHeldStrippedKeys(domain, schema, raw, parsed) {
957
978
  return strippedKeysUnder(domain, raw, parsed, []).filter(({ holder }) => holder.length >= 2 && fields.has(String(holder[0])));
958
979
  }
959
980
  /**
960
- * 视图面整份判官的后一半(22.0.0;逐条丢弃域与 wire 上的 skills 清单,见 {@link parseForView} / `readSkillsManifest`):文档已过 schema,但有条目体内的键被剥 ⇒
981
+ * 视图面整份判官的后一半(22.0.0;逐条丢弃域,见 {@link parseForView}):文档已过 schema,但有条目体内的键被剥 ⇒
961
982
  * 抛 {@link strippedKeysError}(从域根起的坐标);比键集时读不出 ⇒ 抛 {@link unreadableDomainError}。调用方接住它走逐条抢救(带未知键的条目丢它自己,
962
983
  * {@link judgeEntry});救不活(零幸存者、丢了之后引用悬空)⇒ 这就是「整份读不进」的那个原错 —— 不会退回剥键照装。
963
984
  */
@@ -1095,18 +1116,44 @@ export function parseDomainLoud(domain, raw, onWarning) {
1095
1116
  * 读改写(读存量、改、整份写回)的「现状」也不许读它 —— 抢救读出再写回,被丢的条目就成了删除。
1096
1117
  */
1097
1118
  export function parseDomainSalvaged(domain, raw, onWarning) {
1098
- return readDomainDocument(domain, raw, onWarning, (doc) => parseForView(domain, doc), (unreadable) => parseSalvaged(domain, raw, unreadable, onWarning));
1119
+ return readView(domainSeat(domain), raw, onWarning);
1120
+ }
1121
+ /** 一个域的文档座位。退役域名 / 不是域名(JS 调用方递来的任意串)⇒ 与 {@link parseDomain} 同一只判官、同一句拒({@link domainSchemaOf})。 */
1122
+ function domainSeat(domain) {
1123
+ return { domain, schema: domainSchemaOf(domain) };
1124
+ }
1125
+ /** wire 上的 skills 清单的座位(`readEffectiveWire`)。 */
1126
+ const SKILLS_MANIFEST_SEAT = { domain: "skills", schema: SkillsManifestSchema };
1127
+ /** 视图面读一份文档(整份判 → 按 {@link DOMAIN_ENTRY_SALVAGE} 逐条抢救 → 未知键告警);读不进 ⇒ 抛第一次严判的原错。{@link parseDomainSalvaged} 的本体。 */
1128
+ function readView(seat, raw, onWarning) {
1129
+ return readDomainDocument(seat.domain, raw, onWarning, (doc) => parseForView(seat, doc), (unreadable) => parseSalvaged(seat, raw, unreadable, onWarning));
1130
+ }
1131
+ /**
1132
+ * 视图面读一份文档,**读不进时按 {@link DOMAIN_READ_FALLBACK} 答**:`"throw"` ⇒ 原错抛出;`"default"` ⇒ schema 默认 + 一条 `domain-defaulted`。
1133
+ * `buildEffective` 的每个域与 `readEffectiveWire` 的 skills 清单都经这一只 —— 两张表各问一次,同一个域在每条读腿上同一个答案(24.0.0 前清单是单列一臂,
1134
+ * 恒逐条抢救、恒默认化,不读这两张表)。好文档的路径一字不动。
1135
+ */
1136
+ function readViewOr(seat, raw, onWarning) {
1137
+ try {
1138
+ return readView(seat, raw, onWarning);
1139
+ }
1140
+ catch (e) {
1141
+ if (DOMAIN_READ_FALLBACK[seat.domain] === "throw")
1142
+ throw e;
1143
+ onWarning?.({ domain: seat.domain, kind: "domain-defaulted", error: e });
1144
+ return strictParse(seat.schema, seat.domain, emptyDocument()); // schema default — always valid
1145
+ }
1099
1146
  }
1100
1147
  /**
1101
- * 视图面的**整份判官**(22.0.0):`parseDomain`,外加 —— 在逐条丢弃域({@link DOMAIN_ENTRY_SALVAGE} 判 `"salvage"`)里 —— 「没有条目体内被剥的键」
1102
- * ({@link refuseEntryHeldStrippedKeys})。视图面判条目只有一条律({@link judgeEntry}:过 schema 且体内没有键被剥),整份文档也按同一条律判:
1103
- * 否则零幸存者的集合(一条都救不活 ⇒ 抢救一条不丢)就会剥键照装,正是本律要关掉的那条放宽。
1104
- * 不逐条丢的域与文档面({@link parseDomainLoud})只用 `parseDomain`:那里一条条目都不丢,条目体内的未知键照旧剥键 + 告警。
1148
+ * 视图面的**整份判官**(22.0.0):整份严判(缺席 —— 只有 `undefined` —— 按空文档判,与 {@link parseDomain} 同一条),外加 —— 在逐条丢弃域
1149
+ * ({@link DOMAIN_ENTRY_SALVAGE} 判 `"salvage"`)里 —— 「没有条目体内被剥的键」({@link refuseEntryHeldStrippedKeys})。视图面判条目只有一条律
1150
+ * ({@link judgeEntry}:过 schema 且体内没有键被剥),整份文档也按同一条律判:否则零幸存者的集合(一条都救不活 ⇒ 抢救一条不丢)就会剥键照装,
1151
+ * 正是本律要关掉的那条放宽。不逐条丢的域与文档面({@link parseDomainLoud})只做整份严判:那里一条条目都不丢,条目体内的未知键照旧剥键 + 告警。
1105
1152
  */
1106
- function parseForView(domain, raw) {
1107
- const parsed = parseDomain(domain, raw);
1108
- if (DOMAIN_ENTRY_SALVAGE[domain] === "salvage")
1109
- refuseEntryHeldStrippedKeys(domain, DOMAIN_SCHEMAS[domain], raw, parsed, domain);
1153
+ function parseForView(seat, raw) {
1154
+ const parsed = strictParse(seat.schema, seat.domain, raw === undefined ? emptyDocument() : raw);
1155
+ if (DOMAIN_ENTRY_SALVAGE[seat.domain] === "salvage")
1156
+ refuseEntryHeldStrippedKeys(seat.domain, seat.schema, raw, parsed, seat.domain);
1110
1157
  return parsed;
1111
1158
  }
1112
1159
  /**
@@ -1128,10 +1175,11 @@ function readDomainDocument(domain, raw, onWarning, parse, whenUnreadable) {
1128
1175
  /** {@link parseDomainSalvaged} 的第 2 / 3 步(整域 parse 已经失败):能救就救,救不了就抛 `unreadable`(第 1 步的原错)。
1129
1176
  * 档位判 `!== "salvage"`(不是 `=== "none"`):一个不是域的名字(JS 调用方 / 写入席收到的任意键)查表得到 `undefined` 或原型链上的东西,
1130
1177
  * 照样不抢救 —— 只有表里白纸黑字的 `"salvage"` 才开这扇门。 */
1131
- function parseSalvaged(domain, raw, unreadable, onWarning) {
1178
+ function parseSalvaged(seat, raw, unreadable, onWarning) {
1179
+ const { domain } = seat;
1132
1180
  if (DOMAIN_ENTRY_SALVAGE[domain] !== "salvage")
1133
1181
  throw unreadable;
1134
- const { parsed, salvage } = salvageThenParse(DOMAIN_SCHEMAS[domain], domain, raw, (doc) => parseForView(domain, doc), unreadable);
1182
+ const { parsed, salvage } = salvageThenParse(seat.schema, domain, raw, (doc) => parseForView(seat, doc), unreadable);
1135
1183
  if (onWarning) {
1136
1184
  // 坐标律(S-323b):一条告警用运维手里那份文档的坐标。`entry-dropped` 是本层(salvage)铸的,用的就是本层入参那份文档的坐标 ⇒ 原样出门;
1137
1185
  // 未知键扫描是对压缩后文档的诊断,但它报的坐标不经任何压缩过的集合(22.0.0:集合条目体内的被剥键让那一条丢 —— 压缩后的文档条目体内没有被剥的键,
@@ -1143,7 +1191,7 @@ function parseSalvaged(domain, raw, unreadable, onWarning) {
1143
1191
  return parsed;
1144
1192
  }
1145
1193
  /**
1146
- * 逐条抢救的**那一步**(域面 {@link parseSalvaged} 与 wire 面 skills 清单 `readSkillsManifest` 共用 —— 一条律,两个调用点):整份严判已经失败
1194
+ * 逐条抢救的**那一步**({@link parseSalvaged} 的本体;每个座位 —— 域文档与 wire 上的 skills 清单 —— 都经它,一条律一个调用点):整份严判已经失败
1147
1195
  * (校验不过,或校验过程抛 —— 同一条臂:{@link salvageEntries} 逐条判,抛的那一条记 `entry-unreadable` 丢它自己)之后,丢掉坏条目再严判一次。
1148
1196
  * 什么都没丢 / 丢了仍读不进(条目之外还有毛病:重名 / 悬空 ref / 域级判据;零幸存者的集合里还留着带未知键的条目;或抢救后的文档在重判时读不出)⇒
1149
1197
  * 抛 `unreadable`(第一次严判的原错)—— 一个文档一个结论,没救活就不留「丢了某条」的半路叙述。`domain` = 哪个域的扩展命名空间生效(见 {@link salvageEntries})。
@@ -1176,8 +1224,16 @@ function announceUnknownKeys(domain, raw, parsed, emit) {
1176
1224
  * `"throw"` = keep fail-loud (defaulting would LOOSEN gates or destructively apply — worse than an outage,
1177
1225
  * consumers fail-static on last-good). A `satisfies Record<DomainName,…>` forces every FUTURE domain to make
1178
1226
  * this call explicitly (compile error until it's classified). Per-domain rationale:
1179
- * - models/skills/mcp/plugins/scenarios/systems/collab: additive capability catalogs — empty = the
1227
+ * - **The law (24.0.0, the last domain of the class)**: a domain whose entry's absence WIDENS ({@link DOMAIN_ENTRY_SALVAGE} `"none"` for that
1228
+ * reason) is also `"throw"` here — its empty default widens the same way, for every reader at once. `scenarios` / `plugins` / `skills`.
1229
+ * - models/mcp/systems/collab: additive capability catalogs — empty = the
1180
1230
  * capability disappears (fail-closed), no gate is lost.
1231
+ * - scenarios: THROW (23.0.0) — an empty `scenarios` revives every built-in scenario an entry overrode, widening the tool surface of each;
1232
+ * defaulting would hand that to every reader that has no candidate gate. {@link DOMAIN_ENTRY_SALVAGE} judges the domain `"none"` for the same
1233
+ * reason, and a `"none"` domain that then defaulted would be the same loosening one level up (one bad entry ⇒ ALL overrides gone).
1234
+ * - plugins: THROW (23.0.0) — an empty `plugins` drops the hooks (guards among them) the references carried; same reasoning as `scenarios`.
1235
+ * - skills: THROW (24.0.0) — an empty `skills` returns every built-in skill a center skill overrode by name (with the built-in's own tool
1236
+ * allow list, without the center entry's deny list); same reasoning as `scenarios`. The wire manifest is the same domain and asks this row too.
1181
1237
  * - hosts: empty host registry = no auto-placement targets (availability-only); self-registration re-lands
1182
1238
  * entries as approved:false = 待批 (fail-closed).
1183
1239
  * - rosters: THROW — a lost roster makes resolveEffectiveForWorker fall back to the FULL models catalog
@@ -1199,10 +1255,10 @@ function announceUnknownKeys(domain, raw, parsed, emit) {
1199
1255
  export const DOMAIN_READ_FALLBACK = {
1200
1256
  models: "default",
1201
1257
  rosters: "throw",
1202
- skills: "default",
1258
+ skills: "throw", // 24.0.0:空 skills = 被中心按名覆盖的出厂技能全部回位(带回它们自己的 allow 名单),不是 fail-closed;与 DOMAIN_ENTRY_SALVAGE 的 none 同一理由
1203
1259
  mcp: "default",
1204
- plugins: "default",
1205
- scenarios: "default",
1260
+ plugins: "throw", // 23.0.0:空 plugins = 引用承运的 hooks(守卫)全缺席,不是 fail-closed;与 DOMAIN_ENTRY_SALVAGE 的 none 同一理由
1261
+ scenarios: "throw", // 23.0.0:空 scenarios = 覆盖过的内建场景全部回位(更宽的工具面),不是 fail-closed;与 DOMAIN_ENTRY_SALVAGE 的 none 同一理由
1206
1262
  systems: "default",
1207
1263
  collab: "default",
1208
1264
  workers: "throw",
@@ -1211,7 +1267,7 @@ export const DOMAIN_READ_FALLBACK = {
1211
1267
  entitlement: "throw",
1212
1268
  execution: "throw",
1213
1269
  projects: "throw",
1214
- // prompts:内容域(scenarios 同类)——坏形→空默认 `{}`(=「不管提示词」:不下发中心层,引擎用内置);fail-closed 由 PUBLISH_MODE
1270
+ // prompts:内容域 ——坏形→空默认 `{}`(=「不管提示词」:不下发中心层,引擎用内置);fail-closed 由 PUBLISH_MODE
1215
1271
  // 发布闸承担,default 不扩权。14.0.0 起墓碑键(`bindings` / `catalog`)也走这一档(读不出 ⇒ 缺省 + domain-defaulted 点名 SS-M10)。
1216
1272
  prompts: "default",
1217
1273
  // limits(0.19.0):THROW —— 本域是成本 / 限流天花板的唯一发布位(11.0.0 起 runtime 域retired)。坏形
@@ -1232,6 +1288,9 @@ export const DOMAIN_READ_FALLBACK = {
1232
1288
  * (domain top level, a top-level plain object field) is still stripped and named (`unknown-keys-dropped`).
1233
1289
  * `"none"` = never drop a single entry: the first bad entry makes the whole domain unreadable. An unknown key inside an entry of such a
1234
1290
  * domain is stripped and named, as before 22.0.0 — those domains drop nothing, so the strip warning is the reader's signal.
1291
+ * (23.0.0: `scenarios` and `plugins` joined the seven, 24.0.0: `skills` — their entries' absence widens; see the judgment below.)
1292
+ * An entry is an object: a collection whose elements are values (a tool list, a scope list, credential references) is ONE value of the entry
1293
+ * holding it — never thinned element by element (24.0.0; see `salvageEntries`).
1235
1294
  * A `satisfies Record<DomainName,…>` forces every FUTURE domain to answer this explicitly (compile error until classified).
1236
1295
  *
1237
1296
  * **View face only.** The document face never salvages: `parseDomain` / `validateDomain` / `writeDomainFile` judge the whole
@@ -1240,12 +1299,25 @@ export const DOMAIN_READ_FALLBACK = {
1240
1299
  * it back would turn every dropped entry into a deletion — read-modify-write faces read the stored document with the document face.
1241
1300
  *
1242
1301
  * Per-domain rationale:
1243
- * - models/skills/mcp/plugins/scenarios/systems/collab: additive capability / content catalogs — a dropped entry is
1244
- * one capability gone (fail-closed). Inside a surviving entry the same holds: the nested collections these entries carry
1245
- * are allowlists / scopings (`allowTools`, `scenarios`, `rosters`, `callsWorkers`, …) where one entry fewer only NARROWS,
1246
- * and the zero-survivor law (never mint an empty collection — several of these read "empty = all") holds at every level.
1302
+ * - **The judgment (23.0.0)**: `"salvage"` is for a domain whose entry's ABSENCE can only NARROW what is reachable. A domain whose entry's
1303
+ * absence WIDENS — the entry is a restriction, a guard, or an override of a built-in of the same name (its absence revives the built-in) — is `"none"`:
1304
+ * dropping the entry would be the same loosening as stripping its key. The judgment is written on the row (a trailing comment, closed set: a new
1305
+ * domain adds its row AND its judgment).
1306
+ * - models/mcp/systems/collab: capability / content catalogs and grants — a dropped entry is
1307
+ * one capability gone (fail-closed). The value lists these entries carry (`allowTools`, `scenarios`, `rosters`, `callsWorkers`, …) are
1308
+ * read whole: one bad element drops the entry that holds it (one capability gone), never a shorter list; nested OBJECT collections
1309
+ * (collab slots / members) are entries in their own right, and the zero-survivor law (never mint an empty collection) holds at every level.
1310
+ * - skills: NONE (24.0.0) — a center skill OVERRIDES the built-in skill of the same name, and carries its own tool allow / deny lists.
1311
+ * A dropped skill returns the built-in (its allow list back, the center's deny list gone); a deny list thinned by one element is wider than
1312
+ * the author wrote. The wire manifest is the same domain: it reads both tables through the same reader as the domain document.
1313
+ * - scenarios: NONE (23.0.0) — an entry names the tool surface of a scenario, and may carry the name of a built-in scenario (then it OVERRIDES
1314
+ * it, narrowing its tool surface). A dropped entry revives the built-in with its wider surface: the loosening 22.0.0's rule made out of a
1315
+ * misspelt or forward-looking key.
1316
+ * - plugins: NONE (23.0.0) — an entry is the source reference of an executable surface (commands / hooks / MCP); its hooks may be guards
1317
+ * (`PreToolUse` / `PermissionRequest`, see `./hooks-config`). A dropped reference takes the guard with it.
1247
1318
  * - hosts: a dropped host is one placement target fewer; a dropped label makes a host match fewer `placement.requires`.
1248
- * - projects: SALVAGE — a registration absent from the ledger = that project's claim is refused (fail-closed). Throwing the
1319
+ * - projects: SALVAGE — a registration absent from the ledger is one project fewer (the pinned consumer reads a lookup miss as "no
1320
+ * default-scope seed", not as a refused admission: the ledger is an additive registry, not a gate). Throwing the
1249
1321
  * whole domain stops EVERY project of the scope, which protects nothing: one stored registration that a later, tighter
1250
1322
  * schema refuses (12.2.1's UNC judgement on `contextItems[].value`) must not take the scope's other projects with it.
1251
1323
  * Its whenUnreadable stance stays `"throw"` (a ledger that cannot be read at all is never defaulted — see
@@ -1263,26 +1335,26 @@ export const DOMAIN_READ_FALLBACK = {
1263
1335
  * - execution: NONE — a dropped lane / public key changes the execution mandate (放权,不许).
1264
1336
  * - limits: NONE — a dropped allowlist row changes a published ceiling (the domain is the one publishing seat of those ceilings).
1265
1337
  * - a2a: SALVAGE (18.0.0) — the peer roster is a capability catalog like mcp: a dropped peer is one remote agent fewer. A peer's
1266
- * credential references (`headerRefs`) are in {@link ATOMIC_SALVAGE}: a bad reference drops the whole peer, never the reference
1338
+ * credential references (`headerRefs`) are a value collection: a bad reference drops the whole peer, never the reference
1267
1339
  * alone (a peer kept with half of its credentials is the wrong failure direction). */
1268
1340
  export const DOMAIN_ENTRY_SALVAGE = {
1269
- models: "salvage",
1270
- rosters: "none",
1271
- skills: "salvage",
1272
- mcp: "salvage",
1273
- plugins: "salvage",
1274
- scenarios: "salvage",
1275
- systems: "salvage",
1276
- collab: "salvage",
1277
- workers: "none",
1278
- hosts: "salvage",
1279
- governance: "none",
1280
- entitlement: "none",
1281
- execution: "none",
1282
- projects: "salvage",
1283
- prompts: "none",
1284
- limits: "none",
1285
- a2a: "salvage",
1341
+ models: "salvage", // 留:条目 = 一个目录模型(及 `roles` 里的一个角色覆盖);缺席 = 少一个模型 / 一个角色回落到缺省 —— 选路变了,可达面没变(被引用的模型缺席 ⇒ 引用悬空 ⇒ 整域缺省,既有律)
1342
+ rosters: "none", // 收:条目 = 一台 worker 的模型名册;缺席 ⇒ 该 worker 回落到整份目录 = 放宽
1343
+ skills: "none", // 收:条目 = 按名覆盖出厂技能的中心技能(带它自己的工具 allow / deny 名单);缺席 = 同名出厂技能回位(带回它的 allow 名单、丢掉中心的 deny 名单)= 放宽
1344
+ mcp: "salvage", // 留:条目 = 一台工具源;缺席 = 该台不挂载 —— 已知缺口:名字不再被部署占位(请求侧同名注入只在读方放开它的部署:单用户、未锁、合规允许),见 CHANGELOG 已知限制
1345
+ plugins: "none", // 收:条目 = 可执行面的来源引用,hooks(含 PreToolUse / PermissionRequest 守卫)随引用走;缺席 = 守卫缺席 = 放宽
1346
+ scenarios: "none", // 收:条目 = 覆盖内建场景名的工具面声明;缺席 = 同名内建(更宽的工具面)复活 = 放宽
1347
+ systems: "salvage", // 留:条目 = 一个外部系统的凭据与可调 worker 名单(授权);缺席 = 少一份授权
1348
+ collab: "salvage", // 留:条目 = 一个协作模板(预算闸随模板走);缺席 = 少一个可选模板,已有的闸一个不松
1349
+ workers: "none", // 收:条目 = 一台 worker 的声明;缺席 = 「不再声明」,对账器会把它撤下(破坏性),它的名册绑定也一并消失
1350
+ hosts: "salvage", // 留:条目 = 一个排布目标;缺席 = 少一个目标(待批 / drain / 停用的条目缺席同样不可排)
1351
+ governance: "none", // 收:条目 = 命令策略行 / 审批要求;缺席 = 护栏静默消失 = 放宽
1352
+ entitlement: "none", // 收:条目 = 档 / 主体 / 绑定 / 预算组;缺席 = 谁能做什么变了(限制、配额、预算成员随条目走)
1353
+ execution: "none", // 收:条目 = 执行车道 / 公钥登记;缺席 = 执行授权的面变了
1354
+ projects: "salvage", // 留:条目 = 一条项目登记(加性登记簿,不是准入门);缺席 = 少一份默认记忆 scope 的种子(消费方查表 miss 不 fail)
1355
+ prompts: "none", // 收:条目受 digest 约束;缺席 = digest 不再成立,或范围文本替换掉某台 worker 的 artifact(是替换不是收窄)
1356
+ limits: "none", // 收:条目 = 已发布上限的一行;缺席 = 发布的天花板变了(本域是这些上限的唯一发布位)
1357
+ a2a: "salvage", // 留:条目 = 一个出站对端;缺席 = 少一个对端(凭据引用是值集合、整体判;名字占位同 mcp,见 CHANGELOG 已知限制)
1286
1358
  };
1287
1359
  /**
1288
1360
  * Merge every domain into the effective config a consumer pulls. Shared by all store impls.
@@ -1296,21 +1368,11 @@ export function buildEffective(version, getRaw, updatedAt, onWarning) {
1296
1368
  // 墓碑先判:一份没迁的retired 域文档意味着这个 scope 的存量还没过一次性迁移 —— 拿剩下的域拼一份 effective 等于静默丢掉它的事实。
1297
1369
  for (const retired of Object.keys(RETIRED_DOMAINS))
1298
1370
  refuseRetiredDomain(retired, getRaw(retired));
1299
- // 每个域同一只读法(12.3.0,S-1494):视图面读函数 {@link parseDomainSalvaged}(整域 parse → 按 DOMAIN_ENTRY_SALVAGE 逐条抢救 → 未知键告警;
1300
- // 与文档面 `parseDomainLoud` 共用同一只内部体)读不进 ⇒ 只剩**整域读不进**这一个问题,答案只看 DOMAIN_READ_FALLBACK(决策表与逐域理由见那张表):
1301
- // `"throw"` ⇒ 原错抛出;`"default"` ⇒ schema 默认 + `domain-defaulted`。哪个域走哪一档不再写在下面的行上(此前 gate 域的行
1302
- // 调 parseLoud、其余调 parseOr —— 同一张表的第二份手抄),行只说「读这个域」。好配置的路径一字不动(同一次 parseDomain,同一份字节)。
1303
- const parseOr = (domain, raw) => {
1304
- try {
1305
- return parseDomainSalvaged(domain, raw, onWarning);
1306
- }
1307
- catch (e) {
1308
- if (DOMAIN_READ_FALLBACK[domain] === "throw")
1309
- throw e;
1310
- onWarning?.({ domain, kind: "domain-defaulted", error: e });
1311
- return parseDomain(domain, undefined); // schema default — always valid
1312
- }
1313
- };
1371
+ // 每个域同一只读法(12.3.0 起;24.0.0 起 wire 上的 skills 清单也是这一只):{@link readViewOr} —— 视图面读(整域 parse → 按 DOMAIN_ENTRY_SALVAGE
1372
+ // 逐条抢救 → 未知键告警)读不进 ⇒ 只剩**整域读不进**这一个问题,答案只看 DOMAIN_READ_FALLBACK(决策表与逐域理由见那张表):
1373
+ // `"throw"` ⇒ 原错抛出;`"default"` ⇒ schema 默认 + `domain-defaulted`。哪个域走哪一档不写在下面的行上,行只说「读这个域」。
1374
+ // 好配置的路径一字不动(同一次严判,同一份字节)。
1375
+ const parseOr = (domain, raw) => readViewOr(domainSeat(domain), raw, onWarning);
1314
1376
  return {
1315
1377
  version,
1316
1378
  updatedAt,
@@ -1350,9 +1412,10 @@ export function buildEffective(version, getRaw, updatedAt, onWarning) {
1350
1412
  * an open-world key.
1351
1413
  *
1352
1414
  * `skills` is the ONE wire divergence: on the wire it is a MANIFEST(content → contentHash,
1353
- * {@link SkillsManifest}),so the full skills-domain schema would reject every LEGAL manifest and silently
1354
- * default the domain(蒸发整张 skill 清单)— it validates against {@link SkillsManifestSchema} instead,
1355
- * same "default" fallback tier as the skills domain itself.
1415
+ * {@link SkillsManifest}),so the full skills-domain schema would MISREAD every legal manifest (each entry would read as
1416
+ * `content: ""` with `contentHash` stripped as an unknown key) — it validates against
1417
+ * {@link SkillsManifestSchema} instead, through the SAME reader as every domain (24.0.0, {@link readViewOr}): the skills domain's two tables
1418
+ * answer for the manifest too (`"none"` + `"throw"` ⇒ one unreadable manifest entry makes the payload unreadable), and only `undefined` is absence.
1356
1419
  *
1357
1420
  * NEVER FABRICATES a domain the producer did not send (20.0.0): the domains of {@link WIRE_CARRIED_DOMAINS} (`prompts`, `a2a`) are carried by presence —
1358
1421
  * absent on the wire ⇒ absent in the result (an older producer does not know `a2a`; `prompts` is absent whenever nothing is published), present ⇒ the
@@ -1392,20 +1455,16 @@ export function readEffectiveWire(raw, onWarning) {
1392
1455
  if (typeof r.version !== "number" || !Number.isFinite(r.version))
1393
1456
  throw new Error("effective wire payload has no numeric version");
1394
1457
  const updatedAt = typeof r.updatedAt === "string" ? r.updatedAt : "";
1395
- // skills redirected to undefined: buildEffective must never see the manifest(it would fail the full-domain
1396
- // schema and "default" it with a FALSE domain-defaulted warning);the manifest is judged separately below.
1458
+ // skills redirected to undefined: buildEffective must never judge the manifest with the domain schema (every legal manifest entry would read
1459
+ // as an entry without `content` carrying an unknown `contentHash`); the manifest is judged below by the SAME reader with its own seat.
1397
1460
  // prompts likewise redirected(#100):on the wire it is the published form `EffectivePromptsWire`(`{schemaVersion: 2, artifact}`,
1398
1461
  // the one artifact selected for the pulling worker — never the storage shape), judged by the CONSUMER(that shape, then the engine's
1399
1462
  // verify). The read leg must not parse it with the storage schema: a bad prompts value would be degraded to "absent" here and read
1400
1463
  // downstream as "the center withdrew its layer" — the consumer's judge refuses it loudly instead. verbatim, by presence(见 return)。
1401
1464
  const built = buildEffective(r.version, (d) => (d === "skills" || d === "prompts" ? undefined : r[d]), updatedAt, onWarning);
1402
1465
  // retired 域名不是 open-world 的未知键:墓碑已在 buildEffective 里判过(带事实 ⇒ 抛),剩下的 `{}` 没有可承运的东西。
1403
- const manifest = readSkillsManifest(r.skills);
1404
- // 告警在判完之后、读法之外发:`onWarning` 自己抛的错不会被当成「清单读不进」
1405
- if (onWarning)
1406
- for (const w of manifest.warnings)
1407
- onWarning(w);
1408
- const skills = manifest.skills;
1466
+ // skills 清单:skills 域的线上形,与域文档同一只读法、同两张表(SKILLS_MANIFEST_SEAT)
1467
+ const skills = readViewOr(SKILLS_MANIFEST_SEAT, r.skills, onWarning);
1409
1468
  // Open-world passthrough: keys that are neither validated domains nor the envelope fields ride verbatim.
1410
1469
  // `hasOwnProperty.call(built, k)`,**不是** `k in built`(S-332):`in` 会一路问到 `Object.prototype`,
1411
1470
  // 于是 `constructor` / `toString` / `hasOwnProperty` / `__proto__` 这些**原型链上的名字**作未知顶层键时
@@ -1425,33 +1484,6 @@ export function readEffectiveWire(raw, onWarning) {
1425
1484
  }
1426
1485
  /** 一个顶层键是不是承运表里的域(读名字,不读值)。 */
1427
1486
  const isWireCarriedDomain = (k) => WIRE_CARRIED_DOMAINS.includes(k);
1428
- /**
1429
- * wire 上 skills 清单的读法 —— **与非门控域同一臂**,只是判的是清单 schema({@link SkillsManifestSchema}):整份严判({@link strictParse})→ 读不进
1430
- * (校验不过,或校验器自己抛 —— 合法 JSON 里的怪形值、嵌入方对象的 getter / 陷阱 —— 同一条臂)⇒ 逐条抢救({@link salvageThenParse}:坏条目丢它自己 + `entry-dropped`,
1431
- * 其余合法条目保留;零幸存者不凭空造空集合)→ 仍读不进 ⇒ 整份退默认(空清单)+ `domain-defaulted`(`error` = 第一次严判的原错:脱敏的 ZodError,或包自己那一句的 TypeError)。
1432
- * 缺席 ⇒ 按包自己造的空文档判(`COPY_PROTOTYPE`,读不到污染值)。告警交回给调用方发。
1433
- */
1434
- function readSkillsManifest(raw) {
1435
- // 整份判与视图面域读同一条律(22.0.0;skills 是逐条丢弃域,清单是它的线上形):过 schema,且清单条目体内没有被剥的键 —— 有 ⇒ 走逐条抢救,带未知键的条目丢它自己。
1436
- const parse = (doc) => {
1437
- const parsed = strictParse(SkillsManifestSchema, "skills", doc);
1438
- refuseEntryHeldStrippedKeys("skills", SkillsManifestSchema, doc, parsed, "skills");
1439
- return parsed;
1440
- };
1441
- try {
1442
- return { skills: parse(raw ?? emptyDocument()), warnings: [] };
1443
- }
1444
- catch (unreadable) {
1445
- try {
1446
- const { parsed, salvage } = salvageThenParse(SkillsManifestSchema, "skills", raw, parse, unreadable);
1447
- return { skills: parsed, warnings: salvage.dropped.map((d) => entryDroppedWarning("skills", d)) };
1448
- }
1449
- catch {
1450
- // 救不回 ⇒ 告警带第一次严判的原错(salvageThenParse 只重抛它;salvageEntries 是总的)—— 在结构上就是它,不靠「被捕获的恰好是它」
1451
- return { skills: { skills: [] }, warnings: [{ domain: "skills", kind: "domain-defaulted", error: unreadable }] };
1452
- }
1453
- }
1454
- }
1455
1487
  /** 档位组→引擎单表的唯一解析点(0.9.0)。返回 ACTIVE 档位组的绑定表(剔除未绑档),即 core
1456
1488
  * `RunnerDeps.tiers` 要吃的那张单表——组切换=web-admin 换这张表下发,零新引擎机制。无 active 组/未命中/
1457
1489
  * 组内一档未绑 → `undefined`(引擎档位层恒惰性,与「未配 tiers」逐字同义)。消费方(web-admin /effective
@@ -10,7 +10,8 @@
10
10
  * 变换表(每条写明:动了什么、影响哪几条腿、出处):
11
11
  * · **T1 承运域在场性**(wire):`buildEffective` 恒物化每个域;wire 腿对承运表 `WIRE_CARRIED_DOMAINS` 里的域(`prompts`、`a2a`)按**在场性**
12
12
  * 挂回(线上读口不编造生产方没发的域)—— 缺席进缺席出;在场时 `prompts` 是**未解析的原文档**,`a2a` 是域腿的读数。表由常量派生,不手抄域名。
13
- * · **T2 skills 表示**(wire):域形带 `content`,wire 形带 `contentHash`(manifest)。判据 schema 随表示走。
13
+ * · **T2 skills 表示**(wire):域形带 `content`,wire 形带 `contentHash`(manifest)。判据 schema 随表示走;读法不随(24.0.0 起清单与域文档同一只读法、
14
+ * 同两张表,剥键扫描与告警同读 —— 此前清单不走剥键扫描,派生要把 skills 的剥键告警从 wire 期望里滤掉)。
14
15
  * · **T3 非便携域**(local-root):`config.d/` 只读 {@link PORTABLE_DOMAINS};其余域的文件在场则报
15
16
  * `unread-config-file{why:"non-portable-domain"}`,域本身取 schema 默认。**由 `PORTABLE_DOMAINS` 派生,
16
17
  * 不手抄域名** —— 设计稿只点了 `hosts` 一个实例,类是「非便携域」。
@@ -41,7 +42,7 @@ import { DOMAINS, WIRE_CARRIED_DOMAINS, isDomainName } from "../types.js";
41
42
  /** 变换表(本文件头注的机器形;`docs/CONFORMANCE.md` 与 `test/conformance-coverage.test.ts` 都读它)。 */
42
43
  export const DERIVATION_TRANSFORMS = [
43
44
  { id: "T1-wire-carried-domains", legs: ["wire"], what: "buildEffective 恒物化每个域;wire 对 WIRE_CARRIED_DOMAINS(prompts / a2a)按在场性挂回(缺席进缺席出;在场时 prompts 是原文档、a2a 是域腿读数)" },
44
- { id: "T2-skills-representation", legs: ["wire"], what: "域形 content ↔ wire 形 contentHash(manifest),判据 schema 随表示走" },
45
+ { id: "T2-skills-representation", legs: ["wire"], what: "域形 content ↔ wire 形 contentHash(manifest),判据 schema 随表示走;读法与告警同一只" },
45
46
  { id: "T3-non-portable-domains", legs: ["localRoot"], what: "config.d/ 只读 PORTABLE_DOMAINS;其余域取默认 + unread-config-file{non-portable-domain}" },
46
47
  { id: "T4-unknown-top-level-key", legs: ["wire", "localRoot"], what: "wire open-world 逐字承运;domains 腿按域名取文档故无声;local 报 unread-config-file{not-a-domain}" },
47
48
  { id: "T5-file-layer-first", legs: ["localRoot"], what: "config.d/<域>.json 必须是 JSON 对象(空/null/数组/标量 throw),这一层在域解析之前" },
@@ -121,8 +122,6 @@ export function deriveWireExpectation(source, docs) {
121
122
  const warnings = source.warnings.filter((w) => {
122
123
  if ("domain" in w && w.domain === "prompts")
123
124
  return false; // T1:wire 腿不解析 prompts ⇒ 没有它的告警
124
- if ("domain" in w && w.domain === "skills" && (w.kind === "unknown-keys-dropped" || w.kind === "unknown-keys-carried"))
125
- return false; // T2:manifest 不走剥键扫描
126
125
  return true;
127
126
  });
128
127
  return { outcome: "effective", effective, warnings, metadata: { ...source.metadata } };
@@ -69,9 +69,9 @@ export declare class FileConfigStore implements ConfigReader {
69
69
  * throw,消费者(server main 单点 catch)只能整包回落 env——models.json 一个坏文件把 skills/mcp/
70
70
  * scenarios 全域连坐。`getEffective({tolerant:true})` 把 READ 层的坏文件按 parse 层既有的
71
71
  * {@link DOMAIN_READ_FALLBACK} 同一张表处置:
72
- * - `"default"` 域(models/skills/mcp/… 追加型 capability 目录):该域按 schema default 落 +
72
+ * - `"default"` 域(models/mcp/… 追加型 capability 目录):该域按 schema default 落 +
73
73
  * 错误单列进 `domainErrors`(fail-closed:default 只会移除能力),其余好域照常生效;
74
- * - `"throw"` 域(governance/rosters/entitlement/…):坏文件仍然 throw——READ 容错绝不放宽
74
+ * - `"throw"` 域(governance/rosters/entitlement/…,以及条目缺席会放宽的 scenarios/plugins/skills):坏文件仍然 throw——READ 容错绝不放宽
75
75
  * gate 域的 fail-loud(与 parse 层同一条纪律,defaulting=放权,不许)。
76
76
  * 版本语义:坏域在 version hash 里以 `{__corruptDomainFile: <文件文本 hash>}` 哨兵参与——绝不与
77
77
  * 「文件缺失(absent)」同 bytes(#readDomainRaw 头注的 lock-step 要求),坏→修好、好→坏、
package/dist/types.d.ts CHANGED
@@ -1850,7 +1850,9 @@ export interface SkillsManifest {
1850
1850
  }
1851
1851
  /** Runtime (zod) twin of {@link SkillsManifest} — the READ-side judgment for a wire payload's `skills` key
1852
1852
  * (`readEffectiveWire`). Derived from {@link SkillSpec} exactly like {@link SkillManifestEntry} is (omit
1853
- * `content` / require `contentHash`) so schema, entry type and interface can never drift apart. Only
1853
+ * `content` / require `contentHash`) so schema, entry type and interface can never drift apart, and built by the same
1854
+ * document constructor as {@link SkillsConfig} (24.0.0: the manifest is the skills domain on the wire — one document judgment,
1855
+ * duplicate names included; the reader judges it with the skills domain's two tables). Only
1854
1856
  * `min(1)` on contentHash: the hash is the service's PULL KEY for the content endpoint, its exact format
1855
1857
  * is web-admin's writing concern — re-pinning it here would make an old reader reject a newer web-admin's
1856
1858
  * legal hash scheme. */
@@ -1867,19 +1869,6 @@ export declare const SkillsManifestSchema: z.ZodObject<{
1867
1869
  contentHash: z.ZodString;
1868
1870
  }, z.core.$strip>>>;
1869
1871
  }, z.core.$strip>;
1870
- /**
1871
- * 18.0.0 —— **凭据引用集合不可部分抢救**(按 schema 身份的集合)。成员是「名 → 宿主 env-NAME」的凭据引用 Record:mcp 的 `envRefs` / `headerRefs`
1872
- * (a2a 对端的 `headerRefs` 复用后者,因此同在)、车道块的 `secretRefs` 与 worker 的 `secretEnv`。逐条抢救(`salvageEntries`)走到成员**不下钻**、把它当一个值判:
1873
- * 集合里任一键 / 值坏形 ⇒ 它所属的那一条条目整条 `entry-dropped`,兄弟条目保留。理由:丢掉一条坏引用不是「更窄」,而是让条目带着**一半凭据**活下来 ——
1874
- * 拨一个远端服务 / 智能体时错误的失败方向(读方对「任一引用的 env 缺席」本来就整条跳过,同一个方向)。
1875
- * 既有读数只变一处:直接对 `WorkersConfig` 调 `salvageEntries` 时,`secretEnv` 带坏引用的 worker 由「只丢那一条引用、worker 存活」变「整条丢」
1876
- * (各域读数不变:workers 域不逐条抢救;mcp 的两只住在传输判别联合里,走查不进联合;车道块住在不是集合的 `runtime` 对象里)
1877
- * —— 由 17.2.0 包的真读数逐行对拍钉住(`test/atomic-salvage-18.0.0.test.ts`,改了读数的那一行逐行登记)。别的集合字段(allowTools / scenarios / allowSkills …)照旧逐条抢救:丢坏元素只会更窄。
1878
- * 成员读键按自有属性名判:`__proto__` / `constructor` / `prototype` 任一在场 ⇒ 集合坏 ⇒ 条目整条丢(见 `credentialRefs`;zod 的 record 读键前跳过 `__proto__`、不判它的值)。
1879
- * 新的凭据引用集合必须复用这几只 schema 或由 `credentialRefs` 铸出并登记进这里(按身份判,换一只「形一样」的新 schema 不算成员)。
1880
- * 登记的是剥掉包装之后的那只 `record`(与抢救走查同一只读法 `unwrapSchema`)。
1881
- */
1882
- export declare const ATOMIC_SALVAGE: ReadonlySet<z.ZodType>;
1883
1872
  export declare const McpTransport: z.ZodDiscriminatedUnion<[z.ZodObject<{
1884
1873
  kind: z.ZodLiteral<"stdio">;
1885
1874
  command: z.ZodString;