@sema-agent/settings-schema 26.0.0 → 27.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 CHANGED
@@ -8,6 +8,203 @@
8
8
 
9
9
  ## Unreleased
10
10
 
11
+ ## 27.0.0 — 2026-11-11 — major:目录条目 `ModelEntry.fallbacks`(引擎每模型回落链的声明位;**只判形**,坏形整条拒)· 墓碑表加 `MODEL_DEGRADE_ON`(`replaced` → `MODEL_FALLBACK_ON`)与 `MODEL_DEGRADE_REACTIVE`(`removed`):设了即拒启
12
+
13
+ > 档位(按发版纪律):**major** —— 校验收紧、同一份文档 / 同一份部署配置解析出不同结果,下面两条各有读数:
14
+ > ① **`fallbacks` 的坏形整条拒**:目录条目上的 `fallbacks` 此前是契约外的键 —— 文档面(`validateDomain` / `writeDomainFile` / `getDomain` / `parseDomain`)**剥键后受理**(`fallbacks: "x"` 这类坏形的条目照收、键被剥),视图面(`buildEffective` / `readEffectiveWire` / `loadLocalConfig` / `FileConfigStore.getEffective`)把带这个键的条目**一律整条丢**(`entry-dropped`,`reasonCode: "entry-unknown-key"`,不论值合不合形);自此坏形的条目在文档面整份拒、在视图面仍丢但丢弃词改为 `entry-schema-invalid`,合形的在两面都装上。
15
+ > ② **两行墓碑**:部署 env 里留着 `MODEL_DEGRADE_ON` / `MODEL_DEGRADE_REACTIVE`(任何显式值)由起服变拒启(墓碑表只增不减,每加一行都是校验收紧)。
16
+ > 新可选键本身是 minor(发版纪律「新键 = minor」);本版判 major 的依据是上面两条读数变化,不是新键本身。无导出删除、无导出新增(`ModelEntry` 的推断型多一个可选成员,`RETIRED_ENVS` 多两行数据)。
17
+
18
+ ### 病
19
+
20
+ 引擎的目录条目有了每模型回落链(`RunnerDeps.models.<名>.fallbacks`),整只 Brain 的「一个 env 开关 + 一个全局目标」式反应式降级壳随之退场。`ModelEntry` 没有这一席:部署在目录条目上写 `fallbacks`,视图面把它当未知键整条丢(模型不见了),文档面悄悄剥掉(写了没到);墓碑表也没有旧壳那两只 env 的行,留着它们的部署升级后被悄悄忽略 —— 运维以为壳还在生效。
21
+
22
+ ### 律(一条)
23
+
24
+ **一个事实一只判官**:`fallbacks` 里的词在不在目录、指不指自己、重不重复、链有几跳 —— 这些只有**引擎的目录门**判(引擎自 7.67.0 起在收取目录时判:链词在展开档位之后的目录上解、链是平的、词不在目录 / 指自己 / 重复 / 超跳数一律拒,拒句点名 `RunnerDeps.models.<名>.fallbacks`;本包只承载声明,不验证引擎行为)。本包只判「是不是非空串数组」这一件事(形),不判有效性:再判一遍就是第二只判官,两边迟早对同一条链各说各话。
25
+
26
+ ### BREAKING ① `ModelEntry.fallbacks?: string[]`
27
+
28
+ - **席位**:`z.array(z.string().min(1)).optional()`,放在 `thinkingLevelMap` 之后。三态同 `reasoning` / `vision`:**缺席** = 未声明(本包不铸键);**`[]`** = 声明了、没有链(引擎读作「无链」);**非空数组** = 按跳序的链,逐字交出(本包不排序、不去重、不截断)。
29
+ - **坏形整条拒、不剥键、不折默认**(与同族先例 `thinkingLevelMap` 同一条律,不另立):非数组(串 / 数 / 布尔 / 对象)· `null` · 元素不是非空串(数 / `null` / 空串 / 数组 / 对象)⇒ 这一条目不过。严写面(写入席、`parseDomainLoud`、`validateDomain` / `writeDomainFile`、`getDomain` / 导出)整份拒;读腿逐条丢并报 `entry-dropped`(`reasonCode: "entry-schema-invalid"`),兄弟条目照装;它被 `roles` / `atMention.only` / `tierGroups` 引用、或是唯一一条时走既有的级联 / 零幸存者律(整个 `models` 域 `domain-defaulted`,只发这一种告警)—— 与任何别的坏目录条目同答,本版不改那条律。
30
+ - **不判有效性**:目录里没有的词 · 指自己 · 重复 · 超过引擎允许的跳数 ⇒ 本包**照收、原样交出**;跨域引用判官(`refIntegrityIssues`)不把 `fallbacks` 当引用。词可以是档位词 / 别名(在引擎的展开目录上解);链是**平**的,一跳自己的 `fallbacks` 不被走(这两句是引擎自 7.67.0 起的读法,本包不验证)。
31
+ - 不进 `PARSE_TRANSPARENT_KEYS`(本包对它的形有主张);不是 env 腿的键(env 腿没有按成员声明的位置,与 `thinkingLevelMap` 同)。
32
+
33
+ ### BREAKING ② 墓碑表加两行
34
+
35
+ `RETIRED_ENVS` 表尾多两行(判据只问键在不在场:**任何显式值都拒,空串 = 未设**;拒启句由唯一铸点 `retiredEnvRefusal` 铸,带拒启码 `config.env_key_retired`、点名键与理由、**从不回显值**;目录 wire `retired[]` 与 worker 规格 `env` / `secretEnv` 写闸同表派生、零代码改动):
36
+
37
+ - `["MODEL_DEGRADE_ON", "MODEL_FALLBACK_ON", "replaced", <理由>]` —— 门词旋钮有现名、但**值语义变了**:`budget` 不再是门词;`network` / `auth` / `stream_torn` 是新词;作用面由「整只 Brain 的一个目标」变成「每条目录链」。拒句点名 `MODEL_FALLBACK_ON` 与「别照抄旧值」。
38
+ - `["MODEL_DEGRADE_REACTIVE", <理由>, "removed"]` —— 整只 Brain 的反应式降级壳删除,没有可 rename 的目标;出路写在理由里:在目录条目上声明 `fallbacks`,决定何时跳的门词是 `MODEL_FALLBACK_ON`。
39
+ - **门词的词表与语义归引擎的回落门与服务端对 `MODEL_FALLBACK_ON` 的拆词**,本包只登记墓碑与理由句:理由句里「`budget` 不再是门词、`network` / `auth` / `stream_torn` 是新词」是引擎回落门的现状读法(以提货该门的引擎版本的说明为准)。
40
+ - **不进表**:`MODEL_DEGRADE_TO` / `MODEL_DEGRADE_AT_COST_FRACTION` / `MODEL_DEGRADE_TO_VISION` 仍是活旋钮(近预算降级线);`MODEL_FALLBACK_ON` 是现名(链只有一跳,去向不能是另一个已退役的名字)。
41
+ - **进表的判据**(表头注那一条):没有带着本表的引擎还读这个名 —— 服务端停读这两个键与提货本版**同一发版**;更早的引擎内带更早的契约,看不见这两行。
42
+
43
+ ### 导出面
44
+
45
+ - **新增 / 删除导出**:无。**运行期读数变**:`ModelEntry`(及含它的 `ModelsConfig` / `DOMAIN_SCHEMAS` 的 `models` 域)对带 `fallbacks` 的条目的读数 —— 见 BREAKING ①;`RETIRED_ENVS` 多两行、`buildRetiredEnvWire()` 的投影随表多两项、`retiredEnvRefusal` 对这两个名答拒句。
46
+ - **类型面**:`ModelEntry` 多可选成员 `fallbacks?: string[]`(加性;对 `ModelEntry` 的 `keyof` 写穷举表的消费方会编译红,补一列)。
47
+
48
+ ### 三问
49
+
50
+ - **谁需要**:① 中心目录部署 —— 主模型限流 / 5xx 时落到便宜模型继续服务,链是目录数据而不是一个全局 env 目标;② 多账户部署 —— 回落跳在别的账户 / 网关,带自己的钥匙声明;③ 自托管部署 —— 首个 token 迟迟不来时换一只模型。没有这一席,这些链只能写在引擎的嵌入面上,经目录下发的部署声明不了。
51
+ - **谁受伤**:① env 里留着 `MODEL_DEGRADE_REACTIVE` / `MODEL_DEGRADE_ON`(任何显式值)的部署 —— 提货本版的服务端由「起服照旧、整只 Brain 降级」变成**拒启**,拒句点名键(这是预期:壳已删除,留着它们等于以为它还在生效);② 目录条目已经带着 `fallbacks` 的文档 —— 此前视图面把那条目整条丢(模型在消费方不可用),自此合形的**装上**(链随条目到达,消费方按自己的版本读它),写坏的仍丢(词改 `entry-schema-invalid`);③ 文档面写过坏形 `fallbacks` 的存量文档 —— 此前剥键受理,自此整份拒(`validateDomain` / `writeDomainFile` / `getDomain` / 导出),坏条目被 `roles` / `atMention.only` / `tierGroups` 引用或是唯一一条时,读腿整个 `models` 域退缺省;④ 对 `ModelEntry` 的 `keyof` 写穷举表的代码 —— 编译红(补一列)。
52
+ - **补偿**:① 删掉 env 里两个旧键;要保留「某模型失败落到另一只」的行为 ⇒ 在该模型的目录条目上写 `fallbacks`,门词设 `MODEL_FALLBACK_ON`(拒句已点名,别照抄旧值);② 升级前对存着的 `models` 文档(含存下来要续跑的、中心名册草稿)自查 `fallbacks`:每个值必须是非空串数组(或整个键删掉);③ 只想保留近预算降级的部署:`MODEL_DEGRADE_TO` / `MODEL_DEGRADE_AT_COST_FRACTION` / `MODEL_DEGRADE_TO_VISION` 不动。
53
+
54
+ ### 给消费方的迁移句(BREAKING)
55
+
56
+ 提货本版:① 把「留着 `MODEL_DEGRADE_ON` / `MODEL_DEGRADE_REACTIVE` 的部署」的升级指引写成「删这两个键 → 回落链写进目录条目 `fallbacks` → 门词用 `MODEL_FALLBACK_ON`」,不要写成「改个名字」(`MODEL_DEGRADE_ON` 是 `replaced`:值语义变了);② 自己停读这两个键与提货本版同一发版;③ 渲染 `retired[]` 的一方会多看到两行(一行带 `replacement` + `reason`,一行只带 `reason`);④ 目录编辑面要承运 `fallbacks`,只产合形(非空串数组),别把空串当「没有」写出去。
57
+
58
+ ### 各消费方
59
+
60
+ | 消费方 | 读点 | 动作 |
61
+ |---|---|---|
62
+ | server | 起服墓碑拒启 · 目录条目的投影 · 引擎目录门(链词的唯一判官) | 同一发版停读两只旧键;墓碑拒启格由「预期红」翻成常规格;目录 wire `retired[]` 多两项;链的有效性(词在不在目录 / 自指 / 重复 / 跳数 / 停用)继续只由引擎目录门判,不在本包 |
63
+ | web-admin | 目录编辑面 · `retired[]` 渲染 | 可选:表单承运 `fallbacks`(只产非空串数组);`retired[]` 多两行照常渲染;写坏的条目自此会被拒 / 丢 |
64
+ | cli | 手列环境变量目录的旧键 | 删去这两个旧键;不读新席位也不受影响 |
65
+ | client-core / sdk | 无直接读点 | 零代码改动;契约语料不变(语料零 diff) |
66
+ | test | 黑盒判据 | 见下「黑盒判据」 |
67
+
68
+ ### 黑盒判据(从包的导出面可执行,不引用内部实现)
69
+
70
+ - **G1 合形照收**:`ModelEntry.parse({ name: "a", id: "x", fallbacks: ["b"] }).fallbacks` 等于 `["b"]`;`fallbacks: []` 装上的仍是 `[]`;缺席时结果里没有 `fallbacks` 这个键。
71
+ - **G2 坏形整条拒**:`fallbacks` 取 `"b"` · `null` · `[1]` · `[""]` · `[["b"]]` 之一 ⇒ `ModelEntry.safeParse` 失败、问题坐标在 `fallbacks`;同一条目放进 `models` 文档:`validateDomain("models", …)` 不过;`buildEffective` / `readEffectiveWire` 丢它并报一条 `entry-dropped`(`reasonCode: "entry-schema-invalid"`),兄弟条目照装。
72
+ - **G3 不判有效性**:`fallbacks: ["no-such-model"]` · `["a"]`(指自己)· `["b", "b"]` · 四个以上的词 ⇒ 全部照收、原样交出,零告警。
73
+ - **G4 墓碑**:`retiredEnvRefusal({ MODEL_DEGRADE_ON: "rate_limit" })` 的句子含 `[config.env_key_retired]`、`MODEL_DEGRADE_ON`、`MODEL_FALLBACK_ON` 与「do not copy the old value across unread」,不含值 `rate_limit`;`retiredEnvRefusal({ MODEL_DEGRADE_REACTIVE: "true" })` 的句子含键名与 `declare \`fallbacks\` on the catalog entry`,不含值;空串 = 未设 ⇒ 返回 `undefined`;`MODEL_DEGRADE_TO` / `MODEL_FALLBACK_ON` 在场 ⇒ 返回 `undefined`。
74
+ - **G5 投影**:`buildRetiredEnvWire()` 恰多两项:`{ name: "MODEL_DEGRADE_ON", kind: "replaced", replacement: "MODEL_FALLBACK_ON", reason }` 与 `{ name: "MODEL_DEGRADE_REACTIVE", kind: "removed", reason }`(后者没有 `replacement` 键),按表序在尾。
75
+
76
+ ### 钉
77
+
78
+ `test/model-fallbacks-27.0.0.test.ts`(合形 / 三态 / 坏形整条拒 / 不判有效性 / 不铸键 / 内容哈希区分 `[]` 与缺席与链序 / 每条读写口:正控、坏形逐条丢并带词 `entry-schema-invalid`、零幸存者与引用级联与「缺 id」同答、写腿不落盘)·
79
+ `test/retired-env-model-degrade-27.0.0.test.ts`(两行逐字 / 表尾次序 / 链一跳 / 活旋钮不进表 / 拒句逐字且不回显值 / 两名同在场的族序 / 空串 = 未设 / `retired[]` 两种形 / worker 规格写闸)·
80
+ 既有行数与行集钉(`retired-envs-11.0.0` / `retired-envs-previous-generation-11.2.0`)各加两行。
81
+ 红先:在 26.1.0 的源上跑这两个文件,33 个红(`fallbacks` 23 / 墓碑 10)、7 个守住格同绿。
82
+ 变异(每刀都红):去掉席位 · 元素放宽成 `z.string()` · 去掉 `.optional()` · 加 `.nonempty()` · 加 `.max(3)` · 去重 transform · `.default([])` · `.nullable()` · 坏形折成缺席 · 目录里判词在不在 · 判指自己;表里删任一行 · REACTIVE 改成 `replaced` · 两行换序 · 理由句去掉 `network` · 理由句去掉出路 · 多一行 `MODEL_DEGRADE_TO` · 多一行 `MODEL_FALLBACK_ON` · 空串当在场。
83
+
84
+ **自 v26.1.0 起运行期代码有改动的公开导出(机器重算;上界 —— 可达 ≠ 一定变,不可达 ⇒ 一定不变;本版新增的导出不入表)**
85
+
86
+ ```text
87
+ DOMAINS [., ./types]
88
+ DOMAIN_SCHEMAS [., ./types]
89
+ FileConfigStore [./node]
90
+ ModelEntry [., ./types]
91
+ ModelsConfig [., ./types]
92
+ NON_PORTABLE_DOMAINS [./conformance]
93
+ RETIRED_ENVS [.]
94
+ WorkerSpec [., ./types]
95
+ WorkersConfig [., ./types]
96
+ buildEffective [., ./config-fns]
97
+ buildRetiredEnvWire [.]
98
+ changedWriteFields [., ./config-fns]
99
+ deriveLocalExpectation [./conformance]
100
+ deriveWireExpectation [./conformance]
101
+ domainFilePath [./node]
102
+ emptyEffective [., ./config-fns]
103
+ foreignKeysOf [./conformance]
104
+ isDomainName [., ./types]
105
+ loadLocalConfig [./node]
106
+ loadRemoteExec [./node]
107
+ migrateConfigDirectory [./node]
108
+ migrateConfigDocuments [./node]
109
+ migrateEffectiveSnapshot [./one-time-migrations]
110
+ migrateEnvModelsDecision [./node]
111
+ migrateStoredDocuments [./one-time-migrations]
112
+ parseDomain [., ./config-fns]
113
+ parseDomainLoud [., ./config-fns]
114
+ parseDomainSalvaged [., ./config-fns]
115
+ planEnvModelTableWrite [.]
116
+ readBundle [./node]
117
+ readConfigDFileReadingSync [./node]
118
+ readEffectiveWire [., ./config-fns]
119
+ readWorkersRows [.]
120
+ remoteExecPath [./node]
121
+ resolveLegExpectation [./conformance]
122
+ retiredEnvRefusal [.]
123
+ runConformance [./conformance]
124
+ salvageEntries [., ./config-fns]
125
+ validateDomain [./node]
126
+ writeBundle [./node]
127
+ writeDomainFile [./node]
128
+ writeRemoteExec [./node]
129
+ ```
130
+
131
+
132
+ ## 26.1.0 — 2026-11-11 — minor:引擎属主钩子事件的**逐员起始契约版本**成了导出的数据(`ENGINE_OWNED_HOOK_EVENT_SINCE`)· 一只读者 `engineOwnsHookEventAt(event, contractVersion)`
133
+
134
+ > 档位(按发版纪律):**minor** —— 只加导出(包根与 `./hooks` 子路径各三名:两个值、一个型);无导出删除、无闭集缩小、无校验变化、无读数变化:`ENGINE_OWNED_HOOK_EVENTS` 的元组型与成员顺序(已发的型面)、`HOOK_EVENT_OWNER` 的读数、`HooksConfig` / `classifyHooksConfig` 对任何设置文档的读数都逐字不变。
135
+ > 属主集没有新成员,所以持「按属主集穷举」的 `Record` / `switch` 的消费方提货不会编译红。
136
+
137
+ ### 病
138
+
139
+ 26.0.0 把 `PermissionDenied` 由壳属主改判引擎属主。按属主表分流的消费方提了 26.0.0、而对端服务端还没提时,会把这只钩子装进请求体交给一台**不认它归引擎**的服务端,服务端静默不注册 —— 本端以为交出去了,两边都不跑,wire 上看不出来。
140
+ 「某一员从哪一版契约起归引擎」此前只写在属主表的型注释里,没有导出成数据:消费方只能各自手写 `{ PermissionDenied: "26.0.0" }` 一类的特例表 —— 同一件事多个来源。
141
+
142
+ ### 律(一条)
143
+
144
+ **一个事实一处**:「某员从哪一版起归引擎」只住在 `ENGINE_OWNED_HOOK_EVENT_SINCE` 这一张表里,读它的比较只住在 `engineOwnsHookEventAt` 这一只函数里。表的键集与 `ENGINE_OWNED_HOOK_EVENTS` 同源:加员而没给起始版本、或表里有不在属主集里的键,**编译红**(表不会与属主集漂开)。
145
+ 消费规则一句话(成文在 README「钩子事件按属主分流」一节):**交引擎 ⟺ 属主表说 `engine` ∧ 对端契约版本 ≥ 该员的起始版本**;对端版本读自服务端 `GET /v1/capabilities` 的 `settingsContract.version`,缺席 ⇒ 传你方支持底线(你方支持的最老一代服务端所内嵌的契约版本)。
146
+
147
+ ### 导出面
148
+
149
+ - **新增**(包根与 `./hooks` 子路径各一份,共三名):
150
+ - `ENGINE_OWNED_HOOK_EVENT_SINCE: Readonly<Record<EngineOwnedHookEvent, string>>` —— 引擎属主十员各自的**起始契约版本**(第一次出现在属主集里的本包版本,按包现名的版本线记,完整 `x.y.z`),冻结。`PermissionDenied` = `"26.0.0"`,其余九员 = `"1.0.0"`(包现名的第一个版本 —— 下限,不是这九员的引入日期,见下节)。
151
+ - `engineOwnsHookEventAt(event: string, contractVersion: string): boolean` —— 唯一的读者:`event` 在 `ENGINE_OWNED_HOOK_EVENTS` 里 **且** `contractVersion` ≥ 该员的起始版本 ⇒ `true`;其余(壳属主事件、不是钩子事件的名字、版本更低)⇒ `false`。
152
+ - 型 `EngineOwnedHookEvent` = `(typeof ENGINE_OWNED_HOOK_EVENTS)[number]`。
153
+ - **删除 / 类型缩窄 / 读法变**:无。`ENGINE_OWNED_HOOK_EVENTS` 仍是十员、同序(`PermissionDenied` 在尾),`HOOK_EVENT_OWNER` 仍由它派生;本版只改了它头注的文字(起始版本不再夹在注释里,指向那张表)。
154
+
155
+ ### 值是从 tag 史读的(不凭记忆、不凭注释)
156
+
157
+ 逐个 tag(`v0.11.0` … `v26.0.0`,共 82 个)读 `git show <tag>:src/hooks.ts` 里 `ENGINE_OWNED_HOOK_EVENTS` 的成员:
158
+ - `PermissionDenied`:`v25.1.0`(九员)没有它,`v26.0.0`(十员,它在尾)有 ⇒ `26.0.0`。
159
+ - 其余九员:从最早的 tag `v0.11.0` 到 `v25.1.0` 的每一个 tag 上都是这九员、同序,没有进出过;仓库的第一个提交(旧包名 `@sema-agent/registry-core` 的 0.10.9)里已经是这九员 —— 它们比改名还早。起始版本按**本包现名的版本线**记:`1.0.0` 是包改名后的第一个版本(见本档头注的包名分水岭),`v1.0.0` 的属主集已是这九员 ⇒ `1.0.0`。
160
+ 因此 `1.0.0` 是「本包现名能报出的最低版本」,不是这九员的引入日期;凡报得出契约版本的对端都不低于它,规则对这九员恒 `true`。
161
+
162
+ ### 读者的律
163
+
164
+ - **只收完整的 `x.y.z`**:十进制、无前导零、无预发布 / 构建段、无 `v` 前缀、无空白。其余 —— 含 `"26"` · `"26.0"` · `"v26.0.0"` · `""` · `"26.0.0-rc.1"` · `"26.0.0+build.5"`,以及非字符串(含 `undefined`)—— **抛 `TypeError`**,稳定句以 `engineOwnsHookEventAt: contractVersion must be a complete x.y.z version` 起头,**不回显入参**(对端给的串是外来输入)。不猜、不当 0。
165
+ - **预发布段的律**:`26.0.0-rc.1` 排在 `26.0.0` 之前,「它是不是已含某一员」是个猜,读者不猜 —— 消费方先去掉后缀,或按自己的律定了再问。
166
+ - **版本先于事件判**:坏版本对任何事件都抛(壳属主事件、不在集里的名字也一样),不会被读成「不归引擎」。事件名按**属主元组的成员**判(不是对象键读),`"constructor"` / `"__proto__"` 一类原型链上的名字 ⇒ `false`。
167
+ - 比较是**数值、逐段**(不是字符串序:`9.0.0` < `26.0.0` < `100.0.0`;`26.2.0` < `26.10.0`),段长不设上限(超过 2^53 的段也按数值精确比)。
168
+ - **对端版本位缺席**是消费方的事(底线各家不同):函数不收 `undefined`,缺席时传你方支持底线。
169
+
170
+ ### 三问
171
+
172
+ - **谁需要**:按属主表分流的消费方 —— client-core(重生成的属主表 · 请求体只投引擎属主事件)· cli(本地座位表)· web-client / desktop(随 client-core 的镜像)· web-admin(凡读属主表决定「交引擎还是本端跑」的地方)—— 对着一台可能还没提 26.0.0 的服务端,要判「这只钩子交过去,对端会不会跑」。没有这张表,每个消费方各写一份特例表,一个事实多个来源。
173
+ - **谁受伤**:无。纯加性:校验、读数、属主元组的型与顺序一字不变;属主集没有新成员,穷举 `Record<EngineOwnedHookEvent, …>` / `switch` 的消费方提货不会编译红;不读新导出的消费方零动作。
174
+ - **补偿**:不适用(无人受伤)。
175
+
176
+ ### 各消费方
177
+
178
+ | 消费方 | 读点 | 动作 |
179
+ |---|---|---|
180
+ | client-core | 重生成的属主表 · 请求体只投引擎属主事件的那一步 | 请托的读法:对端契约版本读自 `settingsContract.version`(缺席传支持底线)后,**交引擎 ⟺ 属主表说 `engine` ∧ `engineOwnsHookEventAt(event, 对端契约版本)`**;自己手写的 `PermissionDenied` 特例表(若有)在提货本版后退役,不留第二个来源 |
181
+ | cli | SDK 入口面转出的属主集 · 本地座位表 | 同上;座位表里「引擎点亮、本地另有触发点」那一组按读者的答案分流,不再按特例 |
182
+ | web-client / desktop | 随 client-core 镜像 | 零代码改动(读法随 client-core) |
183
+ | web-admin | 凡读属主表决定「交引擎还是本端跑」的地方(若有) | 同上;没有这样的读点则零改动 |
184
+ | server | 内嵌本包、在 `/v1/capabilities` 报 `settingsContract.version` 的一方 | 零代码改动(它是被判的一端) |
185
+ | sdk | 契约套件 | 零代码改动;语料不变 |
186
+ | test | 黑盒判据 | 见下「黑盒判据」 |
187
+
188
+ ### 黑盒判据(从包的导出面可执行,不引用内部实现)
189
+
190
+ - **G1 表**:`Object.keys(ENGINE_OWNED_HOOK_EVENT_SINCE)` 恰是 `ENGINE_OWNED_HOOK_EVENTS` 的十员;`PermissionDenied` = `"26.0.0"`,其余九员 = `"1.0.0"`;表是冻结的。
191
+ - **G2 读者边界**:`engineOwnsHookEventAt("PermissionDenied", "25.1.0")` = `false`;`"26.0.0"` = `true`;`("Stop", "1.0.0")` = `true`;`("SessionStart", "999.0.0")` = `false`(壳属主恒假)。
192
+ - **G3 坏版本抛**:`("Stop", "26")` · `("Stop", "")` · `("Stop", "v26.0.0")` · `("Stop", "26.0.0-rc.1")` · `("Stop", undefined)` 都抛 `TypeError`;`("SessionStart", "26")` 同样抛(先判版本)。
193
+ - **G4 数值序**:`("PermissionDenied", "9.0.0")` = `false`,`("PermissionDenied", "100.0.0")` = `true`,`("PermissionDenied", "25.10.0")` = `false`。
194
+
195
+ ### 钉
196
+
197
+ `test/hooks-engine-owned-since-26.1.0.test.ts`:表的键集恰 = 属主集(运行期)· 表的键型 / 事件型的类型等式(类型检查期)· **编译期红**:把真源 `src/hooks.ts` 变异两刀过 tsc —— 属主元组多一员而表里没有它 ⇒ 红,表里多一个不在属主集里的键 ⇒ 红(外加未变异对照零诊断,红归因于变异本身)·
198
+ `PermissionDenied` = `26.0.0`、其余九员 = `1.0.0` 逐员硬钉 · 值的出处对 tag 史的核对(`v1.0.0` / `v25.1.0` / `v26.0.0` 的属主集;没有 tag 的浅克隆里这一组跳)· 冻结 · 每个值是读者认的完整 `x.y.z` 且 ≤ 当前包版本 ·
199
+ 读者:每员 × {起始版本前一版 ⇒ `false`,起始版本 ⇒ `true`,补丁 / 次 / 主三档更高 ⇒ `true`} · 壳属主事件与不在集里的名字(含原型链名)恒 `false` · 数值序而非字符串序 · 读者与 `HOOK_EVENT_OWNER` 在当前版本上逐事件同答 · 一组坏串与一组非字符串入参(含 `undefined`)都抛、句子稳定、不回显 · 版本先于事件判 · 文书四处(README 规则、头注、llms 两档)。
200
+ 变异(本车跑过,每刀都红):比较方向反了、PermissionDenied 起始版本改小、Stop 起始版本改小、比较改字符串序、相等边判 `false`、先判事件再判版本、表不冻结、预发布段被接受、事件名改用 `in` 读(原型链名漏进)。
201
+
202
+ **自 v26.0.0 起运行期代码有改动的公开导出(机器重算;上界 —— 可达 ≠ 一定变,不可达 ⇒ 一定不变;本版新增的导出不入表)**
203
+
204
+ ```text
205
+ (无)
206
+ ```
207
+
11
208
  ## 26.0.0 — 2026-11-10 — major:`PermissionDenied` 的属主改判 engine(`ENGINE_OWNED_HOOK_EVENTS` 十员)· `models[].headers` 的容器必须是对象(与 `extraBody` 同一只判官,`PARSE_TRANSPARENT_KEYS` 少一行)· 一致性门账本加 `kind: "posture"`(消费方姿态,只盖「给得少」)· 语料里的 artifact 摘要按内容铸 · 墓碑表加 `STREAM_APPROVAL_ENABLED`(`removed`:设了即拒启)· 到期删码九条(窗已关的八步一次性迁移 + fleet 平铺引擎状态方言)
