@substrat-run/kernel 0.136.0 → 0.138.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 (88) hide show
  1. package/dist/capability.d.ts +2 -0
  2. package/dist/capability.d.ts.map +1 -1
  3. package/dist/capability.js +2 -0
  4. package/dist/capability.js.map +1 -1
  5. package/dist/delivery-refusal.d.ts +21 -0
  6. package/dist/delivery-refusal.d.ts.map +1 -0
  7. package/dist/delivery-refusal.js +21 -0
  8. package/dist/delivery-refusal.js.map +1 -0
  9. package/dist/index.d.ts +23 -17
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +18 -12
  12. package/dist/index.js.map +1 -1
  13. package/dist/invocation-log.d.ts +25 -1
  14. package/dist/invocation-log.d.ts.map +1 -1
  15. package/dist/invocation-log.js +45 -6
  16. package/dist/invocation-log.js.map +1 -1
  17. package/dist/job-run.d.ts +370 -47
  18. package/dist/job-run.d.ts.map +1 -1
  19. package/dist/job-run.js +472 -81
  20. package/dist/job-run.js.map +1 -1
  21. package/dist/lifecycle-flow.d.ts.map +1 -1
  22. package/dist/lifecycle-flow.js +2 -1
  23. package/dist/lifecycle-flow.js.map +1 -1
  24. package/dist/membership-executor.d.ts +97 -0
  25. package/dist/membership-executor.d.ts.map +1 -0
  26. package/dist/membership-executor.js +246 -0
  27. package/dist/membership-executor.js.map +1 -0
  28. package/dist/membership-fence.d.ts +57 -0
  29. package/dist/membership-fence.d.ts.map +1 -0
  30. package/dist/membership-fence.js +90 -0
  31. package/dist/membership-fence.js.map +1 -0
  32. package/dist/operation-series.d.ts +58 -0
  33. package/dist/operation-series.d.ts.map +1 -0
  34. package/dist/operation-series.js +63 -0
  35. package/dist/operation-series.js.map +1 -0
  36. package/dist/peer.d.ts +13 -8
  37. package/dist/peer.d.ts.map +1 -1
  38. package/dist/peer.js +13 -14
  39. package/dist/peer.js.map +1 -1
  40. package/dist/permission-eval.d.ts +48 -1
  41. package/dist/permission-eval.d.ts.map +1 -1
  42. package/dist/permission-eval.js +137 -18
  43. package/dist/permission-eval.js.map +1 -1
  44. package/dist/read-only-sql.d.ts +2 -26
  45. package/dist/read-only-sql.d.ts.map +1 -1
  46. package/dist/read-only-sql.js +13 -9
  47. package/dist/read-only-sql.js.map +1 -1
  48. package/dist/refusal-query.d.ts +4 -1
  49. package/dist/refusal-query.d.ts.map +1 -1
  50. package/dist/refusal-query.js +6 -4
  51. package/dist/refusal-query.js.map +1 -1
  52. package/dist/refusals.d.ts +80 -8
  53. package/dist/refusals.d.ts.map +1 -1
  54. package/dist/refusals.js +141 -22
  55. package/dist/refusals.js.map +1 -1
  56. package/dist/scope-copy.d.ts +18 -0
  57. package/dist/scope-copy.d.ts.map +1 -1
  58. package/dist/scope-copy.js +18 -0
  59. package/dist/scope-copy.js.map +1 -1
  60. package/dist/scope-host.d.ts +266 -15
  61. package/dist/scope-host.d.ts.map +1 -1
  62. package/dist/scope-host.js +41 -0
  63. package/dist/scope-host.js.map +1 -1
  64. package/dist/spine-restore.d.ts +7 -2
  65. package/dist/spine-restore.d.ts.map +1 -1
  66. package/dist/spine-restore.js +13 -5
  67. package/dist/spine-restore.js.map +1 -1
  68. package/dist/system-switch-record.d.ts +290 -74
  69. package/dist/system-switch-record.d.ts.map +1 -1
  70. package/dist/system-switch-record.js +353 -101
  71. package/dist/system-switch-record.js.map +1 -1
  72. package/dist/system-switch.d.ts +146 -20
  73. package/dist/system-switch.d.ts.map +1 -1
  74. package/dist/system-switch.js +135 -27
  75. package/dist/system-switch.js.map +1 -1
  76. package/dist/timeline.d.ts +23 -0
  77. package/dist/timeline.d.ts.map +1 -1
  78. package/dist/timeline.js +30 -0
  79. package/dist/timeline.js.map +1 -1
  80. package/dist/ulid.d.ts +5 -0
  81. package/dist/ulid.d.ts.map +1 -1
  82. package/dist/ulid.js +9 -0
  83. package/dist/ulid.js.map +1 -1
  84. package/dist/vertical-events.d.ts +7 -1
  85. package/dist/vertical-events.d.ts.map +1 -1
  86. package/dist/vertical-events.js +14 -0
  87. package/dist/vertical-events.js.map +1 -1
  88. package/package.json +4 -4
@@ -1,5 +1,9 @@
1
+ import { liveTupleSql } from './permission-eval.js';
2
+ import { PEER_SUBJECT_PREFIX, } from './system-switch.js';
1
3
  /** The record's table name, as the DDL below spells it. */
2
4
  export const SYSTEM_SWITCHES_TABLE = '_substrat_system_switches';
