@sema-agent/settings-schema 34.1.0 → 35.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +482 -0
  2. package/README.md +73 -32
  3. package/conformance/VERSION +1 -1
  4. package/conformance/cases/c100-a2a-inside-stale-fingerprint-dropped/expected.json +101 -0
  5. package/conformance/cases/c100-a2a-inside-stale-fingerprint-dropped/input.json +28 -0
  6. package/conformance/cases/c100-a2a-inside-stale-fingerprint-dropped/meta.json +6 -0
  7. package/conformance/cases/c101-a2a-inside-incomplete-dropped/expected.json +113 -0
  8. package/conformance/cases/c101-a2a-inside-incomplete-dropped/input.json +38 -0
  9. package/conformance/cases/c101-a2a-inside-incomplete-dropped/meta.json +6 -0
  10. package/conformance/cases/c102-a2a-inside-incomplete-zero-survivors/expected.json +85 -0
  11. package/conformance/cases/c102-a2a-inside-incomplete-zero-survivors/input.json +34 -0
  12. package/conformance/cases/c102-a2a-inside-incomplete-zero-survivors/meta.json +6 -0
  13. package/conformance/cases/c103-mcp-caller-meta-declared/expected.json +106 -0
  14. package/conformance/cases/c103-mcp-caller-meta-declared/input.json +28 -0
  15. package/conformance/cases/c103-mcp-caller-meta-declared/meta.json +6 -0
  16. package/conformance/cases/c98-a2a-registration-keys-carried/expected.json +163 -0
  17. package/conformance/cases/c98-a2a-registration-keys-carried/input.json +42 -0
  18. package/conformance/cases/c98-a2a-registration-keys-carried/meta.json +6 -0
  19. package/conformance/cases/c99-a2a-preapproval-on-outside-peer-dropped/expected.json +100 -0
  20. package/conformance/cases/c99-a2a-preapproval-on-outside-peer-dropped/input.json +23 -0
  21. package/conformance/cases/c99-a2a-preapproval-on-outside-peer-dropped/meta.json +6 -0
  22. package/conformance/profile/annotations.md +65 -0
  23. package/conformance/profile/loading-rules.md +193 -0
  24. package/conformance/profile/profiles/solo-auto.json +22 -0
  25. package/conformance/profile/profiles/solo-managed.json +21 -0
  26. package/conformance/profile/profiles/tenant-auto.json +36 -0
  27. package/conformance/profile/profiles/tenant-managed.json +36 -0
  28. package/conformance/profile/sema-profile.schema.json +201 -0
  29. package/conformance/profile/tools/mutations.md +62 -0
  30. package/conformance/profile/tools/validate.mjs +1190 -0
  31. package/conformance/profile/vectors/frozen-promises.json +120 -0
  32. package/conformance/profile/vectors/vectors.json +362 -0
  33. package/dist/a2a-peer-identity.d.ts +116 -0
  34. package/dist/a2a-peer-identity.js +182 -0
  35. package/dist/atomic-write.js +1 -1
  36. package/dist/catalog-manages.js +2 -2
  37. package/dist/config-dir-migration.js +0 -1
  38. package/dist/config-document-refusal.d.ts +1 -1
  39. package/dist/config-fns.d.ts +21 -8
  40. package/dist/config-fns.js +16 -3
  41. package/dist/config-root-documents.d.ts +3 -54
  42. package/dist/config-root-documents.js +24 -21
  43. package/dist/config-root-node.d.ts +2 -96
  44. package/dist/config-root-node.js +15 -163
  45. package/dist/conformance/index.d.ts +1 -0
  46. package/dist/conformance/index.js +1 -0
  47. package/dist/conformance/profile.d.ts +55 -0
  48. package/dist/conformance/profile.js +108 -0
  49. package/dist/conformance/warnings.js +1 -1
  50. package/dist/env-model-table.d.ts +3 -3
  51. package/dist/env-model-table.js +5 -5
  52. package/dist/index.d.ts +2 -1
  53. package/dist/index.js +2 -1
  54. package/dist/migration-receipt.d.ts +9 -11
  55. package/dist/migration-receipt.js +4 -5
  56. package/dist/node.d.ts +3 -3
  57. package/dist/node.js +3 -3
  58. package/dist/one-time-migrations.d.ts +3 -4
  59. package/dist/one-time-migrations.js +3 -28
  60. package/dist/retired-envs.js +5 -0
  61. package/dist/safety-merge-spec.d.ts +21 -0
  62. package/dist/safety-merge-spec.js +13 -0
  63. package/dist/scheduler-store-node.d.ts +14 -11
  64. package/dist/scheduler-store-node.js +22 -34
  65. package/dist/scheduler-store.d.ts +21 -6
  66. package/dist/scheduler-store.js +100 -19
  67. package/dist/settings-units.d.ts +9 -0
  68. package/dist/settings-units.js +12 -7
  69. package/dist/types.d.ts +44 -2
  70. package/dist/types.js +70 -2
  71. package/docs/API-SURFACE.md +38 -12
  72. package/docs/CC-DIVERGENCE.md +2 -1
  73. package/docs/CONFORMANCE.md +20 -3
  74. package/docs/CONSUMER-INTEGRATION.md +110 -13
  75. package/llms-full.txt +36 -13
  76. package/llms.txt +15 -5
  77. package/package.json +3 -3
@@ -124,7 +124,7 @@ export function findSecretLeaks(warnings, secrets) {
124
124
  const hay = warnings.map((w) => `${stableKey(projectWarning(w))}${JOINER}${stableKey(fieldsBesideError(w))}${JOINER}${errorText(w)}`).join(JOINER);
125
125
  return secrets.filter((s) => s.length > 0 && hay.includes(s));
126
126
  }
127
- /** 一条告警除 `error` 外的**每一只**键(扫描用,不是投影):投影只留比对用的键(每臂声明的诊断键不进投影 —— `domain-defaulted` 的 `path` / `identity` / `reasonCode` / `unknownKeys` / `truncatedFrom`、`entry-dropped` 的 `unknownKeys` / `truncatedFrom`;见 `WarningProjection`),
127
+ /** 一条告警除 `error` 外的**每一只**键(扫描用,不是投影):投影只留比对用的键(每臂声明的诊断键不进投影 —— `domain-defaulted` 的 `path` / `identity` / `reasonCode` / `unknownKeys` / `truncatedFrom` / `registrationProblems`、`entry-dropped` 的 `unknownKeys` / `truncatedFrom` / `registrationProblems`;见 `WarningProjection`),
128
128
  * 扫描却要看告警带出门的一切 —— 每个 kind 同一个读法,新加的键不会因为不在投影里就躲过扫描。 */
