@sema-agent/settings-schema 25.1.0 → 26.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 (71) hide show
  1. package/CHANGELOG.md +319 -0
  2. package/README.md +65 -33
  3. package/conformance/VERSION +1 -1
  4. package/conformance/cases/c27-hosts-array-1025/meta.json +1 -1
  5. package/conformance/cases/c48-s935-model-headers-transported/expected.json +18 -68
  6. package/conformance/cases/c48-s935-model-headers-transported/meta.json +1 -1
  7. package/conformance/cases/c67-s784-retired-field-loud/meta.json +1 -1
  8. package/conformance/cases/c77-prompts-center-artifact-carried/expected.json +5 -5
  9. package/conformance/cases/c77-prompts-center-artifact-carried/input.json +2 -2
  10. package/conformance/cases/c79-prompts-bad-worker-artifact-not-salvaged/expected.json +1 -1
  11. package/conformance/cases/c79-prompts-bad-worker-artifact-not-salvaged/input.json +3 -3
  12. package/conformance/cases/c80-prompts-wire-v2-verbatim/expected.json +1 -1
  13. package/conformance/cases/c80-prompts-wire-v2-verbatim/input.json +1 -1
  14. package/conformance/cases/c82-prompts-v1-catalog-refused/expected.json +1 -1
  15. package/conformance/cases/c82-prompts-v1-catalog-refused/input.json +1 -1
  16. package/conformance/cases/c83-prompts-bad-overlay-not-salvaged/expected.json +1 -1
  17. package/conformance/cases/c83-prompts-bad-overlay-not-salvaged/input.json +1 -1
  18. package/dist/cli.d.ts +7 -7
  19. package/dist/cli.js +11 -19
  20. package/dist/config-dir-io.js +3 -14
  21. package/dist/config-dir-migration.d.ts +1 -4
  22. package/dist/config-dir-migration.js +16 -22
  23. package/dist/config-document-refusal.d.ts +2 -3
  24. package/dist/config-fns.d.ts +3 -4
  25. package/dist/config-fns.js +4 -6
  26. package/dist/conformance/run.js +89 -29
  27. package/dist/conformance/types.d.ts +65 -39
  28. package/dist/execution-lane-index.d.ts +8 -19
  29. package/dist/execution-lane-index.js +6 -27
  30. package/dist/file-store.js +2 -3
  31. package/dist/fleet.d.ts +10 -47
  32. package/dist/fleet.js +13 -40
  33. package/dist/fs-failure.d.ts +5 -10
  34. package/dist/fs-failure.js +4 -8
  35. package/dist/hooks.d.ts +41 -6
  36. package/dist/hooks.js +68 -4
  37. package/dist/migration-receipt.d.ts +12 -14
  38. package/dist/migration-receipt.js +5 -7
  39. package/dist/node.js +1 -1
  40. package/dist/one-time-migrations.d.ts +9 -24
  41. package/dist/one-time-migrations.js +30 -796
  42. package/dist/remote-exec.js +2 -3
  43. package/dist/retired-envs.js +2 -0
  44. package/dist/retired-form.d.ts +12 -11
  45. package/dist/retired-form.js +12 -8
  46. package/dist/sandbox-git.d.ts +1 -1
  47. package/dist/sandbox-git.js +3 -3
  48. package/dist/scheduler-lifetime.d.ts +1 -1
  49. package/dist/scheduler-lifetime.js +1 -1
  50. package/dist/scheduler-store.d.ts +4 -29
  51. package/dist/scheduler-store.js +21 -14
  52. package/dist/types.d.ts +13 -19
  53. package/dist/types.js +75 -110
  54. package/dist/web-admin-credential.d.ts +2 -2
  55. package/dist/web-admin-credential.js +4 -4
  56. package/dist/worker-row-verdict.d.ts +1 -1
  57. package/dist/worker-row-verdict.js +1 -1
  58. package/dist/workers-rows.d.ts +2 -2
  59. package/dist/workers-rows.js +2 -2
  60. package/dist/zod-unwrap.d.ts +1 -1
  61. package/dist/zod-unwrap.js +1 -1
  62. package/docs/API-SURFACE.md +11 -12
  63. package/docs/CONFORMANCE.md +25 -13
  64. package/docs/CONSUMER-INTEGRATION.md +54 -27
  65. package/llms-full.txt +24 -22
  66. package/llms.txt +20 -14
  67. package/package.json +1 -1
  68. package/dist/runtime-lift-targets.d.ts +0 -7
  69. package/dist/runtime-lift-targets.js +0 -7
  70. package/dist/scheduler-store-migration.d.ts +0 -14
  71. package/dist/scheduler-store-migration.js +0 -14
package/dist/fleet.d.ts CHANGED
@@ -11,8 +11,8 @@
11
11
  *
12
12
  * 🔴 Contract discipline (same rules as scheduler-store):
13
13
  * - ABSTRACT: types + zod wire shapes + PURE decision functions. ZERO IO, ZERO node:* — browser-safe barrel.
14
- * - FINAL-STATE: shapes codify what is SHIPPED on the wire (server 1.96.0 drain: /health `version`/`draining`/
15
- * `drainingSince`, billable submit 503+Retry-After) — no transitional aliases, breaking changes over shims
14
+ * - FINAL-STATE: shapes codify what is SHIPPED on the wire (/health `version` + the engine signal, billable submit
15
+ * 503+Retry-After) — no transitional aliases, breaking changes over shims
16
16
  * (产品拍板: no temporary compatibility design; the target is long-term stability).
17
17
  * - EXTENSIBLE: enums + optional fields externalize decisions (add an LB strategy = add an enum value,
18
18
  * the skeleton does not move).
@@ -273,15 +273,13 @@ export type EngineDraining = z.infer<typeof EngineDraining>;
273
273
  * {@link judgeRoutability}) read nothing else.
274
274
  *
275
275
  * One fact, one place on a body: the engine's STATE is this object; the row's IDENTITY (`instanceId`, `worker`, `address`,
276
- * `version`, `heartbeatMs`) is the body's top level and is not repeated here. The flat keys of this object's names that the two
277
- * bodies still carry (`ready`, `draining` as a boolean + `drainingSince`, `restart`, `generation`, `leaseState`, `leaseUntil`)
278
- * are the pre-11 flat dialect: sent during its contraction window for readers that predate this key, unchanged in shape, read by
279
- * nothing in this package; their removal is registered (`ONE_TIME_MIGRATIONS` row `SS-W1`).
276
+ * `version`, `heartbeatMs`) is the body's top level and is not repeated here. Neither body types a key of this object's names at
277
+ * its top level (26.0.0 removed the pre-11 flat dialect — `ready`, the boolean `draining` + `drainingSince`, `restart`,
278
+ * `generation`, `leaseState`, `leaseUntil`): a body that still carries them is read as without them — the heartbeat shape strips
279
+ * them, `/health` passes them through untyped — and no judge reads them.
280
280
  *
281
- * Nested under one key, not flat on the body: the boolean dialect (`draining: boolean` + `drainingSince`, {@link InstanceHealth} /
282
- * {@link InstanceAnnouncement}) is still sent during its contraction window while `draining` here is an OBJECT — one key cannot hold
283
- * both, and a flat object `draining` would make every reader still on the boolean refuse a draining engine's heartbeat. Nested, an
284
- * older reader never sees it (the heartbeat shape strips unknown keys; `/health` is an open record) and a newer one reads only it.
281
+ * Nested under one key, not flat on the body: the state is one object the engine mints once, so it travels whole and a reader
282
+ * takes all of it or none of it (see "Reading" below) — never a mix of a body's top-level keys and the signal.
285
283
  *