5
+ /** The peer switch's record (#2029), as `PEER_SWITCHES_DDL` spells it. */
6
+ const PEER_SWITCHES_TABLE = '_substrat_peer_switches';
3
7
  /**
4
8
  * The table. Interpolated into both adapters' directory DDL, so `lint:spine-ddl` sees the
5
9
  * one spelling on each side. No CHECK on `position`: the drift gate does not compare
@@ -25,35 +29,158 @@ export const SYSTEM_SWITCHES_DDL = `
25
29
  CREATE INDEX IF NOT EXISTS _substrat_system_switches_operation
26
30
  ON _substrat_system_switches (operation_id);
27
31
  `;
32
+ /**
33
+ * The peer switch's record (#2029): `SYSTEM_SWITCHES_DDL`'s shape, keyed by the calling
34
+ * vertical's slug. No fleet read pages it yet, so it carries none of that read's indexes; every
35
+ * read here names (tenant, scope), the primary key's prefix.
36
+ */
37
+ export const PEER_SWITCHES_DDL = `
38
+ CREATE TABLE IF NOT EXISTS _substrat_peer_switches (
39
+ tenant_id TEXT NOT NULL,
40
+ scope_id TEXT NOT NULL,
41
+ -- The calling vertical's slug, as the target's peers declaration names it.
42
+ vertical TEXT NOT NULL,
43
+ position TEXT NOT NULL,
44
+ actor TEXT NOT NULL,
45
+ reason TEXT NOT NULL,
46
+ operation_id TEXT NOT NULL,
47
+ switched_at TEXT NOT NULL,
48
+ PRIMARY KEY (tenant_id, scope_id, vertical)
49
+ );
50
+ `;
51
+ /**
52
+ * Everything that differs between the two kinds, in one place: where each is recorded, how its
53
+ * switch calls and re-asserts are written to the admin log, and how a call that held nothing is
54
+ * refused. Every function below reads this table; none branches on the kind itself.
55
+ */
56
+ const RECORDS = {
57
+ system: {
58
+ table: SYSTEM_SWITCHES_TABLE,
59
+ ddl: SYSTEM_SWITCHES_DDL,
60
+ key: 'module_id',
61
+ subjectPrefix: 'system:',
62
+ actions: ['revokeFromSystem', 'restoreToSystem'],
63
+ reassertAction: 'reassertSystemSwitch',
64
+ /** The payload fields naming the subject and its position (`moduleId` + `schedules`). */
65
+ payloadKey: 'moduleId',
66
+ positionField: 'schedules',
67
+ notFound: (scopeId, key, to) => `scope ${scopeId} holds no system grant for module '${key}' — nothing to switch ${to} ` +
68
+ `(check the module id: it is the module's manifest id, e.g. '@substrat-run/engine-absence')`,
69
+ },
70
+ peer: {
71
+ table: PEER_SWITCHES_TABLE,
72
+ ddl: PEER_SWITCHES_DDL,
73
+ key: 'vertical',
74
+ subjectPrefix: PEER_SUBJECT_PREFIX,
75
+ actions: ['revokeFromPeer', 'restoreToPeer'],
76
+ reassertAction: 'reassertPeerSwitch',
77
+ payloadKey: 'vertical',
78
+ positionField: 'calls',
79
+ notFound: (scopeId, key, to) => `scope ${scopeId} holds no grant for peer '${key}' — nothing to switch ${to} ` +
80
+ `(check the slug: it is the calling vertical's registry id, as the target's \`peers\` names it)`,
81
+ },
82
+ };
83
+ /** Every kind, for the passes that walk them all (a scope's reap, a directory restore). */
84
+ export const SWITCH_KINDS = ['system', 'peer'];
85
+ /** The admin-log action a switch call of this kind writes its intent and outcome rows under. */
86
+ export const switchActionOf = (kind, to) => RECORDS[kind].actions[to === 'off' ? 0 : 1];
87
+ /** The `not_found` a switch call that held nothing answers — one wording per kind, both adapters. */
88
+ export const switchNotFoundMessage = (kind, scopeId, key, to) => RECORDS[kind].notFound(scopeId, key, to);
89
+ /**
90
+ * #2045: the `conflict` a switch call answers when a newer call on the same subject got there first —
91
+ * its record write or its move was refused by the fence, and nothing of it was written.
92
+ */
93
+ export const switchSupersededMessage = (kind, scopeId, key, to) => `a newer switch call on ${kind === 'system' ? `module '${key}'` : `peer '${key}'`} on scope ${scopeId} landed first, ` +
94
+ `so this one (${to}) switched nothing. Read the scope's switch status before retrying.`;
95
+ /** The record table of one kind. */
96
+ export const switchesTableOf = (kind) => RECORDS[kind].table;
97
+ /**
98
+ * #2045: the subjects whose scope may not be where their record says. A WRITE-AHEAD intent
99
+ * (Codex r3): the switch call's record write marks its subject owed in the same directory write,
100
+ * BEFORE anything moves, and the mark is cleared only once the scope has confirmed a move under a
101
+ * fence at least the call's own (`clearSwitchOwed`). So every way a move can go wrong — it throws,
102
+ * its answer is lost, the RPC that would have cleared the mark fails, the caller dies — leaves the
103
+ * mark set, and the next re-assert moves the scope to its record, in EITHER direction, under the
104
+ * record's fence. Without a mark a re-assert keeps #1674's rule: a record never turns anything on.
105
+ *
106
+ * `operation_id` is the newest call that marked the subject. A confirmation under an older fence
107
+ * clears nothing, so a newer call's mark outlives an older call's success.
108
+ */
109
+ export const SWITCH_OWED_DDL = `
110
+ CREATE TABLE IF NOT EXISTS _substrat_switch_owed (
111
+ tenant_id TEXT NOT NULL,
112
+ scope_id TEXT NOT NULL,
113
+ -- 'system' or 'peer', and the module id or the peer's slug.
114
+ kind TEXT NOT NULL,
115
+ subject TEXT NOT NULL,
116
+ -- The newest switch call that marked it: a ULID, so it orders by text.
117
+ operation_id TEXT NOT NULL,
118
+ PRIMARY KEY (tenant_id, scope_id, kind, subject)
119
+ );
120
+ `;
121
+ /** #2045: mark one subject's scope owed a re-assert, by this switch call. Never moves a mark backwards. */
122
+ export function markSwitchOwed(db, kind, tenantId, scopeId, key, operationId) {
123
+ db.run(`INSERT INTO _substrat_switch_owed (tenant_id, scope_id, kind, subject, operation_id) VALUES (?, ?, ?, ?, ?)
124
+ ON CONFLICT (tenant_id, scope_id, kind, subject) DO UPDATE SET operation_id = excluded.operation_id
125
+ WHERE excluded.operation_id > _substrat_switch_owed.operation_id`, tenantId, scopeId, kind, key, operationId);
126
+ }
127
+ /** #2045: the subjects of one kind marked owed on one scope, each with the newest call that marked it. */
128
+ export function switchesOwedOf(db, kind, tenantId, scopeId) {
129
+ const rows = db.all(`SELECT subject, operation_id FROM _substrat_switch_owed
130
+ WHERE tenant_id = ? AND scope_id = ? AND kind = ? ORDER BY subject`, tenantId, scopeId, kind);
131
+ return new Map(rows.map((r) => [String(r.subject), String(r.operation_id)]));
132
+ }
133
+ /**
134
+ * #2045: the scope confirmed a move of this subject under `fence` — its mark goes, unless a newer
135
+ * call has marked it since (a compare-and-set on the mark's operation id).
136
+ */
137
+ export function clearSwitchOwed(db, kind, tenantId, scopeId, key, fence) {
138
+ db.run(`DELETE FROM _substrat_switch_owed
139
+ WHERE tenant_id = ? AND scope_id = ? AND kind = ? AND subject = ? AND operation_id <= ?`, tenantId, scopeId, kind, key, fence);
140
+ }
141
+ /**
142
+ * #2045: does any subject on this scope still owe a re-assert? While one does, the scope's
143
+ * reconcile receipt is not written (the control plane's `markScopeProvisioned`), so the sweep keeps
144
+ * reconciling it until a re-assert has settled every mark.
145
+ */
146
+ export function scopeOwesSwitch(db, scopeId) {
147
+ return db.all(`SELECT 1 FROM _substrat_switch_owed WHERE scope_id = ? LIMIT 1`, scopeId).length > 0;
148
+ }
149
+ /** Each kind's DDL, for a pass that creates a table with its backfill. */
150
+ export const switchesDdlOf = (kind) => RECORDS[kind].ddl;
28
151
  /**
29
152
  * The one-time backfill from the admin log: every switch moved before the record existed.
30
153
  * Without it, those are exactly the switches a wipe would still lose.
31
154
  *
32
- * It reads the admin-log shape `revokeFromSystem` / `restoreToSystem` have written since
33
- * #1666, two rows per call sharing `after.operationId`: an `intent` row carrying
34
- * `after.moduleId` and `after.reason`, then an outcome row whose `after.phase` is
35
- * `applied`, `refused` or `failed`. Only calls whose outcome is `applied` count, because a
36
- * refused call moved nothing and a failed one may not have. Of those, only the LATEST per
37
- * (tenant, scope, module) is taken, by the intent's ULID id. `at` is the intent's, the
38
- * same instant the status read's who/why join reports. A key whose calls include no
39
- * applied OFF gets no row, even when its latest applied call is an ON: a live
40
- * `restoreToSystem` of a module never switched off writes none either
41
- * (`recordSystemSwitchedOn`), and the backfill must not record what the live path would not.
155
+ * It reads the admin-log shape the switch calls have written since they existed
156
+ * (`revokeFromSystem` / `restoreToSystem` since #1666, `revokeFromPeer` / `restoreToPeer`
157
+ * since #1706), two rows per call sharing `after.operationId`: an `intent` row carrying the
158
+ * subject (`after.moduleId`, or `after.vertical` for a peer) and `after.reason`, then an
159
+ * outcome row whose `after.phase` is `applied`, `refused` or `failed`. Only calls whose
160
+ * outcome is `applied` count, because a refused call moved nothing and a failed one may not
161
+ * have. Of those, only the LATEST per (tenant, scope, subject) is taken, by the intent's ULID
162
+ * id. `at` is the intent's, the same instant the status read's who/why join reports. A key
163
+ * whose calls include no applied OFF gets no row, even when its latest applied call is an ON:
164
+ * history wrote no scope fence (#2045), so there is no fence for such a row to keep pace with,
165
+ * and an ON-only key needs no record to re-assert.
42
166
  *
43
167
  * `INSERT OR IGNORE`, so a row the switch wrote itself is never overwritten by history.
44
168
  * The adapters run it only on the construction that creates the table, so it runs once.
45
169
  */