12
209
 
13
210
  > 档位(按发版纪律):**major** —— 属主表读数变(`HOOK_EVENT_OWNER.PermissionDenied` 由 `shell` 变 `engine`:按属主分流的消费方同一份配置跑出不同结果)· 校验收紧(`models[].headers` 的非对象容器由受理变拒;部署 env 里留着 `STREAM_APPROVAL_ENABLED` 由起服变拒启)· 类型改形(`KnownDivergence` / `PathDivergence` / `OutcomeDivergence` / `LedgerRow` 按类收窄,读 `LedgerRow.window` 要先判类)· 到期删码(导出删六名、`migrateStoredDocuments` 去掉第二参、迁移 id / 收据词 / 收据文档三只闭集收窄、`SchedulerParseWarning` 少一臂、fleet 两只形少八个平铺字段;窗内没迁的存量旧形由「迁移改写」变为既有的响亮拒 —— 调度店一步例外:旧形逐字读出,见 BREAKING ⑤)。语料两件(c48 金样翻面、artifact 摘要真算)随版。
package/README.md CHANGED
@@ -47,6 +47,22 @@ therefore shows only `zod`. Node built-ins only (`node:crypto`, `node:fs`).
47
47
  > zod 3, nested inside every zod-4 host). The move to zod 4 did not change what any schema accepts or produces —
