@sema-agent/settings-schema 31.1.0 → 33.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 (68) hide show
  1. package/CHANGELOG.md +917 -0
  2. package/README.md +103 -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/center-refs.d.ts +1 -1
  11. package/dist/center-refs.js +1 -1
  12. package/dist/cli.d.ts +4 -1
  13. package/dist/cli.js +8 -3
  14. package/dist/config-dir-migration.d.ts +17 -1
  15. package/dist/config-dir-migration.js +89 -31
  16. package/dist/config-fns.d.ts +31 -4
  17. package/dist/config-fns.js +180 -24
  18. package/dist/config-root-documents.js +1 -1
  19. package/dist/conformance/contract-adapter.js +18 -1
  20. package/dist/conformance/warnings.d.ts +1 -1
  21. package/dist/conformance/warnings.js +8 -2
  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/fleet.d.ts +5 -5
  29. package/dist/fleet.js +4 -3
  30. package/dist/hooks-config.d.ts +47 -23
  31. package/dist/hooks-config.js +93 -134
  32. package/dist/hooks.d.ts +26 -22
  33. package/dist/hooks.js +17 -8
  34. package/dist/host-path.d.ts +9 -5
  35. package/dist/host-path.js +9 -20
  36. package/dist/index.d.ts +2 -0
  37. package/dist/index.js +2 -0
  38. package/dist/ip-address.d.ts +19 -0
  39. package/dist/ip-address.js +28 -0
  40. package/dist/loopback.d.ts +3 -11
  41. package/dist/loopback.js +11 -12
  42. package/dist/mcp-request-entry.js +4 -6
  43. package/dist/migration-receipt.d.ts +1 -1
  44. package/dist/migration-receipt.js +1 -1
  45. package/dist/one-time-migrations.d.ts +1 -1
  46. package/dist/one-time-migrations.js +257 -62
  47. package/dist/plain-json-object.d.ts +5 -8
  48. package/dist/plain-json-object.js +5 -8
  49. package/dist/read-sentences.d.ts +66 -0
  50. package/dist/read-sentences.js +85 -0
  51. package/dist/record-seat.d.ts +35 -0
  52. package/dist/record-seat.js +97 -0
  53. package/dist/reserved-member-name.d.ts +8 -3
  54. package/dist/reserved-member-name.js +10 -3
  55. package/dist/retired-envs.js +10 -0
  56. package/dist/retired-form.d.ts +2 -0
  57. package/dist/retired-form.js +4 -0
  58. package/dist/safety-merge-spec.d.ts +11 -3
  59. package/dist/safety-merge-spec.js +3 -2
  60. package/dist/types.d.ts +405 -113
  61. package/dist/types.js +135 -76
  62. package/docs/API-SURFACE.md +25 -6
  63. package/docs/CC-DIVERGENCE.md +11 -2
  64. package/docs/CONFORMANCE.md +4 -4
  65. package/docs/CONSUMER-INTEGRATION.md +185 -6
  66. package/llms-full.txt +35 -20
  67. package/llms.txt +15 -8
  68. package/package.json +7 -6
@@ -1,3 +1,4 @@
1
+ import { type DroppedEntryIdentity } from "./config-fns.js";
1
2
  import { type ConfigDDocumentName } from "./config-d-file.js";
2
3
  import { type MigrationReceipt } from "./one-time-migrations.js";
3
4
  /** 注入的 I/O(本模块不碰 `node:fs`)。`writeFileAtomic` 必须原子(写临时文件再改名):半写的域文档比旧文档更糟。 */
@@ -7,13 +8,16 @@ export interface ConfigDirectoryIo {
7
8
  writeFileAtomic(path: string, text: string): Promise<void>;
8
9
  }
9
10
  /** 一条拒绝 —— 迁移步的拒(收据 `refused`)与整域终判的拒**同一套形**:`migration`(整域终判拒为 `null`)/ `document` / `path`(相对该域文档,出门形)/ `appliedAs: "refused"` / `reason`。
10
- * 句子来自本包唯一的脱敏器,坐标段与句子都是出门形、不带值。 */
11
+ * 句子来自本包唯一的脱敏器,坐标段与句子都是出门形、不带值。
12
+ * `identity`(可缺,加性):坐标落在某一条条目体内(`<集合字段>.<下标>…`)时那一条的身份 —— 连接器 / worker / 模型的名字(只带可披露的名与 id,与读腿告警同一只读法 `readEntryIdentity`),
13
+ * 坐标本身只给下标,运维拿它找到「是哪一条」;坐标不在条目下(域级的键、整份文档)⇒ 键缺席。 */
11
14
  export type ConfigDirectoryRefusal = {
12
15
  readonly migration: string | null;
13
16
  readonly document: string;
14
17
  readonly path: string;
15
18
  readonly appliedAs: "refused";
16
19
  readonly reason: string;
20
+ readonly identity?: DroppedEntryIdentity;
17
21
  };
