@sema-agent/settings-schema 31.1.0 → 33.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +917 -0
  2. package/README.md +103 -19
  3. package/conformance/VERSION +1 -1
  4. package/conformance/cases/c97-roles-own-proto-key-entry-dropped/expected.json +105 -0
  5. package/conformance/cases/c97-roles-own-proto-key-entry-dropped/input.json +26 -0
  6. package/conformance/cases/c97-roles-own-proto-key-entry-dropped/meta.json +6 -0
  7. package/dist/api/auth.d.ts +1 -1
  8. package/dist/api/feedback.d.ts +3 -3
  9. package/dist/api/feedback.js +3 -2
  10. package/dist/center-refs.d.ts +1 -1
  11. package/dist/center-refs.js +1 -1
  12. package/dist/cli.d.ts +4 -1
  13. package/dist/cli.js +8 -3
  14. package/dist/config-dir-migration.d.ts +17 -1
  15. package/dist/config-dir-migration.js +89 -31
  16. package/dist/config-fns.d.ts +31 -4
  17. package/dist/config-fns.js +180 -24
  18. package/dist/config-root-documents.js +1 -1
  19. package/dist/conformance/contract-adapter.js +18 -1
  20. package/dist/conformance/warnings.d.ts +1 -1
  21. package/dist/conformance/warnings.js +8 -2
  22. package/dist/declared-capture.d.ts +1 -1
  23. package/dist/declared-capture.js +5 -1
  24. package/dist/device-lane-knobs.d.ts +57 -0
  25. package/dist/device-lane-knobs.js +127 -0
  26. package/dist/execution-lanes.d.ts +3 -1
  27. package/dist/execution-lanes.js +3 -1
  28. package/dist/fleet.d.ts +5 -5
  29. package/dist/fleet.js +4 -3
  30. package/dist/hooks-config.d.ts +47 -23
  31. package/dist/hooks-config.js +93 -134
  32. package/dist/hooks.d.ts +26 -22
  33. package/dist/hooks.js +17 -8
  34. package/dist/host-path.d.ts +9 -5
  35. package/dist/host-path.js +9 -20
  36. package/dist/index.d.ts +2 -0
  37. package/dist/index.js +2 -0
  38. package/dist/ip-address.d.ts +19 -0
  39. package/dist/ip-address.js +28 -0
  40. package/dist/loopback.d.ts +3 -11
  41. package/dist/loopback.js +11 -12
  42. package/dist/mcp-request-entry.js +4 -6
  43. package/dist/migration-receipt.d.ts +1 -1
  44. package/dist/migration-receipt.js +1 -1
  45. package/dist/one-time-migrations.d.ts +1 -1
  46. package/dist/one-time-migrations.js +257 -62
  47. package/dist/plain-json-object.d.ts +5 -8
  48. package/dist/plain-json-object.js +5 -8
  49. package/dist/read-sentences.d.ts +66 -0
  50. package/dist/read-sentences.js +85 -0
  51. package/dist/record-seat.d.ts +35 -0
  52. package/dist/record-seat.js +97 -0
  53. package/dist/reserved-member-name.d.ts +8 -3
  54. package/dist/reserved-member-name.js +10 -3
  55. package/dist/retired-envs.js +10 -0
  56. package/dist/retired-form.d.ts +2 -0
  57. package/dist/retired-form.js +4 -0
  58. package/dist/safety-merge-spec.d.ts +11 -3
  59. package/dist/safety-merge-spec.js +3 -2
  60. package/dist/types.d.ts +405 -113
  61. package/dist/types.js +135 -76
  62. package/docs/API-SURFACE.md +25 -6
  63. package/docs/CC-DIVERGENCE.md +11 -2
  64. package/docs/CONFORMANCE.md +4 -4
  65. package/docs/CONSUMER-INTEGRATION.md +185 -6
  66. package/llms-full.txt +35 -20
  67. package/llms.txt +15 -8
  68. package/package.json +7 -6