48
48
  > the conformance corpus reads byte-identically on both — only the wording of validation errors (see CHANGELOG 11.0.0).
49
49
 
50
+ ## 升级指引:26.1.x → 27.0.0(BREAKING:目录条目 `fallbacks` 的坏形整条拒 · 墓碑表加 `MODEL_DEGRADE_ON`(`replaced`)与 `MODEL_DEGRADE_REACTIVE`(`removed`))
51
+
52
+ 两处**不加性**的边(读数逐条、三问、各消费方改法见 CHANGELOG 27.0.0 与 `docs/CONSUMER-INTEGRATION.md` §26):
53
+ 1. **目录条目多一个可选席 `fallbacks?: string[]`**(引擎每模型回落链的声明位,按跳序):缺席 = 未声明(本包不铸键),`[]` = 声明了、没有链;**本包只判形**(非空串数组),词在不在目录 · 指自己 · 重复 · 超几跳一概不判 —— 唯一的判官是引擎的目录门。
54
+ - **读数变化(不加性)**:此前目录条目上的 `fallbacks` 是契约外的键 —— 视图面(`buildEffective` / `readEffectiveWire` / `loadLocalConfig` / `FileConfigStore.getEffective`)把带它的条目一律整条丢(`entry-unknown-key`),文档面(`validateDomain` / `writeDomainFile` / `getDomain` / `parseDomain`)剥键受理;自此合形的装上,
55
+ **坏形(非数组 · `null` · 元素不是非空串)的条目整条被拒** —— 文档面整份拒,读口逐条丢并报 `entry-dropped`(`reasonCode: "entry-schema-invalid"`;被 `roles` / `atMention.only` / `tierGroups` 引用或是唯一一条时走既有的级联 / 零幸存者律,整个 `models` 域 `domain-defaulted`)。没写这个键的条目零变化。
56
+ - **动作**:升级前对存着的 `models` 文档(含存下来要续跑的、中心名册草稿)自查 `fallbacks`:每个值必须是非空串数组,或把整个键删掉。对 `ModelEntry` 的 `keyof` 写穷举表的地方编译红(多一个可选键):补一列。
57
+ 2. **墓碑表 `RETIRED_ENVS` 加两行**:`MODEL_DEGRADE_ON`(`replaced` → `MODEL_FALLBACK_ON`:门词的值语义变了 —— `budget` 不再是门词,`network` / `auth` / `stream_torn` 是新词,作用面由整只 Brain 的一个目标变成每条目录链,别照抄旧值)与 `MODEL_DEGRADE_REACTIVE`(`removed`:整只 Brain 的反应式降级壳删除,出路是在目录条目上声明 `fallbacks`)。
58
+ 部署 env 里留着它们(任何值)⇒ 提货本版的引擎拒启,拒句点名键、不回显值;空串 = 未设。近预算降级线的 `MODEL_DEGRADE_TO` / `MODEL_DEGRADE_AT_COST_FRACTION` / `MODEL_DEGRADE_TO_VISION` 仍是活旋钮,不在表里。
59
+
60
+ ## 升级指引:26.0.x → 26.1.0(minor,加性:引擎属主钩子事件的逐员起始契约版本 `ENGINE_OWNED_HOOK_EVENT_SINCE` + 一只读者 `engineOwnsHookEventAt`)
61
+
62
+ 只加导出(包根与 `./hooks` 子路径各三名:值 `ENGINE_OWNED_HOOK_EVENT_SINCE` / `engineOwnsHookEventAt`,型 `EngineOwnedHookEvent`),零校验变化、零读数变化 —— 零动作可升。
63
+ 按属主表(`HOOK_EVENT_OWNER` / `ENGINE_OWNED_HOOK_EVENTS`)决定「这只钩子交引擎还是本端跑」的消费方,请把「对端那一半从哪一版契约起也这么认」改读这两个导出(规则一句话与细则见下文「钩子事件按属主分流」一节);
64
+ 此前这件事只写在属主表的型注释里,消费方只能各自手写特例表。
65
+
50
66
  ## 升级指引:25.1.x → 26.0.0(BREAKING:`PermissionDenied` 的属主改判 engine · `models[].headers` 的容器必须是对象 · 一致性门账本加 `kind: "posture"` · 墓碑表加 `STREAM_APPROVAL_ENABLED`)