18
22
  export type ConfigDirectoryMigration = {
19
23
  readonly kind: "unreadable";
@@ -46,6 +50,18 @@ export interface MigrateConfigDirectoryOptions {
46
50
  readonly io: ConfigDirectoryIo;
47
51
  /** 只判、不写:有改动且整域判得过 ⇒ `pending`。默认 `false`。 */
48
52
  readonly check?: boolean;
53
+ /**
54
+ * 整域终判判**哪些**文档(可选入参,缺省 = 此前的行为)。**这不是兼容开关** —— 两个调用方问的是两个不同的问题,各自要的是自己那一问的答案:
55
+ * · `"changed"`(缺省)—— 问「**迁移有没有把它改坏**」:只判迁移改过的文档(要写回的那一份必须读得进);迁移没碰的文档读不读得进是读者的事。引擎起服对本地 `config.d`
56
+ * 的迁移问的是这一问:一份陈旧的文档不该挡住同目录里别的文档的迁移(同一个目录里别的可迁文档照迁,陈旧的那份由读腿按它的墓碑 / 档位处置);
57
+ * · `"present"` —— 问「**这个目录现在干不干净**」:在场的**每一份**覆盖面内文档都判(含 retired 域:带事实的墓碑文档读侧拒,这里同拒),判官是文档面那几只
58
+ * (`parseDomain` / `parseRemoteExecDocument` / 墓碑判 `refuseRetiredDomain`,不另写第二份判形)。不过 ⇒ `refused`、一字不写,`refused[]` 点名文档与坐标、说读腿会怎么处置它、
59
+ * 出路是手改后重跑。命令行 `migrate`(`--check` 与真跑都传它)问的是这一问:运维跑完它不该带着一份文档面判不过的文档上线。
60
+ * 判官是文档面那一只(`parseDomain`),它与读腿(视图面)两个方向上不同,这一问的答案因此不等于「读腿读不读得干净」(已知的边):
61
+ * 比读腿宽 —— 条目只因带读侧不认识的键,文档面剥键受理:视图面丢那一条,集合里每一条都这样(零幸存者)时整域退缺省(`models` 读成空目录)/ 整域拒,这一问仍答「干净」;
62
+ * 比读腿严 —— 逐条丢弃域里一条 schema 不过的条目:视图面只丢它、其余照读,这一问答 `refused`。
63
+ */
64
+ readonly judge?: "changed" | "present";
49
65
  }
50
66
  export interface MigrateConfigDocumentsOptions {
51
67
  /** 覆盖面:调用方读的文档名集 —— 与 {@link MigrateConfigDirectoryOptions.documents} 同一个词、同一个律(覆盖面内没给的文档 = 从未设过;覆盖面外的键不读、不判、不进结果;拼错的名字 ⇒ 抛 `TypeError`)。 */
@@ -14,7 +14,10 @@
14
14
  * ## 结果是一个闭集({@link ConfigDirectoryMigration}),调用方穷举
15
15
  * · `unreadable` —— 读不了目录 / 某份文件,或某份文档是坏文件(空 / 纯空白 / 坏 JSON / 不是 JSON 对象,与 `FileConfigStore` 同一只判、同一句)。一字不写。
16
16
  * · `no-documents`—— 覆盖面内一份文档都没找到;带回目录清单 `entries`(调用方自己判这是「填错了目录」还是「真空的新目录」)。一字不写。
17
- * · `refused` —— 迁移步拒(收据 `refused`:要猜才改得动的形)**或**要写回的文档整域读不进(整域终判:名字 / 路由唯一这类跨行规则只有整域判得出)。一字不写。
17
+ * · `refused` —— 迁移步拒(收据 `refused`:要猜才改得动的形)**或**整域终判不过(名字 / 路由唯一这类跨行规则只有整域判得出):缺省只判要写回的文档;入参 `judge: "present"` 时在场的每一份文档都判
18
+ * (含迁移不碰的陈旧形:带事实的 retired 域文档、已不迁移的旧键与旧值 —— 文档面判官判不过的,这里同拒)。一字不写。判官是文档面那一只,与读腿(视图面)两个方向上不同:
19
+ * 比读腿宽 —— 条目只因带读侧不认识的键:视图面丢那一条,集合里每一条都这样(零幸存者)时整域退缺省 / 整域拒,文档面剥键受理、这里判得过;
20
+ * 比读腿严 —— 逐条丢弃域里一条 schema 不过的条目:视图面只丢它、其余照读,这里整份拒。
18
21
  * · `noop` —— 读到了文档、没有要改的。
19
22
  * · `pending` —— `check: true` 且有改动、整域判得过:一字不写。
20
23
  * · `applied` —— 已写回改过的文档 —— 中途断掉再跑一次,迁移照样恒等收尾(写过的文档已是新形,再迁零改动)。
@@ -27,18 +30,23 @@
27
30
  * 覆盖面、「没改的文档不判」「迁移不许越过覆盖面去写」与目录形逐字同;层的合并(层序 / 覆盖 / 托管锁)不在这里 —— 一层一次调用。
28
31
  */
29
32
  import { z } from "zod";
30
- import { formatConfigPath, parseDomain } from "./config-fns.js";
33
+ import { DOMAIN_ENTRY_SALVAGE, DOMAIN_READ_FALLBACK, formatConfigPath, parseDomain, readEntryIdentityAt, redactSecrets, refuseRetiredDomain } from "./config-fns.js";
31
34
  import { configDDocumentText, judgeConfigDText, judgeConfigDValue, parseRemoteExecDocument } from "./config-d-file.js";
32
35
  import { fsFailureMessage } from "./fs-failure.js";
36
+ import { stripControlAndBidi } from "./control-and-bidi.js";
33
37
  import { isPlainJsonObject } from "./plain-json-object.js";
34
38
  import { migrateStoredDocuments } from "./one-time-migrations.js";
39
+ import { issueSentence, readConsequenceSentence } from "./read-sentences.js";
35
40
  import { REMOTE_EXEC_DOCUMENT } from "./remote-exec.js";
36
41
  import { isDomainName, isRetiredDomainName } from "./types.js";
37
42
  const isConfigDirectoryDocument = (name) => isDomainName(name) || isRetiredDomainName(name) || name === REMOTE_EXEC_DOCUMENT;
38
- /** 改过的文档的整文档终判:域过读侧那一只 `parseDomain`,`remote-exec` 过 `loadRemoteExec` 那一只 `parseRemoteExecDocument`;retired 域不终判(没有一步改它,读侧墓碑判它)。 */
43
+ /** 一份文档的整文档终判 —— 读侧那几只判官各读一遍:域过 `parseDomain`,`remote-exec` 过 `loadRemoteExec` 那一只 `parseRemoteExecDocument`,retired 域过墓碑判
44
+ * `refuseRetiredDomain`(带事实 ⇒ 抛 `RetiredDomainError`;今天没有一步改 retired 域的文档,所以只有 `judge: "present"` 会判到它)。 */
39
45
  function judgeWholeDocument(name, doc) {
40
46
  if (isDomainName(name))
41
47
  parseDomain(name, doc);
48
+ else if (isRetiredDomainName(name))
49
+ refuseRetiredDomain(name, doc);
42
50
  else if (name === REMOTE_EXEC_DOCUMENT)
43
51
  parseRemoteExecDocument(doc);
44
52
  }
@@ -61,42 +69,89 @@ export function reportReceipt(r) {
61
69
  }
62
70
  }
63
71
  }