46
- export const SYSTEM_SWITCHES_BACKFILL_SQL = `
170
+ export function switchesBackfillSqlOf(kind) {
171
+ const { table, key, actions, payloadKey } = RECORDS[kind];
172
+ const [revoke, restore] = actions;
173
+ return `
47
174
  WITH applied AS (
48
175
  SELECT DISTINCT action, json_extract(after, '$.operationId') AS operation_id
49
176
  FROM _substrat_admin_log
50
- WHERE action IN ('revokeFromSystem', 'restoreToSystem')
177
+ WHERE action IN ('${revoke}', '${restore}')
51
178
  AND json_extract(after, '$.phase') = 'applied'
52
179
  ),
53
180
  intents AS (
54
181
  SELECT i.id AS id, i.tenant_id AS tenant_id, i.scope_id AS scope_id,
55
- json_extract(i.after, '$.moduleId') AS module_id,
56
- CASE i.action WHEN 'revokeFromSystem' THEN 'off' ELSE 'on' END AS position,
182
+ json_extract(i.after, '$.${payloadKey}') AS subject_key,
183
+ CASE i.action WHEN '${revoke}' THEN 'off' ELSE 'on' END AS position,
57
184
  i.actor AS actor,
58
185
  json_extract(i.after, '$.reason') AS reason,
59
186
  json_extract(i.after, '$.operationId') AS operation_id,
@@ -61,35 +188,37 @@ export const SYSTEM_SWITCHES_BACKFILL_SQL = `
61
188
  FROM _substrat_admin_log i
62
189
  JOIN applied a
63
190
  ON a.action = i.action AND a.operation_id = json_extract(i.after, '$.operationId')
64
- WHERE i.action IN ('revokeFromSystem', 'restoreToSystem')
191
+ WHERE i.action IN ('${revoke}', '${restore}')
65
192
  AND i.tenant_id IS NOT NULL AND i.scope_id IS NOT NULL
66
193
  AND json_extract(i.after, '$.phase') = 'intent'
67
- AND json_extract(i.after, '$.moduleId') IS NOT NULL
194
+ AND json_extract(i.after, '$.${payloadKey}') IS NOT NULL
68
195
  AND json_extract(i.after, '$.reason') IS NOT NULL
69
196
  ),
70
197
  ranked AS (
71
198
  SELECT *,
72
- ROW_NUMBER() OVER (PARTITION BY tenant_id, scope_id, module_id ORDER BY id DESC) AS latest,
73
- MAX(position = 'off') OVER (PARTITION BY tenant_id, scope_id, module_id) AS ever_off
199
+ ROW_NUMBER() OVER (PARTITION BY tenant_id, scope_id, subject_key ORDER BY id DESC) AS latest,
200
+ MAX(position = 'off') OVER (PARTITION BY tenant_id, scope_id, subject_key) AS ever_off
74
201
  FROM intents
75
202
  )
76
- INSERT OR IGNORE INTO _substrat_system_switches
77
- (tenant_id, scope_id, module_id, position, actor, reason, operation_id, switched_at)
78
- SELECT tenant_id, scope_id, module_id, position, actor, reason, operation_id, at
203
+ INSERT OR IGNORE INTO ${table}
204
+ (tenant_id, scope_id, ${key}, position, actor, reason, operation_id, switched_at)
205
+ SELECT tenant_id, scope_id, subject_key, position, actor, reason, operation_id, at
79
206
  FROM ranked
80
207
  WHERE latest = 1 AND ever_off = 1
81
208
  `;
209
+ }
82
210
  /**
83
- * Does a dump carry the record table? A directory restore builds the table either way, and
84
- * backfills it from the dump's own admin log only when the dump did not (#1898). Compared
211
+ * Does a dump carry this kind's record table? A directory restore builds the table either way,
212
+ * and backfills it from the dump's own admin log only when the dump did not (#1898). Compared
85
213
  * without case, as SQLite resolves a table name.
86
214
  */