51
67
 
52
68
  四处**不加性**的边(律、读数逐条、三问、锁步次序与各消费方改法见 CHANGELOG 26.0.0 与 `docs/CONSUMER-INTEGRATION.md` §25):
@@ -811,7 +827,8 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
811
827
  - **Hooks contract** (`hooks.ts`, subpath `./hooks`): the CC-parity hook surface — `HOOK_EVENTS` (33 events:
812
828
  the CC 2.1.198 set of 27 plus `CwdChanged` / `FileChanged` / `MessageDisplay` / `DirectoryAdded` and, from
813
829
  2.0.0, the model-switch pair `PreModelSwitch` / `PostModelSwitch`), the single-owner map
814
- `HOOK_EVENT_OWNER` (engine | shell), the matcher-field table, a per-event input schema (`HookInput`),
830
+ `HOOK_EVENT_OWNER` (engine | shell) with, from 26.1.0, each engine-owned member's first contract version `ENGINE_OWNED_HOOK_EVENT_SINCE` and its one reader
831
+ `engineOwnsHookEventAt(event, contractVersion)` (the consumption rule is the section 「钩子事件按属主分流」), the matcher-field table, a per-event input schema (`HookInput`),
815
832
  the output/decision shapes (`SyncHookOutput` / `HookSpecificOutput` / `HookPermissionRequestDecision`),
816
833
  the config surface (defined in `hooks-config.ts`, re-exported by `./hooks`): `HOOK_ENTRY_TYPES` (CC 2.1.296's five: command / prompt / agent / http /
817
834
  `mcp_tool`; the field table carries `args` — the exec-form argument list — on `command` entries and `onFailure` — `HOOK_ON_FAILURE_WORDS` = `continue` | `block`, type `HookOnFailure` —
@@ -987,6 +1004,23 @@ user: a client that runs under a different user should create the root itself be
987
1004
  Fleet-only domains (`workers`, `hosts`, `systems`) are omitted on a single machine — they resolve to schema
988
1005
  defaults. Each `config.d/<domain>.json` is exactly that domain's zod object.
989
1006
 
1007
+ ## 钩子事件按属主分流:什么时候交引擎(消费规则,26.1.0 起)
1008
+
1009
+ 属主表(`HOOK_EVENT_OWNER` / `ENGINE_OWNED_HOOK_EVENTS`)说「这只事件归哪一半」,不说「对端那一半从哪一版契约起也这么认」。属主表会变(26.0.0 把 `PermissionDenied` 由 `shell` 改判 `engine`),
1010
+ 而对端(服务端)提货本包的节奏不归你方定:对着一台还没提那一版的服务端,把这只钩子装进请求体交给它,它不认这只事件归引擎、不注册它 —— 本端以为交出去了 ⇒ **两边都不跑**,wire 上看不出来。
1011
+
1012
+ **规则(一句)**:把一只钩子事件交给引擎 ⟺ 属主表说它是 `engine` ∧ 对端契约版本 ≥ 该员的起始版本,即 `engineOwnsHookEventAt(event, 对端契约版本) === true`;不满足 ⇒ 不交(不进给对端的请求体),按本端的读法处理。
1013
+
1014
+ - **起始版本**住在 `ENGINE_OWNED_HOOK_EVENT_SINCE`:引擎属主十员各一行,完整 `x.y.z`,冻结;键集恰 = `ENGINE_OWNED_HOOK_EVENTS`(加员而没给起始版本、或表里有不在属主集里的键,都是编译红)。
1015
+ `PermissionDenied` = `26.0.0`;其余九员 = `1.0.0`(本包现名的第一个版本,它的属主集里已是这九员 —— 这九员比改名还早,所以 `1.0.0` 是下限、不是引入日期,凡报得出契约版本的对端都不低于它)。
1016
+ 值是从各 tag 的 `src/hooks.ts` 读出来的,不是凭注释写的。以后再有成员加进属主集,表里多一行、规则自动适用;消费方**不要**自己维护「哪一员从哪一版起」的特例表。
1017
+ - **对端契约版本**读自服务端 `GET /v1/capabilities` 的 `settingsContract.version`(服务端内嵌的本包版本;自 7.147.0 起的服务端才带这一位,更老的没有)。**缺席或读不出 ⇒ 传你方支持底线**:你方支持的最老一代服务端所内嵌的契约版本 —— 对那一代判,不当 0、也不当最新。
1018
+ 底线各家不同,所以缺省由消费方给,读者不收 `undefined`。
1019
+ - **`contractVersion` 只收完整的 `x.y.z`**(十进制、无前导零、无预发布 / 构建段、无 `v` 前缀);其余一律**抛 `TypeError`**(稳定句,以 `engineOwnsHookEventAt: contractVersion must be a complete x.y.z version` 起头,不回显入参),不猜、不当 0。
1020
+ **预发布段的律**:`26.0.0-rc.1` 这类排在它的正式版之前,「是不是已含某员」是个猜,读者不猜 —— 消费方先去掉后缀、或自己定律后再问。版本先于事件判:坏版本不会被读成「不归引擎」。
1021
+ - 事件不在属主集里(壳属主事件,或根本不是钩子事件的名字)⇒ `false`,任何版本都是。
1022
+ - 对当前包版本,`engineOwnsHookEventAt(e, 当前版本)` 恰 = `HOOK_EVENT_OWNER[e] === "engine"`(两处同源,不会各说各的)。
1023
+
990
1024
  ## 发版纪律(semver,1.x 起)
991
1025
 
992
1026
  自 `1.0.0`(改名)起本包按**标准 semver** 发版;`0.x` 时代的「破坏性变更必 bump minor」规矩**已撤**
@@ -1 +1 @@
1
- 26.0.0
1
+ 27.0.0
package/dist/hooks.d.ts CHANGED
@@ -85,16 +85,49 @@ export type HookOwner = z.infer<typeof HookOwner>;
85
85
  /**
86
86
  * Events whose TRIGGER lives in the engine half of sema's two-process wire — the owner of an event is the half where the
87
87
  * occurrence it names happens:
88
- * - tool-execution chain: PreToolUse / PostToolUse / PostToolUseFailure / PostToolBatch, and PermissionDenied (26.0.0) — a
88
+ * - tool-execution chain: PreToolUse / PostToolUse / PostToolUseFailure / PostToolBatch, and PermissionDenied — a
89
89
  * tool call refused by the engine's tool gate; the refusal is decided in the tool-execution chain, not in a dialog
90
90
  * - compaction (runs engine-side): PreCompact / PostCompact
91
91
  * - model-turn boundary (run-end is only known to the engine): Stop / StopFailure / UserPromptSubmit
92
92
  * Everything else is shell-owned (UI / lifecycle: the permission dialog — PermissionRequest —, sessions, teams, worktrees,
93
93
  * files live in the shell). A shell that routes hooks by owner derives its table from this one (no second copy).
94
+ *
95
+ * FROM WHICH CONTRACT VERSION a member counts as engine-owned is data, not prose: {@link ENGINE_OWNED_HOOK_EVENT_SINCE} (one row
96
+ * per member, a compile error when a member has no row), read through {@link engineOwnsHookEventAt} — a peer that embeds an older
97
+ * contract than a member's row does not know the member is engine-owned. A consumer that routes by this set must not keep its own
98
+ * table of "which member joined at which version".
94
99
  */
95
100
  export declare const ENGINE_OWNED_HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "PreCompact", "PostCompact", "Stop", "StopFailure", "UserPromptSubmit", "PermissionDenied"];
96
101
  /** owner per event — single owner; the non-owner side never fires it (dedup rule). */
97
102
  export declare const HOOK_EVENT_OWNER: Readonly<Record<HookEventName, HookOwner>>;
103
+ /** One member of {@link ENGINE_OWNED_HOOK_EVENTS} (the events whose trigger lives in the engine half). */
104
+ export type EngineOwnedHookEvent = (typeof ENGINE_OWNED_HOOK_EVENTS)[number];
105
+ /**
106
+ * The first version of THIS package whose {@link ENGINE_OWNED_HOOK_EVENTS} carried each member — the contract version from which a peer that
107
+ * embeds this package treats the event as engine-owned (the server reports its embedded version as `settingsContract.version` on
108
+ * `GET /v1/capabilities`). A complete `x.y.z`.
109
+ *
110
+ * One row per member of {@link ENGINE_OWNED_HOOK_EVENTS}, no more, no fewer: a member added to that set without a row here, or a row for an event
111
+ * that is not in the set, does not compile. Values were read from the release history (each tag's `src/hooks.ts`), not from memory:
112
+ * - `PermissionDenied` — the tool gate's refusal — became engine-owned in 26.0.0 (the release before it owned nine events and listed it as shell-owned);
113
+ * - the other nine are `1.0.0`: the first version under this package's current name already listed them, in this order. They are older than
114
+ * that (the set predates the rename), so `1.0.0` is the floor of what this package's name can report, not an introduction date — every peer that
115
+ * reports a contract version of this package has it.
116
+ *
117
+ * Frozen: every reader in a process shares it. Read it through {@link engineOwnsHookEventAt}; do not compare against it by hand.
118
+ */
119
+ export declare const ENGINE_OWNED_HOOK_EVENT_SINCE: Readonly<Record<EngineOwnedHookEvent, string>>;
120
+ /**
121
+ * Is `event` engine-owned for a peer whose embedded contract is `contractVersion`? `true` ⟺ `event` is a member of {@link ENGINE_OWNED_HOOK_EVENTS}
122
+ * AND `contractVersion` ≥ its row in {@link ENGINE_OWNED_HOOK_EVENT_SINCE} (numeric, segment by segment). Anything else — a shell-owned event, a
123
+ * name that is not a hook event at all — is `false` at every version.
124
+ *
125
+ * `contractVersion` is a complete `x.y.z` and nothing else; a malformed one THROWS a `TypeError` (checked before the event, so a bad version never reads
126
+ * as "not engine-owned"): a pre-release (`26.0.0-rc.1`) sorts before its release and whether it already carried a member is a guess this function does
127
+ * not make, so the caller strips the suffix (or applies its own rule) before asking. `undefined` is not accepted either: when the peer reports no
128
+ * version, the consumer passes the contract version embedded by the oldest peer generation it supports — that is the generation it must be right about.
129
+ */
130
+ export declare function engineOwnsHookEventAt(event: string, contractVersion: string): boolean;
98
131
  /**
99
132
  * Which INPUT FIELD an entry's `matcher` string is matched against, per event (`null` = matchers are
100
133
  * ignored for the event; every entry matches). Ported from the shell's getMatchingHooks switch. HOW the matcher is read
package/dist/hooks.js CHANGED
@@ -51,12 +51,17 @@ export const HookOwner = z.enum(["engine", "shell"]);
51
51
  /**
52
52
  * Events whose TRIGGER lives in the engine half of sema's two-process wire — the owner of an event is the half where the
53
53
  * occurrence it names happens:
54
- * - tool-execution chain: PreToolUse / PostToolUse / PostToolUseFailure / PostToolBatch, and PermissionDenied (26.0.0) — a
54
+ * - tool-execution chain: PreToolUse / PostToolUse / PostToolUseFailure / PostToolBatch, and PermissionDenied — a
55
55
  * tool call refused by the engine's tool gate; the refusal is decided in the tool-execution chain, not in a dialog
56
56
  * - compaction (runs engine-side): PreCompact / PostCompact
57
57
  * - model-turn boundary (run-end is only known to the engine): Stop / StopFailure / UserPromptSubmit
58
58
  * Everything else is shell-owned (UI / lifecycle: the permission dialog — PermissionRequest —, sessions, teams, worktrees,
59
59
  * files live in the shell). A shell that routes hooks by owner derives its table from this one (no second copy).
60
+ *
61
+ * FROM WHICH CONTRACT VERSION a member counts as engine-owned is data, not prose: {@link ENGINE_OWNED_HOOK_EVENT_SINCE} (one row
62
+ * per member, a compile error when a member has no row), read through {@link engineOwnsHookEventAt} — a peer that embeds an older
63
+ * contract than a member's row does not know the member is engine-owned. A consumer that routes by this set must not keep its own
64
+ * table of "which member joined at which version".
60
65
  */
