@sema-agent/settings-schema 33.1.0 → 34.1.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 (53) hide show
  1. package/CHANGELOG.md +664 -0
  2. package/README.md +138 -19
  3. package/conformance/VERSION +1 -1
  4. package/dist/api/credentials.d.ts +94 -14
  5. package/dist/api/credentials.js +33 -8
  6. package/dist/atomic-write.d.ts +68 -3
  7. package/dist/atomic-write.js +314 -4
  8. package/dist/cli.d.ts +5 -2
  9. package/dist/cli.js +15 -3
  10. package/dist/config-d-file.d.ts +0 -3
  11. package/dist/config-d-file.js +1 -6
  12. package/dist/config-dir-migration.d.ts +2 -1
  13. package/dist/config-dir-migration.js +34 -20
  14. package/dist/config-fns.d.ts +60 -14
  15. package/dist/config-fns.js +48 -13
  16. package/dist/conformance/index.d.ts +1 -0
  17. package/dist/conformance/index.js +2 -0
  18. package/dist/conformance/warnings.d.ts +1 -1
  19. package/dist/conformance/warnings.js +3 -3
  20. package/dist/conformance/web-admin-credential-lock.d.ts +17 -0
  21. package/dist/conformance/web-admin-credential-lock.js +347 -0
  22. package/dist/hooks-config.d.ts +12 -4
  23. package/dist/hooks-config.js +28 -11
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.js +3 -2
  26. package/dist/local-load.d.ts +66 -1
  27. package/dist/local-load.js +123 -39
  28. package/dist/mcp-request-entry.d.ts +43 -5
  29. package/dist/mcp-request-entry.js +60 -18
  30. package/dist/node.d.ts +1 -0
  31. package/dist/node.js +2 -0
  32. package/dist/plugin-id-segment.d.ts +15 -0
  33. package/dist/plugin-id-segment.js +15 -0
  34. package/dist/plugin-settings.d.ts +61 -0
  35. package/dist/plugin-settings.js +111 -0
  36. package/dist/read-sentences.d.ts +14 -3
  37. package/dist/read-sentences.js +32 -11
  38. package/dist/safety-merge-spec.d.ts +7 -7
  39. package/dist/safety-merge-spec.js +5 -3
  40. package/dist/settings-units.d.ts +35 -1
  41. package/dist/settings-units.js +51 -16
  42. package/dist/types.d.ts +13 -6
  43. package/dist/types.js +37 -11
  44. package/dist/ui-language.d.ts +3 -1
  45. package/dist/ui-language.js +3 -1
  46. package/dist/web-admin-credential.d.ts +14 -1
  47. package/dist/web-admin-credential.js +15 -1
  48. package/docs/API-SURFACE.md +60 -5
  49. package/docs/CONFORMANCE.md +19 -2
  50. package/docs/CONSUMER-INTEGRATION.md +165 -11
  51. package/llms-full.txt +51 -16
  52. package/llms.txt +18 -8
  53. package/package.json +5 -1
