@kairos-es/read 1.0.0-alpha.0 → 1.0.0-alpha.1
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/README.md +3 -1
- package/dist/cjs/projectionWiringFault.js +21 -27
- package/dist/cjs/projectionWiringFault.js.map +1 -1
- package/dist/dts/projectionWiringFault.d.ts +1 -1
- package/dist/dts/projectionWiringFault.d.ts.map +1 -1
- package/dist/esm/projectionWiringFault.js +22 -28
- package/dist/esm/projectionWiringFault.js.map +1 -1
- package/package.json +3 -3
- package/src/projectionWiringFault.ts +23 -29
package/README.md
CHANGED
|
@@ -325,7 +325,9 @@ at all. `modelAtHead` from `@kairos-es/codec` reads the log at query time and is
|
|
|
325
325
|
consistent as of the `head` its read returned, which makes it MORE current than any
|
|
326
326
|
maintained view of the same slices — a maintained view is consistent as of a
|
|
327
327
|
checkpoint that trails that head. No table, no checkpoint, no runner, and no rung
|
|
328
|
-
of the construction gate applies to it.
|
|
328
|
+
of the construction gate applies to it. ⚠ Its error channel carries
|
|
329
|
+
`TaglessSliceInLedger`, raised when a slice built without tags would be unioned with
|
|
330
|
+
another inside a `transact` bracket — see `@kairos-es/codec`.
|
|
329
331
|
|
|
330
332
|
All three over one course's roster:
|
|
331
333
|
[`examples/course-subscriptions/src/courseRosterMaterialisations.ts`](../../examples/course-subscriptions/src/courseRosterMaterialisations.ts),
|
|
@@ -142,7 +142,7 @@ var _EventLogDurability = require("./EventLogDurability.js");
|
|
|
142
142
|
* options literal, a smaller and more local mistake than picking the wrong pair
|
|
143
143
|
* of layers.
|
|
144
144
|
* 4. **The store's own servable grammar**, once over the SHARED composed query,
|
|
145
|
-
* reported in the STORE's vocabulary by `core`'s own
|
|
145
|
+
* reported in the STORE's vocabulary by `core`'s own servable-query grammar.
|
|
146
146
|
* 5. **The read side's stricter per-slice tag rule**, once over the SHARED slice
|
|
147
147
|
* record, and it MUST stay after (4): it catches only what that grammar admits,
|
|
148
148
|
* since a lone type-only item is servable. Were it first, a tagless-plus-tagged
|
|
@@ -327,7 +327,7 @@ const tuningFault = tuning => {
|
|
|
327
327
|
* `undefined` when the store would serve it, otherwise `core`'s own sentence about
|
|
328
328
|
* why it would not.
|
|
329
329
|
*
|
|
330
|
-
* ## Why `core`'s
|
|
330
|
+
* ## Why `core`'s grammar and not a predicate of our own
|
|
331
331
|
*
|
|
332
332
|
* It is the very function every engine applies inside `read`/`subscribe`/`append`,
|
|
333
333
|
* so calling it is what makes ONE grammar rather than two that agree until one is
|
|
@@ -339,31 +339,25 @@ const tuningFault = tuning => {
|
|
|
339
339
|
* once the breaker trips on a checkpoint that never moved — several backoff sleeps
|
|
340
340
|
* later, describing a stall rather than the mis-built slice that caused it.
|
|
341
341
|
*
|
|
342
|
-
* ## Why
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
342
|
+
* ## Why core's TOTAL form is called rather than its throwing one
|
|
343
|
+
*
|
|
344
|
+
* The grammar has two dispositions and core owns both: `assertServableQuery`
|
|
345
|
+
* throws, because its own callers are store methods where a throw inside an
|
|
346
|
+
* `Effect` is already the defect it should be, and `servableQueryFault` returns the
|
|
347
|
+
* sentence, for a caller that can still act on it. Here it is one of five rules
|
|
348
|
+
* whose results compose, so a throw would give this gate two exit routes — a
|
|
349
|
+
* returned sentence for four rules and an exception for the fifth — and every
|
|
350
|
+
* caller would need both a `??` chain and a `try`. The total form keeps ONE exit
|
|
351
|
+
* route, and the caller keeps one `Effect.die`.
|
|
352
|
+
*
|
|
353
|
+
* This used to convert the throw here, with a `try`/`catch` and an `instanceof`
|
|
354
|
+
* fallback, which was a THIRD statement of a rule that must have one home — and,
|
|
355
|
+
* once core's total form existed, a private symbol of the same name and meaning
|
|
356
|
+
* sitting beside the public one. The message is core's either way, so the violation
|
|
357
|
+
* goes on being reported in the store's own vocabulary and an author who meets it
|
|
358
|
+
* twice meets it once.
|
|
358
359
|
*/
|
|
359
|
-
const
|
|
360
|
-
try {
|
|
361
|
-
(0, _core.assertServableQuery)(wiring.query);
|
|
362
|
-
return undefined;
|
|
363
|
-
} catch (error) {
|
|
364
|
-
return error instanceof Error ? error.message : String(error);
|
|
365
|
-
}
|
|
366
|
-
};
|
|
360
|
+
const servableSliceQueryFault = wiring => (0, _core.servableQueryFault)(wiring.query);
|
|
367
361
|
/**
|
|
368
362
|
* The read side's OWN per-slice rule: `undefined` when every slice carries at least
|
|
369
363
|
* one tag, otherwise the sentence naming the first slice that does not.
|
|
@@ -436,7 +430,7 @@ const perEntry = (entries, rule) => {
|
|
|
436
430
|
const projectionWiringFault = wiring => materialisationCollisionFault(wiring) ?? perEntry(wiring.materialisations, entry => (0, _EventLogDurability.durabilityOrderingFault)({
|
|
437
431
|
eventLogDurability: wiring.eventLogDurability,
|
|
438
432
|
viewDurability: entry.viewDurability
|
|
439
|
-
})) ?? perEntry(wiring.materialisations, tuningFault) ??
|
|
433
|
+
})) ?? perEntry(wiring.materialisations, tuningFault) ?? servableSliceQueryFault(wiring) ?? taglessSliceFault(wiring);
|
|
440
434
|
/**
|
|
441
435
|
* The SET-LEVEL rung: `undefined` when no two materialisations of one read model
|
|
442
436
|
* would fight over one cursor, otherwise the sentence naming the offending pair and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projectionWiringFault.js","names":["_core","require","_effect","_EventLogDurability","positiveFiniteDuration","name","input","role","decoded","Duration","decodeUnknown","Option","isNone","Either","left","String","isFinite","value","isZero","right","MIS_TUNED","tuningFault","tuning","checked","all","batchWindow","restartMinDelay","restartMaxDelay","restartResetAfter","isLeft","greaterThan","format","undefined","
|
|
1
|
+
{"version":3,"file":"projectionWiringFault.js","names":["_core","require","_effect","_EventLogDurability","positiveFiniteDuration","name","input","role","decoded","Duration","decodeUnknown","Option","isNone","Either","left","String","isFinite","value","isZero","right","MIS_TUNED","tuningFault","tuning","checked","all","batchWindow","restartMinDelay","restartMaxDelay","restartResetAfter","isLeft","greaterThan","format","undefined","servableSliceQueryFault","wiring","servableQueryFault","query","taglessSliceFault","slice","Object","entries","slices","untagged","items","length","some","item","tags","perEntry","rule","index","fault","projectionWiringFault","materialisationCollisionFault","materialisations","entry","durabilityOrderingFault","eventLogDurability","viewDurability","exports","one","other","cursorIdentity","key","projection","partition"],"sources":["../../src/projectionWiringFault.ts"],"sourcesContent":[null],"mappings":";;;;;;AA4LA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AA9LA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAMG,sBAAsB,GAAGA,CAC7BC,IAAY,EACZC,KAA6B,EAC7BC,IAAY,KACgC;EAC5C,MAAMC,OAAO,GAAGC,gBAAQ,CAACC,aAAa,CAACJ,KAAK,CAAC;EAC7C,IAAIK,cAAM,CAACC,MAAM,CAACJ,OAAO,CAAC,EAAE;IAC1B,OAAOK,cAAM,CAACC,IAAI,CAChB,GAAGT,IAAI,yCAAyCU,MAAM,CAACT,KAAK,CAAC,YAAY,GACvE,mEAAmE,GACnE,qDAAqD,CACxD;EACH;EACA,IAAI,CAACG,gBAAQ,CAACO,QAAQ,CAACR,OAAO,CAACS,KAAK,CAAC,EAAE;IACrC,OAAOJ,cAAM,CAACC,IAAI,CAAC,GAAGT,IAAI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B,CAACV,MAAM,EAAEzB,KAAK,IAAI,CAAC,EAAE;MACtE,MAAMyC,GAAG,GAAGN,gBAAgB,CAACxC,IAAI,CAAC;MAClC,MAAM+C,KAAK,GAAGP,gBAAgB,CAACnC,KAAK,CAAC;MACrC,IACEyC,GAAG,CAACE,cAAc,KAAKD,KAAK,CAACC,cAAc,IAC3CF,GAAG,CAACG,GAAG,CAACC,UAAU,KAAKH,KAAK,CAACE,GAAG,CAACC,UAAU,IAC3CJ,GAAG,CAACG,GAAG,CAACE,SAAS,KAAKJ,KAAK,CAACE,GAAG,CAACE,SAAS,EACzC;QACA,OACE,iDAAiDnD,IAAI,QAAQ,GAC7D,oBAAoBK,KAAK,6CAA6C,GACtE,6BAA6ByC,GAAG,CAACG,GAAG,CAACE,SAAS,2BAA2B,GACzE,mEAAmE,GACnE,uEAAuE,GACvE,kEAAkE,GAClE,qEAAqE,GACrE,2DAA2D,GAC3D,wEAAwE,GACxE,uEAAuE,GACvE,sEAAsE,GACtE,yEAAyE,GACzE,iEAAiE,GACjE,mEAAmE,GACnE,oBAAoB;MAExB;IACF;EACF;EACA,OAAOjC,SAAS;AAClB,CAAC","ignoreList":[]}
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
* options literal, a smaller and more local mistake than picking the wrong pair
|
|
134
134
|
* of layers.
|
|
135
135
|
* 4. **The store's own servable grammar**, once over the SHARED composed query,
|
|
136
|
-
* reported in the STORE's vocabulary by `core`'s own
|
|
136
|
+
* reported in the STORE's vocabulary by `core`'s own servable-query grammar.
|
|
137
137
|
* 5. **The read side's stricter per-slice tag rule**, once over the SHARED slice
|
|
138
138
|
* record, and it MUST stay after (4): it catches only what that grammar admits,
|
|
139
139
|
* since a lone type-only item is servable. Were it first, a tagless-plus-tagged
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projectionWiringFault.d.ts","sourceRoot":"","sources":["../../src/projectionWiringFault.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;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M,qBAAqB,GAAI,QAAQ;IAC5C,QAAQ,CAAC,kBAAkB,EAAE,UAAU,CAAA;IACvC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC,CAAA;IAC1D,QAAQ,CAAC,gBAAgB,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAA;CAChE,KAAG,MAAM,GAAG,SAUc,CAAA"}
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
* options literal, a smaller and more local mistake than picking the wrong pair
|
|
134
134
|
* of layers.
|
|
135
135
|
* 4. **The store's own servable grammar**, once over the SHARED composed query,
|
|
136
|
-
* reported in the STORE's vocabulary by `core`'s own
|
|
136
|
+
* reported in the STORE's vocabulary by `core`'s own servable-query grammar.
|
|
137
137
|
* 5. **The read side's stricter per-slice tag rule**, once over the SHARED slice
|
|
138
138
|
* record, and it MUST stay after (4): it catches only what that grammar admits,
|
|
139
139
|
* since a lone type-only item is servable. Were it first, a tagless-plus-tagged
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
* offers — a caller with a wiring to validate has `runProjection` or
|
|
187
187
|
* `runProjections` itself. BOTH judge all five rules before either forks anything.
|
|
188
188
|
*/
|
|
189
|
-
import {
|
|
189
|
+
import { servableQueryFault } from '@kairos-es/core';
|
|
190
190
|
import { Duration, Either, Option } from 'effect';
|
|
191
191
|
import { durabilityOrderingFault } from "./EventLogDurability.js";
|
|
192
192
|
/**
|
|
@@ -320,7 +320,7 @@ const tuningFault = tuning => {
|
|
|
320
320
|
* `undefined` when the store would serve it, otherwise `core`'s own sentence about
|
|
321
321
|
* why it would not.
|
|
322
322
|
*
|
|
323
|
-
* ## Why `core`'s
|
|
323
|
+
* ## Why `core`'s grammar and not a predicate of our own
|
|
324
324
|
*
|
|
325
325
|
* It is the very function every engine applies inside `read`/`subscribe`/`append`,
|
|
326
326
|
* so calling it is what makes ONE grammar rather than two that agree until one is
|
|
@@ -332,31 +332,25 @@ const tuningFault = tuning => {
|
|
|
332
332
|
* once the breaker trips on a checkpoint that never moved — several backoff sleeps
|
|
333
333
|
* later, describing a stall rather than the mis-built slice that caused it.
|
|
334
334
|
*
|
|
335
|
-
* ## Why
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
335
|
+
* ## Why core's TOTAL form is called rather than its throwing one
|
|
336
|
+
*
|
|
337
|
+
* The grammar has two dispositions and core owns both: `assertServableQuery`
|
|
338
|
+
* throws, because its own callers are store methods where a throw inside an
|
|
339
|
+
* `Effect` is already the defect it should be, and `servableQueryFault` returns the
|
|
340
|
+
* sentence, for a caller that can still act on it. Here it is one of five rules
|
|
341
|
+
* whose results compose, so a throw would give this gate two exit routes — a
|
|
342
|
+
* returned sentence for four rules and an exception for the fifth — and every
|
|
343
|
+
* caller would need both a `??` chain and a `try`. The total form keeps ONE exit
|
|
344
|
+
* route, and the caller keeps one `Effect.die`.
|
|
345
|
+
*
|
|
346
|
+
* This used to convert the throw here, with a `try`/`catch` and an `instanceof`
|
|
347
|
+
* fallback, which was a THIRD statement of a rule that must have one home — and,
|
|
348
|
+
* once core's total form existed, a private symbol of the same name and meaning
|
|
349
|
+
* sitting beside the public one. The message is core's either way, so the violation
|
|
350
|
+
* goes on being reported in the store's own vocabulary and an author who meets it
|
|
351
|
+
* twice meets it once.
|
|
351
352
|
*/
|
|
352
|
-
const
|
|
353
|
-
try {
|
|
354
|
-
assertServableQuery(wiring.query);
|
|
355
|
-
return undefined;
|
|
356
|
-
} catch (error) {
|
|
357
|
-
return error instanceof Error ? error.message : String(error);
|
|
358
|
-
}
|
|
359
|
-
};
|
|
353
|
+
const servableSliceQueryFault = wiring => servableQueryFault(wiring.query);
|
|
360
354
|
/**
|
|
361
355
|
* The read side's OWN per-slice rule: `undefined` when every slice carries at least
|
|
362
356
|
* one tag, otherwise the sentence naming the first slice that does not.
|
|
@@ -429,7 +423,7 @@ const perEntry = (entries, rule) => {
|
|
|
429
423
|
export const projectionWiringFault = wiring => materialisationCollisionFault(wiring) ?? perEntry(wiring.materialisations, entry => durabilityOrderingFault({
|
|
430
424
|
eventLogDurability: wiring.eventLogDurability,
|
|
431
425
|
viewDurability: entry.viewDurability
|
|
432
|
-
})) ?? perEntry(wiring.materialisations, tuningFault) ??
|
|
426
|
+
})) ?? perEntry(wiring.materialisations, tuningFault) ?? servableSliceQueryFault(wiring) ?? taglessSliceFault(wiring);
|
|
433
427
|
/**
|
|
434
428
|
* The SET-LEVEL rung: `undefined` when no two materialisations of one read model
|
|
435
429
|
* would fight over one cursor, otherwise the sentence naming the offending pair and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projectionWiringFault.js","names":["
|
|
1
|
+
{"version":3,"file":"projectionWiringFault.js","names":["servableQueryFault","Duration","Either","Option","durabilityOrderingFault","positiveFiniteDuration","name","input","role","decoded","decodeUnknown","isNone","left","String","isFinite","value","isZero","right","MIS_TUNED","tuningFault","tuning","checked","all","batchWindow","restartMinDelay","restartMaxDelay","restartResetAfter","isLeft","greaterThan","format","undefined","servableSliceQueryFault","wiring","query","taglessSliceFault","slice","Object","entries","slices","untagged","items","length","some","item","tags","perEntry","rule","index","fault","projectionWiringFault","materialisationCollisionFault","materialisations","entry","eventLogDurability","viewDurability","one","other","cursorIdentity","key","projection","partition"],"sources":["../../src/projectionWiringFault.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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qEAAqE,GACrE,2DAA2D,GAC3D,wEAAwE,GACxE,uEAAuE,GACvE,sEAAsE,GACtE,yEAAyE,GACzE,iEAAiE,GACjE,mEAAmE,GACnE,oBAAoB;MAExB;IACF;EACF;EACA,OAAO9B,SAAS;AAClB,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kairos-es/read",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
4
|
"description": "Query-driven projection runner and checkpoint port for kairos-es",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"repository": {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"homepage": "https://github.com/neverbland/kairos-es",
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"effect": "^3.22.0",
|
|
15
|
-
"@kairos-es/codec": "^1.0.0-alpha.
|
|
16
|
-
"@kairos-es/core": "^1.0.0-alpha.
|
|
15
|
+
"@kairos-es/codec": "^1.0.0-alpha.1",
|
|
16
|
+
"@kairos-es/core": "^1.0.0-alpha.1"
|
|
17
17
|
},
|
|
18
18
|
"main": "./dist/cjs/index.js",
|
|
19
19
|
"module": "./dist/esm/index.js",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
* options literal, a smaller and more local mistake than picking the wrong pair
|
|
134
134
|
* of layers.
|
|
135
135
|
* 4. **The store's own servable grammar**, once over the SHARED composed query,
|
|
136
|
-
* reported in the STORE's vocabulary by `core`'s own
|
|
136
|
+
* reported in the STORE's vocabulary by `core`'s own servable-query grammar.
|
|
137
137
|
* 5. **The read side's stricter per-slice tag rule**, once over the SHARED slice
|
|
138
138
|
* record, and it MUST stay after (4): it catches only what that grammar admits,
|
|
139
139
|
* since a lone type-only item is servable. Were it first, a tagless-plus-tagged
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
* offers — a caller with a wiring to validate has `runProjection` or
|
|
187
187
|
* `runProjections` itself. BOTH judge all five rules before either forks anything.
|
|
188
188
|
*/
|
|
189
|
-
import {
|
|
189
|
+
import { type Query, servableQueryFault } from '@kairos-es/core'
|
|
190
190
|
import { Duration, Either, Option } from 'effect'
|
|
191
191
|
import { durabilityOrderingFault } from './EventLogDurability'
|
|
192
192
|
import type { CheckpointKey, Durability } from './ProjectionStore'
|
|
@@ -388,7 +388,7 @@ const tuningFault = (tuning: {
|
|
|
388
388
|
* `undefined` when the store would serve it, otherwise `core`'s own sentence about
|
|
389
389
|
* why it would not.
|
|
390
390
|
*
|
|
391
|
-
* ## Why `core`'s
|
|
391
|
+
* ## Why `core`'s grammar and not a predicate of our own
|
|
392
392
|
*
|
|
393
393
|
* It is the very function every engine applies inside `read`/`subscribe`/`append`,
|
|
394
394
|
* so calling it is what makes ONE grammar rather than two that agree until one is
|
|
@@ -400,33 +400,27 @@ const tuningFault = (tuning: {
|
|
|
400
400
|
* once the breaker trips on a checkpoint that never moved — several backoff sleeps
|
|
401
401
|
* later, describing a stall rather than the mis-built slice that caused it.
|
|
402
402
|
*
|
|
403
|
-
* ## Why
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
*
|
|
403
|
+
* ## Why core's TOTAL form is called rather than its throwing one
|
|
404
|
+
*
|
|
405
|
+
* The grammar has two dispositions and core owns both: `assertServableQuery`
|
|
406
|
+
* throws, because its own callers are store methods where a throw inside an
|
|
407
|
+
* `Effect` is already the defect it should be, and `servableQueryFault` returns the
|
|
408
|
+
* sentence, for a caller that can still act on it. Here it is one of five rules
|
|
409
|
+
* whose results compose, so a throw would give this gate two exit routes — a
|
|
410
|
+
* returned sentence for four rules and an exception for the fifth — and every
|
|
411
|
+
* caller would need both a `??` chain and a `try`. The total form keeps ONE exit
|
|
412
|
+
* route, and the caller keeps one `Effect.die`.
|
|
413
|
+
*
|
|
414
|
+
* This used to convert the throw here, with a `try`/`catch` and an `instanceof`
|
|
415
|
+
* fallback, which was a THIRD statement of a rule that must have one home — and,
|
|
416
|
+
* once core's total form existed, a private symbol of the same name and meaning
|
|
417
|
+
* sitting beside the public one. The message is core's either way, so the violation
|
|
418
|
+
* goes on being reported in the store's own vocabulary and an author who meets it
|
|
419
|
+
* twice meets it once.
|
|
419
420
|
*/
|
|
420
|
-
const
|
|
421
|
+
const servableSliceQueryFault = (wiring: {
|
|
421
422
|
readonly query: Query
|
|
422
|
-
}): string | undefined =>
|
|
423
|
-
try {
|
|
424
|
-
assertServableQuery(wiring.query)
|
|
425
|
-
return undefined
|
|
426
|
-
} catch (error) {
|
|
427
|
-
return error instanceof Error ? error.message : String(error)
|
|
428
|
-
}
|
|
429
|
-
}
|
|
423
|
+
}): string | undefined => servableQueryFault(wiring.query)
|
|
430
424
|
|
|
431
425
|
/**
|
|
432
426
|
* The read side's OWN per-slice rule: `undefined` when every slice carries at least
|
|
@@ -575,7 +569,7 @@ export const projectionWiringFault = (wiring: {
|
|
|
575
569
|
}),
|
|
576
570
|
) ??
|
|
577
571
|
perEntry(wiring.materialisations, tuningFault) ??
|
|
578
|
-
|
|
572
|
+
servableSliceQueryFault(wiring) ??
|
|
579
573
|
taglessSliceFault(wiring)
|
|
580
574
|
|
|
581
575
|
/**
|