129
129
  function fieldsBesideError(w) {
130
130
  return Object.fromEntries(Object.entries(w).filter(([k]) => k !== "error")); // fromEntries(不是逐键赋值):键名不走原型 setter
@@ -29,10 +29,10 @@ export type EnvCheapSlot = {
29
29
  /** cheap 槽铸出来的 id(不铸 ⇒ `undefined`)。 */
30
30
  export declare function mintedCheapId(slot: EnvCheapSlot): string | undefined;
31
31
  /**
32
- * 包内(不进包根):把 env 模型表的键(缺省四把;调用方只要两槽时只拍两把)**读一次**进一份快照(下标读,同「读到即算」)。计划助手与一次性迁移在**要用的那一刻**拍、
33
- * 此后的每个读法都答自同一份 —— 一只 getter 两次读答两个值时,判「env 表已声明」与列 env 模型不会各读到一个(那样结局与回执自相矛盾);用不到的键不读。
32
+ * 包内(不进包根):把 env 模型表的四把键**读一次**进一份快照(下标读,同「读到即算」)。计划助手在**要用的那一刻**拍、
33
+ * 此后的每个读法都答自同一份 —— 一只 getter 两次读答两个值时,判「env 表已声明」与列 env 模型不会各读到一个(那样结局与回执自相矛盾);表外的键不读。
34
34
  */
35
- export declare function snapshotEnvModelTable(env: EnvSnapshot, keys?: readonly EnvModelTableKey[]): EnvSnapshot;
35
+ export declare function snapshotEnvModelTable(env: EnvSnapshot): EnvSnapshot;
36
36
  /** env 两槽的**唯一读口**(见文件头)。`mainId` = `MODEL_ID`(空串 = 没有主槽)。 */
37
37
  export declare function readEnvModelSlots(env: EnvSnapshot): {
38
38
  readonly mainId: string;
@@ -5,7 +5,7 @@
5
5
  * ## 律
6
6
  * · **env 两槽只在这里读一次**({@link readEnvModelSlots}):`MODEL_ID` 缺席或空串 = 没有主槽(纯空白算在场 —— 与引擎的 env 路由读口同尺);
7
7
  * cheap 槽四态({@link EnvCheapSlot})。「env 模型表已声明」({@link envModelTableDeclared})与角色底({@link buildEnvModelBaseline})都由它派生 ——
8
- * 这道闸的执行方(服务端的本地配置腿)与写者的计划助手调同一份(一次性迁移 SS-M11 只用两槽点名被顶替的 env 模型,铸不铸不看它),不各写一份。env 快照按「读到即算」(下标读;原型分层的快照里继承来的键算在场)。
8
+ * 这道闸的执行方(服务端的本地配置腿)与写者的计划助手调同一份,不各写一份。env 快照按「读到即算」(下标读;原型分层的快照里继承来的键算在场)。
9
9
  * 引擎另有「名册占位 ⇒ env 表算空」一格,那是引擎自己的部署事实,不在本包。
10
10
  * · **计划助手判序**({@link planEnvModelTableWrite}):目标腿不读 `config.d`(remote / none)⇒ 照写 → 候选不管模型面 ⇒ 照写 →
11
11
  * env 表未声明 ⇒ 照写、**不写确认** → 配置根的决定是 `replaced` ⇒ 照写 →
@@ -47,12 +47,12 @@ export function mintedCheapId(slot) {
47
47
  }
48
48
  }
49
49
  /**
50
- * 包内(不进包根):把 env 模型表的键(缺省四把;调用方只要两槽时只拍两把)**读一次**进一份快照(下标读,同「读到即算」)。计划助手与一次性迁移在**要用的那一刻**拍、
51
- * 此后的每个读法都答自同一份 —— 一只 getter 两次读答两个值时,判「env 表已声明」与列 env 模型不会各读到一个(那样结局与回执自相矛盾);用不到的键不读。
50
+ * 包内(不进包根):把 env 模型表的四把键**读一次**进一份快照(下标读,同「读到即算」)。计划助手在**要用的那一刻**拍、
51
+ * 此后的每个读法都答自同一份 —— 一只 getter 两次读答两个值时,判「env 表已声明」与列 env 模型不会各读到一个(那样结局与回执自相矛盾);表外的键不读。
52
52
  */
53
- export function snapshotEnvModelTable(env, keys = Object.values(ENV_MODEL_TABLE_KEYS)) {
53
+ export function snapshotEnvModelTable(env) {
54
54
  const snapshot = isolatedObject(); // the package's copy container (no inherited members to read)
55
- for (const key of keys)
55
+ for (const key of Object.values(ENV_MODEL_TABLE_KEYS))
56
56
  Object.defineProperty(snapshot, key, dataDescriptor(env[key]));
57
57
  return snapshot;
58
58
  }
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * web-admin, the worker service, and the TOC desktop/CLI.
4
4
  */
5
5
  export * from "./types.js";
6
+ export { A2A_PEER_BOUNDARIES, A2A_PEER_ENTRY_PROBLEMS, A2A_PEER_FINGERPRINT_RE, A2aPeerFingerprint, a2aPeerBoundaryOf, a2aPeerFingerprintDigest, mintA2aPeerFingerprint, pairA2aPeers, type A2aPeerBoundary, type A2aPeerEntryProblem, type A2aPeerFields, type A2aPeerIdentitySource, type A2aPeerPairable, type A2aPeerPairing, } from "./a2a-peer-identity.js";
6
7
  export * from "./execution-lanes.js";
7
8
  export * from "./config-document-refusal.js";
8
9
  export * from "./url-shape.js";
@@ -13,7 +14,7 @@ export * from "./url-credential.js";
13
14
  export * from "./default-model.js";
14
15
  export { catalogManagesModelPlane, enabledEntryCount, isExplicitlyDisabledEntry } from "./catalog-manages.js";
15
16
  export { DEFAULT_MODEL_KEY, ENV_MODEL_TABLE_KEYS, buildEnvModelBaseline, envModelTableDeclared, envModelTableWriteRefusal, mintedCheapId, planEnvModelTableWrite, readEnvModelSlots, type EnvCheapSlot, type EnvModelBaseline, type EnvModelTableEntry, type EnvModelTableKey, type EnvModelTableLanding, type EnvModelTableReceipt, type EnvModelTableRoleRow, type EnvModelTableTarget, type EnvModelTableWriteInput, type EnvModelTableWriteIntent, type EnvModelTableWritePlan, type EnvRoleBinding, type EnvSnapshot, } from "./env-model-table.js";
16
- export { CONFIG_ROOT_DOCUMENTS, ENV_MODELS_DECISIONS, ENV_MODELS_DOCUMENT, ROOT_DOCUMENT_UNREADABLE_REASONS, envModelsDecisionTag, type ConfigRootDocument, type EnvModelsDecision, type EnvModelsDecisionWord, type MarkedMigrationId, type MigrationMarker, type RootDocumentUnreadableReason } from "./config-root-documents.js";
17
+ export { CONFIG_ROOT_DOCUMENTS, ENV_MODELS_DECISIONS, ENV_MODELS_DOCUMENT, ROOT_DOCUMENT_UNREADABLE_REASONS, envModelsDecisionTag, type ConfigRootDocument, type EnvModelsDecision, type EnvModelsDecisionWord, type RootDocumentUnreadableReason } from "./config-root-documents.js";
17
18
  export * from "./loopback.js";
18
19
  export * from "./hash.js";
19
20
  export * from "./sha256.js";
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  * web-admin, the worker service, and the TOC desktop/CLI.
4
4
  */
5
5
  export * from "./types.js";
6
+ export { A2A_PEER_BOUNDARIES, A2A_PEER_ENTRY_PROBLEMS, A2A_PEER_FINGERPRINT_RE, A2aPeerFingerprint, a2aPeerBoundaryOf, a2aPeerFingerprintDigest, mintA2aPeerFingerprint, pairA2aPeers, } from "./a2a-peer-identity.js"; // (named: the entry judge, its member table and the issue-word reading stay package-private — A2aPeerSpec is the one place an entry is judged): the a2a peer's identity and registration — boundary words A2A_PEER_BOUNDARIES + their one reading a2aPeerBoundaryOf (absent = outside); the entry-problem closed set A2A_PEER_ENTRY_PROBLEMS (the engine primitives' registration words + fingerprint_stale / id_missing); the identity stamp: its one spelling A2A_PEER_FINGERPRINT_RE / A2aPeerFingerprint, the one digest recompute a2aPeerFingerprintDigest, the one mint mintA2aPeerFingerprint (this package mints, everyone else compares); the one pairing of a stored roster with a submitted one pairA2aPeers (id first, then name among the unpaired); Web Crypto random, no node:crypto — pure/browser-safe
6
7
  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
8
  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 / too_deep / retired_domain; ConfigDocumentRefusal { document, reason, error }; its file-level arm carries an optional ioKind on io refusals — CONFIG_DOCUMENT_IO_KINDS = dangling_symlink / read_error, 31.1.0) — the reading is `FileConfigStore.read()` in ./node; pure/browser-safe
8
9
  export * from "./url-shape.js"; // 11.0.0: THE URL shape judge (httpUrlFlaws / httpUrlRule / isHierarchicalUrl; 16.0.0 + wsUrlFlaws), pure/browser-safe
@@ -13,7 +14,7 @@ export * from "./url-credential.js"; // 14.5.0: THE "does this URL carry a crede
13
14
  export * from "./default-model.js"; // 11.0.0: THE catalog-default resolver (roles.default → active tier ladder → fallback), pure/browser-safe
14
15
  export { catalogManagesModelPlane, enabledEntryCount, isExplicitlyDisabledEntry } from "./catalog-manages.js"; // THE "does this models document manage the model plane" judge (raw half: at least one entry not explicitly disabled) + the log count it is derived from + THE "is this one entry explicitly disabled" predicate they (and every per-entry consumer) read (the three-state `enabled` reading stays package-private), pure/browser-safe
15
16
  export { DEFAULT_MODEL_KEY, ENV_MODEL_TABLE_KEYS, buildEnvModelBaseline, envModelTableDeclared, envModelTableWriteRefusal, mintedCheapId, planEnvModelTableWrite, readEnvModelSlots, } from "./env-model-table.js"; // the env model table (MODEL_ID / MODEL_CHEAP_ID) read once: readEnvModelSlots / envModelTableDeclared / buildEnvModelBaseline + the writer's plan planEnvModelTableWrite (receipt by id, confirmKey) + envModelTableWriteRefusal, pure/browser-safe (named: the env snapshot helper stays package-private)
16
- export { CONFIG_ROOT_DOCUMENTS, ENV_MODELS_DECISIONS, ENV_MODELS_DOCUMENT, ROOT_DOCUMENT_UNREADABLE_REASONS, envModelsDecisionTag } from "./config-root-documents.js"; // the config-root documents (config.env-models.json + the per-id migration marker config.migration.<id>.json): names + closed answer tables + the one tagged identity of a decision reading (envModelsDecisionTag); the readers / writer are in ./node
17
+ export { CONFIG_ROOT_DOCUMENTS, ENV_MODELS_DECISIONS, ENV_MODELS_DOCUMENT, ROOT_DOCUMENT_UNREADABLE_REASONS, envModelsDecisionTag } from "./config-root-documents.js"; // the config-root document (config.env-models.json): names + closed answer tables + the one tagged identity of a decision reading (envModelsDecisionTag); the readers / writer are in ./node
17
18
  export * from "./loopback.js"; // 11.0.0: the two「本机」predicates (auth relaxation — narrow / connection routing — wide), pure/browser-safe
18
19
  export * from "./hash.js";
19
20
  export * from "./sha256.js";
@@ -1,27 +1,25 @@
1
1
  /**
2
2
  * 一次性迁移的**收据形**与两张闭集(11.0.0)—— 叶子模块(运行期零依赖;除包内私有的零 import 叶 `./deep-freeze` 外只有型导入),由 `./one-time-migrations` 再导出(不进主桶)。
3
- * 单拆出来只为一件事:读迁移 id 闭集的叶子(墓碑句 `./retired-form`、车道表 `./execution-lane-index`、配置根文档 `./config-root-documents`)
3
+ * 单拆出来只为一件事:读迁移 id 闭集的叶子(墓碑句 `./retired-form`、车道表 `./execution-lane-index`)
4
4
  * 不该为一个型把整套迁移体与域 schema 拉进来。(26.0.0 起调度店的读口不再带收据 —— 它的读时改写到期删了。)
5
5
  */
6
- import type { ENV_MODELS_DOCUMENT } from "./config-root-documents.js";
7
6
  import type { DomainName } from "./types.js";
8
7
  /** 本版登记的一次性迁移 id(闭集;每个 id 在 `ONE_TIME_MIGRATIONS` 登记表里恰一行)。收据只许这些 id。 */
9
- export declare const ONE_TIME_MIGRATION_IDS: readonly ["SS-M11", "SS-M12", "SS-M13", "SS-M14"];
8
+ export declare const ONE_TIME_MIGRATION_IDS: readonly ["SS-M12", "SS-M13", "SS-M14"];
10
9
  export type OneTimeMigrationId = (typeof ONE_TIME_MIGRATION_IDS)[number];
11
10
  /**
12
11
  * 一条收据说迁移**对一个坐标做了什么**(闭集,每词一义):
13
12
  * - `moved` — 值搬到新位(`to`),义不变;
14
13
  * - `rewritten` — 同一坐标上的值换成今天的生效读法(例:15.x worker 行的记忆方言词 `tidb` ⇒ `mysql`);
15
14
  * - `dropped-inert` — 删掉;今天的读法本就不让它生效(例:不声明那条车道的行上的车道键、mcp 条目上从没有读者的 `authForm` / `entryKind`);
16
- * - `refused` — 不改:要改就得替运维猜(或旧文档今天本就读不进);原样留着,读侧照旧响亮拒,`reason` 说为什么;
17
- * - `minted` — 在**缺席处**写下一份新事实(一份部署决定),不改任何已有的值 —— 只有 SS-M11 铸(配置根的 `config.env-models.json`:
18
- * 升级前「管模型面的目录整表顶替 env 模型」的读法,写成 `replaced`;不存在才建)。
15
+ * - `refused` — 不改:要改就得替运维猜(或旧文档今天本就读不进);原样留着,读侧照旧响亮拒,`reason` 说为什么。
16
+ * (35.0.0 起没有 `minted`:唯一铸它的 SS-M11 窗关删了。)
19
17
  */
20
- export declare const MIGRATION_APPLIED_AS: readonly ["moved", "rewritten", "dropped-inert", "refused", "minted"];
18
+ export declare const MIGRATION_APPLIED_AS: readonly ["moved", "rewritten", "dropped-inert", "refused"];
21
19
  export type MigrationAppliedAs = (typeof MIGRATION_APPLIED_AS)[number];
22
- /** 收据指向的那份文档:配置域名,或配置根上的 env 模型表决定(`config.env-models`,SS-M11 铸)。
23
- * (26.0.0 起没有一步给 retired 域 `runtime`、`config.d/remote-exec.json` 或调度店出收据 —— 那三只文档的迁移步到期删了。) */
24
- export type MigrationDocument = DomainName | typeof ENV_MODELS_DOCUMENT;
20
+ /** 收据指向的那份文档:配置域名。
21
+ * (26.0.0 起没有一步给 retired 域 `runtime`、`config.d/remote-exec.json` 或调度店出收据 —— 那三只文档的迁移步到期删了;35.0.0 起也没有给配置根上的 `config.env-models` 的 —— SS-M11 删了。) */
22
+ export type MigrationDocument = DomainName;
25
23
  /** 文档里的段坐标(字符串段 = 对象键,数字段 = 数组下标;与告警坐标同一形)。 */
26
24
  export type MigrationPath = readonly (string | number)[];
27
25
  interface ReceiptBase {
@@ -37,7 +35,7 @@ export type MigrationReceipt = (ReceiptBase & {
37
35
  readonly path: MigrationPath;
38
36
  };
39
37
  }) | (ReceiptBase & {
40
- readonly appliedAs: "rewritten" | "dropped-inert" | "minted";
38
+ readonly appliedAs: "rewritten" | "dropped-inert";
41
39
  }) | (ReceiptBase & {
42
40
  readonly appliedAs: "refused";
43
41
  readonly reason: string;
@@ -1,13 +1,12 @@
1
1
  import { deepFreeze } from "./deep-freeze.js";
2
2
  /** 本版登记的一次性迁移 id(闭集;每个 id 在 `ONE_TIME_MIGRATIONS` 登记表里恰一行)。收据只许这些 id。 */
3
- export const ONE_TIME_MIGRATION_IDS = deepFreeze(["SS-M11", "SS-M12", "SS-M13", "SS-M14"]);
3
+ export const ONE_TIME_MIGRATION_IDS = deepFreeze(["SS-M12", "SS-M13", "SS-M14"]);
4
4
  /**
5
5
  * 一条收据说迁移**对一个坐标做了什么**(闭集,每词一义):
6
6
  * - `moved` — 值搬到新位(`to`),义不变;
7
7
  * - `rewritten` — 同一坐标上的值换成今天的生效读法(例:15.x worker 行的记忆方言词 `tidb` ⇒ `mysql`);
8
8
  * - `dropped-inert` — 删掉;今天的读法本就不让它生效(例:不声明那条车道的行上的车道键、mcp 条目上从没有读者的 `authForm` / `entryKind`);
9
- * - `refused` — 不改:要改就得替运维猜(或旧文档今天本就读不进);原样留着,读侧照旧响亮拒,`reason` 说为什么;
10
- * - `minted` — 在**缺席处**写下一份新事实(一份部署决定),不改任何已有的值 —— 只有 SS-M11 铸(配置根的 `config.env-models.json`:
11
- * 升级前「管模型面的目录整表顶替 env 模型」的读法,写成 `replaced`;不存在才建)。
9
+ * - `refused` — 不改:要改就得替运维猜(或旧文档今天本就读不进);原样留着,读侧照旧响亮拒,`reason` 说为什么。
10
+ * (35.0.0 起没有 `minted`:唯一铸它的 SS-M11 窗关删了。)
12
11
  */
13
- export const MIGRATION_APPLIED_AS = deepFreeze(["moved", "rewritten", "dropped-inert", "refused", "minted"]);
12
+ export const MIGRATION_APPLIED_AS = deepFreeze(["moved", "rewritten", "dropped-inert", "refused"]);
package/dist/node.d.ts CHANGED
@@ -14,6 +14,6 @@ export { tryWebAdminCredentialFileLock, type WebAdminCredentialLockHeld, type We
14
14
  export { migrateConfigDirectory, migrateConfigDocuments, // 14.5.0:同一段「迁 → 整域终判」的同步口(入参是已有的存量文档,无 io)—— 目录形调的就是它的内核
15
15
  type ConfigDirectoryDocument, type ConfigDirectoryIo, type ConfigDirectoryMigration, type ConfigDirectoryRefusal, type ConfigDocumentsMigration, type MigrateConfigDirectoryOptions, type MigrateConfigDocumentsOptions, } from "./config-dir-migration.js";
16
16
  export { nodeConfigDirectoryIo } from "./config-dir-io.js";
17
- export { migrateEnvModelsDecision, nodeConfigRootIo, readEnvModelsDecision, readEnvModelsDecisionSync, // 同步孪生:同一个字节读法 / 缺席律 / 答案表(壳在同步具名锁里写模型池要在锁里读决定)
18
- readMigrationMarker, writeEnvModelsDecision, writeEnvModelsDecisionSync, // 同步孪生:同一份写计划 + 同一对同步原子写原语
19
- type ConfigRootIo, type EnvModelsDecisionWrite, type EnvModelsMigration, type EnvModelsMint, } from "./config-root-node.js";
17
+ export { nodeConfigRootIo, readEnvModelsDecision, readEnvModelsDecisionSync, // 同步孪生:同一个字节读法 / 缺席律 / 答案表(壳在同步具名锁里写模型池要在锁里读决定)
18
+ writeEnvModelsDecision, writeEnvModelsDecisionSync, // 同步孪生:同一份写计划 + 同一对同步原子写原语
19
+ type ConfigRootIo, type EnvModelsDecisionWrite, } from "./config-root-node.js";
package/dist/node.js CHANGED
@@ -17,7 +17,7 @@ export { tryWebAdminCredentialFileLock } from "./atomic-write.js";
17
17
  export { migrateConfigDirectory, migrateConfigDocuments, // 14.5.0:同一段「迁 → 整域终判」的同步口(入参是已有的存量文档,无 io)—— 目录形调的就是它的内核
18
18
  } from "./config-dir-migration.js";
19
19
  export { nodeConfigDirectoryIo } from "./config-dir-io.js"; // 上面那只函数的真 I/O 绑定:node:fs + 本包唯一的原子写器(config-document 模式规则)
20
- // 配置根上的决定文档(config.env-models.json)与按 id 的运行记录(config.migration.<id>.json)的两只读者、决定文档的唯一写函数(运行记录由迁移独占创建;决定文档的读写各有同步孪生),与一次性迁移 SS-M11 的迁移体(名字与闭集答案表在包根)。显式列名。
21
- export { migrateEnvModelsDecision, nodeConfigRootIo, readEnvModelsDecision, readEnvModelsDecisionSync, // 同步孪生:同一个字节读法 / 缺席律 / 答案表(壳在同步具名锁里写模型池要在锁里读决定)
22
- readMigrationMarker, writeEnvModelsDecision, writeEnvModelsDecisionSync, // 同步孪生:同一份写计划 + 同一对同步原子写原语
20
+ // 配置根上的决定文档(config.env-models.json)的唯一读者与唯一写函数(读写各有同步孪生;名字与闭集答案表在包根)。显式列名。
21
+ export { nodeConfigRootIo, readEnvModelsDecision, readEnvModelsDecisionSync, // 同步孪生:同一个字节读法 / 缺席律 / 答案表(壳在同步具名锁里写模型池要在锁里读决定)
22
+ writeEnvModelsDecision, writeEnvModelsDecisionSync, // 同步孪生:同一份写计划 + 同一对同步原子写原语
23
23
  } from "./config-root-node.js";
@@ -8,10 +8,9 @@ export interface OneTimeMigrationWindow {
8
8
  readonly id: OneTimeMigrationId;
9
9
  /** 旧形在读侧的待遇(闭集,每词一义;「读写两面遇旧形一律响亮拒,迁移还在时拒句点名迁移 id、窗关删码后止于今天的位」这条律的例外只在这一格里写):
10
10
  * · `refused` — 读写两面拒,拒句点名本行 id(经 `migrationSignpost` 铸;钉:每个 `refused` 行的 id 在 `src/` 至少一处铸点,
11
- * 且非 `refused` 行零铸点);
12
- * · `read-as-default` — 旧形是一份文档的**缺席**(SS-M11:配置根上没有 `config.env-models.json`),读者按它的缺省读(`kept`),不拒、没有拒句可点名 ——
13
- * 缺省读出来的后果由读者自己的响亮臂说(引擎的模型面组拒句点名出路)。 */
14
- readonly oldForm: "refused" | "read-as-default";
11
+ * 且非 `refused` 行零铸点)。
12
+ * (35.0.0 起只剩这一词:`read-as-default` —— 旧形是一份文档的缺席、读者按缺省读 —— 只给 SS-M11 用过,随它删。再登记一条不拒旧形的迁移,先在这里加回一词并写明它的义。) */
13
+ readonly oldForm: "refused";
15
14
  /** 引入这条迁移的版本。 */
16
15
  readonly introducedIn: string;
17
16
  /** 该版本在 npm 上的发布日(UTC 日历日 YYYY-MM-DD)。`null` = 未发布形,由抬 `package.json` 到 `introducedIn` 的发布准备提交回填。 */
@@ -20,13 +20,10 @@
20
20
  * (数组读里陷阱抛出的值原样出来,不是包里那一句);「不适用」只给形状(不是对象 / 不是数组 / 不是朴素对象 / 有洞的数组 —— 迁移只改它点名的键,读不懂的容器形不替调用方改,原样留给读面判)。三只小件各管一件:{@link snapshotOf}(对象容器 ⇒ 一份读数)· {@link rowsOf}(数组容器 ⇒ 按下标读一次的副本)·
21
21
  * {@link objectFrom}(读数 ⇒ 新对象);步只许经它们读调用方的容器。JSON 解析出来的文档(纯数据)读不出也没有访问器,所以每一步的结果与读法无关;只有 JS 调用方交来的非纯数据会碰到抛。
22
22
  *
23
- * ## 第二种机制:在配置根上铸一次事实(只有 SS-M11)
24
- * 上面的「只认形」律管的是**改写存储文档**的迁移。SS-M11 不改写任何存储形:它在一份文档**缺席**处铸一份部署决定(配置根的 `config.env-models.json`,收据词 `minted`),
25
- * 而「缺席」本身没有形可认 —— 所以它不归上面的律,另有三条:① 它读 env、碰文件系统,住 `./node`(`migrateEnvModelsDecision`),不在下面的纯函数入口里;
26
- * ② 它靠**按 id 一份的运行记录**(`config.migration.SS-M11.json`,「不存在才建」)跑恰一次,建成运行记录的进程是本根唯一的执行者;
27
- * ③ 它的旧形待遇是 `read-as-default`(缺席按读者的缺省 `kept` 读,没有拒句可点名)。窗、删法与删后由谁接住照样只写在登记表那一行。
23
+ * (35.0.0 起没有第二种机制:唯一一条「在配置根上铸一次事实」的迁移 SS-M11 —— 在 `config.env-models.json` 缺席处铸 `replaced`、靠运行记录跑恰一次 —— 窗关删了,
24
+ * 它的收据词 `minted` 与旧形待遇词 `read-as-default` 随它删;决定缺席 ≡ `kept`,由读者自己的判官说后果与出路。)
28
25
  *
29
- * ## 入口(纯函数:不读环境、不读墙钟、不改入参、**不抬任何版本号**;SS-M11 除外,见上一节)
26
+ * ## 入口(纯函数:不读环境、不读墙钟、不改入参、**不抬任何版本号**)
30
27
  * · {@link migrateStoredDocuments} —— 一组**存储文档**(域名 → 文档;还有本机的 `remote-exec` —— `config.d/remote-exec.json`:它是 `config.d`
31
28
  * 能放的一份文档,所以照收,今天没有一步改写它)。一个 scope 的全部草稿、一个 principal 层(个人 models / mcp / skills / plugins)、回滚史里的一条单域行,各调一次。缺的域 = 不动
32
29
  * (26.0.0 起没有一步要知道「缺席的域是从未设过还是没给」:那只问题的唯一读者 SS-M1 到期删了,`coverage` 选项随它删)。
@@ -52,28 +49,6 @@ import { deepFreeze } from "./deep-freeze.js";
52
49
  export { MIGRATION_APPLIED_AS, ONE_TIME_MIGRATION_IDS } from "./migration-receipt.js";
53
50
  /** 一次性迁移登记表 —— 本族各条窗的**唯一属主**。别处只写「窗见 `ONE_TIME_MIGRATIONS` 登记表」。 */
54
51
  export const ONE_TIME_MIGRATIONS = deepFreeze([
55
- {
56
- id: "SS-M11",
57
- oldForm: "read-as-default",
58
- introducedIn: "14.8.0",
59
- releasedOn: "2026-10-27",
60
- removableAfter: "2026-11-26",
61
- rewrites: "nothing stored is rewritten — the config root's env-model-table decision is minted once (migrateEnvModelsDecision, ./node): when the run " +
62
- "marker config.migration.SS-M11.json is absent (a marker that does not read counts as run), the decision and whether config.d/models.json " +
63
- "manages the model plane (catalogManagesModelPlane) are read first; then the marker is created exclusively — the one process that creates " +
64
- "it is the only one that may mint on this root, any other stops for good — and that minter creates {\"envModels\":\"replaced\"} " +
65
- "exclusively only when the decision it read before the election is absent and the catalog manages the model plane (whether an env model " +
66
- "table is declared does not matter: the env only names the replaced env models) — the reading before the decision existed (a managing " +
67
- "catalog replaced the env model table). Outcomes: minted / exists (only EEXIST) / failed (errno + a manual way out); an interruption after the marker is " +
68
- "never retried. An absent root is created owner-only, holding only the marker; config.d is never created",
69
- removal: "the next major after the window: delete migrateEnvModelsDecision (the SS-M11 body), this row, SS-M11 from ONE_TIME_MIGRATION_IDS, the " +
70
- "`minted` receipt word and the `read-as-default` oldForm word; the marker then has no reader — readMigrationMarker and the marker's " +
71
- "entry in CONFIG_ROOT_DOCUMENTS go with it (a marker left on disk is inert)",
72
- afterRemoval: "an absent decision reads as kept — the reading the group-refusal code config.catalog_replaces_env_models is for: this package exports " +
73
- "that code constant and the decision document for the engine to read, enforcing it is the engine's side, and the engine does not " +
74
- "refuse on it today. Where the engine refuses, the way out is to write config.env-models.json = {\"envModels\":\"replaced\"} in the " +
75
- "config root; no signpost in this package",
76
- },
77
52
  {
78
53
  id: "SS-M12",
79
54
  oldForm: "refused",
@@ -33,6 +33,8 @@ 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
34
  /** 调度两只旧旋钮共用的理由句(一句话说清变成了什么、怎么写;会原样进拒启句,所以不带点分版本号)。 */
35
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";
36
+ /** 沙箱直传用户文件通道删除后的理由句(原样进拒启句,不带点分版本号)。 */
37
+ const SEND_USER_FILE_SANDBOX_PUT_ENDPOINT_WHY = "the sandbox direct-upload lane this endpoint configured was removed: files a task sends to the user are now read through the engine's read permission and uploaded by the server itself. Delete this variable; no replacement is needed. Object-store permissions that existed only for sandbox direct uploads can be dropped";
36
38
  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)`;
37
39
  export const RETIRED_ENVS = deepFreeze([
38
40
  ["TIDB_HOST", "MYSQL_HOST", "renamed"],
@@ -103,6 +105,9 @@ export const RETIRED_ENVS = deepFreeze([
103
105
  // 理由句只说为什么换成一只声明、不带点分版本号(会原样进拒启句;与 SESSION_BOX_ENGINE_FRAMES / LSP_ENABLED / STREAM_APPROVAL_ENABLED / MODEL_DEGRADE_REACTIVE 同约定;两行逐字同一句):版本事实写在这里与 CHANGELOG。
104
106
  ["SCHEDULER_SESSION_WAKEUP", "SCHEDULER_RESIDENT_TRIGGER", "replaced", SCHEDULER_RESIDENT_WHY],
105
107
  ["SCHEDULER_SESSION_LIFETIME", "SCHEDULER_RESIDENT_TRIGGER", "replaced", SCHEDULER_RESIDENT_WHY],
108
+ // 沙箱直传用户文件的通道已删除:任务发给用户的文件改为经引擎读权限由服务端直接读取并上传,不再走沙箱直传端点,没有替代变量名。
109
+ // 理由句不带点分版本号(原样进拒启句),与上面各行同约定。
110
+ ["SEND_USER_FILE_SANDBOX_PUT_ENDPOINT", SEND_USER_FILE_SANDBOX_PUT_ENDPOINT_WHY, "removed"],
106
111
  ]);
107
112
  /** 墓碑表 → wire 投影(纯数据)。**同一张表、同序**;族是闭集,穷举 switch(加一族不写这里 ⇒ 编译红)。 */
108
113
  export function buildRetiredEnvWire() {
@@ -668,6 +668,27 @@ export declare const SAFETY_MERGE_SPEC: {
668
668
  readonly fail: "closed";
669
669
  readonly seam: "settings.webSearch (one section, taken whole from one layer) → request settings.webSearch";
670
670
  };
671
+ readonly autoMemory: {
672
+ readonly mergeShape: "replace";
673
+ readonly minTrust: "global";
674
+ readonly tighten: {
675
+ readonly rule: "boolStricter";
676
+ readonly strict: false;
677
+ };
678
+ readonly enforcement: "resolver";
679
+ readonly fail: "closed";
680
+ readonly seam: "auto-memory switch (autoMemoryEnabled = false disables reading and writing auto-memory; enforced at the settings resolver)";
681
+ readonly members: {
682
+ readonly autoMemoryEnabled: {
683
+ readonly direction: "tighten";
684
+ readonly minTrust: "global";
685
+ readonly boolPole: {
686
+ readonly strict: false;
687
+ readonly minTrust: "local";
688
+ };
689
+ };
690
+ };
691
+ };
671
692
  };
672
693
  export type SafetyMergeCategory = keyof typeof SAFETY_MERGE_SPEC;
673
694
  /** The members a category declares, as a CLOSED SET TYPE: `"allow" | "deny" | "ask"` for `permissions`, `never` for
@@ -485,6 +485,19 @@ export const SAFETY_MERGE_SPEC = deepFreeze({
485
485
  mergeShape: "replace", minTrust: "project", tighten: { rule: "none" }, enforcement: "resolver", fail: "closed",
486
486
  seam: `settings.${WEB_SEARCH_SECTION_KEYS[0]} (one section, taken whole from one layer) → request settings.${WEB_SEARCH_SECTION_KEYS[0]}`,
487
487
  },
488
+ // The auto-memory switch `autoMemoryEnabled` (boolean; `false` disables reading from and writing to auto-memory).
489
+ // TIGHTEN-ONLY FROM EVERY LAYER: disabling auto-memory (`false`) narrows what a session reads/writes, so any settings-file
490
+ // layer may set it (strict pole `false` at `"local"`, the lowest settings-file tier); `true`, a non-boolean or a valueless
491
+ // query sits at the row floor `"global"` (user / flag / policy only — never admitted from repository-controllable layers,
492
+ // and a pre-boolPole consumer withholds both poles from repository layers, fail-closed). Merged `replace` + `boolStricter`
493
+ // with `strict: false`: once any admitted layer sets `false`, no other layer can re-enable it.
494
+ autoMemory: {
495
+ mergeShape: "replace", minTrust: "global", tighten: { rule: "boolStricter", strict: false }, enforcement: "resolver", fail: "closed",
496
+ seam: "auto-memory switch (autoMemoryEnabled = false disables reading and writing auto-memory; enforced at the settings resolver)",
497
+ members: {
498
+ autoMemoryEnabled: { direction: "tighten", minTrust: "global", boolPole: { strict: false, minTrust: "local" } },
499
+ },
500
+ },
488
501
  });
489
502
  /** Own-property table lookup. The category union is compile-time only; a JavaScript or deserialized caller can
490
503
  * hand in `"__proto__"` / `"constructor"` / `"toString"`, which a bare index resolves through Object.prototype
@@ -1,13 +1,11 @@
1
- import { type SchedulerParseWarning, type SchedulerReadOptions, type SchedulerRecord, type SchedulerStore, type SchedulerStoreRead } from './scheduler-store.js';
1
+ import { type SchedulerParseWarning, type SchedulerReadOptions, type SchedulerRecord, type SchedulerStore, type SchedulerStoreFileRead } from './scheduler-store.js';
2
2
  /**
3
- * Load the durable store. A MISSING file (ENOENT) ⇒ no records, no warnings (first-run/never-written case); any OTHER
4
- * read failure (EACCES/EIO/EISDIR/…) RETHROWS — only absence means "empty", not "unreadable for any reason"
5
- * (a permissions/IO fault silently treated as [] would let a caller-side save() overwrite real on-disk data with
6
- * an empty store). Content the parser could not read verbatim comes back in `warnings` ({@link parseSchedulerStore});
7
- * a whole file that is not a JSON array reads as zero records + `unreadable-file` — NOT as an empty store (writers must go
8
- * through {@link mutateSchedulerStore}, which refuses to write over it).
3
+ * 读调度店文件:读法与读数见 {@link storeFileReadOf} —— 路径不在 ⇒ `absent: true`、零条零告警;店路径是悬空符号链接 ⇒ 原样抛那一句(不吞、不重包;
4
+ * 句子与写器同一句);其余读失败(`EACCES` / `EIO` / `EISDIR` / …)原样抛。路径是指向真文件的符号链接 ⇒ 读真文件(写器写的也是真文件)。
5
+ * 解析告警随 `warnings` 返回({@link parseSchedulerStore});整份文件不是 JSON 数组时读作零条记录 + `unreadable-file`,
6
+ * 写者须经 {@link mutateSchedulerStore}(遇它拒写)。
9
7
  */
10
- export declare function loadSchedulerStore(path: string, opts: SchedulerReadOptions): SchedulerStoreRead;
8
+ export declare function loadSchedulerStore(path: string, opts: SchedulerReadOptions): SchedulerStoreFileRead;
11
9
  /**
12
10
  * Persist ATOMICALLY: create the parent if it is missing, then the package's one atomic writer (`./atomic-write`: a uniquely-named `.tmp`
13
11
  * sibling, then `rename` over the target — atomic on POSIX, so a concurrent reader never sees a partial file). The file mode
@@ -26,7 +24,9 @@ export declare function saveSchedulerStore(path: string, records: SchedulerRecor
26
24
  * 消费方改调 `createFileSchedulerStore`(改名是硬 breaking:消费方的 tsc 红 / 运行期 undefined 就是通知本身)。 */
27
25
  export declare function createFileSchedulerStore(path: string, opts: {
28
26
  now: () => number;
29
- }): SchedulerStore;
27
+ }): Omit<SchedulerStore, 'load'> & {
28
+ load(): SchedulerStoreFileRead;
29
+ };
30
30
  /** Outcome of {@link mutateSchedulerStore}. `conflict_exhausted` = a concurrent writer kept changing the file
31
31
  * faster than the bounded replays; nothing was written on that final attempt (earlier attempts never wrote).
32
32
  * `unreadable_file` = the file on disk is not a JSON array: `fn` never ran and nothing was written (writing would replace
@@ -55,7 +55,8 @@ export type SchedulerStoreMutation = ({
55
55
  * load→filter→save — the naked sequence is a lost-update race: two writers load the same base
56
56
  * array, mutate independently, and the later `save` silently reverts the earlier one.
57
57
  *
58
- * Optimistic concurrency, format-preserving (no envelope/sidecar/lock file):
58
+ * Optimistic concurrency with no envelope / sidecar / lock file (the on-disk format stays the plain array; the TEXT is not preserved —
59
+ * the commit rewrites the whole array via `serializeSchedulerStore`, and records the read dropped are not written back):
59
60
  * 1. read the RAW file text and keep it as the base witness (missing file ⇒ empty witness);
60
61
  * 2. run `fn(records)` — MUST be pure/replayable; return the next records array, or `null` to
61
62
  * abort with no write (e.g. "nothing to do" discovered under the latest base);
@@ -73,7 +74,9 @@ export type SchedulerStoreMutation = ({
73
74
  * above). A base file that is not a JSON array ⇒ `unreadable_file`, no write. `nowMs` is the caller's clock (the read drops
74
75
  * session-pinned records that went stale — see `parseSchedulerStore`).
75
76
  */
76
- export declare function mutateSchedulerStore(path: string, fn: (records: SchedulerRecord[]) => SchedulerRecord[] | null, opts: {
77
+ export declare function mutateSchedulerStore(path: string, fn: (records: SchedulerRecord[], base: {
78
+ readonly absent: boolean;
79
+ }) => SchedulerRecord[] | null, opts: {
77
80
  nowMs: number;
78
81
  retries?: number;
79
82
  }): SchedulerStoreMutation;
@@ -6,29 +6,25 @@
6
6
  *
7
7
  * Store path = caller-supplied; both sides agree on `SEMA_CONFIG_DIR` → `~/.sema/scheduled_tasks.json`.
8
8
  */
9
- import { readFileSync } from 'node:fs';
10
9
  import { dirname } from 'node:path';
11
- import { ensureOwnerOnlyDirectory, writeFileAtomic } from './atomic-write.js';
10
+ import { ensureOwnerOnlyDirectory, readTextIfPresentSync, writeFileAtomic } from './atomic-write.js';
12
11
  import { parseSchedulerStore, serializeSchedulerStore } from './scheduler-store.js';
13
12
  /**
14
- * Load the durable store. A MISSING file (ENOENT) ⇒ no records, no warnings (first-run/never-written case); any OTHER
15
- * read failure (EACCES/EIO/EISDIR/…) RETHROWS — only absence means "empty", not "unreadable for any reason"
16
- * (a permissions/IO fault silently treated as [] would let a caller-side save() overwrite real on-disk data with
17
- * an empty store). Content the parser could not read verbatim comes back in `warnings` ({@link parseSchedulerStore});
18
- * a whole file that is not a JSON array reads as zero records + `unreadable-file` — NOT as an empty store (writers must go
19
- * through {@link mutateSchedulerStore}, which refuses to write over it).
13
+ * 店文件的一次读数 —— **只此一只铸法**({@link loadSchedulerStore} 与 {@link mutateSchedulerStore} 共用):文本由包里那只同步读口
14
+ * `readTextIfPresentSync` 读(「文件不在 / 悬空软链」只在它的缺席尾判一次:路径上没有条目 ⇒ `undefined`;悬空软链 ⇒ 抛那一句悬空句;别的读失败原样抛)。
15
+ * `undefined` ⇒ `{ records: [], warnings: [], absent: true }`;读到文本 ⇒ `{ ...parseSchedulerStore(text, opts), absent: false }`(文件是 `[]` 或非数组坏内容时 `absent` 也是 `false`)。
16
+ */
17
+ function storeFileReadOf(text, opts) {
18
+ return text === undefined ? { records: [], warnings: [], absent: true } : { ...parseSchedulerStore(text, opts), absent: false };
19
+ }
20
+ /**
21
+ * 读调度店文件:读法与读数见 {@link storeFileReadOf} —— 路径不在 ⇒ `absent: true`、零条零告警;店路径是悬空符号链接 ⇒ 原样抛那一句(不吞、不重包;
22
+ * 句子与写器同一句);其余读失败(`EACCES` / `EIO` / `EISDIR` / …)原样抛。路径是指向真文件的符号链接 ⇒ 读真文件(写器写的也是真文件)。
23
+ * 解析告警随 `warnings` 返回({@link parseSchedulerStore});整份文件不是 JSON 数组时读作零条记录 + `unreadable-file`,
24
+ * 写者须经 {@link mutateSchedulerStore}(遇它拒写)。
20
25
  */
21
26
  export function loadSchedulerStore(path, opts) {
22
- let text;
23
- try {
24
- text = readFileSync(path, 'utf-8');
25
- }
26
- catch (e) {
27
- if (e.code === 'ENOENT')
28
- return { records: [], warnings: [] };
29
- throw e;
30
- }
31
- return parseSchedulerStore(text, opts);
27
+ return storeFileReadOf(readTextIfPresentSync(path), opts);
32
28
  }
33
29
  /**
34
30
  * Persist ATOMICALLY: create the parent if it is missing, then the package's one atomic writer (`./atomic-write`: a uniquely-named `.tmp`
@@ -62,7 +58,8 @@ export function createFileSchedulerStore(path, opts) {
62
58
  * load→filter→save — the naked sequence is a lost-update race: two writers load the same base
63
59
  * array, mutate independently, and the later `save` silently reverts the earlier one.
64
60
  *
65
- * Optimistic concurrency, format-preserving (no envelope/sidecar/lock file):
61
+ * Optimistic concurrency with no envelope / sidecar / lock file (the on-disk format stays the plain array; the TEXT is not preserved —
62
+ * the commit rewrites the whole array via `serializeSchedulerStore`, and records the read dropped are not written back):
66
63
  * 1. read the RAW file text and keep it as the base witness (missing file ⇒ empty witness);
67
64
  * 2. run `fn(records)` — MUST be pure/replayable; return the next records array, or `null` to
68
65
  * abort with no write (e.g. "nothing to do" discovered under the latest base);
@@ -82,27 +79,18 @@ export function createFileSchedulerStore(path, opts) {
82
79
  */
83
80
  export function mutateSchedulerStore(path, fn, opts) {
84
81
  const maxRetries = Math.max(0, opts.retries ?? 5);
85
- const rawOf = () => {
86
- try {
87
- return readFileSync(path, 'utf-8');
88
- }
89
- catch (e) {
90
- if (e.code === 'ENOENT')
91
- return null; // missing file — parse side treats as []
92
- throw e; // non-ENOENT (EACCES/EIO/EISDIR/…) must NOT collapse to "missing" — that would hand fn a fake
93
- // empty baseline and the subsequent save() would overwrite real on-disk data with just fn's additions.
94
- }
95
- };
96
82
  for (let attempt = 0;; attempt++) {
97
- const baseRaw = rawOf();
98
- const base = baseRaw === null ? { records: [], warnings: [] } : parseSchedulerStore(baseRaw, { nowMs: opts.nowMs });
83
+ // the read's absence law is the package's one (`readTextIfPresentSync`): a read failure that is not absence (EACCES/EIO/EISDIR/a dangling link…) throws —
84
+ // it must NOT collapse to "missing": that would hand fn a fake empty baseline and the save below would overwrite real on-disk data with just fn's additions
85
+ const baseRaw = readTextIfPresentSync(path);
86
+ const base = storeFileReadOf(baseRaw, { nowMs: opts.nowMs });
99
87
  const { warnings } = base;
100
88
  if (warnings.some((w) => w.kind === 'unreadable-file'))
101
89
  return { ok: false, reason: 'unreadable_file', warnings };
102
- const next = fn(base.records);
90
+ const next = fn(base.records, { absent: base.absent });
103
91
  if (next === null)
104
92
  return { ok: false, reason: 'aborted', warnings };
105
- if (rawOf() !== baseRaw) {
93
+ if (readTextIfPresentSync(path) !== baseRaw) {
106
94
  if (attempt >= maxRetries)
107
95
  return { ok: false, reason: 'conflict_exhausted', retries: attempt, warnings };
108
96
  continue; // a concurrent writer landed between our read and commit intent — replay on the new base
@@ -10,8 +10,8 @@ export type SchedulerWhen = {
10
10
  delaySec: number;
11
11
  };
12
12
  /**
13
- * A persisted scheduled record (durable across restarts). Required: id/scope/prompt/when/createdMs. Optional
14
- * fields are additive — a future field is a non-breaking extension (readers preserve unknown fields on round-trip).
13
+ * A persisted scheduled record (durable across restarts). Required: id/scope/prompt/when/createdMs. Unknown fields are
14
+ * preserved on round-trip; every DECLARED member is judged by `isSchedulerRecord` (declaring one adds its row there — the table is exhaustive over this type).
15
15
  */
16
16
  export interface SchedulerRecord {
17
17
  id: string;
@@ -24,6 +24,11 @@ export interface SchedulerRecord {
24
24
  label?: string;
25
25
  createdMs: number;
26
26
  nextRunMs?: number;
27
+ /** 记录生命周期。今天的写者写两词之一:`"durable"`(缺席同读)/ `"session"`(读口的过期清理只认这一词)。
28
+ * 型对别的串开放:判官只判它在场时是串,不判是哪个词 —— 较新写者写下的词原样读出(前向兼容,不丢不改);读者按词判,已知两词之外由读者自己处置。 */
29
+ lifetime?: 'durable' | 'session' | (string & {});
30
+ /** 调度模式。今天的写者写两词之一:`"task"` / `"session-wakeup"`(本包的读口不读这一键)。型对别的串开放,理由与 `lifetime` 同。 */
31
+ mode?: 'task' | 'session-wakeup' | (string & {});
27
32
  }
28
33
  /**
29
34
  * The store ABSTRACTION the two sides depend on (writer saves, reader loads). The `@sema-agent/settings-schema/node`
@@ -34,16 +39,22 @@ export interface SchedulerStore {
34
39
  load(): SchedulerStoreRead;
35
40
  save(records: SchedulerRecord[]): void;
36
41
  }
37
- /** Structural validation of one record (required fields + a well-formed `when`). Unknown fields are allowed. */
42
+ /**
43
+ * The ONE record judge, two rules: ① **the judge is the type** — every declared member ({@link RECORD_MEMBERS}, `when` by its arm {@link WHEN_MEMBER}) that is
44
+ * present holds its declared type (strings are strings, numbers are numbers), the required ones are present; a member written as `undefined` reads as absent;
45
+ * ② **the element is plain JSON data and every number anywhere in it is finite** ({@link isFiniteJsonData}: declared members, unknown fields and their nesting alike).
46
+ * Unknown fields are otherwise free and preserved. 35.0.0: before, only the required members' `typeof` — a record whose `lifetime` was `{}`, whose `createdMs`
47
+ * was `1e400`, or whose custom field nested a `1e400` passed, was read as the declared type, and its non-finite number turned into `null` on the next write.
48
+ */
38
49
  export declare function isSchedulerRecord(v: unknown): v is SchedulerRecord;
39
- /** 一条会话链上的记录过期多久算「永驻孤儿」:`lifetime: "session"` ∧ `sessionId` 在场 ∧ `nextRunMs` 已过去这么久 ⇒ 读口丢弃并告警(7 天)。 */
50
+ /** 一条会话链上的记录过期多久算「永驻孤儿」:`lifetime: "session"` ∧ `sessionId` 是非空串 ∧ `nextRunMs` 在场(是数)且已过去这么久 ⇒ 读口丢弃并告警(7 天)。 */
40
51
  export declare const STALE_SESSION_RECORD_MS: number;
41
52
  /** {@link parseSchedulerStore} 对它读到的数据**做了什么**(而不是逐字读)。闭集 —— 新 `kind` 是联合加员(穷举 `switch` 的消费方
42
53
  * 会编译红,那就是通知)。`index` = 记录在原数组里的下标(对照源文件用)。
43
54
  * - `unreadable-file` — 整份文件不是 JSON / 不是数组:读出零条记录。**不是**「空店」:{@link mutateSchedulerStore} 遇它拒写
44
55
  * (否则下一次保存会把盘上那份读不懂的数据整份覆盖掉)。
45
- * - `malformed-record` — 这一条没过 {@link isSchedulerRecord},丢弃;`record` = 原值(未校验,诊断用)。
46
- * - `stale-session-record` — 会话链上的记录(`lifetime: "session"` ∧ `sessionId` 在场)而 `nextRunMs` 已过去 ≥ {@link STALE_SESSION_RECORD_MS}:
56
+ * - `malformed-record` — 这一条没过 {@link isSchedulerRecord}(缺必填成员、声明成员不是声明的型、元素里任何一处的数不是有限数 —— 例 `1e400` 解析出的 `Infinity`,自定义字段里的也算 —— 或元素读不成纯 JSON 数据),丢弃;`record` = 原值(未校验,诊断用)。
57
+ * - `stale-session-record` — 会话链上的记录(`lifetime: "session"` ∧ `sessionId` 是非空串)而 `nextRunMs` 在场、已过去 ≥ {@link STALE_SESSION_RECORD_MS}:
47
58
  * 它的会话没走到收割(无常驻 daemon 的车道 / 崩溃),再留着就是永驻。丢弃,不另起写 —— 下一个写者落盘。
48
59
  * **只认显式的 `"session"`**:`lifetime` 缺席读作 durable;durable 记录带着来源 sessionId
49
60
  * 是合法形,daemon 停机一周后的 cron 照样是用户的任务,不许当孤儿丢。
@@ -68,6 +79,10 @@ export interface SchedulerStoreRead {
68
79
  readonly records: SchedulerRecord[];
69
80
  readonly warnings: SchedulerParseWarning[];
70
81
  }
82
+ /** 一次文件读的结果:{@link SchedulerStoreRead} 加上文件当时是否缺席(`absent`:路径不存在 ⇒ `true`;文件存在,含空数组 `[]` 或非数组坏内容 ⇒ `false`)。 */
83
+ export type SchedulerStoreFileRead = SchedulerStoreRead & {
84
+ readonly absent: boolean;
85
+ };
71
86
  /** 读口的入参:`nowMs` 由调用方给(本包不读墙钟),判 {@link STALE_SESSION_RECORD_MS}。 */
72
87
  export interface SchedulerReadOptions {
73
88
  readonly nowMs: number;