87
- export function dumpCarriesSystemSwitches(names) {
88
- return names.some((n) => n.toLowerCase() === SYSTEM_SWITCHES_TABLE);
215
+ export function dumpCarriesSwitches(names, kind) {
216
+ const table = RECORDS[kind].table;
217
+ return names.some((n) => n.toLowerCase() === table);
89
218
  }
90
- /** "Does the record table exist yet?" — asked BEFORE the DDL, so the backfill runs once. */
91
- export function systemSwitchesTableExists(db) {
92
- return (db.all(`SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = ?`, SYSTEM_SWITCHES_TABLE)
219
+ /** "Does this kind's record table exist yet?" — asked BEFORE the DDL, so the backfill runs once. */
220
+ export function switchesTableExists(db, kind) {
221
+ return (db.all(`SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = ?`, RECORDS[kind].table)
93
222
  .length > 0);
94
223
  }
95
224
  const positionOf = (v) => (v === 'on' ? 'on' : 'off');
@@ -143,10 +272,14 @@ export function listSystemSwitchRecords(db, filter = {}) {
143
272
  }
144
273
  return db.all(sql, ...params).map(rowOf);
145
274
  }
146
- /** One scope's record rows by module — what the per-scope status read joins as `recorded`. */
147
- export function systemSwitchRecordsOf(db, tenantId, scopeId) {
148
- const rows = db.all(`SELECT module_id, position FROM _substrat_system_switches WHERE tenant_id = ? AND scope_id = ?`, tenantId, scopeId);
149
- return new Map(rows.map((r) => [String(r.module_id), positionOf(r.position)]));
275
+ /**
276
+ * One scope's record rows of one kind, by subject (module id or peer slug) — what the per-scope
277
+ * status read joins as `recorded`, and what a re-assert reverts a stale carry against.
278
+ */
279
+ export function switchRecordsOf(db, kind, tenantId, scopeId) {
280
+ const { table, key } = RECORDS[kind];
281
+ const rows = db.all(`SELECT ${key} AS k, position FROM ${table} WHERE tenant_id = ? AND scope_id = ?`, tenantId, scopeId);
282
+ return new Map(rows.map((r) => [String(r.k), positionOf(r.position)]));
150
283
  }
151
284
  /**
152
285
  * The per-scope status read's rows with the record joined on. Each module the scope
@@ -163,12 +296,12 @@ export function withRecorded(states, recorded) {
163
296
  }
164
297
  return rows.sort((a, b) => (a.moduleId < b.moduleId ? -1 : a.moduleId > b.moduleId ? 1 : 0));
165
298
  }
166
- /** The modules a reconcile must re-assert OFF on this scope. */
167
- export function switchedOffModulesOf(db, tenantId, scopeId) {
299
+ /** The subjects of one kind (module ids, or peer slugs) a reconcile must re-assert OFF on this scope. */
300
+ export function switchedOffOf(db, kind, tenantId, scopeId) {
301
+ const { table, key } = RECORDS[kind];
168
302
  return db
169
- .all(`SELECT module_id FROM _substrat_system_switches
170
- WHERE tenant_id = ? AND scope_id = ? AND position = 'off' ORDER BY module_id`, tenantId, scopeId)
171
- .map((r) => String(r.module_id));
303
+ .all(`SELECT ${key} AS k FROM ${table} WHERE tenant_id = ? AND scope_id = ? AND position = 'off' ORDER BY ${key}`, tenantId, scopeId)
304
+ .map((r) => String(r.k));
172
305
  }
173
306
  /**
174
307
  * The scopes of one tenant the record holds a module OFF on — what a tenant-level
@@ -184,22 +317,75 @@ export function scopesSwitchedOffFor(db, tenantId, moduleId) {
184
317
  .map((r) => String(r.scope_id));
185
318
  }
186
319
  /**
187
- * The `reassertSystemSwitch` audit rows (less their `operationId`) for the in-unit moves:
188
- * those that changed something, on a module the directory records `off` for this scope.
320
+ * Does the tenant hold a live TENANT-level grant for this subject (#1823, and #2030 for a peer)?
321
+ * Asked of the directory, where the tenant tuple lives, and handed to the switch as
322
+ * `tenantHeld`: a subject whose only authority on a scope is a tenant-level grant has nothing
323
+ * in the scope's storage for the switch to find, and must still be switchable there. One
324
+ * statement on both adapters' directories; the same "live" the evaluator judges a grant by
325
+ * (unrevoked, unexpired at `now`).
326
+ */
327
+ export function tenantHoldsGrant(db, kind, tenantId, key, now) {
328
+ const row = db.all(`SELECT EXISTS (SELECT 1 FROM _substrat_tenant_tuples
329
+ WHERE tenant_id = ? AND subject = ? AND object = ? AND substr(relation, 1, 8) = 'granted:'
330
+ AND ${liveTupleSql()}) AS held`, tenantId, `${RECORDS[kind].subjectPrefix}${key}`, `tenant:${tenantId}`, now)[0];
331
+ return Number(row?.held) === 1;
332
+ }
333
+ /** Of `keys`, those the tenant holds a live tenant-level grant for (`tenantHoldsGrant`), in order. */
334
+ export function tenantHeldOf(db, kind, tenantId, keys, now) {
335
+ return keys.filter((key) => tenantHoldsGrant(db, kind, tenantId, key, now));
336
+ }
337
+ /** The subject an in-unit report names, if it is of this kind. */
338
+ export const reportKeyOf = (kind, report) => report[RECORDS[kind].payloadKey];
339
+ /**
340
+ * The fields an audit row names its subject and position with — the shape each kind's switch
341
+ * calls have always written (`moduleId` + `schedules`, `vertical` + `calls`).
342
+ */
343
+ export function switchAuditSubject(kind, key, position) {
344
+ const { payloadKey, positionField } = RECORDS[kind];
345
+ return { [payloadKey]: key, [positionField]: position };
346
+ }
347
+ /** The admin-log action a re-assert of this kind writes its rows under. */
348
+ export const reassertActionOf = (kind) => RECORDS[kind].reassertAction;
349
+ /** One re-assert answer entry: the subject by its kind's field, and what the move did. */
350
+ export const reassertEntry = (kind, key, outcome) => ({ [RECORDS[kind].payloadKey]: key, held: outcome.held, changed: outcome.changed });
351
+ /**
352
+ * #2045: the audit row (less its `operationId`) for a re-assert's ON that moved something — a
353
+ * record of ON beside a scope that was off, converged to the record under its fence.
354
+ */
355
+ export const reassertOnRow = (kind, key, permissions) => ({
356
+ ...switchAuditSubject(kind, key, 'on'),
357
+ phase: 'applied',
358
+ changed: true,
359
+ permissions: [...permissions],
360
+ });
361
+ /** The audit row (less its `operationId`) for a re-assert's own OFF that moved something — both adapters. */
362
+ export const reassertOffRow = (kind, key, permissions) => ({
363
+ ...switchAuditSubject(kind, key, 'off'),
364
+ phase: 'applied',
365
+ changed: true,
366
+ permissions: [...permissions],
367
+ });
368
+ /**
369
+ * The re-assert's audit rows (less their `operationId`) for the in-unit moves of one kind:
370
+ * those that changed something, on a subject the directory records `off` for this scope.
189
371
  * That filter is the point. The report comes from the deployment, and an audit row naming
190
- * a module the record never switched off would be the deployment writing the platform's
191
- * log. One row per module, first report wins. Built here so both adapters write one shape.
372
+ * a subject the record never switched off would be the deployment writing the platform's
373
+ * log. One row per subject, first report wins. Built here so both adapters write one shape.
192
374
  */
193
- export function inUnitMovesToAudit(recordedOff, applied) {
375
+ export function inUnitMovesToAudit(kind, recordedOff, applied,
376
+ /** Subjects this re-assert's stale-carry pass switched back on: their in-unit move is not credited. */
377
+ reverted = new Set()) {
194
378
  const off = new Set(recordedOff);
195
379
  const moves = new Map();
196
380
  for (const a of applied ?? []) {
197
- if (a.changed && off.has(a.moduleId) && !moves.has(a.moduleId))
198
- moves.set(a.moduleId, [...a.permissions]);
381
+ const key = reportKeyOf(kind, a);
382
+ if (key === undefined || reverted.has(key))
383
+ continue;
384
+ if (a.changed && off.has(key) && !moves.has(key))
385
+ moves.set(key, [...a.permissions]);
199
386
  }
200
- return [...moves].map(([moduleId, permissions]) => ({
201
- moduleId,
202
- schedules: 'off',
387
+ return [...moves].map(([key, permissions]) => ({
388
+ ...switchAuditSubject(kind, key, 'off'),
203
389
  phase: 'applied',
204
390
  changed: true,
205
391
  permissions,
@@ -208,25 +394,26 @@ export function inUnitMovesToAudit(recordedOff, applied) {
208
394
  }
209
395
  /**
210
396
  * The in-unit moves a STALE carry made, which the re-assert must undo (#1742 review): the
211
- * deployment switched a module off because the list it was handed said so, but by the time
212
- * the re-assert reads the record, an operator's `restoreToSystem` has moved it to `on`. The
213
- * list was read before the call and the ON landed in between. Left alone, the scope would
214
- * stay off while the record says on, and no later pass would put it back.
397
+ * deployment switched a subject off because the list it was handed said so, but by the time
398
+ * the re-assert reads the record, an operator's restore has moved it to `on`. The list was
399
+ * read before the call and the ON landed in between. Left alone, the scope would stay off
400
+ * while the record says on, and no later pass would put it back.
215
401
  *
216
- * Only a module the record now holds `on`, so a revert only ever re-applies an operator's
217
- * own ON. It never turns on a module whose record is `off` or missing, and so a report from
402
+ * Only a subject the record now holds `on`, so a revert only ever re-applies an operator's
403
+ * own ON. It never turns on a subject whose record is `off` or missing, and so a report from
218
404
  * the deployment can never switch on anything the platform has not already restored.
219
405
  */
220
- export function staleCarryReverts(recorded, applied) {
221
- return [
222
- ...new Set((applied ?? []).filter((a) => a.changed && recorded.get(a.moduleId) === 'on').map((a) => a.moduleId)),
223
- ];
406
+ export function staleCarryReverts(kind, recorded, applied) {
407
+ const keys = (applied ?? []).flatMap((a) => {
408
+ const key = reportKeyOf(kind, a);
409
+ return key !== undefined && a.changed && recorded.get(key) === 'on' ? [key] : [];
410
+ });
411
+ return [...new Set(keys)];
224
412
  }
225
413
  /** The audit row (less its `operationId`) for one stale-carry revert — both adapters write this shape. */
226
- export function staleCarryRevertRow(moduleId, outcome) {
414
+ export function staleCarryRevertRow(kind, key, outcome) {
227
415
  return {
228
- moduleId,
229
- schedules: 'on',
416
+ ...switchAuditSubject(kind, key, 'on'),
230
417
  phase: 'applied',
231
418
  changed: outcome.changed,
232
419
  permissions: [...outcome.permissions],
@@ -237,40 +424,19 @@ export function staleCarryRevertRow(moduleId, outcome) {
237
424
  * Overwrite one existing row's position and provenance — ON's write, and its undo. With
238
425
  * `ifOperationId`, only while the row is still the one that operation wrote (a CAS).
239
426
  */
240
- function setRecordRow(db, key, row, ifOperationId) {
241
- db.run(`UPDATE _substrat_system_switches
427
+ function setRecordRow(db, at, row, ifOperationId) {
428
+ const { table, key } = RECORDS[at.kind];
429
+ db.run(`UPDATE ${table}
242
430
  SET position = ?, actor = ?, reason = ?, operation_id = ?, switched_at = ?
243
- WHERE tenant_id = ? AND scope_id = ? AND module_id = ?` +
244
- (ifOperationId === undefined ? '' : ' AND operation_id = ?'), row.position, row.actor, row.reason, row.operationId, row.at, key.tenantId, key.scopeId, key.moduleId, ...(ifOperationId === undefined ? [] : [ifOperationId]));
245
- }
246
- /**
247
- * OFF's write, made AFTER the scope's switch held. An upsert: a repeat OFF refreshes the
248
- * actor, reason and time, as the status read reports the latest reason. Never made for a
249
- * call that held nothing, because a row saying `off` for a module the scope never ran
250
- * would switch it off on the day it is installed (the kernel's `held` check, for the same
251
- * reason).
252
- */
253
- export function recordSystemSwitchedOff(db, row) {
254
- db.run(`INSERT INTO _substrat_system_switches
255
- (tenant_id, scope_id, module_id, position, actor, reason, operation_id, switched_at)
256
- VALUES (?, ?, ?, 'off', ?, ?, ?, ?)
257
- ON CONFLICT (tenant_id, scope_id, module_id) DO UPDATE SET
258
- position = 'off', actor = excluded.actor, reason = excluded.reason,
259
- operation_id = excluded.operation_id, switched_at = excluded.switched_at`, row.tenantId, row.scopeId, row.moduleId, row.actor, row.reason, row.operationId, row.at);
431
+ WHERE tenant_id = ? AND scope_id = ? AND ${key} = ?` + (ifOperationId === undefined ? '' : ' AND operation_id = ?'), row.position, row.actor, row.reason, row.operationId, row.at, at.tenantId, at.scopeId, at.key, ...(ifOperationId === undefined ? [] : [ifOperationId]));
260
432
  }
261
- /**
262
- * ON's write, made BEFORE the scope's switch moves, and only to a row that exists. Before,
263
- * because the other order fails unsafely: a scope switched on whose record write then
264
- * failed would still read `off`, and the next reconcile would switch the operator's
265
- * restore back off. This order fails toward a record of `on` beside a live marker, which
266
- * the marker wins. Answers the row as it was, for `restoreSystemSwitchRecord`.
267
- */
268
- export function recordSystemSwitchedOn(db, row) {
269
- const prior = db.all(`SELECT position, actor, reason, operation_id, switched_at FROM _substrat_system_switches
270
- WHERE tenant_id = ? AND scope_id = ? AND module_id = ?`, row.tenantId, row.scopeId, row.moduleId)[0];
433
+ /** The row as it stands now, or null — what a write answers so its undo can put it back. */
434
+ function priorOf(db, at) {
435
+ const { table, key } = RECORDS[at.kind];
436
+ const prior = db.all(`SELECT position, actor, reason, operation_id, switched_at FROM ${table}
437
+ WHERE tenant_id = ? AND scope_id = ? AND ${key} = ?`, at.tenantId, at.scopeId, at.key)[0];
271
438
  if (!prior)
272
439
  return null;
273
- setRecordRow(db, row, { position: 'on', actor: row.actor, reason: row.reason, operationId: row.operationId, at: row.at });
274
440
  return {
275
441
  position: positionOf(prior.position),
276
442
  actor: String(prior.actor),
@@ -280,21 +446,107 @@ export function recordSystemSwitchedOn(db, row) {
280
446
  };
281
447
  }
282
448
  /**
283
- * Put a row back as `recordSystemSwitchedOn` found it — the ON that wrote it threw, or held
284
- * nothing. A compare-and-set on the ON's own `operationId`: if another switch call has
285
- * written the row since (a concurrent OFF), the row is left as that call wrote it, so an
286
- * ON's undo can never clobber a newer position.
449
+ * #2045: the record's half of the switch fence (`SWITCH_FENCES_DDL`). A write from a call OLDER than
450
+ * the one the row holds writes nothing: a newer call has already recorded its position, and the
451
+ * scope will refuse this call's move for the same reason. Both writes answer the prior row, and the
452
+ * caller reads this off it, with the same test (`recordWriteSuperseded`).
453
+ */
454
+ const supersededBy = (prior, row) => prior !== null && prior.operationId > row.operationId;
455
+ /** #2045: did this record write find a newer call's row, and so write nothing? */
456
+ export const recordWriteSuperseded = supersededBy;
457
+ /**
458
+ * #2045: the operation id each of one scope's record rows of one kind holds, by subject — the fence a
459
+ * re-assert or a carry moves the scope with, so a scope moved since by a newer call stays as that
460
+ * call put it.
461
+ */
462
+ export function switchFencesOf(db, kind, tenantId, scopeId) {
463
+ const { table, key } = RECORDS[kind];
464
+ const rows = db.all(`SELECT ${key} AS k, operation_id FROM ${table} WHERE tenant_id = ? AND scope_id = ?`, tenantId, scopeId);
465
+ return new Map(rows.map((r) => [String(r.k), String(r.operation_id)]));
466
+ }
467
+ /**
468
+ * #2045: each record row's position AND operation id, by subject, in ONE read. A caller that moves
469
+ * the scope to a row's position under the row's fence must take both from the same instant: read
470
+ * apart, a row that moves between them pairs one call's position with another call's fence (an OFF
471
+ * carried under the ON's fence applies, since the scope holds that very fence), and a row the undo
472
+ * deleted between them is moved with no fence at all, which the scope applies unconditionally.
287
473
  */
288
- export function restoreSystemSwitchRecord(db, on, prior) {
289
- if (prior)
290
- setRecordRow(db, on, prior, on.operationId);
474
+ export function switchRecordStatesOf(db, kind, tenantId, scopeId) {
475
+ const { table, key } = RECORDS[kind];
476
+ const rows = db.all(`SELECT ${key} AS k, position, operation_id FROM ${table} WHERE tenant_id = ? AND scope_id = ? ORDER BY ${key}`, tenantId, scopeId);
477
+ return new Map(rows.map((r) => [String(r.k), { position: positionOf(r.position), fence: String(r.operation_id) }]));
478
+ }
479
+ /** #2045: the tuple subject a record key names (`system:<m>`, `vertical:<v>`) — how a carry keys its fences. */
480
+ export const switchSubjectOf = (kind, key) => `${RECORDS[kind].subjectPrefix}${key}`;
481
+ /**
482
+ * OFF's write, made BEFORE the scope's switch moves (#1823), and undone by
483
+ * `restoreSwitchRecord` when the move throws or holds nothing. An upsert: a repeat OFF
484
+ * refreshes the actor, reason and time, as the status read reports the latest reason.
485
+ * Answers the row as it was.
486
+ *
487
+ * Before, because the other order left a window: between the scope moving and this write, a
488
+ * tenant-level `grantToSystem` read no `off` row and was accepted (#1743's refusal reads this
489
+ * table, in the unit that writes the tenant tuple). Written first, there is no instant at
490
+ * which the scope is off and the record is not. This order fails toward a record of `off`
491
+ * beside a scope still on, until the undo runs — the direction OFF wins anyway, and the one a
492
+ * kill switch should fail in. Still never LEFT behind for a call that held nothing: a row
493
+ * saying `off` for a subject the scope never had would switch it off on the day it is
494
+ * installed (the kernel's `held` check, for the same reason).
495
+ */
496
+ export function recordSwitchedOff(db, row) {
497
+ return writeRecord(db, row, 'off');
498
+ }
499
+ /** Both writes' upsert: the row as this call's position, unless a newer call's row is there (#2045). */
500
+ function writeRecord(db, row, position) {
501
+ const { table, key } = RECORDS[row.kind];
502
+ const prior = priorOf(db, row);
503
+ if (supersededBy(prior, row))
504
+ return prior;
505
+ db.run(`INSERT INTO ${table}
506
+ (tenant_id, scope_id, ${key}, position, actor, reason, operation_id, switched_at)
507
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
508
+ ON CONFLICT (tenant_id, scope_id, ${key}) DO UPDATE SET
509
+ position = excluded.position, actor = excluded.actor, reason = excluded.reason,
510
+ operation_id = excluded.operation_id, switched_at = excluded.switched_at`, row.tenantId, row.scopeId, row.key, position, row.actor, row.reason, row.operationId, row.at);
511
+ return prior;
512
+ }
513
+ /**
514
+ * ON's write, made BEFORE the scope's switch moves. Before, because the other order fails
515
+ * unsafely: a scope switched on whose record write then failed would still read `off`, and the
516
+ * next reconcile would switch the operator's restore back off. Answers the row as it was, for
517
+ * `restoreSwitchRecord`.
518
+ *
519
+ * #2045: an upsert, like OFF's. An ON with no row before it writes one, because its move stores
520
+ * its id in the scope's fence: without a row carrying the same id, an OLDER OFF arriving after
521
+ * it would find no row to be refused by, record itself, and leave the directory behind the scope
522
+ * (Codex r2). The directory's fence is never behind the scope's. An ON that holds nothing still
523
+ * leaves no row: its undo removes the one it wrote.
524
+ */
525
+ export function recordSwitchedOn(db, row) {
526
+ return writeRecord(db, row, 'on');
527
+ }
528
+ /**
529
+ * Put a row back as `recordSwitchedOn` or `recordSwitchedOff` found it — the call that wrote
530
+ * it threw, or held nothing. A row that did not exist is removed again. A compare-and-set on
531
+ * the call's own `operationId`: if another switch call has written the row since, the row is
532
+ * left as that call wrote it, so an undo can never clobber a newer position.
533
+ */
534
+ export function restoreSwitchRecord(db, call, prior) {
535
+ if (prior) {
536
+ setRecordRow(db, call, prior, call.operationId);
537
+ return;
538
+ }
539
+ const { table, key } = RECORDS[call.kind];
540
+ db.run(`DELETE FROM ${table} WHERE tenant_id = ? AND scope_id = ? AND ${key} = ? AND operation_id = ?`, call.tenantId, call.scopeId, call.key, call.operationId);
291
541
  }
292
542
  /**
293
- * Forget one scope's switch records — the scope's directory row is going too (a reaped
294
- * preview or fork, a reaped scope). Without this the fleet read keeps listing a switch on
543
+ * Forget one scope's switch records, of every kind — the scope's directory row is going too (a
544
+ * reaped preview or fork, a reaped scope). Without this the fleet read keeps listing a switch on
295
545
  * a scope that no longer exists. The admin log keeps the history, as it keeps the scope's.
296
546
  */
297
- export function forgetSystemSwitchesOf(db, scopeId) {
298
- db.run(`DELETE FROM _substrat_system_switches WHERE scope_id = ?`, scopeId);
547
+ export function forgetSwitchesOf(db, scopeId) {
548
+ for (const kind of SWITCH_KINDS)
549
+ db.run(`DELETE FROM ${RECORDS[kind].table} WHERE scope_id = ?`, scopeId);
550
+ db.run(`DELETE FROM _substrat_switch_owed WHERE scope_id = ?`, scopeId);
299
551
  }
300
552
  //# sourceMappingURL=system-switch-record.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"system-switch-record.js","sourceRoot":"","sources":["../src/system-switch-record.ts"],"names":[],"mappings":"AA6BA,2DAA2D;AAC3D,MAAM,CAAC,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAEjE;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;CAmBlC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmC3C,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAwB;IAChE,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,qBAAqB,CAAC,CAAC;AACtE,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,yBAAyB,CAAC,EAAa;IACrD,OAAO,CACL,EAAE,CAAC,GAAG,CAAC,0EAA0E,EAAE,qBAAqB,CAAC;SACtG,MAAM,GAAG,CAAC,CACd,CAAC;AACJ,CAAC;AA2BD,MAAM,UAAU,GAAG,CAAC,CAAU,EAAgB,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAE7E,MAAM,OAAO,GAAG;gCACgB,CAAC;AAEjC,MAAM,KAAK,GAAG,CAAC,CAA0B,EAAyB,EAAE,CAAC,CAAC;IACpE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7B,QAAQ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