@substrat-run/kernel 0.114.0 → 0.117.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/capability.d.ts +220 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +537 -0
- package/dist/capability.js.map +1 -0
- package/dist/check-key.d.ts +30 -0
- package/dist/check-key.d.ts.map +1 -0
- package/dist/check-key.js +37 -0
- package/dist/check-key.js.map +1 -0
- package/dist/denial-query.d.ts +35 -2
- package/dist/denial-query.d.ts.map +1 -1
- package/dist/denial-query.js +70 -28
- package/dist/denial-query.js.map +1 -1
- package/dist/index.d.ts +23 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/dist/job-run.d.ts +493 -0
- package/dist/job-run.d.ts.map +1 -0
- package/dist/job-run.js +655 -0
- package/dist/job-run.js.map +1 -0
- package/dist/outbox-event.d.ts +131 -0
- package/dist/outbox-event.d.ts.map +1 -0
- package/dist/outbox-event.js +185 -0
- package/dist/outbox-event.js.map +1 -0
- package/dist/permission-checker.d.ts +8 -1
- package/dist/permission-checker.d.ts.map +1 -1
- package/dist/permission-checker.js +18 -0
- package/dist/permission-checker.js.map +1 -1
- package/dist/permission-eval.d.ts +8 -0
- package/dist/permission-eval.d.ts.map +1 -1
- package/dist/permission-eval.js +164 -91
- package/dist/permission-eval.js.map +1 -1
- package/dist/platform-request-query.d.ts +58 -1
- package/dist/platform-request-query.d.ts.map +1 -1
- package/dist/platform-request-query.js +61 -1
- package/dist/platform-request-query.js.map +1 -1
- package/dist/platform-sweep.d.ts +180 -8
- package/dist/platform-sweep.d.ts.map +1 -1
- package/dist/platform-sweep.js +243 -34
- package/dist/platform-sweep.js.map +1 -1
- package/dist/row-decode.d.ts +107 -0
- package/dist/row-decode.d.ts.map +1 -0
- package/dist/row-decode.js +93 -0
- package/dist/row-decode.js.map +1 -0
- package/dist/scope-host.d.ts +444 -9
- package/dist/scope-host.d.ts.map +1 -1
- package/dist/scope-host.js +33 -0
- package/dist/scope-host.js.map +1 -1
- package/dist/scope-tuple-seat.d.ts +72 -0
- package/dist/scope-tuple-seat.d.ts.map +1 -0
- package/dist/scope-tuple-seat.js +93 -0
- package/dist/scope-tuple-seat.js.map +1 -0
- package/dist/subject-redaction.d.ts +160 -0
- package/dist/subject-redaction.d.ts.map +1 -0
- package/dist/subject-redaction.js +210 -0
- package/dist/subject-redaction.js.map +1 -0
- package/dist/system-switch.d.ts +108 -0
- package/dist/system-switch.d.ts.map +1 -0
- package/dist/system-switch.js +145 -0
- package/dist/system-switch.js.map +1 -0
- package/dist/timeline.d.ts.map +1 -1
- package/dist/timeline.js +115 -52
- package/dist/timeline.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-run.js","sourceRoot":"","sources":["../src/job-run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiB,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAA4C,MAAM,iBAAiB,CAAC;AAE1G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;AAEH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkE1B,CAAC;AAqEF,kDAAkD;AAClD,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC,uFAAuF;AACvF,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAEpC;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,KAAyB;IACvD,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAA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CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAM,EAAE,CAAC,CAAC;gBAC7D,MAAM;YACR,CAAC;YACD,IAAI,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;gBAClC,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC;gBACrB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAM,EAAE,CAAC,CAAC;gBAC7D,MAAM;YACR,CAAC;YACD,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC;YACrB,6EAA6E;YAC7E,4EAA4E;YAC5E,4DAA4D;YAC5D,IAAI,IAAI,GAAG,CAAC,IAAI,SAAS;gBAAE,MAAM;YACjC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC9C,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;gBAAE,MAAM;YAChD,GAAG,GAAG,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { type DomainEvent, type DrainedEvent } from '@substrat-run/contracts';
|
|
2
|
+
/**
|
|
3
|
+
* Decoding a stored `_substrat_outbox` row into the envelope work is done with (#1636).
|
|
4
|
+
*
|
|
5
|
+
* The READ side of the outbox is tolerant (`readHistory` and the walks, via `rowDecoder`):
|
|
6
|
+
* a row that does not decode comes back beside its neighbours, saying why. This is the
|
|
7
|
+
* other side — the rows that are EXECUTED. A consumer's handler, an executor's handler and
|
|
8
|
+
* the Tier-2 drain each act on the event, and a half-decoded event is not one any of them
|
|
9
|
+
* may act on: a consumer built from stand-ins would record effects nobody asked for, and a
|
|
10
|
+
* lake row built from them would be exact history that is not. So this decode is strict and
|
|
11
|
+
* throws, and what changed is WHERE the throw lands. It used to sit above each loop's
|
|
12
|
+
* per-event containment, so one bad row halted every event behind it on every pass:
|
|
13
|
+
*
|
|
14
|
+
* - consumer delivery never delivered anything of that type after it;
|
|
15
|
+
* - executor dispatch failed the executor's whole pending list;
|
|
16
|
+
* - the Tier-2 drain stalled for the scope, because a row that never ships is never
|
|
17
|
+
* stamped, so the next pass read it first again.
|
|
18
|
+
*
|
|
19
|
+
* Each caller now contains it per event — a dead letter for a delivery, a skip for the
|
|
20
|
+
* drain — and the event behind it moves.
|
|
21
|
+
*
|
|
22
|
+
* One decoder, where there were two copies of the same `domainEvent.parse` in the two
|
|
23
|
+
* adapters: both now decode through here, so a row cannot deliver on one and dead-letter
|
|
24
|
+
* on the other.
|
|
25
|
+
*/
|
|
26
|
+
/** The `_substrat_outbox` columns the envelope is built from, as either adapter hands them back. */
|
|
27
|
+
export interface OutboxEnvelopeRow {
|
|
28
|
+
id: string;
|
|
29
|
+
type: string;
|
|
30
|
+
schema_version: number;
|
|
31
|
+
occurred_at: string;
|
|
32
|
+
tenant_id: string;
|
|
33
|
+
scope_id: string;
|
|
34
|
+
actor: string;
|
|
35
|
+
entity_type: string;
|
|
36
|
+
entity_id: string;
|
|
37
|
+
pii_class: string;
|
|
38
|
+
subject_id: string | null;
|
|
39
|
+
authorization: string | null;
|
|
40
|
+
impersonation: string | null;
|
|
41
|
+
operation: string | null;
|
|
42
|
+
payload: string | null;
|
|
43
|
+
}
|
|
44
|
+
/** …plus the columns the Tier-2 drain lifts beside the envelope (#1242, #1237). */
|
|
45
|
+
export interface OutboxDrainRow extends OutboxEnvelopeRow {
|
|
46
|
+
version?: string | null;
|
|
47
|
+
caused_by?: string | null;
|
|
48
|
+
invocation_id?: string | null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The stored row → the `DomainEvent` a consumer or executor is handed, or a throw naming
|
|
52
|
+
* EVERY column that did not decode.
|
|
53
|
+
*
|
|
54
|
+
* A row the kernel wrote decodes exactly as it always did — the same candidate into the same
|
|
55
|
+
* `domainEvent.parse`. The throw's message never quotes the stored text (see `rowDecoder`):
|
|
56
|
+
* it is written into a dead letter, which is stored beside the event and survives an erasure
|
|
57
|
+
* of its payload.
|
|
58
|
+
*/
|
|
59
|
+
export declare function domainEventOf(row: OutboxEnvelopeRow): DomainEvent;
|
|
60
|
+
/**
|
|
61
|
+
* The stored row → the `DrainedEvent` the Tier-2 drain ships, or a throw (`domainEventOf`'s).
|
|
62
|
+
*
|
|
63
|
+
* The WHOLE event is parsed by the published `drainedEvent` schema — the envelope and the
|
|
64
|
+
* columns lifted beside it (`operation`, `version`, `caused_by`, `invocation_id`), which the
|
|
65
|
+
* envelope does not carry. They used to be copied onto an already-validated envelope as
|
|
66
|
+
* stored, into a value merely TYPED as a `DrainedEvent` (#1641 review): a restored row with
|
|
67
|
+
* `version: ''` or a `caused_by` that is not an event id reached the lake, append-only, and
|
|
68
|
+
* was stamped as having left. Parsed here, it throws, and `readUndrainedOutbox` skips it and
|
|
69
|
+
* says so. A row the kernel wrote passes unchanged: each lifted column is written from a
|
|
70
|
+
* validated value or as NULL.
|
|
71
|
+
*/
|
|
72
|
+
export declare function drainedEventOf(row: OutboxDrainRow): DrainedEvent;
|
|
73
|
+
/**
|
|
74
|
+
* What a Tier-2 read passed over (#1636): rows that would not decode, so were neither
|
|
75
|
+
* returned nor — since nothing ships them — ever stamped.
|
|
76
|
+
*
|
|
77
|
+
* `eventIds` is capped at {@link UNDRAINED_SKIPPED_IDS}; `count` is exact. Ids only, never
|
|
78
|
+
* a reason: this travels to the control plane's sweep report and its log, and a decode
|
|
79
|
+
* message is one step from the stored text it describes.
|
|
80
|
+
*/
|
|
81
|
+
export interface UndrainedSkipped {
|
|
82
|
+
count: number;
|
|
83
|
+
eventIds: string[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* `readUndrainedEvents`' answer: the events, oldest first — an ARRAY, because every caller
|
|
87
|
+
* already reads one — with what the read skipped riding beside them as an optional
|
|
88
|
+
* property. Absent when every row it read decoded, so a clean read is the array it always
|
|
89
|
+
* was.
|
|
90
|
+
*
|
|
91
|
+
* A property on an array does not survive `JSON.stringify` or an RPC hop, so each hop that
|
|
92
|
+
* carries this says so explicitly (the DO's `undrainedEventsRead`, the vertical's
|
|
93
|
+
* `/internal/undrained-events?withSkipped=1`); it is only ever attached in-process.
|
|
94
|
+
*/
|
|
95
|
+
export type UndrainedEvents = DrainedEvent[] & {
|
|
96
|
+
skipped?: UndrainedSkipped;
|
|
97
|
+
};
|
|
98
|
+
/** The same answer, as a plain object — the shape that crosses an RPC or HTTP hop. */
|
|
99
|
+
export interface UndrainedRead {
|
|
100
|
+
events: DrainedEvent[];
|
|
101
|
+
skipped?: UndrainedSkipped;
|
|
102
|
+
}
|
|
103
|
+
/** How many rows past `limit` one read may look through, as a multiple of `limit`. */
|
|
104
|
+
export declare const UNDRAINED_SCAN_FACTOR = 10;
|
|
105
|
+
/** How many skipped ids a read names; the count past it stays exact. */
|
|
106
|
+
export declare const UNDRAINED_SKIPPED_IDS = 50;
|
|
107
|
+
/**
|
|
108
|
+
* The Tier-2 drain's read over one scope's outbox (#1334), CONTAINED per row (#1636) — the
|
|
109
|
+
* one implementation both adapters run, so they cannot disagree about what is skipped.
|
|
110
|
+
*
|
|
111
|
+
* `page(offset, count)` is the adapter's
|
|
112
|
+
* `SELECT * … WHERE drained_at IS NULL ORDER BY id LIMIT count OFFSET offset`. Offset
|
|
113
|
+
* rather than an id cursor on purpose: the rows being stepped over are exactly the ones
|
|
114
|
+
* whose `id` may be the column that is broken.
|
|
115
|
+
*
|
|
116
|
+
* A row that does not decode is SKIPPED: not returned, so no sink ever receives an event
|
|
117
|
+
* built from stand-ins — the lake is append-only, and a wrong row there cannot be taken
|
|
118
|
+
* back — and not stamped, so `drained_at` stays an exact record of what left. The read
|
|
119
|
+
* keeps going past it, so the healthy rows behind it still ship. The cost is stated rather
|
|
120
|
+
* than hidden: a skipped row never reaches the lake, and every pass reads it again. It
|
|
121
|
+
* stays visible in Tier 1, where `readHistory` returns it with a `decodeError`.
|
|
122
|
+
*
|
|
123
|
+
* Bounded: at most `limit × UNDRAINED_SCAN_FACTOR` rows are looked at. A scope whose next
|
|
124
|
+
* that-many undrained rows ALL fail to decode ships nothing, pass after pass — at that
|
|
125
|
+
* point the spine is broken wholesale, which is a restore to repair rather than a row to
|
|
126
|
+
* step over, and the skipped count in the sweep report is what says so.
|
|
127
|
+
*/
|
|
128
|
+
export declare function readUndrainedOutbox(page: (offset: number, count: number) => OutboxDrainRow[], limit: number): UndrainedRead;
|
|
129
|
+
/** An `UndrainedRead` → the in-process array shape, the skip attached only when there is one. */
|
|
130
|
+
export declare function undrainedEventsOf(read: UndrainedRead): UndrainedEvents;
|
|
131
|
+
//# sourceMappingURL=outbox-event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox-event.d.ts","sourceRoot":"","sources":["../src/outbox-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGzG;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,oGAAoG;AACpG,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IA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+
import { domainEvent, drainedEvent } from '@substrat-run/contracts';
|
|
2
|
+
import { issueOf, NOT_JSON } from './row-decode.js';
|
|
3
|
+
/** Contract field → the column a message should name, where the two differ. */
|
|
4
|
+
const COLUMN_OF = {
|
|
5
|
+
schemaVersion: 'schema_version',
|
|
6
|
+
occurredAt: 'occurred_at',
|
|
7
|
+
tenantId: 'tenant_id',
|
|
8
|
+
scopeId: 'scope_id',
|
|
9
|
+
piiClass: 'pii_class',
|
|
10
|
+
subjectId: 'subject_id',
|
|
11
|
+
causedBy: 'caused_by',
|
|
12
|
+
invocationId: 'invocation_id',
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The envelope candidate a schema parse is run over, JSON columns parsed.
|
|
16
|
+
*
|
|
17
|
+
* Every optional column is tested for PRESENCE (`!= null`), never for truthiness (#1641
|
|
18
|
+
* review). A truthiness test read a stored `''` as "absent" and skipped validating it, so a
|
|
19
|
+
* restored row carrying an empty `authorization`, `impersonation`, `subject_id` or
|
|
20
|
+
* `operation` was delivered, executed or drained as though the column were null, instead of
|
|
21
|
+
* contained. The kernel never writes `''` to any of them — each is written from a validated
|
|
22
|
+
* value or as NULL — so a present value is always one to validate. `undefined` still reads
|
|
23
|
+
* as absent: it is the column missing from a legacy row, never a stored value.
|
|
24
|
+
*/
|
|
25
|
+
function envelopeCandidate(row, into) {
|
|
26
|
+
const json = (column, stored) => {
|
|
27
|
+
try {
|
|
28
|
+
return JSON.parse(stored);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
into.failed.push(`${column}: ${NOT_JSON}`);
|
|
32
|
+
into.named.add(column);
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
id: row.id,
|
|
38
|
+
type: row.type,
|
|
39
|
+
schemaVersion: row.schema_version,
|
|
40
|
+
occurredAt: row.occurred_at,
|
|
41
|
+
tenantId: row.tenant_id,
|
|
42
|
+
scopeId: row.scope_id,
|
|
43
|
+
actor: json('actor', row.actor),
|
|
44
|
+
entity: { entityType: row.entity_type, entityId: row.entity_id },
|
|
45
|
+
piiClass: row.pii_class,
|
|
46
|
+
...(row.subject_id != null ? { subjectId: row.subject_id } : {}),
|
|
47
|
+
...(row.authorization != null ? { authorization: json('authorization', row.authorization) } : {}),
|
|
48
|
+
// K-42: the stamp survives the read, so a consumer's event and an executor's
|
|
49
|
+
// are the same fact the stored row is. Absent rather than null when nobody
|
|
50
|
+
// was impersonating, because `DomainEvent.impersonation` is optional — the
|
|
51
|
+
// shape module code never sees is also the shape it cannot branch on.
|
|
52
|
+
...(row.impersonation != null ? { impersonation: json('impersonation', row.impersonation) } : {}),
|
|
53
|
+
// #1231: absent rather than null, the same shape rule as the stamp above.
|
|
54
|
+
...(row.operation != null ? { operation: row.operation } : {}),
|
|
55
|
+
payload: row.payload == null ? undefined : json('payload', row.payload),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* `candidate` parsed by the PUBLISHED `schema`, returned only as that parse's own output — or
|
|
60
|
+
* a throw naming every column that did not decode. Nothing is copied onto the result after
|
|
61
|
+
* validation, so the value a caller gets is exactly what the schema accepted (#1641 review).
|
|
62
|
+
*/
|
|
63
|
+
function strictly(row, schema, candidate, { failed, named }) {
|
|
64
|
+
const parsed = schema.safeParse(candidate);
|
|
65
|
+
if (parsed.success && failed.length === 0)
|
|
66
|
+
return parsed.data;
|
|
67
|
+
if (!parsed.success) {
|
|
68
|
+
for (const issue of parsed.error.issues) {
|
|
69
|
+
const head = String(issue.path[0] ?? '');
|
|
70
|
+
const column = head === 'entity' ? (issue.path[1] === 'entityId' ? 'entity_id' : 'entity_type') : (COLUMN_OF[head] ?? head);
|
|
71
|
+
// A JSON column that did not parse is already named; its `Required` issue here says
|
|
72
|
+
// nothing new.
|
|
73
|
+
if (named.has(column))
|
|
74
|
+
continue;
|
|
75
|
+
named.add(column);
|
|
76
|
+
failed.push(issueOf(column, { issues: [{ ...issue, path: issue.path.slice(head === 'entity' ? 2 : 1) }] }));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
throw new Error(`event row ${JSON.stringify(row.id)} cannot be decoded — ${failed.join('; ')}`);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The stored row → the `DomainEvent` a consumer or executor is handed, or a throw naming
|
|
83
|
+
* EVERY column that did not decode.
|
|
84
|
+
*
|
|
85
|
+
* A row the kernel wrote decodes exactly as it always did — the same candidate into the same
|
|
86
|
+
* `domainEvent.parse`. The throw's message never quotes the stored text (see `rowDecoder`):
|
|
87
|
+
* it is written into a dead letter, which is stored beside the event and survives an erasure
|
|
88
|
+
* of its payload.
|
|
89
|
+
*/
|
|
90
|
+
export function domainEventOf(row) {
|
|
91
|
+
const collected = { failed: [], named: new Set() };
|
|
92
|
+
return strictly(row, domainEvent, envelopeCandidate(row, collected), collected);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The stored row → the `DrainedEvent` the Tier-2 drain ships, or a throw (`domainEventOf`'s).
|
|
96
|
+
*
|
|
97
|
+
* The WHOLE event is parsed by the published `drainedEvent` schema — the envelope and the
|
|
98
|
+
* columns lifted beside it (`operation`, `version`, `caused_by`, `invocation_id`), which the
|
|
99
|
+
* envelope does not carry. They used to be copied onto an already-validated envelope as
|
|
100
|
+
* stored, into a value merely TYPED as a `DrainedEvent` (#1641 review): a restored row with
|
|
101
|
+
* `version: ''` or a `caused_by` that is not an event id reached the lake, append-only, and
|
|
102
|
+
* was stamped as having left. Parsed here, it throws, and `readUndrainedOutbox` skips it and
|
|
103
|
+
* says so. A row the kernel wrote passes unchanged: each lifted column is written from a
|
|
104
|
+
* validated value or as NULL.
|
|
105
|
+
*/
|
|
106
|
+
export function drainedEventOf(row) {
|
|
107
|
+
const collected = { failed: [], named: new Set() };
|
|
108
|
+
return strictly(row, drainedEvent, {
|
|
109
|
+
...envelopeCandidate(row, collected),
|
|
110
|
+
operation: row.operation ?? null,
|
|
111
|
+
version: row.version ?? null,
|
|
112
|
+
// #1237 — lifted like the two above, and for the same reason: the column
|
|
113
|
+
// exists on the outbox but not on the envelope.
|
|
114
|
+
causedBy: row.caused_by ?? null,
|
|
115
|
+
// …and the invocation, for the same reason again: a lake that kept cause and
|
|
116
|
+
// dropped the call could say what set an event off and never which request did
|
|
117
|
+
// it, which is the grouping a trace is built on.
|
|
118
|
+
invocationId: row.invocation_id ?? null,
|
|
119
|
+
}, collected);
|
|
120
|
+
}
|
|
121
|
+
/** How many rows past `limit` one read may look through, as a multiple of `limit`. */
|
|
122
|
+
export const UNDRAINED_SCAN_FACTOR = 10;
|
|
123
|
+
/** How many skipped ids a read names; the count past it stays exact. */
|
|
124
|
+
export const UNDRAINED_SKIPPED_IDS = 50;
|
|
125
|
+
/**
|
|
126
|
+
* The Tier-2 drain's read over one scope's outbox (#1334), CONTAINED per row (#1636) — the
|
|
127
|
+
* one implementation both adapters run, so they cannot disagree about what is skipped.
|
|
128
|
+
*
|
|
129
|
+
* `page(offset, count)` is the adapter's
|
|
130
|
+
* `SELECT * … WHERE drained_at IS NULL ORDER BY id LIMIT count OFFSET offset`. Offset
|
|
131
|
+
* rather than an id cursor on purpose: the rows being stepped over are exactly the ones
|
|
132
|
+
* whose `id` may be the column that is broken.
|
|
133
|
+
*
|
|
134
|
+
* A row that does not decode is SKIPPED: not returned, so no sink ever receives an event
|
|
135
|
+
* built from stand-ins — the lake is append-only, and a wrong row there cannot be taken
|
|
136
|
+
* back — and not stamped, so `drained_at` stays an exact record of what left. The read
|
|
137
|
+
* keeps going past it, so the healthy rows behind it still ship. The cost is stated rather
|
|
138
|
+
* than hidden: a skipped row never reaches the lake, and every pass reads it again. It
|
|
139
|
+
* stays visible in Tier 1, where `readHistory` returns it with a `decodeError`.
|
|
140
|
+
*
|
|
141
|
+
* Bounded: at most `limit × UNDRAINED_SCAN_FACTOR` rows are looked at. A scope whose next
|
|
142
|
+
* that-many undrained rows ALL fail to decode ships nothing, pass after pass — at that
|
|
143
|
+
* point the spine is broken wholesale, which is a restore to repair rather than a row to
|
|
144
|
+
* step over, and the skipped count in the sweep report is what says so.
|
|
145
|
+
*/
|
|
146
|
+
export function readUndrainedOutbox(page, limit) {
|
|
147
|
+
const events = [];
|
|
148
|
+
const eventIds = [];
|
|
149
|
+
let count = 0;
|
|
150
|
+
let scanned = 0;
|
|
151
|
+
const ceiling = limit * UNDRAINED_SCAN_FACTOR;
|
|
152
|
+
while (events.length < limit && scanned < ceiling) {
|
|
153
|
+
const want = Math.min(limit, ceiling - scanned);
|
|
154
|
+
const rows = page(scanned, want);
|
|
155
|
+
for (const row of rows) {
|
|
156
|
+
if (events.length === limit)
|
|
157
|
+
break;
|
|
158
|
+
scanned += 1;
|
|
159
|
+
let event;
|
|
160
|
+
try {
|
|
161
|
+
event = drainedEventOf(row);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
// `drainedEventOf` is a pure decode of text already in hand — nothing in it can
|
|
165
|
+
// fail transiently, so a throw here is a fact about the row, not about this pass.
|
|
166
|
+
count += 1;
|
|
167
|
+
if (eventIds.length < UNDRAINED_SKIPPED_IDS)
|
|
168
|
+
eventIds.push(String(row.id));
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
events.push(event);
|
|
172
|
+
}
|
|
173
|
+
if (rows.length < want)
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
return count > 0 ? { events, skipped: { count, eventIds } } : { events };
|
|
177
|
+
}
|
|
178
|
+
/** An `UndrainedRead` → the in-process array shape, the skip attached only when there is one. */
|
|
179
|
+
export function undrainedEventsOf(read) {
|
|
180
|
+
const events = [...read.events];
|
|
181
|
+
if (read.skipped)
|
|
182
|
+
events.skipped = read.skipped;
|
|
183
|
+
return events;
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=outbox-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbox-event.js","sourceRoot":"","sources":["../src/outbox-event.ts"],"names":[],"m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,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK;gBAAE,MAAM;YACnC,OAAO,IAAI,CAAC,CAAC;YACb,IAAI,KAAmB,CAAC;YACxB,IAAI,CAAC;gBACH,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;YAC9B,CAAC;YAAC,MAAM,CAAC;gBACP,gFAAgF;gBAChF,kFAAkF;gBAClF,KAAK,IAAI,CAAC,CAAC;gBACX,IAAI,QAAQ,CAAC,MAAM,GAAG,qBAAqB;oBAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC3E,SAAS;YACX,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI;YAAE,MAAM;IAChC,CAAC;IACD,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;AAC3E,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,iBAAiB,CAAC,IAAmB;IACnD,MAAM,MAAM,GAAoB,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,IAAI,IAAI,CAAC,OAAO;QAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAChD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SubstratError, type Coverage, type Decision, type EntityRef, type Node, type PermissionKey, type CheckSubject, type PrincipalId } from '@substrat-run/contracts';
|
|
1
|
+
import { SubstratError, type Actor, type Coverage, type Decision, type EntityRef, type Node, type PermissionKey, type CheckSubject, type PrincipalId } from '@substrat-run/contracts';
|
|
2
2
|
/**
|
|
3
3
|
* The evaluation seam (D-16): the MODEL is kernel-owned, the evaluation engine
|
|
4
4
|
* is an adapter — the built-in default is a constrained relationship-tuple
|
|
@@ -46,6 +46,13 @@ export interface PermissionChecker {
|
|
|
46
46
|
}
|
|
47
47
|
/** Convenience for the overwhelmingly common case. */
|
|
48
48
|
export declare const asPrincipal: (id: PrincipalId) => CheckSubject;
|
|
49
|
+
/**
|
|
50
|
+
* The spine ACTOR a check subject is recorded as — on an event, a denial, a platform
|
|
51
|
+
* intent. One mapping, so the four places that record "who" cannot disagree about it: a
|
|
52
|
+
* principal is its bare id, and every subject that is not a person is the object form that
|
|
53
|
+
* says what it is instead (#97, #383, #1672).
|
|
54
|
+
*/
|
|
55
|
+
export declare const actorOf: (subject: CheckSubject) => Actor;
|
|
49
56
|
/**
|
|
50
57
|
* A refused check. The message constructor stays the public surface modules use
|
|
51
58
|
* (`throw new PermissionDenied('…')` for their own policy denials). `assertAllowed`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission-checker.d.ts","sourceRoot":"","sources":["../src/permission-checker.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,IAAI,EACT,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,KAAK,CACH,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,aAAa,EACzB,IAAI,EAAE,IAAI,EACV,MAAM,CAAC,EAAE,SAAS,GACjB,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CACJ,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,QAAQ,CAAC,CAA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AS,aAAa,EAAE,EAClC,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,QAAQ,CAAC,CAAC;CACtB;AAED,sDAAsD;AACtD,eAAO,MAAM,WAAW,OAAQ,WAAW,KAAG,YAA2C,CAAC;AAE1F;;;;;GAKG;AACH,eAAO,MAAM,OAAO,YAAa,YAAY,KAAG,KAW/C,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;IACpC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACrB,YAAY,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;QAAE,UAAU,EAAE,aAAa,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,EAS9E;CACF;AAED,sFAAsF;AACtF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAC5E,QAAQ,EACR;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAClB,CAOA;AAED,4FAA4F;AAC5F,eAAO,MAAM,cAAc,EAAE,iBAa5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,iBAgBpC,CAAC"}
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import { objectRef, SubstratError, } from '@substrat-run/contracts';
|
|
2
2
|
/** Convenience for the overwhelmingly common case. */
|
|
3
3
|
export const asPrincipal = (id) => ({ kind: 'principal', id });
|
|
4
|
+
/**
|
|
5
|
+
* The spine ACTOR a check subject is recorded as — on an event, a denial, a platform
|
|
6
|
+
* intent. One mapping, so the four places that record "who" cannot disagree about it: a
|
|
7
|
+
* principal is its bare id, and every subject that is not a person is the object form that
|
|
8
|
+
* says what it is instead (#97, #383, #1672).
|
|
9
|
+
*/
|
|
10
|
+
export const actorOf = (subject) => {
|
|
11
|
+
switch (subject.kind) {
|
|
12
|
+
case 'principal':
|
|
13
|
+
return subject.id;
|
|
14
|
+
case 'system':
|
|
15
|
+
return { system: subject.id };
|
|
16
|
+
case 'connection':
|
|
17
|
+
return { connection: subject.id };
|
|
18
|
+
case 'capability':
|
|
19
|
+
return { capability: subject.id };
|
|
20
|
+
}
|
|
21
|
+
};
|
|
4
22
|
/**
|
|
5
23
|
* A refused check. The message constructor stays the public surface modules use
|
|
6
24
|
* (`throw new PermissionDenied('…')` for their own policy denials). `assertAllowed`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission-checker.js","sourceRoot":"","sources":["../src/permission-checker.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,aAAa,
|
|
1
|
+
{"version":3,"file":"permission-checker.js","sourceRoot":"","sources":["../src/permission-checker.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,aAAa,GASd,MAAM,yBAAyB,CAAC;AAyDjC,sDAAsD;AACtD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAe,EAAgB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;AAE1F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAqB,EAAS,EAAE;IACtD,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,WAAW;YACd,OAAO,OAAO,CAAC,EAAE,CAAC;QACpB,KAAK,QAAQ;YACX,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC;QAChC,KAAK,YAAY;YACf,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC;QACpC,KAAK,YAAY;YACf,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC;IACtC,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IACxC,UAAU,CAAiB;IAC3B,IAAI,CAAQ;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;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsB;IACvD,oFAAoF;IACpF,uEAAuE;IACvE,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACpD,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAC7C,OAAO,EAAE,IAAI;QACb,KAAK,EAAE;YACL;gBACE,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,aAAa,SAAS,EAAE,CAAC;gBAClD,QAAQ,EAAE,WAAW,UAAU,EAAE;gBACjC,MAAM,EAAE,SAAS,CAAC,KAAK,CACrB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,QAAQ,EAAE,CACnE;aACF;SACF;KACF,CAAC;CACH,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Node, type RoleDefinition } from '@substrat-run/contracts';
|
|
2
2
|
import type { PermissionChecker } from './permission-checker.js';
|
|
3
|
+
import { type CapabilityRow } from './capability.js';
|
|
3
4
|
type MaybePromise<T> = T | Promise<T>;
|
|
4
5
|
/**
|
|
5
6
|
* One tuple row as the spine stores it — snake_case, because that is what both adapters
|
|
@@ -25,6 +26,13 @@ export interface ScopeTupleReader {
|
|
|
25
26
|
grant(subject: string, relation: string, object: string): MaybePromise<PermissionTupleRow | undefined>;
|
|
26
27
|
/** The declared `parent` edges out of `object`. */
|
|
27
28
|
parents(object: string): MaybePromise<PermissionTupleRow[]>;
|
|
29
|
+
/**
|
|
30
|
+
* The capability row a `{ kind: 'capability' }` subject names (#1672), read with
|
|
31
|
+
* `capabilityByIdQuery` — capabilities live in the scope's own spine beside the entities
|
|
32
|
+
* they reach. Optional so a reader written before capabilities still compiles; ABSENT
|
|
33
|
+
* means every capability check DENIES, never that one is waved through.
|
|
34
|
+
*/
|
|
35
|
+
capability?(id: string): MaybePromise<CapabilityRow | undefined>;
|
|
28
36
|
}
|
|
29
37
|
/**
|
|
30
38
|
* Everything the evaluator needs to know, and nothing about where it comes from.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission-eval.d.ts","sourceRoot":"","sources":["../src/permission-eval.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,IAAI,EAIT,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"permission-eval.d.ts","sourceRoot":"","sources":["../src/permission-eval.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,IAAI,EAIT,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAqC,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAyBxF,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEtC;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oFAAoF;IACpF,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,YAAY,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACpF,qEAAqE;IACrE,KAAK,CACH,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,YAA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