package/README.md CHANGED
@@ -52,6 +52,35 @@ only (`node:crypto`, `node:fs`). The machine gate is `test/runtime-dependencies-
52
52
  > zod 3, nested inside every zod-4 host). The move to zod 4 did not change what any schema accepts or produces —
53
53
  > the conformance corpus reads byte-identically on both — only the wording of validation errors (see CHANGELOG 11.0.0).
54
54
 
55
+ ## 升级指引:34.0.x → 34.1.0(minor,加性:沙箱 git 拒答表尾插第十一词 `plane_misconfigured` 与凭据平面共享拒答表 `CREDENTIAL_PLANE_REFUSALS` · web-admin 凭证文件锁 `unreadable` 臂的可缺诊断位 `ioKind` · 请求面凭据值的独立判口 `readRequestMcpCredentials` · 插件设置三只纯读法 `readEnabledPluginsValue` / `readPluginId` / `PLUGIN_MARKETPLACE_SENTINELS`(新子路径 `./plugin-settings`;名段文法提成常量 `PLUGIN_ID_SEGMENT_REGEX`);文书:项目登记簿两句、凭据锁「根修」那半句)
56
+
57
+ 只加导出、一个闭集尾插词与一个可选键:除新词那一例(`SandboxGitCredentialRefusal` 对 `plane_misconfigured` 由拒变收,两张拒答表各多一行 / 一员)与凭据锁 `unreadable` 答多一个可缺的 `ioKind` 外,既有输入的读数不变、没有校验收紧 —— 不涉及所列例外(第 1、2 条)的消费方代码零动作可升;第 1、2 条会让一部分消费方提货后红一次(对 `SandboxGitRefusalError` 的穷举 `switch` 与 `Record<…>` 全量映射表、对拒答词表按十个词的逐字比对、对 `unreadable` 臂整个结果的深相等)。逐件的读法表、三问、各消费方表与黑盒判据 K43 – K53 见 CHANGELOG 34.1.0 与 `docs/CONSUMER-INTEGRATION.md` §12.5、§56(末尾)、§57,凭据锁那一件在 §8 里 web-admin 凭证文件那一条。
58
+ 1. **沙箱 git 拒答表多第十一个词**(加性,提货成本):`SandboxGitRefusalError` / `SANDBOX_GIT_REFUSAL_ERRORS` 尾插 `plane_misconfigured`(状态 503、`terminal`:凭据平面在答方配置错,运维改配置之前定时重试不会成功),既有十词的次序、状态集与 `permanence` 逐字不变;新导出 `CREDENTIAL_PLANE_REFUSALS`(凭据平面共享拒答表,九词)· `CREDENTIAL_PLANE_REFUSAL_ERRORS` · 型 `CredentialPlaneRefusalError`,`SANDBOX_GIT_REFUSALS` 按声明次序由共享表与本口自有两词派生(共享的九行与共享表是同一批对象)。对 `SandboxGitRefusalError` 做穷举 `switch` 的一方补一臂,对它写 `Record<SandboxGitRefusalError, …>` 这类全量映射表的一方补一行;对拒答词表按「十个词」逐字比对的钉改成十一个。**次序:读方先升、发这个词的一方最后改答** —— 没升级的收方遇到它:按本包规则读的当畸形应答、按 HTTP 5xx 兜底的当暂不可用并退避重试,两种都不取值;升级后才读得到 `terminal`、停止定时重试。
59
+ 2. **凭据锁 `unreadable` 臂多可缺的 `ioKind`**(加性):`tryWebAdminCredentialFileLock` 在「解凭证路径」那一步失败时,`unreadable` 的结果多一个可缺键 `ioKind`(`dangling_symlink` = 悬空软链〔登出删掉真目标之后链接悬空〕,`read_error` = 别的读不出;词表是包根既有的 `CONFIG_DOCUMENT_IO_KINDS`,不加词);别的 `unreadable`(锁建不出 / 锁名被不是普通文件的东西占着 / 锁内读不了真目标)不带这一键(键不在场,不是 `undefined`)。壳据它直接渲出路(删掉悬空链接,或先重建目标),不解析句子;只有**凭证文件本身**是悬空软链时才是 `dangling_symlink` —— 上层目录的软链悬空时,解路径那一步读不到(ENOENT)照「不存在」往下走,到建锁才失败,答 `unreadable` 而不带这一键(`error` 的句子只说目录写不进〔ENOENT〕,不点名悬空链接)。**悬空软链答 `unreadable` 是本版有意维持的行为**:不建文件、不写,与本包原子写器对悬空链接的拒同一条律;34.0.0 的节与几处随包文字曾把这一形写成「根修后翻成写穿」「后续版本设计先行」「本版不带」,说得不准,撤掉了(随包文字里同类的句子 —— 原子写器头注、一致性测试头注、`docs/CONFORMANCE.md`、本档协议段、`llms-full.txt` 与接入档里的凭据锁段 —— 已改成同一说法;34.0.0 节本身不改字,订正写在 CHANGELOG 34.1.0 节末):本版不解析悬空链接的落点,要做就得改原子写器对悬空链接的拒律(不替链接建它指向的文件),那是另一份设计、按大版本排。对 `unreadable` 臂整个结果做深相等的钉,在「解凭证路径」失败的形上多见一键。
60
+ 3. **请求面凭据值的独立判口 `readRequestMcpCredentials`**(加性,包根两个新导出:函数与型 `RequestMcpCredentialsVerdict`):问一个已读出的 `credentials` 值收不收 —— `{ kind: "absent" }` · `{ kind: "taken", credential }`(新造的冻结副本)· `{ kind: "refused", refusal: "credentials_not_carried", reason }`(三臂答案都冻结)。读器 `readRequestMcpTransport` 现在调的就是它,判法与每一句拒句一字未动;只想问「这一个值收不收」、不想为此拼一整条传输的消费方改用它(整条传输还会因 `url` / `headers` 等别的键答 `ok: false`,判口不知道那些)。能力面「请求面收哪些凭据引用种类」的唯一值源仍是 `MCP_REQUEST_CREDENTIAL_KINDS`。**已知的边**:`transport` 形参的型是闭集 `"stdio" | "http"`,类型内的调用到不了表外词;运行期传表外词(纯 JS / 强制转型)会按 http 臂判,对合形保管库引用答 `taken`;下一个大版本改成穷举、表外词拒。
61
+ 4. **插件设置的三只纯读法**(加性,新子路径 `./plugin-settings`,与包根同一批对象):`readEnabledPluginsValue(v)` 读 `enabledPlugins` 里一个键的值(`true` / `false` / 字符串数组 ⇒ `on` / `off` / `versions`,其余 ⇒ `unreadable`;数组元素不细判)· `readPluginId(v)` 拆插件 id(`<名>@<市场>` 恰一个 `@`,两半各过名段文法;npm 来源 id `@<scope>/<包名>@npm`〔读出的名含 `@` 与 `/`,**不是合法的 `PluginSpec.name`**:中心层插件条目没有 npm 来源形,这样的 id 只能读出、不能原样写成中心层条目〕;`<名>@skills-dir` 是合法 id;读不出 ⇒ `undefined`)· `PLUGIN_MARKETPLACE_SENTINELS`(`inline` / `skills-dir` / `synced` / `builtin` 四词,深冻)与 `isPluginMarketplaceSentinel`。三只都只读值、**不定合并**:中心层 `plugins[].enabled` 与设置层 `enabledPlugins` 怎么组合不在本版 —— 合并读法到货之前,同时读中心 `plugins` 与本机设置文件的宿主只照中心层答、不自己拼;托管策略表与它的哨兵臂、`pluginConfigs` / `extraKnownMarketplaces` 的条目形也不在本版。
62
+ 5. **名段文法提成常量 `PLUGIN_ID_SEGMENT_REGEX`**(加性,包根与 `./types`;行为逐字不变):`PluginSpec.name` 与 `PluginSource` 的 marketplace 臂此前各写一遍的名段正则与同一句拒句,现在只有一处定义(包内私有的零 import 叶,`./types` 与包根上是它的原名转出);对同一组坏名,两处的拒句、路径与条数与上一版逐字相同。`./plugin-settings` 冷载入不带出 `./types`、不带出 zod。
63
+ 6. **文书更正**(类型旁的注释与随包文字,不改任何类型、校验与导出面):`ProjectRegistration.archivedAt` 的说明原写「没有硬删」,不准 —— 归档保留登记,删除后会话行上的 `projectId` 可能指向已删除的项目,读方按「不存在」处置;`projects` 记录的条目序是契约事实(登记簿的展示序,唯一来源 = 文档条目次序),写者必须保序,今天的内容版本按排序后的键计算、只调换次序不换版本号;凭据锁「后续版本设计先行」那半句更正见第 2 条。
64
+
65
+ 本版没有新登记的一次性迁移,也没有到期删码的(`SS-M11` 的窗到 2026-11-26)。
66
+
67
+ ## 升级指引:33.1.x → 34.0.0(BREAKING,编译期三处:`planHookCommandSpawn` 入参 `entry.plugin` 必带 `name` · 钩子命令行三只选项词的拒因多必填 `pluginName`(三句拒句改字面)· 公共型 `WarningProjection` 逐臂减掉诊断键;BREAKING,运行期一处(校验放宽):请求面 MCP 条目的 http 传输收 `vault` 凭据引用;加性:被丢条目与告警 `entry-dropped` / `domain-defaulted` 多可缺的 `unknownKeys` / `truncatedFrom` · 单元表第十一个单元 `semaUiLanguage`、每行必填的读者位 `reader` 与读自哪些源 `sources`、新导出 `SETTINGS_UNIT_READERS` / `SettingsUnitReader` · 本地 `.env` 两步读法 · web-admin 凭证文件的单写者锁;文案与命令行:`--help` / `-h` 退 0、拒句一批改字)
68
+
69
+ 没有校验收紧、没有已存数据要迁移 —— 会让按 33.1.x 写的消费方红的是第 1 – 3 条(编译期,tsc 报给你)与第 9 条(运行期:同一份请求读出不同结果),第 4 – 6 条与第 10 – 11 条是加性与提货成本,第 7 – 8 条是命令行与文案;下面任何一条都不碰的消费方零动作可升。逐件的「改前 → 改后」、三问、各消费方表与黑盒判据 K1 – K42 见 CHANGELOG 34.0.0 与 `docs/CONSUMER-INTEGRATION.md` §53 – §56。
70
+ 1. **钩子命令行规划口的入参**(BREAKING,编译期):`planHookCommandSpawn` 第一参的 `entry.plugin` 由 `{ options? }` 变 `{ name: string; options? }`(`plugin` 本身仍可缺)。手搭入参条目(夹具、适配器)的一方给 `plugin` 补 `name: "<插件名>"`;把分类器装上的 `CommandHookEntry` 原样交进来的一方零改动(它的 `plugin` 本来就带 `name`)。绕类型的 JS 调用方:`name` 只由入参型要求、运行期不校验 —— 缺失时 `planHookCommandSpawn` 照旧答(拒因里 `pluginName` 是 `undefined`),把这样的拒因交给 `hookCommandSpawnRefusalSentence` 时句子函数抛 `TypeError`。
71
+ 2. **选项拒因**(BREAKING,编译期 + 句子字面):三只选项词(`shell_form_user_config` / `user_config_unset` / `user_config_unresolved`)的拒因由 `{ word; key }` 变同形一臂 `{ word; key; pluginName }`(`pluginName` 必填 = 条目自己的 `plugin.name`;型只剩两臂,`path_unset` 一臂不变)。手搭这三只词的拒因的一方补 `pluginName`;只读 `planHookCommandSpawn` 的答案、再把拒因交 `hookCommandSpawnRefusalSentence` 的一方零改动。三句拒句同一个起头 `hook command names option "<键>" of plugin "<插件名>"`,后接各自原来说的事(三句逐字见 CHANGELOG 34.0.0 的「改字清单」):对旧拒句逐字比对的钉与脚本改读新句;识别 shell 形那一拒请读拒因的 `word`,不要找句子里的 `${user_config.`。**33.x 形的拒因(没有 `pluginName`)不要交给 34 的句子函数** —— 它读不了缺席的 `pluginName`、抛 `TypeError`;跨进程把拒因序列化后传给另一侧的消费方,两侧要同一版升。
72
+ 3. **`WarningProjection` 公共型**(BREAKING,编译期):每臂 = 该臂减 `error` 再减该臂声明的**诊断键**(`domain-defaulted` 的 `path` / `identity` / `reasonCode` / `unknownKeys` / `truncatedFrom`、`entry-dropped` 的 `unknownKeys` / `truncatedFrom`)—— 此前类型说这些键在投影里、`projectWarning` 从不铸它们。运行期投影的值、符合性语料与历史对拍一字不变。从投影型上读这些键的一方(它们本来就读不到值)tsc 红一次:改读告警本体 `EffectiveReadWarning`。`unknown-keys-dropped` / `unknown-keys-carried` 的 `truncatedFrom` 不是诊断键,仍在投影里。
73
+ 4. **读腿的行多两个可缺键**(加性):`salvageEntries().dropped[]` 的 `DroppedEntry`、告警 `entry-dropped`、触发条目就是这样一行的 `domain-defaulted`,在词为 `entry-unknown-key` 时可带 `unknownKeys`(条目体内被剥的键名里过 `isDisclosableIdentity` 的那些,文档序、同名一次、至多 64 个)与 `truncatedFrom`(名单不全时带,= 被剥的不同键名总数;`unknownKeys` 在场而 `truncatedFrom` 缺席 ⇒ 名单就是全部)。渲「是哪几只键」的一方读 `unknownKeys`,`truncatedFrom` 在场时渲「还有没列出的」;对这些行 / 告警做整对象深相等的钉与夹具改成按键读、或补这两个键。两键都不进符合性投影。
74
+ 5. **单元表**(加性 + 提货成本):`SETTINGS_UNITS` 尾插第十一个单元 `semaUiLanguage`(读法 `uiLanguage`,只收 `en` / `zh` 原字,只从用户设置读写);每一行单元多必填的 `reader`(闭集 `SETTINGS_UNIT_READERS` = `shell` / `engine`:`shell` = 只改宿主自己的界面、到不了引擎,`engine` = 其余一切的保守答)与 `sources`(这一单元从哪些设置源读;既有十行 = `SETTINGS_SOURCES`);`SettingsUnitName` 尾插一员。既有十个单元对任何输入的读数、比较器与寻址逐字不变;按单元名 / 读者词穷举的消费方、拿行的字面型注解手写对象、对行做深相等的一方提货时红一次 —— 给新单元补一行、读者分支补 `shell` 一臂。
75
+ 6. **`SAFETY_MERGE_SPEC.ui.seam`**(展示字串):不再断言「never touches the engine」,改指向单元的 `reader`;规则字段逐字不变。逐字比对这只字串的一方红一次(由契约包生成的层准入表副本重出即可)。
76
+ 7. **命令行 `--help` / `-h`**:退出 0、用法在 stdout、stderr 空(此前退出 2、stdout 空、用法在 stderr);无参与别的用法错照旧(退出 2)。把 `--help` 的退出码 2 当「拒」的脚本红一次。
77
+ 8. **拒句一批改字**(受理与否、退出码表、结论行 `outcome=` / `written=`、`refused[]` 的 `document` / `path` / `appliedAs` 都不动,唯一的边见 CHANGELOG「车道坐标超长」):`migrate` 拒收的整份 `why` 与 stderr(几处 · 每处的文件、坐标与原因 · 出路)· 坏的记录键的拒因(泛话 `Invalid key in record` → 键自己的拒句)· 迁移改过那一臂的 `refused[].reason` · `DomainReadRefusedError.message`(一行,坐标在前;`cause` 与 `issues` 不动)· 车道坐标超长的写闸拒句(点名坐标、说字数与上界、出路是缩短;issue 的 `code` / `origin` / `maximum` / 路径不变)。逐字比对这些句子的钉与脚本红一次;机读请读结论行、退出码、`refused[]` 的坐标、`e.domain` / `e.cause.issues`、issue 的 `code`。
78
+ 9. **请求面 MCP 条目的 http 传输收 `vault` 凭据引用**(BREAKING,运行期,校验放宽):`readRequestMcpTransport` 对 `{ kind: "http", url, credentials: { kind: "vault", entry } }` 此前答 `ok: false`(`credentials_not_carried`),自此答 `ok: true`、读后的传输带冻结副本 `credentials`(型 `McpRequestCredential`;`RequestMcpTransport` 的 http 臂多可选键 `credentials`)。收哪些种类只有一张表 `MCP_REQUEST_CREDENTIAL_KINDS`(今天 `["vault"]`);本包只判形、不解析、不取值、不判头归属。别的输入判决不变:另三种合形引用(`env` / `handle` / `assertion`)与一切坏形在 http 上仍拒(词与路径不变;「不是读器收的引用」那一支的原因句换了字,逐字比对它的钉改读新句),stdio 上任何值仍拒、句子一字不动。**连带两处**:http + 合法保管库引用 + 坏 `url`,上一版答 `credentials_not_carried`、本版答 `url` 的硬坏形(不带 `refusal`);「是不是引用」的判官是引擎原语包的读法(自有可枚举键),请求体(JSON 解析出的数据)里的多余成员它都看得见而拒,只有程序构造的对象才带得出的不可枚举 / Symbol 键的多余成员它读不到、不拒 —— 判官的属主在引擎原语包,本包不另写一份。下面「32.0.x → 33.0.0」升级指引第 5 条说的是那一版的读法,对 http 上的 `vault` 以本条为准。**提货的消费方**:对 `credentials` 这一键表态 —— 进对端座的输入,或照旧拒;能力位「请求面收哪些凭据引用种类」读 `MCP_REQUEST_CREDENTIAL_KINDS`、不手抄;按键穷举处置读器型的编译红一次。不表态而把读后的传输往下传、丢掉这一键,条目会在没有凭据的情况下挂载(远端 401),引用里只有条目名、没有值外泄。对读后的传输做整对象深相等的钉 / 夹具,遇到带 `vault` 的 http 条目会多见 `credentials`。
79
+ 10. **本地 `.env` 两步读法**(加性,`./node`):`readEnvFileLines(root)` 读行(不解 `file:`、不并 `process.env`;非赋值行按行号与闭集词报,不带行内容)· `resolveEnvFileAssignments(reading, names, { trust?, failFast? })` 只解名单里的名,每个 `file:` 目标先问调用方交入的信任座(座收绝对路径,答字符串 = 拒、抛 = 拒,拒了零字节读出)· `envFilePath(root)`;`loadEnvFile(root)` 的签名与行为一字不动(它就是这两步的组合)。要只读自己那几只名、或要在读目标之前先过自己的文件信任判官的读者调两步;`loadEnvFile` 的既有调用方零动作 —— 相对配置根下无座的读,原生读错误的 `path` / `message` 与上一版逐字节同(只有给了座,座与随后的读才共用同一条绝对路径;座按路径判,判与读之间路径背后的链接被换掉它看不见,那是按路径判的既有读法)。名叫 `__proto__` 的键:两步的 `values` 里是自有数据属性,`loadEnvFile` 仍与上一版同答(合并进普通对象时该键被丢)—— 要读它的调两步。
80
+ 11. **web-admin 凭证文件的单写者锁**(加性):包根 `WEB_ADMIN_CREDENTIAL_FILE_LOCK`(`staleMs` = 10 s,协议常量)/ `webAdminCredentialLockName`,`./node` `tryWebAdminCredentialFileLock(credentialPath, critical)`,`./conformance` `runWebAdminCredentialLockConformance`。凭证信封与线上面一字不动;写那只文件的每一方(引擎续签写回、壳的登录 / 刷新 / 登出)改走同一把锁、在锁内比较世代再写,持锁段只许同步本机 IO,别按同语义自写 —— 自己实现的必须过那套一致性测试。**已知限制**:凭证路径是软链时锁与写落在链接指向的真目标上,但登出(删掉真目标)之后链接悬空,再登录(再取锁)答 `unreadable`(失败关闭:不建文件、不写,与本包原子写器对悬空链接的拒同一条律;出路 = 删掉悬空链接,或先重建目标;凭证路径就是真文件的不受影响);锁名上不是普通文件的东西(命名管道 / 目录 / 任何软链)答 `unreadable`,同码同句、不等待、不碰它(对取锁那一刻看到的占位物;取锁过程中被换掉的竞态窗见锁的协议段的限制)。这是协议要求,不是类型要求,提货不会让任何人编译红。
81
+
82
+ 本版没有新登记的一次性迁移,也没有到期删码的(最早一只 `SS-M11` 的窗到 2026-11-26)。
83
+
55
84
  ## 升级指引:33.0.x → 33.1.0(minor,加性:排空口的「凭据点名形」请求体 `CredentialDrainRequest` / 读器 `readCredentialDrainRequest` / 两词闭集 `DRAIN_TURNS` · 条件不满足的拒体 `DrainConditionUnmet` / `readDrainConditionUnmet` / 码常量 `DRAIN_CONDITION_UNMET_CODE` · 读「请求体是哪一形」的聚合读器 `readDrainRequestReading` / 判别联合 `DrainRequestReading` / 形词闭集 `DRAIN_REQUEST_FORMS`)
56
85
 
57
86
  只加导出(包根与 `./fleet` 各十名),零校验变化、零读数变化 —— 代码零动作可升(逐字比对 `migrate` 拒句的除外,见第 6 条);部署上引擎的版本见第 7 条。逐件的读法表、三问、各消费方表与黑盒判据见 CHANGELOG 33.1.0 与 `docs/CONSUMER-INTEGRATION.md` §52。
@@ -69,7 +98,7 @@ only (`node:crypto`, `node:fs`). The machine gate is `test/runtime-dependencies-
69
98
 
70
99
  只有一件会让按 32.x 写的消费方在运行期变红:命令行的答法(第 1 – 3 条);别的是加性与文案(第 4 – 6 条)。下面任何一条都不碰的部署零动作可升:不拿 `migrate` 的退出 0 当「可上线」· 存量 `config.d` 里没有读侧读不进的文档(`models.json` 里已退役的 `default` 键、带 `#fragment` 的模型 URL、带事实的 `runtime.json`、重名的目录模型一类)· 不逐字比对两条告警的 `error.message` 或 `RetiredDomainError` 的整句 · 不对告警对象恰等 `{ domain, kind, error }`、也不对 `refused[]` 的整对象做深相等。逐件的读数表、三问、各消费方表与黑盒判据见 CHANGELOG 33.0.0 各小节与 `docs/CONSUMER-INTEGRATION.md` §51。
71
100
 
72
- **升级前自查:一种答法的变化,不是读数的变化。** 本版没有一件让已落盘的内容由读得进变读不进 —— 读腿对每一份存量的读数逐字不变;变的是 `migrate` 不再替「文档面整文档判不过」的文档说干净。查法:在一个不碰线上依赖的临时目录里装本版,对存量 `config.d` 的副本跑 `npx @sema-agent/settings-schema migrate <目录> --check` —— 退出 0 = 覆盖面内的文档都过了文档面的整文档判、没有要迁的(这不等于读腿读得干净,见下面第 2 条的已知的边:条目只因带读侧不认识的键 —— 读腿丢那一条,集合里每一条都这样时读腿整域退缺省或整域拒 —— 仍答 0);3 = 有要迁的;1 = 报告 `refused[]` 点名的文件与坐标要手改;2 = 用法错,或环境错 / 坏文件(读不了目录或文件、空文件、坏 JSON、不是 JSON 对象)、或目录里有条目却没有一份域文档。线上还是上一版时就能知道升级后哪里被点名。
101
+ **升级前自查:一种答法的变化,不是读数的变化。** 本版没有一件让已落盘的内容由读得进变读不进 —— 读腿对每一份存量的读数逐字不变;变的是 `migrate` 不再替「文档面整文档判不过」的文档说干净。查法:在一个不碰线上依赖的临时目录里装本版,对存量 `config.d` 的副本跑 `npx @sema-agent/settings-schema migrate <目录> --check` —— 退出 0 = 覆盖面内的文档都过了文档面的整文档判、没有要迁的(这不等于读腿读得干净,见下面第 2 条的已知的边:**只在逐条丢弃域里**成立 —— 读腿只在那里拒条目体内被剥的键,不逐条丢的域两边都剥键受理、答得一样 —— 那里条目只因带读侧不认识的键,读腿丢那一条,集合里每一条都这样时读腿整域退缺省或整域拒,命令行仍答 0);3 = 有要迁的;1 = 报告 `refused[]` 点名的文件与坐标要手改;2 = 用法错,或环境错 / 坏文件(读不了目录或文件、空文件、坏 JSON、不是 JSON 对象)、或目录里有条目却没有一份域文档。线上还是上一版时就能知道升级后哪里被点名。
73
102
 
74
103
  1. **律**:命令行问的是「这个目录现在干不干净」—— 在场的**每一份**覆盖面内文档过文档面那几只判官(域 `parseDomain`、`remote-exec.json` 的 `parseRemoteExecDocument`、退役域的墓碑判),不过 ⇒ `refused`、退出 1、一字不写;`migrate` 与 `migrate --check` 同判。此前迁移不碰的文档永不被判:陈旧形(`models.json` 里已退役的 `default` 键、带 `#fragment` 的模型 URL、带事实的 `runtime.json`)与别的读侧读不进的文档(例:重名的目录模型)都报 `noop` / 退出 0。
75
104
  2. **读数变化**:同一个目录,此前 `noop` / 退出 0,现在 `refused` / 退出 1;同目录里还有可迁的文档时,此前可迁的那份被写回、现在整目录一字不写(`--check` 同判,不是 `pending`);迁移步拒收的坐标与读不进的陈旧文档并在一份 `refused[]` 里。`outcome` / `written` / `refused` 三字段的形与退出码表(0 / 1 / 2 / 3)不变;读得进的目录、只有可迁的文档、退役域的空文件 `{}` 照旧。**已知的边**:判官是文档面那一只(`parseDomain`),它与读腿(视图面)两个方向上答得不一样 ——
@@ -102,7 +131,7 @@ only (`node:crypto`, `node:fs`). The machine gate is `test/runtime-dependencies-
102
131
  3. **读数变化**:同一份记录里别的毛病在去掉保留名之后才报(守卫一条就是这只座位的结论);逐条丢弃域里名叫保留名的 Record 条目整条 `entry-dropped`(`entry-key-invalid`);`isReportableRefusalName` 对 `constructor` / `prototype` 答 `false`。
103
132
  4. **型面**:凭据引用集合那几格的 `z.input` 由 `unknown` 变成记录形;对记录字段 schema 做 `instanceof z.ZodRecord` 的内省先剥一层输入侧管道(`.out`);经过记录字段的 `z.encode` 抛;JS 调用方递来的非纯数据记录(访问器成员、不可枚举的自有键、另一个原型上的对象)拒。导出名零变化。
104
133
  5. **目录条目的 `defaultThinking`**(消费接入档 §43):一个模型自己的缺省思考级位,值是 `MODEL_THINKING_LEVEL_WORDS` 里的一个词(`off` 与六档;与 `thinkingLevelMap` 的键同一张表);缺席 = 未声明。坏值(表外的词 / 别的大小写 / 两侧空白 / `null` / 非串)整条拒 —— 此前文档面剥键受理、视图面带它的条目整条丢(`entry-unknown-key`),自此合法值照带、坏值视图面 `entry-schema-invalid`、严写面整份拒。动作:存量目录上写了这一键的,升级前跑 `validateDomain("models", 文档)`;拒了就改成七词之一或删掉。漂移门对拍的引擎钉抬到 7.68.5。
105
- 6. **跨域读的域读拒**(§44):`buildEffective` / `readEffectiveWire` / `FileConfigStore` 的 `read()` 与 `getEffective()` / `loadLocalConfig` 在门控域整域读不进时抛 `DomainReadRefusedError`(`domain` = 那个域,`cause` = 判官的原拒,`message` = `config domain "<域>" could not be read: <原拒的句子>`);此前裸抛原拒(脱敏 `ZodError` / 中性 `TypeError`)。动作:按型捕获的改成 `e instanceof DomainReadRefusedError`(跨两份包实例用 `e.name`),原来的 issue 读 `e.cause.issues`。目录域的 `domain-defaulted` 告警与单域读口(`parseDomain` 等)不变。`onWarning` 回调自己抛的错自此原样穿出(此前目录域会把它读成整域读不进、回落默认)。
134
+ 6. **跨域读的域读拒**(§44):`buildEffective` / `readEffectiveWire` / `FileConfigStore` 的 `read()` 与 `getEffective()` / `loadLocalConfig` 在门控域整域读不进时抛 `DomainReadRefusedError`(`domain` = 那个域,`cause` = 判官的原拒,`message` = `config domain "<域>" could not be read: <原拒的一句话>` —— 每条 issue 一段 `<坐标>: <句子>`、至多三段、一行,坐标在前,不是原拒 `message` 的 JSON 文本;原拒原样在 `cause` 上);此前裸抛原拒(脱敏 `ZodError` / 中性 `TypeError`)。动作:按型捕获的改成 `e instanceof DomainReadRefusedError`(跨两份包实例用 `e.name`),原来的 issue 读 `e.cause.issues`。目录域的 `domain-defaulted` 告警与单域读口(`parseDomain` 等)不变。`onWarning` 回调自己抛的错自此原样穿出(此前目录域会把它读成整域读不进、回落默认)。
106
135
  7. **device 车道两只可选坐标**(§45):`DEVICE_MAX_PREAUTH_PER_REMOTE`(`off` 或正十进制整数)与 `DEVICE_TRUSTED_PROXY_CIDRS`(逗号分隔的 CIDR,项两侧只剥空格与制表符;拒空项 / zone id / 非 CIDR / 装下某一族每个来源的项〔前缀 0,或装下整段 IPv4 映射地址的 IPv6 网络〕/ 主机位非零)的值由写闸判,判官是包根的 `readDeviceMaxPreAuthPerRemote` / `readDeviceTrustedProxyCidrs`(交读数);引擎起服改读同一只是服务端提货本版那一步的事,在那之前服务端起服仍用它自己的解析器。空串 = 未设;纯空白由收变拒。动作:升级前对存量 worker 行跑 `WorkerSpec.safeParse`,命中 `coords.DEVICE_` 开头的 issue 即按 CHANGELOG 32.0.0「device 车道」一节「写闸新拒的每一形」的样本表改值(例:信整块写 `10.0.0.0/8`,信一台写 `10.0.0.5/32`)。地址文法包里一份(`ipFamilyOf` 是它的族),连接路由的 `isLoopbackRouteHost` 改读它:剥掉两侧空白 / 大小写 / 方括号 / 尾点之后整串得是一个地址 —— 串里带制表符 / 换行、`]` 后接端口 / 路径 / 查询、带用户信息的 IPv6 形由 `true` 变 `false`(只此方向);拿 `URL.hostname` / socket 地址问的读者读数不变。
107
136
  8. **http hook 条目的 `url`**(§46):字段表 `HOOK_ENTRY_FIELDS` 的 `http.url` 由 `"text"` 改 `"url"` —— 非空、无 NUL 的串,且 WHATWG URL 解析器原样读得出绝对 URL、去掉两端空白之后也读得出(`URL.canParse`;后一步是参照实现的读法,本包收的参照必收);原样带。url 不是绝对 URL 的条目由装上变坏块(非守卫事件剔那一条、守卫事件整份拒,`field` = `url`)。与参照实现的余差:url 两端带非 ASCII 空白(U+00A0 / U+3000 / U+FEFF 等)且带着它原样解析不出的(开头带恒如此),参照去掉再判、照装,本包是坏块(`docs/CC-DIVERGENCE.md` H9)。动作:升级前对存量设置文件与要续跑的请求体跑 `classifyHooksConfig`,`field` = `url` 的改成绝对 URL 或删掉;对字段取值类写穷举的补一臂 `url`。
108
137
  9. **`SubagentStart` / `SubagentStop` 改判引擎属主**(§46):`ENGINE_OWNED_HOOK_EVENTS` 尾插两员(十 → 十二),`ENGINE_OWNED_HOOK_EVENT_SINCE` 两行 = `32.0.0`;配置校验不读属主表,设置文档读数不变。动作:按属主分流的消费方照旧只问 `engineOwnsHookEventAt(event, 对端契约版本)`;本地也会触发这两只钩子的终端,对报 32.0.0 及以上的服务端要让位(否则同一次子代起止两边都跑);对 `EngineOwnedHookEvent` 写穷举的补两行。
@@ -609,8 +638,8 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
609
638
  `receipts` 逐条说「对哪个坐标做了什么」(`moved` / `rewritten` / `dropped-inert` / `refused` / `minted`;不带值)。
610
639
  `refused` 的坐标原样留着,读侧照旧拒:要人改。再跑一次 = 零改动。
611
640
  - **目录形**:`npx @sema-agent/settings-schema migrate <config.d directory> [--check]`(同一只函数;目录当一个 scope;有 refused 一字不写、退出 1;
612
- `--check` 有改动退出 3)。命令行问的是「这个目录现在干不干净」:在场的**每一份**文档过文档面的整文档判官(`parseDomain` 一类),判不过的文档 —— 迁移不再改写的陈旧形
613
- (`models.json` 里已退役的 `default` 键、带 `#fragment` 的模型 URL、带事实的 `runtime.json`)与任何别的整文档判不过的文档 —— 也是 refused、退出 1、一字不写:`refused[]` 点名文档与坐标并给出路(手改后重跑)。
641
+ `--check` 有改动退出 3;拒收时 stderr 一行说几处被拒、每处的文件 / 坐标 / 原因与出路 —— 与函数结果的 `why` 同一句,原因就是 `refused[]` 里那条 `reason` 开头的那一句;`--help` / `-h` 是求用法:用法打 stdout、退出 0,无参与别的用法错仍是 stderr、退出 2)。命令行问的是「这个目录现在干不干净」:在场的**每一份**文档过文档面的整文档判官(`parseDomain` 一类),判不过的文档 —— 迁移不再改写的陈旧形
642
+ (`models.json` 里已退役的 `default` 键、带 `#fragment` 的模型 URL、带事实的 `runtime.json`)与任何别的整文档判不过的文档 —— 也是 refused、退出 1、一字不写:`refused[]` 点名文档与坐标:迁移没碰的文档,每条拒还带读腿的后果与出路句(手改后重跑);迁移改过、改完仍判不过的那一份,条目本身没有出路(`reason` 只是判官那一句),出路在整份 `why`(stderr 里同一句:手改后重跑)。
614
643
  文档面与读腿两个方向上答得不一样(升级指引 33.0.0 第 2 条的已知的边):逐条丢弃域里条目只因带读侧不认识的键,这里答干净而读腿丢那一条(零幸存者时整域退缺省 / 整域拒;不逐条丢的域两边都剥键受理);逐条丢弃域里一条坏条目,读腿只丢它而这里整目录拒。
