@sema-agent/settings-schema 27.2.0 → 28.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 +423 -0
- package/README.md +7 -0
- package/conformance/VERSION +1 -1
- package/dist/api/auth-bridge.js +4 -3
- package/dist/api/auth.js +6 -5
- package/dist/api/credentials.js +9 -8
- package/dist/api/pull-token.js +2 -1
- package/dist/api/scopes.js +5 -4
- package/dist/center-refs.js +3 -2
- package/dist/config-dir-io.d.ts +1 -1
- package/dist/config-dir-io.js +3 -2
- package/dist/config-document-refusal.d.ts +1 -1
- package/dist/config-document-refusal.js +2 -1
- package/dist/config-fns.d.ts +4 -4
- package/dist/config-fns.js +17 -16
- package/dist/config-root-documents.js +4 -3
- package/dist/config-root-node.d.ts +1 -1
- package/dist/config-root-node.js +3 -2
- package/dist/conformance/derive.d.ts +3 -3
- package/dist/conformance/derive.js +6 -5
- package/dist/conformance/types.js +4 -3
- package/dist/cross-domain.js +6 -5
- package/dist/cross-session.js +3 -2
- package/dist/deep-freeze.d.ts +26 -0
- package/dist/deep-freeze.js +69 -0
- package/dist/default-model.js +2 -1
- package/dist/device-relay.d.ts +1 -1
- package/dist/device-relay.js +1 -1
- package/dist/env-model-table.js +2 -1
- package/dist/execution-lane-index.d.ts +1 -1
- package/dist/execution-lane-index.js +5 -4
- package/dist/execution-lanes.d.ts +2 -2
- package/dist/execution-lanes.js +18 -17
- package/dist/file-store.js +2 -1
- package/dist/fleet.js +14 -13
- package/dist/hooks-config.d.ts +12 -12
- package/dist/hooks-config.js +16 -15
- package/dist/hooks.d.ts +5 -5
- package/dist/hooks.js +17 -16
- package/dist/http-hook-allowlists.js +2 -1
- package/dist/index.js +1 -1
- package/dist/mcp-request-entry.js +2 -1
- package/dist/mcp-server-policy.js +3 -2
- package/dist/migration-receipt.d.ts +1 -1
- package/dist/migration-receipt.js +3 -2
- package/dist/one-time-migrations.js +3 -2
- package/dist/own-key-read.d.ts +3 -1
- package/dist/plain-json-object.d.ts +6 -3
- package/dist/plain-json-object.js +6 -3
- package/dist/portable-domains.js +4 -3
- package/dist/reserved-member-name.d.ts +1 -1
- package/dist/reserved-member-name.js +3 -2
- package/dist/resolve-roster.js +3 -2
- package/dist/retired-envs.js +3 -6
- package/dist/safety-merge-spec.d.ts +11 -4
- package/dist/safety-merge-spec.js +5 -4
- package/dist/secret-scan.js +1 -1
- package/dist/settings-sources.js +6 -5
- package/dist/settings-units.js +3 -2
- package/dist/types.d.ts +9 -9
- package/dist/types.js +27 -26
- package/dist/ui-language.js +4 -3
- package/dist/url-credential.js +4 -3
- package/dist/url-shape.d.ts +1 -1
- package/dist/url-shape.js +5 -4
- package/dist/web-admin-credential.js +2 -1
- package/dist/web-admin-env.d.ts +1 -1
- package/dist/web-admin-env.js +4 -3
- package/docs/CONSUMER-INTEGRATION.md +22 -2
- package/llms-full.txt +3 -2
- package/llms.txt +2 -1
- package/package.json +1 -1
|
@@ -19,8 +19,9 @@ import { captureDenseArray, inspect, isStringEntry, readKey } from "./own-key-re
|
|
|
19
19
|
import { isJsonArray, isPlainJsonArray, jsonShapeOf } from "./plain-json-object.js";
|
|
20
20
|
import { layerAdmission } from "./settings-sources.js";
|
|
21
21
|
import { urlAllowPatternMatches } from "./url-pattern.js";
|
|
22
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
22
23
|
/** 两键(闭集,声明序)。 */
|
|
23
|
-
export const HTTP_HOOK_ALLOWLIST_KEYS = ["allowedHttpHookUrls", "httpHookAllowedEnvVars"];
|
|
24
|
+
export const HTTP_HOOK_ALLOWLIST_KEYS = deepFreeze(["allowedHttpHookUrls", "httpHookAllowedEnvVars"]);
|
|
24
25
|
/**
|
|
25
26
|
* 整份 `settings.json` 里本片段负责的两键:在场则必须是字符串数组。刻意 `passthrough`(与 `CrossSessionSettings` 同姿势):本片段不是整份
|
|
26
27
|
* 设置的闭集门。它是**写侧**的形门;读侧坏形不拒整份,按 {@link readHttpHookAllowlistLayer} 读成空名单(fail-closed)。
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* web-admin, the worker service, and the TOC desktop/CLI.
|
|
4
4
|
*/
|
|
5
5
|
export * from "./types.js";
|
|
6
|
-
export * from "./execution-lanes.js"; // 7.0.0 M-R2: the ONE lane / store vocabulary (EXECUTION_LANE_WORDS / EXECUTION_LANES / STORE_BACKENDS / SESSION_BACKENDS / MEMORY_ENGINE_BACKENDS) + THE lane-coordinate blank judge isBlankCoordinate (empty or whitespace-only = absent; the write gate and every consumer ask this one function; whether a key is set, and whether an optional key may be empty, stays the caller's call; the same function object as on the `./execution-lanes` subpath) — a zero-import
|
|
6
|
+
export * from "./execution-lanes.js"; // 7.0.0 M-R2: the ONE lane / store vocabulary (EXECUTION_LANE_WORDS / EXECUTION_LANES / STORE_BACKENDS / SESSION_BACKENDS / MEMORY_ENGINE_BACKENDS) + THE lane-coordinate blank judge isBlankCoordinate (empty or whitespace-only = absent; the write gate and every consumer ask this one function; whether a key is set, and whether an optional key may be empty, stays the caller's call; the same function object as on the `./execution-lanes` subpath) — a leaf whose only import is the package-private zero-import freezer, pure/browser-safe
|
|
7
7
|
export * from "./config-document-refusal.js"; // 15.2.0: the typed refusal of one config.d document (CONFIG_DOCUMENT_REFUSAL_REASONS = empty / invalid_json / not_object / io / retired_domain; ConfigDocumentRefusal { document, reason, error } + the tombstone arm's migration) — the reading is `inspectBundle` in ./node; pure/browser-safe
|
|
8
8
|
export * from "./url-shape.js"; // 11.0.0: THE URL shape judge (httpUrlFlaws / httpUrlRule / isHierarchicalUrl; 16.0.0 + wsUrlFlaws), pure/browser-safe
|
|
9
9
|
export * from "./device-relay.js"; // 16.0.0: THE value grammar of the device lane's DEVICE_RELAY_URL (DEVICE_RELAY_NONE / deviceRelayFlaws / DEVICE_RELAY_RULE), pure/browser-safe
|
|
@@ -33,6 +33,7 @@ import { RESERVED_MCP_SERVER_NAME_REASON, isReservedMcpServerName } from "./mcp-
|
|
|
33
33
|
import { startsWithHttpScheme } from "./url-shape.js";
|
|
34
34
|
import { TOOL_WIRE_NAME_MAX_CHARS, hasEdgeWhitespace, isUsableWireName } from "./wire-name.js";
|
|
35
35
|
import { isReservedMemberName } from "./reserved-member-name.js";
|
|
36
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
36
37
|
// ── 值的种类描述(拒句只说「你写的是什么形」,不回显值:值可能带凭据、可能任意长)──────────────────────────────────────
|
|
37
38
|
/** 值的**种类词**(不回显值本身):`null` / `array` / `typeof` 词(`object` / `function` / `string` …);读不出的对象 ⇒ 全包唯一的那一句。形状只问座位(总,不抛):两只坏值描述器共用这一只。 */
|
|
38
39
|
function describeKindWord(v) {
|
|
@@ -321,7 +322,7 @@ const reservedMemberFault = (name) => `no member of a declaration may be named "
|
|
|
321
322
|
* 词的意义逐词写在 {@link McpEntryKeyIssue}。消费方按词分派,不读句子;读器的读数 {@link PlainStringRecordRead} 与传输条目的机读位 {@link McpEntryKeyIssue} 的 `fault` 都由这一张表推出。
|
|
322
323
|
* 多一个词而消费方的穷尽 `switch` 不补 ⇒ 编译红(提货成本,不是静默)。
|
|
323
324
|
*/
|
|
324
|
-
export const PLAIN_STRING_RECORD_FAULTS = ["not_plain_record", "member_not_string", "member_name_reserved"];
|
|
325
|
+
export const PLAIN_STRING_RECORD_FAULTS = deepFreeze(["not_plain_record", "member_not_string", "member_name_reserved"]);
|
|
325
326
|
/** 记录不交时 `detail` 的前半句:它是哪一种不朴素(null / 数组 / 原始值各一句,对象里的非朴素一句)。`shape` 穷举 —— 新词不补 = 编译红。 */
|
|
326
327
|
function notPlainDetail(shape, v) {
|
|
327
328
|
switch (shape) {
|
|
@@ -17,10 +17,11 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { settingsSourceContract } from "./settings-sources.js";
|
|
19
19
|
import { urlAllowPatternMatches, urlDenyPatternMatches } from "./url-pattern.js";
|
|
20
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
20
21
|
/** 两张名单的键(闭集,声明序)。 */
|
|
21
|
-
export const MCP_SERVER_LIST_KEYS = ["allowedMcpServers", "deniedMcpServers"];
|
|
22
|
+
export const MCP_SERVER_LIST_KEYS = deepFreeze(["allowedMcpServers", "deniedMcpServers"]);
|
|
22
23
|
/** 没过的那一条的种类(闭集)。拒绝名单:命中的条目种类;允许名单:必须命中而没命中的条目种类,`empty` = 允许名单是空数组。 */
|
|
23
|
-
export const MCP_POLICY_RULES = ["name", "command", "url", "empty"];
|
|
24
|
+
export const MCP_POLICY_RULES = deepFreeze(["name", "command", "url", "empty"]);
|
|
24
25
|
const isName = (e) => "serverName" in e && e.serverName !== undefined;
|
|
25
26
|
const isCommand = (e) => "serverCommand" in e && e.serverCommand !== undefined;
|
|
26
27
|
const isUrl = (e) => "serverUrl" in e && e.serverUrl !== undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 一次性迁移的**收据形**与两张闭集(11.0.0)—— 叶子模块(
|
|
2
|
+
* 一次性迁移的**收据形**与两张闭集(11.0.0)—— 叶子模块(运行期零依赖;除包内私有的零 import 叶 `./deep-freeze` 外只有型导入),由 `./one-time-migrations` 再导出(不进主桶)。
|
|
3
3
|
* 单拆出来只为一件事:读迁移 id 闭集的叶子(墓碑句 `./retired-form`、车道表 `./execution-lane-index`、配置根文档 `./config-root-documents`)
|
|
4
4
|
* 不该为一个型把整套迁移体与域 schema 拉进来。(26.0.0 起调度店的读口不再带收据 —— 它的读时改写到期删了。)
|
|
5
5
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
1
2
|
/** 本版登记的一次性迁移 id(闭集;每个 id 在 `ONE_TIME_MIGRATIONS` 登记表里恰一行)。收据只许这些 id。 */
|
|
2
|
-
export const ONE_TIME_MIGRATION_IDS = ["SS-M8", "SS-M10", "SS-M11", "SS-M12"];
|
|
3
|
+
export const ONE_TIME_MIGRATION_IDS = deepFreeze(["SS-M8", "SS-M10", "SS-M11", "SS-M12"]);
|
|
3
4
|
/**
|
|
4
5
|
* 一条收据说迁移**对一个坐标做了什么**(闭集,每词一义):
|
|
5
6
|
* - `moved` — 值搬到新位(`to`),义不变;
|
|
@@ -9,4 +10,4 @@ export const ONE_TIME_MIGRATION_IDS = ["SS-M8", "SS-M10", "SS-M11", "SS-M12"];
|
|
|
9
10
|
* - `minted` — 在**缺席处**写下一份新事实(一份部署决定),不改任何已有的值 —— 只有 SS-M11 铸(配置根的 `config.env-models.json`:
|
|
10
11
|
* 升级前「管模型面的目录整表顶替 env 模型」的读法,写成 `replaced`;不存在才建)。
|
|
11
12
|
*/
|
|
12
|
-
export const MIGRATION_APPLIED_AS = ["moved", "rewritten", "dropped-inert", "refused", "minted"];
|
|
13
|
+
export const MIGRATION_APPLIED_AS = deepFreeze(["moved", "rewritten", "dropped-inert", "refused", "minted"]);
|
|
@@ -40,9 +40,10 @@ import { isJsonArray, isPlainJsonObject, jsonShapeOf } from "./plain-json-object
|
|
|
40
40
|
import { RETIRED_ROLE_WORDS } from "./retired-role-words.js";
|
|
41
41
|
import { isDomainName, isRetiredDomainName } from "./types.js";
|
|
42
42
|
import { workerRowVerdict } from "./worker-row-verdict.js";
|
|
43
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
43
44
|
export { MIGRATION_APPLIED_AS, ONE_TIME_MIGRATION_IDS } from "./migration-receipt.js";
|
|
44
45
|
/** 一次性迁移登记表 —— 本族各条窗的**唯一属主**。别处只写「窗见 `ONE_TIME_MIGRATIONS` 登记表」。 */
|
|
45
|
-
export const ONE_TIME_MIGRATIONS = [
|
|
46
|
+
export const ONE_TIME_MIGRATIONS = deepFreeze([
|
|
46
47
|
{
|
|
47
48
|
id: "SS-M8",
|
|
48
49
|
oldForm: "refused",
|
|
@@ -110,7 +111,7 @@ export const ONE_TIME_MIGRATIONS = [
|
|
|
110
111
|
afterRemoval: "the runtime.execution.lane tombstone field, the memory-backend refusal for \"tidb\" and the reserved-env refusal for DEVICE_RELAY_URL (permanent): a residual " +
|
|
111
112
|
"15.x row is refused on write and held by readWorkersRows on read, never rewritten",
|
|
112
113
|
},
|
|
113
|
-
];
|
|
114
|
+
]);
|
|
114
115
|
/**
|
|
115
116
|
* 迁移一组存储文档(见文件头「入口」)。纯函数;没改的文档原样返回;**不抬任何版本号**(结果里没有版本 —— 那是调用方的)。
|
|
116
117
|
* 重跑恒等:第二次跑零改动,只剩第一次就 `refused` 的那几张收据(那些坐标原样留着,读侧照旧拒)。
|
package/dist/own-key-read.d.ts
CHANGED
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
* 内核覆盖声明键读与整容器读;**仍自带读法的读者按名登记**(各自写明契约;普查钉按「文件 → 函数 → 读法 API」逐处数,登记外出现即红):
|
|
26
26
|
* 既有、未经内核的数据读者:`tightenVerdict` 的 `none` 规则(`strictJsonCopy`:对象的不可枚举键跳过、访问器 ⇒ 整份 `unreadable`;数组按 `length` 逐位读描述符 —— `length` 走一次 `[[Get]]`、不可枚举的下标照读)·
|
|
27
27
|
* 被丢条目的身份(`readEntryIdentity` 读 `name` / `id`,它调的 `ownEnabledFlag`(`./catalog-manages`,与原文判官共用)读 `enabled` —— 同一读法:访问器 ⇒ 当缺席,从不调)· 传输记录读法(`readPlainStringRecord`:自己枚举成员名 `getOwnPropertyNames`,值经 {@link readKey});
|
|
28
|
-
* 不是数据读的:安全判官 `extraBodyUnsafe` 的审计读(`./types`:问「任何自有键上有没有可疑」,含符号键与会抛的描述符,访问器 ⇒ 判不安全,从不调)
|
|
28
|
+
* 不是数据读的:安全判官 `extraBodyUnsafe` 的审计读(`./types`:问「任何自有键上有没有可疑」,含符号键与会抛的描述符,访问器 ⇒ 判不安全,从不调)·
|
|
29
|
+
* 包内冻结助手 `freezeGraph`(`./deep-freeze`:`getOwnPropertyDescriptor` + `Reflect.ownKeys` 走**包自己的闭集常量**的自有数据属性、决定冻谁,不读嵌入方传来的值;它保持零 import,所以不经本内核 ——
|
|
30
|
+
* 是选择,不是做不到:本内核只 import 座位与 zod 的类型,引它不成环)。
|
|
29
31
|
* 直接用 `[[Get]]` 的几处(不经内核,按名登记):hooks 分类器(`Object.keys` + 成员读;闭包可抄的内建写法,随闭包契约变更收)· `collectDropped` / `collectionSlots`(`./config-fns`:
|
|
30
32
|
* 未知键扫描与条目集合的位置表,自己枚举容器再 `[[Get]]`;既有)· http hook 名单读器与判官的**普通读对拍**(安全轴的名单、判官的 `layers` / `hookVars` 要描述符视图
|
|
31
33
|
* 与普通读两份观测一致才算读到 —— 普通读只作对拍,交出去的值取自描述符那一份;见 `./http-hook-allowlists`)。`stableStringify` 已归零(每个容器经 {@link containerView} 的宽归类列一次成员、
|
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
* (`./one-time-migrations`)、`config.d` 文档形(`./config-d-file`)、`extraBody` 的形闸与秘密走查(`./types`)、settings 单元读法与严格 JSON 深度判(`./settings-units` / `./safety-merge-spec`)、
|
|
7
7
|
* 请求面传输的记录读法与描述件(`./mcp-request-entry`)、workers 行读口(`./workers-rows`)、有效配置线上载荷读口(`./config-fns` 的 `readEffectiveWire`)、http hook 名单的设置袋(`./http-hook-allowlists`)、
|
|
8
8
|
* fleet 线上载荷的受护判(`./fleet`)、符合性语料的比较器 / 派生 / 语料读口 / 元数据拆分(`./conformance/*`)。零 import。
|
|
9
|
-
* **形状分类核 {@link jsonShapeOf} 是座位的本体**,`isPlainJsonObject` 由它派生(`plain` 那一格)
|
|
9
|
+
* **形状分类核 {@link jsonShapeOf} 是座位的本体**,`isPlainJsonObject` 由它派生(`plain` 那一格);本模块里读原型的只有它与安全轴的朴素数组判据 {@link isPlainJsonArray}(全包另有两处读原型,见下)。**总(不抛)**:检视就抛的对象(已撤销的 Proxy、`getPrototypeOf` 陷阱抛)
|
|
10
10
|
* 核答 `uninspectable`、判官答 `false`,不抛出去 —— 全包经座位的读口因此拒而不抛,律在座位上收一处,不在每个读器各包一个 `try`;读者对 `uninspectable` 一律按最严处置(hooks ⇒ 拒整份文档;名单 ⇒ `malformed`;传输 ⇒ 整只不交)。
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* **形状判的第二处是 `./hooks-config` 的 `hookShapeOf` / `hookIsRecord`,与 {@link jsonShapeOf} / 本函数逐字同文(调用名归一后)**:hooks 分类器的闭包要被消费方生成器整函数抄走(闭包里的自由名只有 `HOOK_EVENTS`),闭包里不能 import 本模块 ——
|
|
13
13
|
* 同文由 `test/plain-json-object-single-seat-14.6.0.test.ts` 逐字证明(漂开即红),闭包契约多注入一个名字时(S-2133)把它并回这里。
|
|
14
|
-
*
|
|
14
|
+
* **第三处是包内冻结助手 `./deep-freeze` 的 `freezeGraph`**:它也问「是不是数组」「原型是什么」,但它只接触包自己的闭集常量(不读嵌入方传来的值),判「朴素对象」用的是原型恒等 `Object.prototype`(或 `null`),
|
|
15
|
+
* 与本模块的判法(原型是 `null`,或原型自己的原型是 `null`)不同 —— 它不是本模块的副本,没有「同文」的要求。助手保持零 import 是一个选择(叶性钉与消费方抄本组不必跟着变),不是做不到:本模块自己零 import,引它不成环。
|
|
16
|
+
* 两种「朴素对象」读法收成一种是后续的设计事项,这条注释不改判据。
|
|
17
|
+
* 同一个门也数全包:返回类型是 `x is Record<string, unknown>` 的函数,除本模块与 `./hooks-config` 那一份这两处之外一处不许有;读原型的调用点,除这两处与冻结助手一处之外一处不许有;内联的「typeof 对象 ∧ 非 null ∧ 非数组」合取则**一处都不许有**(座位里它是分开的 `if` 臂,不是合取)。
|
|
15
18
|
*
|
|
16
19
|
* **读者要的答案不只是「是不是朴素对象」时,调本模块的 {@link jsonShapeOf}**(六词形状分类),不在读者里再推一遍形状:例如托管层的 http hook 名单,非朴素的**对象**袋必须 fail-closed(读成空名单并告警),
|
|
17
20
|
* 而 `null` / 原始值 / 数组仍是「整份设置不是对象 ⇒ 两键都缺」—— 两种不同的答案,只能由形状分类给。`isPlainJsonObject` 就是 `jsonShapeOf` 的「朴素」那一格。
|
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
* (`./one-time-migrations`)、`config.d` 文档形(`./config-d-file`)、`extraBody` 的形闸与秘密走查(`./types`)、settings 单元读法与严格 JSON 深度判(`./settings-units` / `./safety-merge-spec`)、
|
|
7
7
|
* 请求面传输的记录读法与描述件(`./mcp-request-entry`)、workers 行读口(`./workers-rows`)、有效配置线上载荷读口(`./config-fns` 的 `readEffectiveWire`)、http hook 名单的设置袋(`./http-hook-allowlists`)、
|
|
8
8
|
* fleet 线上载荷的受护判(`./fleet`)、符合性语料的比较器 / 派生 / 语料读口 / 元数据拆分(`./conformance/*`)。零 import。
|
|
9
|
-
* **形状分类核 {@link jsonShapeOf} 是座位的本体**,`isPlainJsonObject` 由它派生(`plain` 那一格)
|
|
9
|
+
* **形状分类核 {@link jsonShapeOf} 是座位的本体**,`isPlainJsonObject` 由它派生(`plain` 那一格);本模块里读原型的只有它与安全轴的朴素数组判据 {@link isPlainJsonArray}(全包另有两处读原型,见下)。**总(不抛)**:检视就抛的对象(已撤销的 Proxy、`getPrototypeOf` 陷阱抛)
|
|
10
10
|
* 核答 `uninspectable`、判官答 `false`,不抛出去 —— 全包经座位的读口因此拒而不抛,律在座位上收一处,不在每个读器各包一个 `try`;读者对 `uninspectable` 一律按最严处置(hooks ⇒ 拒整份文档;名单 ⇒ `malformed`;传输 ⇒ 整只不交)。
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* **形状判的第二处是 `./hooks-config` 的 `hookShapeOf` / `hookIsRecord`,与 {@link jsonShapeOf} / 本函数逐字同文(调用名归一后)**:hooks 分类器的闭包要被消费方生成器整函数抄走(闭包里的自由名只有 `HOOK_EVENTS`),闭包里不能 import 本模块 ——
|
|
13
13
|
* 同文由 `test/plain-json-object-single-seat-14.6.0.test.ts` 逐字证明(漂开即红),闭包契约多注入一个名字时(S-2133)把它并回这里。
|
|
14
|
-
*
|
|
14
|
+
* **第三处是包内冻结助手 `./deep-freeze` 的 `freezeGraph`**:它也问「是不是数组」「原型是什么」,但它只接触包自己的闭集常量(不读嵌入方传来的值),判「朴素对象」用的是原型恒等 `Object.prototype`(或 `null`),
|
|
15
|
+
* 与本模块的判法(原型是 `null`,或原型自己的原型是 `null`)不同 —— 它不是本模块的副本,没有「同文」的要求。助手保持零 import 是一个选择(叶性钉与消费方抄本组不必跟着变),不是做不到:本模块自己零 import,引它不成环。
|
|
16
|
+
* 两种「朴素对象」读法收成一种是后续的设计事项,这条注释不改判据。
|
|
17
|
+
* 同一个门也数全包:返回类型是 `x is Record<string, unknown>` 的函数,除本模块与 `./hooks-config` 那一份这两处之外一处不许有;读原型的调用点,除这两处与冻结助手一处之外一处不许有;内联的「typeof 对象 ∧ 非 null ∧ 非数组」合取则**一处都不许有**(座位里它是分开的 `if` 臂,不是合取)。
|
|
15
18
|
*
|
|
16
19
|
* **读者要的答案不只是「是不是朴素对象」时,调本模块的 {@link jsonShapeOf}**(六词形状分类),不在读者里再推一遍形状:例如托管层的 http hook 名单,非朴素的**对象**袋必须 fail-closed(读成空名单并告警),
|
|
17
20
|
* 而 `null` / 原始值 / 数组仍是「整份设置不是对象 ⇒ 两键都缺」—— 两种不同的答案,只能由形状分类给。`isPlainJsonObject` 就是 `jsonShapeOf` 的「朴素」那一格。
|
package/dist/portable-domains.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
1
2
|
/** The domains a single-machine TOC carries: what `FileConfigStore` reads out of `config.d/`, and the
|
|
2
3
|
* **default**域集 of the bundle helpers (`exportBundle`/`readBundle`). 每个被排除的域必须在
|
|
3
4
|
* {@link NON_PORTABLE_DOMAIN_REASONS} 里有一条成文理由(禁裸排除,#282 件5 附带裁定)。
|
|
@@ -12,7 +13,7 @@
|
|
|
12
13
|
* 同形**。当年 `limits` 域就是这样在单机腿静默丢了一整片限额发布(远端腿同批可用,所以更难看出来)。
|
|
13
14
|
* 今日的兜底:漏登记的文件会被 `FileConfigStore`(`./node`)的 `"unread-config-file"` 警告点名(fail-loud,
|
|
14
15
|
* 见 getEffective),但那只在消费方接了 `onWarning` 时才响 —— **登记仍是第一现场的义务**。 */
|
|
15
|
-
export const PORTABLE_DOMAINS = ["models", "rosters", "skills", "mcp", "plugins", "scenarios", "collab", "governance", "execution", "prompts", "limits", "a2a"];
|
|
16
|
+
export const PORTABLE_DOMAINS = deepFreeze(["models", "rosters", "skills", "mcp", "plugins", "scenarios", "collab", "governance", "execution", "prompts", "limits", "a2a"]);
|
|
16
17
|
/**
|
|
17
18
|
* 非便携域的**排除理由表**(#282 件5 附带裁定:禁裸排除)。
|
|
18
19
|
*
|
|
@@ -21,10 +22,10 @@ export const PORTABLE_DOMAINS = ["models", "rosters", "skills", "mcp", "plugins"
|
|
|
21
22
|
* (此前是「理由写在注释里」,机器只能做子串匹配——域名出现在文件任何角落都算数,等于没门;对抗复审
|
|
22
23
|
* 复审 round1 F3。)理由要写**为什么它不该被单机/跨部署搬运**,带出处。
|
|
23
24
|
*/
|
|
24
|
-
export const NON_PORTABLE_DOMAIN_REASONS = {
|
|
25
|
+
export const NON_PORTABLE_DOMAIN_REASONS = deepFreeze({
|
|
25
26
|
workers: "FLEET-only:单机没有 reconciler,`{workers:[]}` 的 schema 默认就是正确语义(缺席不需要 stub)。",
|
|
26
27
|
hosts: "FLEET-only:同 workers —— 单机无机器注册表/自动排布,空注册表即正确语义。",
|
|
27
28
|
systems: "FLEET-only:系统接入/凭据下发的元数据(nonce+路由)属于 web-admin 侧生命周期,单机 lane 无对应执法点。",
|
|
28
29
|
projects: "TENANT IDENTITY DATA,不是可搬运的配置:登记簿随包复制进另一个部署 = 凭空多出的身份登记(design/142 §1.4 威胁模型①「carried-in foreign projectId」换了身 import 的衣服)。要带走走 142 §5 的导出面(service 半场)。",
|
|
29
30
|
entitlement: "per-PRINCIPAL 商务/治理数据(tier·预算上限·kill-switch·allowlist),与 projects 同威胁模型(#282 件5 附带裁定,此前是唯一裸排除项):(a) 搬走 = 把一个租户的商务档复制进另一部署;(b) 反向也不成立 —— 单机 TOC 无 principal 轴(无鉴权语境、无 `/effective?principal=` 解析面),本地 entitlement.json 只会造出一份**永不被执法**的假管控面(真执法点在 service / web-admin 边界)。缺席语义如实:本地 buildEffective 给它 schema 默认值(空表),这**不等于**把远端 kill-switch/预算上限搬到了本地 —— 单机 lane 本就没有那个执法点。",
|
|
30
|
-
};
|
|
31
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 包内私有叶子模块(
|
|
2
|
+
* 包内私有叶子模块(运行期只 import 包内私有的零 import 叶 `./deep-freeze`,浏览器安全;不进 `package.json` 的 exports,主桶经 `./mcp-request-entry` 转出这里的公开名):
|
|
3
3
|
* **一个名字能不能作「名 → 串」记录的成员名**的唯一判据 —— 原型链上的三个名字永远不能:`__proto__`(按赋值拷贝会变成原型;zod 的 record 读键前先跳过它、不判它的值)、
|
|
4
4
|
* `constructor` / `prototype`(读方对普通对象做 `obj[名]` 时撞上原型成员)。
|
|
5
5
|
* 三个读口问它,同一张表、同一个答案:域 schema 的凭据引用集合(`./types` 的 `credentialRefs`:在场 ⇒ 集合坏)· 公开的记录读器(`./mcp-request-entry` 的 `readPlainStringRecord` /
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 包内私有叶子模块(
|
|
2
|
+
* 包内私有叶子模块(运行期只 import 包内私有的零 import 叶 `./deep-freeze`,浏览器安全;不进 `package.json` 的 exports,主桶经 `./mcp-request-entry` 转出这里的公开名):
|
|
3
3
|
* **一个名字能不能作「名 → 串」记录的成员名**的唯一判据 —— 原型链上的三个名字永远不能:`__proto__`(按赋值拷贝会变成原型;zod 的 record 读键前先跳过它、不判它的值)、
|
|
4
4
|
* `constructor` / `prototype`(读方对普通对象做 `obj[名]` 时撞上原型成员)。
|
|
5
5
|
* 三个读口问它,同一张表、同一个答案:域 schema 的凭据引用集合(`./types` 的 `credentialRefs`:在场 ⇒ 集合坏)· 公开的记录读器(`./mcp-request-entry` 的 `readPlainStringRecord` /
|
|
6
6
|
* `isStringRecord`,请求面传输的 `env` / `headers` 同读:剔出副本并点名)· 中心引用解析口(`./center-refs`,经记录读器:在场 ⇒ `refs_unreadable`)。
|
|
7
7
|
* 住在叶子里,是因为 `./types` 与 `./mcp-request-entry` 都要它,而后者反过来引 `./types`。
|
|
8
8
|
*/
|
|
9
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
9
10
|
/** 保留成员名,闭集。 */
|
|
10
|
-
export const RESERVED_MEMBER_NAMES = ["__proto__", "constructor", "prototype"];
|
|
11
|
+
export const RESERVED_MEMBER_NAMES = deepFreeze(["__proto__", "constructor", "prototype"]);
|
|
11
12
|
/** 这个名字是保留成员名吗(大小写敏感:`Constructor` / `X-Prototype` 不是)。 */
|
|
12
13
|
export function isReservedMemberName(name) {
|
|
13
14
|
return RESERVED_MEMBER_NAMES.includes(name);
|
package/dist/resolve-roster.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { stableHash } from "./hash.js";
|
|
2
2
|
import { danglingRefs } from "./cross-domain.js";
|
|
3
3
|
import { toSkillsManifest } from "./skills-manifest.js";
|
|
4
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
4
5
|
// ── 主/cheap 角色标记语义(0.6.3, E3)────────────────────────────────
|
|
5
6
|
// service 现有 ModelRoles 口径:default→主(12.0.0 起唯一;`team` / `synthesize` 随 core 7.49.0 删)、subagent/summarize→cheap。1.8.0 起 `classifier`/`consolidate`
|
|
6
7
|
// 同 `verifier` 一样**不派生**(归 cheap 会盖掉 models.tiers 档位与 core 兜底链)。`verifier` 刻意
|
|
7
8
|
// 不派生(unset→core 的 default 兜底链,与 service 语义一致)。常量导出=单一语义源,service 收敛小单与
|
|
8
9
|
// web-admin 表单同源引用,别第二份。
|
|
9
10
|
/** primaryModel 标记喂的角色族(§3)。 */
|
|
10
|
-
export const ROSTER_PRIMARY_ROLES = ["default"];
|
|
11
|
+
export const ROSTER_PRIMARY_ROLES = deepFreeze(["default"]);
|
|
11
12
|
/** cheapModel 标记喂的角色族(§3)。 */
|
|
12
|
-
export const ROSTER_CHEAP_ROLES = ["subagent", "summarize"];
|
|
13
|
+
export const ROSTER_CHEAP_ROLES = deepFreeze(["subagent", "summarize"]);
|
|
13
14
|
/** 把 roster 的主/cheap 角色标记派生成 roles 片段(PURE)。显式 roster.roles 逐角色盖过它;它盖过全局
|
|
14
15
|
* models.roles(合并点见 {@link resolveEffectiveForWorker})。wire 形状不变——service 零改仍兼容,
|
|
15
16
|
* 收敛后直接读标记亦可(effective 的 rosters 域不上 wire,标记经此物化进 models.roles)。 */
|
package/dist/retired-envs.js
CHANGED
|
@@ -25,13 +25,14 @@
|
|
|
25
25
|
*
|
|
26
26
|
* 行形 = 字面元组(第三元是族词),一行一个旧名。纯数据 + 纯函数,零 IO,browser-safe。
|
|
27
27
|
*/
|
|
28
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
28
29
|
import { PREVIOUS_WEB_ADMIN_ENV } from "./previous-web-admin-env.js";
|
|
29
30
|
import { WEB_ADMIN_ENV } from "./web-admin-env.js";
|
|
30
31
|
/** 墓碑拒启码(机读;拒句方括号里)。 */
|
|
31
32
|
export const RETIRED_ENV_REFUSAL_CODE = "config.env_key_retired";
|
|
32
33
|
const OA_REMOVED = "the OA scenario was removed in 5.0.0";
|
|
33
34
|
const negativeAliasWhy = (old, positive) => `negative-name alias retired in server 3.0.0 — unset it; the polarity is inverted: ${old}=true is ${positive}=false (the positive name defaults on)`;
|
|
34
|
-
export const RETIRED_ENVS = [
|
|
35
|
+
export const RETIRED_ENVS = deepFreeze([
|
|
35
36
|
["TIDB_HOST", "MYSQL_HOST", "renamed"],
|
|
36
37
|
["TIDB_PORT", "MYSQL_PORT", "renamed"],
|
|
37
38
|
["TIDB_USER", "MYSQL_USER", "renamed"],
|
|
@@ -85,11 +86,7 @@ export const RETIRED_ENVS = [
|
|
|
85
86
|
// 壳的总开关没有可 rename 的目标(出路是在目录条目上声明链,不是换个 env 名)⇒ removed。近预算降级线的三个旋钮(`MODEL_DEGRADE_TO` / `_AT_COST_FRACTION` / `_TO_VISION`)仍是活旋钮,不在本表。
|
|
86
87
|
["MODEL_DEGRADE_ON", "MODEL_FALLBACK_ON", "replaced", "the gate words moved to the engine's per-model fallback chain: budget is no longer a gate word, network / auth / stream_torn are new, and the gate now applies to every catalog chain instead of one whole-Brain target"],
|
|
87
88
|
["MODEL_DEGRADE_REACTIVE", "the env-driven whole-Brain reactive degrade shell was retired: declare `fallbacks` on the catalog entry (models.models[].fallbacks) — a fallback chain is catalog data now; the gate words that decide when a hop is taken are MODEL_FALLBACK_ON", "removed"],
|
|
88
|
-
];
|
|
89
|
-
// 冻结:拿到导出的人改不了拒启判据(读拒句的与投影 wire 的是同一个数组对象)。
|
|
90
|
-
for (const row of RETIRED_ENVS)
|
|
91
|
-
Object.freeze(row);
|
|
92
|
-
Object.freeze(RETIRED_ENVS);
|
|
89
|
+
]);
|
|
93
90
|
/** 墓碑表 → wire 投影(纯数据)。**同一张表、同序**;族是闭集,穷举 switch(加一族不写这里 ⇒ 编译红)。 */
|
|
94
91
|
export function buildRetiredEnvWire() {
|
|
95
92
|
return RETIRED_ENVS.map((row) => {
|
|
@@ -198,6 +198,12 @@ export declare const FailMode: z.ZodEnum<{
|
|
|
198
198
|
open: "open";
|
|
199
199
|
}>;
|
|
200
200
|
export type FailMode = z.infer<typeof FailMode>;
|
|
201
|
+
/** `T` with every field and every array read-only, at every depth (type level only — no runtime effect). The spec table {@link SAFETY_MERGE_SPEC} is deep-frozen, so the
|
|
202
|
+
* type of one of its rows, and of a rule read off one, must not offer a write the frozen row refuses; a `z.infer` type is mutable by construction,
|
|
203
|
+
* this is its read-only projection. A mutable value is assignable to it, so a caller that builds a rule or a row keeps compiling. */
|
|
204
|
+
type ReadonlyDeep<T> = T extends readonly (infer U)[] ? readonly ReadonlyDeep<U>[] : T extends object ? {
|
|
205
|
+
readonly [K in keyof T]: ReadonlyDeep<T[K]>;
|
|
206
|
+
} : T;
|
|
201
207
|
/** The monotone tighten-only direction for a category (which way is "stricter"). `enumRank.order` lists values
|
|
202
208
|
* from LOOSEST→STRICTEST — the category's whole vocabulary: a word outside it is refused, and a ONE-word order (11.0.0:
|
|
203
209
|
* `shellGate`, whose engine vocabulary is the single floor word) is the degenerate rank where the only merge is identity;
|
|
@@ -225,7 +231,7 @@ export declare const TightenRule: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
225
231
|
}, z.core.$strip>, z.ZodObject<{
|
|
226
232
|
rule: z.ZodLiteral<"numericLower">;
|
|
227
233
|
}, z.core.$strip>], "rule">;
|
|
228
|
-
export type TightenRule = z.infer<typeof TightenRule
|
|
234
|
+
export type TightenRule = ReadonlyDeep<z.infer<typeof TightenRule>>;
|
|
229
235
|
/** Where `candidate` lands relative to `existing` under a {@link TightenRule} (14.6.0; closed, in this order):
|
|
230
236
|
* `equal` · `stricter` · `looser` · `unordered` (comparable values, neither side contains the other — two different sets,
|
|
231
237
|
* two different `none` values) · `unreadable` (a side is outside the rule's normalized domain — absent, misspelled,
|
|
@@ -333,7 +339,7 @@ export declare const MergeCategorySpec: z.ZodObject<{
|
|
|
333
339
|
list: z.ZodOptional<z.ZodLiteral<true>>;
|
|
334
340
|
}, z.core.$strip>>>;
|
|
335
341
|
}, z.core.$strip>;
|
|
336
|
-
export type MergeCategorySpec = z.infer<typeof MergeCategorySpec
|
|
342
|
+
export type MergeCategorySpec = ReadonlyDeep<z.infer<typeof MergeCategorySpec>>;
|
|
337
343
|
/** The category spec. Keys = the unified settings categories both seats map their concrete keys/fields into.
|
|
338
344
|
* Faithful to settings-core v2-design §3 (the semantic source of record). */
|
|
339
345
|
export declare const SAFETY_MERGE_SPEC: {
|
|
@@ -370,7 +376,7 @@ export declare const SAFETY_MERGE_SPEC: {
|
|
|
370
376
|
readonly minTrust: "global";
|
|
371
377
|
readonly tighten: {
|
|
372
378
|
readonly rule: "enumRank";
|
|
373
|
-
readonly order: ["bypassPermissions", "auto", "acceptEdits", "default", "dontAsk", "plan"];
|
|
379
|
+
readonly order: readonly ["bypassPermissions", "auto", "acceptEdits", "default", "dontAsk", "plan"];
|
|
374
380
|
};
|
|
375
381
|
readonly enforcement: "gate";
|
|
376
382
|
readonly fail: "closed";
|
|
@@ -392,7 +398,7 @@ export declare const SAFETY_MERGE_SPEC: {
|
|
|
392
398
|
readonly minTrust: "global";
|
|
393
399
|
readonly tighten: {
|
|
394
400
|
readonly rule: "enumRank";
|
|
395
|
-
readonly order: ["always"];
|
|
401
|
+
readonly order: readonly ["always"];
|
|
396
402
|
};
|
|
397
403
|
readonly enforcement: "gate";
|
|
398
404
|
readonly fail: "closed";
|
|
@@ -690,3 +696,4 @@ export declare function resolveMemberTighten(spec: MergeCategorySpec, member: st
|
|
|
690
696
|
/** A declared member's comparator from the published table (see {@link resolveMemberTighten}); compare two of its values with
|
|
691
697
|
* {@link tightenVerdict}. Unknown category or member ⇒ RangeError (never the category rule as a fallback). */
|
|
692
698
|
export declare function memberTighten<C extends SafetyMergeCategory>(category: C, member: SafetyMergeMember<C>): TightenRule;
|
|
699
|
+
export {};
|
|
@@ -68,6 +68,7 @@ import { z } from "zod";
|
|
|
68
68
|
import { MAX_HASH_DEPTH, stableStringify } from "./hash.js";
|
|
69
69
|
import { captureStringArray, dataDescriptor, isAccessorDescriptor, isolatedObject } from "./own-key-read.js";
|
|
70
70
|
import { jsonShapeOf } from "./plain-json-object.js";
|
|
71
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
71
72
|
/** How values from different layers/principals combine for a category. */
|
|
72
73
|
export const MergeShape = z.enum(["denyFirst", "replace", "runAll", "overrideByName", "concat"]);
|
|
73
74
|
/** The trust-tier VOCABULARY as a RUNTIME VALUE — the ONE source of the ladder's words, in the same form as
|
|
@@ -77,7 +78,7 @@ export const MergeShape = z.enum(["denyFirst", "replace", "runAll", "overrideByN
|
|
|
77
78
|
* table as the one global the closure needs, instead of writing a ladder of its own.
|
|
78
79
|
* ⚠️ The DECLARATION ORDER is NOT the rank (it is the 1.1.0 order with `task` appended — kept byte-stable because
|
|
79
80
|
* reordering is breaking); never index it as a ladder — use {@link trustRank}. */
|
|
80
|
-
export const MIN_TRUST_WORDS = ["local", "session", "project", "global", "managed", "task"];
|
|
81
|
+
export const MIN_TRUST_WORDS = deepFreeze(["local", "session", "project", "global", "managed", "task"]);
|
|
81
82
|
/** The trust-tier VOCABULARY a category — or, since 1.1.0, one of its members — names as its admission floor
|
|
82
83
|
* (the MINIMUM trust a layer/principal must have to set it). The RANK is v2-design §1:29,
|
|
83
84
|
* `managed 6 > global 5 > project 4 > local 3 > session 2 > task 1`, published as {@link trustRank}; compare with
|
|
@@ -177,7 +178,7 @@ export const TightenRule = z.discriminatedUnion("rule", [
|
|
|
177
178
|
* `equal` · `stricter` · `looser` · `unordered` (comparable values, neither side contains the other — two different sets,
|
|
178
179
|
* two different `none` values) · `unreadable` (a side is outside the rule's normalized domain — absent, misspelled,
|
|
179
180
|
* the wrong type). */
|
|
180
|
-
export const TIGHTEN_VERDICTS = ["equal", "stricter", "looser", "unordered", "unreadable"];
|
|
181
|
+
export const TIGHTEN_VERDICTS = deepFreeze(["equal", "stricter", "looser", "unordered", "unreadable"]);
|
|
181
182
|
/** `diff` > 0 ⇒ the candidate is higher on the strictness order. */
|
|
182
183
|
function orderVerdict(diff) {
|
|
183
184
|
return diff > 0 ? "stricter" : diff < 0 ? "looser" : "equal";
|
|
@@ -348,7 +349,7 @@ export const MergeCategorySpec = z.object({
|
|
|
348
349
|
});
|
|
349
350
|
/** The category spec. Keys = the unified settings categories both seats map their concrete keys/fields into.
|
|
350
351
|
* Faithful to settings-core v2-design §3 (the semantic source of record). */
|
|
351
|
-
export const SAFETY_MERGE_SPEC = {
|
|
352
|
+
export const SAFETY_MERGE_SPEC = deepFreeze({
|
|
352
353
|
// 1.1.0 [5797] ④ — member-level admission, direction-asymmetric (header): allow = loosen ⇒ global-or-managed;
|
|
353
354
|
// deny/ask = tighten ⇒ every settings-file layer (local = the lowest file tier). The category minTrust stays
|
|
354
355
|
// "global" = the DEFAULT floor (member rows override it; consumers that predate `members` still enforce it on
|
|
@@ -459,7 +460,7 @@ export const SAFETY_MERGE_SPEC = {
|
|
|
459
460
|
disableAutoMode: { direction: "tighten", minTrust: "global", boolPole: { strict: true, minTrust: "local" } },
|
|
460
461
|
},
|
|
461
462
|
},
|
|
462
|
-
};
|
|
463
|
+
});
|
|
463
464
|
/** Own-property table lookup. The category union is compile-time only; a JavaScript or deserialized caller can
|
|
464
465
|
* hand in `"__proto__"` / `"constructor"` / `"toString"`, which a bare index resolves through Object.prototype
|
|
465
466
|
* to a non-spec object — `membersOf` would then answer `[]` = "whole key, nothing to check" (fail-OPEN). An
|
package/dist/secret-scan.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* 不靠异常:单个转义的判据写成字符集(只有 ASCII 的 `%00`–`%7F` 单独解得开),转义串的判据写成 UTF-8 良构判定 ——
|
|
11
11
|
* 结果与原来的 try/catch 逐字相同(`test/disclosable-identity-6.3.0.test.ts` 的两只冻结 oracle 钉着)。
|
|
12
12
|
*
|
|
13
|
-
* 本模块只引 `./url-shape`(
|
|
13
|
+
* 本模块只引 `./url-shape`(叶子:自己只引包内私有的零 import 叶 `./deep-freeze`;`./types` 引本模块,本模块不回引,不成环)。
|
|
14
14
|
*/
|
|
15
15
|
import { httpUrlFlaws } from "./url-shape.js"; // the URL shape judge — whether a parsed URL carries userinfo is its call
|
|
16
16
|
/** How many percent-decoded layers a secret scan reads beyond the raw string (a multi-encoded `%2573%256B…` →
|
package/dist/settings-sources.js
CHANGED
|
@@ -35,18 +35,19 @@
|
|
|
35
35
|
import { echoCallerText } from "./caller-text-echo.js";
|
|
36
36
|
import { stripControlAndBidi } from "./control-and-bidi.js";
|
|
37
37
|
import { SAFETY_MERGE_SPEC, isAtLeast, memberAdmission } from "./safety-merge-spec.js";
|
|
38
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
38
39
|
/** The settings sources, in MERGE order (a later source overrides an earlier one where a category's merge shape lets it):
|
|
39
40
|
* user < project < local < flag < policy. `flagSettings` = settings handed in at launch (`--settings <file|json>`, an SDK embedder's inline
|
|
40
41
|
* settings); `policySettings` = managed. `foreignProjectSettings` (appended) = the repository's settings files written for another tool; it
|
|
41
42
|
* contributes tightening writes only, and every tighten rule merges by "the stricter wins" (order-independent), so its place in the order
|
|
42
43
|
* changes no merged value. */
|
|
43
|
-
export const SETTINGS_SOURCES = ["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings", "foreignProjectSettings"];
|
|
44
|
+
export const SETTINGS_SOURCES = deepFreeze(["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings", "foreignProjectSettings"]);
|
|
44
45
|
/**
|
|
45
46
|
* The source table. `flagSettings` is in the operator tier (`global`, not repository-controllable) like CC's: settings handed in at launch are
|
|
46
47
|
* the launcher's own act — an SDK embedder or a wrapper script — not something a repository brings (a wrapper that turns repository content
|
|
47
48
|
* into `--settings` makes that choice itself).
|
|
48
49
|
*/
|
|
49
|
-
export const SETTINGS_SOURCE_CONTRACT = {
|
|
50
|
+
export const SETTINGS_SOURCE_CONTRACT = deepFreeze({
|
|
50
51
|
userSettings: { trust: "global", repoControllable: false },
|
|
51
52
|
projectSettings: { trust: "project", repoControllable: true },
|
|
52
53
|
localSettings: { trust: "project", repoControllable: true },
|
|
@@ -56,7 +57,7 @@ export const SETTINGS_SOURCE_CONTRACT = {
|
|
|
56
57
|
// project tier and repository-controlled like this product's own project files, and tighten-only — its deny / ask rules, kill-switches ON and
|
|
57
58
|
// sandbox restrictions are read, its allow rules, hooks, env, MCP servers and the rest never are (see the file header).
|
|
58
59
|
foreignProjectSettings: { trust: "project", repoControllable: true, tightenOnly: true },
|
|
59
|
-
};
|
|
60
|
+
});
|
|
60
61
|
/**
|
|
61
62
|
* The ONE lookup of {@link SETTINGS_SOURCE_CONTRACT}: a source's tier and whether a repository controls it. Every function in this package
|
|
62
63
|
* that needs a layer's tier reads it here ({@link layerAdmission}, the http hook allowlist judge, the MCP server list verdict) — none takes a
|
|
@@ -73,11 +74,11 @@ export function settingsSourceContract(source) {
|
|
|
73
74
|
* host must assume so), `no_trust_step` (the host has no trust step at all). A host whose reading throws or yields a word outside this set
|
|
74
75
|
* passes `declined`; this package's functions refuse an unknown word loudly rather than reading it as any tier.
|
|
75
76
|
*/
|
|
76
|
-
export const WORKSPACE_TRUST_STATES = ["accepted", "declined", "no_trust_step"];
|
|
77
|
+
export const WORKSPACE_TRUST_STATES = deepFreeze(["accepted", "declined", "no_trust_step"]);
|
|
77
78
|
/** What {@link layerAdmission} answers (closed): `admitted`; `trust_withheld` = would be admitted once the workspace is `accepted`;
|
|
78
79
|
* `below_trust_floor` = this source can never set it (its tier is below the floor); `tighten_only` = this source is read in the tighten direction
|
|
79
80
|
* only, so nothing — no workspace decision — admits this write from it. */
|
|
80
|
-
export const LAYER_ADMISSION_VERDICTS = ["admitted", "trust_withheld", "below_trust_floor", "tighten_only"];
|
|
81
|
+
export const LAYER_ADMISSION_VERDICTS = deepFreeze(["admitted", "trust_withheld", "below_trust_floor", "tighten_only"]);
|
|
81
82
|
/**
|
|
82
83
|
* Does a value from `source` for `category` (or one of its declared `member`s; `value` = the candidate value, for a value-directional member)
|
|
83
84
|
* enter the effective settings, given the workspace trust reading? The rule is in the file header; the data is {@link SETTINGS_SOURCE_CONTRACT}
|
package/dist/settings-units.js
CHANGED
|
@@ -60,8 +60,9 @@ import { classifyHooksConfig } from "./hooks-config.js";
|
|
|
60
60
|
import { captureJson, captureStringArray, ownEntriesOf } from "./own-key-read.js";
|
|
61
61
|
import { isPlainJsonObject } from "./plain-json-object.js";
|
|
62
62
|
import { SAFETY_MERGE_SPEC, resolveMemberTighten, tightenVerdict } from "./safety-merge-spec.js";
|
|
63
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
63
64
|
/** The settings-document units (see the file header). `path` is the unit's place in a settings document. */
|
|
64
|
-
export const SETTINGS_UNITS = {
|
|
65
|
+
export const SETTINGS_UNITS = deepFreeze({
|
|
65
66
|
permissions: { path: ["permissions"], category: "permissions", reads: "members" },
|
|
66
67
|
permissionMode: { path: ["permissions", "defaultMode"], category: "permissionMode", reads: "whole", reading: "permissionMode" },
|
|
67
68
|
additionalDirectories: { path: ["permissions", "additionalDirectories"], category: "sandboxNetwork", reads: "whole", reading: "stringList" },
|
|
@@ -72,7 +73,7 @@ export const SETTINGS_UNITS = {
|
|
|
72
73
|
env: { path: ["env"], category: "env", reads: "whole", reading: "envMap" },
|
|
73
74
|
model: { path: ["model"], category: "model", reads: "whole", reading: "nonEmptyString" },
|
|
74
75
|
outputStyle: { path: ["outputStyle"], category: "ui", reads: "whole", reading: "nonEmptyString" },
|
|
75
|
-
};
|
|
76
|
+
});
|
|
76
77
|
/** The one place a unit + optional member resolves to what is being asked about — the row and its comparator. Fail-closed
|
|
77
78
|
* and loud on every misaddressing: an unknown unit (own-property lookup — `"__proto__"` is unknown, not Object.prototype),
|
|
78
79
|
* a `members` unit without a member, a `whole` unit with one, a `member` unit given another one, an undeclared member
|
package/dist/types.d.ts
CHANGED
|
@@ -118,14 +118,14 @@ export type SealedApiKey = z.infer<typeof SealedApiKey>;
|
|
|
118
118
|
export type ParseTransparentValidator = "engine-ingest" | "consumer";
|
|
119
119
|
/** {@link PARSE_TRANSPARENT_KEYS} 的一行。 */
|
|
120
120
|
export interface ParseTransparentKey {
|
|
121
|
-
domain: DomainName;
|
|
121
|
+
readonly domain: DomainName;
|
|
122
122
|
/** 从域根算起的路径,`[]` = 数组条目,`{}` = Record 值(与门里的派生形逐字一致)。 */
|
|
123
|
-
path: string;
|
|
123
|
+
readonly path: string;
|
|
124
124
|
/** 这个键从哪一版起是解析透明的。 */
|
|
125
|
-
since: string;
|
|
126
|
-
validatedBy: ParseTransparentValidator;
|
|
125
|
+
readonly since: string;
|
|
126
|
+
readonly validatedBy: ParseTransparentValidator;
|
|
127
127
|
/** 为什么它在这里不设形判据 —— 一句,带真实后果。 */
|
|
128
|
-
why: string;
|
|
128
|
+
readonly why: string;
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
131
|
* **解析透明键登记表** —— 本包收下但**不校验其形**的键,一处列全,连同「谁校验」。
|
|
@@ -509,7 +509,7 @@ export declare const ScenarioConfig: z.ZodObject<{
|
|
|
509
509
|
export type ScenarioConfig = z.infer<typeof ScenarioConfig>;
|
|
510
510
|
/** Platform credential surfaces a system may NEVER deliver into (红线1 — would let a publish overwrite the
|
|
511
511
|
* platform's own secrets). Runtime delivery (S3) re-checks; this is the save-time half. */
|
|
512
|
-
export declare const DELIVER_DENYLIST:
|
|
512
|
+
export declare const DELIVER_DENYLIST: ReadonlySet<string>;
|
|
513
513
|
export declare const SystemEntry: z.ZodObject<{
|
|
514
514
|
name: z.ZodString;
|
|
515
515
|
callsWorkers: z.ZodPrefault<z.ZodArray<z.ZodString>>;
|
|
@@ -737,7 +737,7 @@ export type EntitlementRuntimeCaps = z.infer<typeof EntitlementRuntimeCaps>;
|
|
|
737
737
|
* `allow*` ceilings tighten toward `false` (disabled wins); `forceDurableGate` tightens toward `true` (forced
|
|
738
738
|
* wins). Single source for the merge polarity so resolvers don't hardcode it. `Record<keyof …>` = a new cap
|
|
739
739
|
* without an entry is a COMPILE error (no silent wrong-direction merge). */
|
|
740
|
-
export declare const RUNTIME_CAP_STRICT: Record<keyof EntitlementRuntimeCaps, boolean
|
|
740
|
+
export declare const RUNTIME_CAP_STRICT: Readonly<Record<keyof EntitlementRuntimeCaps, boolean>>;
|
|
741
741
|
/** A named entitlement bundle (a `tier`, or a composable `role`). Bind a `roster` to inherit its model/skill/mcp
|
|
742
742
|
* visibility for free; explicit allowlists intersect on top. Edit a tier once → re-prices everyone on it. */
|
|
743
743
|
export declare const EntitlementTier: z.ZodObject<{
|
|
@@ -1422,7 +1422,7 @@ export declare const WorkerLifecycle: z.ZodObject<{
|
|
|
1422
1422
|
export type WorkerLifecycle = z.infer<typeof WorkerLifecycle>;
|
|
1423
1423
|
/** 结构化 WorkerSpec 字段已经产出的 env 名 —— 通用 `env` / `secretEnv` 逃生口**不许**设它们(用专属字段)。由
|
|
1424
1424
|
* `RESERVED_ENV_FIELD`(名 → 唯一写位)的键派生;增删理由见那张表的头注。 */
|
|
1425
|
-
export declare const RESERVED_WORKER_ENV:
|
|
1425
|
+
export declare const RESERVED_WORKER_ENV: ReadonlySet<string>;
|
|
1426
1426
|
/** 一台 worker 的名字(唯一 → 容器名 / compose project / 缺省路由键)—— **唯一**的名字判据。web-admin 在租约 / 用量 /
|
|
1427
1427
|
* discovery `?worker=` 等面上校验外部传来的 worker 名时读它(不抄窄正则)。 */
|
|
1428
1428
|
export declare const WORKER_NAME: z.ZodString;
|
|
@@ -3339,7 +3339,7 @@ export interface ConfigChange {
|
|
|
3339
3339
|
at: string;
|
|
3340
3340
|
summary?: string;
|
|
3341
3341
|
}
|
|
3342
|
-
export declare const DOMAINS: DomainName[];
|
|
3342
|
+
export declare const DOMAINS: readonly DomainName[];
|
|
3343
3343
|
/** The canonical "is this a config domain?" predicate. Use it instead of hard-coding a domain list when
|
|
3344
3344
|
* filtering arbitrary keys (e.g. a `config.d/` directory scan that also turns up the non-domain
|
|
3345
3345
|
* `remote-exec.json`) — `remote-exec` is NOT a domain (it's the exec backend; see writeRemoteExec). */
|