61
66
  export const ENGINE_OWNED_HOOK_EVENTS = [
62
67
  "PreToolUse",
@@ -72,6 +77,62 @@ export const ENGINE_OWNED_HOOK_EVENTS = [
72
77
  ];
73
78
  /** owner per event — single owner; the non-owner side never fires it (dedup rule). */
74
79
  export const HOOK_EVENT_OWNER = Object.fromEntries(HOOK_EVENTS.map((e) => [e, ENGINE_OWNED_HOOK_EVENTS.includes(e) ? "engine" : "shell"]));
80
+ /**
81
+ * The first version of THIS package whose {@link ENGINE_OWNED_HOOK_EVENTS} carried each member — the contract version from which a peer that
82
+ * embeds this package treats the event as engine-owned (the server reports its embedded version as `settingsContract.version` on
83
+ * `GET /v1/capabilities`). A complete `x.y.z`.
84
+ *
85
+ * One row per member of {@link ENGINE_OWNED_HOOK_EVENTS}, no more, no fewer: a member added to that set without a row here, or a row for an event
86
+ * that is not in the set, does not compile. Values were read from the release history (each tag's `src/hooks.ts`), not from memory:
87
+ * - `PermissionDenied` — the tool gate's refusal — became engine-owned in 26.0.0 (the release before it owned nine events and listed it as shell-owned);
88
+ * - the other nine are `1.0.0`: the first version under this package's current name already listed them, in this order. They are older than
89
+ * that (the set predates the rename), so `1.0.0` is the floor of what this package's name can report, not an introduction date — every peer that
90
+ * reports a contract version of this package has it.
91
+ *
92
+ * Frozen: every reader in a process shares it. Read it through {@link engineOwnsHookEventAt}; do not compare against it by hand.
93
+ */
94
+ export const ENGINE_OWNED_HOOK_EVENT_SINCE = Object.freeze({
95
+ PreToolUse: "1.0.0",
96
+ PostToolUse: "1.0.0",
97
+ PostToolUseFailure: "1.0.0",
98
+ PostToolBatch: "1.0.0",
99
+ PreCompact: "1.0.0",
100
+ PostCompact: "1.0.0",
101
+ Stop: "1.0.0",
102
+ StopFailure: "1.0.0",
103
+ UserPromptSubmit: "1.0.0",
104
+ PermissionDenied: "26.0.0",
105
+ });
106
+ /** A complete `x.y.z`: three decimal numbers, no leading zeros (so numeric order is digit-count order, then digits), no pre-release / build part, no prefix. */
107
+ const CONTRACT_VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
108
+ function readContractVersion(value) {
109
+ const m = typeof value === "string" ? CONTRACT_VERSION.exec(value) : null;
110
+ if (m === null) {
111
+ throw new TypeError("engineOwnsHookEventAt: contractVersion must be a complete x.y.z version string (decimal digits, no leading zeros, no pre-release or build part, no `v` prefix) — " +
112
+ "the peer's reported contract version, or the one embedded by the oldest peer generation the consumer supports when the peer reports none");
113
+ }
114
+ return [BigInt(m[1]), BigInt(m[2]), BigInt(m[3])];
115
+ }
116
+ /**
117
+ * Is `event` engine-owned for a peer whose embedded contract is `contractVersion`? `true` ⟺ `event` is a member of {@link ENGINE_OWNED_HOOK_EVENTS}
118
+ * AND `contractVersion` ≥ its row in {@link ENGINE_OWNED_HOOK_EVENT_SINCE} (numeric, segment by segment). Anything else — a shell-owned event, a
119
+ * name that is not a hook event at all — is `false` at every version.
120
+ *
121
+ * `contractVersion` is a complete `x.y.z` and nothing else; a malformed one THROWS a `TypeError` (checked before the event, so a bad version never reads
122
+ * as "not engine-owned"): a pre-release (`26.0.0-rc.1`) sorts before its release and whether it already carried a member is a guess this function does
123
+ * not make, so the caller strips the suffix (or applies its own rule) before asking. `undefined` is not accepted either: when the peer reports no
124
+ * version, the consumer passes the contract version embedded by the oldest peer generation it supports — that is the generation it must be right about.
125
+ */
126
+ export function engineOwnsHookEventAt(event, contractVersion) {
127
+ const peer = readContractVersion(contractVersion);
128
+ if (!ENGINE_OWNED_HOOK_EVENTS.includes(event))
129
+ return false;
130
+ const since = readContractVersion(ENGINE_OWNED_HOOK_EVENT_SINCE[event]);
131
+ for (let i = 0; i < 3; i++)
132
+ if (peer[i] !== since[i])
133
+ return peer[i] > since[i];
134
+ return true;
135
+ }
75
136
  /**
76
137
  * Which INPUT FIELD an entry's `matcher` string is matched against, per event (`null` = matchers are
77
138
  * ignored for the event; every entry matches). Ported from the shell's getMatchingHooks switch. HOW the matcher is read
@@ -81,6 +81,10 @@ export const RETIRED_ENVS = [
81
81
  ["LSP_ENABLED", "the sandbox-lane LSP bridge was removed (e2b / k8s lanes mount no LSP); unset it — the host lane's switch is LSP_HOST_ENABLED", "removed"],
82
82
  // 呈卡协议的回退开关:审批卡只有一种帧族之后,它「关」那一档(回退发旧族卡)不存在了 —— 没有可关的东西,也没有可 rename 的目标。任何显式值都拒。
83
83
  ["STREAM_APPROVAL_ENABLED", "the approval-card fallback switch was retired: approval cards have a single frame family, so its off position (falling back to the legacy card frames) no longer exists and there is nothing left to switch", "removed"],
84
+ // 整只 Brain 的反应式降级壳整只删除:回落链是目录数据(`ModelEntry.fallbacks`),不再是「一个 env 开关 + 一个全局目标」。门词旋钮有现名、但值语义变了(`budget` 出表,新增三词,作用面由一个目标变成每条目录链)⇒ replaced;
85
+ // 壳的总开关没有可 rename 的目标(出路是在目录条目上声明链,不是换个 env 名)⇒ removed。近预算降级线的三个旋钮(`MODEL_DEGRADE_TO` / `_AT_COST_FRACTION` / `_TO_VISION`)仍是活旋钮,不在本表。
86
+ ["MODEL_DEGRADE_ON", "MODEL_FALLBACK_ON", "replaced", "the gate words moved to the engine's per-model fallback chain: budget is no longer a gate word, network / auth / stream_torn are new, and the gate now applies to every catalog chain instead of one whole-Brain target"],
87
+ ["MODEL_DEGRADE_REACTIVE", "the env-driven whole-Brain reactive degrade shell was retired: declare `fallbacks` on the catalog entry (models.models[].fallbacks) — a fallback chain is catalog data now; the gate words that decide when a hop is taken are MODEL_FALLBACK_ON", "removed"],
84
88
  ];
85
89
  // 冻结:拿到导出的人改不了拒启判据(读拒句的与投影 wire 的是同一个数组对象)。
86
90
  for (const row of RETIRED_ENVS)
package/dist/types.d.ts CHANGED
@@ -211,6 +211,7 @@ export declare const ModelEntry: z.ZodObject<{
211
211
  xhigh: z.ZodOptional<z.ZodNullable<z.ZodString>>;
212
212
  max: z.ZodOptional<z.ZodNullable<z.ZodString>>;
213
213
  }, z.core.$strict>>;
214
+ fallbacks: z.ZodOptional<z.ZodArray<z.ZodString>>;
214
215
  contextWindow: z.ZodOptional<z.ZodNumber>;
215
216
  maxTokens: z.ZodOptional<z.ZodNumber>;
216
217
  autoCompactTokens: z.ZodOptional<z.ZodNumber>;
@@ -333,6 +334,7 @@ export declare const ModelsConfig: z.ZodObject<{
333
334
  xhigh: z.ZodOptional<z.ZodNullable<z.ZodString>>;
334
335
  max: z.ZodOptional<z.ZodNullable<z.ZodString>>;
335
336
  }, z.core.$strict>>;
337
+ fallbacks: z.ZodOptional<z.ZodArray<z.ZodString>>;
336
338
  contextWindow: z.ZodOptional<z.ZodNumber>;
337
339
  maxTokens: z.ZodOptional<z.ZodNumber>;
338
340
  autoCompactTokens: z.ZodOptional<z.ZodNumber>;
@@ -2435,6 +2437,7 @@ export declare const DOMAIN_SCHEMAS: {
2435
2437
  xhigh: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2436
2438
  max: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2437
2439
  }, z.core.$strict>>;
2440
+ fallbacks: z.ZodOptional<z.ZodArray<z.ZodString>>;
2438
2441
  contextWindow: z.ZodOptional<z.ZodNumber>;
2439
2442
  maxTokens: z.ZodOptional<z.ZodNumber>;
2440
2443
  autoCompactTokens: z.ZodOptional<z.ZodNumber>;
package/dist/types.js CHANGED
@@ -516,6 +516,20 @@ export const ModelEntry = z.object({
516
516
  * face's rule for a closed vocabulary, unlike `compat`'s parse-transparent carry. What each value means on the wire is the reading
517
517
  * consumer's call; this package only carries the declaration. */
518
518
  thinkingLevelMap: ModelThinkingLevelMap.optional(),
519
+ /** This model's fallback chain — the engine's per-model `fallbacks` (`RunnerDeps.models.<name>.fallbacks`): the names of the catalog entries
520
+ * (or tier words / aliases, which the engine resolves against its own expanded catalog) a call falls back to, in hop order, when this model
521
+ * cannot serve it. THREE-STATE like the capability bits above: ABSENT = not declared (this package never mints the key), `[]` = declared, no
522
+ * chain (the engine reads it as "no chain").
523
+ *
524
+ * **This package judges the FORM only: an array of non-empty strings.** A bad form refuses the WHOLE entry — a string, `null`, an object, an
525
+ * empty-string element, a non-string element: nothing is stripped and nothing is defaulted (the strict write face refuses the document; the read
526
+ * legs drop the entry with `entry-dropped` / `entry-schema-invalid` under the same cascade as any other bad entry — the entry is referenced by
527
+ * `roles` / `atMention` / `tierGroups`, or is the only one ⇒ the whole `models` domain defaults), the same law as {@link ModelEntry}`.thinkingLevelMap`.
528
+ * Whether a word names a catalog entry, whether it points at the entry itself, repeats, or makes the chain longer than the engine allows is NOT
529
+ * judged here: the engine's catalog gate is the ONE judge of that (its refusal names `RunnerDeps.models.<name>.fallbacks`), and a second judge
530
+ * in this package would be a second source of the same fact. The chain is FLAT: a hop's own `fallbacks` is not followed (that is how the engine's catalog door reads a chain since core 7.67.0; this package only carries the declaration and does not verify engine behavior). Not an env-leg key: the
531
+ * env leg has no per-member seat in the catalog, so a chain is declared in the catalog document. */
532
+ fallbacks: z.array(z.string().min(1)).optional(),
519
533
  contextWindow: INTEGER.positive().optional(),
520
534
  maxTokens: INTEGER.positive().optional(),
521
535
  /** Auto-compaction trigger threshold (tokens) for this model — web-admin 显式下发时本地 FileConfigStore
@@ -4,9 +4,9 @@
4
4
  > 每次全量重算并逐名比对 —— 加 / 删 / 改形一个导出而不重生成本档 ⇒ 红。导出面的每次变动因此以本档的 diff 出现在评审里。
5
5
  > 形:`value` = 运行期拿得到的值;`type` = 只在类型层;`value+type` = 同名的值与类型(zod schema 与它推出的类型)。
6
6
 
7
- 子路径 24 条(资产出口 `./package.json` / `./fleet-paths.json` 不是模块,不列),导出名合计 1516 个(同名在多条子路径上各计一次)。
7
+ 子路径 24 条(资产出口 `./package.json` / `./fleet-paths.json` 不是模块,不列),导出名合计 1522 个(同名在多条子路径上各计一次)。
8
8
 
9
- ## `.`(795)
9
+ ## `.`(798)
10
10
 
11
11
  - `A2aConfig` — value+type
12
12
  - `A2aPeerSpec` — value+type
@@ -143,6 +143,7 @@
143
143
  - `DroppedEntryIdentity` — type
144
144
  - `DroppedEntryReasonCode` — type
145
145
  - `ENGINE_OWNED_HOOK_EVENTS` — value
146
+ - `ENGINE_OWNED_HOOK_EVENT_SINCE` — value
146
147
  - `ENGINE_SIGNAL_KEY` — value
147
148
  - `ENV_MODELS_DECISIONS` — value
148
149
  - `ENV_MODELS_DOCUMENT` — value
@@ -159,6 +160,7 @@
159
160
  - `ElicitationHookInput` — value
160
161
  - `ElicitationResultHookInput` — value
161
162
  - `EngineDraining` — value+type
163
+ - `EngineOwnedHookEvent` — type
162
164
  - `EngineSignal` — value+type
163
165
  - `EntitlementBudget` — value+type
164
166
  - `EntitlementConfig` — value+type
@@ -653,6 +655,7 @@
653
655
  - `effectiveScopeRole` — value
654
656
  - `emptyEffective` — value
655
657
  - `enabledEntryCount` — value
658
+ - `engineOwnsHookEventAt` — value
656
659
  - `envModelTableDeclared` — value
657
660
  - `envModelTableWriteRefusal` — value
658
661
  - `envModelsDecisionTag` — value
@@ -1300,7 +1303,7 @@
1300
1303
  - `parseSchedulerStore` — value
1301
1304
  - `serializeSchedulerStore` — value
1302
1305
 
1303
- ## `./hooks`(100)
1306
+ ## `./hooks`(103)
1304
1307
 
1305
1308
  - `AgentHookEntry` — value+type
1306
1309
  - `AssistantTurnError` — value+type
@@ -1316,8 +1319,10 @@
1316
1319
  - `DIRECTORY_ADDED_SOURCES` — value
1317
1320
  - `DirectoryAddedHookInput` — value+type
1318
1321
  - `ENGINE_OWNED_HOOK_EVENTS` — value
1322
+ - `ENGINE_OWNED_HOOK_EVENT_SINCE` — value
1319
1323
  - `ElicitationHookInput` — value
1320
1324
  - `ElicitationResultHookInput` — value
1325
+ - `EngineOwnedHookEvent` — type
1321
1326
  - `FileChangedHookInput` — value
1322
1327
  - `HOOKS_CLASSIFICATION_OUTCOMES` — value
1323
1328
  - `HOOKS_DROPPED_PIECE_CODES` — value
@@ -1398,6 +1403,7 @@
1398
1403
  - `WorktreeCreateHookInput` — value
1399
1404
  - `WorktreeRemoveHookInput` — value
1400
1405
  - `classifyHooksConfig` — value
1406
+ - `engineOwnsHookEventAt` — value
1401
1407
  - `hookMatcherForm` — value
1402
1408
  - `hookMatcherSelects` — value
1403
1409
  - `interpolateHookEnvVars` — value
@@ -21,6 +21,7 @@
21
21
  > **25.0.0** 的写权限读口(只有一只 `writeRoleFor`,逐字段角色表 `DOMAIN_FIELD_WRITE_ROLE`,`domainWriteRole` 删)与能力读数两态(`CapabilityReading` 删 `undeclared`)在 §23。
22
22
  > **25.1.0** 的项目登记内容证明键(`contentAttestedAt`,写角色 publisher,读方只问在不在;盖章要在读方升级之后)在 §24。
23
23
  > **26.0.0** 的 `PermissionDenied` 属主改判 engine(锁步次序)、`models[].headers` 容器必须是对象、一致性门账本的 `kind: "posture"`、墓碑表的 `STREAM_APPROVAL_ENABLED` 在 §25。
24
+ > **27.0.0** 的目录条目 `ModelEntry.fallbacks`(引擎每模型回落链的声明位,只判形、坏形整条拒)与墓碑表的 `MODEL_DEGRADE_ON`(`replaced`)/ `MODEL_DEGRADE_REACTIVE`(`removed`)在 §26。
24
25
 
25
26
  ---
26
27
 
@@ -876,3 +877,21 @@ fleet 成员对中心公告的可达地址(`FLEET_ADVERTISE_ADDRESS`,中心往
876
877
  | sdk | 契约套件 · 事件集说明 | 零代码改动;「引擎属主九个」的说明句改十 |
877
878
  | test | 黑盒判据 | 见 CHANGELOG 26.0.0「黑盒判据」G1–G4 |
878
879
 
880
+
881
+ ## 26. 目录条目的 `fallbacks`(只判形)· 墓碑 `MODEL_DEGRADE_ON` / `MODEL_DEGRADE_REACTIVE`(27.0.0 起)—— server、web-admin、cli、client-core、sdk、test 各自的读法
882
+
883
+ **`ModelEntry.fallbacks?: string[]`**(引擎每模型回落链 `RunnerDeps.models.<名>.fallbacks` 的声明位):按跳序的非空串数组;缺席 = 未声明(本包不铸键),`[]` = 声明了、没有链(引擎读作「无链」)。**本包只判形**:非数组 / `null` / 元素不是非空串 ⇒ 条目整条拒、不剥键(严写面与文档面整份拒;读腿逐条丢,`entry-dropped` / `entry-schema-invalid`,被 `roles` / `atMention.only` / `tierGroups` 引用或是唯一一条 ⇒ 既有级联 / 零幸存者律,整个 `models` 域 `domain-defaulted`),与 `thinkingLevelMap` 同律(§19)。
884
+ **不判有效性**:词在不在目录、指自己、重复、超几跳 —— 一概不判,唯一的判官是引擎目录门(拒句点名 `RunnerDeps.models.<名>.fallbacks`);跨域引用判官也不把它当引用。词可以是档位词 / 别名(在引擎的展开目录上解);链是平的,一跳自己的 `fallbacks` 不被走(引擎自 7.67.0 起的读法,本包不验证)。不是 env 腿的键。
885
+ **读数变**(27.0.0 的 major 依据):此前带这个键的条目,视图面一律整条丢(`entry-unknown-key`),文档面剥键受理;自此合形的两面都装上,坏形文档面整份拒、视图面丢但词改 `entry-schema-invalid`。
886
+
887
+ **墓碑**:`RETIRED_ENVS` 表尾两行。`MODEL_DEGRADE_ON`(`replaced` → `MODEL_FALLBACK_ON`:门词值语义变了 —— `budget` 不再是门词,`network` / `auth` / `stream_torn` 是新词,作用面由整只 Brain 的一个目标变成每条目录链,别照抄旧值);`MODEL_DEGRADE_REACTIVE`(`removed`:整只 Brain 的反应式降级壳删除,出路 = 在目录条目上声明 `fallbacks`)。任何显式值都拒、空串 = 未设;拒句点名键、不回显值;目录 wire `retired[]`(`replaced` 行带 `replacement` + `reason`,`removed` 行只带 `reason`)与 worker 规格写闸随表。`MODEL_DEGRADE_TO` / `MODEL_DEGRADE_AT_COST_FRACTION` / `MODEL_DEGRADE_TO_VISION` 仍是活旋钮,不在表里。进表的判据:没有带着本表的引擎还读这个名 —— 服务端停读这两个键与提货本版同一发版。
888
+
889
+ **谁受伤**:① env 留着这两个键的部署 —— 提货本版的服务端拒启(预期);② 目录条目里已有 `fallbacks` 的文档 —— 合形的此前被丢、自此装上,写坏的文档面此前被剥键受理、自此整份拒。补偿:删 env 键 → 回落链写进目录条目 `fallbacks` → 门词用 `MODEL_FALLBACK_ON`;升级前自查存着的 `models` 文档里每个 `fallbacks` 是非空串数组。
890
+
891
+ | 消费方 | 读点 | 动作 |
892
+ |---|---|---|
893
+ | server | 起服墓碑拒启 · 目录条目投影 · 引擎目录门 | 同一发版停读两只旧键,墓碑拒启格翻成常规格;`retired[]` 多两项;链的有效性只由引擎目录门判 |
894
+ | web-admin | 目录编辑面 · `retired[]` 渲染 | 可选:表单承运 `fallbacks`(只产非空串数组,别把空串当「没有」);`retired[]` 多两行照常渲染 |
895
+ | cli | 手列环境变量目录的旧键 | 删去这两个旧键 |
896
+ | client-core / sdk | 无直接读点 | 零代码改动;语料不变 |
897
+ | test | 黑盒判据 | 见 `CHANGELOG.md` 27.0.0「黑盒判据」G1–G5 |
package/llms-full.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  <!--
2
2
  llms-full.txt — 自包含全文 · 消费方(使用者)视角 · @sema-agent/settings-schema
3
- 重写日期: 2026-11-10 | 包版本: 26.0.0
3
+ 重写日期: 2026-11-11 | 包版本: 27.0.0
4
4
  生成方式: 无生成脚本——按当前树 src/*.ts 导出面 + package.json + README/CHANGELOG 手写事实版。
5
5
  证据约定: 每条"它怎么工作"的断言附 (文件: 符号) 坐标,刻意不用行号(行号逐版腐烂;符号名由
6
6
  typecheck 与 test/package-surface.test.ts、test/docs-hygiene.test.ts 等常驻门钉住)。无证据推断显式标【推断】。
@@ -108,6 +108,8 @@ registry:公网 npmjs,无需私有 registry 配置。
108
108
  --- 6.4.0:`ModelEntry.headers?`(无默认,缺席不铸键)——部署 ↔ 供应商的 per-model 附加请求头,例 `{"anthropic-beta":"context-1m-2025-08-07"}`(开 1M 上下文);头名闭集白名单 × 读它的线路 × 值形的判据**唯一属主是 sema-server**(坏声明 ⇒ 该条目整条不可用,不是丢头照常),本包不复述那张表。修前(≤6.3.0)每条读腿都剥它并报 `unknown-keys-dropped`。6.4.0–25.x 它登记为解析透明键;**26.0.0 起它是自由形对象键,与 `extraBody` 同一只判官**:容器必须是纯 JSON 对象(串 / 数组 / 数 / 布尔 / `null` ⇒ 条目拒,句子 `headers must be a plain JSON object`,不回显值;严写面整份拒,读腿上 `models` 逐条丢、那一条目 `entry-dropped` / `entry-schema-invalid`),对象里的名与值照旧逐字过,再过与 `compat`/`extraBody` 共用的 `vetFreeFormJson` 安全判据 ---
109
109
  --- 20.0.0:`ModelEntry.thinkingLevelMap?`(引擎 `Model.thinkingLevelMap` 的声明位;键闭集 = 词表 `MODEL_THINKING_LEVEL_WORDS` 七词 `off`/`minimal`/`low`/`medium`/`high`/`xhigh`/`max`,型 `ModelThinkingLevel`,席位 schema `ModelThinkingLevelMap` 从词表铸键并 `.strict()`;全可选;值 = 非空串〔供应商在该档上的取值〕或 `null`〔该档在这个模型上不支持〕;缺席 = 未声明,本包不补 `{}`,`{}` = 声明了、没有覆盖)——
110
110
  坏形整条目拒、不剥键、不折默认:未知键〔含大小写变体〕/ 非对象〔含整张表写 `null`、数组〕/ 空串值 / 非串非 `null` 值 ⇒ 读口逐条丢并报 `entry-dropped`(同域未被引用的其余条目照常;被 `roles` / `atMention.only` / `tierGroups` 引用的条目坏形 ⇒ 既有级联律,整个 `models` 域 `domain-defaulted`、目录退空、兄弟条目一并丢;一条好条目都不剩〔含它是唯一一条〕走既有的零幸存者律:只发 `domain-defaulted`、`models` 退成空目录),文档面〔`getDomain` / 导出〕整域抛,写口拒;此前该键被当未知键剥掉。本包只承载与判形,串的内容归读它的消费方。与引擎 `ModelThinkingLevel` 的两向锚在漂移门 ⑫(编译期;引擎加词只在 `npm run typecheck` 红)。
111
+ --- 27.0.0:`ModelEntry.fallbacks?`(引擎每模型回落链 `RunnerDeps.models.<名>.fallbacks` 的声明位;`z.array(z.string().min(1)).optional()`,按跳序;缺席 = 未声明,本包不铸键,`[]` = 声明了、没有链〔引擎读作「无链」〕;不是 env 腿的键)——
112
+ **本包只判形**:非数组 / `null` / 元素不是非空串 ⇒ 整条目拒、不剥键、不折默认(严写面与文档面整份拒;读口逐条丢并报 `entry-dropped` / `entry-schema-invalid`,被 `roles` / `atMention.only` / `tierGroups` 引用或是唯一一条 ⇒ 既有级联 / 零幸存者律,与 `thinkingLevelMap` 坏形同答)。词在不在目录、指自己、重复、超几跳 —— 一概不判:唯一的判官是引擎目录门(拒句点名 `RunnerDeps.models.<名>.fallbacks`),本包再判一遍就是第二只判官。词可以是档位词 / 别名(在引擎的展开目录上解);链是平的,一跳自己的 `fallbacks` 不被走(引擎自 7.67.0 起的读法,本包不验证)。修前(26.1.0):视图面把带这个键的条目当未知键一律整条丢(`entry-unknown-key`),文档面剥键受理;自此合形的装上、坏形整条拒。
111
113
  · rosters:`RosterEntry[]`(`primaryModel`/`cheapModel` 标记角色;`ROSTER_PRIMARY_ROLES`/`ROSTER_CHEAP_ROLES`)。
112
114
  · skills:`SkillSpec[]`(content 全文;wire 转 manifest 见 §4.5)。
113
115
  --- 14.4.0:`SkillSpec.allowedTools?` / `disallowedTools?`(`string[]`,元素非空串;与引擎本地 `.sema/skills` 清单同名同形)—— 逐条按作者所写承运:不去重 / 不排序 / 不判拼写(本包只判「非空字符串」);缺席 = 键不出现,在场 = 整只数组交给消费方的判官(`[]` 与缺席是两种承运形,读成什么由判官定;引擎本地目录把空名单读作未声明);manifest 由 `SkillSpec` 派生,两键自动随到 `/effective` 的 `skills[]`;读腿:24.0.0 起两只名单是一个值(与 `scenarios` / `rosters` / MCP `allowTools` 同一条律),且 `skills` 不逐条丢、读档 throw —— 名单里坏一个元素 ⇒ 整域读不进、读抛,两腿同读(14.4.0–23.0.0:坏元素被逐元素剔、`disallowedTools` 被截短、技能照装)。
@@ -349,6 +351,8 @@ entitlement/execution/limits = `none`;`projects` = `salvage`,整域档位仍 `"t
349
351
  - 事件全集 `HOOK_EVENTS`(33 个 hook 事件 = CC 2.1.198 的 27 + post-198 的 CwdChanged/FileChanged/
350
352
  MessageDisplay/DirectoryAdded/PreModelSwitch/PostModelSwitch);owner 表 `HOOK_EVENT_OWNER`(engine|shell,单属主;26.0.0 起 `ENGINE_OWNED_HOOK_EVENTS` 十员 = 工具执行链五员〔含 `PermissionDenied`:引擎工具门的拒〕+ 压缩两员 + 轮界三员)、`ENGINE_OWNED_HOOK_EVENTS`、
351
353
  matcher 语义表 `HOOK_EVENT_MATCHER_FIELD`(null = 无 matcher 轴)。
354
+ - 按属主分流的消费规则(26.1.0 起):`ENGINE_OWNED_HOOK_EVENT_SINCE`(`Readonly<Record<EngineOwnedHookEvent, string>>`,冻结;引擎属主十员各自的起始契约版本 = 那一员第一次出现在属主集里的包版本(按包现名的版本线记),`PermissionDenied` = `26.0.0`,其余九员 = `1.0.0`(九员比改名还早:`1.0.0` 是包现名的第一个版本,下限而非引入日期);键集恰 = `ENGINE_OWNED_HOOK_EVENTS`,加员漏填 / 表里多键 ⇒ 编译红)+ 唯一读者 `engineOwnsHookEventAt(event, contractVersion): boolean`:
355
+ 交引擎 ⟺ 事件在属主集里 ∧ 对端契约版本 ≥ 该员起始版本(数值逐段比;对端版本读自服务端 `GET /v1/capabilities` 的 `settingsContract.version`,缺席 ⇒ 传你方支持底线);`contractVersion` 只收完整 `x.y.z`(无前导零 / 预发布 / 构建段 / `v` 前缀),其余含 `undefined` 抛 `TypeError`(预发布段读者不猜);壳属主事件与非钩子事件名恒 `false`。(src/hooks.ts: `ENGINE_OWNED_HOOK_EVENT_SINCE` / `engineOwnsHookEventAt` / 型 `EngineOwnedHookEvent`)
352
356
  - 逐事件输入形 `*HookInput`(union `HookInput`);输出:`SyncHookOutput`(exit 0 JSON;exit 2 = 阻断,stderr
353
357
  作为理由/附加上下文喂回模型;其余 exit/超时/spawn 失败/坏 JSON = 非阻断故障〔缺省 `onFailure: "continue"`;command / http 条目写 `onFailure: "block"`(19.0.0 起的契约字段)则这些失败按 exit 2 算,执行是消费方的事〕,消费方 hook-runner 铸
354
358
  `hook_non_blocking_failure` 通知帧上任务/fleet 流,stderr 先脱敏后截断 512 字)、`AsyncHookOutput`、
@@ -527,6 +531,7 @@ entitlement/execution/limits = `none`;`projects` = `salvage`,整域档位仍 `"t
527
531
  —— 旧名在场即拒启,替代名设没设都一样(空串 = 未设);永久,不设到期;链只有一跳(去向恒是现名)。拒启句唯一铸点
528
532
  `retiredEnvRefusal(env)`(纯,读传入的 env;码 `RETIRED_ENV_REFUSAL_CODE` = `config.env_key_retired`;只点名键不回显值);
529
533
  目录 wire 投影 `buildRetiredEnvWire()`。引擎起服 / 壳起本机引擎 / web-admin 渲染 worker env 判同一张表。
534
+ 27.0.0 起表尾两行:`MODEL_DEGRADE_ON`(replaced → `MODEL_FALLBACK_ON`:门词的值语义变了,`budget` 不再是门词、`network` / `auth` / `stream_torn` 是新词、作用面由整只 Brain 的一个目标变成每条目录链)与 `MODEL_DEGRADE_REACTIVE`(removed:整只 Brain 的反应式降级壳删除,出路是在目录条目上声明 `fallbacks`);近预算降级线的 `MODEL_DEGRADE_TO` / `MODEL_DEGRADE_AT_COST_FRACTION` / `MODEL_DEGRADE_TO_VISION` 仍是活旋钮,不在表里。
530
535
 
531
536
  --- 4.10c 沙箱 git 凭据平面(src/sandbox-git.ts + src/api/credentials.ts,主 barrel,不开子路径;14.7.0) ---
532
537
  - 沙箱里的 git 用成员本人的凭据:数据面向 web-admin 的凭据取值口按 run 身份申领句柄、凭句柄兑换。本包只有形与词表,零 IO。
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  <!--
2
2
  llms.txt — 消费方(使用者)视角索引 · @sema-agent/settings-schema
3
- 重写日期: 2026-11-10 | 包版本: 26.0.0
3
+ 重写日期: 2026-11-11 | 包版本: 27.0.0
4
4
  生成方式: 无生成脚本——按当前树的 src/*.ts 导出面 + package.json + README/CHANGELOG 手写事实版;
5
5
  每条断言附证据坐标(文件:符号),刻意不用行号(行号随每版腐烂,符号名由 typecheck/test 钉住)。
6
6
  刷新触发: package.json 版号变更(test/docs-hygiene.test.ts D 组钉「包版本:」与 package.json 相等、
@@ -28,6 +28,7 @@ llms.txt — 消费方(使用者)视角索引 · @sema-agent/settings-schema
28
28
  改写存量的一次性迁移 26.0.0 到期删了,出路是手写到 governance / limits)。(src/types.ts: `DOMAIN_SCHEMAS`)
29
29
  - **目录条目的 `thinkingLevelMap?`**(20.0.0,引擎 `Model.thinkingLevelMap` 的声明位):键闭集 `MODEL_THINKING_LEVEL_WORDS`(`off` `minimal` `low` `medium` `high` `xhigh` `max`,型 `ModelThinkingLevel`,席位 schema `ModelThinkingLevelMap`),全可选;
30
30
  值 = 非空串(供应商在该档上的取值)或 `null`(该档在这个模型上不支持);缺席 = 未声明,本包不补 `{}`。坏形(未知键 · 非对象 · 空串值 · 非串非 `null` 值)**整条目拒** —— 读口逐条丢并报 `entry-dropped`(未被引用的其余条目照常;**被 `roles` / `atMention.only` / `tierGroups` 引用的条目坏形 ⇒ 既有级联律,整个 `models` 域 `domain-defaulted`、目录退空**;一条好条目都不剩时走既有的零幸存者律:只发 `domain-defaulted`),不剥键、不折默认。与引擎联合的两向锚在漂移门(编译期)。(src/types.ts: `ModelEntry` / `MODEL_THINKING_LEVEL_WORDS`)
31
+ - **目录条目的 `fallbacks?`**(27.0.0,引擎每模型回落链 `RunnerDeps.models.<名>.fallbacks` 的声明位):非空串数组,按跳序;缺席 = 未声明(本包不铸键),`[]` = 声明了、没有链(引擎读作「无链」)。**本包只判形**:坏形(非数组 · `null` · 元素不是非空串)**整条目拒、不剥键** —— 读口逐条丢并报 `entry-dropped`(`entry-schema-invalid`;级联与零幸存者律同上),严写面整份拒;词在不在目录 · 指自己 · 重复 · 超几跳一概不判,唯一的判官是引擎的目录门。词可以是档位词 / 别名(在引擎的展开目录上解);链是平的,一跳自己的 `fallbacks` 不被走(引擎自 7.67.0 起的读法,本包不验证)。不是 env 腿的键。(src/types.ts: `ModelEntry`)
31
32
  - **域内坏条目逐条丢**(2.0.0):一条写坏的目录条目只丢它自己,同域其余条目照常生效,并逐条发
32
33
  `entry-dropped` 点名(坐标形见下条;6.1.0 起可带 `identity?: { name?, id?, enabled? }` = 被丢条目原文里
33
34
  读得出的身份,类型不对 / `isDisclosableIdentity` 说不可披露 ⇒ 不带该键;6.3.0 起身份须是白名单闭形
@@ -103,7 +104,7 @@ llms.txt — 消费方(使用者)视角索引 · @sema-agent/settings-schema
103
104
  - **hooks 契约**:33 个 hook 事件的全集 + owner 表 + 逐事件输入/输出形 + 配置面:hook 条目五种 type(`HOOK_ENTRY_TYPES`,含 `mcp_tool`;19.0.0 起 command 条目承运 `args`〔exec 形参数表〕、command / http 条目承运 `onFailure`〔`HOOK_ON_FAILURE_WORDS` = continue|block,型 `HookOnFailure`;承运不是执行〕;20.0.0 起另承运 `rewakeMessage` / `rewakeSummary`〔command,非空串〕、`cloud`〔command / http,任意值照带:CC 把词表外的任何值读作 skip,折在读者;`HOOK_CLOUD_WORDS` = device|skip,型 `HookCloud` 是折法参考〕、`continueOnBlock`〔prompt,布尔〕——CC 条目 schema 上的每个键都在字段表里,其余三个键的坏值是坏块)与**一只**
104
105
  坏形分类器 `classifyHooksConfig(settingsDoc)`(非守卫事件坏块逐个剔、守卫事件 PreToolUse / PermissionRequest 任何坏处或守卫迹象 ⇒ 整份拒;码 + 坐标 + 坏字段名 `field`(坏块是匹配器 / 条目 ⇒ 它上面出问题的键,块不是对象才缺席;一块多个迹象时先该块自身的迹象(自有守卫事件键;条目自己是匹配器形取 `hooks`),再按文档序找嵌套迹象;匹配器下合形条目列表里的迹象归各条目)、零句子、零 zod 自含;
105
106
  闭包里 JS 内建之外只有一个自由名 `HOOK_EVENTS` —— 整函数抄走的生成器(client-core)须把本包运行期导出 `HOOK_EVENTS`(上游常量)注入抄本作用域,不许贴字面事件表),
106
- `HooksConfig` / `HookEntry` 等 zod 面是它的投影;事件与 type 两张闭集与上游的漂移由常驻门看住(上游有而本包没有的词 ⇒ 门红并点名)。http 钩子 header 里 `$VAR` / `${VAR}` 的展开也只有一只读法(名单内展开、名单外与凭据名置空并回报)。(src/hooks.ts: `HOOK_EVENTS` / `interpolateHookEnvVars`)
107
+ `HooksConfig` / `HookEntry` 等 zod 面是它的投影;事件与 type 两张闭集与上游的漂移由常驻门看住(上游有而本包没有的词 ⇒ 门红并点名)。http 钩子 header 里 `$VAR` / `${VAR}` 的展开也只有一只读法(名单内展开、名单外与凭据名置空并回报)。按属主分流的消费方(26.1.0 起):逐员起始契约版本 `ENGINE_OWNED_HOOK_EVENT_SINCE`(引擎属主十员各一行,键集恰 = `ENGINE_OWNED_HOOK_EVENTS`;`PermissionDenied` = 26.0.0,其余九员 = 1.0.0)+ 唯一读者 `engineOwnsHookEventAt(event, contractVersion)`(交引擎 ⟺ 事件在属主集里 ∧ 对端契约版本〔服务端 `/v1/capabilities` 的 `settingsContract.version`;缺席 ⇒ 传你方支持底线〕≥ 该员起始版本;只收完整 `x.y.z`,坏串含预发布段抛 `TypeError`)。(src/hooks.ts: `HOOK_EVENTS` / `interpolateHookEnvVars` / `ENGINE_OWNED_HOOK_EVENT_SINCE` / `engineOwnsHookEventAt`)
107
108
  - **hook 条目字段表**(20.0.0 起运行期导出):`HOOK_ENTRY_FIELDS`(每型 → 字段名 → 取值类,`?` 结尾 = 选填;深冻结,包根与 `./hooks` 同一只)与型 `HookEntryFields`;分类器读的是闭包私有的投影,与导出表以型标注咬合、判法随字段表。(src/hooks-config.ts: `HOOK_ENTRY_FIELDS`)
108
109
  - **跨会话两键**(1.6.0 新增,`settings.json` 面;6.0.0 词表随 core 7.30.0 改):`crossSessionInbound`(wake/next-turn/hold/refuse + `default`=未设;`accept` 已退役,文件层响亮拒)
109
110
  与 `dialogExpiry`(60s/5m/10m/never,缺省 5m);另出两只层读取器,坏值 `ok:false` 不静默折缺省。
@@ -159,6 +160,8 @@ llms.txt — 消费方(使用者)视角索引 · @sema-agent/settings-schema
159
160
  `isReadyForTraffic` / `isRoutable` 是它们的布尔形;没有信号(旧引擎)= `no-engine-signal`,不可路由;平铺方言(`/health` 的布尔对 + 心跳上与信号同名的平铺键)26.0.0 删,还带它们的体照收、判官不读;
160
161
  8.3.0 additive:env 名常量 `FLEET_SCOPE_ENV`(`"FLEET_SCOPE"`,成员所属租户 scope,渲染器写、引擎读;缺席 = 默认 scope `GLOBAL_SCOPE`;进保留 env 名表);
161
162
  14.7.0 additive:公告地址 env 名常量 `FLEET_ADVERTISE_ADDRESS_ENV`(`"FLEET_ADVERTISE_ADDRESS"`)+「后面要拼路径的基址」座位的禁用成分集 `PATH_BASE_URL_FORBIDDEN_PARTS`(`userinfo` / `query` / `fragment`)+ 判官 `pathBaseUrlFlaws(url)`(= `httpUrlFlaws` 配这一集;判展开之后的值;`webAdminSessionUrl` 也读它);
163
+ 27.0.0 BREAKING:目录条目多可选席 `fallbacks`(只判形,坏形整条拒 —— 严写面此前剥键受理的坏形自此整份拒;视图面此前带它的条目一律整条丢〔`entry-unknown-key`〕,自此合形的装上、坏形丢但词改 `entry-schema-invalid`)· 墓碑表 `RETIRED_ENVS` 加 `MODEL_DEGRADE_ON`(replaced → `MODEL_FALLBACK_ON`:门词值语义变了)与 `MODEL_DEGRADE_REACTIVE`(removed:整只 Brain 的反应式降级壳删除,出路 = 在目录条目上声明 `fallbacks`),设了即拒启,拒句点名键不回显值;近预算降级线的三个旋钮仍是活旋钮、不在表里;
164
+ 26.1.0 additive:引擎属主钩子事件的逐员起始契约版本 `ENGINE_OWNED_HOOK_EVENT_SINCE`(`Readonly<Record<EngineOwnedHookEvent, string>>`,冻结;`PermissionDenied` = 26.0.0,其余九员 = 1.0.0;键集恰 = `ENGINE_OWNED_HOOK_EVENTS`,加员漏填 ⇒ 编译红)+ 唯一读者 `engineOwnsHookEventAt(event, contractVersion): boolean`(交引擎 ⟺ 属主表说 engine ∧ 对端契约版本 ≥ 该员起始版本;坏版本串抛 `TypeError`)+ 型 `EngineOwnedHookEvent`;包根与 `./hooks` 各三名,零校验变化;
162
165
  26.0.0 BREAKING:`ENGINE_OWNED_HOOK_EVENTS` 十员(尾插 `PermissionDenied`,`HOOK_EVENT_OWNER.PermissionDenied` = engine:一次工具调用被引擎的工具门拒,发生在工具执行链里;
163
166
  按属主分流的消费方锁步改 —— 服务端补站对位,客户端核心重生成属主表与终端客户端座位改组同一个客户端发版;本包的配置校验不读属主表)·
164
167
  `models[].headers` 容器必须是对象(同上)· 一致性门账本一行 = 坐标 × 类:`debt`(票号 + 窗 + 翻转条件)/ `posture`(消费方姿态:票号,不挂窗;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/settings-schema",
3
- "version": "26.0.0",
3
+ "version": "27.0.0",
4
4
  "description": "Sema settings schema — pure config contract (zod domains + effective-config + roster resolution + ref-integrity + remoteExec) shared by sema-web-admin, sema-server, and the TOC desktop/CLI. One source of truth. (Renamed at 1.0.0 from @sema-agent/registry-core — name and docs only, no behavior change; note the range moves 0.19.0 -> 1.0.0, so a dependency must become ^1.0.0. The old names @sema-agent/registry-core <=0.19.0 and @sema-ai/registry-core remain published, frozen, for migration.)",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",