615
644
  参数是 `config.d` 目录**本身**(里面直接放 `<域>.json`):目录里有条目却没有一份域文档 —— 填成了它的上一层、只有
616
645
  `remote-exec.json` 之类非域文件 —— 退出 2、stdout 空,stderr 点名这个目录(`<目录>/config.d` 在场就直接点它);目录真空(零条目,或只有以 `.` 开头的条目)是合法态
@@ -836,11 +865,21 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
836
865
  A category's `tighten` answers only a `whole` unit's value; a declared member's comparator comes from its row's value class —
837
866
  `MemberAdmission.list: true` marks a string-list member, `boolPole` a boolean one, exactly one per row — via
838
867
  `memberTighten(category, member)` (`list` ⇒ setUnion for tighten / setNarrower for loosen; neither or both ⇒ RangeError).
839
- The settings-document unit table is published here too: `SETTINGS_UNITS` (the ten units `permissions` · `permissionMode` ·
840
- `additionalDirectories` · `sandbox` · `disableBypassPermissionsMode` · `disableAutoMode` · `hooks` · `env` · `model` · `outputStyle`,
841
- each with its document `path`, category, addressing and reading), `unitTighten(unit, member?)` (a unit's comparator) and
842
- `readSettingsUnit(unit, raw, member?)` (its raw-value reading: `"manual"` ⇒ `"default"`, `"disable"` ⇒ `true`, `false` stays
843
- `false`, `"bypassPermissions"` ⇒ `launch_only`, everything outside the unit's reading — and `undefined` / `null` — ⇒ `unreadable`).
868
+ The settings-document unit table is published here too: `SETTINGS_UNITS` (eleven units: `permissions` · `permissionMode` ·
869
+ `additionalDirectories` · `sandbox` · `disableBypassPermissionsMode` · `disableAutoMode` · `hooks` · `env` · `model` · `outputStyle` ·
870
+ `semaUiLanguage`, each with its document `path`, category, addressing, reading, `reader` and `sources`), `unitTighten(unit, member?)` (a unit's
871
+ comparator) and `readSettingsUnit(unit, raw, member?)` (its raw-value reading: `"manual"` ⇒ `"default"`, `"disable"` ⇒ `true`, `false`
872
+ stays `false`, `"bypassPermissions"` ⇒ `launch_only`, `semaUiLanguage` takes exactly `en` / `zh` — `zh-CN`, `EN` and the like are not
873
+ folded —, everything outside the unit's reading — and `undefined` / `null` — ⇒ `unreadable`). A writer judges the value it is about to
874
+ write with the same call, so the refusal word is the reading's `reason`. Who reads a unit is its row's `reader`, one of
875
+ `SETTINGS_UNIT_READERS` (`shell` = only the host's own interface, never the engine, wherever it runs — `semaUiLanguage`; `engine` =
876
+ the conservative answer for the rest: the value can change what the engine does, whether the engine reads it or a host folds it into
877
+ the engine's request — the other ten, `outputStyle` included; whether one write reaches one engine depends on how that host feeds
878
+ it, so ask the host): a fact per key, not per category (the `ui` category holds both kinds; its seam string points at the units'
879
+ `reader`); `hooks` is `engine` as a whole, the per-event owner is `HOOK_EVENT_OWNER`. Which settings sources carry a unit is its
880
+ row's `sources`: a value in any other source is not read, and inside them `layerAdmission` answers — the ten carry every source
881
+ (`SETTINGS_SOURCES`), `semaUiLanguage` only `UI_LANGUAGE_SETTING.source` (user settings, which `layerAdmission` admits for `ui`).
882
+ The UI-language row takes its key, category and source from `UI_LANGUAGE_SETTING`; its comparator is the `ui` category's `none`.
844
883
  - **Settings sources + layer admission** (`settings-sources.ts`, main barrel): `SETTINGS_SOURCES` (declaration order =
845
884
  merge order: user < project < local < flag < policy), `SETTINGS_SOURCE_CONTRACT` (each source's trust tier and whether a
846
885
  repository controls it — `projectSettings` / `localSettings` are repository-controllable and share the `project` tier, as in
@@ -887,7 +926,8 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
887
926
  `parseWebAdminCredentialFile(text)` is the ONE discrimination law — trimmed text starting with `{` is read ONLY
888
927
  as an envelope (a failure is `unreadable`, never a fallback to a bare line); anything else is a bare line,
889
928
  and a first line that is not a token is `unreadable` too (never sent as a bearer); empty is `unreadable`. The `reason` names envelope fields / zod issue codes / an unknown-key COUNT, never file
890
- content. Pure: reading, atomically writing and renewing the file are the consumers' job. The DECLARATION face is lifted here too (since 6.1.0 as two key names plus the exclusive-or judge; the one table below, the `assertion` pair and the required second argument since 11.0.0): `WEB_ADMIN_ENV` — every env name an engine reads to reach web-admin, one table
929
+ content. Pure: reading, atomically writing and renewing the file are the consumers' job — every writer of the file takes the
930
+ single-writer lock below. The DECLARATION face is lifted here too (since 6.1.0 as two key names plus the exclusive-or judge; the one table below, the `assertion` pair and the required second argument since 11.0.0): `WEB_ADMIN_ENV` — every env name an engine reads to reach web-admin, one table
891
931
  (`url` / `token` / `tokenFile` / `worker` / `liveUrl` / `webUrl` / `dryRun` / `adminToken` / `assertionToken` /
892
932
  `assertionTokenFile`, values `SEMA_WEB_ADMIN_*`; one spelling for web-admin rendering worker env, the shell writing its
893
933
  local engine's env, and the server reading it) and `judgeWebAdminCredentialDeclaration(env, credential)` — `credential` ∈
@@ -895,6 +935,52 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
895
935
  no default) → `env` / `file` / `absent`, the one pick-exactly-one rule for every credential: an empty string is unset, BOTH set (non-empty) throws (the refusal
896
936
  names the two keys, never a value), the file path comes back verbatim (resolving a relative one against a cwd
897
937
  is the reader's job).
938
+ - **Single-writer lock on the web-admin credential file** (protocol constants in the main barrel, the lock in `./node`, its conformance test in
939
+ `./conformance`): the engine renewing the envelope and the shell logging in / refreshing / logging out write ONE file. The rule is one sentence:
940
+ **every rewrite or delete of the file happens inside its leaf lock as compare-then-write** — re-read under the lock, write only when the
941
+ generation on disk (the envelope's `refreshToken`) is the one this action expects (a renewal: the token it spent; a read-then-rewrite: the one it
942
+ read; a logout / new login: any), otherwise write nothing and adopt what is on disk. **The section held under the lock does synchronous local IO
943
+ only** — no network call, no waiting, no second lock: the protocol reads a lock's age as evidence that its holder died.
944
+ `tryWebAdminCredentialFileLock(credentialPath, critical)` (`./node`) is the one implementation: the path is resolved to its real target (a symbolic
945
+ link is written through, a dangling one — the link there, its target gone — is refused as `unreadable`: nothing created, nothing written, the same rule
946
+ as the package's atomic writer; see the first limit below); the lock is `.<real file name>.lock`
947
+ (`webAdminCredentialLockName`) beside it, created with `open(…, "wx")`, identity = that descriptor's `(dev, ino)`, **and the descriptor stays open
948
+ until the lock is released** — an identity is two numbers, and a deleted file's inode number is handed to the next file created (on Linux an
949
+ immediate re-create commonly gets the same one), so the file object is pinned for as long as the numbers are compared. **An implementation that
950
+ records `(dev, ino)` and closes the descriptor is wrong**: measured on Linux, a successor lock created right after the old one was deleted got the
951
+ identical inode number, and such an implementation took the successor's lock for its own (two holders) and deleted a live lock it took for the
952
+ stale one; it is tried once and never
953
+ waited for — and the lock's name must be held by a regular file: anything else there (a named pipe, a directory, a symbolic link, dangling or not) is
954
+ not a lock, is neither waited for nor reclaimed nor touched, and the answer is `unreadable` with one sentence and one `code` for all of them (as seen when
955
+ the lock is attempted; see the limits below for an occupant swapped in mid-attempt); a lock older than `WEB_ADMIN_CREDENTIAL_FILE_LOCK.staleMs` (10 s — a protocol constant, not a deployment knob; a modification time in
956
+ the future counts as fresh; the lock being judged is opened read-only and pinned the same way) is reclaimed by renaming it aside
957
+ (`.lock-aside.<process id>.<random>` — bounded length, not appended to the lock name), checking the moved file is the one judged stale, and
958
+ deleting the moved file — when it turns out to be someone else's fresh lock the answer is `busy` and that lock's holder reads it as lost (it is
959
+ never put back: a put-back `rename` would overwrite a third writer's lock created on the momentarily free name). Releasing first checks the lock
960
+ is still this caller's and touches nothing otherwise, so a lock is never deleted by path. The callback gets a handle: `target` (the real file), `current` (its text read under the lock; `undefined` = no file),
961
+ `stillMine()`, and the two last writes `replaceWith(tempFile)` / `remove()`, each of which re-checks the lock's identity first and answers `false`
962
+ (nothing written) when the lock is no longer this caller's. Loss is sticky: once the handle has answered "not mine" (including "could not tell"),
963
+ it never writes again. The answer is closed: `acquired` / `lost` (the callback ran, but the lock was found taken over or could not be confirmed —
964
+ a write the handle answered `true` for BEFORE that point did land; whether a write landed is the method's own answer, not the status) / `busy` (`heldForMs` when the age was read and not in the future) / `unreadable` (the lock or
965
+ the target could not be created / read; nothing ran, nothing was written — never an unlocked fallback; when it is the credential path itself that could not be resolved the
966
+ answer also carries an optional `ioKind` — `dangling_symlink` for a dangling link, `read_error` for anything else — so a shell can show the way out without parsing the sentence; the
967
+ other `unreadable` answers do not carry the key). The callback must be synchronous: an
968
+ `async` callback is a compile error, and a callback that returns a promise at runtime is refused with a `TypeError` after the lock is released.
969
+ **Another implementation of this protocol must pass `runWebAdminCredentialLockConformance(implementation)`** (`./conformance`; same signature as
970
+ `tryWebAdminCredentialFileLock`) — one protocol, one set of checks; two implementations each declaring themselves compliant does not count.
971
+ Limits, stated: **a credential file reached through a symbolic link is not writable again after a logout deletes the link's target** — the link now dangles
972
+ and the next lock attempt answers `unreadable` (fail closed: nothing created, nothing written; the way out is to remove the dangling link or recreate its
973
+ target; a credential path that is the real file is not affected); this version does not resolve a dangling link to the place it points at — that
974
+ would mean changing the package's atomic writer, which refuses to create the file a link points at, so it would be a separate design and a major release. The
975
+ lock name's occupant is judged as seen when the lock is attempted; swapped between the type check and the act it can show up as the kernel's own `code`
976
+ and sentence (a link put there between the check and the open), as `busy` (a directory or link put there between the first collision and the second
977
+ exclusive create), or as a link moved aside and deleted like a stale lock (put there under an old lock between its stat and the rename). A holder frozen for longer than `staleMs` (debugger, `SIGSTOP`) is taken over, and the one system call between its last identity
978
+ check and its rename / unlink is not sealed (the same one call is open when two reclaimers race on one stale lock and one of them moves the
979
+ other's brand-new lock aside); the holder whose lock was moved aside by mistake does not get its write in this time; a writer that keeps the lock taken can keep another writer out indefinitely (each
980
+ attempt is bounded, eventual success is not); a crashed lock plus a clock moved backwards stays "fresh" until real time catches up (stop every
981
+ writer, then delete the lock file by hand); the credential file must be on a local disk (network filesystems: synchronous calls have no timeout
982
+ and the server stamps modification times); Windows semantics of `wx` / `rename` / file ids follow the documented platform behaviour and are not
983
+ measured here.
898
984
  - **Sandbox git credential plane** (14.7.0; `sandbox-git.ts` + `api/credentials.ts`, main barrel only — no subpath): a sandbox's git uses the
899
985
  MEMBER's own credential, fetched by the data plane from web-admin's credential port and used only through a proxy in that member's own pod. This
900
986
  package carries the shapes and word tables, no IO. (1) `isSandboxGitOrigin` — a string equal to its own WHATWG origin with scheme http / https (the
@@ -905,11 +991,12 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
905
991
  default, carried verbatim by `readEffectiveWire` (`EffectiveWire.sandboxGit` is `unknown`) and judged by the consumer with `SandboxGitConfig`.
906
992
  (2) The credential port's wire for `kind: "sandbox_git"`: `SandboxGitCredentialRequest` (claim a handle), `CredentialHandleAnswer` /
907
993
  `CredentialResolveRequest` (kind-independent), `SandboxGitCredentialAnswer` with one `SandboxGitOriginAnswer` per origin (discriminated by
908
- `state`; `secret` only on the `active` arm — other arms strip it), `SandboxGitCredentialRefusal` (`{ error, permanence, message }`). Three word tables,
909
- each spelled once: `SANDBOX_GIT_ORIGIN_VERDICTS` (the 11-row per-origin judgment order; `SANDBOX_GIT_ORIGIN_STATES` / `SANDBOX_GIT_ORIGIN_REASONS`
910
- and the answer arms' reason domains derive from it), `SANDBOX_GIT_REFUSALS` (10 refusal words → HTTP statuses + `permanence`;
911
- `SANDBOX_GIT_REFUSAL_ERRORS` derives from it), `SANDBOX_GIT_PERMANENCE` (`terminal` / `transient`). Both sides' reading is in
912
- `docs/CONSUMER-INTEGRATION.md` §12.
994
+ `state`; `secret` only on the `active` arm — other arms strip it), `SandboxGitCredentialRefusal` (`{ error, permanence, message }`). Word tables
995
+ (each word's row — HTTP statuses and `permanence` — is written once): `SANDBOX_GIT_ORIGIN_VERDICTS` (the 11-row per-origin judgment order; `SANDBOX_GIT_ORIGIN_STATES` / `SANDBOX_GIT_ORIGIN_REASONS`
996
+ and the answer arms' reason domains derive from it), `SANDBOX_GIT_REFUSALS` (11 refusal words → HTTP statuses + `permanence`, derived in a
997
+ declared order from the credential plane's shared table `CREDENTIAL_PLANE_REFUSALS` (9 words) and this port's own two words — the previous
998
+ release's ten words keep their order, new words are appended; `SANDBOX_GIT_REFUSAL_ERRORS` derives from it), `SANDBOX_GIT_PERMANENCE`
999
+ (`terminal` / `transient`). Both sides' reading is in `docs/CONSUMER-INTEGRATION.md` §12.
913
1000
  - **User lifecycle events** (29.0.0; `api/lifecycle-events.ts`, main barrel only — no subpath): the wire shapes of "this principal was deleted /
914
1001
  demoted / removed from a space" — the producer (web-admin) emits sequenced events, the consumer (the execution plane) pulls them in pages, dedups by
915
1002
  `seq`, and reconciles principals' standing at start-up and when its cursor stops being valid. Shapes and word tables only, no IO; unknown KEYS are stripped
@@ -1050,7 +1137,17 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
1050
1137
  key to the strip inside its body (registered extension keys excepted) — an entry carrying an unknown key is a bad entry under the same salvage
1051
1138
  laws (dropped and named, zero survivors ⇒ the whole-domain tier, never loaded stripped); unknown keys outside every entry, the seven non-salvage
1052
1139
  domains and the document face are unchanged. `salvageEntries(schema, raw, domain)` takes the domain as a required third argument (whose
1053
- extension namespaces apply). **3.0.0** re-casts every coordinate these warnings
1140
+ extension namespaces apply). A row whose word is `entry-unknown-key` also says WHICH keys (additive, on `DroppedEntry`, on the `entry-dropped` warning, and on a
1141
+ `domain-defaulted` warning whose triggering entry is such a row): `unknownKeys: string[]` — the stripped key NAMES that may leave the process
1142
+ (each asked of `isDisclosableIdentity`, the one judge of a name's `name` / `id` identity; the others are left out, never masked), in document order, each name once,
1143
+ at most 64. It is a list of names, not coordinates (the layers are in `error`'s `unrecognized_keys` issues, whose keys have each passed the coordinate redactor).
1144
+ The list can be short: when it does not hold every stripped name (a name that may not leave, or more than 64), the row also carries `truncatedFrom` — the number of
1145
+ DISTINCT stripped key names — the same name and the same meaning as on `unknown-keys-dropped`; `truncatedFrom` absent while `unknownKeys` is present ⇒ the list is all of them.
1146
+ Nothing nameable ⇒ both keys absent (the word alone says "a key was stripped"). The other three words never carry either key. Neither is part of the warning projection:
1147
+ they are DIAGNOSTIC keys, declared once beside the warning union (with the three keys a `domain-defaulted` warning carries), and `WarningProjection` — the arm minus `error` and minus
1148
+ the arm's diagnostic keys — and `projectWarning` both follow that one declaration, so the type no longer says "in the projection" about keys the projection never carries
1149
+ (a type-level break for anyone who read those keys off `WarningProjection`: read the warning itself; the projection's values are unchanged; `truncatedFrom` on `unknown-keys-*`
1150
+ is not a diagnostic key and stays in the projection). **3.0.0** re-casts every coordinate these warnings
1054
1151
  carry (`entry-dropped.path`, `unknown-keys-*.keys`) from a dot-joined STRING to a structured
1055
1152
  `ConfigPath = readonly (string | number)[]` — a string segment is an object key (verbatim, `.` included),
1056
1153
  a number segment is an array index — because the string form was a LOSSY encoding: a key literally named
@@ -1077,7 +1174,9 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
1077
1174
  plus the one fold of an option key into its hook environment variable name, `pluginOptionEnvName(key)`;
1078
1175
  and THE rule for a command line's placeholders, `planHookCommandSpawn(entry, paths, resolved?)` (self-contained, pure: the three path names and `${user_config.K}` substituted in one
1079
1176
  left-to-right pass whose inserted values are not scanned again; `${user_config.K}` is a placeholder on a plugin entry only — an entry with a `plugin` member, the entry
1080
- itself says so; its table is `resolved` when given, else the entry's own `plugin.options`, `{}` when it has none; refusal words `HOOK_COMMAND_SPAWN_REFUSAL_WORDS`, in precedence order, sentences `hookCommandSpawnRefusalSentence`;
1177
+ itself says so; its table is `resolved` when given, else the entry's own `plugin.options`, `{}` when it has none; refusal words `HOOK_COMMAND_SPAWN_REFUSAL_WORDS`, in precedence order, sentences `hookCommandSpawnRefusalSentence` —
1178
+ the three words about a plugin's options, `shell_form_user_config` / `user_config_unset` / `user_config_unresolved`, have one shape — the word, `key`, and `pluginName` (the entry's own `plugin.name`) —
1179
+ and their sentences open alike, naming both: `hook command names option "<key>" of plugin "<plugin>", which is not set`;
1081
1180
  the answer is the copy a process starts from, never what is shown)) and the ONE classifier `classifyHooksConfig(settingsDoc)` — which pieces of a settings document's `hooks` drop
1082
1181
  (`HOOKS_DROPPED_PIECE_CODES`), whether the whole document is rejected because a guard (`PreToolUse` / `PermissionRequest`) may be
1083
1182
  in a bad piece (`HOOKS_REJECTION_CODES`), and what loads; codes + `ConfigPath` coordinates + the wrong key's name (`field`: for a matcher / entry, the contract
@@ -1107,11 +1206,29 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
1107
1206
  `TOOL_WIRE_NAME_MAX_CHARS`, mirrored; a name with leading or trailing whitespace is a bad name too — never trimmed, never normalised; inner whitespace stays legal), `isUsableMcpServerName` / `describeBadMcpServerName` (14.8.0; the request plane's judge of an MCP server's name: the wire-name judge plus one arm — the `remote-` prefix, `REMOTE_MCP_SERVER_NAME_PREFIX`, is reserved for the remote MCP servers a device executor offers; the config plane's `McpServerSpec.name` accepts it — refusing would be a validation tightening, which the release discipline files under a major; A2A peer names keep `isUsableWireName`), `isContentOriginWord` / `describeBadContentOrigin`, `readRequestMcpTransport` (29.0.0: the keys it refuses by name, `MCP_REQUEST_KEY_REFUSALS`; `readMcpIdentityHeaders` removed)
1108
1207
  (hard faults `ok:false` naming the key path; soft faults dropped by the reader and listed in `lost`; `env` / `headers` are read as plain-data string records — a `Map`, a class instance or an own `__proto__` member is not one, the delivered record is a copy, and a `lost` entry for a record carries machine-readable `member` / `fault` — 29.0.0: that reading is the public `readRequestStringRecord(path, raw)` taken at `transport.env` / `transport.headers`, so a consumer reading its own name → string record (an A2A peer's `headers`) gets the same diagnostics at its own path; the two describers strip control and bidi characters and cut at 64 characters, the service's echo form) and the value-shape describers — one reading for
1109
1208
  the service's request legs and the shell's pre-send check. A `toolFaces` declaration stays parse-transparent here: its shape is the engine ingest side's to judge, and none of the tool-face vocabularies is mirrored in this package.
1209
+ - **Credential reference on a request-plane http MCP entry** (`mcp-request-entry.ts`, 34.0.0 — a loosening of what the reader accepts, which the release rules count as breaking; see the 33.1.x → 34.0.0 upgrade guide): `readRequestMcpTransport` takes `transport.credentials` on an **http** transport when it is a well-formed
1210
+ reference of a kind in the reader table `MCP_REQUEST_CREDENTIAL_KINDS` (today `["vault"]`, deep-frozen, the one admission table — a consumer that derives "which reference kinds does the request plane take" reads it
1211
+ instead of keeping a list) and hands it on in the read transport (`McpRequestCredential` = the judge's `HookPluginOptionRef`, a fresh frozen copy — never the caller's object). The reader **judges form only: it resolves nothing and fetches no value**;
1212
+ whose store the `vault` entry lives in, where a token comes from and what a reference alongside a hard-coded `Authorization` header means are the consumer's — the reader accepts that combination and does not judge header ownership.
1213
+ The reader does not judge "is this a vault reference" itself — it asks `readHookPluginOptionRef`, the package's one judge of that (the plugin option values of a hook entry use it too), and the table is **asked of that judge, not written
1214
+ down**. Admission is the conjunction: the judge takes it (the value is read once by the primitives' `readCredentialRef`, the safe copy is put to the judge) ∧ the engine's admission table still says `own_entry` for the request plane. Everything else is as it was:
1215
+ the other three well-formed kinds (`env` / `handle` / `assertion`) and every malformed value on an http transport, and **any** value on a stdio transport (a `vault` reference included), stay `credentials_not_carried` at
1216
+ `transport.credentials` (the sentence for a value that is not a reference of an admitted kind on http names what the reader takes; the other sentences are unchanged). Order and reading are unchanged: `assertionHeader` is judged
1217
+ before `credentials`; a `credentials` visible only through the prototype chain is not read (it is listed in `lost`); an own accessor is read once.
1218
+ Two consequences, stated: an http entry with a well-formed `vault` reference AND a bad `url` used to answer `credentials_not_carried` and now answers the hard-bad `url` (no `refusal`); and "is it a reference" is the primitives' judge, which reads own
1219
+ ENUMERABLE keys — a request body (parsed JSON) shows every extra member to it, but an extra member under a non-enumerable or Symbol key, which only a program-built object can carry, is not seen and not refused.
1220
+ - **`.env` in two steps** (`local-load.ts`, `./node`, additive): `readEnvFileLines(root)` parses `<root>/.env` into `NAME → the text written` and resolves **nothing** (no `file:` target is looked at, the process environment is not merged in);
1221
+ a line that is not an assignment is reported by number and a closed-set word (`ENV_FILE_LINE_FAULTS`: `no_equals` / `empty_name`), never by its text. `resolveEnvFileAssignments(reading, names, { trust? })` resolves only the names the
1222
+ caller lists: a `file:` target is asked of the caller's trust seat with its absolute path **before any byte is read** (`undefined` lets it through, a string refuses and is the sentence, a throw or a reject refuses too — nothing is
1223
+ read from a refused target, absent or not), and a name that cannot be resolved comes back in `refused` with a closed-set fault (`ENV_FILE_REF_FAULTS`) and the same error `loadEnvFile` throws on that line. `loadEnvFile(root)` is these two
1224
+ steps over every name in the file with no seat, the process environment underneath and the file winning — its signature and behaviour are unchanged (one bad `file:` reference anywhere in the file still throws, the first in file order).
1225
+ `envFilePath(root)` is the one builder of the file's path.
1110
1226
  - **One-line echo strip set** (`control-and-bidi.ts`, main barrel): `CONTROL_AND_BIDI_CHARS` (C0 + DEL + the 12 `Bidi_Control=Yes` code points,
1111
1227
  as regex character-class source text), `stripControlAndBidi(text)` and `hasControlOrBidi(text)` — the one set a caller- or repository-written string loses
1112
1228
  before it lands in a refusal, a warning, a log line or one screen line (C1 and U+2028 / U+2029 deliberately outside it). It is an echo policy owned here,
1113
1229
  not a mirror of the engine's bidi table: the request-plane describers read it, and so do consumers instead of keeping a class of their own.
1114
- - **UI language** (`ui-language.ts`, 13.0.0): `semaUiLanguage` (`en` / `zh`, category `ui`, user settings) + `readUiLanguage`.
1230
+ - **UI language** (`ui-language.ts`, 13.0.0): `semaUiLanguage` (`en` / `zh`, category `ui`, user settings) + `readUiLanguage`. Its write-side
1231
+ unit is the `semaUiLanguage` row of `SETTINGS_UNITS` (reading `uiLanguage`, which delegates to `readUiLanguage`; `reader: "shell"`).
1115
1232
  - **Cross-session settings** (`cross-session.ts`): the two `settings.json` keys `crossSessionInbound`
1116
1233
  (wake/next-turn/hold/refuse — the core 7.30.0 vocabulary, `accept` retired in 6.0.0; `default` = unset) and `dialogExpiry` (60s/5m/10m/never), each with a reader that
1117
1234
  answers `ok:false` on a bad value instead of silently folding to the default.
@@ -1240,6 +1357,8 @@ if (!report.ok) throw new Error(report.violations.join("\n"));
1240
1357
  - **两种模式**:`release`(版本三方对齐 + 每条腿有表态 + 生产入口核验 + 禁 `only`/归一器 + 至少实现一条腿 + **实现的腿
1241
1358
  必须跑**)与 `historical`(对旧版包跑,只记行为 diff)。
1242
1359
  - **四律**:对抗律 / 变异律 / 覆盖律 / 来源律 —— 缺一不算「门」。
1360
+ - **凭证文件锁的协议一致性测试**(同一子路径,另一份 kit):`runWebAdminCredentialLockConformance(impl)` —— `impl` 与 `./node` 的 `tryWebAdminCredentialFileLock` 同签名;
1361
+ kit 在私有临时根里逐格跑黑盒场景,答 `{ ok, cases[{ id, ok, why? }] }`。本包原语过它;别的实现(壳若自己实现这把锁)也必须过它 —— 一份协议、一份判据。
1243
1362
  - **已知分歧账本** `knownDivergences`:消费方对金样的**合法**差异登记成机器可核的一行 —— 两类:会还的差异 = 债(`kind: "debt"`,票号 + 窗 + 翻转条件)、不打算还的姿态 = 姿态(`kind: "posture"`,票号指向消费方的裁定;只盖消费方比金样给得少的一侧:拒金样受理的 / 少交金样有的值),
1244
1363
  命中记 `diff-ledgered` 不阻塞;**告警差与元数据差永不可入账**,而**从未命中的一条登记本身就是
1245
1364
  违例**(棘轮只降不升,两类同律)。契约仓自证不许挂账本。
@@ -1262,7 +1381,7 @@ local `.env`). This package never carries a credential.
1262
1381
  remote-exec.json # NOT a domain (the exec backend; read by loadRemoteExec)
1263
1382
  config.env-models.json # the env-model-table decision {"envModels":"replaced"|"kept"} (readEnvModelsDecision / writeEnvModelsDecision)
1264
1383
  config.migration.SS-M11.json # the run marker of one-time migration SS-M11 {"migration":"SS-M11"} (readMigrationMarker; written only by the migration)
1265
- .env # secret VALUES only (KEY=value); gitignored; never read into any *.json
1384
+ .env # secret VALUES only (KEY=value); gitignored; never read into any *.json (read by loadEnvFile = readEnvFileLines + resolveEnvFileAssignments)
1266
1385
  ```
1267
1386
 
1268
1387
  **The root belongs to the client (TOC).** An engine writes exactly two files in it — the two root-level documents above, both outside `config.d` (the sampled
@@ -1 +1 @@
1
- 33.1.0
1
+ 34.1.0
@@ -8,12 +8,13 @@
8
8
  * 取值口的另两种凭据(`model` / `mcp_static`)的请求与应答形不在本模块;它们落地时与本模块的 `sandbox_git` 形并成按 `kind` 判别的联合,
9
9
  * 本模块的形不动(`kind` 字面量已经在)。
10
10
  *
11
- * ## 三张词表,各一张,每个词只在本文件里拼一次
11
+ * ## 词表:每个词的行(状态集与 `permanence`)只在本文件里写一次
12
12
  * · {@link SANDBOX_GIT_ORIGIN_VERDICTS} —— **逐 origin 判定序表**,11 行,序即判定序(首条命中即答;一个 origin 的结果不影响别的 origin)。
13
13
  * 状态词({@link SANDBOX_GIT_ORIGIN_STATES},六个)与原因词({@link SANDBOX_GIT_ORIGIN_REASONS},十个)由它派生,没有第二张词表;`active` 行没有原因。
14
14
  * 应答行({@link SandboxGitOriginAnswer})每个状态一个臂,臂里 `reason` 的值域 = 表里该状态的行 —— 状态与原因的配对由表定,臂不手写。
15
15
  * 每一行的**条件**(什么事实使它命中)是 web-admin 的判定逻辑,写在 `docs/CONSUMER-INTEGRATION.md` 里,不进运行期表。
16
- * · {@link SANDBOX_GIT_REFUSALS} —— **整次拒答词**(十个)→ HTTP 状态集与 `permanence`;拒体里的 `permanence` 是错误词的函数,必须等于这一行的。
16
+ * · {@link CREDENTIAL_PLANE_REFUSALS} —— 凭据平面共享拒答表(九个词;同一平面的各只口从它派生,每个词的状态集与 `permanence` 只在这里写一次)。
17
+ * · {@link SANDBOX_GIT_REFUSALS} —— 整次拒答词(十一个)→ HTTP 状态集与 `permanence`,由凭据平面共享表 {@link CREDENTIAL_PLANE_REFUSALS}(九个)与本口自有的两个词按声明的次序派生(上一版的十个词原序、新词只在尾部);拒体里的 `permanence` 是错误词的函数,必须等于这一行的。
17
18
  * · {@link SANDBOX_GIT_PERMANENCE} —— `terminal`(不按定时重试)/ `transient`(退避重试)两词,语义在本表定义。
18
19
  *
19
20
  * ## 解析一律剥未知键
@@ -208,18 +209,15 @@ export type SandboxGitCredentialAnswer = z.infer<typeof SandboxGitCredentialAnsw
208
209
  export declare const SANDBOX_GIT_PERMANENCE: readonly ["terminal", "transient"];
209
210
  export type SandboxGitPermanence = (typeof SANDBOX_GIT_PERMANENCE)[number];
210
211
  /**
211
- * 整次拒答词 → 它的 HTTP 状态集(中心答这个词时用其一)与 `permanence`。**一个错误词的 permanence 是固定的**,拒体里再带一份只为让收方不必查表 ——
212
- * 两处不一致就是畸形应答({@link SandboxGitCredentialRefusal} 拒)。收方怎么处置某个词(例如哪些 terminal 可由用户动作恢复)是收方的状态机,不在这里。
212
+ * 凭据平面共享拒答表(九个词):同一凭据平面的各只口都从它派生(`sandbox_git` 凭据取值口如此,同一平面的后续取值口同样如此),
213
+ * 每个词的 HTTP 状态集与 `permanence` 只在这里写一次。
214
+ * `plane_misconfigured` = 凭据平面在答方配置错 —— `terminal`,按定时重试不会成功,必须由运维修正配置。
213
215
  */
214
- export declare const SANDBOX_GIT_REFUSALS: {
216
+ export declare const CREDENTIAL_PLANE_REFUSALS: {
215
217
  readonly caller_not_admitted: {
216
218
  readonly statuses: readonly [401, 403];
217
219
  readonly permanence: "terminal";
218
220
  };
219
- readonly scope_mismatch: {
220
- readonly statuses: readonly [403];
221
- readonly permanence: "terminal";
222
- };
223
221
  readonly incarnation_mismatch: {
224
222
  readonly statuses: readonly [403];
225
223
  readonly permanence: "terminal";
@@ -244,32 +242,114 @@ export declare const SANDBOX_GIT_REFUSALS: {
244
242
  readonly statuses: readonly [503];
245
243
  readonly permanence: "terminal";
246
244
  };
245
+ readonly vault_unavailable: {
246
+ readonly statuses: readonly [503];
247
+ readonly permanence: "transient";
248
+ };
249
+ readonly plane_misconfigured: {
250
+ readonly statuses: readonly [503];
251
+ readonly permanence: "terminal";
252
+ };
253
+ };
254
+ /** 凭据平面共享拒答词(闭集,九个)—— 类型由 {@link CREDENTIAL_PLANE_REFUSALS} 派生。 */
255
+ export type CredentialPlaneRefusalError = keyof typeof CREDENTIAL_PLANE_REFUSALS;
256
+ /** 凭据平面共享拒答词表(运行期;表的键,按表序)。 */
257
+ export declare const CREDENTIAL_PLANE_REFUSAL_ERRORS: readonly [CredentialPlaneRefusalError, ...CredentialPlaneRefusalError[]];
258
+ declare const SANDBOX_GIT_OWN_REFUSALS: {
259
+ readonly scope_mismatch: {
260
+ readonly statuses: readonly [403];
261
+ readonly permanence: "terminal";
262
+ };
247
263
  readonly handle_invalid: {
248
264
  readonly statuses: readonly [401];
249
265
  readonly permanence: "transient";
250
266
  };
251
- readonly vault_unavailable: {
267
+ };
268
+ /** 上一版的十个词保持原序,新词只追加在尾部 —— 调整既有词的次序是破坏性变更。 */
269
+ declare const SANDBOX_GIT_REFUSAL_ORDER: readonly ["caller_not_admitted", "scope_mismatch", "incarnation_mismatch", "request_invalid", "principal_not_live", "delegation_required", "vault_disabled", "vault_frozen", "handle_invalid", "vault_unavailable", "plane_misconfigured"];
270
+ type SandboxGitRefusalWord = (typeof SANDBOX_GIT_REFUSAL_ORDER)[number];
271
+ type SandboxGitRefusalSource = CredentialPlaneRefusalError | keyof typeof SANDBOX_GIT_OWN_REFUSALS;
272
+ /** 编译期核对,只在类型层(不留运行期语句):`T` 必须是 `true`,否则这一行编译即红。 */
273
+ type MustBeTrue<T extends true> = T;
274
+ /**
275
+ * 次序表与两张来源表「恰好」互为全集:来源里每个词都在次序表里(漏一个红)、次序表里每个词都在来源里(写进不存在的词红)、
276
+ * 共享表与自有表没有同名的词(重名红)。下面 `SANDBOX_GIT_REFUSALS` 的类型用到它,所以不成立 ⇒ 编译红。
277
+ */
278
+ type SandboxGitRefusalOrderIsExact = MustBeTrue<[
279
+ Exclude<SandboxGitRefusalSource, SandboxGitRefusalWord>,
280
+ Exclude<SandboxGitRefusalWord, SandboxGitRefusalSource>,
281
+ Extract<CredentialPlaneRefusalError, keyof typeof SANDBOX_GIT_OWN_REFUSALS>
282
+ ] extends [never, never, never] ? true : false>;
283
+ declare const SANDBOX_GIT_REFUSAL_ROWS: {
284
+ scope_mismatch: {
285
+ readonly statuses: readonly [403];
286
+ readonly permanence: "terminal";
287
+ };
288
+ handle_invalid: {
289
+ readonly statuses: readonly [401];
290
+ readonly permanence: "transient";
291
+ };
292
+ caller_not_admitted: {
293
+ readonly statuses: readonly [401, 403];
294
+ readonly permanence: "terminal";
295
+ };
296
+ incarnation_mismatch: {
297
+ readonly statuses: readonly [403];
298
+ readonly permanence: "terminal";
299
+ };
300
+ request_invalid: {
301
+ readonly statuses: readonly [400];
302
+ readonly permanence: "terminal";
303
+ };
304
+ principal_not_live: {
305
+ readonly statuses: readonly [403];
306
+ readonly permanence: "terminal";
307
+ };
308
+ delegation_required: {
309
+ readonly statuses: readonly [403];
310
+ readonly permanence: "terminal";
311
+ };
312
+ vault_disabled: {
313
+ readonly statuses: readonly [503];
314
+ readonly permanence: "terminal";
315
+ };
316
+ vault_frozen: {
317
+ readonly statuses: readonly [503];
318
+ readonly permanence: "terminal";
319
+ };
320
+ vault_unavailable: {
252
321
  readonly statuses: readonly [503];
253
322
  readonly permanence: "transient";
254
323
  };
324
+ plane_misconfigured: {
325
+ readonly statuses: readonly [503];
326
+ readonly permanence: "terminal";
327
+ };
255
328
  };
256
- /** 整次拒答词(闭集,十个)—— 类型由 {@link SANDBOX_GIT_REFUSALS} 派生。 */
329
+ /**
330
+ * 整次拒答词 → 它的 HTTP 状态集(中心答这个词时用其一)与 `permanence`。**一个错误词的 permanence 是固定的**,拒体里再带一份只为让收方不必查表 ——
331
+ * 两处不一致就是畸形应答({@link SandboxGitCredentialRefusal} 拒)。收方怎么处置某个词(例如哪些 terminal 可由用户动作恢复)是收方的状态机,不在这里。
332
+ * 表由 {@link CREDENTIAL_PLANE_REFUSALS} 与本口自有两词按声明的次序派生(复用同一行对象,不抄行)。
333
+ */
334
+ export declare const SANDBOX_GIT_REFUSALS: { readonly [W in SandboxGitRefusalOrderIsExact extends true ? SandboxGitRefusalWord : never]: (typeof SANDBOX_GIT_REFUSAL_ROWS)[W]; };
335
+ /** 整次拒答词(闭集,十一个)—— 类型由 {@link SANDBOX_GIT_REFUSALS} 派生,次序来自声明的次序。 */
257
336
  export type SandboxGitRefusalError = keyof typeof SANDBOX_GIT_REFUSALS;
258
- /** 整次拒答词表(运行期;表的键,按表序)。 */
337
+ /** 整次拒答词表(运行期;表的键,按声明的次序)。 */
259
338
  export declare const SANDBOX_GIT_REFUSAL_ERRORS: readonly [SandboxGitRefusalError, ...SandboxGitRefusalError[]];
260
339
  /** 整次拒答的体:`{ error, permanence, message }`。`message` 是中心的诊断句(收方不据它判,可为空串)。 */
261
340
  export declare const SandboxGitCredentialRefusal: z.ZodObject<{
262
341
  error: z.ZodEnum<{
263
342
  caller_not_admitted: "caller_not_admitted";
264
- scope_mismatch: "scope_mismatch";
265
343
  incarnation_mismatch: "incarnation_mismatch";
266
344
  request_invalid: "request_invalid";
267
345
  principal_not_live: "principal_not_live";
268
346
  delegation_required: "delegation_required";
269
347
  vault_disabled: "vault_disabled";
270
348
  vault_frozen: "vault_frozen";
271
- handle_invalid: "handle_invalid";
272
349
  vault_unavailable: "vault_unavailable";
350
+ plane_misconfigured: "plane_misconfigured";
351
+ scope_mismatch: "scope_mismatch";
352
+ handle_invalid: "handle_invalid";
273
353
  }>;
274
354
  permanence: z.ZodEnum<{
275
355
  terminal: "terminal";
@@ -8,12 +8,13 @@
8
8
  * 取值口的另两种凭据(`model` / `mcp_static`)的请求与应答形不在本模块;它们落地时与本模块的 `sandbox_git` 形并成按 `kind` 判别的联合,
9
9
  * 本模块的形不动(`kind` 字面量已经在)。
10
10
  *
11
- * ## 三张词表,各一张,每个词只在本文件里拼一次
11
+ * ## 词表:每个词的行(状态集与 `permanence`)只在本文件里写一次
12
12
  * · {@link SANDBOX_GIT_ORIGIN_VERDICTS} —— **逐 origin 判定序表**,11 行,序即判定序(首条命中即答;一个 origin 的结果不影响别的 origin)。
13
13
  * 状态词({@link SANDBOX_GIT_ORIGIN_STATES},六个)与原因词({@link SANDBOX_GIT_ORIGIN_REASONS},十个)由它派生,没有第二张词表;`active` 行没有原因。
14
14
  * 应答行({@link SandboxGitOriginAnswer})每个状态一个臂,臂里 `reason` 的值域 = 表里该状态的行 —— 状态与原因的配对由表定,臂不手写。
15
15
  * 每一行的**条件**(什么事实使它命中)是 web-admin 的判定逻辑,写在 `docs/CONSUMER-INTEGRATION.md` 里,不进运行期表。
16
- * · {@link SANDBOX_GIT_REFUSALS} —— **整次拒答词**(十个)→ HTTP 状态集与 `permanence`;拒体里的 `permanence` 是错误词的函数,必须等于这一行的。
16
+ * · {@link CREDENTIAL_PLANE_REFUSALS} —— 凭据平面共享拒答表(九个词;同一平面的各只口从它派生,每个词的状态集与 `permanence` 只在这里写一次)。
17
+ * · {@link SANDBOX_GIT_REFUSALS} —— 整次拒答词(十一个)→ HTTP 状态集与 `permanence`,由凭据平面共享表 {@link CREDENTIAL_PLANE_REFUSALS}(九个)与本口自有的两个词按声明的次序派生(上一版的十个词原序、新词只在尾部);拒体里的 `permanence` 是错误词的函数,必须等于这一行的。
17
18
  * · {@link SANDBOX_GIT_PERMANENCE} —— `terminal`(不按定时重试)/ `transient`(退避重试)两词,语义在本表定义。
18
19
  *
19
20
  * ## 解析一律剥未知键
@@ -121,22 +122,46 @@ export const SandboxGitCredentialAnswer = z.object({
121
122
  /** `permanence` 两词:`terminal` = 不按定时重试;`transient` = 退避重试。 */
122
123
  export const SANDBOX_GIT_PERMANENCE = deepFreeze(["terminal", "transient"]);
123
124
  /**
124
- * 整次拒答词 → 它的 HTTP 状态集(中心答这个词时用其一)与 `permanence`。**一个错误词的 permanence 是固定的**,拒体里再带一份只为让收方不必查表 ——
125
- * 两处不一致就是畸形应答({@link SandboxGitCredentialRefusal} 拒)。收方怎么处置某个词(例如哪些 terminal 可由用户动作恢复)是收方的状态机,不在这里。
125
+ * 凭据平面共享拒答表(九个词):同一凭据平面的各只口都从它派生(`sandbox_git` 凭据取值口如此,同一平面的后续取值口同样如此),
126
+ * 每个词的 HTTP 状态集与 `permanence` 只在这里写一次。
127
+ * `plane_misconfigured` = 凭据平面在答方配置错 —— `terminal`,按定时重试不会成功,必须由运维修正配置。
126
128
  */
127
- export const SANDBOX_GIT_REFUSALS = deepFreeze({
129
+ export const CREDENTIAL_PLANE_REFUSALS = deepFreeze({
128
130
  caller_not_admitted: { statuses: [401, 403], permanence: "terminal" },
129
- scope_mismatch: { statuses: [403], permanence: "terminal" },
130
131
  incarnation_mismatch: { statuses: [403], permanence: "terminal" },
131
132
  request_invalid: { statuses: [400], permanence: "terminal" },
132
133
  principal_not_live: { statuses: [403], permanence: "terminal" },
133
134
  delegation_required: { statuses: [403], permanence: "terminal" },
134
135
  vault_disabled: { statuses: [503], permanence: "terminal" },
135
136
  vault_frozen: { statuses: [503], permanence: "terminal" },
136
- handle_invalid: { statuses: [401], permanence: "transient" },
137
137
  vault_unavailable: { statuses: [503], permanence: "transient" },
138
+ plane_misconfigured: { statuses: [503], permanence: "terminal" },
139
+ });
140
+ /** 凭据平面共享拒答词表(运行期;表的键,按表序)。 */
141
+ export const CREDENTIAL_PLANE_REFUSAL_ERRORS = deepFreeze(Object.keys(CREDENTIAL_PLANE_REFUSALS));
142
+ const SANDBOX_GIT_OWN_REFUSALS = deepFreeze({
143
+ scope_mismatch: { statuses: [403], permanence: "terminal" },
144
+ handle_invalid: { statuses: [401], permanence: "transient" },
138
145
  });
139
- /** 整次拒答词表(运行期;表的键,按表序)。 */
146
+ /** 同一个词写了两遍 ⇒ 模块加载即抛(次序表是公开事实,重复的词会让派生表静默少一行)。原样交回入参(元组类型不丢)。 */
147
+ function wordsListedOnce(words) {
148
+ if (new Set(words).size !== words.length)
149
+ throw new Error("SANDBOX_GIT_REFUSAL_ORDER lists a word twice");
150
+ return words;
151
+ }
152
+ /** 上一版的十个词保持原序,新词只追加在尾部 —— 调整既有词的次序是破坏性变更。 */
153
+ const SANDBOX_GIT_REFUSAL_ORDER = wordsListedOnce([
154
+ "caller_not_admitted", "scope_mismatch", "incarnation_mismatch", "request_invalid", "principal_not_live",
155
+ "delegation_required", "vault_disabled", "vault_frozen", "handle_invalid", "vault_unavailable", "plane_misconfigured",
156
+ ]);
157
+ const SANDBOX_GIT_REFUSAL_ROWS = { ...CREDENTIAL_PLANE_REFUSALS, ...SANDBOX_GIT_OWN_REFUSALS };
158
+ /**
159
+ * 整次拒答词 → 它的 HTTP 状态集(中心答这个词时用其一)与 `permanence`。**一个错误词的 permanence 是固定的**,拒体里再带一份只为让收方不必查表 ——
160
+ * 两处不一致就是畸形应答({@link SandboxGitCredentialRefusal} 拒)。收方怎么处置某个词(例如哪些 terminal 可由用户动作恢复)是收方的状态机,不在这里。
161
+ * 表由 {@link CREDENTIAL_PLANE_REFUSALS} 与本口自有两词按声明的次序派生(复用同一行对象,不抄行)。
162
+ */
163
+ export const SANDBOX_GIT_REFUSALS = deepFreeze(Object.fromEntries(SANDBOX_GIT_REFUSAL_ORDER.map((w) => [w, SANDBOX_GIT_REFUSAL_ROWS[w]])));
164
+ /** 整次拒答词表(运行期;表的键,按声明的次序)。 */
140
165
  export const SANDBOX_GIT_REFUSAL_ERRORS = deepFreeze(Object.keys(SANDBOX_GIT_REFUSALS));
141
166
  /** 整次拒答的体:`{ error, permanence, message }`。`message` 是中心的诊断句(收方不据它判,可为空串)。 */
142
167
  export const SandboxGitCredentialRefusal = z