@optimystic/db-core 1.19.0 → 1.20.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/src/cluster/structs.d.ts +41 -8
- package/dist/src/cluster/structs.d.ts.map +1 -1
- package/dist/src/cluster/structs.js +18 -7
- package/dist/src/cluster/structs.js.map +1 -1
- package/dist/src/collection/action.d.ts +29 -0
- package/dist/src/collection/action.d.ts.map +1 -1
- package/dist/src/collection/action.js +6 -0
- package/dist/src/collection/action.js.map +1 -1
- package/dist/src/collection/collection.d.ts +533 -120
- package/dist/src/collection/collection.d.ts.map +1 -1
- package/dist/src/collection/collection.js +974 -500
- package/dist/src/collection/collection.js.map +1 -1
- package/dist/src/collection/head-commit.d.ts +110 -0
- package/dist/src/collection/head-commit.d.ts.map +1 -0
- package/dist/src/collection/head-commit.js +65 -0
- package/dist/src/collection/head-commit.js.map +1 -0
- package/dist/src/collection/index.d.ts +2 -0
- package/dist/src/collection/index.d.ts.map +1 -1
- package/dist/src/collection/index.js +2 -0
- package/dist/src/collection/index.js.map +1 -1
- package/dist/src/collection/segments.d.ts +77 -0
- package/dist/src/collection/segments.d.ts.map +1 -0
- package/dist/src/collection/segments.js +110 -0
- package/dist/src/collection/segments.js.map +1 -0
- package/dist/src/collection/struct.d.ts +156 -1
- package/dist/src/collection/struct.d.ts.map +1 -1
- package/dist/src/collection/struct.js +70 -0
- package/dist/src/collection/struct.js.map +1 -1
- package/dist/src/collection/write-attempts.d.ts +245 -0
- package/dist/src/collection/write-attempts.d.ts.map +1 -0
- package/dist/src/collection/write-attempts.js +439 -0
- package/dist/src/collection/write-attempts.js.map +1 -0
- package/dist/src/collections/tree/struct.d.ts +100 -17
- package/dist/src/collections/tree/struct.d.ts.map +1 -1
- package/dist/src/collections/tree/struct.js +38 -7
- package/dist/src/collections/tree/struct.js.map +1 -1
- package/dist/src/collections/tree/tree.d.ts +17 -5
- package/dist/src/collections/tree/tree.d.ts.map +1 -1
- package/dist/src/collections/tree/tree.js +112 -26
- package/dist/src/collections/tree/tree.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/network/i-repo.d.ts +3 -0
- package/dist/src/network/i-repo.d.ts.map +1 -1
- package/dist/src/network/index.d.ts +3 -0
- package/dist/src/network/index.d.ts.map +1 -1
- package/dist/src/network/index.js +3 -0
- package/dist/src/network/index.js.map +1 -1
- package/dist/src/network/promise-shortfall-error.d.ts +40 -0
- package/dist/src/network/promise-shortfall-error.d.ts.map +1 -0
- package/dist/src/network/promise-shortfall-error.js +67 -0
- package/dist/src/network/promise-shortfall-error.js.map +1 -0
- package/dist/src/network/refuse-solo.d.ts +8 -0
- package/dist/src/network/refuse-solo.d.ts.map +1 -0
- package/dist/src/network/refuse-solo.js +8 -0
- package/dist/src/network/refuse-solo.js.map +1 -0
- package/dist/src/network/stale-failure.d.ts +20 -3
- package/dist/src/network/stale-failure.d.ts.map +1 -1
- package/dist/src/network/stale-failure.js +24 -3
- package/dist/src/network/stale-failure.js.map +1 -1
- package/dist/src/network/struct.d.ts +148 -2
- package/dist/src/network/struct.d.ts.map +1 -1
- package/dist/src/network/struct.js.map +1 -1
- package/dist/src/network/validity-rejected-error.d.ts +28 -0
- package/dist/src/network/validity-rejected-error.d.ts.map +1 -0
- package/dist/src/network/validity-rejected-error.js +51 -0
- package/dist/src/network/validity-rejected-error.js.map +1 -0
- package/dist/src/offline/entry.d.ts +72 -0
- package/dist/src/offline/entry.d.ts.map +1 -0
- package/dist/src/offline/entry.js +73 -0
- package/dist/src/offline/entry.js.map +1 -0
- package/dist/src/offline/index.d.ts +5 -0
- package/dist/src/offline/index.d.ts.map +1 -0
- package/dist/src/offline/index.js +5 -0
- package/dist/src/offline/index.js.map +1 -0
- package/dist/src/offline/journal.d.ts +61 -0
- package/dist/src/offline/journal.d.ts.map +1 -0
- package/dist/src/offline/journal.js +2 -0
- package/dist/src/offline/journal.js.map +1 -0
- package/dist/src/offline/queue.d.ts +484 -0
- package/dist/src/offline/queue.d.ts.map +1 -0
- package/dist/src/offline/queue.js +1236 -0
- package/dist/src/offline/queue.js.map +1 -0
- package/dist/src/offline/reachability.d.ts +25 -0
- package/dist/src/offline/reachability.d.ts.map +1 -0
- package/dist/src/offline/reachability.js +13 -0
- package/dist/src/offline/reachability.js.map +1 -0
- package/dist/src/offline/status.d.ts +148 -0
- package/dist/src/offline/status.d.ts.map +1 -0
- package/dist/src/offline/status.js +63 -0
- package/dist/src/offline/status.js.map +1 -0
- package/dist/src/offline/wake.d.ts +30 -0
- package/dist/src/offline/wake.d.ts.map +1 -0
- package/dist/src/offline/wake.js +68 -0
- package/dist/src/offline/wake.js.map +1 -0
- package/dist/src/testing/test-transactor.d.ts +29 -0
- package/dist/src/testing/test-transactor.d.ts.map +1 -1
- package/dist/src/testing/test-transactor.js +50 -0
- package/dist/src/testing/test-transactor.js.map +1 -1
- package/dist/src/transaction/commit-failure-class.d.ts +103 -0
- package/dist/src/transaction/commit-failure-class.d.ts.map +1 -0
- package/dist/src/transaction/commit-failure-class.js +96 -0
- package/dist/src/transaction/commit-failure-class.js.map +1 -0
- package/dist/src/transaction/coordinator.d.ts +165 -41
- package/dist/src/transaction/coordinator.d.ts.map +1 -1
- package/dist/src/transaction/coordinator.js +605 -300
- package/dist/src/transaction/coordinator.js.map +1 -1
- package/dist/src/transaction/entry-commit.d.ts +139 -0
- package/dist/src/transaction/entry-commit.d.ts.map +1 -0
- package/dist/src/transaction/entry-commit.js +199 -0
- package/dist/src/transaction/entry-commit.js.map +1 -0
- package/dist/src/transaction/index.d.ts +4 -1
- package/dist/src/transaction/index.d.ts.map +1 -1
- package/dist/src/transaction/index.js +1 -0
- package/dist/src/transaction/index.js.map +1 -1
- package/dist/src/transaction/transaction.d.ts +20 -0
- package/dist/src/transaction/transaction.d.ts.map +1 -1
- package/dist/src/transaction/validator.d.ts +7 -0
- package/dist/src/transaction/validator.d.ts.map +1 -1
- package/dist/src/transaction/validator.js +21 -12
- package/dist/src/transaction/validator.js.map +1 -1
- package/dist/src/transactor/network-transactor.d.ts +1 -0
- package/dist/src/transactor/network-transactor.d.ts.map +1 -1
- package/dist/src/transactor/network-transactor.js +61 -28
- package/dist/src/transactor/network-transactor.js.map +1 -1
- package/dist/src/transactor/transactor-source.d.ts +22 -11
- package/dist/src/transactor/transactor-source.d.ts.map +1 -1
- package/dist/src/transactor/transactor-source.js +9 -13
- package/dist/src/transactor/transactor-source.js.map +1 -1
- package/dist/src/utility/visit-every.d.ts +14 -0
- package/dist/src/utility/visit-every.d.ts.map +1 -0
- package/dist/src/utility/visit-every.js +27 -0
- package/dist/src/utility/visit-every.js.map +1 -0
- package/package.json +1 -1
- package/src/cluster/structs.ts +42 -7
- package/src/collection/action.ts +34 -0
- package/src/collection/collection.ts +1048 -543
- package/src/collection/head-commit.ts +148 -0
- package/src/collection/index.ts +2 -0
- package/src/collection/segments.ts +149 -0
- package/src/collection/struct.ts +183 -1
- package/src/collection/write-attempts.ts +506 -0
- package/src/collections/tree/struct.ts +97 -17
- package/src/collections/tree/tree.ts +125 -29
- package/src/index.ts +2 -0
- package/src/network/i-repo.ts +3 -0
- package/src/network/index.ts +3 -0
- package/src/network/promise-shortfall-error.ts +69 -0
- package/src/network/refuse-solo.ts +7 -0
- package/src/network/stale-failure.ts +27 -4
- package/src/network/struct.ts +154 -2
- package/src/network/validity-rejected-error.ts +55 -0
- package/src/offline/entry.ts +127 -0
- package/src/offline/index.ts +4 -0
- package/src/offline/journal.ts +60 -0
- package/src/offline/queue.ts +1342 -0
- package/src/offline/reachability.ts +32 -0
- package/src/offline/status.ts +183 -0
- package/src/offline/wake.ts +67 -0
- package/src/testing/test-transactor.ts +53 -0
- package/src/transaction/commit-failure-class.ts +133 -0
- package/src/transaction/coordinator.ts +696 -349
- package/src/transaction/entry-commit.ts +285 -0
- package/src/transaction/index.ts +4 -0
- package/src/transaction/transaction.ts +21 -0
- package/src/transaction/validator.ts +22 -12
- package/src/transactor/network-transactor.ts +62 -28
- package/src/transactor/transactor-source.ts +29 -13
- package/src/utility/visit-every.ts +25 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pend the cohort could not accept because too few of its members answered the promise round: the
|
|
3
|
+
* approvals fell short of the bar with no member refusing the write as a lost race or a held block,
|
|
4
|
+
* and too few rejecting it for a rejection. Nobody judged the write; the cohort was not all there.
|
|
5
|
+
* Not retryable by a write path — every coordinator of the cohort meets the same silent members, so a
|
|
6
|
+
* re-read and re-pend fails the same way until they answer again. Nothing was saved: the members that
|
|
7
|
+
* approved release their reservation when the writer cancels.
|
|
8
|
+
*
|
|
9
|
+
* ONE class for every place it is raised, as `TransactionExpiredError` is. The cluster coordinator
|
|
10
|
+
* (db-p2p `ClusterCoordinator`) raises it; the coordinating repo returns its facts as a
|
|
11
|
+
* {@link ShortfallFailure} ({@link toFailure}), which is what lets a remote writer receive them at
|
|
12
|
+
* all; and each write path (`Collection.sync`, `TransactionCoordinator.commit`) raises it again from
|
|
13
|
+
* that refusal.
|
|
14
|
+
*
|
|
15
|
+
* The message is the sentence the coordinator has always thrown, byte for byte: a downstream
|
|
16
|
+
* repository matches it to retry a silent cohort (backlog
|
|
17
|
+
* `debt-a-downstream-repo-classifies-retries-by-parsing-our-error-text`). Test for this class, or for
|
|
18
|
+
* the refusal with `isShortfallFailure`, rather than for the text.
|
|
19
|
+
*/
|
|
20
|
+
export class PromiseShortfallError extends Error {
|
|
21
|
+
/** Approve votes the round received. */
|
|
22
|
+
approvals;
|
|
23
|
+
/** Reject votes the round received — fewer than would make the round a rejection. */
|
|
24
|
+
rejections;
|
|
25
|
+
/** How many members the cohort the round ran on has. */
|
|
26
|
+
peerCount;
|
|
27
|
+
/** The approvals the round needed. */
|
|
28
|
+
needed;
|
|
29
|
+
/** Peer-id strings of the cohort members that cast no promise vote at all. */
|
|
30
|
+
silentPeers;
|
|
31
|
+
/** Why a lone coordinator refused to write alone, when that is what this shortfall is
|
|
32
|
+
* ({@link PromiseShortfall.soloRefused}); absent when a consensus round fell short. */
|
|
33
|
+
soloRefused;
|
|
34
|
+
constructor(shortfall) {
|
|
35
|
+
// NOTE: `shortfall` off the wire is trusted as shaped (`isShortfallFailure` checks only presence),
|
|
36
|
+
// so a malformed coordinator answer throws a TypeError here (no `silentPeers` array) instead of
|
|
37
|
+
// this error. Either still ends the write; if hostile coordinators become a concern, validate the
|
|
38
|
+
// shape where the refusal is received, as for `TransactionExpiredError`.
|
|
39
|
+
super(`Failed to get super-majority: ${shortfall.approvals}/${shortfall.peerCount} approvals (needed ${shortfall.needed}, ${shortfall.rejections} rejections)`);
|
|
40
|
+
this.name = 'PromiseShortfallError';
|
|
41
|
+
this.approvals = shortfall.approvals;
|
|
42
|
+
this.rejections = shortfall.rejections;
|
|
43
|
+
this.peerCount = shortfall.peerCount;
|
|
44
|
+
this.needed = shortfall.needed;
|
|
45
|
+
this.silentPeers = [...shortfall.silentPeers];
|
|
46
|
+
if (shortfall.soloRefused !== undefined)
|
|
47
|
+
this.soloRefused = shortfall.soloRefused;
|
|
48
|
+
}
|
|
49
|
+
/** The refusal a coordinating repo returns for this error, so it crosses the repo protocol as an
|
|
50
|
+
* answer rather than as a reset stream. */
|
|
51
|
+
toFailure() {
|
|
52
|
+
return {
|
|
53
|
+
success: false,
|
|
54
|
+
conflict: false,
|
|
55
|
+
reason: this.message,
|
|
56
|
+
shortfall: {
|
|
57
|
+
approvals: this.approvals,
|
|
58
|
+
rejections: this.rejections,
|
|
59
|
+
peerCount: this.peerCount,
|
|
60
|
+
needed: this.needed,
|
|
61
|
+
silentPeers: [...this.silentPeers],
|
|
62
|
+
...(this.soloRefused === undefined ? {} : { soloRefused: this.soloRefused }),
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=promise-shortfall-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-shortfall-error.js","sourceRoot":"","sources":["../../../src/network/promise-shortfall-error.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC/C,wCAAwC;IAC/B,SAAS,CAAS;IAC3B,qFAAqF;IAC5E,UAAU,CAAS;IAC5B,wDAAwD;IAC/C,SAAS,CAAS;IAC3B,sCAAsC;IAC7B,MAAM,CAAS;IACxB,8EAA8E;IACrE,WAAW,CAAoB;IACxC;2FACuF;IAC9E,WAAW,CAAqB;IAEzC,YAAY,SAA2B;QACtC,mGAAmG;QACnG,gGAAgG;QAChG,kGAAkG;QAClG,yEAAyE;QACzE,KAAK,CAAC,iCAAiC,SAAS,CAAC,SAAS,IAAI,SAAS,CAAC,SAAS,sBAAsB,SAAS,CAAC,MAAM,KAAK,SAAS,CAAC,UAAU,cAAc,CAAC,CAAC;QAChK,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,CAAC,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;QAC9C,IAAI,SAAS,CAAC,WAAW,KAAK,SAAS;YAAE,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;IACnF,CAAC;IAED;gDAC4C;IAC5C,SAAS;QACR,OAAO;YACN,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,SAAS,EAAE;gBACV,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;gBAClC,GAAG,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;aAC5E;SACD,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Wraps `PendRequest.refuseSolo` and `CommitRequest.refuseSolo` so the field spreads onto a request
|
|
2
|
+
* only when the write refuses to be committed alone. A write that does not is omitted rather than
|
|
3
|
+
* sent as `false`: the request is hashed verbatim into every cohort signature preimage, so it must
|
|
4
|
+
* serialize exactly as it did before the field existed. Every producer of the field goes through here. */
|
|
5
|
+
export declare function refuseSoloField(refuse: boolean | undefined): {
|
|
6
|
+
refuseSolo?: true;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=refuse-solo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refuse-solo.d.ts","sourceRoot":"","sources":["../../../src/network/refuse-solo.ts"],"names":[],"mappings":"AAAA;;;0GAG0G;AAC1G,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG;IAAE,UAAU,CAAC,EAAE,IAAI,CAAA;CAAE,CAElF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Wraps `PendRequest.refuseSolo` and `CommitRequest.refuseSolo` so the field spreads onto a request
|
|
2
|
+
* only when the write refuses to be committed alone. A write that does not is omitted rather than
|
|
3
|
+
* sent as `false`: the request is hashed verbatim into every cohort signature preimage, so it must
|
|
4
|
+
* serialize exactly as it did before the field existed. Every producer of the field goes through here. */
|
|
5
|
+
export function refuseSoloField(refuse) {
|
|
6
|
+
return refuse === true ? { refuseSolo: true } : {};
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=refuse-solo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refuse-solo.js","sourceRoot":"","sources":["../../../src/network/refuse-solo.ts"],"names":[],"mappings":"AAAA;;;0GAG0G;AAC1G,MAAM,UAAU,eAAe,CAAC,MAA2B;IAC1D,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { ActionId, ActionRev } from "../collection/action.js";
|
|
2
|
-
import type { ExpiredFailure, StaleFailure, WriteFailure } from "./struct.js";
|
|
2
|
+
import type { ExpiredFailure, RejectedFailure, ShortfallFailure, StaleFailure, WriteFailure } from "./struct.js";
|
|
3
3
|
/**
|
|
4
4
|
* The single rule for "is this non-success retryable after a re-read?" Both write paths and the
|
|
5
5
|
* transactor's aggregation call this — no consumer re-derives it.
|
|
6
6
|
*
|
|
7
7
|
* {@link StaleFailure.conflict} is authoritative when present. The `missing`/`pending` fallback
|
|
8
8
|
* covers producers that have not been taught the field, including a remote peer on an older build
|
|
9
|
-
* (the repo protocol is plain JSON, so an unset field simply arrives absent). An expiry
|
|
10
|
-
*
|
|
9
|
+
* (the repo protocol is plain JSON, so an unset field simply arrives absent). An expiry
|
|
10
|
+
* ({@link isExpiryFailure}), a promise shortfall ({@link isShortfallFailure}) and a validity
|
|
11
|
+
* rejection ({@link isRejectedFailure}) are never a conflict, whatever else arrived beside them.
|
|
11
12
|
*/
|
|
12
13
|
export declare function isConflictFailure(failure: WriteFailure): boolean;
|
|
13
14
|
/**
|
|
@@ -18,6 +19,22 @@ export declare function isConflictFailure(failure: WriteFailure): boolean;
|
|
|
18
19
|
* reads as the shape it always had.
|
|
19
20
|
*/
|
|
20
21
|
export declare function isExpiryFailure(failure: WriteFailure): failure is ExpiredFailure;
|
|
22
|
+
/**
|
|
23
|
+
* The single rule for "did the cohort refuse this pend because too few of its members answered the
|
|
24
|
+
* promise round?" ({@link ShortfallFailure}). Every write path stops on it rather than retrying, since
|
|
25
|
+
* every coordinator of the cohort meets the same silent members. Decided by the structured field,
|
|
26
|
+
* never the reason text; a coordinator on a build that predates the field throws the shortfall
|
|
27
|
+
* instead of returning it, which a writer sees as it always did.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isShortfallFailure(failure: WriteFailure): failure is ShortfallFailure;
|
|
30
|
+
/**
|
|
31
|
+
* The single rule for "did the cohort refuse this pend because the members that sank it judged the
|
|
32
|
+
* transaction invalid?" ({@link RejectedFailure}). Every write path stops on it rather than retrying,
|
|
33
|
+
* since re-sending the same content to the same checks is refused the same way. Decided by the
|
|
34
|
+
* structured field, never the reason text; a coordinator on a build that predates the field throws the
|
|
35
|
+
* rejection instead of returning it, which a writer sees as it always did.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isRejectedFailure(failure: WriteFailure): failure is RejectedFailure;
|
|
21
38
|
/**
|
|
22
39
|
* The single rule for picking one {@link StaleFailure.staleAt} out of several candidates.
|
|
23
40
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stale-failure.d.ts","sourceRoot":"","sources":["../../../src/network/stale-failure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"stale-failure.d.ts","sourceRoot":"","sources":["../../../src/network/stale-failure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEjH;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAGhE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,IAAI,cAAc,CAEhF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,IAAI,gBAAgB,CAErF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,IAAI,eAAe,CAEnF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,SAAS,YAAY,CAAC,SAAS,CAAC,EAAE,GAAG,YAAY,CAAC,SAAS,CAAC,CAQtG;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAEjH"}
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
*
|
|
5
5
|
* {@link StaleFailure.conflict} is authoritative when present. The `missing`/`pending` fallback
|
|
6
6
|
* covers producers that have not been taught the field, including a remote peer on an older build
|
|
7
|
-
* (the repo protocol is plain JSON, so an unset field simply arrives absent). An expiry
|
|
8
|
-
*
|
|
7
|
+
* (the repo protocol is plain JSON, so an unset field simply arrives absent). An expiry
|
|
8
|
+
* ({@link isExpiryFailure}), a promise shortfall ({@link isShortfallFailure}) and a validity
|
|
9
|
+
* rejection ({@link isRejectedFailure}) are never a conflict, whatever else arrived beside them.
|
|
9
10
|
*/
|
|
10
11
|
export function isConflictFailure(failure) {
|
|
11
|
-
if (isExpiryFailure(failure))
|
|
12
|
+
if (isExpiryFailure(failure) || isShortfallFailure(failure) || isRejectedFailure(failure))
|
|
12
13
|
return false;
|
|
13
14
|
return failure.conflict ?? Boolean(failure.missing?.length || failure.pending?.length);
|
|
14
15
|
}
|
|
@@ -22,6 +23,26 @@ export function isConflictFailure(failure) {
|
|
|
22
23
|
export function isExpiryFailure(failure) {
|
|
23
24
|
return failure.expired !== undefined;
|
|
24
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The single rule for "did the cohort refuse this pend because too few of its members answered the
|
|
28
|
+
* promise round?" ({@link ShortfallFailure}). Every write path stops on it rather than retrying, since
|
|
29
|
+
* every coordinator of the cohort meets the same silent members. Decided by the structured field,
|
|
30
|
+
* never the reason text; a coordinator on a build that predates the field throws the shortfall
|
|
31
|
+
* instead of returning it, which a writer sees as it always did.
|
|
32
|
+
*/
|
|
33
|
+
export function isShortfallFailure(failure) {
|
|
34
|
+
return failure.shortfall !== undefined;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The single rule for "did the cohort refuse this pend because the members that sank it judged the
|
|
38
|
+
* transaction invalid?" ({@link RejectedFailure}). Every write path stops on it rather than retrying,
|
|
39
|
+
* since re-sending the same content to the same checks is refused the same way. Decided by the
|
|
40
|
+
* structured field, never the reason text; a coordinator on a build that predates the field throws the
|
|
41
|
+
* rejection instead of returning it, which a writer sees as it always did.
|
|
42
|
+
*/
|
|
43
|
+
export function isRejectedFailure(failure) {
|
|
44
|
+
return failure.rejected !== undefined;
|
|
45
|
+
}
|
|
25
46
|
/**
|
|
26
47
|
* The single rule for picking one {@link StaleFailure.staleAt} out of several candidates.
|
|
27
48
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stale-failure.js","sourceRoot":"","sources":["../../../src/network/stale-failure.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"stale-failure.js","sourceRoot":"","sources":["../../../src/network/stale-failure.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAqB;IACtD,IAAI,eAAe,CAAC,OAAO,CAAC,IAAI,kB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Id, IBlock, ActionId, Transform, Transforms } from "../index.js";
|
|
2
2
|
import type { ActionContext, ActionRev } from "../collection/action.js";
|
|
3
|
-
import type { Transaction } from "../transaction/transaction.js";
|
|
3
|
+
import type { Transaction, ValidityRejection } from "../transaction/transaction.js";
|
|
4
4
|
import type { DisputeResolutionProof } from "../log/struct.js";
|
|
5
5
|
import type { PeerId } from "./types.js";
|
|
6
6
|
export type ActionBlocks = {
|
|
@@ -99,6 +99,25 @@ export type PendRequest = ActionTransforms & {
|
|
|
99
99
|
* an older build ignores it, and then delivers at once as it always did.
|
|
100
100
|
*/
|
|
101
101
|
soleReservation?: true;
|
|
102
|
+
/**
|
|
103
|
+
* The writer's word that this write must not be committed by a lone node that knows it is not
|
|
104
|
+
* alone (`SyncOptions.refuseSoloCommit`). A coordinator whose cohort for the write is only itself
|
|
105
|
+
* refuses the pend — before reserving anything — when it knows of cohort members it could not
|
|
106
|
+
* place in the cohort, is still waiting to hear from a configured bootstrap peer, or could not
|
|
107
|
+
* route the write to itself, answering with a {@link ShortfallFailure} whose
|
|
108
|
+
* {@link PromiseShortfall.soloRefused} names which (`CoordinatorRepo.pendSolo` in db-p2p). A
|
|
109
|
+
* coordinator that is genuinely alone ignores it and pends as it always did, and so does every
|
|
110
|
+
* coordinator whose cohort has more than one member.
|
|
111
|
+
*
|
|
112
|
+
* Carried by every send of the write's attempt cycle, the re-send a refresh makes to finish a torn
|
|
113
|
+
* attempt included (`Collection.completeOwnEntry`). Every per-coordinator rebuild of the request
|
|
114
|
+
* keeps it (`pendRequestForBatch` in `NetworkTransactor`), since a batch that dropped it would
|
|
115
|
+
* lose the protection for that coordinator's share. Omitted rather than `false`, for the same
|
|
116
|
+
* preimage reason as {@link baseRevs}: a write that does not set it serializes exactly as before.
|
|
117
|
+
* A coordinator on an older build ignores it and commits alone at `local`; in a group of mixed
|
|
118
|
+
* versions the offline queue's reachability gate is then the only protection.
|
|
119
|
+
*/
|
|
120
|
+
refuseSolo?: true;
|
|
102
121
|
};
|
|
103
122
|
export type BlockActionStatus = ActionBlocks & {
|
|
104
123
|
statuses: ('pending' | 'committed' | 'checkpointed' | 'aborted' | 'committed-invalidated')[];
|
|
@@ -221,6 +240,12 @@ export type StaleFailure = {
|
|
|
221
240
|
};
|
|
222
241
|
/** Never set on a lost race — an expiry is its own failure shape, {@link ExpiredFailure}. */
|
|
223
242
|
expired?: never;
|
|
243
|
+
/** Never set on a lost race — a cohort too few of whose members answered is its own failure
|
|
244
|
+
* shape, {@link ShortfallFailure}. */
|
|
245
|
+
shortfall?: never;
|
|
246
|
+
/** Never set on a lost race — a write judged invalid is its own failure shape,
|
|
247
|
+
* {@link RejectedFailure}. */
|
|
248
|
+
rejected?: never;
|
|
224
249
|
};
|
|
225
250
|
/**
|
|
226
251
|
* Why a cohort refused a write as expired: by each refusing member's own clock, the transaction's
|
|
@@ -255,9 +280,117 @@ export type ExpiredFailure = {
|
|
|
255
280
|
missing?: never;
|
|
256
281
|
pending?: never;
|
|
257
282
|
staleAt?: never;
|
|
283
|
+
shortfall?: never;
|
|
284
|
+
rejected?: never;
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Why a cohort's promise round fell short with no member refusing it as a lost race or a held block,
|
|
288
|
+
* and too few rejecting it for a rejection: too few members answered. Plain data, so it crosses the
|
|
289
|
+
* JSON repo protocol intact. `PromiseShortfallError` is built from it, wherever it is raised.
|
|
290
|
+
*/
|
|
291
|
+
export type PromiseShortfall = {
|
|
292
|
+
/** Approve votes the round received. */
|
|
293
|
+
approvals: number;
|
|
294
|
+
/** Reject votes the round received — fewer than would make the round a rejection. */
|
|
295
|
+
rejections: number;
|
|
296
|
+
/** How many members the cohort the round ran on has. */
|
|
297
|
+
peerCount: number;
|
|
298
|
+
/** The approvals the round needed: `ceil(peerCount × superMajorityThreshold)`. */
|
|
299
|
+
needed: number;
|
|
300
|
+
/** Peer-id strings of the cohort members that cast no promise vote at all. */
|
|
301
|
+
silentPeers: string[];
|
|
302
|
+
/**
|
|
303
|
+
* Set only when no consensus round ran: a coordinator whose cohort for the write was only itself
|
|
304
|
+
* refused to write alone, because the write asked it to (`PendRequest.refuseSolo`). The other
|
|
305
|
+
* fields then describe the cohort the coordinator expected rather than one it asked: one approval
|
|
306
|
+
* (its own), no rejections, the members it knows of and could not reach as `silentPeers`, and the
|
|
307
|
+
* bar a cohort of that size would set. Absent on a shortfall a consensus round produced, so a log
|
|
308
|
+
* or an application can tell "refused to write alone" from "a round heard too few".
|
|
309
|
+
*/
|
|
310
|
+
soloRefused?: SoloRefusalReason;
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* Why a lone coordinator refused a write that asked not to be committed alone
|
|
314
|
+
* (`PendRequest.refuseSolo`, `CommitRequest.refuseSolo`):
|
|
315
|
+
* - `absent-members`: its cohort for the write was only itself, and it knows of cohort members it
|
|
316
|
+
* could not place in that cohort (`IKeyNetwork.absentCohortMembers`);
|
|
317
|
+
* - `awaiting-bootstrap`: its cohort was only itself and it is still waiting to hear from a peer it
|
|
318
|
+
* was configured to join through (`IKeyNetwork.awaitingBootstrapContact`);
|
|
319
|
+
* - `unrouted`: the cohort lookup failed, named nobody, or named one peer that is not this node.
|
|
320
|
+
*/
|
|
321
|
+
export type SoloRefusalReason = 'absent-members' | 'awaiting-bootstrap' | 'unrouted';
|
|
322
|
+
/**
|
|
323
|
+
* The cohort refused the pend because too few of its members ANSWERED the promise round for it to
|
|
324
|
+
* reach its bar — silence, not a judgement of the write and not a lost race. Not retryable by a write
|
|
325
|
+
* path: every coordinator of that cohort meets the same silent members, so a re-read and re-pend fails
|
|
326
|
+
* the same way until they come back. A sibling of {@link StaleFailure} and {@link ExpiredFailure},
|
|
327
|
+
* with the fields it can never carry typed `never`, so a consumer reads `reason`, `missing` or
|
|
328
|
+
* `staleAt` off any of them unnarrowed. Tell it apart with `isShortfallFailure`, never by reading
|
|
329
|
+
* `reason`. A pend answer only: a commit that falls short is still thrown (see
|
|
330
|
+
* `CoordinatorRepo.commit`).
|
|
331
|
+
*/
|
|
332
|
+
export type ShortfallFailure = {
|
|
333
|
+
success: false;
|
|
334
|
+
/** The coordinator's description of the refusal, for a log line. Never branch on it. */
|
|
335
|
+
reason?: string;
|
|
336
|
+
/** Always false: silence is not a conflict a re-read can win. */
|
|
337
|
+
conflict: false;
|
|
338
|
+
shortfall: PromiseShortfall;
|
|
339
|
+
missing?: never;
|
|
340
|
+
pending?: never;
|
|
341
|
+
staleAt?: never;
|
|
342
|
+
expired?: never;
|
|
343
|
+
rejected?: never;
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* One refusal behind a {@link TransactionInvalidity}: a cohort member's validity-marked reject vote
|
|
347
|
+
* (`Signature`'s `validity`), or the validity verdict of the coordinating node's own storage-tier check
|
|
348
|
+
* (`StorageRepo.pend`, for a cohort of one, where no vote is cast).
|
|
349
|
+
*/
|
|
350
|
+
export type ValidityRefusal = ValidityRejection & {
|
|
351
|
+
/** The refusing member's peer-id string. Absent for a refusal a node's storage made without a vote. */
|
|
352
|
+
peerId?: string;
|
|
353
|
+
/** The refuser's description, free-form, for a log line. Never branch on it. */
|
|
354
|
+
reason?: string;
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* Why a write was refused as INVALID: the members that sank it judged the transaction itself wrong
|
|
358
|
+
* (see {@link ValidityRejection} for which refusals qualify), and no refusal of any other kind sank it
|
|
359
|
+
* beside them, bar expiry votes. Plain data, so it crosses the JSON repo protocol intact.
|
|
360
|
+
* `ValidityRejectedError` is built from it, wherever it is raised.
|
|
361
|
+
*/
|
|
362
|
+
export type TransactionInvalidity = {
|
|
363
|
+
/** Every validity refusal that sank the write. Never empty. */
|
|
364
|
+
refusals: ValidityRefusal[];
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* The cohort refused the write because the members that sank it judged it INVALID — the transaction
|
|
368
|
+
* failed its re-execution, its operations hash, its stamp or its client signature. Never retryable:
|
|
369
|
+
* re-sending the same content to the same checks is refused the same way. A sibling of
|
|
370
|
+
* {@link StaleFailure}, {@link ExpiredFailure} and {@link ShortfallFailure}, with the fields it can
|
|
371
|
+
* never carry typed `never`, so a consumer reads `reason`, `missing` or `staleAt` off any of them
|
|
372
|
+
* unnarrowed. Tell it apart with `isRejectedFailure`, never by reading `reason`.
|
|
373
|
+
*
|
|
374
|
+
* A pend answer only, and only when nothing else could explain the rejection: a reject vote with no
|
|
375
|
+
* validity marker beside the marked ones (a stale revision, a member on an older build) leaves the
|
|
376
|
+
* rejection unclassified, and a revision loss the coordinator's own storage confirms is returned as
|
|
377
|
+
* the {@link StaleFailure} it is, since the writer's rebase sends different content.
|
|
378
|
+
*/
|
|
379
|
+
export type RejectedFailure = {
|
|
380
|
+
success: false;
|
|
381
|
+
/** The coordinator's description of the refusal, for a log line. Never branch on it. */
|
|
382
|
+
reason?: string;
|
|
383
|
+
/** Always false: a verdict on the content is not a conflict a re-read can win. */
|
|
384
|
+
conflict: false;
|
|
385
|
+
rejected: TransactionInvalidity;
|
|
386
|
+
missing?: never;
|
|
387
|
+
pending?: never;
|
|
388
|
+
staleAt?: never;
|
|
389
|
+
expired?: never;
|
|
390
|
+
shortfall?: never;
|
|
258
391
|
};
|
|
259
392
|
/** Every way a pend or a commit can be refused with an answer rather than a throw. */
|
|
260
|
-
export type WriteFailure = StaleFailure | ExpiredFailure;
|
|
393
|
+
export type WriteFailure = StaleFailure | ExpiredFailure | ShortfallFailure | RejectedFailure;
|
|
261
394
|
export type PendResult = PendSuccess | WriteFailure;
|
|
262
395
|
/** What one block will materialize to at the committing revision, declared by the client that
|
|
263
396
|
* authored the transforms. */
|
|
@@ -294,6 +427,17 @@ export type CommitRequest = ActionBlocks & {
|
|
|
294
427
|
* cohort signature with no change to the hash helpers. Action-wide here; the transactor narrows
|
|
295
428
|
* it to each per-coordinator batch's own block ids before sending (`RepoCommitRequest`). */
|
|
296
429
|
blockDigests?: BlockContentDigests;
|
|
430
|
+
/**
|
|
431
|
+
* {@link PendRequest.refuseSolo}, on the commit. A coordinator whose cohort for the commit is only
|
|
432
|
+
* itself refuses it on the same rule, before minting a proof or applying anything, with a
|
|
433
|
+
* conflict-shaped refusal (`SOLO_COMMIT_REFUSED_REASON` in db-p2p), since a commit cannot answer
|
|
434
|
+
* with a shortfall. That is reached when the pend ran on a real cohort and the partner dropped
|
|
435
|
+
* before the commit: the writer cancels and retries, and the retry's pend meets the pend-side
|
|
436
|
+
* refusal. Carried through every per-coordinator rebuild of the commit (`repoCommitRequest` in
|
|
437
|
+
* `NetworkTransactor`); omitted rather than `false` for the preimage reason
|
|
438
|
+
* {@link blockDigests} is.
|
|
439
|
+
*/
|
|
440
|
+
refuseSolo?: true;
|
|
297
441
|
};
|
|
298
442
|
/**
|
|
299
443
|
* Originates a compensating invalidation through the same critical-cluster consensus as any
|
|
@@ -528,6 +672,8 @@ export type PendValidationResult = {
|
|
|
528
672
|
valid: boolean;
|
|
529
673
|
/** Reason for validation failure (if valid=false) */
|
|
530
674
|
reason?: string;
|
|
675
|
+
/** Set only on a failure that judges the transaction itself wrong; see {@link ValidityRejection}. */
|
|
676
|
+
validity?: ValidityRejection;
|
|
531
677
|
};
|
|
532
678
|
/**
|
|
533
679
|
* Hook for validating transactions in PendRequests.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"struct.d.ts","sourceRoot":"","sources":["../../../src/network/struct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"struct.d.ts","sourceRoot":"","sources":["../../../src/network/struct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE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,EAAE,cAAc,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC,gCAAgC;IAChC,KAAK,EAAE,OAAO,CAAC;IACf,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qGAAqG;IACrG,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAChC,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,MAAM,KAClB,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAGnC,2CAA2C;AAC3C,MAAM,MAAM,SAAS,GAAG,YAAY,CAAC;AACrC,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAC7C,8CAA8C;AAC9C,MAAM,MAAM,YAAY,GAAG,eAAe,CAAC;AAC3C,4CAA4C;AAC5C,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"struct.js","sourceRoot":"","sources":["../../../src/network/struct.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"struct.js","sourceRoot":"","sources":["../../../src/network/struct.ts"],"names":[],"mappings":"AA+qBA;;;;;GAKG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC1B;IAA2B;IAAhD,YAAqB,OAAgB,EAAW,MAA8B;QAC7E,KAAK,CAAC,SAAS,OAAO,oBAAoB,MAAM,mDAAmD,CAAC,CAAC;QADjF,YAAO,GAAP,OAAO,CAAS;QAAW,WAAM,GAAN,MAAM,CAAwB;QAE7E,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACrC,CAAC;CACD;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAC5B;IAA2B;IAAhD,YAAqB,OAAgB,EAAW,UAAkB;QACjE,KAAK,CAAC,SAAS,OAAO,4CAA4C,UAAU,wDAAwD,CAAC,CAAC;QADlH,YAAO,GAAP,OAAO,CAAS;QAAW,eAAU,GAAV,UAAU,CAAQ;QAEjE,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACvC,CAAC;CACD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RejectedFailure, TransactionInvalidity, ValidityRefusal } from "./struct.js";
|
|
2
|
+
/**
|
|
3
|
+
* A write the cohort refused because the members that sank it judged the transaction INVALID: it failed
|
|
4
|
+
* its re-execution, its operations hash, its stamp or its client signature (`ValidityRejection` in
|
|
5
|
+
* `transaction/transaction.ts` says which refusals qualify). Not retryable — re-sending the same
|
|
6
|
+
* content to the same checks is refused the same way. Nothing was saved: the members that approved
|
|
7
|
+
* release their reservation when the writer cancels.
|
|
8
|
+
*
|
|
9
|
+
* ONE class for every place it is raised, as `TransactionExpiredError` is. The coordinating repo (db-p2p
|
|
10
|
+
* `CoordinatorRepo`) returns its facts as a {@link RejectedFailure} ({@link toFailure}) when every reject
|
|
11
|
+
* that sank a pend was validity-marked or an expiry vote and its own storage confirms no revision loss,
|
|
12
|
+
* and a cohort of one's storage tier returns the same for its own check; each write path
|
|
13
|
+
* (`Collection.sync`, `TransactionCoordinator.commit`) raises it again from that refusal.
|
|
14
|
+
*
|
|
15
|
+
* Not the dispute answer. With disputes enabled, a marked rejection beside approvals is held for a ruling
|
|
16
|
+
* before it ends the pend, and that writer is answered with the dispute's own refusal (backlog
|
|
17
|
+
* `dispute-commit-path-block`, `dispute-writer-sees-disputed-pend`); this error stays the answer for a
|
|
18
|
+
* rejection no approval contests.
|
|
19
|
+
*/
|
|
20
|
+
export declare class ValidityRejectedError extends Error {
|
|
21
|
+
/** Every validity refusal that sank the write. Never empty. */
|
|
22
|
+
readonly refusals: readonly ValidityRefusal[];
|
|
23
|
+
constructor(invalidity: TransactionInvalidity);
|
|
24
|
+
/** The refusal a coordinating repo returns for this error, so it crosses the repo protocol as an
|
|
25
|
+
* answer rather than as a reset stream. */
|
|
26
|
+
toFailure(): RejectedFailure;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=validity-rejected-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validity-rejected-error.d.ts","sourceRoot":"","sources":["../../../src/network/validity-rejected-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE3F;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC/C,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;gBAElC,UAAU,EAAE,qBAAqB;IAU7C;gDAC4C;IAC5C,SAAS,IAAI,eAAe;CAQ5B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A write the cohort refused because the members that sank it judged the transaction INVALID: it failed
|
|
3
|
+
* its re-execution, its operations hash, its stamp or its client signature (`ValidityRejection` in
|
|
4
|
+
* `transaction/transaction.ts` says which refusals qualify). Not retryable — re-sending the same
|
|
5
|
+
* content to the same checks is refused the same way. Nothing was saved: the members that approved
|
|
6
|
+
* release their reservation when the writer cancels.
|
|
7
|
+
*
|
|
8
|
+
* ONE class for every place it is raised, as `TransactionExpiredError` is. The coordinating repo (db-p2p
|
|
9
|
+
* `CoordinatorRepo`) returns its facts as a {@link RejectedFailure} ({@link toFailure}) when every reject
|
|
10
|
+
* that sank a pend was validity-marked or an expiry vote and its own storage confirms no revision loss,
|
|
11
|
+
* and a cohort of one's storage tier returns the same for its own check; each write path
|
|
12
|
+
* (`Collection.sync`, `TransactionCoordinator.commit`) raises it again from that refusal.
|
|
13
|
+
*
|
|
14
|
+
* Not the dispute answer. With disputes enabled, a marked rejection beside approvals is held for a ruling
|
|
15
|
+
* before it ends the pend, and that writer is answered with the dispute's own refusal (backlog
|
|
16
|
+
* `dispute-commit-path-block`, `dispute-writer-sees-disputed-pend`); this error stays the answer for a
|
|
17
|
+
* rejection no approval contests.
|
|
18
|
+
*/
|
|
19
|
+
export class ValidityRejectedError extends Error {
|
|
20
|
+
/** Every validity refusal that sank the write. Never empty. */
|
|
21
|
+
refusals;
|
|
22
|
+
constructor(invalidity) {
|
|
23
|
+
// NOTE: `invalidity` off the wire is trusted as shaped (`isRejectedFailure` checks only presence),
|
|
24
|
+
// so a malformed coordinator answer throws a TypeError here (no `refusals` array) instead of this
|
|
25
|
+
// error. Either still ends the write; if hostile coordinators become a concern, validate the shape
|
|
26
|
+
// where the refusal is received, as for `TransactionExpiredError`.
|
|
27
|
+
super(validityRejectedMessage(invalidity.refusals));
|
|
28
|
+
this.name = 'ValidityRejectedError';
|
|
29
|
+
this.refusals = invalidity.refusals.map(refusal => ({ ...refusal }));
|
|
30
|
+
}
|
|
31
|
+
/** The refusal a coordinating repo returns for this error, so it crosses the repo protocol as an
|
|
32
|
+
* answer rather than as a reset stream. */
|
|
33
|
+
toFailure() {
|
|
34
|
+
return {
|
|
35
|
+
success: false,
|
|
36
|
+
conflict: false,
|
|
37
|
+
reason: this.message,
|
|
38
|
+
rejected: { refusals: this.refusals.map(refusal => ({ ...refusal })) },
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Written to be shown to a person. Names each refuser — the member's peer id, or the coordinating
|
|
43
|
+
* node's own check where no vote was cast — with the reason it gave. */
|
|
44
|
+
function validityRejectedMessage(refusals) {
|
|
45
|
+
const details = refusals
|
|
46
|
+
.map(refusal => `${refusal.peerId ?? 'coordinating node'}: ${refusal.reason ?? 'no reason given'}`)
|
|
47
|
+
.join('; ');
|
|
48
|
+
return `The transaction was rejected as invalid by ${refusals.length} validator(s) (${details}). `
|
|
49
|
+
+ `This is a verdict on the transaction itself, not a conflict or an unreachable cohort, and sending it again is refused the same way.`;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=validity-rejected-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validity-rejected-error.js","sourceRoot":"","sources":["../../../src/network/validity-rejected-error.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC/C,+DAA+D;IACtD,QAAQ,CAA6B;IAE9C,YAAY,UAAiC;QAC5C,mGAAmG;QACnG,kGAAkG;QAClG,mGAAmG;QACnG,mEAAmE;QACnE,KAAK,CAAC,uBAAuB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC;IACtE,CAAC;IAED;gDAC4C;IAC5C,SAAS;QACR,OAAO;YACN,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,EAAE;SACtE,CAAC;IACH,CAAC;CACD;AAED;yEACyE;AACzE,SAAS,uBAAuB,CAAC,QAAoC;IACpE,MAAM,OAAO,GAAG,QAAQ;SACtB,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,mBAAmB,KAAK,OAAO,CAAC,MAAM,IAAI,iBAAiB,EAAE,CAAC;SAClG,IAAI,CAAC,IAAI,CAAC,CAAC;IACb,OAAO,8CAA8C,QAAQ,CAAC,MAAM,kBAAkB,OAAO,KAAK;UAC/F,qIAAqI,CAAC;AAC1I,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ActionId, AlreadyAppliedTally } from '../collection/action.js';
|
|
2
|
+
import type { Collection } from '../collection/collection.js';
|
|
3
|
+
import type { EntryId } from '../collection/segments.js';
|
|
4
|
+
import type { CollectionId, InFlightAttempt } from '../collection/struct.js';
|
|
5
|
+
import type { WriteDurability } from '../network/struct.js';
|
|
6
|
+
import type { CommittedEffect, EntryStatus, EntryWaitingFor, QueuedEntry } from './status.js';
|
|
7
|
+
import type { JournalDriveState } from './journal.js';
|
|
8
|
+
/** One queued entry, as `OfflineQueue` holds it, and the projections of it the queue reports. */
|
|
9
|
+
export type Entry = {
|
|
10
|
+
readonly id: EntryId;
|
|
11
|
+
readonly seq: number;
|
|
12
|
+
readonly queuedAt: number;
|
|
13
|
+
readonly expiresAt: number | undefined;
|
|
14
|
+
/** The collections the entry sealed a segment in — the ones `sealPending` answered `true` for. */
|
|
15
|
+
readonly collections: readonly Collection<any>[];
|
|
16
|
+
/** One action id for the entry's whole life, with one exception: a `torn-not-saved` outcome mints
|
|
17
|
+
* a fresh one (the queue's `applyFailure` says why). */
|
|
18
|
+
actionId: ActionId;
|
|
19
|
+
attempts: number;
|
|
20
|
+
/** Whether an attempt may have landed; sticky — see the NOTE at the queue's `recordAttempts`. */
|
|
21
|
+
inDoubt: boolean;
|
|
22
|
+
/** The attempts recorded under `actionId` and not yet resolved, per collection, handed back as
|
|
23
|
+
* `resume` when the entry is re-driven. Cleared with the action id. */
|
|
24
|
+
readonly retained: Map<CollectionId, InFlightAttempt>;
|
|
25
|
+
/** The collections a partial commit has already committed, with who holds each, accumulated
|
|
26
|
+
* across submissions (`recordCollectionDurability`); empty until one does. The committed half's
|
|
27
|
+
* segments are consumed, so the next submission drives only the rest, and the terminal status
|
|
28
|
+
* reports these beside it. */
|
|
29
|
+
readonly committed: Map<CollectionId, WriteDurability | undefined>;
|
|
30
|
+
/** What each collection's head segment accepted as already applied when it was committed, as the
|
|
31
|
+
* `onCommittedHead` hooks reported it — across submissions, so a partial commit's committed half is
|
|
32
|
+
* recorded before the error reaches the queue and a later submission's tallies accumulate beside
|
|
33
|
+
* it. A collection a restore found already committed records nothing. Folded into the `committed`
|
|
34
|
+
* status's `effect` ({@link effectOf}, which answers `applied` while any collection the entry wrote
|
|
35
|
+
* has no tally here). In memory only: a restart between a partial commit and the remainder's commit
|
|
36
|
+
* loses the committed half's tally, and the entry then reports `applied`, the conservative answer,
|
|
37
|
+
* whatever the remainder reports. */
|
|
38
|
+
readonly applied: Map<CollectionId, AlreadyAppliedTally>;
|
|
39
|
+
phase: 'queued' | 'submitting';
|
|
40
|
+
waitingFor: EntryWaitingFor | undefined;
|
|
41
|
+
lastError: unknown;
|
|
42
|
+
/** The last `queued` status emitted, so a re-check that changes nothing emits nothing. */
|
|
43
|
+
lastQueued: QueuedStatus | undefined;
|
|
44
|
+
/** The `offline:expiry-deferred` line is logged once per entry, not once per re-check. */
|
|
45
|
+
expiryDeferredLogged: boolean;
|
|
46
|
+
};
|
|
47
|
+
export type QueuedStatus = Extract<EntryStatus, {
|
|
48
|
+
kind: 'queued';
|
|
49
|
+
}>;
|
|
50
|
+
export declare function queuedStatus(entry: Entry): QueuedStatus;
|
|
51
|
+
/** `{ committedCollections }` once part of the entry has committed, `{}` before — the field the
|
|
52
|
+
* `queued` and `failed` statuses and {@link snapshot} carry only when it says something. */
|
|
53
|
+
export declare function committedField(entry: Entry): {
|
|
54
|
+
committedCollections?: readonly CollectionId[];
|
|
55
|
+
};
|
|
56
|
+
export declare function currentStatus(entry: Entry): EntryStatus;
|
|
57
|
+
/** The entry as `OfflineQueue.entries` lists it. */
|
|
58
|
+
export declare function snapshot(entry: Entry): QueuedEntry;
|
|
59
|
+
/** Whether two `queued` statuses differ in anything an application can see. */
|
|
60
|
+
export declare function queuedStatusChanged(previous: QueuedStatus | undefined, status: QueuedStatus): boolean;
|
|
61
|
+
/** The `effect` of a committed entry ({@link CommittedEffect}): `already-applied` exactly when EVERY
|
|
62
|
+
* collection the entry wrote reported a tally and the tallies sum to `alreadyApplied > 0` and
|
|
63
|
+
* `applied === 0`. A collection whose tally was never heard — one committed before a restart, or one
|
|
64
|
+
* a restore found already committed — may have changed rows, so its absence answers `applied`: a
|
|
65
|
+
* remainder that was wholly already applied must not speak for a half that was not. */
|
|
66
|
+
export declare function effectOf(entry: Entry): CommittedEffect;
|
|
67
|
+
/** The entry's drive state as the journal records it (`IOfflineJournal.driving`): its action id,
|
|
68
|
+
* the attempts retained under it — with `attempts`, the ones about to be sent, laid over them when
|
|
69
|
+
* given — and the collections already committed. Copies, so the journal serialises a state the
|
|
70
|
+
* drain cannot change under it. */
|
|
71
|
+
export declare function driveState(entry: Entry, attempts?: ReadonlyMap<CollectionId, InFlightAttempt>): JournalDriveState;
|
|
72
|
+
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../../src/offline/entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,iGAAiG;AACjG,MAAM,MAAM,KAAK,GAAG;IACnB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ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