@sema-agent/settings-schema 23.0.0 → 25.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.
- package/CHANGELOG.md +240 -0
- package/README.md +30 -3
- package/conformance/VERSION +1 -1
- package/conformance/cases/c34-skills-content-vs-manifest/expected.json +31 -17
- package/conformance/cases/c34-skills-content-vs-manifest/meta.json +1 -1
- package/conformance/cases/c36-skills-entry-without-content/expected.json +3 -66
- package/conformance/cases/c36-skills-entry-without-content/meta.json +1 -1
- package/conformance/cases/c37-skills-field-null/expected.json +9 -132
- package/conformance/cases/c37-skills-field-null/meta.json +1 -1
- package/conformance/cases/c87-a2a-credential-refs-not-partially-salvaged/expected.json +4 -12
- package/conformance/cases/c87-a2a-credential-refs-not-partially-salvaged/meta.json +1 -1
- package/dist/config-fns.d.ts +83 -27
- package/dist/config-fns.js +232 -115
- package/dist/conformance/derive.js +3 -4
- package/dist/file-store.d.ts +2 -2
- package/dist/fleet.d.ts +41 -31
- package/dist/fleet.js +63 -30
- package/dist/types.d.ts +3 -14
- package/dist/types.js +24 -34
- package/docs/API-SURFACE.md +12 -8
- package/docs/CONFORMANCE.md +1 -1
- package/docs/CONSUMER-INTEGRATION.md +56 -1
- package/llms-full.txt +13 -8
- package/llms.txt +5 -4
- package/package.json +1 -1
package/dist/config-fns.js
CHANGED
|
@@ -18,12 +18,13 @@
|
|
|
18
18
|
import { z } from "zod";
|
|
19
19
|
import { MODEL_ENTRY_REFUSAL_CODES, ModelRefusalsWire } from "./fleet.js";
|
|
20
20
|
import { UNINSPECTABLE, dataDescriptor, emptyDocument, guardedSafeParse, inspect, isAccessorDescriptor, isolatedObject, ownEntriesOf, ownRow, ownValueOf } from "./own-key-read.js";
|
|
21
|
+
import { stableStringify } from "./hash.js";
|
|
21
22
|
import { ownEnabledFlag } from "./catalog-manages.js";
|
|
22
23
|
import { isJsonArray, isPlainJsonObject, jsonShapeOf } from "./plain-json-object.js";
|
|
23
24
|
import { carriesUserinfo, secretScanForms } from "./secret-scan.js"; // package-private normalization (both scanners read it) + the userinfo judgement (not in the barrel)
|
|
24
25
|
import { sha256Hex } from "./sha256.js";
|
|
25
26
|
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 {
|
|
27
|
+
import { DOMAIN_SCHEMAS, InfraCostRates, LimitsConfig, PRIVATE_KEY_PEM_HEADER, RETIRED_DOMAINS, SkillsManifestSchema, WIRE_CARRIED_DOMAINS, containsSecretToken, isDomainName, isRetiredDomainName, renderQuotedSentence, retiredDomainSentence } from "./types.js";
|
|
27
28
|
/** Redact secret-shaped tokens from a validation MESSAGE — a zod error echoes the offending value (e.g.
|
|
28
29
|
* `received 'sk-live-…'`), so a secret pasted into the WRONG field would leak via the error string. Redacts
|
|
29
30
|
* space-spanning auth credentials (`Bearer <token>`) FIRST (the token pass can't see across the space), then
|
|
@@ -162,10 +163,11 @@ export function isRole(v) {
|
|
|
162
163
|
return typeof v === "string" && USER_ROLES.includes(v);
|
|
163
164
|
}
|
|
164
165
|
/**
|
|
165
|
-
*
|
|
166
|
+
* The FLOOR of a domain write: the minimum role any write to the domain needs. Default = `editor`; `skills` and `mcp` are raised to `publisher`
|
|
166
167
|
* because their content goes straight into the agent's system prompt / tool surface — one edit retargets
|
|
167
168
|
* the prompt of every worker × scenario that loads it (the mcp/skills design note §3.3, decision §6 Q3 从严).
|
|
168
|
-
*
|
|
169
|
+
* Any domain absent here uses {@link DEFAULT_DOMAIN_WRITE_ROLE}. Nobody reads this table directly: the one reader is
|
|
170
|
+
* {@link writeRoleFor}, which also looks at WHICH fields a write changes ({@link DOMAIN_FIELD_WRITE_ROLE}).
|
|
169
171
|
*/
|
|
170
172
|
export const DEFAULT_DOMAIN_WRITE_ROLE = "editor";
|
|
171
173
|
export const DOMAIN_WRITE_ROLE = {
|
|
@@ -180,7 +182,7 @@ export const DOMAIN_WRITE_ROLE = {
|
|
|
180
182
|
// systems drive CREDENTIAL minting/delivery/rotation (S2/S3) — the credential lifecycle is ≥ the skills tier.
|
|
181
183
|
systems: "publisher",
|
|
182
184
|
// access: DELETED in 0.6.0 (域整删,EXPERT-REDESIGN §9)。
|
|
183
|
-
// governance (治理三件,0.6.0 从 runtime 拆出): editor(EXPERT-REDESIGN §5
|
|
185
|
+
// governance (治理三件,0.6.0 从 runtime 拆出): editor(与 EXPERT-REDESIGN §5 的写角色表同步;
|
|
184
186
|
// default 即 editor,故不列条目;此注释即该裁定的落点)。
|
|
185
187
|
// entitlement governs who-can-USE-what (models/skills/mcp/budget/runtime caps) per principal — a governance +
|
|
186
188
|
// security surface (budget ceilings, bypass kill-switch) on par with systems. Same raised gate.
|
|
@@ -192,8 +194,10 @@ export const DOMAIN_WRITE_ROLE = {
|
|
|
192
194
|
prompts: "publisher",
|
|
193
195
|
// execution (0.8.0): editor — same档 as governance (治理旋钮同类;真安全边界在 service gate,
|
|
194
196
|
// client-advisory 面不值 publisher 档)。default 即 editor,故不列条目;此注释即该裁定的落点。
|
|
195
|
-
// projects (0.10.0
|
|
196
|
-
//
|
|
197
|
+
// projects (0.10.0): the floor is editor — the registry's identity fields (name, remotes, default scopes, icon, colour, archive time)
|
|
198
|
+
// are an index, an editor's job; default 即 editor,故不列条目。25.0.0: the registration's CONTENT fields (`goal`, `contextItems`, `notes`)
|
|
199
|
+
// are not an index — they ride into the system prompt and the task's workspace — and are raised field by field in
|
|
200
|
+
// {@link DOMAIN_FIELD_WRITE_ROLE}, not by raising the whole domain.
|
|
197
201
|
// limits (0.19.0): editor —— 与它的前身 runtime 域(11.0.0 retired)同档,刻意不抬 publisher:本域是纯数值
|
|
198
202
|
// 旋钮,无 prompt 注入面、无凭据、无可执行内容;真正的执法点在消费方的限额闸,发布闸(PUBLISH_MODE /
|
|
199
203
|
// 审批流)才是"要不要多一道人"的属主。default 即 editor,故不列条目;此注释即该裁定的落点。
|
|
@@ -202,9 +206,105 @@ export const DOMAIN_WRITE_ROLE = {
|
|
|
202
206
|
// Written out (not left to the default) because the default would be the WRONG answer here.
|
|
203
207
|
a2a: "publisher",
|
|
204
208
|
};
|
|
205
|
-
/**
|
|
206
|
-
|
|
207
|
-
|
|
209
|
+
/**
|
|
210
|
+
* `projects`: a registration's identity fields are an index and stay with the floor (`editor`); its CONTENT fields are what the project hands
|
|
211
|
+
* to the agent — `goal` and `notes` ride into the system prompt, `contextItems` carries folder / file entries the task's workspace and
|
|
212
|
+
* attachments are built from — the same injection surface as `prompts`, so they need `publisher`. `registeredBy` / `registeredAt` are stamped
|
|
213
|
+
* by the write port on registration; whether a caller may rewrite them is that port's rule, not a role (raising them would also block an
|
|
214
|
+
* editor from registering a project at all).
|
|
215
|
+
*/
|
|
216
|
+
const PROJECT_FIELD_WRITE_ROLE = {
|
|
217
|
+
displayName: "editor",
|
|
218
|
+
gitRemotes: "editor",
|
|
219
|
+
defaultScopes: "editor",
|
|
220
|
+
registeredBy: "editor",
|
|
221
|
+
registeredAt: "editor",
|
|
222
|
+
notes: "publisher",
|
|
223
|
+
goal: "publisher",
|
|
224
|
+
contextItems: "publisher",
|
|
225
|
+
archivedAt: "editor",
|
|
226
|
+
icon: "editor",
|
|
227
|
+
color: "editor",
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* The domains whose write role depends on WHICH fields a write changes. Same shape of use as {@link DOMAIN_WRITE_ROLE} — a package-owned table,
|
|
231
|
+
* one row per domain, an absent row means "the floor decides" — read only through {@link writeRoleFor}; the changed fields come from
|
|
232
|
+
* {@link changedWriteFields} (the one place that diffs two documents against this table).
|
|
233
|
+
*/
|
|
234
|
+
export const DOMAIN_FIELD_WRITE_ROLE = {
|
|
235
|
+
projects: { entries: "projects", fields: PROJECT_FIELD_WRITE_ROLE },
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* The minimum role to make a write that changes exactly `changedFields` in `domain`: the HIGHEST of the domain's floor ({@link DOMAIN_WRITE_ROLE},
|
|
239
|
+
* else {@link DEFAULT_DOMAIN_WRITE_ROLE}) and the role of each changed field ({@link DOMAIN_FIELD_WRITE_ROLE}). `[]` = a write that changes no
|
|
240
|
+
* field that has a role of its own — the floor alone, which is also the answer to "may this role write anything in the domain at all" (a UI
|
|
241
|
+
* deciding whether to show a write affordance). The PUT, PATCH and mint doors of a domain all ask this ONE function, with the fields
|
|
242
|
+
* {@link changedWriteFields} reports for the document they are about to store. A field name the domain's table does not have — a typo, a
|
|
243
|
+
* field of another domain, any name for a domain with no field table — is a RangeError (the answer would otherwise be the floor, a quiet
|
|
244
|
+
* lowering): a caller's mistake is loud, never an `editor`.
|
|
245
|
+
*/
|
|
246
|
+
export function writeRoleFor(domain, changedFields) {
|
|
247
|
+
let role = ownRow(DOMAIN_WRITE_ROLE, domain) ?? DEFAULT_DOMAIN_WRITE_ROLE;
|
|
248
|
+
const table = ownRow(DOMAIN_FIELD_WRITE_ROLE, domain);
|
|
249
|
+
for (const field of changedFields) {
|
|
250
|
+
const fieldRole = table === undefined ? undefined : ownRow(table.fields, field);
|
|
251
|
+
if (fieldRole === undefined) {
|
|
252
|
+
throw new RangeError(`writeRoleFor: ${JSON.stringify(String(field))} is not a field with a write role in domain "${domain}" (${table === undefined ? "the domain has no field table" : `its fields: ${Object.keys(table.fields).join(", ")}`})`);
|
|
253
|
+
}
|
|
254
|
+
if (ROLE_RANK[fieldRole] > ROLE_RANK[role])
|
|
255
|
+
role = fieldRole;
|
|
256
|
+
}
|
|
257
|
+
return role;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* The entries of one domain document as the STORE would receive them: the document read through {@link parseDomain} — the reading a write is
|
|
261
|
+
* validated with — so what {@link changedWriteFields} compares and what is persisted are one document, not two readings of the caller's object
|
|
262
|
+
* (a Proxy that lists no keys but answers the validator's reads, an accessor, a key the validator strips). Anything `parseDomain` refuses or cannot
|
|
263
|
+
* read throws; the caller turns every throw into the fail-closed answer.
|
|
264
|
+
*/
|
|
265
|
+
function writeEntriesOf(domain, table, document) {
|
|
266
|
+
const parsed = parseDomain(domain, document); // `undefined` = nothing stored yet = the domain's empty document
|
|
267
|
+
const carried = ownValueOf(parsed, table.entries);
|
|
268
|
+
if (!carried.ok || !isPlainJsonObject(carried.value))
|
|
269
|
+
throw new TypeError(`changedWriteFields: domain "${domain}" has no record of entries under "${table.entries}"`);
|
|
270
|
+
const entries = new Map();
|
|
271
|
+
for (const [id, entry] of Object.entries(carried.value)) {
|
|
272
|
+
if (!isPlainJsonObject(entry))
|
|
273
|
+
throw new TypeError(`changedWriteFields: an entry of domain "${domain}" is not an object`);
|
|
274
|
+
entries.set(id, entry);
|
|
275
|
+
}
|
|
276
|
+
return entries;
|
|
277
|
+
}
|
|
278
|
+
/** What one field of one entry holds, as a string two entries can be compared by: absent and present are different, and a value is compared by its stable JSON. */
|
|
279
|
+
function writeFieldImage(entry, field) {
|
|
280
|
+
return entry === undefined || !Object.hasOwn(entry, field) ? "-" : `=${stableStringify(entry[field])}`;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Which fields a write changes: the fields of {@link DOMAIN_FIELD_WRITE_ROLE}`[domain]` whose value differs, in ANY entry, between the stored
|
|
284
|
+
* document `before` and the document about to be stored `after` — in the table's order, each once. This is the one place two documents are
|
|
285
|
+
* diffed against the table, whatever the door: a whole-domain PUT passes the stored and the submitted document; a PATCH passes the stored
|
|
286
|
+
* document and the document {@link applyProjectPatch} returns; a mint passes the stored document and the document with the new entry.
|
|
287
|
+
* Both documents are read through {@link parseDomain}, the reading a write is validated with, so the comparison is between the documents the
|
|
288
|
+
* store would receive: store what you authorized — the parse result, not a second reading of the raw body. A field is changed when it is added
|
|
289
|
+
* (absent → present), removed (present → absent) or its value differs; a new entry changes every field it carries, a removed one every field it
|
|
290
|
+
* carried; resending a field unchanged, or the keys in another order, changes nothing. `before` `undefined` = the domain has no document yet (the
|
|
291
|
+
* only spelling of "nothing stored"). A domain with no field table ⇒ `[]` (the floor alone decides). Fail-closed on the security axis, in ONE
|
|
292
|
+
* arm: a document the domain's schema refuses or cannot read — not an object, a getter or trap that throws, a bad entry, a stored document that
|
|
293
|
+
* no longer passes — or any step of the comparison that fails ⇒ EVERY field of the table, so the write needs the highest role the table names.
|
|
294
|
+
* Never throws.
|
|
295
|
+
*/
|
|
296
|
+
export function changedWriteFields(domain, before, after) {
|
|
297
|
+
const table = ownRow(DOMAIN_FIELD_WRITE_ROLE, domain);
|
|
298
|
+
if (table === undefined)
|
|
299
|
+
return [];
|
|
300
|
+
const fields = Object.keys(table.fields);
|
|
301
|
+
const changed = inspect(() => {
|
|
302
|
+
const was = writeEntriesOf(domain, table, before);
|
|
303
|
+
const now = writeEntriesOf(domain, table, after);
|
|
304
|
+
const ids = [...new Set([...was.keys(), ...now.keys()])];
|
|
305
|
+
return fields.filter((field) => ids.some((id) => writeFieldImage(was.get(id), field) !== writeFieldImage(now.get(id), field)));
|
|
306
|
+
});
|
|
307
|
+
return changed.ok ? changed.value : fields;
|
|
208
308
|
}
|
|
209
309
|
/** The empty/defaults effective config at version 0 — what publish mode serves before the first publish.
|
|
210
310
|
* Seeds the epoch (`new Date(0)`) so it's deterministic (the wall-clock default was the original store.ts
|
|
@@ -239,24 +339,30 @@ export function refuseRetiredDomain(domain, raw) {
|
|
|
239
339
|
if (carriesFacts(raw))
|
|
240
340
|
throw new RetiredDomainError(domain);
|
|
241
341
|
}
|
|
242
|
-
/**
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
342
|
+
/**
|
|
343
|
+
* 「这个名字判哪张 schema」只有这一只判官 —— 文档面({@link parseDomain})与视图面({@link domainSeat})共用,两面对同一个名字说同一句话。
|
|
344
|
+
* A retired domain is refused by its tombstone (one sentence naming the one-time migration), not as "not a domain":
|
|
345
|
+
* 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 —
|
|
346
|
+
* before, `DOMAIN_SCHEMAS[name]` was undefined and the TypeError surfaced through the read guard as "a value could not be
|
|
347
|
+
* read", which names the wrong failure. The strict-write face hands {@link parseDomain} every key of a submitted document
|
|
348
|
+
* set, so the name is user text: it leaves through the same outgoing redaction as a warning coordinate segment.
|
|
349
|
+
*/
|
|
350
|
+
function domainSchemaOf(domain) {
|
|
246
351
|
if (isRetiredDomainName(domain))
|
|
247
352
|
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
353
|
if (!isDomainName(domain))
|
|
253
354
|
throw new Error(`"${outgoingSegment(String(domain))}" is not a config domain`);
|
|
355
|
+
return DOMAIN_SCHEMAS[domain];
|
|
356
|
+
}
|
|
357
|
+
/** Validate + fill defaults for a domain payload (or the schema's empty default when absent/invalid). */
|
|
358
|
+
export function parseDomain(domain, raw) {
|
|
359
|
+
const schema = domainSchemaOf(domain);
|
|
254
360
|
// ONLY true absence (undefined) defaults; an explicit `null` (e.g. a `config.d/<d>.json` containing JSON
|
|
255
361
|
// `null`) is corrupt input → let zod reject it ("expected object, received null"), not silently default. R4.
|
|
256
|
-
return strictParse(
|
|
362
|
+
return strictParse(schema, domain, raw === undefined ? emptyDocument() : raw);
|
|
257
363
|
}
|
|
258
364
|
/**
|
|
259
|
-
* 一次**整份严判**(域文档与 wire 上的 skills 清单共用这一只 ——
|
|
365
|
+
* 一次**整份严判**(域文档与 wire 上的 skills 清单共用这一只 —— 清单是 skills 域的线上形,读法与域文档同一只,见 {@link readViewOr}):过 ⇒ 数据;
|
|
260
366
|
* 不过 ⇒ 抛脱敏后的 ZodError(逐字段递归脱敏,不回显秘密;R13/R14);校验过程抛(含首读 `error` 时抛,见 {@link guardedSafeParse})⇒ 抛 {@link unreadableDomainError}
|
|
261
367
|
* (抛出值的文案可能带秘密,从不转述;R13)。
|
|
262
368
|
*/
|
|
@@ -439,7 +545,7 @@ function judgeKey(keySchema, key) {
|
|
|
439
545
|
* 登记的键不算(按条目在域文档里的原文坐标 `from` 判 —— models 条目上壳写的 `sema*` 是契约,不是拼错)。有 ⇒ `entry-unknown-key`,`error` 是
|
|
440
546
|
* zod 自己的 `.strict()` 会说的那种(每个持键层一条 `unrecognized_keys`,坐标相对条目,见 {@link strippedKeysError})。
|
|
441
547
|
* 比键集的那一遍读原文时抛了(第二次读才抛的访问器)⇒ `entry-unreadable`:决策面不许把读不出当没看见。
|
|
442
|
-
* 只在 {@link salvageEntries} 里调 ——
|
|
548
|
+
* 只在 {@link salvageEntries} 里调 —— 逐条丢弃只发生在视图面的逐条丢弃域;文档面与不逐条丢的域里,条目体内的
|
|
443
549
|
* 未知键照旧剥键 + `unknown-keys-dropped`。 */
|
|
444
550
|
function judgeEntry(element, entry, domain, from) {
|
|
445
551
|
const judged = judgeAgainst(element, entry, "entry-schema-invalid");
|
|
@@ -457,19 +563,26 @@ function judgeEntry(element, entry, domain, from) {
|
|
|
457
563
|
/**
|
|
458
564
|
* 从**schema 自身**派生条目集合(数组字段 / Record 字段),逐条判,坏的丢掉并逐条记账。
|
|
459
565
|
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
566
|
+
* **诊断口,不是读腿**:本函数不查 {@link DOMAIN_ENTRY_SALVAGE} / {@link DOMAIN_READ_FALLBACK} —— 它回答「这份文档里哪几条判不过、为什么」,
|
|
567
|
+
* 不回答「读方该怎么读」。读腿只在表判 `"salvage"` 的域里拿它的结果({@link readView});对 `"none"` 域直接调它照样逐条报。
|
|
568
|
+
* 把它的 `value` 当文档再交给读口,是调用方自己在 `"none"` 域丢了条目,读法没有这一步。
|
|
569
|
+
*
|
|
570
|
+
* 入参是 **schema 而不是域名**:同一个域可以有不止一种文档表示(`skills` 在 wire 上是 manifest,`SkillsManifestSchema`)——
|
|
571
|
+
* 只吃域名的抢救点会把另一种表示漏在门外。吃 schema ⇒ 每种表示同一条律,没有第二实现。
|
|
463
572
|
*
|
|
464
573
|
* 为什么从 schema 派生而不是写一张「域 → 条目字段」表:那张表是第二份真源,开新域必漏。schema 里
|
|
465
574
|
* 「这个字段是一组条目」这件事本来就写着,读它即可 —— 新域天然被覆盖,零登记动作。
|
|
466
575
|
*
|
|
576
|
+
* 🔴 **条目是对象,一张值名单是一个值**(24.0.0):条目集合 = 元素(数组元素 / Record 值)是对象(或全由对象组成的联合)的集合,见 {@link isEntrySchema}。
|
|
577
|
+
* 元素是串 / 数 / 枚举 / 字面量的集合 —— 工具名单(`allowTools` / `disallowedTools`)、范围名单(`scenarios` / `rosters`)、凭据引用(名 → env-NAME)—— 是
|
|
578
|
+
* 作者写下的**一个值**:不下钻、不逐元素剔。剔掉一个元素读出来的就不是作者写的那张名单(拒绝名单被截短 = 更松;凭据引用被截短 = 带着一半凭据去拨远端),
|
|
579
|
+
* 所以坏一个元素 ⇒ 持有它的那一条条目在上一层整条判不过、整条丢;在域顶层 ⇒ 没有可丢的条目,整域读不进。判据只读 schema 的形,不读名字、不登记身份。
|
|
580
|
+
*
|
|
467
581
|
* 🔴 **零幸存者不算「部分损坏」**:一个集合如果所有条目都坏,那它不是「部分损坏的集合」,而是**整个坏掉
|
|
468
582
|
* 的集合** —— 本函数对这种字段**一条都不丢**,原样留着让整域档位去裁。这条不是特判,是「抢救」的定义:
|
|
469
|
-
* 没有要抢救的东西。它同时把一整类 fail-open 陷阱一次性挡住 ——
|
|
470
|
-
* (
|
|
471
|
-
*
|
|
472
|
-
* 造出一个空集合**。
|
|
583
|
+
* 没有要抢救的东西。它同时把一整类 fail-open 陷阱一次性挡住 —— 一个集合**空 = 不设限**时,把「全是坏条目」的集合抢救成
|
|
584
|
+
* 空集合,等于把运维的限制悄悄删了。这里不去枚举「哪些字段空了等于放权」(枚举必漏),而是**从不凭空造出一个空集合**。
|
|
585
|
+
* (「空 = 不设限」最常见的是值名单 —— 它们根本不被逐元素抢救,见上一条;零幸存者律守的是对象集合。)
|
|
473
586
|
*
|
|
474
587
|
* 🔴 **告警不许比它诊断的东西更危险**(复审 R1 两条,红先复现):① Record 的键是用户写的,完全可能就是
|
|
475
588
|
* 一条粘错位置的凭据,所以路径里的键段过 {@link redactSecrets} 才出门(6.3.0 起经 `outgoingPath` 这一道;不变量①:secret 值永不随错误外流,
|
|
@@ -481,19 +594,19 @@ function judgeEntry(element, entry, domain, from) {
|
|
|
481
594
|
* 没有任何域专用分支),再拿抢救后的那一条去判整条。体内丢的子条目以父坐标为前缀上账(`["projects", <id>, "contextItems", 1]`),
|
|
482
595
|
* 体内压缩过的数组以全路径进位移表({@link EntryKeptIndex});整条最终仍判不过 ⇒ 整条丢,它体内的半路账一并作废(一条一个结论),
|
|
483
596
|
* 记账行的判决取**原文**的(拒句坐标是原文档的,不是抢救形里压缩过的下标)。
|
|
484
|
-
* 零幸存者律在**每一层**成立 ——
|
|
485
|
-
* (`skills[].scenarios` / `mcp.servers[].allowTools` …),抢救成 `[]` 就是把限定范围放成全开。账按文档序排(父条目丢在哪个位置,
|
|
597
|
+
* 零幸存者律在**每一层**成立 —— 体内的条目集合全坏 ⇒ 不压成空集合,那一条照原样去判(于是整条丢)。账按文档序排(父条目丢在哪个位置,
|
|
486
598
|
* 体内的子条目就排在哪个位置)。
|
|
487
599
|
*
|
|
488
600
|
* **条目好坏只有一条判据**({@link judgeEntry};22.0.0):过它自己的 schema,**且体内没有键被剥**。带未知键的条目(拼错的收紧键、比本包新的
|
|
489
601
|
* 写者写的前瞻键)是坏条目,与坏形条目同一条律处置 —— 丢它自己、`entry-dropped` 点名(词 `entry-unknown-key`)、零幸存者不丢、体内的嵌套集合先抢救。
|
|
490
602
|
* 第三个参数 `domain` 说**哪个域的扩展命名空间生效**({@link EXTENSION_NAMESPACES}:models 条目上壳写的 `sema*` 不是未知键);必填 ——
|
|
491
|
-
* 缺了就只能把壳写的每一条目录条目当带未知键丢掉,所以不是域名 ⇒ 响亮拒(TypeError),不替调用方猜。
|
|
603
|
+
* 缺了就只能把壳写的每一条目录条目当带未知键丢掉,所以不是域名 ⇒ 响亮拒(TypeError),不替调用方猜。
|
|
492
604
|
*
|
|
493
605
|
* 边界(如实登记):① 只下钻**条目**(集合的元素 / 值),不下钻顶层的普通对象字段(`models.atMention` 不是条目 —— 它里面的未知键不让任何条目丢,
|
|
494
606
|
* 照旧剥键 + `unknown-keys-dropped`);② raw 不是纯 JSON 对象、字段值与 schema 形状对不上(schema 说数组、文档给对象)⇒ 原样返回,交给整域档位裁;
|
|
495
607
|
* ③ 域级判据(重名 / 悬空 ref)不在本函数视野内 —— 丢条目救不了它们,调用方据此回落整域档位;
|
|
496
|
-
* ④ 只认 `ZodArray` / `ZodRecord`
|
|
608
|
+
* ④ 只认 `ZodArray` / `ZodRecord` 两种条目集合形、只认对象(与全由对象组成的联合)作条目 —— 别的形(元组、值名单、`z.lazy` 包着的元素等)
|
|
609
|
+
* 不抢救,退回上一层 / 整域档位(保守方向);⑤ 递归深度止于 schema
|
|
497
610
|
* (本包没有自引用 schema);`z.lazy` 包着的 schema 不展开(`unwrapSchema` 不认它)⇒ 不下钻,那一条按原样判;⑥ 被剥键的扫描与告警面同一只
|
|
498
611
|
* ({@link visitStripped}),同一个深度上界 —— 逐条丢弃域的 schema 里,能被剥键的那一层最深在第 6 段(collab 槽位成员),在上界之内。
|
|
499
612
|
*/
|
|
@@ -511,23 +624,31 @@ function salvageLayer(schema, raw, domain, origin) {
|
|
|
511
624
|
return layer.ok ? layer.value : { raw, dropped: [], shifts: [] };
|
|
512
625
|
}
|
|
513
626
|
/** 「哪些字段是一组条目」的**唯一**派生(逐条抢救 {@link salvageLayerUnsafe} 与视图面判官 {@link entryHeldStrippedKeys} 同读这一只):
|
|
514
|
-
* 根(拆掉包装层后)是对象 ⇒
|
|
515
|
-
* 它所属的条目在上一层整条判不过、整条丢。根不是对象 ⇒ 没有条目集合。只读 schema,不读文档。 */
|
|
627
|
+
* 根(拆掉包装层后)是对象 ⇒ 它的每个元素是条目({@link isEntrySchema})的数组 / Record 字段。元素不是条目的集合(值名单、凭据引用)是一个值,
|
|
628
|
+
* 不在其列 —— 坏一项 ⇒ 它所属的条目在上一层整条判不过、整条丢。根不是对象 ⇒ 没有条目集合。只读 schema,不读文档。 */
|
|
516
629
|
function entryCollectionsOf(schema) {
|
|
517
630
|
const root = unwrapSchema(schema);
|
|
518
631
|
if (!(root instanceof z.ZodObject))
|
|
519
632
|
return [];
|
|
520
633
|
return Object.entries(root.shape).flatMap(([field, fieldSchema]) => {
|
|
521
634
|
const collection = unwrapSchema(fieldSchema);
|
|
522
|
-
if (
|
|
523
|
-
return [];
|
|
524
|
-
if (collection instanceof z.ZodArray)
|
|
635
|
+
if (collection instanceof z.ZodArray && isEntrySchema(collection.element))
|
|
525
636
|
return [{ field, isArray: true, element: collection.element, keySchema: undefined }];
|
|
526
|
-
if (collection instanceof z.ZodRecord)
|
|
637
|
+
if (collection instanceof z.ZodRecord && isEntrySchema(collection.valueType))
|
|
527
638
|
return [{ field, isArray: false, element: collection.valueType, keySchema: collection.keyType }];
|
|
528
|
-
return []; //
|
|
639
|
+
return []; // 不是条目集合(值名单、普通字段):连读都不读(少触发一次访问器)
|
|
529
640
|
});
|
|
530
641
|
}
|
|
642
|
+
/** 一个集合元素的 schema 是不是**条目**:拆掉包装层后是对象,或是每个选项都是条目的联合(判别联合同,`models.roles` 的值、projects 的上下文条目)。
|
|
643
|
+
* 其余一切(串 / 数 / 枚举 / 字面量 / 嵌套的数组 / 认不出的形)⇒ 不是:那个集合是一个值,整只判。认不出就不是条目 —— 逐元素抢救是放宽方向,只给认得出的对象开门。 */
|
|
644
|
+
function isEntrySchema(schema) {
|
|
645
|
+
const s = unwrapSchema(schema);
|
|
646
|
+
if (s instanceof z.ZodObject)
|
|
647
|
+
return true;
|
|
648
|
+
if (s instanceof z.ZodUnion)
|
|
649
|
+
return s.options.every(isEntrySchema);
|
|
650
|
+
return false;
|
|
651
|
+
}
|
|
531
652
|
/** 集合字段的值 → 它的位置表;值的形与 schema 对不上(schema 说数组、文档给对象)⇒ `undefined`(不抢救,交给整域档位)。
|
|
532
653
|
* 数组走 `forEach`(不是手写 `for (i < value.length)`):它在**进入时**就钉死了长度,而重读 `value.length` 会跟着一个在校验期间
|
|
533
654
|
* 自我增殖的数组一路跑下去(病态 getter 在 zod 读字段时往同一个数组里再 push 一条)—— 抢救是尽力而为的旁路,绝不许把同步读挂死;
|
|
@@ -957,7 +1078,7 @@ function entryHeldStrippedKeys(domain, schema, raw, parsed) {
|
|
|
957
1078
|
return strippedKeysUnder(domain, raw, parsed, []).filter(({ holder }) => holder.length >= 2 && fields.has(String(holder[0])));
|
|
958
1079
|
}
|
|
959
1080
|
/**
|
|
960
|
-
* 视图面整份判官的后一半(22.0.0
|
|
1081
|
+
* 视图面整份判官的后一半(22.0.0;逐条丢弃域,见 {@link parseForView}):文档已过 schema,但有条目体内的键被剥 ⇒
|
|
961
1082
|
* 抛 {@link strippedKeysError}(从域根起的坐标);比键集时读不出 ⇒ 抛 {@link unreadableDomainError}。调用方接住它走逐条抢救(带未知键的条目丢它自己,
|
|
962
1083
|
* {@link judgeEntry});救不活(零幸存者、丢了之后引用悬空)⇒ 这就是「整份读不进」的那个原错 —— 不会退回剥键照装。
|
|
963
1084
|
*/
|
|
@@ -1095,18 +1216,44 @@ export function parseDomainLoud(domain, raw, onWarning) {
|
|
|
1095
1216
|
* 读改写(读存量、改、整份写回)的「现状」也不许读它 —— 抢救读出再写回,被丢的条目就成了删除。
|
|
1096
1217
|
*/
|
|
1097
1218
|
export function parseDomainSalvaged(domain, raw, onWarning) {
|
|
1098
|
-
return
|
|
1219
|
+
return readView(domainSeat(domain), raw, onWarning);
|
|
1220
|
+
}
|
|
1221
|
+
/** 一个域的文档座位。退役域名 / 不是域名(JS 调用方递来的任意串)⇒ 与 {@link parseDomain} 同一只判官、同一句拒({@link domainSchemaOf})。 */
|
|
1222
|
+
function domainSeat(domain) {
|
|
1223
|
+
return { domain, schema: domainSchemaOf(domain) };
|
|
1224
|
+
}
|
|
1225
|
+
/** wire 上的 skills 清单的座位(`readEffectiveWire`)。 */
|
|
1226
|
+
const SKILLS_MANIFEST_SEAT = { domain: "skills", schema: SkillsManifestSchema };
|
|
1227
|
+
/** 视图面读一份文档(整份判 → 按 {@link DOMAIN_ENTRY_SALVAGE} 逐条抢救 → 未知键告警);读不进 ⇒ 抛第一次严判的原错。{@link parseDomainSalvaged} 的本体。 */
|
|
1228
|
+
function readView(seat, raw, onWarning) {
|
|
1229
|
+
return readDomainDocument(seat.domain, raw, onWarning, (doc) => parseForView(seat, doc), (unreadable) => parseSalvaged(seat, raw, unreadable, onWarning));
|
|
1099
1230
|
}
|
|
1100
1231
|
/**
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1103
|
-
*
|
|
1104
|
-
* 不逐条丢的域与文档面({@link parseDomainLoud})只用 `parseDomain`:那里一条条目都不丢,条目体内的未知键照旧剥键 + 告警。
|
|
1232
|
+
* 视图面读一份文档,**读不进时按 {@link DOMAIN_READ_FALLBACK} 答**:`"throw"` ⇒ 原错抛出;`"default"` ⇒ schema 默认 + 一条 `domain-defaulted`。
|
|
1233
|
+
* `buildEffective` 的每个域与 `readEffectiveWire` 的 skills 清单都经这一只 —— 两张表各问一次,同一个域在每条读腿上同一个答案(24.0.0 前清单是单列一臂,
|
|
1234
|
+
* 恒逐条抢救、恒默认化,不读这两张表)。好文档的路径一字不动。
|
|
1105
1235
|
*/
|
|
1106
|
-
function
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1236
|
+
function readViewOr(seat, raw, onWarning) {
|
|
1237
|
+
try {
|
|
1238
|
+
return readView(seat, raw, onWarning);
|
|
1239
|
+
}
|
|
1240
|
+
catch (e) {
|
|
1241
|
+
if (DOMAIN_READ_FALLBACK[seat.domain] === "throw")
|
|
1242
|
+
throw e;
|
|
1243
|
+
onWarning?.({ domain: seat.domain, kind: "domain-defaulted", error: e });
|
|
1244
|
+
return strictParse(seat.schema, seat.domain, emptyDocument()); // schema default — always valid
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* 视图面的**整份判官**(22.0.0):整份严判(缺席 —— 只有 `undefined` —— 按空文档判,与 {@link parseDomain} 同一条),外加 —— 在逐条丢弃域
|
|
1249
|
+
* ({@link DOMAIN_ENTRY_SALVAGE} 判 `"salvage"`)里 —— 「没有条目体内被剥的键」({@link refuseEntryHeldStrippedKeys})。视图面判条目只有一条律
|
|
1250
|
+
* ({@link judgeEntry}:过 schema 且体内没有键被剥),整份文档也按同一条律判:否则零幸存者的集合(一条都救不活 ⇒ 抢救一条不丢)就会剥键照装,
|
|
1251
|
+
* 正是本律要关掉的那条放宽。不逐条丢的域与文档面({@link parseDomainLoud})只做整份严判:那里一条条目都不丢,条目体内的未知键照旧剥键 + 告警。
|
|
1252
|
+
*/
|
|
1253
|
+
function parseForView(seat, raw) {
|
|
1254
|
+
const parsed = strictParse(seat.schema, seat.domain, raw === undefined ? emptyDocument() : raw);
|
|
1255
|
+
if (DOMAIN_ENTRY_SALVAGE[seat.domain] === "salvage")
|
|
1256
|
+
refuseEntryHeldStrippedKeys(seat.domain, seat.schema, raw, parsed, seat.domain);
|
|
1110
1257
|
return parsed;
|
|
1111
1258
|
}
|
|
1112
1259
|
/**
|
|
@@ -1128,10 +1275,11 @@ function readDomainDocument(domain, raw, onWarning, parse, whenUnreadable) {
|
|
|
1128
1275
|
/** {@link parseDomainSalvaged} 的第 2 / 3 步(整域 parse 已经失败):能救就救,救不了就抛 `unreadable`(第 1 步的原错)。
|
|
1129
1276
|
* 档位判 `!== "salvage"`(不是 `=== "none"`):一个不是域的名字(JS 调用方 / 写入席收到的任意键)查表得到 `undefined` 或原型链上的东西,
|
|
1130
1277
|
* 照样不抢救 —— 只有表里白纸黑字的 `"salvage"` 才开这扇门。 */
|
|
1131
|
-
function parseSalvaged(
|
|
1278
|
+
function parseSalvaged(seat, raw, unreadable, onWarning) {
|
|
1279
|
+
const { domain } = seat;
|
|
1132
1280
|
if (DOMAIN_ENTRY_SALVAGE[domain] !== "salvage")
|
|
1133
1281
|
throw unreadable;
|
|
1134
|
-
const { parsed, salvage } = salvageThenParse(
|
|
1282
|
+
const { parsed, salvage } = salvageThenParse(seat.schema, domain, raw, (doc) => parseForView(seat, doc), unreadable);
|
|
1135
1283
|
if (onWarning) {
|
|
1136
1284
|
// 坐标律(S-323b):一条告警用运维手里那份文档的坐标。`entry-dropped` 是本层(salvage)铸的,用的就是本层入参那份文档的坐标 ⇒ 原样出门;
|
|
1137
1285
|
// 未知键扫描是对压缩后文档的诊断,但它报的坐标不经任何压缩过的集合(22.0.0:集合条目体内的被剥键让那一条丢 —— 压缩后的文档条目体内没有被剥的键,
|
|
@@ -1143,7 +1291,7 @@ function parseSalvaged(domain, raw, unreadable, onWarning) {
|
|
|
1143
1291
|
return parsed;
|
|
1144
1292
|
}
|
|
1145
1293
|
/**
|
|
1146
|
-
* 逐条抢救的**那一步**(
|
|
1294
|
+
* 逐条抢救的**那一步**({@link parseSalvaged} 的本体;每个座位 —— 域文档与 wire 上的 skills 清单 —— 都经它,一条律一个调用点):整份严判已经失败
|
|
1147
1295
|
* (校验不过,或校验过程抛 —— 同一条臂:{@link salvageEntries} 逐条判,抛的那一条记 `entry-unreadable` 丢它自己)之后,丢掉坏条目再严判一次。
|
|
1148
1296
|
* 什么都没丢 / 丢了仍读不进(条目之外还有毛病:重名 / 悬空 ref / 域级判据;零幸存者的集合里还留着带未知键的条目;或抢救后的文档在重判时读不出)⇒
|
|
1149
1297
|
* 抛 `unreadable`(第一次严判的原错)—— 一个文档一个结论,没救活就不留「丢了某条」的半路叙述。`domain` = 哪个域的扩展命名空间生效(见 {@link salvageEntries})。
|
|
@@ -1176,12 +1324,16 @@ function announceUnknownKeys(domain, raw, parsed, emit) {
|
|
|
1176
1324
|
* `"throw"` = keep fail-loud (defaulting would LOOSEN gates or destructively apply — worse than an outage,
|
|
1177
1325
|
* consumers fail-static on last-good). A `satisfies Record<DomainName,…>` forces every FUTURE domain to make
|
|
1178
1326
|
* this call explicitly (compile error until it's classified). Per-domain rationale:
|
|
1179
|
-
* -
|
|
1327
|
+
* - **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
|
|
1328
|
+
* reason) is also `"throw"` here — its empty default widens the same way, for every reader at once. `scenarios` / `plugins` / `skills`.
|
|
1329
|
+
* - models/mcp/systems/collab: additive capability catalogs — empty = the
|
|
1180
1330
|
* capability disappears (fail-closed), no gate is lost.
|
|
1181
1331
|
* - scenarios: THROW (23.0.0) — an empty `scenarios` revives every built-in scenario an entry overrode, widening the tool surface of each;
|
|
1182
1332
|
* defaulting would hand that to every reader that has no candidate gate. {@link DOMAIN_ENTRY_SALVAGE} judges the domain `"none"` for the same
|
|
1183
1333
|
* reason, and a `"none"` domain that then defaulted would be the same loosening one level up (one bad entry ⇒ ALL overrides gone).
|
|
1184
1334
|
* - plugins: THROW (23.0.0) — an empty `plugins` drops the hooks (guards among them) the references carried; same reasoning as `scenarios`.
|
|
1335
|
+
* - 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
|
|
1336
|
+
* 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.
|
|
1185
1337
|
* - hosts: empty host registry = no auto-placement targets (availability-only); self-registration re-lands
|
|
1186
1338
|
* entries as approved:false = 待批 (fail-closed).
|
|
1187
1339
|
* - rosters: THROW — a lost roster makes resolveEffectiveForWorker fall back to the FULL models catalog
|
|
@@ -1203,7 +1355,7 @@ function announceUnknownKeys(domain, raw, parsed, emit) {
|
|
|
1203
1355
|
export const DOMAIN_READ_FALLBACK = {
|
|
1204
1356
|
models: "default",
|
|
1205
1357
|
rosters: "throw",
|
|
1206
|
-
skills: "
|
|
1358
|
+
skills: "throw", // 24.0.0:空 skills = 被中心按名覆盖的出厂技能全部回位(带回它们自己的 allow 名单),不是 fail-closed;与 DOMAIN_ENTRY_SALVAGE 的 none 同一理由
|
|
1207
1359
|
mcp: "default",
|
|
1208
1360
|
plugins: "throw", // 23.0.0:空 plugins = 引用承运的 hooks(守卫)全缺席,不是 fail-closed;与 DOMAIN_ENTRY_SALVAGE 的 none 同一理由
|
|
1209
1361
|
scenarios: "throw", // 23.0.0:空 scenarios = 覆盖过的内建场景全部回位(更宽的工具面),不是 fail-closed;与 DOMAIN_ENTRY_SALVAGE 的 none 同一理由
|
|
@@ -1236,7 +1388,9 @@ export const DOMAIN_READ_FALLBACK = {
|
|
|
1236
1388
|
* (domain top level, a top-level plain object field) is still stripped and named (`unknown-keys-dropped`).
|
|
1237
1389
|
* `"none"` = never drop a single entry: the first bad entry makes the whole domain unreadable. An unknown key inside an entry of such a
|
|
1238
1390
|
* domain is stripped and named, as before 22.0.0 — those domains drop nothing, so the strip warning is the reader's signal.
|
|
1239
|
-
* (23.0.0: `scenarios` and `plugins` joined the seven — their entries' absence widens; see the judgment below.)
|
|
1391
|
+
* (23.0.0: `scenarios` and `plugins` joined the seven, 24.0.0: `skills` — their entries' absence widens; see the judgment below.)
|
|
1392
|
+
* 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
|
|
1393
|
+
* holding it — never thinned element by element (24.0.0; see `salvageEntries`).
|
|
1240
1394
|
* A `satisfies Record<DomainName,…>` forces every FUTURE domain to answer this explicitly (compile error until classified).
|
|
1241
1395
|
*
|
|
1242
1396
|
* **View face only.** The document face never salvages: `parseDomain` / `validateDomain` / `writeDomainFile` judge the whole
|
|
@@ -1249,10 +1403,13 @@ export const DOMAIN_READ_FALLBACK = {
|
|
|
1249
1403
|
* 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"`:
|
|
1250
1404
|
* 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
|
|
1251
1405
|
* domain adds its row AND its judgment).
|
|
1252
|
-
* - models/
|
|
1253
|
-
* one capability gone (fail-closed).
|
|
1254
|
-
*
|
|
1255
|
-
* and the zero-survivor law (never mint an empty collection
|
|
1406
|
+
* - models/mcp/systems/collab: capability / content catalogs and grants — a dropped entry is
|
|
1407
|
+
* one capability gone (fail-closed). The value lists these entries carry (`allowTools`, `scenarios`, `rosters`, `callsWorkers`, …) are
|
|
1408
|
+
* read whole: one bad element drops the entry that holds it (one capability gone), never a shorter list; nested OBJECT collections
|
|
1409
|
+
* (collab slots / members) are entries in their own right, and the zero-survivor law (never mint an empty collection) holds at every level.
|
|
1410
|
+
* - 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.
|
|
1411
|
+
* 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
|
|
1412
|
+
* the author wrote. The wire manifest is the same domain: it reads both tables through the same reader as the domain document.
|
|
1256
1413
|
* - 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
|
|
1257
1414
|
* 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
|
|
1258
1415
|
* misspelt or forward-looking key.
|
|
@@ -1278,13 +1435,13 @@ export const DOMAIN_READ_FALLBACK = {
|
|
|
1278
1435
|
* - execution: NONE — a dropped lane / public key changes the execution mandate (放权,不许).
|
|
1279
1436
|
* - limits: NONE — a dropped allowlist row changes a published ceiling (the domain is the one publishing seat of those ceilings).
|
|
1280
1437
|
* - 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
|
|
1281
|
-
* credential references (`headerRefs`) are
|
|
1438
|
+
* credential references (`headerRefs`) are a value collection: a bad reference drops the whole peer, never the reference
|
|
1282
1439
|
* alone (a peer kept with half of its credentials is the wrong failure direction). */
|
|
1283
1440
|
export const DOMAIN_ENTRY_SALVAGE = {
|
|
1284
1441
|
models: "salvage", // 留:条目 = 一个目录模型(及 `roles` 里的一个角色覆盖);缺席 = 少一个模型 / 一个角色回落到缺省 —— 选路变了,可达面没变(被引用的模型缺席 ⇒ 引用悬空 ⇒ 整域缺省,既有律)
|
|
1285
1442
|
rosters: "none", // 收:条目 = 一台 worker 的模型名册;缺席 ⇒ 该 worker 回落到整份目录 = 放宽
|
|
1286
|
-
skills: "
|
|
1287
|
-
mcp: "salvage", // 留:条目 = 一台工具源;缺席 = 该台不挂载 —— 已知缺口:名字不再被部署占位(
|
|
1443
|
+
skills: "none", // 收:条目 = 按名覆盖出厂技能的中心技能(带它自己的工具 allow / deny 名单);缺席 = 同名出厂技能回位(带回它的 allow 名单、丢掉中心的 deny 名单)= 放宽
|
|
1444
|
+
mcp: "salvage", // 留:条目 = 一台工具源;缺席 = 该台不挂载 —— 已知缺口:名字不再被部署占位(请求侧同名注入只在读方放开它的部署:单用户、未锁、合规允许),见 CHANGELOG 已知限制
|
|
1288
1445
|
plugins: "none", // 收:条目 = 可执行面的来源引用,hooks(含 PreToolUse / PermissionRequest 守卫)随引用走;缺席 = 守卫缺席 = 放宽
|
|
1289
1446
|
scenarios: "none", // 收:条目 = 覆盖内建场景名的工具面声明;缺席 = 同名内建(更宽的工具面)复活 = 放宽
|
|
1290
1447
|
systems: "salvage", // 留:条目 = 一个外部系统的凭据与可调 worker 名单(授权);缺席 = 少一份授权
|
|
@@ -1297,7 +1454,7 @@ export const DOMAIN_ENTRY_SALVAGE = {
|
|
|
1297
1454
|
projects: "salvage", // 留:条目 = 一条项目登记(加性登记簿,不是准入门);缺席 = 少一份默认记忆 scope 的种子(消费方查表 miss 不 fail)
|
|
1298
1455
|
prompts: "none", // 收:条目受 digest 约束;缺席 = digest 不再成立,或范围文本替换掉某台 worker 的 artifact(是替换不是收窄)
|
|
1299
1456
|
limits: "none", // 收:条目 = 已发布上限的一行;缺席 = 发布的天花板变了(本域是这些上限的唯一发布位)
|
|
1300
|
-
a2a: "salvage", // 留:条目 = 一个出站对端;缺席 = 少一个对端(
|
|
1457
|
+
a2a: "salvage", // 留:条目 = 一个出站对端;缺席 = 少一个对端(凭据引用是值集合、整体判;名字占位同 mcp,见 CHANGELOG 已知限制)
|
|
1301
1458
|
};
|
|
1302
1459
|
/**
|
|
1303
1460
|
* Merge every domain into the effective config a consumer pulls. Shared by all store impls.
|
|
@@ -1311,21 +1468,11 @@ export function buildEffective(version, getRaw, updatedAt, onWarning) {
|
|
|
1311
1468
|
// 墓碑先判:一份没迁的retired 域文档意味着这个 scope 的存量还没过一次性迁移 —— 拿剩下的域拼一份 effective 等于静默丢掉它的事实。
|
|
1312
1469
|
for (const retired of Object.keys(RETIRED_DOMAINS))
|
|
1313
1470
|
refuseRetiredDomain(retired, getRaw(retired));
|
|
1314
|
-
// 每个域同一只读法(12.3.0
|
|
1315
|
-
//
|
|
1316
|
-
// `"throw"` ⇒ 原错抛出;`"default"` ⇒ schema 默认 + `domain-defaulted
|
|
1317
|
-
//
|
|
1318
|
-
const parseOr = (domain, raw) =>
|
|
1319
|
-
try {
|
|
1320
|
-
return parseDomainSalvaged(domain, raw, onWarning);
|
|
1321
|
-
}
|
|
1322
|
-
catch (e) {
|
|
1323
|
-
if (DOMAIN_READ_FALLBACK[domain] === "throw")
|
|
1324
|
-
throw e;
|
|
1325
|
-
onWarning?.({ domain, kind: "domain-defaulted", error: e });
|
|
1326
|
-
return parseDomain(domain, undefined); // schema default — always valid
|
|
1327
|
-
}
|
|
1328
|
-
};
|
|
1471
|
+
// 每个域同一只读法(12.3.0 起;24.0.0 起 wire 上的 skills 清单也是这一只):{@link readViewOr} —— 视图面读(整域 parse → 按 DOMAIN_ENTRY_SALVAGE
|
|
1472
|
+
// 逐条抢救 → 未知键告警)读不进 ⇒ 只剩**整域读不进**这一个问题,答案只看 DOMAIN_READ_FALLBACK(决策表与逐域理由见那张表):
|
|
1473
|
+
// `"throw"` ⇒ 原错抛出;`"default"` ⇒ schema 默认 + `domain-defaulted`。哪个域走哪一档不写在下面的行上,行只说「读这个域」。
|
|
1474
|
+
// 好配置的路径一字不动(同一次严判,同一份字节)。
|
|
1475
|
+
const parseOr = (domain, raw) => readViewOr(domainSeat(domain), raw, onWarning);
|
|
1329
1476
|
return {
|
|
1330
1477
|
version,
|
|
1331
1478
|
updatedAt,
|
|
@@ -1365,9 +1512,10 @@ export function buildEffective(version, getRaw, updatedAt, onWarning) {
|
|
|
1365
1512
|
* an open-world key.
|
|
1366
1513
|
*
|
|
1367
1514
|
* `skills` is the ONE wire divergence: on the wire it is a MANIFEST(content → contentHash,
|
|
1368
|
-
* {@link SkillsManifest}),so the full skills-domain schema would
|
|
1369
|
-
*
|
|
1370
|
-
*
|
|
1515
|
+
* {@link SkillsManifest}),so the full skills-domain schema would MISREAD every legal manifest (each entry would read as
|
|
1516
|
+
* `content: ""` with `contentHash` stripped as an unknown key) — it validates against
|
|
1517
|
+
* {@link SkillsManifestSchema} instead, through the SAME reader as every domain (24.0.0, {@link readViewOr}): the skills domain's two tables
|
|
1518
|
+
* answer for the manifest too (`"none"` + `"throw"` ⇒ one unreadable manifest entry makes the payload unreadable), and only `undefined` is absence.
|
|
1371
1519
|
*
|
|
1372
1520
|
* 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 —
|
|
1373
1521
|
* absent on the wire ⇒ absent in the result (an older producer does not know `a2a`; `prompts` is absent whenever nothing is published), present ⇒ the
|
|
@@ -1407,20 +1555,16 @@ export function readEffectiveWire(raw, onWarning) {
|
|
|
1407
1555
|
if (typeof r.version !== "number" || !Number.isFinite(r.version))
|
|
1408
1556
|
throw new Error("effective wire payload has no numeric version");
|
|
1409
1557
|
const updatedAt = typeof r.updatedAt === "string" ? r.updatedAt : "";
|
|
1410
|
-
// skills redirected to undefined: buildEffective must never
|
|
1411
|
-
//
|
|
1558
|
+
// skills redirected to undefined: buildEffective must never judge the manifest with the domain schema (every legal manifest entry would read
|
|
1559
|
+
// as an entry without `content` carrying an unknown `contentHash`); the manifest is judged below by the SAME reader with its own seat.
|
|
1412
1560
|
// prompts likewise redirected(#100):on the wire it is the published form `EffectivePromptsWire`(`{schemaVersion: 2, artifact}`,
|
|
1413
1561
|
// the one artifact selected for the pulling worker — never the storage shape), judged by the CONSUMER(that shape, then the engine's
|
|
1414
1562
|
// verify). The read leg must not parse it with the storage schema: a bad prompts value would be degraded to "absent" here and read
|
|
1415
1563
|
// downstream as "the center withdrew its layer" — the consumer's judge refuses it loudly instead. verbatim, by presence(见 return)。
|
|
1416
1564
|
const built = buildEffective(r.version, (d) => (d === "skills" || d === "prompts" ? undefined : r[d]), updatedAt, onWarning);
|
|
1417
1565
|
// retired 域名不是 open-world 的未知键:墓碑已在 buildEffective 里判过(带事实 ⇒ 抛),剩下的 `{}` 没有可承运的东西。
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
if (onWarning)
|
|
1421
|
-
for (const w of manifest.warnings)
|
|
1422
|
-
onWarning(w);
|
|
1423
|
-
const skills = manifest.skills;
|
|
1566
|
+
// skills 清单:skills 域的线上形,与域文档同一只读法、同两张表(SKILLS_MANIFEST_SEAT)
|
|
1567
|
+
const skills = readViewOr(SKILLS_MANIFEST_SEAT, r.skills, onWarning);
|
|
1424
1568
|
// Open-world passthrough: keys that are neither validated domains nor the envelope fields ride verbatim.
|
|
1425
1569
|
// `hasOwnProperty.call(built, k)`,**不是** `k in built`(S-332):`in` 会一路问到 `Object.prototype`,
|
|
1426
1570
|
// 于是 `constructor` / `toString` / `hasOwnProperty` / `__proto__` 这些**原型链上的名字**作未知顶层键时
|
|
@@ -1440,33 +1584,6 @@ export function readEffectiveWire(raw, onWarning) {
|
|
|
1440
1584
|
}
|
|
1441
1585
|
/** 一个顶层键是不是承运表里的域(读名字,不读值)。 */
|
|
1442
1586
|
const isWireCarriedDomain = (k) => WIRE_CARRIED_DOMAINS.includes(k);
|
|
1443
|
-
/**
|
|
1444
|
-
* wire 上 skills 清单的读法 —— **与非门控域同一臂**,只是判的是清单 schema({@link SkillsManifestSchema}):整份严判({@link strictParse})→ 读不进
|
|
1445
|
-
* (校验不过,或校验器自己抛 —— 合法 JSON 里的怪形值、嵌入方对象的 getter / 陷阱 —— 同一条臂)⇒ 逐条抢救({@link salvageThenParse}:坏条目丢它自己 + `entry-dropped`,
|
|
1446
|
-
* 其余合法条目保留;零幸存者不凭空造空集合)→ 仍读不进 ⇒ 整份退默认(空清单)+ `domain-defaulted`(`error` = 第一次严判的原错:脱敏的 ZodError,或包自己那一句的 TypeError)。
|
|
1447
|
-
* 缺席 ⇒ 按包自己造的空文档判(`COPY_PROTOTYPE`,读不到污染值)。告警交回给调用方发。
|
|
1448
|
-
*/
|
|
1449
|
-
function readSkillsManifest(raw) {
|
|
1450
|
-
// 整份判与视图面域读同一条律(22.0.0;skills 是逐条丢弃域,清单是它的线上形):过 schema,且清单条目体内没有被剥的键 —— 有 ⇒ 走逐条抢救,带未知键的条目丢它自己。
|
|
1451
|
-
const parse = (doc) => {
|
|
1452
|
-
const parsed = strictParse(SkillsManifestSchema, "skills", doc);
|
|
1453
|
-
refuseEntryHeldStrippedKeys("skills", SkillsManifestSchema, doc, parsed, "skills");
|
|
1454
|
-
return parsed;
|
|
1455
|
-
};
|
|
1456
|
-
try {
|
|
1457
|
-
return { skills: parse(raw ?? emptyDocument()), warnings: [] };
|
|
1458
|
-
}
|
|
1459
|
-
catch (unreadable) {
|
|
1460
|
-
try {
|
|
1461
|
-
const { parsed, salvage } = salvageThenParse(SkillsManifestSchema, "skills", raw, parse, unreadable);
|
|
1462
|
-
return { skills: parsed, warnings: salvage.dropped.map((d) => entryDroppedWarning("skills", d)) };
|
|
1463
|
-
}
|
|
1464
|
-
catch {
|
|
1465
|
-
// 救不回 ⇒ 告警带第一次严判的原错(salvageThenParse 只重抛它;salvageEntries 是总的)—— 在结构上就是它,不靠「被捕获的恰好是它」
|
|
1466
|
-
return { skills: { skills: [] }, warnings: [{ domain: "skills", kind: "domain-defaulted", error: unreadable }] };
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
1587
|
/** 档位组→引擎单表的唯一解析点(0.9.0)。返回 ACTIVE 档位组的绑定表(剔除未绑档),即 core
|
|
1471
1588
|
* `RunnerDeps.tiers` 要吃的那张单表——组切换=web-admin 换这张表下发,零新引擎机制。无 active 组/未命中/
|
|
1472
1589
|
* 组内一档未绑 → `undefined`(引擎档位层恒惰性,与「未配 tiers」逐字同义)。消费方(web-admin /effective
|