72
+ /** 一条拒带上它坐标所在条目的身份(有才带键;读法是读腿告警同一只 `readEntryIdentityAt`)。`doc` = 坐标所指的那份文档(迁移步的拒指入参的文档,整域终判的拒指迁移后的文档)。 */
73
+ function withIdentity(refusal, doc, path) {
74
+ const identity = readEntryIdentityAt(doc, path);
75
+ return identity === undefined ? refusal : { ...refusal, identity };
76
+ }
64
77
  /** 整域终判的一条拒(issue 来自 `parseDomain`,已过本包唯一的脱敏器 —— 坐标段与句子都是出门形)。 */
65
78
  function wholeDomainRefusal(document, path, reason) {
66
79
  return { migration: null, document, path: formatConfigPath(path), appliedAs: "refused", reason };
67
80
  }
81
+ /** 读腿对这份文档读不进时的处置(按文档名):域 ⇒ 两张读腿表的答案;retired 域 ⇒ 带事实就拒;`remote-exec` ⇒ `loadRemoteExec` 拒。 */
82
+ function consequenceOf(name) {
83
+ if (isDomainName(name))
84
+ return readConsequenceSentence(name, { fallback: DOMAIN_READ_FALLBACK[name], salvage: DOMAIN_ENTRY_SALVAGE[name] });
85
+ if (isRetiredDomainName(name))
86
+ return `the reader refuses the whole "${name}" document while it carries any key`;
87
+ return `the reader refuses the whole ${name} document`;
88
+ }
68
89
  /**
69
- * 迁移结果 → 结论。顺序:迁移步拒 → 无改动 ⇒ noop → **整域终判**(要写回的每个域文档 —— 改过的、新建的 —— 过读侧那一只
70
- * `parseDomain`:名字 / 路由唯一这类跨行规则只有整域判得出)→ 有改动。整域终判在 `check` 之前:否则同一个目录 `check` 报 pending、
71
- * 真跑写出一份读侧必拒的文档。没改的文件不归这里判(迁移不碰它,它读不读得进是读者的事)。
90
+ * 迁移没碰的文档的一条拒句:判官的原句(已折成一行、剥过一行回显的剥除集)· 读腿会怎么处置它 · 出路。出路只有一条:
91
+ * retired 域的判官原句就是墓碑句,它自带出路(把值手抄到今天的位置、删掉旧文档),这里不再接第二条;别的文档的出路是「在这份文件里手改」。
92
+ * 整句出门前过本包唯一的脱敏器:剥掉隔开的字符可以把两段拼成一个密钥形,脱敏判在剥之后、对最终的那一串做。
72
93
  */
