@substrat-run/adapter-sqlite 0.5.0 → 0.7.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.
- package/dist/checker.d.ts.map +1 -1
- package/dist/checker.js +15 -5
- package/dist/checker.js.map +1 -1
- package/dist/index.d.ts +74 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +922 -61
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/checker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAQL,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAiB9D,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC7B,kFAAkF;IAClF,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC,QAAQ,GAAG,SAAS,CAAC;IACxD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;CACpE;
|
|
1
|
+
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAQL,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAiB9D,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC7B,kFAAkF;IAClF,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC,QAAQ,GAAG,SAAS,CAAC;IACxD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;CACpE;AAgBD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,GAAG,iBAAiB,CA4JvE"}
|
package/dist/checker.js
CHANGED
|
@@ -19,14 +19,18 @@ const t = (subject, relation, object) => ({
|
|
|
19
19
|
});
|
|
20
20
|
export function createTupleChecker(deps) {
|
|
21
21
|
const tenantTuples = (tenantId, subject, relationPrefix) => deps.directory
|
|
22
|
-
.prepare(`SELECT subject, relation, object, expires_at FROM _substrat_tenant_tuples
|
|
22
|
+
.prepare(`SELECT subject, relation, object, expires_at, revoked_at FROM _substrat_tenant_tuples
|
|
23
23
|
WHERE tenant_id = ? AND subject = ? AND relation LIKE ?`)
|
|
24
24
|
.all(tenantId, subject, `${relationPrefix}%`);
|
|
25
25
|
const scopeTuples = (db, subject, relationPrefix) => db
|
|
26
|
-
.prepare(`SELECT subject, relation, object, expires_at FROM _substrat_tuples
|
|
26
|
+
.prepare(`SELECT subject, relation, object, expires_at, revoked_at FROM _substrat_tuples
|
|
27
27
|
WHERE subject = ? AND relation LIKE ?`)
|
|
28
28
|
.all(subject, `${relationPrefix}%`);
|
|
29
|
-
|
|
29
|
+
// A tuple grants only while it is unexpired AND unrevoked. K-21: revocation
|
|
30
|
+
// tombstones rather than deletes, so a revoked row is still here and still
|
|
31
|
+
// readable as evidence — it just stops granting. Same predicate, same sites as
|
|
32
|
+
// `expires_at`, so there is one definition of "live" rather than two.
|
|
33
|
+
const live = (row, now) => (row.expires_at === null || row.expires_at > now) && row.revoked_at === null;
|
|
30
34
|
return {
|
|
31
35
|
async check(principal, permission, node, entity) {
|
|
32
36
|
const now = new Date().toISOString();
|
|
@@ -97,7 +101,7 @@ export function createTupleChecker(deps) {
|
|
|
97
101
|
for (const candidate of frontier) {
|
|
98
102
|
for (const subject of subjects) {
|
|
99
103
|
const grant = scopeDb
|
|
100
|
-
.prepare(`SELECT subject, relation, object, expires_at FROM _substrat_tuples
|
|
104
|
+
.prepare(`SELECT subject, relation, object, expires_at, revoked_at FROM _substrat_tuples
|
|
101
105
|
WHERE subject = ? AND relation = ? AND object = ?`)
|
|
102
106
|
.get(subject.ref, `granted:${permission}`, candidate.ref);
|
|
103
107
|
if (grant && live(grant, now)) {
|
|
@@ -116,10 +120,16 @@ export function createTupleChecker(deps) {
|
|
|
116
120
|
const next = [];
|
|
117
121
|
for (const candidate of frontier) {
|
|
118
122
|
const parents = scopeDb
|
|
119
|
-
.prepare(`SELECT subject, relation, object, expires_at FROM _substrat_tuples
|
|
123
|
+
.prepare(`SELECT subject, relation, object, expires_at, revoked_at FROM _substrat_tuples
|
|
120
124
|
WHERE subject = ? AND relation = 'parent'`)
|
|
121
125
|
.all(candidate.ref);
|
|
122
126
|
for (const p of parents) {
|
|
127
|
+
// A revoked parent edge stops expanding. Without this the tombstone
|
|
128
|
+
// would work for grants and membership but silently NOT for entity
|
|
129
|
+
// edges — which is the case open question 15 is actually about
|
|
130
|
+
// (a facility moving management company must stop being reachable).
|
|
131
|
+
if (!live(p, now))
|
|
132
|
+
continue;
|
|
123
133
|
next.push({
|
|
124
134
|
ref: p.object,
|
|
125
135
|
chain: [...candidate.chain, t(p.subject, 'parent', p.object)],
|
package/dist/checker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checker.js","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,GAQV,MAAM,yBAAyB,CAAC;AAGjC;;;;;;;;;;;GAWG;AAEH,MAAM,iBAAiB,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"checker.js","sourceRoot":"","sources":["../src/checker.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,GAQV,MAAM,yBAAyB,CAAC;AAGjC;;;;;;;;;;;GAWG;AAEH,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAiB5B,MAAM,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,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;wCACrC,GAAG,SAAS,CAAC,KAAK;wCAClB,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC;qCAC/C;iCACF,CAAC;4BACJ,CAAC;wBACH,CAAC;oBACH,CAAC;oBACD,8BAA8B;oBAC9B,MAAM,IAAI,GAAe,EAAE,CAAC;oBAC5B,KAAK,MAAM,SAAS,IAAI,QAAQ,EAAE,CAAC;wBACjC,MAAM,OAAO,GAAG,OAAO;6BACpB,OAAO,CACN;2DAC2C,CAC5C;6BACA,GAAG,CAAC,SAAS,CAAC,GAAG,CAAe,CAAC;wBACpC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;4BACxB,oEAAoE;4BACpE,mEAAmE;4BACnE,+DAA+D;4BAC/D,oEAAoE;4BACpE,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC;gCAAE,SAAS;4BAC5B,IAAI,CAAC,IAAI,CAAC;gCACR,GAAG,EAAE,CAAC,CAAC,MAAM;gCACb,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;6BAC9D,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;oBACD,QAAQ,GAAG,IAAI,CAAC;gBAClB,CAAC;YACH,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PlatformActorId, type PrincipalId, type ScopeId, type TenantId } from '@substrat-run/contracts';
|
|
2
|
-
import { type HostAdmin, type ModuleRegistration, type OperationHandler, type PermissionChecker, type ProvisionScopeInput, type ScopeHost, type ScopeStub } from '@substrat-run/kernel';
|
|
2
|
+
import { type ExecutorHandler, type HostAdmin, type ModuleRegistration, type OperationHandler, type PermissionChecker, type ProvisionScopeInput, type ScopeHost, type ScopeStub } from '@substrat-run/kernel';
|
|
3
3
|
export interface SqliteScopeHostOptions {
|
|
4
4
|
/** Directory holding one SQLite file per scope plus the directory database. */
|
|
5
5
|
dir: string;
|
|
@@ -25,14 +25,39 @@ export declare class SqliteScopeHost implements ScopeHost {
|
|
|
25
25
|
/** operation name → its owning module's entitlementKey (§4.3 gate). */
|
|
26
26
|
private readonly operationEntitlement;
|
|
27
27
|
private readonly roles;
|
|
28
|
+
/** Executor id → {eventType, handler} (K-22 §4.2). Host code, not module code. */
|
|
29
|
+
private readonly executors;
|
|
30
|
+
/**
|
|
31
|
+
* The event currently being effected by an executor, stamped onto any admin rows
|
|
32
|
+
* it writes. Ambient rather than threaded through every HostAdmin signature: it is
|
|
33
|
+
* set and cleared immediately around one `await`, and executors run sequentially,
|
|
34
|
+
* so there is no window where it belongs to a different event.
|
|
35
|
+
*/
|
|
36
|
+
private causedBy;
|
|
28
37
|
private readonly systemPrincipal;
|
|
29
38
|
constructor(options: SqliteScopeHostOptions);
|
|
39
|
+
registerExecutor(id: string, eventType: string, handler: ExecutorHandler): void;
|
|
30
40
|
registerModule(registration: ModuleRegistration): void;
|
|
31
41
|
defineOperation<I, O>(name: string, handler: OperationHandler<I, O>): void;
|
|
32
42
|
provisionScope(actor: PlatformActorId, input: ProvisionScopeInput): Promise<void>;
|
|
33
43
|
getScope(principal: PrincipalId, tenantId: TenantId, scopeId: ScopeId): Promise<ScopeStub>;
|
|
34
44
|
private runGuards;
|
|
35
45
|
close(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Run executors over this scope's outbox (K-22 §4.2) — the connector half of the
|
|
48
|
+
* seam. Same at-least-once journal as consumers, keyed on a distinct delivery id
|
|
49
|
+
* so an executor and a module consumer on the same event do not shadow each other.
|
|
50
|
+
*
|
|
51
|
+
* Runs OUTSIDE the scope's transaction, and deliberately so: the executor acts on
|
|
52
|
+
* the directory, which is not part of the scope's serialization domain. The
|
|
53
|
+
* atomicity that matters already happened — the event only exists because the
|
|
54
|
+
* emitting transaction committed.
|
|
55
|
+
*
|
|
56
|
+
* A throwing executor leaves the delivery unjournaled, so it is retried on the
|
|
57
|
+
* next dispatch. That is the backstop; it is not a substitute for idempotent
|
|
58
|
+
* handlers, which at-least-once still requires.
|
|
59
|
+
*/
|
|
60
|
+
private dispatchExecutors;
|
|
36
61
|
private dispatch;
|
|
37
62
|
private parseOutboxRow;
|
|
38
63
|
/**
|
|
@@ -42,6 +67,14 @@ export declare class SqliteScopeHost implements ScopeHost {
|
|
|
42
67
|
* remembering a call per method. `before` is captured only where cheaply
|
|
43
68
|
* readable; idempotent upserts with no cheap prior state pass `before: null`.
|
|
44
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* Record a staff read (K-24). Called by every read on `HostAdmin`, which is why
|
|
72
|
+
* they all take an actor: a read the log cannot attribute is unrepresentable.
|
|
73
|
+
*
|
|
74
|
+
* `params` is a bounded summary, not the raw filter — enough to know what was
|
|
75
|
+
* asked, capped so one query cannot write an unbounded row.
|
|
76
|
+
*/
|
|
77
|
+
private recordAccess;
|
|
45
78
|
private recordAdmin;
|
|
46
79
|
private tenantHoldsEntitlement;
|
|
47
80
|
private buildAdmin;
|
|
@@ -55,10 +88,50 @@ export declare class SqliteScopeHost implements ScopeHost {
|
|
|
55
88
|
* within tenant"). Idempotent: on a fresh directory every column already
|
|
56
89
|
* exists and every UPDATE matches nothing.
|
|
57
90
|
*/
|
|
91
|
+
/**
|
|
92
|
+
* Additive column migration for a table that already exists in someone's data
|
|
93
|
+
* directory. `PRAGMA table_info` is available in the pure adapter (the DO adapter
|
|
94
|
+
* has to attempt-and-tolerate instead — see its `ensureDirectoryColumns`).
|
|
95
|
+
*/
|
|
96
|
+
private ensureColumn;
|
|
97
|
+
/**
|
|
98
|
+
* Rebuild `_substrat_identities` when it still carries the pre-K-22 global key.
|
|
99
|
+
* A PRIMARY KEY cannot be ALTERed, so this is create-copy-drop-rename.
|
|
100
|
+
*
|
|
101
|
+
* The old shape is detected from `sqlite_master.sql` rather than `PRAGMA table_info`
|
|
102
|
+
* (which reports PK membership but not composition readably), and because the same
|
|
103
|
+
* check works on DO SQLite, where PRAGMA is restricted — so both adapters can use
|
|
104
|
+
* one detection strategy.
|
|
105
|
+
*
|
|
106
|
+
* Rows carry `tenant_id` already, so the copy is lossless: what changes is which
|
|
107
|
+
* columns are unique, not what is stored. Two pools that both issued `123` were
|
|
108
|
+
* previously ONE row (the second link silently ignored); after the rebuild the
|
|
109
|
+
* surviving row keeps its tenant and the other tenant's link can be made again.
|
|
110
|
+
*/
|
|
111
|
+
private ensureIdentityKey;
|
|
112
|
+
/**
|
|
113
|
+
* Drop the admin log's `tenant_id NOT NULL` (K-23). SQLite cannot relax a column
|
|
114
|
+
* constraint in place, so this is the same create-copy-drop-rename the identity key
|
|
115
|
+
* uses, detected the same way — from `sqlite_master.sql`, which works on DO SQLite
|
|
116
|
+
* too. Rows are copied verbatim: the log stays append-only in content, this only
|
|
117
|
+
* widens what a future row may say.
|
|
118
|
+
*/
|
|
119
|
+
private ensureAdminLogTenantNullable;
|
|
58
120
|
private ensureDirectoryColumns;
|
|
59
121
|
private loadRoles;
|
|
60
122
|
private operationContext;
|
|
61
123
|
private applyPendingMigrations;
|
|
124
|
+
/**
|
|
125
|
+
* Project a scope's migration state into the directory — §5.4's "fleet questions
|
|
126
|
+
* never fan out", so the index answers "which scopes are behind" and "which
|
|
127
|
+
* failed" without waking anything.
|
|
128
|
+
*
|
|
129
|
+
* `appliedMigrations.size` is written on both paths: after a partial failure it
|
|
130
|
+
* is the count that actually landed, which is more truthful than the pre-attempt
|
|
131
|
+
* value. On success the failure columns are cleared, so `attempts` counts
|
|
132
|
+
* *consecutive* failures — what the sweep's backoff (#49) needs.
|
|
133
|
+
*/
|
|
134
|
+
private recordMigrationState;
|
|
62
135
|
private runtime;
|
|
63
136
|
}
|
|
64
137
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EA6CL,KAAK,eAAe,EACpB,KAAK,WAAW,EAYhB,KAAK,OAAO,EAGZ,KAAK,QAAQ,EAGd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAML,KAAK,eAAe,EAEpB,KAAK,SAAS,EACd,KAAK,kBAAkB,EAEvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAIxB,KAAK,SAAS,EACd,KAAK,SAAS,EAGf,MAAM,sBAAsB,CAAC;AAyB9B,MAAM,WAAW,sBAAsB;IACrC,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;IACZ,gFAAgF;IAChF,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC7B;AAqMD,qBAAa,eAAgB,YAAW,SAAS;IAC/C,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoB;IAC9C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmC;IAC1D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmC;IAC9D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuD;IAClF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAC/D,gFAAgF;IAChF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsC;IAC7D,gFAAgF;IAChF,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkE;IAC7F,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,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