@sema-agent/settings-schema 33.1.0 → 34.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 +414 -0
- package/README.md +118 -14
- package/conformance/VERSION +1 -1
- package/dist/atomic-write.d.ts +59 -0
- package/dist/atomic-write.js +303 -1
- package/dist/cli.d.ts +5 -2
- package/dist/cli.js +15 -3
- package/dist/config-dir-migration.d.ts +2 -1
- package/dist/config-dir-migration.js +34 -20
- package/dist/config-fns.d.ts +60 -14
- package/dist/config-fns.js +48 -13
- package/dist/conformance/index.d.ts +1 -0
- package/dist/conformance/index.js +2 -0
- package/dist/conformance/warnings.d.ts +1 -1
- package/dist/conformance/warnings.js +3 -3
- package/dist/conformance/web-admin-credential-lock.d.ts +17 -0
- package/dist/conformance/web-admin-credential-lock.js +346 -0
- package/dist/cross-session.d.ts +2 -2
- package/dist/fleet.d.ts +5 -5
- package/dist/hooks-config.d.ts +12 -4
- package/dist/hooks-config.js +28 -11
- package/dist/index.js +2 -2
- package/dist/local-load.d.ts +66 -1
- package/dist/local-load.js +123 -39
- package/dist/mcp-request-entry.d.ts +24 -5
- package/dist/mcp-request-entry.js +57 -17
- package/dist/node.d.ts +1 -0
- package/dist/node.js +2 -0
- package/dist/read-sentences.d.ts +14 -3
- package/dist/read-sentences.js +32 -11
- package/dist/safety-merge-spec.d.ts +5 -5
- package/dist/safety-merge-spec.js +5 -3
- package/dist/settings-units.d.ts +35 -1
- package/dist/settings-units.js +51 -16
- package/dist/types.d.ts +9 -9
- package/dist/types.js +27 -8
- package/dist/ui-language.d.ts +3 -1
- package/dist/ui-language.js +3 -1
- package/dist/web-admin-credential.d.ts +14 -1
- package/dist/web-admin-credential.js +15 -1
- package/docs/API-SURFACE.md +31 -4
- package/docs/CONFORMANCE.md +19 -2
- package/docs/CONSUMER-INTEGRATION.md +114 -10
- package/llms-full.txt +39 -10
- package/llms.txt +15 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,6 +52,23 @@ 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
|
+
## 升级指引: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、拒句一批改字)
|
|
56
|
+
|
|
57
|
+
没有校验收紧、没有已存数据要迁移 —— 会让按 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。
|
|
58
|
+
1. **钩子命令行规划口的入参**(BREAKING,编译期):`planHookCommandSpawn` 第一参的 `entry.plugin` 由 `{ options? }` 变 `{ name: string; options? }`(`plugin` 本身仍可缺)。手搭入参条目(夹具、适配器)的一方给 `plugin` 补 `name: "<插件名>"`;把分类器装上的 `CommandHookEntry` 原样交进来的一方零改动(它的 `plugin` 本来就带 `name`)。绕类型的 JS 调用方:`name` 只由入参型要求、运行期不校验 —— 缺失时 `planHookCommandSpawn` 照旧答(拒因里 `pluginName` 是 `undefined`),把这样的拒因交给 `hookCommandSpawnRefusalSentence` 时句子函数抛 `TypeError`。
|
|
59
|
+
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`;跨进程把拒因序列化后传给另一侧的消费方,两侧要同一版升。
|
|
60
|
+
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` 不是诊断键,仍在投影里。
|
|
61
|
+
4. **读腿的行多两个可缺键**(加性):`salvageEntries().dropped[]` 的 `DroppedEntry`、告警 `entry-dropped`、触发条目就是这样一行的 `domain-defaulted`,在词为 `entry-unknown-key` 时可带 `unknownKeys`(条目体内被剥的键名里过 `isDisclosableIdentity` 的那些,文档序、同名一次、至多 64 个)与 `truncatedFrom`(名单不全时带,= 被剥的不同键名总数;`unknownKeys` 在场而 `truncatedFrom` 缺席 ⇒ 名单就是全部)。渲「是哪几只键」的一方读 `unknownKeys`,`truncatedFrom` 在场时渲「还有没列出的」;对这些行 / 告警做整对象深相等的钉与夹具改成按键读、或补这两个键。两键都不进符合性投影。
|
|
62
|
+
5. **单元表**(加性 + 提货成本):`SETTINGS_UNITS` 尾插第十一个单元 `semaUiLanguage`(读法 `uiLanguage`,只收 `en` / `zh` 原字,只从用户设置读写);每一行单元多必填的 `reader`(闭集 `SETTINGS_UNIT_READERS` = `shell` / `engine`:`shell` = 只改宿主自己的界面、到不了引擎,`engine` = 其余一切的保守答)与 `sources`(这一单元从哪些设置源读;既有十行 = `SETTINGS_SOURCES`);`SettingsUnitName` 尾插一员。既有十个单元对任何输入的读数、比较器与寻址逐字不变;按单元名 / 读者词穷举的消费方、拿行的字面型注解手写对象、对行做深相等的一方提货时红一次 —— 给新单元补一行、读者分支补 `shell` 一臂。
|
|
63
|
+
6. **`SAFETY_MERGE_SPEC.ui.seam`**(展示字串):不再断言「never touches the engine」,改指向单元的 `reader`;规则字段逐字不变。逐字比对这只字串的一方红一次(由契约包生成的层准入表副本重出即可)。
|
|
64
|
+
7. **命令行 `--help` / `-h`**:退出 0、用法在 stdout、stderr 空(此前退出 2、stdout 空、用法在 stderr);无参与别的用法错照旧(退出 2)。把 `--help` 的退出码 2 当「拒」的脚本红一次。
|
|
65
|
+
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`。
|
|
66
|
+
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`。
|
|
67
|
+
10. **本地 `.env` 两步读法**(加性,`./node`):`readEnvFileLines(root)` 读行(不解 `file:`、不并 `process.env`;非赋值行按行号与闭集词报,不带行内容)· `resolveEnvFileAssignments(reading, names, { trust?, failFast? })` 只解名单里的名,每个 `file:` 目标先问调用方交入的信任座(座收绝对路径,答字符串 = 拒、抛 = 拒,拒了零字节读出)· `envFilePath(root)`;`loadEnvFile(root)` 的签名与行为一字不动(它就是这两步的组合)。要只读自己那几只名、或要在读目标之前先过自己的文件信任判官的读者调两步;`loadEnvFile` 的既有调用方零动作 —— 相对配置根下无座的读,原生读错误的 `path` / `message` 与上一版逐字节同(只有给了座,座与随后的读才共用同一条绝对路径;座按路径判,判与读之间路径背后的链接被换掉它看不见,那是按路径判的既有读法)。名叫 `__proto__` 的键:两步的 `values` 里是自有数据属性,`loadEnvFile` 仍与上一版同答(合并进普通对象时该键被丢)—— 要读它的调两步。
|
|
68
|
+
11. **web-admin 凭证文件的单写者锁**(加性):包根 `WEB_ADMIN_CREDENTIAL_FILE_LOCK`(`staleMs` = 10 s,协议常量)/ `webAdminCredentialLockName`,`./node` `tryWebAdminCredentialFileLock(credentialPath, critical)`,`./conformance` `runWebAdminCredentialLockConformance`。凭证信封与线上面一字不动;写那只文件的每一方(引擎续签写回、壳的登录 / 刷新 / 登出)改走同一把锁、在锁内比较世代再写,持锁段只许同步本机 IO,别按同语义自写 —— 自己实现的必须过那套一致性测试。**已知限制**:凭证路径是软链时锁与写落在链接指向的真目标上,但登出(删掉真目标)之后链接悬空,再登录(再取锁)答 `unreadable`(失败关闭:不建文件、不写,与本包原子写器对悬空链接的拒同一条律;出路 = 删掉悬空链接,或先重建目标;凭证路径就是真文件的不受影响);锁名上不是普通文件的东西(命名管道 / 目录 / 任何软链)答 `unreadable`,同码同句、不等待、不碰它(对取锁那一刻看到的占位物;取锁过程中被换掉的竞态窗见锁的协议段的限制)。这是协议要求,不是类型要求,提货不会让任何人编译红。
|
|
69
|
+
|
|
70
|
+
本版没有新登记的一次性迁移,也没有到期删码的(最早一只 `SS-M11` 的窗到 2026-11-26)。
|
|
71
|
+
|
|
55
72
|
## 升级指引:33.0.x → 33.1.0(minor,加性:排空口的「凭据点名形」请求体 `CredentialDrainRequest` / 读器 `readCredentialDrainRequest` / 两词闭集 `DRAIN_TURNS` · 条件不满足的拒体 `DrainConditionUnmet` / `readDrainConditionUnmet` / 码常量 `DRAIN_CONDITION_UNMET_CODE` · 读「请求体是哪一形」的聚合读器 `readDrainRequestReading` / 判别联合 `DrainRequestReading` / 形词闭集 `DRAIN_REQUEST_FORMS`)
|
|
56
73
|
|
|
57
74
|
只加导出(包根与 `./fleet` 各十名),零校验变化、零读数变化 —— 代码零动作可升(逐字比对 `migrate` 拒句的除外,见第 6 条);部署上引擎的版本见第 7 条。逐件的读法表、三问、各消费方表与黑盒判据见 CHANGELOG 33.1.0 与 `docs/CONSUMER-INTEGRATION.md` §52。
|
|
@@ -69,7 +86,7 @@ only (`node:crypto`, `node:fs`). The machine gate is `test/runtime-dependencies-
|
|
|
69
86
|
|
|
70
87
|
只有一件会让按 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
88
|
|
|
72
|
-
**升级前自查:一种答法的变化,不是读数的变化。** 本版没有一件让已落盘的内容由读得进变读不进 —— 读腿对每一份存量的读数逐字不变;变的是 `migrate` 不再替「文档面整文档判不过」的文档说干净。查法:在一个不碰线上依赖的临时目录里装本版,对存量 `config.d` 的副本跑 `npx @sema-agent/settings-schema migrate <目录> --check` —— 退出 0 = 覆盖面内的文档都过了文档面的整文档判、没有要迁的(这不等于读腿读得干净,见下面第 2
|
|
89
|
+
**升级前自查:一种答法的变化,不是读数的变化。** 本版没有一件让已落盘的内容由读得进变读不进 —— 读腿对每一份存量的读数逐字不变;变的是 `migrate` 不再替「文档面整文档判不过」的文档说干净。查法:在一个不碰线上依赖的临时目录里装本版,对存量 `config.d` 的副本跑 `npx @sema-agent/settings-schema migrate <目录> --check` —— 退出 0 = 覆盖面内的文档都过了文档面的整文档判、没有要迁的(这不等于读腿读得干净,见下面第 2 条的已知的边:**只在逐条丢弃域里**成立 —— 读腿只在那里拒条目体内被剥的键,不逐条丢的域两边都剥键受理、答得一样 —— 那里条目只因带读侧不认识的键,读腿丢那一条,集合里每一条都这样时读腿整域退缺省或整域拒,命令行仍答 0);3 = 有要迁的;1 = 报告 `refused[]` 点名的文件与坐标要手改;2 = 用法错,或环境错 / 坏文件(读不了目录或文件、空文件、坏 JSON、不是 JSON 对象)、或目录里有条目却没有一份域文档。线上还是上一版时就能知道升级后哪里被点名。
|
|
73
90
|
|
|
74
91
|
1. **律**:命令行问的是「这个目录现在干不干净」—— 在场的**每一份**覆盖面内文档过文档面那几只判官(域 `parseDomain`、`remote-exec.json` 的 `parseRemoteExecDocument`、退役域的墓碑判),不过 ⇒ `refused`、退出 1、一字不写;`migrate` 与 `migrate --check` 同判。此前迁移不碰的文档永不被判:陈旧形(`models.json` 里已退役的 `default` 键、带 `#fragment` 的模型 URL、带事实的 `runtime.json`)与别的读侧读不进的文档(例:重名的目录模型)都报 `noop` / 退出 0。
|
|
75
92
|
2. **读数变化**:同一个目录,此前 `noop` / 退出 0,现在 `refused` / 退出 1;同目录里还有可迁的文档时,此前可迁的那份被写回、现在整目录一字不写(`--check` 同判,不是 `pending`);迁移步拒收的坐标与读不进的陈旧文档并在一份 `refused[]` 里。`outcome` / `written` / `refused` 三字段的形与退出码表(0 / 1 / 2 / 3)不变;读得进的目录、只有可迁的文档、退役域的空文件 `{}` 照旧。**已知的边**:判官是文档面那一只(`parseDomain`),它与读腿(视图面)两个方向上答得不一样 ——
|
|
@@ -102,7 +119,7 @@ only (`node:crypto`, `node:fs`). The machine gate is `test/runtime-dependencies-
|
|
|
102
119
|
3. **读数变化**:同一份记录里别的毛病在去掉保留名之后才报(守卫一条就是这只座位的结论);逐条丢弃域里名叫保留名的 Record 条目整条 `entry-dropped`(`entry-key-invalid`);`isReportableRefusalName` 对 `constructor` / `prototype` 答 `false`。
|
|
103
120
|
4. **型面**:凭据引用集合那几格的 `z.input` 由 `unknown` 变成记录形;对记录字段 schema 做 `instanceof z.ZodRecord` 的内省先剥一层输入侧管道(`.out`);经过记录字段的 `z.encode` 抛;JS 调用方递来的非纯数据记录(访问器成员、不可枚举的自有键、另一个原型上的对象)拒。导出名零变化。
|
|
104
121
|
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:
|
|
122
|
+
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
123
|
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
124
|
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
125
|
9. **`SubagentStart` / `SubagentStop` 改判引擎属主**(§46):`ENGINE_OWNED_HOOK_EVENTS` 尾插两员(十 → 十二),`ENGINE_OWNED_HOOK_EVENT_SINCE` 两行 = `32.0.0`;配置校验不读属主表,设置文档读数不变。动作:按属主分流的消费方照旧只问 `engineOwnsHookEventAt(event, 对端契约版本)`;本地也会触发这两只钩子的终端,对报 32.0.0 及以上的服务端要让位(否则同一次子代起止两边都跑);对 `EngineOwnedHookEvent` 写穷举的补两行。
|
|
@@ -609,8 +626,8 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
|
|
|
609
626
|
`receipts` 逐条说「对哪个坐标做了什么」(`moved` / `rewritten` / `dropped-inert` / `refused` / `minted`;不带值)。
|
|
610
627
|
`refused` 的坐标原样留着,读侧照旧拒:要人改。再跑一次 = 零改动。
|
|
611
628
|
- **目录形**:`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[]`
|
|
629
|
+
`--check` 有改动退出 3;拒收时 stderr 一行说几处被拒、每处的文件 / 坐标 / 原因与出路 —— 与函数结果的 `why` 同一句,原因就是 `refused[]` 里那条 `reason` 开头的那一句;`--help` / `-h` 是求用法:用法打 stdout、退出 0,无参与别的用法错仍是 stderr、退出 2)。命令行问的是「这个目录现在干不干净」:在场的**每一份**文档过文档面的整文档判官(`parseDomain` 一类),判不过的文档 —— 迁移不再改写的陈旧形
|
|
630
|
+
(`models.json` 里已退役的 `default` 键、带 `#fragment` 的模型 URL、带事实的 `runtime.json`)与任何别的整文档判不过的文档 —— 也是 refused、退出 1、一字不写:`refused[]` 点名文档与坐标:迁移没碰的文档,每条拒还带读腿的后果与出路句(手改后重跑);迁移改过、改完仍判不过的那一份,条目本身没有出路(`reason` 只是判官那一句),出路在整份 `why`(stderr 里同一句:手改后重跑)。
|
|
614
631
|
文档面与读腿两个方向上答得不一样(升级指引 33.0.0 第 2 条的已知的边):逐条丢弃域里条目只因带读侧不认识的键,这里答干净而读腿丢那一条(零幸存者时整域退缺省 / 整域拒;不逐条丢的域两边都剥键受理);逐条丢弃域里一条坏条目,读腿只丢它而这里整目录拒。
|
|
615
632
|
参数是 `config.d` 目录**本身**(里面直接放 `<域>.json`):目录里有条目却没有一份域文档 —— 填成了它的上一层、只有
|
|
616
633
|
`remote-exec.json` 之类非域文件 —— 退出 2、stdout 空,stderr 点名这个目录(`<目录>/config.d` 在场就直接点它);目录真空(零条目,或只有以 `.` 开头的条目)是合法态
|
|
@@ -836,11 +853,21 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
|
|
|
836
853
|
A category's `tighten` answers only a `whole` unit's value; a declared member's comparator comes from its row's value class —
|
|
837
854
|
`MemberAdmission.list: true` marks a string-list member, `boolPole` a boolean one, exactly one per row — via
|
|
838
855
|
`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` (
|
|
840
|
-
`additionalDirectories` · `sandbox` · `disableBypassPermissionsMode` · `disableAutoMode` · `hooks` · `env` · `model` · `outputStyle
|
|
841
|
-
each with its document `path`, category, addressing and
|
|
842
|
-
`readSettingsUnit(unit, raw, member?)` (its raw-value reading: `"manual"` ⇒ `"default"`, `"disable"` ⇒ `true`, `false`
|
|
843
|
-
`false`, `"bypassPermissions"` ⇒ `launch_only`,
|
|
856
|
+
The settings-document unit table is published here too: `SETTINGS_UNITS` (eleven units: `permissions` · `permissionMode` ·
|
|
857
|
+
`additionalDirectories` · `sandbox` · `disableBypassPermissionsMode` · `disableAutoMode` · `hooks` · `env` · `model` · `outputStyle` ·
|
|
858
|
+
`semaUiLanguage`, each with its document `path`, category, addressing, reading, `reader` and `sources`), `unitTighten(unit, member?)` (a unit's
|
|
859
|
+
comparator) and `readSettingsUnit(unit, raw, member?)` (its raw-value reading: `"manual"` ⇒ `"default"`, `"disable"` ⇒ `true`, `false`
|
|
860
|
+
stays `false`, `"bypassPermissions"` ⇒ `launch_only`, `semaUiLanguage` takes exactly `en` / `zh` — `zh-CN`, `EN` and the like are not
|
|
861
|
+
folded —, everything outside the unit's reading — and `undefined` / `null` — ⇒ `unreadable`). A writer judges the value it is about to
|
|
862
|
+
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
|
|
863
|
+
`SETTINGS_UNIT_READERS` (`shell` = only the host's own interface, never the engine, wherever it runs — `semaUiLanguage`; `engine` =
|
|
864
|
+
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
|
|
865
|
+
the engine's request — the other ten, `outputStyle` included; whether one write reaches one engine depends on how that host feeds
|
|
866
|
+
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'
|
|
867
|
+
`reader`); `hooks` is `engine` as a whole, the per-event owner is `HOOK_EVENT_OWNER`. Which settings sources carry a unit is its
|
|
868
|
+
row's `sources`: a value in any other source is not read, and inside them `layerAdmission` answers — the ten carry every source
|
|
869
|
+
(`SETTINGS_SOURCES`), `semaUiLanguage` only `UI_LANGUAGE_SETTING.source` (user settings, which `layerAdmission` admits for `ui`).
|
|
870
|
+
The UI-language row takes its key, category and source from `UI_LANGUAGE_SETTING`; its comparator is the `ui` category's `none`.
|
|
844
871
|
- **Settings sources + layer admission** (`settings-sources.ts`, main barrel): `SETTINGS_SOURCES` (declaration order =
|
|
845
872
|
merge order: user < project < local < flag < policy), `SETTINGS_SOURCE_CONTRACT` (each source's trust tier and whether a
|
|
846
873
|
repository controls it — `projectSettings` / `localSettings` are repository-controllable and share the `project` tier, as in
|
|
@@ -887,7 +914,8 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
|
|
|
887
914
|
`parseWebAdminCredentialFile(text)` is the ONE discrimination law — trimmed text starting with `{` is read ONLY
|
|
888
915
|
as an envelope (a failure is `unreadable`, never a fallback to a bare line); anything else is a bare line,
|
|
889
916
|
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
|
|
917
|
+
content. Pure: reading, atomically writing and renewing the file are the consumers' job — every writer of the file takes the
|
|
918
|
+
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
919
|
(`url` / `token` / `tokenFile` / `worker` / `liveUrl` / `webUrl` / `dryRun` / `adminToken` / `assertionToken` /
|
|
892
920
|
`assertionTokenFile`, values `SEMA_WEB_ADMIN_*`; one spelling for web-admin rendering worker env, the shell writing its
|
|
893
921
|
local engine's env, and the server reading it) and `judgeWebAdminCredentialDeclaration(env, credential)` — `credential` ∈
|
|
@@ -895,6 +923,50 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
|
|
|
895
923
|
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
924
|
names the two keys, never a value), the file path comes back verbatim (resolving a relative one against a cwd
|
|
897
925
|
is the reader's job).
|
|
926
|
+
- **Single-writer lock on the web-admin credential file** (protocol constants in the main barrel, the lock in `./node`, its conformance test in
|
|
927
|
+
`./conformance`): the engine renewing the envelope and the shell logging in / refreshing / logging out write ONE file. The rule is one sentence:
|
|
928
|
+
**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
|
|
929
|
+
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
|
|
930
|
+
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
|
|
931
|
+
only** — no network call, no waiting, no second lock: the protocol reads a lock's age as evidence that its holder died.
|
|
932
|
+
`tryWebAdminCredentialFileLock(credentialPath, critical)` (`./node`) is the one implementation: the path is resolved to its real target (a symbolic
|
|
933
|
+
link is written through, a dangling one — the link there, its target gone — is refused as `unreadable`: nothing created, nothing written, the same rule
|
|
934
|
+
as the package's atomic writer; see the first limit below); the lock is `.<real file name>.lock`
|
|
935
|
+
(`webAdminCredentialLockName`) beside it, created with `open(…, "wx")`, identity = that descriptor's `(dev, ino)`, **and the descriptor stays open
|
|
936
|
+
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
|
|
937
|
+
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
|
|
938
|
+
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
|
|
939
|
+
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
|
|
940
|
+
stale one; it is tried once and never
|
|
941
|
+
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
|
|
942
|
+
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
|
|
943
|
+
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
|
|
944
|
+
the future counts as fresh; the lock being judged is opened read-only and pinned the same way) is reclaimed by renaming it aside
|
|
945
|
+
(`.lock-aside.<process id>.<random>` — bounded length, not appended to the lock name), checking the moved file is the one judged stale, and
|
|
946
|
+
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
|
|
947
|
+
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
|
|
948
|
+
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),
|
|
949
|
+
`stillMine()`, and the two last writes `replaceWith(tempFile)` / `remove()`, each of which re-checks the lock's identity first and answers `false`
|
|
950
|
+
(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"),
|
|
951
|
+
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 —
|
|
952
|
+
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
|
|
953
|
+
the target could not be created / read; nothing ran, nothing was written — never an unlocked fallback). The callback must be synchronous: an
|
|
954
|
+
`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.
|
|
955
|
+
**Another implementation of this protocol must pass `runWebAdminCredentialLockConformance(implementation)`** (`./conformance`; same signature as
|
|
956
|
+
`tryWebAdminCredentialFileLock`) — one protocol, one set of checks; two implementations each declaring themselves compliant does not count.
|
|
957
|
+
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
|
|
958
|
+
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
|
|
959
|
+
target; a credential path that is the real file is not affected); resolving "through" a dangling link needs a second reading of symbolic links that
|
|
960
|
+
agrees with the kernel on relative link text, trailing slashes, the hop bound and a change between the check and the open — it is not in this version. The
|
|
961
|
+
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`
|
|
962
|
+
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
|
|
963
|
+
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
|
|
964
|
+
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
|
|
965
|
+
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
|
|
966
|
+
attempt is bounded, eventual success is not); a crashed lock plus a clock moved backwards stays "fresh" until real time catches up (stop every
|
|
967
|
+
writer, then delete the lock file by hand); the credential file must be on a local disk (network filesystems: synchronous calls have no timeout
|
|
968
|
+
and the server stamps modification times); Windows semantics of `wx` / `rename` / file ids follow the documented platform behaviour and are not
|
|
969
|
+
measured here.
|
|
898
970
|
- **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
971
|
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
972
|
package carries the shapes and word tables, no IO. (1) `isSandboxGitOrigin` — a string equal to its own WHATWG origin with scheme http / https (the
|
|
@@ -1050,7 +1122,17 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
|
|
|
1050
1122
|
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
1123
|
laws (dropped and named, zero survivors ⇒ the whole-domain tier, never loaded stripped); unknown keys outside every entry, the seven non-salvage
|
|
1052
1124
|
domains and the document face are unchanged. `salvageEntries(schema, raw, domain)` takes the domain as a required third argument (whose
|
|
1053
|
-
extension namespaces apply).
|
|
1125
|
+
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
|
|
1126
|
+
`domain-defaulted` warning whose triggering entry is such a row): `unknownKeys: string[]` — the stripped key NAMES that may leave the process
|
|
1127
|
+
(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,
|
|
1128
|
+
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).
|
|
1129
|
+
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
|
|
1130
|
+
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.
|
|
1131
|
+
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:
|
|
1132
|
+
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
|
|
1133
|
+
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
|
|
1134
|
+
(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-*`
|
|
1135
|
+
is not a diagnostic key and stays in the projection). **3.0.0** re-casts every coordinate these warnings
|
|
1054
1136
|
carry (`entry-dropped.path`, `unknown-keys-*.keys`) from a dot-joined STRING to a structured
|
|
1055
1137
|
`ConfigPath = readonly (string | number)[]` — a string segment is an object key (verbatim, `.` included),
|
|
1056
1138
|
a number segment is an array index — because the string form was a LOSSY encoding: a key literally named
|
|
@@ -1077,7 +1159,9 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
|
|
|
1077
1159
|
plus the one fold of an option key into its hook environment variable name, `pluginOptionEnvName(key)`;
|
|
1078
1160
|
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
1161
|
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
|
|
1162
|
+
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` —
|
|
1163
|
+
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`) —
|
|
1164
|
+
and their sentences open alike, naming both: `hook command names option "<key>" of plugin "<plugin>", which is not set`;
|
|
1081
1165
|
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
1166
|
(`HOOKS_DROPPED_PIECE_CODES`), whether the whole document is rejected because a guard (`PreToolUse` / `PermissionRequest`) may be
|
|
1083
1167
|
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 +1191,29 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
|
|
|
1107
1191
|
`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
1192
|
(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
1193
|
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.
|
|
1194
|
+
- **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
|
|
1195
|
+
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
|
|
1196
|
+
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**;
|
|
1197
|
+
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.
|
|
1198
|
+
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
|
|
1199
|
+
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:
|
|
1200
|
+
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
|
|
1201
|
+
`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
|
|
1202
|
+
before `credentials`; a `credentials` visible only through the prototype chain is not read (it is listed in `lost`); an own accessor is read once.
|
|
1203
|
+
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
|
|
1204
|
+
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.
|
|
1205
|
+
- **`.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);
|
|
1206
|
+
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
|
|
1207
|
+
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
|
|
1208
|
+
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
|
|
1209
|
+
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).
|
|
1210
|
+
`envFilePath(root)` is the one builder of the file's path.
|
|
1110
1211
|
- **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
1212
|
as regex character-class source text), `stripControlAndBidi(text)` and `hasControlOrBidi(text)` — the one set a caller- or repository-written string loses
|
|
1112
1213
|
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
1214
|
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`.
|
|
1215
|
+
- **UI language** (`ui-language.ts`, 13.0.0): `semaUiLanguage` (`en` / `zh`, category `ui`, user settings) + `readUiLanguage`. Its write-side
|
|
1216
|
+
unit is the `semaUiLanguage` row of `SETTINGS_UNITS` (reading `uiLanguage`, which delegates to `readUiLanguage`; `reader: "shell"`).
|
|
1115
1217
|
- **Cross-session settings** (`cross-session.ts`): the two `settings.json` keys `crossSessionInbound`
|
|
1116
1218
|
(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
1219
|
answers `ok:false` on a bad value instead of silently folding to the default.
|
|
@@ -1240,6 +1342,8 @@ if (!report.ok) throw new Error(report.violations.join("\n"));
|
|
|
1240
1342
|
- **两种模式**:`release`(版本三方对齐 + 每条腿有表态 + 生产入口核验 + 禁 `only`/归一器 + 至少实现一条腿 + **实现的腿
|
|
1241
1343
|
必须跑**)与 `historical`(对旧版包跑,只记行为 diff)。
|
|
1242
1344
|
- **四律**:对抗律 / 变异律 / 覆盖律 / 来源律 —— 缺一不算「门」。
|
|
1345
|
+
- **凭证文件锁的协议一致性测试**(同一子路径,另一份 kit):`runWebAdminCredentialLockConformance(impl)` —— `impl` 与 `./node` 的 `tryWebAdminCredentialFileLock` 同签名;
|
|
1346
|
+
kit 在私有临时根里逐格跑黑盒场景,答 `{ ok, cases[{ id, ok, why? }] }`。本包原语过它;别的实现(壳若自己实现这把锁)也必须过它 —— 一份协议、一份判据。
|
|
1243
1347
|
- **已知分歧账本** `knownDivergences`:消费方对金样的**合法**差异登记成机器可核的一行 —— 两类:会还的差异 = 债(`kind: "debt"`,票号 + 窗 + 翻转条件)、不打算还的姿态 = 姿态(`kind: "posture"`,票号指向消费方的裁定;只盖消费方比金样给得少的一侧:拒金样受理的 / 少交金样有的值),
|
|
1244
1348
|
命中记 `diff-ledgered` 不阻塞;**告警差与元数据差永不可入账**,而**从未命中的一条登记本身就是
|
|
1245
1349
|
违例**(棘轮只降不升,两类同律)。契约仓自证不许挂账本。
|
|
@@ -1262,7 +1366,7 @@ local `.env`). This package never carries a credential.
|
|
|
1262
1366
|
remote-exec.json # NOT a domain (the exec backend; read by loadRemoteExec)
|
|
1263
1367
|
config.env-models.json # the env-model-table decision {"envModels":"replaced"|"kept"} (readEnvModelsDecision / writeEnvModelsDecision)
|
|
1264
1368
|
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
|
|
1369
|
+
.env # secret VALUES only (KEY=value); gitignored; never read into any *.json (read by loadEnvFile = readEnvFileLines + resolveEnvFileAssignments)
|
|
1266
1370
|
```
|
|
1267
1371
|
|
|
1268
1372
|
**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
|
package/conformance/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
34.0.0
|
package/dist/atomic-write.d.ts
CHANGED
|
@@ -56,3 +56,62 @@ export declare function createFileExclusive(target: string, text: string, kind:
|
|
|
56
56
|
* (`链接/..` 由内核按链接目标的物理父目录解,相对路径对进程 cwd 解)。向上找已在的祖先时逐级取 `path.dirname`,每一级的「在不在」都问内核。
|
|
57
57
|
*/
|
|
58
58
|
export declare function ensureOwnerOnlyDirectory(dir: string): "created" | "present";
|
|
59
|
+
/** 文件系统身份:`(dev, ino)`,按 bigint 读(Windows 的文件号可以超过 2^53,number 会丢精度)。 */
|
|
60
|
+
interface FileIdentity {
|
|
61
|
+
readonly dev: bigint;
|
|
62
|
+
readonly ino: bigint;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 收残留与放锁的**唯一一套动作**:把 `lock` 路径上那只**改名挪开**(同目录的 `.lock-aside.<进程号>.<随机>` —— 名字长度有界,不接在锁名后面:锁名已接近文件名上限时
|
|
66
|
+
* 挪开件名也不会超)→ 核挪走的那只是不是 `expected`(调用方此刻钉着 `expected` 那个文件对象,比对才成立)→ **挪开件一律删掉**。
|
|
67
|
+
* 答 `removed`(挪走的正是 `expected`)/ `displaced`(挪走的是别人的锁 —— 它的持有者从此读到失锁、写不成)/ `absent`(锁路径上本来就没有东西)。
|
|
68
|
+
* 不挪回:挪回只能用 `rename`,它会盖掉第三者在锁名空出来那一刻合法建的锁,造出两个都以为自己持锁的写者;删掉挪错的那只只让它的持有者这一次写不成(失败关闭)。
|
|
69
|
+
* 挪开件删不掉(目录这一刻变得不可写)⇒ 锁路径已经空出来,挪开件留作残件,不改判。
|
|
70
|
+
* 包内导出(不出任何子路径):协议一致性测试扮「另一个写者」接手时也走这一套动作,不另写一份(也不按路径删锁)。
|
|
71
|
+
*/
|
|
72
|
+
export declare function removeLockIf(lock: string, expected: FileIdentity): "removed" | "absent" | "displaced";
|
|
73
|
+
/**
|
|
74
|
+
* 持锁期间交给回调的把手 —— 只在回调里有效(回调返回之后再调任何一只方法都抛)。
|
|
75
|
+
* · `target` —— 解析后的**真目标**(凭证路径是软链时是它指向的文件)。新内容的临时文件建在它所在的目录里(`rename` 只在同一文件系统内原子)。
|
|
76
|
+
* · `current` —— 锁内读到的真目标的 UTF-8 文本;`undefined` = 路径上没有条目(登出删了)。「比较再写」的比较拿它做。
|
|
77
|
+
* · `stillMine()` —— 锁路径上那只锁仍是本次取到的那只(身份比对;持有者的 fd 一直钉着自己的锁,所以比对不会被复用的 inode 号骗)。**失锁是粘的**:答过一次 `false`
|
|
78
|
+
* (含读不出锁路径的那一次)之后,这只把手的三只方法都只答 `false`、再不落写。
|
|
79
|
+
* · `replaceWith(tempFile)` —— 核身份,是自己的才把 `tempFile` 改名盖过真目标,答 `true`;失锁 ⇒ `false`,什么都不改(临时文件原样留给调用方丢)。改名失败抛文件系统失败句。
|
|
80
|
+
* · `remove()` —— 核身份,是自己的才删真目标(已不在也算删成),答 `true`;失锁 ⇒ `false`。删除失败抛文件系统失败句。
|
|
81
|
+
* **写没写成看这两只方法自己的答案**(`true` = 落了),不看结果的 `status`:`lost` 只说「所有权不是自始至终连续的」,它之前答过 `true` 的写是落了的。
|
|
82
|
+
*/
|
|
83
|
+
export interface WebAdminCredentialLockHeld {
|
|
84
|
+
readonly target: string;
|
|
85
|
+
readonly current: string | undefined;
|
|
86
|
+
stillMine(): boolean;
|
|
87
|
+
replaceWith(tempFile: string): boolean;
|
|
88
|
+
remove(): boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* {@link tryWebAdminCredentialFileLock} 的结果 —— 闭集四臂(判别键 `status`):
|
|
92
|
+
* · `acquired` —— 回调在锁里跑完,锁自始至终是自己的;`value` = 回调的返回值。
|
|
93
|
+
* · `lost` —— 回调跑了,但期间或放锁时发现锁已不是自己的(被当残留收走 / 被换掉),或读不出它是不是自己的;`value` 照带。失锁之前经把手答过 `true` 的写落了,
|
|
94
|
+
* 之后的都答 `false`、没落 —— 写没写成由回调自己记下那两只方法的答案(放进 `value`),不要从 `lost` 推「没写成」。
|
|
95
|
+
* · `busy` —— 别人持着新鲜的锁(或 mtime 在未来),回调没跑。`heldForMs` = 那只锁的年龄(读到了且不在未来才有)。
|
|
96
|
+
* · `unreadable` —— 锁建不出 / 看不了 / 收不了,或锁内读不了真目标;回调没跑,什么都没写。`error.message` 是包里的文件系统失败句,errno 在 `error.code`。
|
|
97
|
+
*/
|
|
98
|
+
export type WebAdminCredentialLockOutcome<T> = {
|
|
99
|
+
readonly status: "acquired";
|
|
100
|
+
readonly value: T;
|
|
101
|
+
} | {
|
|
102
|
+
readonly status: "lost";
|
|
103
|
+
readonly value: T;
|
|
104
|
+
} | {
|
|
105
|
+
readonly status: "busy";
|
|
106
|
+
readonly heldForMs?: number;
|
|
107
|
+
} | {
|
|
108
|
+
readonly status: "unreadable";
|
|
109
|
+
readonly error: Error;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* 在 web-admin 凭证文件的单写者锁里跑一次「读 → 比较 → 写」(规则与锁的形见文件头同名一节)。只试一次,从不等待:忙 ⇒ `busy`,调用方按自己的退避再来。
|
|
113
|
+
* `critical` 只许同步:返回类型对 `PromiseLike` 求值为 `never`,直接传 async 回调 = 编译错(静态误用防线,拦不住拓宽成 `unknown` 的回调、或回调里起一个不等待的异步任务);
|
|
114
|
+
* 运行期回调交回一个 thenable ⇒ 放锁后抛 `TypeError`(持锁段已经结束,它之后做的事不在锁里)。回调抛 ⇒ 放锁后原样重抛。
|
|
115
|
+
*/
|
|
116
|
+
export declare function tryWebAdminCredentialFileLock<T>(credentialPath: string, critical: (held: WebAdminCredentialLockHeld) => T extends PromiseLike<unknown> ? never : T): WebAdminCredentialLockOutcome<T>;
|
|
117
|
+
export {};
|