73
- function verdictOf(input, migrated, receipts) {
74
- const refusedReceipts = receipts.filter((r) => r.appliedAs === "refused");
75
- if (refusedReceipts.length > 0) {
76
- return { kind: "refused", refused: refusedReceipts.map((r) => reportReceipt(r)), why: `${refusedReceipts.length} coordinate(s) cannot be migrated (see "refused") — fix them by hand and re-run` };
94
+ function untouchedReason(name, sentence) {
95
+ const parts = isRetiredDomainName(name) ? [sentence, consequenceOf(name)] : [sentence, consequenceOf(name), `fix it in ${name}.json by hand`];
96
+ return redactSecrets(parts.join("; "));
97
+ }
98
+ /**
99
+ * 一份文档的整文档终判的拒(同一套形:每条 issue 一条 `ConfigDirectoryRefusal`,`migration: null`)。`untouched` = 这份文档迁移没碰(只有 `judge: "present"` 才会判到):
100
+ * 它的拒句除判官的原句外,还说读腿会怎么处置它与出路({@link untouchedReason})—— 迁移改过的文档是**我们要写的**那一份,拒句就是判官的原句(整份 `why` 说「手改后重跑」)。
101
+ */
102
+ function wholeDocumentRefusals(name, doc, untouched) {
103
+ try {
104
+ judgeWholeDocument(name, doc);
105
+ return [];
106
+ }
107
+ catch (err) {
108
+ const found = err instanceof z.ZodError
109
+ ? err.issues.map((i) => ({ path: i.path, message: i.message, sentence: issueSentence(i) }))
110
+ : [{ path: [], message: messageOf(err), sentence: issueSentence({ message: messageOf(err) }) }];
111
+ return found.map((i) => withIdentity(wholeDomainRefusal(name, i.path, untouched ? untouchedReason(name, i.sentence) : i.message), doc, i.path));
77
112
  }
78
- if (receipts.length === 0)
113
+ }
114
+ /** 一批拒的**所在**,一行(stderr 用):`<文档>.json (<坐标>)`,同一处只列一次,最多三处。坐标里有用户写的键段:先剥一行回显的剥除集,
115
+ * 剥完再过本包唯一的脱敏器(剥掉隔开的字符可以拼出一个密钥形,判在剥之后)。 */
116
+ function refusedLocations(refused) {
117
+ const seen = [...new Set(refused.map((r) => (r.path === "" ? `${r.document}.json` : `${r.document}.json (${r.path})`)))];
118
+ return redactSecrets(stripControlAndBidi(seen.length <= 3 ? seen.join(", ") : `${seen.slice(0, 3).join(", ")}, …`));
119
+ }
120
+ /**
121
+ * 迁移结果 → 结论。顺序:迁移步拒 → 无改动 ⇒ noop → **整域终判**(`judge: "changed"`:要写回的每个域文档 —— 改过的、新建的;`"present"`:在场的每一份)→ 有改动。整域终判在 `check` 之前:否则同一个目录 `check` 报 pending、
122
+ * 真跑写出一份读侧必拒的文档。`"changed"` 下没改的文件不归这里判(迁移不碰它,它读不读得进是读者的事;引擎起服要的是这一种);`"present"` 下判它们,
123
+ * 文档面判不过 ⇒ 同样 `refused`(命令行:运维跑完 `migrate` 不该带着一份文档面判不过的陈旧文档上线;它与读腿两个方向上的差别见 {@link MigrateConfigDirectoryOptions.judge})。
124
+ */
125
+ function verdictOf(input, migrated, receipts, judge) {
126
+ const refusedReceipts = receipts.filter((r) => r.appliedAs === "refused");
127
+ const byMigration = refusedReceipts.map((r) => withIdentity(reportReceipt(r), input[r.document], r.path));
128
+ const migrationWhy = `${refusedReceipts.length} coordinate(s) cannot be migrated`;
129
+ // 迁移步拒:`"changed"`(引擎起服)问的是「迁移有没有把它改坏」,答案已经是否,不再往下判;`"present"` 问「这个目录现在干不干净」,下面接着判别的文档,两样并在一份报告里。
130
+ if (refusedReceipts.length > 0 && judge === "changed")
131
+ return { kind: "refused", refused: byMigration, why: `${migrationWhy} (see "refused") — fix them by hand and re-run` };
132
+ if (receipts.length === 0 && judge === "changed")
79
133
  return { kind: "noop" };
80
- const refused = [];
134
+ const receiptDocuments = new Set(refusedReceipts.map((r) => r.document)); // 文档名按串比(收据上的是闭集 `MigrationDocument`,这里遍历的键是任意串):这些文档的毛病已经在 byMigration 里(要猜才改得动的形),不再判第二遍、不重复报
135
+ const byJudge = [];
81
136
  for (const [name, doc] of Object.entries(migrated)) {
82
- if (Object.prototype.hasOwnProperty.call(input, name) && input[name] === doc)
137
+ if (receiptDocuments.has(name))
83
138
  continue;
84
- try {
85
- judgeWholeDocument(name, doc);
86
- }
87
- catch (err) {
88
- if (err instanceof z.ZodError)
89
- for (const i of err.issues)
90
- refused.push(wholeDomainRefusal(name, i.path, i.message));
91
- else
92
- refused.push(wholeDomainRefusal(name, [], err instanceof Error ? err.message : String(err)));
93
- }
139
+ const untouched = Object.prototype.hasOwnProperty.call(input, name) && input[name] === doc;
140
+ if (untouched && judge === "changed")
141
+ continue;
142
+ byJudge.push(...wholeDocumentRefusals(name, doc, untouched));
94
143
  }
95
- if (refused.length > 0) {
96
- const documents = [...new Set(refused.map((r) => r.document))];
97
- return { kind: "refused", refused, why: `the migrated ${documents.join(" / ")} document(s) do not read as a whole domain (see "refused") — fix them by hand and re-run` };
144
+ if (byMigration.length > 0 || byJudge.length > 0) {
145
+ const documents = [...new Set(byJudge.map((r) => r.document))];
146
+ const judged = judge === "changed" ? `the migrated ${documents.join(" / ")} document(s) do not read as a whole domain` : `${refusedLocations(byJudge)} do not read as a whole domain`;
147
+ const why = byJudge.length === 0
148
+ ? `${migrationWhy} (see "refused") — fix them by hand and re-run`
149
+ : byMigration.length === 0
150
+ ? `${judged} (see "refused") — fix them by hand and re-run`
151
+ : `${migrationWhy} and ${judged} (see "refused") — fix them by hand and re-run`;
152
+ return { kind: "refused", refused: [...byMigration, ...byJudge], why };
98
153
  }
99
- return { kind: "changes" };
154
+ return receipts.length === 0 ? { kind: "noop" } : { kind: "changes" };
100
155
  }
101
156
  const messageOf = (err) => (err instanceof Error ? err.message : String(err));
102
157
  /** 覆盖面的名字集(校验在这一处):拼错的名字 ⇒ `TypeError`,不让它悄悄变成「什么都没覆盖」。 */
@@ -112,7 +167,7 @@ function coveredDocuments(caller, documents) {
112
167
  /**
113
168
  * 「迁 → 整域终判」的内核(语义只此一处):`docs` = 覆盖面内**在场且已判过形**的文档(都是 JSON 对象),`covered` = 覆盖面。目录形读完目录后调它,同步口 {@link migrateConfigDocuments} 判完形后调它。
114
169
  */
115
- function migrateCovered(caller, docs, covered) {
170
+ function migrateCovered(caller, docs, covered, judge) {
116
171
  const read = Object.keys(docs);
117
172
  if (read.length === 0)
118
173
  return { kind: "no-documents" };
@@ -128,7 +183,7 @@ function migrateCovered(caller, docs, covered) {
128
183
  throw new Error(`${caller}: the migration removed document(s) (${dropped.join(", ")}) — this migration never deletes a file; refusing to write`);
129
184
  }
130
185
  const applied = m.receipts.filter((r) => r.appliedAs !== "refused");
131
- const verdict = verdictOf(docs, m.docs, m.receipts);
186
+ const verdict = verdictOf(docs, m.docs, m.receipts, judge);
132
187
  switch (verdict.kind) {
133
188
  case "refused":
134
189
  return { kind: "refused", read, docs: m.docs, applied, refused: verdict.refused, why: verdict.why };
@@ -166,13 +221,16 @@ export function migrateConfigDocuments(docs, opts) {
166
221
  return { kind: "unreadable", document: name, reason: messageOf(err) };
167
222
  }
168
223
  }
169
- return migrateCovered("migrateConfigDocuments", present, covered);
224
+ return migrateCovered("migrateConfigDocuments", present, covered, "changed"); // 同步口问的是「引擎起服那一次迁移之后」(见 `judge: "changed"`):不判迁移没碰的文档
170
225
  }
171
226
  /**
172
227
  * 对 `dir`(一个 `config.d` 目录)的覆盖面内文档跑一次一次性迁移;语义与结果见文件头。`dir` 与目录内文件名的拼接用 `/`。
173
228
  */
174
229
  export async function migrateConfigDirectory(dir, opts) {
175
230
  const covered = coveredDocuments("migrateConfigDirectory", opts.documents);
231
+ const judge = opts.judge ?? "changed";
232
+ if (judge !== "changed" && judge !== "present")
233
+ throw new TypeError(`migrateConfigDirectory: judge must be "changed" or "present" (got ${JSON.stringify(String(judge))})`);
176
234
  const { io } = opts;
177
235
  let names;
178
236
  try {
@@ -203,7 +261,7 @@ export async function migrateConfigDirectory(dir, opts) {
203
261
  return { kind: "unreadable", reason: messageOf(err) };
204
262
  }
205
263
  }
206
- const m = migrateCovered("migrateConfigDirectory", docs, covered);
264
+ const m = migrateCovered("migrateConfigDirectory", docs, covered, judge);
207
265
  switch (m.kind) {
208
266
  case "no-documents":
209
267
  return { kind: "no-documents", entries: names };
@@ -179,6 +179,18 @@ export declare class RetiredDomainError extends Error {
179
179
  readonly code: "retired_domain";
180
180
  constructor(domain: RetiredDomainName);
181
181
  }
182
+ /**
183
+ * 一次**跨域读**(`buildEffective` / `readEffectiveWire` / `FileConfigStore` 的 `read()` 与 `getEffective()`)里,一个门控域({@link DOMAIN_READ_FALLBACK} 判 `"throw"`)
184
+ * 整域读不进 —— 读者要知道**是哪个域**、**判官为什么拒**:`domain` 是那个域;`cause` 是判官的原拒,原样(整份严判没过 = 脱敏后的 ZodError;校验途中读不出 =
185
+ * 一句中性 TypeError;逐条丢弃域里条目体内有被剥的键且救不活 = `unrecognized_keys` 的 ZodError)。`message` 点名域并接原拒的句子 —— 原拒已脱敏,这里不读任何
186
+ * 脱敏之前的东西;原拒的句子读不出 ⇒ 只留点名域的前半句。
187
+ * 铸点只有一处(视图面读的整域档位,{@link readViewOr})。单域读口(`parseDomain` / `parseDomainLoud` / `parseDomainSalvaged`)照抛原拒 —— 调用方自己点了域;
188
+ * 目录域整域读不进不抛:回落默认 + 一条 `domain-defaulted`,告警的 `error` 与这里的 `cause` 是同一只原拒的 `issues`(另一只对象:同类、同 `issues`,`message` 换成一句话),告警自带 `domain`。retired 域的墓碑拒是另一件事({@link RetiredDomainError})。
189
+ */
190
+ export declare class DomainReadRefusedError extends Error {
191
+ readonly domain: DomainName;
192
+ constructor(domain: DomainName, cause: unknown);
193
+ }
182
194
  /** 墓碑判一次:`raw` 是retired 域 `domain` 的文档,带事实 ⇒ 抛 {@link RetiredDomainError}。 */
183
195
  export declare function refuseRetiredDomain(domain: RetiredDomainName, raw: unknown): void;
184
196
  /** Validate + fill defaults for a domain payload (or the schema's empty default when absent/invalid). */
@@ -291,8 +303,7 @@ export declare const DISCLOSABLE_IDENTITY_RE: RegExp;
291
303
  export declare function isDisclosableIdentity(v: string): boolean;
292
304
  /** S-768 —— 「一个目录条目名能不能当 {@link ModelRefusalsWire} `entries` 的键」的**唯一**判据;引擎铸键前只调这一只,
293
305
  * 不过 ⇒ 按无名处置(不进键、不计数)。两条律的合取,不手抄任何一条:
294
- * ① 这只 schema **自己载得住**这个键 —— 就地拿 schema 判(空串不过键规则;`__proto__` 这类名被 zod 的 record 静默丢掉,
295
- * 载不住),不写名单;
306
+ * ① 这只 schema **自己载得住**这个键 —— 就地拿 schema 判(空串不过键规则;保留成员名让记录座位拒掉整只信号,载不住),不写名单;
296
307
  * ② {@link isDisclosableIdentity}(不是白名单闭形里的标识符,或是秘密形 ⇒ 不出门)。
297
308
  * 非字符串 ⇒ false。住在本文件而不是 `./fleet`:`fleet.ts` 被 `types.ts` 引,它再引本文件会成环。 */
298
309
  export declare function isReportableRefusalName(name: string): boolean;
@@ -303,6 +314,14 @@ export declare function isReportableRefusalName(name: string): boolean;
303
314
  * 摘要输入取 `JSON.stringify(name)`:UTF-8 编码会把孤立代理项换成 U+FFFD(`"\ud800"` / `"\ud801"` / `"\ufffd"` 三个不同的名同一串字节),
304
315
  * JSON 串形逐个 UTF-16 码元保留(孤立代理项写成转义)—— 不同的名恒是不同的输入。 */
305
316
  export declare function withheldNameToken(name: string): string;
317
+ /**
318
+ * 一个坐标落进的那一条**条目**的身份(只带可披露的名与 id,见 {@link DroppedEntryIdentity}):坐标形如 `[<集合字段>, <下标>, …]` 且文档里那一处是数组里的一个条目 ⇒ 读它的身份;
319
+ * 否则(域级的键、整份文档、Record 里的值)⇒ `undefined`。条目身份的读法只有 {@link readEntryIdentity} 一只:`entry-dropped` 的身份由抢救记账时对那一条原文调它;
320
+ * 按坐标找到那一条再调它的,是这一只 —— `domain-defaulted`(抢救账里没有那一条时)与命令行报告的 `refused[]` 说「是哪一条」读它。坐标只给下标,
321
+ * 消费方自己渲染诊断、要点名一条条目时调它(`doc` 是坐标所指的那份文档的原文,`path` 是 {@link ConfigPath}),不另写一份读名字的代码。读文档只走内核的自有成员读;
322
+ * 读不出(含 `path` 不是数组、读它就抛)⇒ `undefined`,从不抛。
323
+ */
324
+ export declare function readEntryIdentityAt(doc: unknown, path: ConfigPath): DroppedEntryIdentity | undefined;
306
325
  /** 抢救造成的**下标位移表**:被压缩过的数组 → 它压缩后每个位置的**原**下标(`kept[j]` = 压缩后第 j 条
307
326
  * 在原文档里的下标)。纯数据,无行为。
308
327
  *
@@ -400,10 +419,17 @@ export declare function statusRowsToPrune(rows: {
400
419
  * 0.19.0 加了两个 kind(additive union member —— 用 `switch` 穷举本类型的消费方需补臂):
401
420
  * `"unknown-keys-dropped"` / `"unread-config-file"`,成案见 {@link droppedKeys}(消费方
402
421
  * #322:配置写了、进程跑着、值没到,而没有任何一个字说出来)。 */
403
- export type EffectiveReadWarning = {
422
+ export type EffectiveReadWarning =
423
+ /** 整个域读不进、按 schema 缺省读。`error` 与判官的原拒同类、同 `issues`(`ZodError` 的 `issues` 一字不动;仍是 `Error` 的实例、带 `stack`),它的 `message` 是**一句话**(整域按缺省读 · 为什么 · 触发的条目是谁 · 在这份文档里手改),不是多行的 JSON 数组文本。
424
+ * 另有三个可缺的键(加性):`path` = 触发的那一处坐标(原拒的第一条 issue 的坐标,出门形;可以是域级的键,如 `["default"]`);`identity` / `reasonCode` = 触发的**条目**是谁、为什么(坐标落在某个条目体内时才有,
425
+ * 与同一条条目在 `entry-dropped` 上的两键同一读法 —— 零幸存者时只剩这一条告警,身份与原因词就在这里)。三键不进符合性投影({@link projectWarning} 仍是 `{ kind, domain }`):它们是诊断,不是读法。 */
426
+ {
404
427
  domain: DomainName;
405
428
  kind: "domain-defaulted";
406
429
  error: unknown;
430
+ path?: ConfigPath;
431
+ identity?: DroppedEntryIdentity;
432
+ reasonCode?: DroppedEntryReasonCode;
407
433
  }
408
434
  /** 域文档里那些**不属于该域 schema** 的键:行为照旧(zod 非 strict = 剥掉,前向兼容不动),但点名
409
435
  * 说出来。`keys` = 段坐标({@link ConfigPath};`["infraCostRates","toolCalMicroUsd"]` /
@@ -516,6 +542,7 @@ export declare function projectWarning(w: EffectiveReadWarning): WarningProjecti
516
542
  * 说的就是这件事。{@link salvageEntries} 铸 `entry-dropped` 时用的是它**入参**那份文档的坐标;若那份文档本身被外层
517
543
  * 压缩过,外层照样要回写它一次。今天读路径上只有一个压缩点(11.0.0 起 hosts 的读侧夹紧臂已retired),所以这一臂当下
518
544
  * 只对 `keptIndex` 为空的表恒等;把「不动」写成一条臂的性质,就是把「哪一层」这件事错记在了「哪个 kind」上。
545
+ * `domain-defaulted` 的可缺坐标 `path`(33.0.0)同理:在场就回写,缺席就原样。
519
546
  *
520
547
  * **恒等纪律**:没有任何一条路径真的变了(含 `keptIndex` 为空)⇒ 返回**同一个对象引用**,连 `keys`
521
548
  * 数组也不复制(好数据穿过读路径 byte 不变)。
@@ -740,7 +767,7 @@ export declare function buildEffective(version: number, getRaw: StoredDocumentRe
740
767
  * type-asserting it(0.12.0,[2281] 裁B:「两个契约共用一个拼写不是一个被检查的契约」——拼写副本要在
741
768
  * 消费端被真校验)。ONE judgment, two legs: every known domain goes through the SAME `parseDomain` +
742
769
  * {@link DOMAIN_READ_FALLBACK} policy as {@link buildEffective}(catalog 域坏形 → schema default + warning;
743
- * gate 域坏形 → throw,caller 的整包 catch 决定回落),including the retired-domain tombstone — DELEGATED to
770
+ * gate 域坏形 → throw {@link DomainReadRefusedError}(点名域,原拒在 `cause`),caller 的整包 catch 决定回落),including the retired-domain tombstone — DELEGATED to
744
771
  * buildEffective, not re-implemented(单判据双腿消费,§M4)。A retired domain on the wire (an older web-admin still
745
772
  * ships `runtime`) is judged by the same tombstone: carrying facts ⇒ {@link RetiredDomainError}; `{}` (what an older
746
773
  * web-admin materialises for an unset domain) carries nothing and is dropped from the result — it never rides through as