@@ -0,0 +1,85 @@
1
+ import { stripControlAndBidi } from "./control-and-bidi.js"; // 一行回显的剥除集(唯一一份):句子里回显的串(zod 句子里的键名 / 值)不许带换行与双向控制符
2
+ import { isJsonArray } from "./plain-json-object.js"; // 形状只问座位:这里的「是不是数组」不裸写 `Array.isArray`(全包反向门)
3
+ /** 一行:空白(含换行、制表)的每一段折成一个空格,再剥掉一行回显的剥除集({@link stripControlAndBidi}:C0、DEL、双向控制符),两端去空白。句子里回显的任何一串(键名、值、别人的句子)都经它,一个换行伪造不出第二行。 */
4
+ const oneLine = (text) => stripControlAndBidi(text.replace(/\s+/g, " ")).trim();
5
+ /**
6
+ * 一条 zod issue 的**一句话**(不含换行):联合(`invalid_union`)自己只说 `Invalid input`,真正的拒句在各选项的 issue 里 —— 取各选项第一条的句子(去重,至多三条,用 ` / ` 连);
7
+ * 别的 issue 就是它自己的 `message`(换行折成空格)。出门前这些句子已经过本包唯一的脱敏器(`sanitizeZodError` 递归进联合的 `errors`),这里只读不改。
8
+ */
9
+ export function issueSentence(issue, depth = 0) {
10
+ if (issue.code === "invalid_union" && isJsonArray(issue.errors) && depth < 4) {
11
+ const branches = [];
12
+ for (const branch of issue.errors) {
13
+ const first = isJsonArray(branch) ? branch[0] : undefined;
14
+ if (first !== undefined && typeof first.message === "string")
15
+ branches.push(issueSentence(first, depth + 1));
16
+ }
17
+ const distinct = [...new Set(branches)].slice(0, 3);
18
+ if (distinct.length > 0)
19
+ return distinct.join(" / ");
20
+ }
21
+ return oneLine(issue.message);
22
+ }
23
+ /** 被丢 / 触发条目的身份,一小段字:只说可披露的名与 id(扣名只说「有名但不给」);没有可说的 ⇒ `undefined`。 */
24
+ export function identityText(identity) {
25
+ if (identity === undefined)
26
+ return undefined;
27
+ const parts = [];
28
+ if (identity.name !== undefined)
29
+ parts.push(`name ${JSON.stringify(identity.name)}`);
30
+ else if (identity.nameWithheld === true)
31
+ parts.push("name withheld");
32
+ if (identity.id !== undefined)
33
+ parts.push(`id ${JSON.stringify(identity.id)}`);
34
+ else if (identity.idWithheld === true)
35
+ parts.push("id withheld");
36
+ return parts.length === 0 ? undefined : parts.join(", ");
37
+ }
38
+ /** 原因,一段字:最多三条 issue(`<坐标>: <句子>`,坐标是根时只有句子),多出来的写个数。 */
39
+ export function causeText(issues) {
40
+ const shown = issues.slice(0, 3).map((i) => (i.path === "" ? i.sentence : `${i.path}: ${i.sentence}`));
41
+ const more = issues.length - shown.length;
42
+ return more > 0 ? `${shown.join("; ")} (+${more} more)` : shown.join("; ");
43
+ }
44
+ /**
45
+ * `entry-dropped` 的一句话:哪一条(`entry <坐标>`,有身份再接括号)· 为什么 · 后果(其余条目照常)· 出路(在这份文档里手改,改回来就读得到)。
46
+ * `entry` 是 `entry <坐标>`、`identity` 是 {@link identityText} 的答案。
47
+ */
48
+ export function droppedEntrySentence(a) {
49
+ const who = a.identity === undefined ? a.entry : `${a.entry} (${a.identity})`;
50
+ return oneLine(`${who} was dropped from the "${a.domain}" domain: ${a.cause === "" ? "it does not read" : a.cause}; the other entries are read as written — fix it in the "${a.domain}" document by hand to bring it back`);
51
+ }
52
+ /**
53
+ * `domain-defaulted` 的一句话:后果(整域按缺省读)· 为什么(触发的坐标与原因)· 触发的条目是谁(有才写)· 出路(在这份文档里手改)。
54
+ * `culprit` = 触发的条目,一小段字(`entry <坐标>` 加身份),域级的毛病没有。
55
+ */
56
+ export function defaultedDomainSentence(a) {
57
+ const tail = a.culprit === undefined ? "" : ` (${a.culprit})`;
58
+ return oneLine(`the whole "${a.domain}" domain is read as its default: ${a.cause === "" ? "it does not read" : a.cause}${tail}; fix it in the "${a.domain}" document by hand`);
59
+ }
60
+ /** 读腿对「这个域的文档读不进」的处置,一句话(不含换行;`domain` 是闭集里的域名)。两张表各答一半、各自穷举:`fallback` 说整域读不进时怎么办,
61
+ * `salvage` 说先不先丢那一条 —— 两半拼成一句,四种组合各有自己的话(「整域拒 + 逐条丢」的域两半都说)。 */
62
+ export function readConsequenceSentence(domain, stance) {
63
+ const whole = (() => {
64
+ switch (stance.fallback) {
65
+ case "throw":
66
+ return `refuses the whole "${domain}" domain`;
67
+ case "default":
68
+ return `reads the whole "${domain}" domain as its default`;
69
+ default: {
70
+ const unhandled = stance.fallback;
71
+ throw new Error(`readConsequenceSentence: unhandled fallback ${String(unhandled)}`);
72
+ }
73
+ }
74
+ })();
75
+ switch (stance.salvage) {
76
+ case "salvage":
77
+ return `the reader drops the offending entry, or ${whole} when no entry can be dropped`;
78
+ case "none":
79
+ return `the reader ${whole}`;
80
+ default: {
81
+ const unhandled = stance.salvage;
82
+ throw new Error(`readConsequenceSentence: unhandled salvage ${String(unhandled)}`);
83
+ }
84
+ }
85
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 包内私有(不进 `package.json` 的 exports、不进主桶):**记录座位**的唯一铸法 —— 包里每一只「名 → 值」记录(zod 的 `record` / `partialRecord`)都由这里的
3
+ * {@link recordOf} / {@link partialRecordOf} 铸出;`src/` 别处不许出现记录构造(源码门:test 的 record-seat-single-site,按检查器解析符号数,不按行匹配)。
4
+ *
5
+ * 律(一条):记录的成员按**自有属性名**读 —— 名字是保留成员名({@link RESERVED_MEMBER_NAMES},一张表,记录读器与中心引用解析口问同一个谓词)⇒ 这只座位拒。
6
+ * 一个名一条 custom issue,路径停在记录本身:句子是记录读器那一句({@link reservedMemberSentence}),机读词 `params.flaw` = `member_name_reserved`
7
+ * (记录读器的原因词表里那一只,不新铸)。为什么要在 zod 之前读:zod 的 record 读键前先跳过自有键 `__proto__`(键不判、值不判、输出里没有它、不报 issue)——
8
+ * 只靠 record 判,一份带它的文档被读成「没有这一键」:键形门不触发、值 schema 不跑(密钥字面值扫描、授权值的严判),读 parse 结果的消费方看不见它。
9
+ * `constructor` / `prototype` zod 照常判、照常带出,与凭据引用集合、记录读器同表同拒:一只守卫,一个名单。
10
+ * 成员不是纯数据或读不出(不可枚举的自有串键 / 访问器 / 陷阱抛)⇒ 同样判坏,句子是内核那一句(fail-closed:守卫看不清就不担保,也不调 getter);
11
+ * 是对象却不是本包认的朴素对象(原型链更深、类实例、读形状就抛)⇒ 拒(zod 的记录按另一套判法收下其中一部分 —— 守卫让路就是让它在没读过名字的对象上跳过 `__proto__`);
12
+ * `null` / 数组 / 原始值 ⇒ 原样交给 record,拒句不变。
13
+ * 守卫有一条就使这只座位判不过:管道在输入侧停住,record 与挂在座位上的检查都不再跑(一条结论,不叠第二条)。
14
+ * 边界(如实):守卫读的是**输入**键 —— 键 schema 若改写键(`.trim()` 一类),改写后才成为 `__proto__` 的键仍被 zod 跳过;所以记录座位的键 schema 不许改写键(今天 23 座都不改写)。
15
+ *
16
+ * 同一条律的另三处读者:能当记录键的名字的判官(worker 名、目录条目名、HTTP 头名都从 {@link RECORD_MEMBER_NAME} 起步:名字在建的那一刻就拒,与以它作键的座位同答)·
17
+ * 逐条抢救的键判(config-fns 的 `judgeKey` 先问 {@link RECORD_MEMBER_NAME}:Record 条目集合里名叫保留名的那一格整条丢,与座位同答)·
18
+ * 按声明键投影的校验(`./declared-capture` 的白名单门按守卫函数的**身份**认座位 —— {@link isRecordSeat} —— 放行到里面的 record:守卫只读自有名,
19
+ * 那里交给校验器的深拷副本保留自有 `__proto__`、拒隐藏 / 访问器成员,两边同答)。
20
+ */
21
+ import { z } from "zod";
22
+ /** 一只记录座位:键 schema × 值 schema(与 zod 的 `record` 同参;`params` 原样交给它)。 */
23
+ export declare function recordOf<K extends z.core.$ZodRecordKey, V extends z.core.SomeType>(key: K, value: V, params?: string | z.core.$ZodRecordParams): z.ZodPreprocess<z.ZodRecord<K, V>, z.core.$InferZodRecordInput<K, V>>;
24
+ /** 一只键可缺席的记录座位(枚举键:写哪个键就是哪个键,其余缺席;与 zod 的 `partialRecord` 同参)。 */
25
+ export declare function partialRecordOf<K extends z.core.$ZodRecordKey, V extends z.core.SomeType>(key: K, value: V, params?: string | z.core.$ZodRecordParams): z.ZodPreprocess<z.ZodRecord<K & z.core.$partial, V>, z.core.$InferZodRecordInput<K & z.core.$partial, V>>;
26
+ /** 这只 schema 是不是记录座位:输入侧恰是座位守卫本身(按函数的**身份**认,且输入侧没有挂别的检查 —— 挂上去的检查能看见调用方的值)、出侧是 record。
27
+ * 别的输入侧变换、守卫外面再挂检查的管道、出侧不是 record 的管道,都不是座位。 */
28
+ export declare function isRecordSeat(schema: unknown): boolean;
29
+ /**
30
+ * 记录成员名的判官:保留名 ⇒ 与座位守卫同一条 issue,且是这一判的唯一结论(issue 不续:后面挂的形状判不再跑,不叠第二条)。
31
+ * 两种读者,同一只:逐条抢救的键判先问它,再问记录自己的键 schema;**能当记录键的名字**的判官从它起步(`RECORD_MEMBER_NAME.min(1).regex(…)`)——
32
+ * worker 名、目录条目名、HTTP 头名:名字在建的那一刻就拒,不会建得出、到了以它作键的座位才被拒。座位 × 键判官的对齐由 test 的
33
+ * record-seat-key-judges 两向核(座位表 = 普查到的座位;每只键判官读这里)。
34
+ */
35
+ export declare const RECORD_MEMBER_NAME: z.ZodString;
@@ -0,0 +1,97 @@
1
+ /**
2
+ * 包内私有(不进 `package.json` 的 exports、不进主桶):**记录座位**的唯一铸法 —— 包里每一只「名 → 值」记录(zod 的 `record` / `partialRecord`)都由这里的
3
+ * {@link recordOf} / {@link partialRecordOf} 铸出;`src/` 别处不许出现记录构造(源码门:test 的 record-seat-single-site,按检查器解析符号数,不按行匹配)。
4
+ *
5
+ * 律(一条):记录的成员按**自有属性名**读 —— 名字是保留成员名({@link RESERVED_MEMBER_NAMES},一张表,记录读器与中心引用解析口问同一个谓词)⇒ 这只座位拒。
6
+ * 一个名一条 custom issue,路径停在记录本身:句子是记录读器那一句({@link reservedMemberSentence}),机读词 `params.flaw` = `member_name_reserved`
7
+ * (记录读器的原因词表里那一只,不新铸)。为什么要在 zod 之前读:zod 的 record 读键前先跳过自有键 `__proto__`(键不判、值不判、输出里没有它、不报 issue)——
8
+ * 只靠 record 判,一份带它的文档被读成「没有这一键」:键形门不触发、值 schema 不跑(密钥字面值扫描、授权值的严判),读 parse 结果的消费方看不见它。
9
+ * `constructor` / `prototype` zod 照常判、照常带出,与凭据引用集合、记录读器同表同拒:一只守卫,一个名单。
10
+ * 成员不是纯数据或读不出(不可枚举的自有串键 / 访问器 / 陷阱抛)⇒ 同样判坏,句子是内核那一句(fail-closed:守卫看不清就不担保,也不调 getter);
11
+ * 是对象却不是本包认的朴素对象(原型链更深、类实例、读形状就抛)⇒ 拒(zod 的记录按另一套判法收下其中一部分 —— 守卫让路就是让它在没读过名字的对象上跳过 `__proto__`);
12
+ * `null` / 数组 / 原始值 ⇒ 原样交给 record,拒句不变。
13
+ * 守卫有一条就使这只座位判不过:管道在输入侧停住,record 与挂在座位上的检查都不再跑(一条结论,不叠第二条)。
14
+ * 边界(如实):守卫读的是**输入**键 —— 键 schema 若改写键(`.trim()` 一类),改写后才成为 `__proto__` 的键仍被 zod 跳过;所以记录座位的键 schema 不许改写键(今天 23 座都不改写)。
15
+ *
16
+ * 同一条律的另三处读者:能当记录键的名字的判官(worker 名、目录条目名、HTTP 头名都从 {@link RECORD_MEMBER_NAME} 起步:名字在建的那一刻就拒,与以它作键的座位同答)·
17
+ * 逐条抢救的键判(config-fns 的 `judgeKey` 先问 {@link RECORD_MEMBER_NAME}:Record 条目集合里名叫保留名的那一格整条丢,与座位同答)·
18
+ * 按声明键投影的校验(`./declared-capture` 的白名单门按守卫函数的**身份**认座位 —— {@link isRecordSeat} —— 放行到里面的 record:守卫只读自有名,
19
+ * 那里交给校验器的深拷副本保留自有 `__proto__`、拒隐藏 / 访问器成员,两边同答)。
20
+ */
21
+ import { z } from "zod";
22
+ import { buildQuotedIssue, fixed } from "./quoted-issue.js";
23
+ import { NOT_PLAIN_DATA, UNINSPECTABLE, ownEntriesOf } from "./own-key-read.js";
24
+ import { jsonShapeOf } from "./plain-json-object.js";
25
+ import { isReservedMemberName, reservedMemberSentence } from "./reserved-member-name.js";
26
+ /** 座位拒保留名时的机读词 —— 记录读器的原因词表里那一只(型上钉在那张表里,不另立词)。 */
27
+ const MEMBER_NAME_RESERVED = "member_name_reserved";
28
+ /** 保留名那一条 issue 的句子与 params(座位守卫与抢救的键判同一只铸法)。 */
29
+ function reservedMemberRefusal(name) {
30
+ const sentence = buildQuotedIssue `${fixed(reservedMemberSentence(name))}`;
31
+ return { ...sentence, params: { ...sentence.params, flaw: MEMBER_NAME_RESERVED } };
32
+ }
33
+ /**
34
+ * 座位守卫(全包唯一一只;{@link isRecordSeat} 按它的身份认座位,所以它是模块级的一个函数,不是每座一个闭包):在 record 之前按自有属性名读成员。
35
+ * 交回原值(不改写):守卫只判,不变换。
36
+ */
37
+ function refuseReservedMembers(input, ctx) {
38
+ const shape = jsonShapeOf(input);
39
+ switch (shape) {
40
+ case "plain":
41
+ break;
42
+ case "null":
43
+ case "primitive":
44
+ case "array":
45
+ return input; // 记录自己拒(`invalid_type`,句子不变)
46
+ // 本包不算朴素的对象(原型链更深、类实例、函数、读形状就抛):zod 的记录对其中一部分照收(它按 `constructor` 判朴素,与本包的座位判法不同)——
47
+ // 守卫在这里让路,就是让 zod 在一份守卫没读过名字的对象上跳过 `__proto__`。所以不是纯数据就拒,不交给另一套判法。
48
+ case "non_plain_object":
49
+ ctx.addIssue({ code: "custom", input, ...buildQuotedIssue `${fixed(NOT_PLAIN_DATA)}` });
50
+ return input;
51
+ case "uninspectable":
52
+ ctx.addIssue({ code: "custom", input, ...buildQuotedIssue `${fixed(UNINSPECTABLE)}` });
53
+ return input;
54
+ default: {
55
+ const unhandled = shape;
56
+ throw new Error(`refuseReservedMembers: unhandled shape ${String(unhandled)}`);
57
+ }
58
+ }
59
+ const members = ownEntriesOf(input);
60
+ if (!members.ok) {
61
+ ctx.addIssue({ code: "custom", input, ...buildQuotedIssue `${fixed(members.sentence)}` });
62
+ return input;
63
+ }
64
+ for (const [name] of members.value)
65
+ if (isReservedMemberName(name))
66
+ ctx.addIssue({ code: "custom", input, ...reservedMemberRefusal(name) });
67
+ return input;
68
+ }
69
+ /** 给一只记录装上守卫。输入型保留为记录自己的输入型(`z.input` 不退成 `unknown`)。 */
70
+ function seat(record) {
71
+ return z.preprocess(refuseReservedMembers, record);
72
+ }
73
+ /** 一只记录座位:键 schema × 值 schema(与 zod 的 `record` 同参;`params` 原样交给它)。 */
74
+ export function recordOf(key, value, params) {
75
+ return seat(z.record(key, value, params));
76
+ }
77
+ /** 一只键可缺席的记录座位(枚举键:写哪个键就是哪个键,其余缺席;与 zod 的 `partialRecord` 同参)。 */
78
+ export function partialRecordOf(key, value, params) {
79
+ return seat(z.partialRecord(key, value, params));
80
+ }
81
+ /** 这只 schema 是不是记录座位:输入侧恰是座位守卫本身(按函数的**身份**认,且输入侧没有挂别的检查 —— 挂上去的检查能看见调用方的值)、出侧是 record。
82
+ * 别的输入侧变换、守卫外面再挂检查的管道、出侧不是 record 的管道,都不是座位。 */
83
+ export function isRecordSeat(schema) {
84
+ if (!(schema instanceof z.ZodPipe) || !(schema.in instanceof z.ZodTransform) || !(schema.out instanceof z.ZodRecord))
85
+ return false;
86
+ return schema.in._zod.def.transform === refuseReservedMembers && (schema.in._zod.def.checks ?? []).length === 0;
87
+ }
88
+ /**
89
+ * 记录成员名的判官:保留名 ⇒ 与座位守卫同一条 issue,且是这一判的唯一结论(issue 不续:后面挂的形状判不再跑,不叠第二条)。
90
+ * 两种读者,同一只:逐条抢救的键判先问它,再问记录自己的键 schema;**能当记录键的名字**的判官从它起步(`RECORD_MEMBER_NAME.min(1).regex(…)`)——
91
+ * worker 名、目录条目名、HTTP 头名:名字在建的那一刻就拒,不会建得出、到了以它作键的座位才被拒。座位 × 键判官的对齐由 test 的
92
+ * record-seat-key-judges 两向核(座位表 = 普查到的座位;每只键判官读这里)。
93
+ */
94
+ export const RECORD_MEMBER_NAME = z.string().superRefine((name, ctx) => {
95
+ if (isReservedMemberName(name))
96
+ ctx.addIssue({ code: "custom", continue: false, ...reservedMemberRefusal(name) });
97
+ });
@@ -1,13 +1,18 @@
1
1
  /**
2
2
  * 包内私有叶子模块(运行期只 import 包内私有的零 import 叶 `./deep-freeze`,浏览器安全;不进 `package.json` 的 exports,主桶经 `./mcp-request-entry` 转出这里的公开名):
3
- * **一个名字能不能作「名 → 串」记录的成员名**的唯一判据 —— 原型链上的三个名字永远不能:`__proto__`(按赋值拷贝会变成原型;zod 的 record 读键前先跳过它、不判它的值)、
3
+ * **一个名字能不能作「名 → 值」记录的成员名**的唯一判据 —— 原型链上的三个名字永远不能:`__proto__`(按赋值拷贝会变成原型;zod 的 record 读键前先跳过它、不判它的值)、
4
4
  * `constructor` / `prototype`(读方对普通对象做 `obj[名]` 时撞上原型成员)。
5
- * 三个读口问它,同一张表、同一个答案:域 schema 的凭据引用集合(`./types` 的 `credentialRefs`:在场 ⇒ 集合坏)· 公开的记录读器(`./mcp-request-entry` 的 `readPlainStringRecord` /
5
+ * 每个读口问它,同一张表、同一个谓词、同一句话(处置各在读口):包里的每一只 schema 记录座位(`./record-seat` 的守卫:在场 ⇒ 座位拒)· 能当记录键的名字的判官
6
+ * (worker 名、目录条目名、HTTP 头名,从 `./record-seat` 的成员名判官起步:名字本身拒)· 公开的记录读器(`./mcp-request-entry` 的 `readPlainStringRecord` /
6
7
  * `isStringRecord`,请求面传输的 `env` / `headers` 同读:剔出副本并点名)· 中心引用解析口(`./center-refs`,经记录读器:在场 ⇒ `refs_unreadable`)。
7
- * 住在叶子里,是因为 `./types` 与 `./mcp-request-entry` 都要它,而后者反过来引 `./types`。
8
+ * 不问它的「名 → 值」读口(已知边界,照收):钩子分类器的记录形 / 任意值形字段(`./hooks-config`)· 设置单元的环境表(`./settings-units`)·
9
+ * 目录条目的自由形值(`./types` 的 `extraBody` / `headers` / `compat`:键的词表归提供方)。
10
+ * 住在叶子里,是因为 `./record-seat`(`./types` 引它)与 `./mcp-request-entry` 都要它,而后者反过来引 `./types`。
8
11
  */
9
12
  /** 保留成员名,闭集。 */
10
13
  export declare const RESERVED_MEMBER_NAMES: readonly ["__proto__", "constructor", "prototype"];
11
14
  export type ReservedMemberName = (typeof RESERVED_MEMBER_NAMES)[number];
12
15
  /** 这个名字是保留成员名吗(大小写敏感:`Constructor` / `X-Prototype` 不是)。 */
13
16
  export declare function isReservedMemberName(name: string): name is ReservedMemberName;
17
+ /** 保留成员名的原因句(一个名一句)—— 记录读器、请求面传输读器与每一只记录座位说同一句(包内私有,不进主桶)。 */
18
+ export declare function reservedMemberSentence(name: ReservedMemberName): string;
@@ -1,10 +1,13 @@
1
1
  /**
2
2
  * 包内私有叶子模块(运行期只 import 包内私有的零 import 叶 `./deep-freeze`,浏览器安全;不进 `package.json` 的 exports,主桶经 `./mcp-request-entry` 转出这里的公开名):
3
- * **一个名字能不能作「名 → 串」记录的成员名**的唯一判据 —— 原型链上的三个名字永远不能:`__proto__`(按赋值拷贝会变成原型;zod 的 record 读键前先跳过它、不判它的值)、
3
+ * **一个名字能不能作「名 → 值」记录的成员名**的唯一判据 —— 原型链上的三个名字永远不能:`__proto__`(按赋值拷贝会变成原型;zod 的 record 读键前先跳过它、不判它的值)、
4
4
  * `constructor` / `prototype`(读方对普通对象做 `obj[名]` 时撞上原型成员)。
5
- * 三个读口问它,同一张表、同一个答案:域 schema 的凭据引用集合(`./types` 的 `credentialRefs`:在场 ⇒ 集合坏)· 公开的记录读器(`./mcp-request-entry` 的 `readPlainStringRecord` /
5
+ * 每个读口问它,同一张表、同一个谓词、同一句话(处置各在读口):包里的每一只 schema 记录座位(`./record-seat` 的守卫:在场 ⇒ 座位拒)· 能当记录键的名字的判官
6
+ * (worker 名、目录条目名、HTTP 头名,从 `./record-seat` 的成员名判官起步:名字本身拒)· 公开的记录读器(`./mcp-request-entry` 的 `readPlainStringRecord` /
6
7
  * `isStringRecord`,请求面传输的 `env` / `headers` 同读:剔出副本并点名)· 中心引用解析口(`./center-refs`,经记录读器:在场 ⇒ `refs_unreadable`)。
7
- * 住在叶子里,是因为 `./types` 与 `./mcp-request-entry` 都要它,而后者反过来引 `./types`。
8
+ * 不问它的「名 → 值」读口(已知边界,照收):钩子分类器的记录形 / 任意值形字段(`./hooks-config`)· 设置单元的环境表(`./settings-units`)·
9
+ * 目录条目的自由形值(`./types` 的 `extraBody` / `headers` / `compat`:键的词表归提供方)。
10
+ * 住在叶子里,是因为 `./record-seat`(`./types` 引它)与 `./mcp-request-entry` 都要它,而后者反过来引 `./types`。
8
11
  */
9
12
  import { deepFreeze } from "./deep-freeze.js";
10
13
  /** 保留成员名,闭集。 */
@@ -13,3 +16,7 @@ export const RESERVED_MEMBER_NAMES = deepFreeze(["__proto__", "constructor", "pr
13
16
  export function isReservedMemberName(name) {
14
17
  return RESERVED_MEMBER_NAMES.includes(name);
15
18
  }
19
+ /** 保留成员名的原因句(一个名一句)—— 记录读器、请求面传输读器与每一只记录座位说同一句(包内私有,不进主桶)。 */
20
+ export function reservedMemberSentence(name) {
21
+ return `no member of a declaration may be named "${name}"`;
22
+ }
@@ -31,6 +31,8 @@ import { WEB_ADMIN_ENV } from "./web-admin-env.js";
31
31
  /** 墓碑拒启码(机读;拒句方括号里)。 */
32
32
  export const RETIRED_ENV_REFUSAL_CODE = "config.env_key_retired";
33
33
  const OA_REMOVED = "the OA scenario was removed in 5.0.0";
34
+ /** 调度两只旧旋钮共用的理由句(一句话说清变成了什么、怎么写;会原样进拒启句,所以不带点分版本号)。 */
35
+ const SCHEDULER_RESIDENT_WHY = "whether anything fires due scheduled records is now one declaration instead of a per-capability opt-out: write SCHEDULER_RESIDENT_TRIGGER=true when a resident process (the terminal's interactive screen) fires them, and leave it unset when none does — then the scheduling tools are not mounted at all";
34
36
  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)`;
35
37
  export const RETIRED_ENVS = deepFreeze([
36
38
  ["TIDB_HOST", "MYSQL_HOST", "renamed"],
@@ -93,6 +95,14 @@ export const RETIRED_ENVS = deepFreeze([
93
95
  // 渲染方在全部 worker 换完之前留在上一版契约包(它还要给没换的 worker 写这只键、对已换的不写),全部换完再提本版;没法按 worker 分别渲染的渲染方先删键再升级。
94
96
  // 理由句只说这个能力为什么没了、不带点分版本号(会原样进拒启句;与 LSP_ENABLED / STREAM_APPROVAL_ENABLED / MODEL_DEGRADE_REACTIVE 三行同约定):版本事实写在这里与 CHANGELOG。
95
97
  ["SESSION_BOX_ENGINE_FRAMES", "the session-box engine-frames switch was retired: every process that drains session boxes reads engine frames, so that is a fact of the build rather than a deployment choice — there is nothing left to switch", "removed"],
98
+ // 调度的两只「按能力退出」旋钮(会话唤醒 / 会话寿命记录:缺省开,没有常驻进程的壳设 false 关掉)并成一只声明:有没有常驻进程在替到点的计划记录触发(终端的交互屏就是一个),
99
+ // 由 `SCHEDULER_RESIDENT_TRIGGER` 一处说了算;没有常驻进程就不设它,那时调度类工具整组不挂载,不再靠逐项关。值语义变了(逐项「退出」变成整体「声明」)⇒ `replaced`,不是 `renamed`:照抄旧值过去是另一个意思。
100
+ // 提了本版契约包的那一版服务端(按计划是 7.156.0;服务端的排期,本包不验证服务端行为)起不再读这两只名:读侧同代要求 —— 更老的服务端仍把它们当活旋钮读;服务端精确钉契约包版本,所以这两行只对提了本版契约包的服务端生效。
101
+ // 本包的 worker 规格写闸不分目标服务端的代,而提了本版契约包的服务端见到任一只旧名即拒启(拒句点名旧名、指到新名)⇒ 给 worker 渲染 env 的一方逐台做:换到带本版契约包的服务端与从这台 worker 的环境里换掉旧名(按需写新名、或删掉)是同一步;
102
+ // 渲染方在它渲染的 worker 全部换完之前留在上一版契约包(它还要给没换的 worker 写旧名、对已换的不写),全部换完再提本版;没法按 worker 分别渲染的渲染方先改环境、再升级。
103
+ // 理由句只说为什么换成一只声明、不带点分版本号(会原样进拒启句;与 SESSION_BOX_ENGINE_FRAMES / LSP_ENABLED / STREAM_APPROVAL_ENABLED / MODEL_DEGRADE_REACTIVE 同约定;两行逐字同一句):版本事实写在这里与 CHANGELOG。
104
+ ["SCHEDULER_SESSION_WAKEUP", "SCHEDULER_RESIDENT_TRIGGER", "replaced", SCHEDULER_RESIDENT_WHY],
105
+ ["SCHEDULER_SESSION_LIFETIME", "SCHEDULER_RESIDENT_TRIGGER", "replaced", SCHEDULER_RESIDENT_WHY],
96
106
  ]);
97
107
  /** 墓碑表 → wire 投影(纯数据)。**同一张表、同序**;族是闭集,穷举 switch(加一族不写这里 ⇒ 编译红)。 */
98
108
  export function buildRetiredEnvWire() {
@@ -32,6 +32,8 @@ export interface RetiredForm {
32
32
  /** 改写存量的一次性迁移 id(`./one-time-migrations` 的闭集;到期门核它在登记表里)。**只在那条迁移还在时写**:迁移到期删了,删码那一车删掉这一格。 */
33
33
  readonly migration?: OneTimeMigrationId;
34
34
  }
35
+ /** 一个retired 域的**出路**(拒句尾,一句一行):把还要用的值手抄到今天的位置上,再删掉旧文档(本地根上它就是 `config.d/<域>.json`)。retired 域的拒句 = 墓碑句 + 这一句,读写两面同一句。 */
36
+ export declare function retiredDomainWayOut(domain: string): string;
35
37
  export declare function retiredFormSentence(form: string, t: RetiredForm): string;
36
38
  /** 墓碑表的一行:`key` 是墓碑字段在它所在对象里的点路径(例:`runtime.sessionBackend`),`sentence` 是它的拒句整句(= 那条 zod issue 的 message)。 */
37
39
  export interface RetiredKeyRow {
@@ -27,6 +27,10 @@ export function migrateCommandFor(configDir) {
27
27
  export function migrationSignpost(migration, before) {
28
28
  return `data stored before ${before}: run the one-time migration ${migration} (@sema-agent/settings-schema/one-time-migrations, or ${MIGRATE_COMMAND_TEMPLATE})`;
29
29
  }
30
+ /** 一个retired 域的**出路**(拒句尾,一句一行):把还要用的值手抄到今天的位置上,再删掉旧文档(本地根上它就是 `config.d/<域>.json`)。retired 域的拒句 = 墓碑句 + 这一句,读写两面同一句。 */
31
+ export function retiredDomainWayOut(domain) {
32
+ return `copy the values you still need to those keys by hand, then delete the "${domain}" document (on a local root: config.d/${domain}.json)`;
33
+ }
30
34
  export function retiredFormSentence(form, t) {
31
35
  const head = `${form} was retired in ${t.retiredIn} — now ${t.now}`;
32
36
  return t.migration === undefined ? head : `${head}; ${migrationSignpost(t.migration, t.retiredIn)}`;
@@ -62,7 +62,7 @@
62
62
  * (v2-design §4:74 lists it in `KeyContract.minTrust`; §2:36 — session/task are runtime overlays, never files):
63
63
  * the loosest floor, "any layer including the task overlay may set this". No row of {@link SAFETY_MERGE_SPEC}
64
64
  * uses it today (the frozen-1.1.0 conformance pin holds that). The enum's DECLARATION ORDER stays what 1.1.0
65
- * published, `task` appended — reordering would be breaking ([5807] ②) and the declaration order is NOT the
65
+ * published, `task` appended — reordering would be breaking and the declaration order is NOT the
66
66
  * ladder anyway; only {@link trustRank} is.
67
67
  */
68
68
  import { z } from "zod";
@@ -313,7 +313,7 @@ export declare const MergeCategorySpec: z.ZodObject<{
313
313
  severity: "severity";
314
314
  shellGate: "shellGate";
315
315
  }>>;
316
- members: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
316
+ members: z.ZodOptional<z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodObject<{
317
317
  direction: z.ZodEnum<{
318
318
  loosen: "loosen";
319
319
  tighten: "tighten";
@@ -338,7 +338,15 @@ export declare const MergeCategorySpec: z.ZodObject<{
338
338
  }>;
339
339
  }, z.core.$strip>>;
340
340
  list: z.ZodOptional<z.ZodLiteral<true>>;
341
- }, z.core.$strip>>>;
341
+ }, z.core.$strip>>, Record<string, {
342
+ direction: "loosen" | "tighten";
343
+ minTrust?: "local" | "session" | "global" | "project" | "managed" | "task" | undefined;
344
+ boolPole?: {
345
+ strict: boolean;
346
+ minTrust: "local" | "session" | "global" | "project" | "managed" | "task";
347
+ } | undefined;
348
+ list?: true | undefined;
349
+ }>>>;
342
350
  }, z.core.$strip>;
343
351
  export type MergeCategorySpec = ReadonlyDeep<z.infer<typeof MergeCategorySpec>>;
344
352
  /** The category spec. Keys = the unified settings categories both seats map their concrete keys/fields into.
@@ -62,7 +62,7 @@
62
62
  * (v2-design §4:74 lists it in `KeyContract.minTrust`; §2:36 — session/task are runtime overlays, never files):
63
63
  * the loosest floor, "any layer including the task overlay may set this". No row of {@link SAFETY_MERGE_SPEC}
64
64
  * uses it today (the frozen-1.1.0 conformance pin holds that). The enum's DECLARATION ORDER stays what 1.1.0
65
- * published, `task` appended — reordering would be breaking ([5807] ②) and the declaration order is NOT the
65
+ * published, `task` appended — reordering would be breaking and the declaration order is NOT the
66
66
  * ladder anyway; only {@link trustRank} is.
67
67
  */
68
68
  import { z } from "zod";
@@ -70,6 +70,7 @@ import { MAX_HASH_DEPTH, stableStringify } from "./hash.js";
70
70
  import { captureStringArray, dataDescriptor, isAccessorDescriptor, isolatedObject } from "./own-key-read.js";
71
71
  import { jsonShapeOf } from "./plain-json-object.js";
72
72
  import { deepFreeze } from "./deep-freeze.js";
73
+ import { recordOf } from "./record-seat.js";
73
74
  import { WEB_SEARCH_SECTION_KEYS } from "./web-search-section.js";
74
75
  /** How values from different layers/principals combine for a category. */
75
76
  export const MergeShape = z.enum(["denyFirst", "replace", "runAll", "overrideByName", "concat"]);
@@ -347,7 +348,7 @@ export const MergeCategorySpec = z.object({
347
348
  /** 1.1.0 — member-level admission (see the file header). ABSENT ⇒ the category is a whole key: its `minTrust`
348
349
  * admits or rejects the whole value. PRESENT ⇒ each named member is admitted on its own row (fallback to the
349
350
  * category `minTrust` when the row omits one); the member set is closed — {@link membersOf} enumerates it. */
350
- members: z.record(z.string(), MemberAdmission).optional(),
351
+ members: recordOf(z.string(), MemberAdmission).optional(),
351
352
  });
352
353
  /** The category spec. Keys = the unified settings categories both seats map their concrete keys/fields into.
353
354
  * Faithful to settings-core v2-design §3 (the semantic source of record). */