286
284
  * - `ready` — always said (never "absent while ready"): the engine can take new work right now.
287
285
  * - `draining` — present ⇔ draining ({@link EngineDraining}).
@@ -339,13 +337,10 @@ export declare function readEngineSignal(body: unknown): EngineSignal | undefine
339
337
  /** The `/health` self-description every orchestrator reads. Liveness and readiness are deliberately SPLIT: `status` stays ok while
340
338
  * draining (the process is alive); readiness is {@link judgeReadiness} over the engine signal the body carries under
341
339
  * {@link ENGINE_SIGNAL_KEY}. Unknown fields pass through — health is a self-description, not a closed record: `modelRefusals`
342
- * rides it untyped and is read with {@link readModelRefusals}; the flat dialect keys other than the boolean pair (`ready`,
343
- * `restart`, `generation`, `leaseState`, `leaseUntil`) ride it untyped too and are read by nothing. */
340
+ * rides it untyped and is read with {@link readModelRefusals}; any other key rides it untyped too and is read by nothing. */
344
341
  export declare const InstanceHealth: z.ZodObject<{
345
342
  instanceId: z.ZodString;
346
343
  version: z.ZodString;
347
- draining: z.ZodOptional<z.ZodBoolean>;
348
- drainingSince: z.ZodOptional<z.ZodNumber>;
349
344
  engineSignal: z.ZodCatch<z.ZodOptional<z.ZodObject<{
350
345
  ready: z.ZodBoolean;
351
346
  draining: z.ZodOptional<z.ZodObject<{
@@ -413,27 +408,11 @@ export declare const InstanceAnnouncement: z.ZodObject<{
413
408
  worker: z.ZodString;
414
409
  address: z.ZodString;
415
410
  version: z.ZodString;
416
- ready: z.ZodBoolean;
417
- draining: z.ZodDefault<z.ZodBoolean>;
418
411
  heartbeatMs: z.ZodDefault<z.ZodNumber>;
419
- restart: z.ZodOptional<z.ZodObject<{
420
- reasons: z.ZodArray<z.ZodString>;
421
- version: z.ZodNumber;
422
- since: z.ZodNumber;
423
- withheld: z.ZodOptional<z.ZodBoolean>;
424
- }, z.core.$strip>>;
425
412
  modelRefusals: z.ZodCatch<z.ZodOptional<z.ZodObject<{
426
413
  entries: z.ZodRecord<z.ZodString, z.ZodString>;
427
414
  plane: z.ZodOptional<z.ZodString>;
428
415
  }, z.core.$strip>>>;
429
- generation: z.ZodCatch<z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>>;
430
- leaseState: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
431
- none: "none";
432
- granted: "granted";
433
- expired: "expired";
434
- denied: "denied";
435
- }>>>;
436
- leaseUntil: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
437
416
  engineSignal: z.ZodCatch<z.ZodOptional<z.ZodObject<{
438
417
  ready: z.ZodBoolean;
439
418
  draining: z.ZodOptional<z.ZodObject<{
@@ -478,27 +457,11 @@ export declare const InstanceRegistration: z.ZodObject<{
478
457
  worker: z.ZodString;
479
458
  address: z.ZodString;
480
459
  version: z.ZodString;
481
- ready: z.ZodBoolean;
482
- draining: z.ZodDefault<z.ZodBoolean>;
483
460
  heartbeatMs: z.ZodDefault<z.ZodNumber>;
484
- restart: z.ZodOptional<z.ZodObject<{
485
- reasons: z.ZodArray<z.ZodString>;
486
- version: z.ZodNumber;
487
- since: z.ZodNumber;
488
- withheld: z.ZodOptional<z.ZodBoolean>;
489
- }, z.core.$strip>>;
490
461
  modelRefusals: z.ZodCatch<z.ZodOptional<z.ZodObject<{
491
462
  entries: z.ZodRecord<z.ZodString, z.ZodString>;
492
463
  plane: z.ZodOptional<z.ZodString>;
493
464
  }, z.core.$strip>>>;
494
- generation: z.ZodCatch<z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>>;
495
- leaseState: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
496
- none: "none";
497
- granted: "granted";
498
- expired: "expired";
499
- denied: "denied";
500
- }>>>;
501
- leaseUntil: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
502
465
  engineSignal: z.ZodCatch<z.ZodOptional<z.ZodObject<{
503
466
  ready: z.ZodBoolean;
504
467
  draining: z.ZodOptional<z.ZodObject<{
@@ -532,7 +495,7 @@ export type InstanceRegistration = z.infer<typeof InstanceRegistration>;
532
495
  export declare function isInstanceStale(r: Pick<InstanceRegistration, "lastSeenMs" | "heartbeatMs">, nowMs: number): boolean;
533
496
  /** Health fusion — the ONE judge of "may dispatch route to this stored instance": a signal is present ∧ the row is not stale ∧
534
497
  * the observer does not veto ∧ the engine's own readiness ({@link judgeReadiness} over the row's {@link EngineSignal}). Two sources
535
- * merge as an AND — EITHER source's "not ready" removes the instance (fail-closed). The row's boolean `draining` is not read. */
498
+ * merge as an AND — EITHER source's "not ready" removes the instance (fail-closed). */
536
499
  export declare function judgeRoutability(r: InstanceRegistration, nowMs: number): RoutingVerdict;
537
500
  /** {@link judgeRoutability} as a boolean (the same judge, no second reading). */
538
501
  export declare function isRoutable(r: InstanceRegistration, nowMs: number): boolean;
package/dist/fleet.js CHANGED
@@ -11,8 +11,8 @@
11
11
  *
12
12
  * 🔴 Contract discipline (same rules as scheduler-store):
13
13
  * - ABSTRACT: types + zod wire shapes + PURE decision functions. ZERO IO, ZERO node:* — browser-safe barrel.
14
- * - FINAL-STATE: shapes codify what is SHIPPED on the wire (server 1.96.0 drain: /health `version`/`draining`/
15
- * `drainingSince`, billable submit 503+Retry-After) — no transitional aliases, breaking changes over shims
14
+ * - FINAL-STATE: shapes codify what is SHIPPED on the wire (/health `version` + the engine signal, billable submit
15
+ * 503+Retry-After) — no transitional aliases, breaking changes over shims
16
16
  * (产品拍板: no temporary compatibility design; the target is long-term stability).
17
17
  * - EXTENSIBLE: enums + optional fields externalize decisions (add an LB strategy = add an enum value,
18
18
  * the skeleton does not move).
@@ -346,15 +346,13 @@ export const EngineDraining = z.object({
346
346
  * {@link judgeRoutability}) read nothing else.
347
347
  *
348
348
  * One fact, one place on a body: the engine's STATE is this object; the row's IDENTITY (`instanceId`, `worker`, `address`,
349
- * `version`, `heartbeatMs`) is the body's top level and is not repeated here. The flat keys of this object's names that the two
350
- * bodies still carry (`ready`, `draining` as a boolean + `drainingSince`, `restart`, `generation`, `leaseState`, `leaseUntil`)
351
- * are the pre-11 flat dialect: sent during its contraction window for readers that predate this key, unchanged in shape, read by
352
- * nothing in this package; their removal is registered (`ONE_TIME_MIGRATIONS` row `SS-W1`).
349
+ * `version`, `heartbeatMs`) is the body's top level and is not repeated here. Neither body types a key of this object's names at
350
+ * its top level (26.0.0 removed the pre-11 flat dialect — `ready`, the boolean `draining` + `drainingSince`, `restart`,
351
+ * `generation`, `leaseState`, `leaseUntil`): a body that still carries them is read as without them — the heartbeat shape strips
352
+ * them, `/health` passes them through untyped — and no judge reads them.
353
353
  *
354
- * Nested under one key, not flat on the body: the boolean dialect (`draining: boolean` + `drainingSince`, {@link InstanceHealth} /
355
- * {@link InstanceAnnouncement}) is still sent during its contraction window while `draining` here is an OBJECT — one key cannot hold
356
- * both, and a flat object `draining` would make every reader still on the boolean refuse a draining engine's heartbeat. Nested, an
357
- * older reader never sees it (the heartbeat shape strips unknown keys; `/health` is an open record) and a newer one reads only it.
354
+ * Nested under one key, not flat on the body: the state is one object the engine mints once, so it travels whole and a reader
355
+ * takes all of it or none of it (see "Reading" below) — never a mix of a body's top-level keys and the signal.
358
356
  *
359
357
  * - `ready` — always said (never "absent while ready"): the engine can take new work right now.
360
358
  * - `draining` — present ⇔ draining ({@link EngineDraining}).
@@ -399,8 +397,7 @@ export function readEngineSignal(body) {
399
397
  /** The `/health` self-description every orchestrator reads. Liveness and readiness are deliberately SPLIT: `status` stays ok while
400
398
  * draining (the process is alive); readiness is {@link judgeReadiness} over the engine signal the body carries under
401
399
  * {@link ENGINE_SIGNAL_KEY}. Unknown fields pass through — health is a self-description, not a closed record: `modelRefusals`
402
- * rides it untyped and is read with {@link readModelRefusals}; the flat dialect keys other than the boolean pair (`ready`,
403
- * `restart`, `generation`, `leaseState`, `leaseUntil`) ride it untyped too and are read by nothing. */
400
+ * rides it untyped and is read with {@link readModelRefusals}; any other key rides it untyped too and is read by nothing. */
404
401
  export const InstanceHealth = z
405
402
  .object({
406
403
  /** The instance's identity: the engine's OWN per-process id, minted by the engine every time the process starts (never read
@@ -409,13 +406,6 @@ export const InstanceHealth = z
409
406
  instanceId: z.string().min(1),
410
407
  /** build self-description — "did the restart actually land new code" (upgrade classification) */
411
408
  version: z.string().min(1),
412
- /** @deprecated Flat engine-state dialect (the boolean draining), sent during its contraction window for readers that predate
413
- * {@link ENGINE_SIGNAL_KEY}; read nothing off it — draining is {@link EngineSignal}`.draining`. Removal registered
414
- * (`ONE_TIME_MIGRATIONS` row `SS-W1`). */
415
- draining: z.boolean().optional(),
416
- /** @deprecated Flat engine-state dialect (pairs with the boolean `draining`: epoch ms, present iff draining); same window —
417
- * read {@link EngineSignal}`.draining.since` instead. */
418
- drainingSince: z.number().optional(),
419
409
  /** The engine's {@link EngineSignal}, whole — the one place its state is read off `/health`. Read exactly as
420
410
  * {@link readEngineSignal} reads it: a value that breaks the shape is ABSENT (`.catch`), never a refused body — and an absent
421
411
  * signal is `no-engine-signal`, never ready. The key may then be present with the value `undefined`. */
@@ -489,17 +479,7 @@ export const InstanceAnnouncement = z.object({
489
479
  /** reachable base URL for the deployment form: k8s pod IP:port / docker net alias / 127.0.0.1:<engine.port> */
490
480
  address: z.string().min(1),
491
481
  version: z.string().min(1),
492
- /** @deprecated Flat engine-state dialect (self-declared readiness), sent during its contraction window for readers that
493
- * predate {@link ENGINE_SIGNAL_KEY}; read nothing off it — readiness is {@link EngineSignal}`.ready`. Removal registered
494
- * (`ONE_TIME_MIGRATIONS` row `SS-W1`). */
495
- ready: z.boolean(),
496
- /** @deprecated Flat engine-state dialect (the boolean draining), same window; read nothing off it — draining is
497
- * {@link EngineSignal}`.draining`. */
498
- draining: z.boolean().default(false),
499
482
  heartbeatMs: INTEGER.positive().default(DEFAULT_HEARTBEAT_MS),
500
- /** @deprecated Flat engine-state dialect (the restart signal), same window; read nothing off it — the restart signal is
501
- * {@link EngineSignal}`.restart`. Its shape is unchanged for the window: a malformed one still refuses the heartbeat, as before. */
502
- restart: RestartSignal.optional(),
503
483
  /** S-768: present ⇔ this instance has at least one reportable model refusal — the SAME {@link ModelRefusalsWire} /health
504
484
  * carries, minted by the same getter; read it with {@link readModelRefusals}`(announcement)` (never off this field
505
485
  * directly: the field is the open wire form, the reader narrows to the closed sets). Every heartbeat re-announces the
@@ -508,22 +488,15 @@ export const InstanceAnnouncement = z.object({
508
488
  * the key never sends it, so there absence is UNKNOWN, not "none" — tell the two apart by the announced `version`.
509
489
  * Failure direction = meaning direction (this is a diagnostic key): a code this package version does not know passes
510
490
  * (it is "not said" to the reader), and a value that breaks the {@link ModelRefusalsWire} shape law is dropped to
511
- * ABSENT (`.catch`) — it never fails the announcement, so it can never make a healthy instance unroutable (unlike
512
- * `restart`, whose shape still gates the row). The key may then be present with the value `undefined`. */
491
+ * ABSENT (`.catch`) — it never fails the announcement, so it can never make a healthy instance unroutable. The key may
492
+ * then be present with the value `undefined`. */
513
493
  modelRefusals: ModelRefusalsWire.optional().catch(undefined),
514
- /** @deprecated Flat engine-state dialect (fleet membership), same window; read nothing off it — it is
515
- * {@link EngineSignal}`.generation`. Shape unchanged for the window (a value that breaks it drops to absent, as before). */
516
- generation: Generation.optional().catch(undefined),
517
- /** @deprecated Flat engine-state dialect (the lease state), same window; read nothing off it — it is {@link EngineSignal}`.leaseState`. */
518
- leaseState: LeaseState.optional().catch(undefined),
519
- /** @deprecated Flat engine-state dialect (the lease deadline), same window; read nothing off it — it is {@link EngineSignal}`.leaseUntil`. */
520
- leaseUntil: EpochMs.optional().catch(undefined),
521
494
  /** The engine's {@link EngineSignal}, whole — the one place its state is read off a heartbeat (the routing judge
522
495
  * {@link judgeRoutability} reads nothing else). Every heartbeat re-announces the full row, so a later heartbeat whose signal
523
496
  * no longer says a part (`restart`, a lease key) means the engine no longer says it — the stored row is replaced, never merged.
524
497
  * Read exactly as {@link readEngineSignal} reads it off any body: a value that breaks the shape is ABSENT (`.catch`), never a
525
498
  * refused heartbeat — and an absent signal is `no-engine-signal`, never routable, so the failure lands on the routing axis
526
- * closed, while the rest of the row (restart, refusals, membership evidence) is still kept. The key may then be present with
499
+ * closed, while the rest of the row (its identity, its refusals) is still kept. The key may then be present with
527
500
  * the value `undefined`. */
528
501
  [ENGINE_SIGNAL_KEY]: EngineSignal.optional().catch(undefined),
529
502
  });
@@ -546,7 +519,7 @@ export function isInstanceStale(r, nowMs) {
546
519
  }
547
520
  /** Health fusion — the ONE judge of "may dispatch route to this stored instance": a signal is present ∧ the row is not stale ∧
548
521
  * the observer does not veto ∧ the engine's own readiness ({@link judgeReadiness} over the row's {@link EngineSignal}). Two sources
549
- * merge as an AND — EITHER source's "not ready" removes the instance (fail-closed). The row's boolean `draining` is not read. */
522
+ * merge as an AND — EITHER source's "not ready" removes the instance (fail-closed). */
550
523
  export function judgeRoutability(r, nowMs) {
551
524
  const signal = r[ENGINE_SIGNAL_KEY];
552
525
  if (signal === undefined)
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * 包内私有(不进主桶、不进 exports 表;零 `node:` 依赖):**文件系统失败句的唯一铸点** —— `(errno, 落点, 真实路径)` → 一句。
3
- * 本包凡是把文件系统错误说成人话的地方(原子写器、命令行的写 / 删口、目录迁移的读口)都调 {@link fsFailureSentence},没有第二处手写的 `cannot …` 句子
3
+ * 本包凡是把文件系统错误说成人话的地方(原子写器、命令行的写口、目录迁移的读口)都调 {@link fsFailureSentence},没有第二处手写的 `cannot …` 句子
4
4
  * (`test/` 下的 `fs-failure-single-mint-gate` 门扫 `src/` 里的字符串字面量,铸点之外出现即红)。
5
5
  *
6
6
  * 落点({@link FsFailureSite}.`landing`,闭集)按失败发生在哪一步分句 —— 同一个 errno 在不同落点指向不同的东西:
@@ -8,16 +8,15 @@
8
8
  * · `chmod` —— 原子写器给临时文件设模式(已有的文件沿用它原来的模式,临时文件建成后、`rename` 之前设)。这一步失败 ⇒ 点名**设模式**这件事(文件系统不让改文件模式;目录没有问题),
9
9
  * 不提目录、不提不可变标志;`path` 是被保留模式的**真文件**(chmod 作用在替换它的临时副本上,用户认得的是真文件名);
10
10
  * · `rename` —— 原子写器 `rename` 盖过目标。目录收了新文件、却换不掉这一份 ⇒ 点名**真文件**;
11
- * · `remove` —— 删一个文件。删的是目录项:目录不让删 ⇒ 点名文件所在的**目录**(与建临时文件同一个因);
12
11
  * · `read` —— 读一个目录或文件;
13
12
  * · `write` —— 写口整体失败、步骤看不见(注入的写口抛的错,不是本包原子写器抛的):只点名要写的文件。
14
13
  * 认得的 errno 给那一步对应的出路,别的 errno(磁盘满、I/O 错 …)给 Node 自己的句子 —— 照样响亮,只是不替它猜出路。两条与落点无关的律:
15
14
  * · errno 只打一遍 —— 句首括号里一次,Node 句子自带的 `<errno>: ` 前缀去掉;
16
15
  * · `ENAMETOOLONG`(路径某一节或整条超限)既不是目录的错也不是文件的错 ⇒ 一句 `path too long: <被操作系统拒的路径> (ENAMETOOLONG)`,不点名目录、不给权限类出路。
17
- * 三个落点(`dir-create-temp` / `remove` / `rename`)的权限类出路走**同一张表**、一只函数({@link permissionWayOut}):落点表 {@link WAY_OUT_LANDING}(这个落点认哪些 errno、清标志点名谁、动已有目录项的落点才有粘滞目录一句)×
16
+ * 两个落点(`dir-create-temp` / `rename`;26.0.0 起删文件的 `remove` 随目录迁移唯一的删文件口一起删了)的权限类出路走**同一张表**、一只函数({@link permissionWayOut}):落点表 {@link WAY_OUT_LANDING}(这个落点认哪些 errno、清标志点名谁、动已有目录项的落点才有粘滞目录一句)×
18
17
  * errno 表 {@link WAY_OUT_BY_ERRNO}(穷举;每个 errno 两格 —— 目录权限位对本进程「可写」/「不可写或没读过」)。同一个 `EPERM` 既可能是目录模式不让写,也可能是不可变标志(macOS `chflags uchg` / Linux `chattr +i`),
19
18
  * 同一个 `EACCES` 在模式位已经放行时只能是 ACL 条目或安全模块策略 —— 铸点是纯函数,分不清,但调用方在 Node 一侧能读目录模式,把「模式对本进程可写」这个事实经落点的 `directoryWritable` 递进来:
20
- * 「可写」⇒ chmod 已经没用,`EPERM` 的首选出路 = 清标志(`chflags nouchg` / `chattr -i`),动已有目录项的落点(remove / rename)再接粘滞目录一句(那条属主规则给的就是 `EPERM`),`EACCES` 的出路 = 查 ACL / 安全模块(不接粘滞句);
19
+ * 「可写」⇒ chmod 已经没用,`EPERM` 的首选出路 = 清标志(`chflags nouchg` / `chattr -i`),动已有目录项的落点(rename)再接粘滞目录一句(那条属主规则给的就是 `EPERM`),`EACCES` 的出路 = 查 ACL / 安全模块(不接粘滞句);
21
20
  * 否则(模式不可写,或调用方没读过模式 —— 注入的替身 I/O 抛的错,包看不到它背后)⇒ 先让目录可写,`EPERM` / `EROFS` 句尾提示「只读 / 不可变」的可能。`EROFS` 的出路不变(只读文件系统清不掉)。
22
21
  * `rename` 落点的「可写」不是读出来的而是已证明的({@link RENAME_DIRECTORY_WRITABLE}:走到 rename 时临时文件刚在同一目录建成)—— 一个来源,`EPERM` 与 `EACCES` 同走「可写」那一列,所以 rename 句从不说「make the directory writable」。
23
22
  *
@@ -25,8 +24,8 @@
25
24
  * 命令行 / 迁移用 {@link fsFailureMessage} 取句 —— 已经是 {@link FsFailure} 的原样用,否则按它所在的口铸。
26
25
  */
27
26
  /** 一次失败发生的地方(闭集):落点加那一步交给操作系统的真实路径(`dir-create-temp` 是要建的临时文件,点名的目录是它的父目录;`rename` 是被盖过的真文件;
28
- * `remove` / `write` 是那份文件;`read` 是读的目录或文件;`chmod` 是被保留模式的真文件〔这一格不是「交给操作系统的路径」口径:chmod 的对象是替换它的临时副本〕)。
29
- * `directoryWritable`(只有 `dir-create-temp` / `remove` 两个落点有)—— 失败那一刻,目录的权限位对本进程是否可写(Node 一侧读的事实,见 `./atomic-write` 的 `directoryAdmitsWrite`);
27
+ * `write` 是那份文件;`read` 是读的目录或文件;`chmod` 是被保留模式的真文件〔这一格不是「交给操作系统的路径」口径:chmod 的对象是替换它的临时副本〕)。
28
+ * `directoryWritable`(只有 `dir-create-temp` 落点有)—— 失败那一刻,目录的权限位对本进程是否可写(Node 一侧读的事实,见 `./atomic-write` 的 `directoryAdmitsWrite`);
30
29
  * 缺席 = 没读过(注入的替身 I/O),出路顺序按「不可写」走。`rename` 落点没有这一格:走到 rename 时临时文件刚在同一目录建成,目录可写是已证明的事实,由铸点按 {@link RENAME_DIRECTORY_WRITABLE} 给出。
31
30
  */
32
31
  export type FsFailureSite = {
@@ -39,10 +38,6 @@ export type FsFailureSite = {
39
38
  } | {
40
39
  readonly landing: "rename";
41
40
  readonly path: string;
42
- } | {
43
- readonly landing: "remove";
44
- readonly path: string;
45
- readonly directoryWritable?: boolean;
46
41
  } | {
47
42
  readonly landing: "read";
48
43
  readonly path: string;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * 包内私有(不进主桶、不进 exports 表;零 `node:` 依赖):**文件系统失败句的唯一铸点** —— `(errno, 落点, 真实路径)` → 一句。
3
- * 本包凡是把文件系统错误说成人话的地方(原子写器、命令行的写 / 删口、目录迁移的读口)都调 {@link fsFailureSentence},没有第二处手写的 `cannot …` 句子
3
+ * 本包凡是把文件系统错误说成人话的地方(原子写器、命令行的写口、目录迁移的读口)都调 {@link fsFailureSentence},没有第二处手写的 `cannot …` 句子
4
4
  * (`test/` 下的 `fs-failure-single-mint-gate` 门扫 `src/` 里的字符串字面量,铸点之外出现即红)。
5
5
  *
6
6
  * 落点({@link FsFailureSite}.`landing`,闭集)按失败发生在哪一步分句 —— 同一个 errno 在不同落点指向不同的东西:
@@ -8,16 +8,15 @@
8
8
  * · `chmod` —— 原子写器给临时文件设模式(已有的文件沿用它原来的模式,临时文件建成后、`rename` 之前设)。这一步失败 ⇒ 点名**设模式**这件事(文件系统不让改文件模式;目录没有问题),
9
9
  * 不提目录、不提不可变标志;`path` 是被保留模式的**真文件**(chmod 作用在替换它的临时副本上,用户认得的是真文件名);
10
10
  * · `rename` —— 原子写器 `rename` 盖过目标。目录收了新文件、却换不掉这一份 ⇒ 点名**真文件**;
11
- * · `remove` —— 删一个文件。删的是目录项:目录不让删 ⇒ 点名文件所在的**目录**(与建临时文件同一个因);
12
11
  * · `read` —— 读一个目录或文件;
13
12
  * · `write` —— 写口整体失败、步骤看不见(注入的写口抛的错,不是本包原子写器抛的):只点名要写的文件。
14
13
  * 认得的 errno 给那一步对应的出路,别的 errno(磁盘满、I/O 错 …)给 Node 自己的句子 —— 照样响亮,只是不替它猜出路。两条与落点无关的律:
15
14
  * · errno 只打一遍 —— 句首括号里一次,Node 句子自带的 `<errno>: ` 前缀去掉;
16
15
  * · `ENAMETOOLONG`(路径某一节或整条超限)既不是目录的错也不是文件的错 ⇒ 一句 `path too long: <被操作系统拒的路径> (ENAMETOOLONG)`,不点名目录、不给权限类出路。
17
- * 三个落点(`dir-create-temp` / `remove` / `rename`)的权限类出路走**同一张表**、一只函数({@link permissionWayOut}):落点表 {@link WAY_OUT_LANDING}(这个落点认哪些 errno、清标志点名谁、动已有目录项的落点才有粘滞目录一句)×
16
+ * 两个落点(`dir-create-temp` / `rename`;26.0.0 起删文件的 `remove` 随目录迁移唯一的删文件口一起删了)的权限类出路走**同一张表**、一只函数({@link permissionWayOut}):落点表 {@link WAY_OUT_LANDING}(这个落点认哪些 errno、清标志点名谁、动已有目录项的落点才有粘滞目录一句)×
18
17
  * errno 表 {@link WAY_OUT_BY_ERRNO}(穷举;每个 errno 两格 —— 目录权限位对本进程「可写」/「不可写或没读过」)。同一个 `EPERM` 既可能是目录模式不让写,也可能是不可变标志(macOS `chflags uchg` / Linux `chattr +i`),
19
18
  * 同一个 `EACCES` 在模式位已经放行时只能是 ACL 条目或安全模块策略 —— 铸点是纯函数,分不清,但调用方在 Node 一侧能读目录模式,把「模式对本进程可写」这个事实经落点的 `directoryWritable` 递进来:
20
- * 「可写」⇒ chmod 已经没用,`EPERM` 的首选出路 = 清标志(`chflags nouchg` / `chattr -i`),动已有目录项的落点(remove / rename)再接粘滞目录一句(那条属主规则给的就是 `EPERM`),`EACCES` 的出路 = 查 ACL / 安全模块(不接粘滞句);
19
+ * 「可写」⇒ chmod 已经没用,`EPERM` 的首选出路 = 清标志(`chflags nouchg` / `chattr -i`),动已有目录项的落点(rename)再接粘滞目录一句(那条属主规则给的就是 `EPERM`),`EACCES` 的出路 = 查 ACL / 安全模块(不接粘滞句);
21
20
  * 否则(模式不可写,或调用方没读过模式 —— 注入的替身 I/O 抛的错,包看不到它背后)⇒ 先让目录可写,`EPERM` / `EROFS` 句尾提示「只读 / 不可变」的可能。`EROFS` 的出路不变(只读文件系统清不掉)。
22
21
  * `rename` 落点的「可写」不是读出来的而是已证明的({@link RENAME_DIRECTORY_WRITABLE}:走到 rename 时临时文件刚在同一目录建成)—— 一个来源,`EPERM` 与 `EACCES` 同走「可写」那一列,所以 rename 句从不说「make the directory writable」。
23
22
  *
@@ -47,10 +46,9 @@ const WAY_OUT_BY_ERRNO = {
47
46
  };
48
47
  const WAY_OUT_LANDING = {
49
48
  "dir-create-temp": { errnos: ["EACCES", "EPERM", "EROFS", "ENOENT"], flagSubject: "the directory" },
50
- remove: { errnos: ["EACCES", "EPERM", "EROFS"], flagSubject: "the file or its directory", stickyVerb: "remove" },
51
49
  rename: { errnos: ["EACCES", "EPERM"], flagSubject: "the file or its directory", stickyVerb: "replace" },
52
50
  };
53
- /** 权限类出路的**唯一一只函数**(三个落点共用,表驱动):`code` 不是这个落点认的权限类 errno ⇒ `undefined`(调用方给 Node 自己的句子)。
51
+ /** 权限类出路的**唯一一只函数**(两个落点共用,表驱动):`code` 不是这个落点认的权限类 errno ⇒ `undefined`(调用方给 Node 自己的句子)。
54
52
  * 组合律一条:errno 表的格(按 `directoryWritable === true` 选「可写」列或「不可写或没读过」列);「可写」∧ 该 errno 带粘滞 ∧ 这个落点有 `stickyVerb` ⇒ 句尾接 `in a sticky directory only the file's owner may <verb> it`。 */
55
53
  const permissionWayOut = (landing, code, directoryWritable) => {
56
54
  const spec = WAY_OUT_LANDING[landing];
@@ -94,8 +92,6 @@ export function fsFailureSentence(site, cause) {
94
92
  return `cannot set the mode of ${site.path}${tag}: ${code !== undefined && CHMOD_REFUSED.has(code) ? CHMOD_WAY_OUT : nodeSentenceOf(cause, code)}`;
95
93
  case "rename":
96
94
  return `cannot replace ${site.path}${tag}: ${permissionWayOut("rename", code, RENAME_DIRECTORY_WRITABLE) ?? nodeSentenceOf(cause, code)}`;
97
- case "remove":
98
- return `cannot remove ${site.path} from directory ${parentDirectory(site.path)}${tag}: ${permissionWayOut("remove", code, site.directoryWritable) ?? nodeSentenceOf(cause, code)}`;
99
95
  case "read":
100
96
  return `cannot read ${site.of === "directory" ? "directory " : ""}${site.path}${tag}: ${nodeSentenceOf(cause, code)}`;
101
97
  case "write":
package/dist/hooks.d.ts CHANGED
@@ -78,21 +78,56 @@ export declare const HookEventName: z.ZodEnum<{
78
78
  }>;
79
79
  export type HookEventName = z.infer<typeof HookEventName>;
80
80
  export declare const HookOwner: z.ZodEnum<{
81
- shell: "shell";
82
81
  engine: "engine";
82
+ shell: "shell";
83
83
  }>;
84
84
  export type HookOwner = z.infer<typeof HookOwner>;
85
85
  /**
86
- * Events whose TRIGGER lives in the engine half of sema's two-process wire (corrected mapping):
87
- * - tool-execution chain: PreToolUse / PostToolUse / PostToolUseFailure / PostToolBatch
86
+ * Events whose TRIGGER lives in the engine half of sema's two-process wire — the owner of an event is the half where the
87
+ * occurrence it names happens:
88
+ * - tool-execution chain: PreToolUse / PostToolUse / PostToolUseFailure / PostToolBatch, and PermissionDenied — a
89
+ * tool call refused by the engine's tool gate; the refusal is decided in the tool-execution chain, not in a dialog
88
90
  * - compaction (runs engine-side): PreCompact / PostCompact
89
91
  * - model-turn boundary (run-end is only known to the engine): Stop / StopFailure / UserPromptSubmit
90
- * Everything else is shell-owned (UI / lifecycle; the permission UI, sessions, teams, worktrees, files
91
- * live in the shell). Matches the shell's ENGINE_OWNED_HOOK_EVENTS verbatim.
92
+ * Everything else is shell-owned (UI / lifecycle: the permission dialog — PermissionRequest —, sessions, teams, worktrees,
93
+ * files live in the shell). A shell that routes hooks by owner derives its table from this one (no second copy).
94
+ *
95
+ * FROM WHICH CONTRACT VERSION a member counts as engine-owned is data, not prose: {@link ENGINE_OWNED_HOOK_EVENT_SINCE} (one row
96
+ * per member, a compile error when a member has no row), read through {@link engineOwnsHookEventAt} — a peer that embeds an older
97
+ * contract than a member's row does not know the member is engine-owned. A consumer that routes by this set must not keep its own
98
+ * table of "which member joined at which version".
92
99
  */
93
- export declare const ENGINE_OWNED_HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "PreCompact", "PostCompact", "Stop", "StopFailure", "UserPromptSubmit"];
100
+ export declare const ENGINE_OWNED_HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "PreCompact", "PostCompact", "Stop", "StopFailure", "UserPromptSubmit", "PermissionDenied"];
94
101
  /** owner per event — single owner; the non-owner side never fires it (dedup rule). */
95
102
  export declare const HOOK_EVENT_OWNER: Readonly<Record<HookEventName, HookOwner>>;
103
+ /** One member of {@link ENGINE_OWNED_HOOK_EVENTS} (the events whose trigger lives in the engine half). */
104
+ export type EngineOwnedHookEvent = (typeof ENGINE_OWNED_HOOK_EVENTS)[number];
105
+ /**
106
+ * The first version of THIS package whose {@link ENGINE_OWNED_HOOK_EVENTS} carried each member — the contract version from which a peer that
107
+ * embeds this package treats the event as engine-owned (the server reports its embedded version as `settingsContract.version` on
108
+ * `GET /v1/capabilities`). A complete `x.y.z`.
109
+ *
110
+ * One row per member of {@link ENGINE_OWNED_HOOK_EVENTS}, no more, no fewer: a member added to that set without a row here, or a row for an event
111
+ * that is not in the set, does not compile. Values were read from the release history (each tag's `src/hooks.ts`), not from memory:
112
+ * - `PermissionDenied` — the tool gate's refusal — became engine-owned in 26.0.0 (the release before it owned nine events and listed it as shell-owned);
113
+ * - the other nine are `1.0.0`: the first version under this package's current name already listed them, in this order. They are older than
114
+ * that (the set predates the rename), so `1.0.0` is the floor of what this package's name can report, not an introduction date — every peer that
115
+ * reports a contract version of this package has it.
116
+ *
117
+ * Frozen: every reader in a process shares it. Read it through {@link engineOwnsHookEventAt}; do not compare against it by hand.
118
+ */
119
+ export declare const ENGINE_OWNED_HOOK_EVENT_SINCE: Readonly<Record<EngineOwnedHookEvent, string>>;
120
+ /**
121
+ * Is `event` engine-owned for a peer whose embedded contract is `contractVersion`? `true` ⟺ `event` is a member of {@link ENGINE_OWNED_HOOK_EVENTS}
122
+ * AND `contractVersion` ≥ its row in {@link ENGINE_OWNED_HOOK_EVENT_SINCE} (numeric, segment by segment). Anything else — a shell-owned event, a
123
+ * name that is not a hook event at all — is `false` at every version.
124
+ *
125
+ * `contractVersion` is a complete `x.y.z` and nothing else; a malformed one THROWS a `TypeError` (checked before the event, so a bad version never reads
126
+ * as "not engine-owned"): a pre-release (`26.0.0-rc.1`) sorts before its release and whether it already carried a member is a guess this function does
127
+ * not make, so the caller strips the suffix (or applies its own rule) before asking. `undefined` is not accepted either: when the peer reports no
128
+ * version, the consumer passes the contract version embedded by the oldest peer generation it supports — that is the generation it must be right about.
129
+ */
130
+ export declare function engineOwnsHookEventAt(event: string, contractVersion: string): boolean;
96
131
  /**
97
132
  * Which INPUT FIELD an entry's `matcher` string is matched against, per event (`null` = matchers are
98
133
  * ignored for the event; every entry matches). Ported from the shell's getMatchingHooks switch. HOW the matcher is read
package/dist/hooks.js CHANGED
@@ -49,12 +49,19 @@ export const HookEventName = z.enum(HOOK_EVENTS);
49
49
  // ── ownership (owner-single) ─────────────────────────────────────────────────────────────────────
50
50
  export const HookOwner = z.enum(["engine", "shell"]);
51
51
  /**
52
- * Events whose TRIGGER lives in the engine half of sema's two-process wire (corrected mapping):
53
- * - tool-execution chain: PreToolUse / PostToolUse / PostToolUseFailure / PostToolBatch
52
+ * Events whose TRIGGER lives in the engine half of sema's two-process wire — the owner of an event is the half where the
53
+ * occurrence it names happens:
54
+ * - tool-execution chain: PreToolUse / PostToolUse / PostToolUseFailure / PostToolBatch, and PermissionDenied — a
55
+ * tool call refused by the engine's tool gate; the refusal is decided in the tool-execution chain, not in a dialog
54
56
  * - compaction (runs engine-side): PreCompact / PostCompact
55
57
  * - model-turn boundary (run-end is only known to the engine): Stop / StopFailure / UserPromptSubmit
56
- * Everything else is shell-owned (UI / lifecycle; the permission UI, sessions, teams, worktrees, files
57
- * live in the shell). Matches the shell's ENGINE_OWNED_HOOK_EVENTS verbatim.
58
+ * Everything else is shell-owned (UI / lifecycle: the permission dialog — PermissionRequest —, sessions, teams, worktrees,
59
+ * files live in the shell). A shell that routes hooks by owner derives its table from this one (no second copy).
60
+ *
61
+ * FROM WHICH CONTRACT VERSION a member counts as engine-owned is data, not prose: {@link ENGINE_OWNED_HOOK_EVENT_SINCE} (one row
62
+ * per member, a compile error when a member has no row), read through {@link engineOwnsHookEventAt} — a peer that embeds an older
63
+ * contract than a member's row does not know the member is engine-owned. A consumer that routes by this set must not keep its own
64
+ * table of "which member joined at which version".
58
65
  */
59
66
  export const ENGINE_OWNED_HOOK_EVENTS = [
60
67
  "PreToolUse",
@@ -66,9 +73,66 @@ export const ENGINE_OWNED_HOOK_EVENTS = [
66
73
  "Stop",
67
74
  "StopFailure",
68
75
  "UserPromptSubmit",
76
+ "PermissionDenied",
69
77
  ];
70
78
  /** owner per event — single owner; the non-owner side never fires it (dedup rule). */
71
79
  export const HOOK_EVENT_OWNER = Object.fromEntries(HOOK_EVENTS.map((e) => [e, ENGINE_OWNED_HOOK_EVENTS.includes(e) ? "engine" : "shell"]));
80
+ /**
81
+ * The first version of THIS package whose {@link ENGINE_OWNED_HOOK_EVENTS} carried each member — the contract version from which a peer that
82
+ * embeds this package treats the event as engine-owned (the server reports its embedded version as `settingsContract.version` on
83
+ * `GET /v1/capabilities`). A complete `x.y.z`.
84
+ *
85
+ * One row per member of {@link ENGINE_OWNED_HOOK_EVENTS}, no more, no fewer: a member added to that set without a row here, or a row for an event
86
+ * that is not in the set, does not compile. Values were read from the release history (each tag's `src/hooks.ts`), not from memory:
87
+ * - `PermissionDenied` — the tool gate's refusal — became engine-owned in 26.0.0 (the release before it owned nine events and listed it as shell-owned);
88
+ * - the other nine are `1.0.0`: the first version under this package's current name already listed them, in this order. They are older than
89
+ * that (the set predates the rename), so `1.0.0` is the floor of what this package's name can report, not an introduction date — every peer that
90
+ * reports a contract version of this package has it.
91
+ *
92
+ * Frozen: every reader in a process shares it. Read it through {@link engineOwnsHookEventAt}; do not compare against it by hand.
93
+ */
94
+ export const ENGINE_OWNED_HOOK_EVENT_SINCE = Object.freeze({
95
+ PreToolUse: "1.0.0",
96
+ PostToolUse: "1.0.0",
97
+ PostToolUseFailure: "1.0.0",
98
+ PostToolBatch: "1.0.0",
99
+ PreCompact: "1.0.0",
100
+ PostCompact: "1.0.0",
101
+ Stop: "1.0.0",
102
+ StopFailure: "1.0.0",
103
+ UserPromptSubmit: "1.0.0",
104
+ PermissionDenied: "26.0.0",
105
+ });
106
+ /** A complete `x.y.z`: three decimal numbers, no leading zeros (so numeric order is digit-count order, then digits), no pre-release / build part, no prefix. */
107
+ const CONTRACT_VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
108
+ function readContractVersion(value) {
109
+ const m = typeof value === "string" ? CONTRACT_VERSION.exec(value) : null;
110
+ if (m === null) {
111
+ throw new TypeError("engineOwnsHookEventAt: contractVersion must be a complete x.y.z version string (decimal digits, no leading zeros, no pre-release or build part, no `v` prefix) — " +
112
+ "the peer's reported contract version, or the one embedded by the oldest peer generation the consumer supports when the peer reports none");
113
+ }
114
+ return [BigInt(m[1]), BigInt(m[2]), BigInt(m[3])];
115
+ }
116
+ /**
117
+ * Is `event` engine-owned for a peer whose embedded contract is `contractVersion`? `true` ⟺ `event` is a member of {@link ENGINE_OWNED_HOOK_EVENTS}
118
+ * AND `contractVersion` ≥ its row in {@link ENGINE_OWNED_HOOK_EVENT_SINCE} (numeric, segment by segment). Anything else — a shell-owned event, a
119
+ * name that is not a hook event at all — is `false` at every version.
120
+ *
121
+ * `contractVersion` is a complete `x.y.z` and nothing else; a malformed one THROWS a `TypeError` (checked before the event, so a bad version never reads
122
+ * as "not engine-owned"): a pre-release (`26.0.0-rc.1`) sorts before its release and whether it already carried a member is a guess this function does
123
+ * not make, so the caller strips the suffix (or applies its own rule) before asking. `undefined` is not accepted either: when the peer reports no
124
+ * version, the consumer passes the contract version embedded by the oldest peer generation it supports — that is the generation it must be right about.
125
+ */
126
+ export function engineOwnsHookEventAt(event, contractVersion) {
127
+ const peer = readContractVersion(contractVersion);
128
+ if (!ENGINE_OWNED_HOOK_EVENTS.includes(event))
129
+ return false;
130
+ const since = readContractVersion(ENGINE_OWNED_HOOK_EVENT_SINCE[event]);
131
+ for (let i = 0; i < 3; i++)
132
+ if (peer[i] !== since[i])
133
+ return peer[i] > since[i];
134
+ return true;
135
+ }
72
136
  /**
73
137
  * Which INPUT FIELD an entry's `matcher` string is matched against, per event (`null` = matchers are
74
138
  * ignored for the event; every entry matches). Ported from the shell's getMatchingHooks switch. HOW the matcher is read
@@ -1,29 +1,27 @@
1
1
  /**
2
2
  * 一次性迁移的**收据形**与两张闭集(11.0.0)—— 叶子模块(运行期零依赖;只有型导入),由 `./one-time-migrations` 再导出(不进主桶)。
3
- * 单拆出来只为一件事:调度店的读口(`./scheduler-store`,轻、浏览器安全)要在告警里带收据,不该为一个型把整套域 schema 拉进来。
3
+ * 单拆出来只为一件事:读迁移 id 闭集的叶子(墓碑句 `./retired-form`、车道表 `./execution-lane-index`、配置根文档 `./config-root-documents`)
4
+ * 不该为一个型把整套迁移体与域 schema 拉进来。(26.0.0 起调度店的读口不再带收据 —— 它的读时改写到期删了。)
4
5
  */
5
6
  import type { ENV_MODELS_DOCUMENT } from "./config-root-documents.js";
6
- import type { REMOTE_EXEC_DOCUMENT } from "./remote-exec.js";
7
- import type { DomainName, RetiredDomainName } from "./types.js";
8
- /** 本版登记的一次性**数据**迁移 id(闭集;每个 id 在 `ONE_TIME_MIGRATIONS` 登记表里恰一行)。收据只许这些 id —— 同表登记的 wire 删码位
9
- * (`WIRE_RETIREMENT_IDS`,`./one-time-migrations`)不改任何存储形,铸不出收据,不在本集。 */
10
- export declare const ONE_TIME_MIGRATION_IDS: readonly ["SS-M1", "SS-M2", "SS-M3", "SS-M4", "SS-M5", "SS-M6", "SS-M7", "SS-M8", "SS-M9", "SS-M10", "SS-M11", "SS-M12"];
7
+ import type { DomainName } from "./types.js";
8
+ /** 本版登记的一次性迁移 id(闭集;每个 id 在 `ONE_TIME_MIGRATIONS` 登记表里恰一行)。收据只许这些 id。 */
9
+ export declare const ONE_TIME_MIGRATION_IDS: readonly ["SS-M8", "SS-M10", "SS-M11", "SS-M12"];
11
10
  export type OneTimeMigrationId = (typeof ONE_TIME_MIGRATION_IDS)[number];
12
11
  /**
13
12
  * 一条收据说迁移**对一个坐标做了什么**(闭集,每词一义):
14
13
  * - `moved` — 值搬到新位(`to`),义不变;
15
- * - `rewritten` — 同一坐标上的值换成今天的生效读法(例:URL 剥掉从不上线的 fragment、调度行的 durable 键重铸、6.x 的 worker 行换新形);
16
- * - `dropped-shadowed` — 删掉;它从来没生效过,因为另一个位赢了(例:`governance` 已设时 `runtime` 上的治理旧键、`sealedApiKey` 在场时的 `apiKeyEnv`);
17
- * - `dropped-inert` — 删掉;今天的读法本就不让它生效(例:超界的主机条目、引擎从不读的旧字段、空的retired 域文档);
14
+ * - `rewritten` — 同一坐标上的值换成今天的生效读法(例:15.x worker 行的记忆方言词 `tidb` ⇒ `mysql`);
15
+ * - `dropped-inert` — 删掉;今天的读法本就不让它生效(例:core 7.49.0 起引擎不再认的角色词 `team` / `synthesize`、空的 `bindings: []`、不声明那条车道的行上的车道键);
18
16
  * - `refused` — 不改:要改就得替运维猜(或旧文档今天本就读不进);原样留着,读侧照旧响亮拒,`reason` 说为什么;
19
17
  * - `minted` — 在**缺席处**写下一份新事实(一份部署决定),不改任何已有的值 —— 只有 SS-M11 铸(配置根的 `config.env-models.json`:
20
18
  * 升级前「管模型面的目录整表顶替 env 模型」的读法,写成 `replaced`;不存在才建)。
21
19
  */
22
- export declare const MIGRATION_APPLIED_AS: readonly ["moved", "rewritten", "dropped-shadowed", "dropped-inert", "refused", "minted"];
20
+ export declare const MIGRATION_APPLIED_AS: readonly ["moved", "rewritten", "dropped-inert", "refused", "minted"];
23
21
  export type MigrationAppliedAs = (typeof MIGRATION_APPLIED_AS)[number];
24
- /** 收据指向的那份文档:配置域名、retired 域名(`runtime`)、`config.d/remote-exec.json`(`remote-exec`)、调度店(`scheduler-store`),
25
- * 或配置根上的 env 模型表决定(`config.env-models`,SS-M11 铸)。 */
26
- export type MigrationDocument = DomainName | RetiredDomainName | typeof REMOTE_EXEC_DOCUMENT | "scheduler-store" | typeof ENV_MODELS_DOCUMENT;
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;
27
25
  /** 文档里的段坐标(字符串段 = 对象键,数字段 = 数组下标;与告警坐标同一形)。 */
28
26
  export type MigrationPath = readonly (string | number)[];
29
27
  interface ReceiptBase {
@@ -39,7 +37,7 @@ export type MigrationReceipt = (ReceiptBase & {
39
37
  readonly path: MigrationPath;
40
38
  };
41
39
  }) | (ReceiptBase & {
42
- readonly appliedAs: "rewritten" | "dropped-shadowed" | "dropped-inert" | "minted";
40
+ readonly appliedAs: "rewritten" | "dropped-inert" | "minted";
43
41
  }) | (ReceiptBase & {
44
42
  readonly appliedAs: "refused";
45
43
  readonly reason: string;
@@ -1,14 +1,12 @@
1
- /** 本版登记的一次性**数据**迁移 id(闭集;每个 id 在 `ONE_TIME_MIGRATIONS` 登记表里恰一行)。收据只许这些 id —— 同表登记的 wire 删码位
2
- * (`WIRE_RETIREMENT_IDS`,`./one-time-migrations`)不改任何存储形,铸不出收据,不在本集。 */
3
- export const ONE_TIME_MIGRATION_IDS = ["SS-M1", "SS-M2", "SS-M3", "SS-M4", "SS-M5", "SS-M6", "SS-M7", "SS-M8", "SS-M9", "SS-M10", "SS-M11", "SS-M12"];
1
+ /** 本版登记的一次性迁移 id(闭集;每个 id 在 `ONE_TIME_MIGRATIONS` 登记表里恰一行)。收据只许这些 id。 */
2
+ export const ONE_TIME_MIGRATION_IDS = ["SS-M8", "SS-M10", "SS-M11", "SS-M12"];
4
3
  /**
5
4
  * 一条收据说迁移**对一个坐标做了什么**(闭集,每词一义):
6
5
  * - `moved` — 值搬到新位(`to`),义不变;
7
- * - `rewritten` — 同一坐标上的值换成今天的生效读法(例:URL 剥掉从不上线的 fragment、调度行的 durable 键重铸、6.x 的 worker 行换新形);
8
- * - `dropped-shadowed` — 删掉;它从来没生效过,因为另一个位赢了(例:`governance` 已设时 `runtime` 上的治理旧键、`sealedApiKey` 在场时的 `apiKeyEnv`);
9
- * - `dropped-inert` — 删掉;今天的读法本就不让它生效(例:超界的主机条目、引擎从不读的旧字段、空的retired 域文档);
6
+ * - `rewritten` — 同一坐标上的值换成今天的生效读法(例:15.x worker 行的记忆方言词 `tidb` ⇒ `mysql`);
7
+ * - `dropped-inert` — 删掉;今天的读法本就不让它生效(例:core 7.49.0 起引擎不再认的角色词 `team` / `synthesize`、空的 `bindings: []`、不声明那条车道的行上的车道键);
10
8
  * - `refused` — 不改:要改就得替运维猜(或旧文档今天本就读不进);原样留着,读侧照旧响亮拒,`reason` 说为什么;
11
9
  * - `minted` — 在**缺席处**写下一份新事实(一份部署决定),不改任何已有的值 —— 只有 SS-M11 铸(配置根的 `config.env-models.json`:
12
10
  * 升级前「管模型面的目录整表顶替 env 模型」的读法,写成 `replaced`;不存在才建)。
13
11
  */
14
- export const MIGRATION_APPLIED_AS = ["moved", "rewritten", "dropped-shadowed", "dropped-inert", "refused", "minted"];
12
+ export const MIGRATION_APPLIED_AS = ["moved", "rewritten", "dropped-inert", "refused", "minted"];
package/dist/node.js CHANGED
@@ -11,7 +11,7 @@ export * from "./local-load.js";
11
11
  // 一份 `config.d/<名>.json` 的读数(缺席 / 在场 / 被拒)的**同步读口**:与包内异步读口同一只纯判、同一个缺席尾(壳在同步具名锁里读 `config.d` 文档用它,不自读文本);纯判本身与异步读口不出门。显式列名。
12
12
  export { readConfigDFileReadingSync } from "./config-d-file.js";
13
13
  export * from "./scheduler-store-node.js"; // R7 self-wake scheduler store — fs binding of the ./scheduler-store contract
14
- // 目录形的一次性迁移(读目录 → 迁 → 整域终判 → 原子写 → 删 retired 域文件)—— 语义只此一处,命令行是它的渲染器、引擎起服调同一只。显式列名:该模块的包内私有件(出门形/拼路径)不外泄。
14
+ // 目录形的一次性迁移(读目录 → 迁 → 整域终判 → 原子写;从不删文件)—— 语义只此一处,命令行是它的渲染器、引擎起服调同一只。显式列名:该模块的包内私有件(出门形/拼路径)不外泄。
15
15
  export { migrateConfigDirectory, migrateConfigDocuments, // 14.5.0:同一段「迁 → 整域终判」的同步口(入参是已有的存量文档,无 io)—— 目录形调的就是它的内核
16
16
  } from "./config-dir-migration.js";
17
17
  export { nodeConfigDirectoryIo } from "./config-dir-io.js"; // 上面那只函数的真 I/O 绑定:node:fs + 本包唯一的原子写器(config-document 模式规则)