@substrat-run/kernel 0.137.0 → 0.139.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 (121) hide show
  1. package/dist/attachment-extractor.d.ts +9 -1
  2. package/dist/attachment-extractor.d.ts.map +1 -1
  3. package/dist/attachment-extractor.js +21 -1
  4. package/dist/attachment-extractor.js.map +1 -1
  5. package/dist/attachment-text.d.ts +64 -0
  6. package/dist/attachment-text.d.ts.map +1 -1
  7. package/dist/attachment-text.js +87 -16
  8. package/dist/attachment-text.js.map +1 -1
  9. package/dist/attribution.d.ts +36 -3
  10. package/dist/attribution.d.ts.map +1 -1
  11. package/dist/attribution.js +21 -8
  12. package/dist/attribution.js.map +1 -1
  13. package/dist/delivery-refusal.d.ts +21 -0
  14. package/dist/delivery-refusal.d.ts.map +1 -0
  15. package/dist/delivery-refusal.js +21 -0
  16. package/dist/delivery-refusal.js.map +1 -0
  17. package/dist/entity-state-reads.d.ts +43 -0
  18. package/dist/entity-state-reads.d.ts.map +1 -0
  19. package/dist/entity-state-reads.js +135 -0
  20. package/dist/entity-state-reads.js.map +1 -0
  21. package/dist/entity-state.d.ts +177 -0
  22. package/dist/entity-state.d.ts.map +1 -0
  23. package/dist/entity-state.js +345 -0
  24. package/dist/entity-state.js.map +1 -0
  25. package/dist/findings.d.ts +143 -0
  26. package/dist/findings.d.ts.map +1 -0
  27. package/dist/findings.js +463 -0
  28. package/dist/findings.js.map +1 -0
  29. package/dist/index.d.ts +30 -20
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +22 -14
  32. package/dist/index.js.map +1 -1
  33. package/dist/job-run.d.ts +309 -48
  34. package/dist/job-run.d.ts.map +1 -1
  35. package/dist/job-run.js +388 -80
  36. package/dist/job-run.js.map +1 -1
  37. package/dist/list-index.d.ts +25 -3
  38. package/dist/list-index.d.ts.map +1 -1
  39. package/dist/list-index.js +70 -26
  40. package/dist/list-index.js.map +1 -1
  41. package/dist/membership-executor.d.ts +109 -0
  42. package/dist/membership-executor.d.ts.map +1 -0
  43. package/dist/membership-executor.js +261 -0
  44. package/dist/membership-executor.js.map +1 -0
  45. package/dist/membership-fence.d.ts +57 -0
  46. package/dist/membership-fence.d.ts.map +1 -0
  47. package/dist/membership-fence.js +90 -0
  48. package/dist/membership-fence.js.map +1 -0
  49. package/dist/module-migrations.d.ts +6 -3
  50. package/dist/module-migrations.d.ts.map +1 -1
  51. package/dist/module-migrations.js +12 -5
  52. package/dist/module-migrations.js.map +1 -1
  53. package/dist/operation-series.d.ts +58 -0
  54. package/dist/operation-series.d.ts.map +1 -0
  55. package/dist/operation-series.js +63 -0
  56. package/dist/operation-series.js.map +1 -0
  57. package/dist/peer.d.ts +13 -8
  58. package/dist/peer.d.ts.map +1 -1
  59. package/dist/peer.js +13 -14
  60. package/dist/peer.js.map +1 -1
  61. package/dist/permission-eval.d.ts +80 -1
  62. package/dist/permission-eval.d.ts.map +1 -1
  63. package/dist/permission-eval.js +164 -18
  64. package/dist/permission-eval.js.map +1 -1
  65. package/dist/platform-sweep.d.ts +7 -1
  66. package/dist/platform-sweep.d.ts.map +1 -1
  67. package/dist/platform-sweep.js +12 -0
  68. package/dist/platform-sweep.js.map +1 -1
  69. package/dist/read-only-sql.d.ts +2 -26
  70. package/dist/read-only-sql.d.ts.map +1 -1
  71. package/dist/read-only-sql.js +13 -9
  72. package/dist/read-only-sql.js.map +1 -1
  73. package/dist/scope-copy.d.ts +18 -0
  74. package/dist/scope-copy.d.ts.map +1 -1
  75. package/dist/scope-copy.js +18 -0
  76. package/dist/scope-copy.js.map +1 -1
  77. package/dist/scope-host.d.ts +416 -13
  78. package/dist/scope-host.d.ts.map +1 -1
  79. package/dist/scope-host.js +51 -2
  80. package/dist/scope-host.js.map +1 -1
  81. package/dist/scope-role-admin.d.ts +68 -0
  82. package/dist/scope-role-admin.d.ts.map +1 -0
  83. package/dist/scope-role-admin.js +80 -0
  84. package/dist/scope-role-admin.js.map +1 -0
  85. package/dist/search-index.d.ts +13 -1
  86. package/dist/search-index.d.ts.map +1 -1
  87. package/dist/search-index.js +9 -16
  88. package/dist/search-index.js.map +1 -1
  89. package/dist/spine-guard.d.ts +64 -2
  90. package/dist/spine-guard.d.ts.map +1 -1
  91. package/dist/spine-guard.js +345 -10
  92. package/dist/spine-guard.js.map +1 -1
  93. package/dist/spine-restore.d.ts +7 -2
  94. package/dist/spine-restore.d.ts.map +1 -1
  95. package/dist/spine-restore.js +13 -5
  96. package/dist/spine-restore.js.map +1 -1
  97. package/dist/sql-identifier.d.ts +12 -0
  98. package/dist/sql-identifier.d.ts.map +1 -0
  99. package/dist/sql-identifier.js +17 -0
  100. package/dist/sql-identifier.js.map +1 -0
  101. package/dist/system-switch-record.d.ts +277 -77
  102. package/dist/system-switch-record.d.ts.map +1 -1
  103. package/dist/system-switch-record.js +322 -105
  104. package/dist/system-switch-record.js.map +1 -1
  105. package/dist/system-switch.d.ts +110 -14
  106. package/dist/system-switch.d.ts.map +1 -1
  107. package/dist/system-switch.js +92 -17
  108. package/dist/system-switch.js.map +1 -1
  109. package/dist/timeline.d.ts +23 -0
  110. package/dist/timeline.d.ts.map +1 -1
  111. package/dist/timeline.js +30 -0
  112. package/dist/timeline.js.map +1 -1
  113. package/dist/ulid.d.ts +5 -0
  114. package/dist/ulid.d.ts.map +1 -1
  115. package/dist/ulid.js +9 -0
  116. package/dist/ulid.js.map +1 -1
  117. package/dist/vertical-events.d.ts +7 -1
  118. package/dist/vertical-events.d.ts.map +1 -1
  119. package/dist/vertical-events.js +14 -0
  120. package/dist/vertical-events.js.map +1 -1
  121. package/package.json +4 -4
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The check every kernel-derived DDL runs on a name before interpolating it (#827, #811, #119).
3
+ *
4
+ * SQL identifiers reach the DDL by interpolation — there is no parameter form for a table or
5
+ * column name — so every one is checked first. The inputs are declarations rather than user
6
+ * input, but a declaration is still a string somebody typed, and "it came from the manifest"
7
+ * is exactly the reasoning that makes an injection a surprise.
8
+ */
9
+ export declare const SQL_IDENTIFIER: RegExp;
10
+ /** `value`, or a throw naming the declaration (`where`) and the role it plays (`kind`). */
11
+ export declare function assertSqlIdentifier(area: string, kind: string, value: string, where: string): string;
12
+ //# sourceMappingURL=sql-identifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-identifier.d.ts","sourceRoot":"","sources":["../src/sql-identifier.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,QAA6B,CAAC;AAEzD,2FAA2F;AAC3F,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAKpG"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The check every kernel-derived DDL runs on a name before interpolating it (#827, #811, #119).
3
+ *
4
+ * SQL identifiers reach the DDL by interpolation — there is no parameter form for a table or
5
+ * column name — so every one is checked first. The inputs are declarations rather than user
6
+ * input, but a declaration is still a string somebody typed, and "it came from the manifest"
7
+ * is exactly the reasoning that makes an injection a surprise.
8
+ */
9
+ export const SQL_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
10
+ /** `value`, or a throw naming the declaration (`where`) and the role it plays (`kind`). */
11
+ export function assertSqlIdentifier(area, kind, value, where) {
12
+ if (!SQL_IDENTIFIER.test(value)) {
13
+ throw new Error(`${area}: ${where} names ${kind} '${value}', which is not a plain SQL identifier`);
14
+ }
15
+ return value;
16
+ }
17
+ //# sourceMappingURL=sql-identifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-identifier.js","sourceRoot":"","sources":["../src/sql-identifier.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAEzD,2FAA2F;AAC3F,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,IAAY,EAAE,KAAa,EAAE,KAAa;IAC1F,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,wCAAwC,CAAC,CAAC;IACrG,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -23,9 +23,25 @@
23
23
  * would be a second one.
24
24
  *
25
25
  * The admin log is still the history. This is only the current position.
26
+ *
27
+ * **The record and the scope follow the same call** (#2045). A switch call writes this record, then
28
+ * moves the scope, and nothing makes the pair one unit, so two calls on one subject could interleave
29
+ * and leave the two on different positions. Each row holds the operation id of the call that wrote
30
+ * it, and a write from an older call writes nothing (`recordWriteSuperseded`). The scope refuses an
31
+ * older move the same way (`SWITCH_FENCES_DDL`), and re-asserts move under the row's id
32
+ * (`switchFencesOf`). Both sides therefore settle on the newest call's position.
33
+ *
34
+ * **Two kinds of switch, one record path** (#2029). The peer kill switch (#1706,
35
+ * `revokeFromPeer`) moves the same marker for a `vertical:<slug>` subject, and loses it the
36
+ * same ways: a wipe, a restore, a PITR rewind. So it is recorded the same way, in its own
37
+ * table (`_substrat_peer_switches`, keyed by the calling vertical's slug), by the same
38
+ * functions below, each told which `SwitchKind` it is writing. Its own table, not rows in the
39
+ * module table: that table's key is (tenant, scope, module id), and a vertical slug can be
40
+ * spelled exactly like a module id.
26
41
  */
27
42
  import type { ListPage } from '@substrat-run/contracts';
28
- import type { SwitchSql, SwitchedOff, SystemScheduleState } from './system-switch.js';
43
+ import { type SwitchKind, type SwitchSql, type SwitchedOff, type SystemScheduleState } from './system-switch.js';
44
+ export type { SwitchKind };
29
45
  /** The record's table name, as the DDL below spells it. */
30
46
  export declare const SYSTEM_SWITCHES_TABLE = "_substrat_system_switches";
31
47
  /**
@@ -34,33 +50,113 @@ export declare const SYSTEM_SWITCHES_TABLE = "_substrat_system_switches";
34
50
  * constraints, and the writers below are the only thing that sets it.
35
51
  */
36
52
  export declare const SYSTEM_SWITCHES_DDL = "\n CREATE TABLE IF NOT EXISTS _substrat_system_switches (\n tenant_id TEXT NOT NULL,\n scope_id TEXT NOT NULL,\n module_id TEXT NOT NULL,\n -- 'on' or 'off'. A row exists only for a module some switch call actually held.\n position TEXT NOT NULL,\n actor TEXT NOT NULL,\n reason TEXT NOT NULL,\n -- The switch call's own id, the one its admin-log intent and outcome rows carry.\n -- A ULID, so it is also the fleet read's chronological keyset cursor.\n operation_id TEXT NOT NULL,\n switched_at TEXT NOT NULL,\n PRIMARY KEY (tenant_id, scope_id, module_id)\n );\n CREATE INDEX IF NOT EXISTS _substrat_system_switches_position\n ON _substrat_system_switches (position, operation_id);\n CREATE INDEX IF NOT EXISTS _substrat_system_switches_operation\n ON _substrat_system_switches (operation_id);\n";
53
+ /**
54
+ * The peer switch's record (#2029): `SYSTEM_SWITCHES_DDL`'s shape, keyed by the calling
55
+ * vertical's slug. No fleet read pages it yet, so it carries none of that read's indexes; every
56
+ * read here names (tenant, scope), the primary key's prefix.
57
+ */
58
+ export declare const PEER_SWITCHES_DDL = "\n CREATE TABLE IF NOT EXISTS _substrat_peer_switches (\n tenant_id TEXT NOT NULL,\n scope_id TEXT NOT NULL,\n -- The calling vertical's slug, as the target's peers declaration names it.\n vertical TEXT NOT NULL,\n position TEXT NOT NULL,\n actor TEXT NOT NULL,\n reason TEXT NOT NULL,\n operation_id TEXT NOT NULL,\n switched_at TEXT NOT NULL,\n PRIMARY KEY (tenant_id, scope_id, vertical)\n );\n";
59
+ /**
60
+ * Everything that differs between the two kinds, in one place: where each is recorded, how its
61
+ * switch calls and re-asserts are written to the admin log, and how a call that held nothing is
62
+ * refused. Every function below reads this table; none branches on the kind itself.
63
+ */
64
+ declare const RECORDS: {
65
+ readonly system: {
66
+ readonly table: "_substrat_system_switches";
67
+ readonly ddl: "\n CREATE TABLE IF NOT EXISTS _substrat_system_switches (\n tenant_id TEXT NOT NULL,\n scope_id TEXT NOT NULL,\n module_id TEXT NOT NULL,\n -- 'on' or 'off'. A row exists only for a module some switch call actually held.\n position TEXT NOT NULL,\n actor TEXT NOT NULL,\n reason TEXT NOT NULL,\n -- The switch call's own id, the one its admin-log intent and outcome rows carry.\n -- A ULID, so it is also the fleet read's chronological keyset cursor.\n operation_id TEXT NOT NULL,\n switched_at TEXT NOT NULL,\n PRIMARY KEY (tenant_id, scope_id, module_id)\n );\n CREATE INDEX IF NOT EXISTS _substrat_system_switches_position\n ON _substrat_system_switches (position, operation_id);\n CREATE INDEX IF NOT EXISTS _substrat_system_switches_operation\n ON _substrat_system_switches (operation_id);\n";
68
+ readonly key: 'module_id';
69
+ readonly subjectPrefix: 'system:';
70
+ readonly actions: readonly ['revokeFromSystem', 'restoreToSystem'];
71
+ readonly reassertAction: 'reassertSystemSwitch';
72
+ /** The payload fields naming the subject and its position (`moduleId` + `schedules`). */
73
+ readonly payloadKey: 'moduleId';
74
+ readonly positionField: 'schedules';
75
+ readonly notFound: (scopeId: string, key: string, to: string) => string;
76
+ };
77
+ readonly peer: {
78
+ readonly table: "_substrat_peer_switches";
79
+ readonly ddl: "\n CREATE TABLE IF NOT EXISTS _substrat_peer_switches (\n tenant_id TEXT NOT NULL,\n scope_id TEXT NOT NULL,\n -- The calling vertical's slug, as the target's peers declaration names it.\n vertical TEXT NOT NULL,\n position TEXT NOT NULL,\n actor TEXT NOT NULL,\n reason TEXT NOT NULL,\n operation_id TEXT NOT NULL,\n switched_at TEXT NOT NULL,\n PRIMARY KEY (tenant_id, scope_id, vertical)\n );\n";
80
+ readonly key: 'vertical';
81
+ readonly subjectPrefix: "vertical:";
82
+ readonly actions: readonly ['revokeFromPeer', 'restoreToPeer'];
83
+ readonly reassertAction: 'reassertPeerSwitch';
84
+ readonly payloadKey: 'vertical';
85
+ readonly positionField: 'calls';
86
+ readonly notFound: (scopeId: string, key: string, to: string) => string;
87
+ };
88
+ };
89
+ /** Every kind, for the passes that walk them all (a scope's reap, a directory restore). */
90
+ export declare const SWITCH_KINDS: readonly SwitchKind[];
91
+ /** The admin-log action a switch call of this kind writes its intent and outcome rows under. */
92
+ export declare const switchActionOf: (kind: SwitchKind, to: 'on' | 'off') => (typeof RECORDS)[SwitchKind]['actions'][number];
93
+ /** The `not_found` a switch call that held nothing answers — one wording per kind, both adapters. */
94
+ export declare const switchNotFoundMessage: (kind: SwitchKind, scopeId: string, key: string, to: 'on' | 'off') => string;
95
+ /**
96
+ * #2045: the `conflict` a switch call answers when a newer call on the same subject got there first —
97
+ * its record write or its move was refused by the fence, and nothing of it was written.
98
+ */
99
+ export declare const switchSupersededMessage: (kind: SwitchKind, scopeId: string, key: string, to: 'on' | 'off') => string;
100
+ /** The record table of one kind. */
101
+ export declare const switchesTableOf: (kind: SwitchKind) => string;
102
+ /**
103
+ * #2045: the subjects whose scope may not be where their record says. A WRITE-AHEAD intent
104
+ * (Codex r3): the switch call's record write marks its subject owed in the same directory write,
105
+ * BEFORE anything moves, and the mark is cleared only once the scope has confirmed a move under a
106
+ * fence at least the call's own (`clearSwitchOwed`). So every way a move can go wrong — it throws,
107
+ * its answer is lost, the RPC that would have cleared the mark fails, the caller dies — leaves the
108
+ * mark set, and the next re-assert moves the scope to its record, in EITHER direction, under the
109
+ * record's fence. Without a mark a re-assert keeps #1674's rule: a record never turns anything on.
110
+ *
111
+ * `operation_id` is the newest call that marked the subject. A confirmation under an older fence
112
+ * clears nothing, so a newer call's mark outlives an older call's success.
113
+ */
114
+ export declare const SWITCH_OWED_DDL = "\n CREATE TABLE IF NOT EXISTS _substrat_switch_owed (\n tenant_id TEXT NOT NULL,\n scope_id TEXT NOT NULL,\n -- 'system' or 'peer', and the module id or the peer's slug.\n kind TEXT NOT NULL,\n subject TEXT NOT NULL,\n -- The newest switch call that marked it: a ULID, so it orders by text.\n operation_id TEXT NOT NULL,\n PRIMARY KEY (tenant_id, scope_id, kind, subject)\n );\n";
115
+ /** #2045: mark one subject's scope owed a re-assert, by this switch call. Never moves a mark backwards. */
116
+ export declare function markSwitchOwed(db: SwitchSql, kind: SwitchKind, tenantId: string, scopeId: string, key: string, operationId: string): void;
117
+ /** #2045: the subjects of one kind marked owed on one scope, each with the newest call that marked it. */
118
+ export declare function switchesOwedOf(db: SwitchSql, kind: SwitchKind, tenantId: string, scopeId: string): Map<string, string>;
119
+ /**
120
+ * #2045: the scope confirmed a move of this subject under `fence` — its mark goes, unless a newer
121
+ * call has marked it since (a compare-and-set on the mark's operation id).
122
+ */
123
+ export declare function clearSwitchOwed(db: SwitchSql, kind: SwitchKind, tenantId: string, scopeId: string, key: string, fence: string): void;
124
+ /**
125
+ * #2045: does any subject on this scope still owe a re-assert? While one does, the scope's
126
+ * reconcile receipt is not written (the control plane's `markScopeProvisioned`), so the sweep keeps
127
+ * reconciling it until a re-assert has settled every mark.
128
+ */
129
+ export declare function scopeOwesSwitch(db: SwitchSql, scopeId: string): boolean;
130
+ /** Each kind's DDL, for a pass that creates a table with its backfill. */
131
+ export declare const switchesDdlOf: (kind: SwitchKind) => string;
37
132
  /**
38
133
  * The one-time backfill from the admin log: every switch moved before the record existed.
39
134
  * Without it, those are exactly the switches a wipe would still lose.
40
135
  *
41
- * It reads the admin-log shape `revokeFromSystem` / `restoreToSystem` have written since
42
- * #1666, two rows per call sharing `after.operationId`: an `intent` row carrying
43
- * `after.moduleId` and `after.reason`, then an outcome row whose `after.phase` is
44
- * `applied`, `refused` or `failed`. Only calls whose outcome is `applied` count, because a
45
- * refused call moved nothing and a failed one may not have. Of those, only the LATEST per
46
- * (tenant, scope, module) is taken, by the intent's ULID id. `at` is the intent's, the
47
- * same instant the status read's who/why join reports. A key whose calls include no
48
- * applied OFF gets no row, even when its latest applied call is an ON: a live
49
- * `restoreToSystem` of a module never switched off writes none either
50
- * (`recordSystemSwitchedOn`), and the backfill must not record what the live path would not.
136
+ * It reads the admin-log shape the switch calls have written since they existed
137
+ * (`revokeFromSystem` / `restoreToSystem` since #1666, `revokeFromPeer` / `restoreToPeer`
138
+ * since #1706), two rows per call sharing `after.operationId`: an `intent` row carrying the
139
+ * subject (`after.moduleId`, or `after.vertical` for a peer) and `after.reason`, then an
140
+ * outcome row whose `after.phase` is `applied`, `refused` or `failed`. Only calls whose
141
+ * outcome is `applied` count, because a refused call moved nothing and a failed one may not
142
+ * have. Of those, only the LATEST per (tenant, scope, subject) is taken, by the intent's ULID
143
+ * id. `at` is the intent's, the same instant the status read's who/why join reports. A key
144
+ * whose calls include no applied OFF gets no row, even when its latest applied call is an ON:
145
+ * history wrote no scope fence (#2045), so there is no fence for such a row to keep pace with,
146
+ * and an ON-only key needs no record to re-assert.
51
147
  *
52
148
  * `INSERT OR IGNORE`, so a row the switch wrote itself is never overwritten by history.
53
149
  * The adapters run it only on the construction that creates the table, so it runs once.
54
150
  */
55
- export declare const SYSTEM_SWITCHES_BACKFILL_SQL = "\n WITH applied AS (\n SELECT DISTINCT action, json_extract(after, '$.operationId') AS operation_id\n FROM _substrat_admin_log\n WHERE action IN ('revokeFromSystem', 'restoreToSystem')\n AND json_extract(after, '$.phase') = 'applied'\n ),\n intents AS (\n SELECT i.id AS id, i.tenant_id AS tenant_id, i.scope_id AS scope_id,\n json_extract(i.after, '$.moduleId') AS module_id,\n CASE i.action WHEN 'revokeFromSystem' THEN 'off' ELSE 'on' END AS position,\n i.actor AS actor,\n json_extract(i.after, '$.reason') AS reason,\n json_extract(i.after, '$.operationId') AS operation_id,\n i.at AS at\n FROM _substrat_admin_log i\n JOIN applied a\n ON a.action = i.action AND a.operation_id = json_extract(i.after, '$.operationId')\n WHERE i.action IN ('revokeFromSystem', 'restoreToSystem')\n AND i.tenant_id IS NOT NULL AND i.scope_id IS NOT NULL\n AND json_extract(i.after, '$.phase') = 'intent'\n AND json_extract(i.after, '$.moduleId') IS NOT NULL\n AND json_extract(i.after, '$.reason') IS NOT NULL\n ),\n ranked AS (\n SELECT *,\n ROW_NUMBER() OVER (PARTITION BY tenant_id, scope_id, module_id ORDER BY id DESC) AS latest,\n MAX(position = 'off') OVER (PARTITION BY tenant_id, scope_id, module_id) AS ever_off\n FROM intents\n )\n INSERT OR IGNORE INTO _substrat_system_switches\n (tenant_id, scope_id, module_id, position, actor, reason, operation_id, switched_at)\n SELECT tenant_id, scope_id, module_id, position, actor, reason, operation_id, at\n FROM ranked\n WHERE latest = 1 AND ever_off = 1\n";
151
+ export declare function switchesBackfillSqlOf(kind: SwitchKind): string;
56
152
  /**
57
- * Does a dump carry the record table? A directory restore builds the table either way, and
58
- * backfills it from the dump's own admin log only when the dump did not (#1898). Compared
153
+ * Does a dump carry this kind's record table? A directory restore builds the table either way,
154
+ * and backfills it from the dump's own admin log only when the dump did not (#1898). Compared
59
155
  * without case, as SQLite resolves a table name.
60
156
  */
61
- export declare function dumpCarriesSystemSwitches(names: readonly string[]): boolean;
62
- /** "Does the record table exist yet?" — asked BEFORE the DDL, so the backfill runs once. */
63
- export declare function systemSwitchesTableExists(db: SwitchSql): boolean;
157
+ export declare function dumpCarriesSwitches(names: readonly string[], kind: SwitchKind): boolean;
158
+ /** "Does this kind's record table exist yet?" — asked BEFORE the DDL, so the backfill runs once. */
159
+ export declare function switchesTableExists(db: SwitchSql, kind: SwitchKind): boolean;
64
160
  /** One record row as the directory holds it, with the scope's binding joined on. */
65
161
  export interface SystemSwitchRecordRow {
66
162
  tenantId: string;
@@ -93,8 +189,11 @@ export interface SystemSwitchRecordFilter extends ListPage {
93
189
  * miss a row that moved after the walk started, so use ascending for "every switch".
94
190
  */
95
191
  export declare function listSystemSwitchRecords(db: SwitchSql, filter?: SystemSwitchRecordFilter): SystemSwitchRecordRow[];
96
- /** One scope's record rows by module — what the per-scope status read joins as `recorded`. */
97
- export declare function systemSwitchRecordsOf(db: SwitchSql, tenantId: string, scopeId: string): Map<string, 'on' | 'off'>;
192
+ /**
193
+ * One scope's record rows of one kind, by subject (module id or peer slug) — what the per-scope
194
+ * status read joins as `recorded`, and what a re-assert reverts a stale carry against.
195
+ */
196
+ export declare function switchRecordsOf(db: SwitchSql, kind: SwitchKind, tenantId: string, scopeId: string): Map<string, 'on' | 'off'>;
98
197
  /**
99
198
  * The per-scope status read's rows with the record joined on. Each module the scope
100
199
  * reports gets its recorded position (or null). A module the record holds that the scope
@@ -109,8 +208,8 @@ export declare function withRecorded(states: {
109
208
  schedules: SystemScheduleState;
110
209
  recorded: 'on' | 'off' | null;
111
210
  }[];
112
- /** The modules a reconcile must re-assert OFF on this scope. */
113
- export declare function switchedOffModulesOf(db: SwitchSql, tenantId: string, scopeId: string): string[];
211
+ /** The subjects of one kind (module ids, or peer slugs) a reconcile must re-assert OFF on this scope. */
212
+ export declare function switchedOffOf(db: SwitchSql, kind: SwitchKind, tenantId: string, scopeId: string): string[];
114
213
  /**
115
214
  * The scopes of one tenant the record holds a module OFF on — what a tenant-level
116
215
  * `grantToSystem` refuses on (#1743). A tenant tuple has no scope of its own to read a
@@ -120,82 +219,181 @@ export declare function switchedOffModulesOf(db: SwitchSql, tenantId: string, sc
120
219
  */
121
220
  export declare function scopesSwitchedOffFor(db: SwitchSql, tenantId: string, moduleId: string): string[];
122
221
  /**
123
- * Does the tenant hold a live TENANT-level grant for this module (#1823)? Asked of the
124
- * directory, where the tenant tuple lives, and handed to the switch as `tenantHeld`: a module
125
- * whose only authority on a scope is a tenant-level grant has nothing in the scope's storage
126
- * for the switch to find, and must still be switchable there. One statement on both adapters'
127
- * directories; the same "live" the evaluator judges a grant by (unrevoked, unexpired at `now`).
222
+ * Does the tenant hold a live TENANT-level grant for this subject (#1823, and #2030 for a peer)?
223
+ * Asked of the directory, where the tenant tuple lives, and handed to the switch as
224
+ * `tenantHeld`: a subject whose only authority on a scope is a tenant-level grant has nothing
225
+ * in the scope's storage for the switch to find, and must still be switchable there. One
226
+ * statement on both adapters' directories; the same "live" the evaluator judges a grant by
227
+ * (unrevoked, unexpired at `now`).
128
228
  */
129
- export declare function tenantHoldsSystemGrant(db: SwitchSql, tenantId: string, moduleId: string, now: string): boolean;
130
- /** What one switch call writes into the record. */
131
- export interface SystemSwitchRecordWrite {
229
+ export declare function tenantHoldsGrant(db: SwitchSql, kind: SwitchKind, tenantId: string, key: string, now: string): boolean;
230
+ /** Of `keys`, those the tenant holds a live tenant-level grant for (`tenantHoldsGrant`), in order. */
231
+ export declare function tenantHeldOf(db: SwitchSql, kind: SwitchKind, tenantId: string, keys: readonly string[], now: string): string[];
232
+ /** What one switch call writes into the record. `key` is the module id, or the peer's slug. */
233
+ export interface SwitchRecordWrite {
234
+ kind: SwitchKind;
132
235
  tenantId: string;
133
236
  scopeId: string;
134
- moduleId: string;
237
+ key: string;
135
238
  actor: string;
136
239
  reason: string;
137
240
  operationId: string;
138
241
  at: string;
139
242
  }
140
243
  /** The row as it stood before a write, so a failed switch can put it back. */
141
- export type SystemSwitchRecordPrior = Pick<SystemSwitchRecordRow, 'position' | 'actor' | 'reason' | 'operationId' | 'at'> | null;
142
- /** What a re-assert did for one recorded-off module — `HostAdmin.reassertSystemSwitches`' answer. */
143
- export interface SystemSwitchReassert {
144
- moduleId: string;
244
+ export type SwitchRecordPrior = Pick<SystemSwitchRecordRow, 'position' | 'actor' | 'reason' | 'operationId' | 'at'> | null;
245
+ /** One record row's identity. */
246
+ type RecordKey = Pick<SwitchRecordWrite, 'kind' | 'tenantId' | 'scopeId' | 'key'>;
247
+ /**
248
+ * What a re-assert did for one recorded-off subject — `HostAdmin.reassertSystemSwitches`'
249
+ * answer: a module (`moduleId`) or, since #2029, a peer (`vertical`).
250
+ */
251
+ export type SystemSwitchReassert = {
145
252
  held: boolean;
146
253
  changed: boolean;
147
- }
254
+ } & ({
255
+ moduleId: string;
256
+ vertical?: never;
257
+ } | {
258
+ vertical: string;
259
+ moduleId?: never;
260
+ });
148
261
  /**
149
262
  * What the deployment reports it switched off inside the reconcile's own unit (#1742), passed
150
263
  * to `HostAdmin.reassertSystemSwitches` so the move is audited here. The re-assert that
151
- * follows finds those modules already off (`changed: false`), and without this the admin log
264
+ * follows finds those subjects already off (`changed: false`), and without this the admin log
152
265
  * would stop showing that a wiped scope was put back off.
153
266
  */
154
267
  export interface SystemSwitchReassertOptions {
155
- appliedInUnit?: readonly Pick<SwitchedOff, 'moduleId' | 'changed' | 'permissions'>[];
268
+ appliedInUnit?: readonly InUnitReport[];
156
269
  }
270
+ /** One in-unit move as a deployment reports it: a module's, or (#2029) a peer's. */
271
+ export type InUnitReport = Pick<SwitchedOff, 'changed' | 'permissions'> & ({
272
+ moduleId: string;
273
+ vertical?: never;
274
+ } | {
275
+ vertical: string;
276
+ moduleId?: never;
277
+ });
278
+ /** The subject an in-unit report names, if it is of this kind. */
279
+ export declare const reportKeyOf: (kind: SwitchKind, report: InUnitReport) => string | undefined;
157
280
  /**
158
- * The `reassertSystemSwitch` audit rows (less their `operationId`) for the in-unit moves:
159
- * those that changed something, on a module the directory records `off` for this scope.
160
- * That filter is the point. The report comes from the deployment, and an audit row naming
161
- * a module the record never switched off would be the deployment writing the platform's
162
- * log. One row per module, first report wins. Built here so both adapters write one shape.
281
+ * The fields an audit row names its subject and position with — the shape each kind's switch
282
+ * calls have always written (`moduleId` + `schedules`, `vertical` + `calls`).
283
+ */
284
+ export declare function switchAuditSubject(kind: SwitchKind, key: string, position: 'on' | 'off'): {
285
+ moduleId: string;
286
+ schedules: 'on' | 'off';
287
+ } | {
288
+ vertical: string;
289
+ calls: 'on' | 'off';
290
+ };
291
+ /** The admin-log action a re-assert of this kind writes its rows under. */
292
+ export declare const reassertActionOf: (kind: SwitchKind) => (typeof RECORDS)[SwitchKind]['reassertAction'];
293
+ /** One re-assert answer entry: the subject by its kind's field, and what the move did. */
294
+ export declare const reassertEntry: (kind: SwitchKind, key: string, outcome: {
295
+ held: boolean;
296
+ changed: boolean;
297
+ }) => SystemSwitchReassert;
298
+ /**
299
+ * #2045: the audit row (less its `operationId`) for a re-assert's ON that moved something — a
300
+ * record of ON beside a scope that was off, converged to the record under its fence.
163
301
  */
164
- export declare function inUnitMovesToAudit(recordedOff: readonly string[], applied: SystemSwitchReassertOptions['appliedInUnit']): {
302
+ export declare const reassertOnRow: (kind: SwitchKind, key: string, permissions: readonly string[]) => {
165
303
  moduleId: string;
166
- schedules: 'off';
304
+ schedules: 'on' | 'off';
305
+ phase: 'applied';
306
+ changed: true;
307
+ permissions: string[];
308
+ } | {
309
+ vertical: string;
310
+ calls: 'on' | 'off';
311
+ phase: 'applied';
312
+ changed: true;
313
+ permissions: string[];
314
+ };
315
+ /** The audit row (less its `operationId`) for a re-assert's own OFF that moved something — both adapters. */
316
+ export declare const reassertOffRow: (kind: SwitchKind, key: string, permissions: readonly string[]) => {
317
+ moduleId: string;
318
+ schedules: 'on' | 'off';
319
+ phase: 'applied';
320
+ changed: true;
321
+ permissions: string[];
322
+ } | {
323
+ vertical: string;
324
+ calls: 'on' | 'off';
325
+ phase: 'applied';
326
+ changed: true;
327
+ permissions: string[];
328
+ };
329
+ /**
330
+ * The re-assert's audit rows (less their `operationId`) for the in-unit moves of one kind:
331
+ * those that changed something, on a subject the directory records `off` for this scope.
332
+ * That filter is the point. The report comes from the deployment, and an audit row naming
333
+ * a subject the record never switched off would be the deployment writing the platform's
334
+ * log. One row per subject, first report wins. Built here so both adapters write one shape.
335
+ */
336
+ export declare function inUnitMovesToAudit(kind: SwitchKind, recordedOff: readonly string[], applied: SystemSwitchReassertOptions['appliedInUnit'],
337
+ /** Subjects this re-assert's stale-carry pass switched back on: their in-unit move is not credited. */
338
+ reverted?: ReadonlySet<string>): (ReturnType<typeof switchAuditSubject> & {
167
339
  phase: 'applied';
168
340
  changed: true;
169
341
  permissions: string[];
170
342
  inUnit: true;
171
- }[];
343
+ })[];
172
344
  /**
173
345
  * The in-unit moves a STALE carry made, which the re-assert must undo (#1742 review): the
174
- * deployment switched a module off because the list it was handed said so, but by the time
175
- * the re-assert reads the record, an operator's `restoreToSystem` has moved it to `on`. The
176
- * list was read before the call and the ON landed in between. Left alone, the scope would
177
- * stay off while the record says on, and no later pass would put it back.
346
+ * deployment switched a subject off because the list it was handed said so, but by the time
347
+ * the re-assert reads the record, an operator's restore has moved it to `on`. The list was
348
+ * read before the call and the ON landed in between. Left alone, the scope would stay off
349
+ * while the record says on, and no later pass would put it back.
178
350
  *
179
- * Only a module the record now holds `on`, so a revert only ever re-applies an operator's
180
- * own ON. It never turns on a module whose record is `off` or missing, and so a report from
351
+ * Only a subject the record now holds `on`, so a revert only ever re-applies an operator's
352
+ * own ON. It never turns on a subject whose record is `off` or missing, and so a report from
181
353
  * the deployment can never switch on anything the platform has not already restored.
182
354
  */
183
- export declare function staleCarryReverts(recorded: ReadonlyMap<string, 'on' | 'off'>, applied: SystemSwitchReassertOptions['appliedInUnit']): string[];
355
+ export declare function staleCarryReverts(kind: SwitchKind, recorded: ReadonlyMap<string, 'on' | 'off'>, applied: SystemSwitchReassertOptions['appliedInUnit']): string[];
184
356
  /** The audit row (less its `operationId`) for one stale-carry revert — both adapters write this shape. */
185
- export declare function staleCarryRevertRow(moduleId: string, outcome: {
357
+ export declare function staleCarryRevertRow(kind: SwitchKind, key: string, outcome: {
186
358
  changed: boolean;
187
359
  permissions: readonly string[];
188
- }): {
189
- moduleId: string;
190
- schedules: 'on';
360
+ }): ReturnType<typeof switchAuditSubject> & {
191
361
  phase: 'applied';
192
362
  changed: boolean;
193
363
  permissions: string[];
194
364
  staleCarry: true;
195
365
  };
366
+ /**
367
+ * #2045: the record's half of the switch fence (`SWITCH_FENCES_DDL`). A write from a call OLDER than
368
+ * the one the row holds writes nothing: a newer call has already recorded its position, and the
369
+ * scope will refuse this call's move for the same reason. Both writes answer the prior row, and the
370
+ * caller reads this off it, with the same test (`recordWriteSuperseded`).
371
+ */
372
+ declare const supersededBy: (prior: SwitchRecordPrior, row: Pick<SwitchRecordWrite, 'operationId'>) => boolean;
373
+ /** #2045: did this record write find a newer call's row, and so write nothing? */
374
+ export declare const recordWriteSuperseded: typeof supersededBy;
375
+ /**
376
+ * #2045: the operation id each of one scope's record rows of one kind holds, by subject — the fence a
377
+ * re-assert or a carry moves the scope with, so a scope moved since by a newer call stays as that
378
+ * call put it.
379
+ */
380
+ export declare function switchFencesOf(db: SwitchSql, kind: SwitchKind, tenantId: string, scopeId: string): Map<string, string>;
381
+ /**
382
+ * #2045: each record row's position AND operation id, by subject, in ONE read. A caller that moves
383
+ * the scope to a row's position under the row's fence must take both from the same instant: read
384
+ * apart, a row that moves between them pairs one call's position with another call's fence (an OFF
385
+ * carried under the ON's fence applies, since the scope holds that very fence), and a row the undo
386
+ * deleted between them is moved with no fence at all, which the scope applies unconditionally.
387
+ */
388
+ export declare function switchRecordStatesOf(db: SwitchSql, kind: SwitchKind, tenantId: string, scopeId: string): Map<string, {
389
+ position: 'on' | 'off';
390
+ fence: string;
391
+ }>;
392
+ /** #2045: the tuple subject a record key names (`system:<m>`, `vertical:<v>`) — how a carry keys its fences. */
393
+ export declare const switchSubjectOf: (kind: SwitchKind, key: string) => string;
196
394
  /**
197
395
  * OFF's write, made BEFORE the scope's switch moves (#1823), and undone by
198
- * `restoreSystemSwitchRecord` when the move throws or holds nothing. An upsert: a repeat OFF
396
+ * `restoreSwitchRecord` when the move throws or holds nothing. An upsert: a repeat OFF
199
397
  * refreshes the actor, reason and time, as the status read reports the latest reason.
200
398
  * Answers the row as it was.
201
399
  *
@@ -205,34 +403,36 @@ export declare function staleCarryRevertRow(moduleId: string, outcome: {
205
403
  * which the scope is off and the record is not. This order fails toward a record of `off`
206
404
  * beside a scope still on, until the undo runs — the direction OFF wins anyway, and the one a
207
405
  * kill switch should fail in. Still never LEFT behind for a call that held nothing: a row
208
- * saying `off` for a module the scope never ran would switch it off on the day it is
406
+ * saying `off` for a subject the scope never had would switch it off on the day it is
209
407
  * installed (the kernel's `held` check, for the same reason).
210
408
  */
211
- export declare function recordSystemSwitchedOff(db: SwitchSql, row: SystemSwitchRecordWrite): SystemSwitchRecordPrior;
409
+ export declare function recordSwitchedOff(db: SwitchSql, row: SwitchRecordWrite): SwitchRecordPrior;
212
410
  /**
213
- * ON's write, made BEFORE the scope's switch moves, and only to a row that exists. Before,
214
- * because the other order fails unsafely: a scope switched on whose record write then
215
- * failed would still read `off`, and the next reconcile would switch the operator's
216
- * restore back off. This order fails toward a record of `on` beside a live marker, which
217
- * the marker wins. Answers the row as it was, for `restoreSystemSwitchRecord`.
411
+ * ON's write, made BEFORE the scope's switch moves. Before, because the other order fails
412
+ * unsafely: a scope switched on whose record write then failed would still read `off`, and the
413
+ * next reconcile would switch the operator's restore back off. Answers the row as it was, for
414
+ * `restoreSwitchRecord`.
415
+ *
416
+ * #2045: an upsert, like OFF's. An ON with no row before it writes one, because its move stores
417
+ * its id in the scope's fence: without a row carrying the same id, an OLDER OFF arriving after
418
+ * it would find no row to be refused by, record itself, and leave the directory behind the scope
419
+ * (Codex r2). The directory's fence is never behind the scope's. An ON that holds nothing still
420
+ * leaves no row: its undo removes the one it wrote.
218
421
  */
219
- export declare function recordSystemSwitchedOn(db: SwitchSql, row: SystemSwitchRecordWrite): SystemSwitchRecordPrior;
422
+ export declare function recordSwitchedOn(db: SwitchSql, row: SwitchRecordWrite): SwitchRecordPrior;
220
423
  /**
221
- * Put a row back as `recordSystemSwitchedOn` or `recordSystemSwitchedOff` found it — the call
222
- * that wrote it threw, or held nothing. A row that did not exist is removed again. A
223
- * compare-and-set on the call's own `operationId`: if another switch call has written the row
224
- * since, the row is left as that call wrote it, so an undo can never clobber a newer position.
424
+ * Put a row back as `recordSwitchedOn` or `recordSwitchedOff` found it — the call that wrote
425
+ * it threw, or held nothing. A row that did not exist is removed again. A compare-and-set on
426
+ * the call's own `operationId`: if another switch call has written the row since, the row is
427
+ * left as that call wrote it, so an undo can never clobber a newer position.
225
428
  */
226
- export declare function restoreSystemSwitchRecord(db: SwitchSql, call: {
227
- tenantId: string;
228
- scopeId: string;
229
- moduleId: string;
429
+ export declare function restoreSwitchRecord(db: SwitchSql, call: RecordKey & {
230
430
  operationId: string;
231
- }, prior: SystemSwitchRecordPrior): void;
431
+ }, prior: SwitchRecordPrior): void;
232
432
  /**
233
- * Forget one scope's switch records — the scope's directory row is going too (a reaped
234
- * preview or fork, a reaped scope). Without this the fleet read keeps listing a switch on
433
+ * Forget one scope's switch records, of every kind — the scope's directory row is going too (a
434
+ * reaped preview or fork, a reaped scope). Without this the fleet read keeps listing a switch on
235
435
  * a scope that no longer exists. The admin log keeps the history, as it keeps the scope's.
236
436
  */
237
- export declare function forgetSystemSwitchesOf(db: SwitchSql, scopeId: string): void;
437
+ export declare function forgetSwitchesOf(db: SwitchSql, scopeId: string): void;
238
438
  //# sourceMappingURL=system-switch-record.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"system-switch-record.d.ts","sourceRoot":"","sources":["../src/system-switch-record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEtF,2DAA2D;AAC3D,eAAO,MAAM,qBAAqB,8BAA8B,CAAC;AAEjE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,22BAmB/B,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,4BAA4B,0oDAmCxC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAE3E;AAED,4FAA4F;AAC5F,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAKhE;AAED,oFAAoF;AACpF,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,IAAI,GAAG,KAAK,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,E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