@optimystic/db-core 0.29.0 → 1.0.0-beta.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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RepoMessage } from "../network/repo-protocol.js";
|
|
2
|
+
import type { PendResult } from "../network/struct.js";
|
|
2
3
|
/**
|
|
3
4
|
* One member's vote on a cluster transaction, in either the promise or the commit map.
|
|
4
5
|
*
|
|
@@ -49,6 +50,16 @@ export type ClusterPeers = {
|
|
|
49
50
|
publicKey: string;
|
|
50
51
|
};
|
|
51
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* One member's own report of what its storage did with this transaction at consensus-apply time; see
|
|
55
|
+
* {@link ClusterRecord.applyOutcomes} for the trust rules. Only the pend arm exists today — a commit
|
|
56
|
+
* refusal is not reported this way, because a commit that reached commit-consensus is authoritative
|
|
57
|
+
* (the coordinator's own retained verdict plus the commit-promise guard cover that tier instead).
|
|
58
|
+
*/
|
|
59
|
+
export type MemberApplyOutcome = {
|
|
60
|
+
/** This member's storage refused the record's pend with a conflict-shaped result. */
|
|
61
|
+
pend?: PendResult;
|
|
62
|
+
};
|
|
52
63
|
export type ClusterRecord = {
|
|
53
64
|
messageHash: string;
|
|
54
65
|
peers: ClusterPeers;
|
|
@@ -84,6 +95,30 @@ export type ClusterRecord = {
|
|
|
84
95
|
networkSizeHint?: number;
|
|
85
96
|
/** Confidence in the network size estimate (0-1) */
|
|
86
97
|
networkSizeConfidence?: number;
|
|
98
|
+
/**
|
|
99
|
+
* What each member's OWN storage answered when it applied this record's operations at consensus,
|
|
100
|
+
* keyed by peer id. Advisory and **unsigned** — no hash covers it — and deliberately so: it is
|
|
101
|
+
* written by a member *after* the votes are cast, on the response it hands back, so no signed
|
|
102
|
+
* payload could carry it without a further round trip.
|
|
103
|
+
*
|
|
104
|
+
* Members set only their own entry, and only for a *conflict-shaped* pend refusal (one carrying
|
|
105
|
+
* `pending` or `missing`, per `isConflictFailure`) — the optimistic-concurrency verdict that a
|
|
106
|
+
* rival holds the blocks or already took the revision. Successes and bare-reason faults are
|
|
107
|
+
* omitted: a bare fault stays tolerated local divergence, mirroring the coordinator's own
|
|
108
|
+
* local-verdict arm.
|
|
109
|
+
*
|
|
110
|
+
* Why unsigned is acceptable: a hostile entry can only *downgrade* a reported pend success into a
|
|
111
|
+
* retryable conflict, which the writer answers by rebasing and trying again. The same member
|
|
112
|
+
* could already force strictly worse outcomes with a signed reject or conflict vote, so this adds
|
|
113
|
+
* no attack surface beyond retry pressure — and failing toward retry is the correct direction for
|
|
114
|
+
* optimistic concurrency. Never treat an entry here as evidence of anything but "retry".
|
|
115
|
+
*
|
|
116
|
+
* Old peers never set it and old coordinators ignore it, so it is wire-compatible in both
|
|
117
|
+
* directions.
|
|
118
|
+
*/
|
|
119
|
+
applyOutcomes?: {
|
|
120
|
+
[peerId: string]: MemberApplyOutcome;
|
|
121
|
+
};
|
|
87
122
|
/** Transaction proceeded despite minority rejections */
|
|
88
123
|
disputed?: boolean;
|
|
89
124
|
/** Evidence of the dispute: which peers rejected and why */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structs.d.ts","sourceRoot":"","sources":["../../../src/cluster/structs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"structs.d.ts","sourceRoot":"","sources":["../../../src/cluster/structs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAClB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAA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AE,MAAM,CAAC;IACvC,wEAAwE;IACxE,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,sDAAsD;IACtD,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,gEAAgE;IAChE,+BAA+B,CAAC,EAAE,MAAM,CAAC;IACzC,iFAAiF;IACjF,+BAA+B,CAAC,EAAE,MAAM,CAAC;IACzC;;;;;;;OAOG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,gLAAgL;IAChL,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,UAAU,CAAC;IAC7C,4GAA4G;IAC5G,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gIAAgI;IAChI,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;OAKG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC;;;OAGG;IACH,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CAClD;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../src/cluster/structs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../src/cluster/structs.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAAY,EAAE,IAAuB,EAAE,KAAc;IAC9F,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACjF,CAAC;AAED,8GAA8G;AAC9G,MAAM,UAAU,8BAA8B,CAAC,IAAY,EAAE,SAAoB;IAChF,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,QAAQ,CAAC,CAAC,OAAO,yBAAyB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;QACxF,KAAK,UAAU,CAAC,CAAC,OAAO,yBAAyB,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;QAC5F,OAAO,CAAC,CAAC,OAAO,yBAAyB,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC;AACF,CAAC;AAmFD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAI,CAAC"}
|
package/package.json
CHANGED
package/src/cluster/structs.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RepoMessage } from "../network/repo-protocol.js";
|
|
2
|
+
import type { PendResult } from "../network/struct.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* One member's vote on a cluster transaction, in either the promise or the commit map.
|
|
@@ -53,6 +54,17 @@ export type ClusterPeers = {
|
|
|
53
54
|
};
|
|
54
55
|
};
|
|
55
56
|
|
|
57
|
+
/**
|
|
58
|
+
* One member's own report of what its storage did with this transaction at consensus-apply time; see
|
|
59
|
+
* {@link ClusterRecord.applyOutcomes} for the trust rules. Only the pend arm exists today — a commit
|
|
60
|
+
* refusal is not reported this way, because a commit that reached commit-consensus is authoritative
|
|
61
|
+
* (the coordinator's own retained verdict plus the commit-promise guard cover that tier instead).
|
|
62
|
+
*/
|
|
63
|
+
export type MemberApplyOutcome = {
|
|
64
|
+
/** This member's storage refused the record's pend with a conflict-shaped result. */
|
|
65
|
+
pend?: PendResult;
|
|
66
|
+
};
|
|
67
|
+
|
|
56
68
|
export type ClusterRecord = {
|
|
57
69
|
messageHash: string; // Serves as a unique identifier for the clustered transaction record
|
|
58
70
|
peers: ClusterPeers;
|
|
@@ -84,6 +96,28 @@ export type ClusterRecord = {
|
|
|
84
96
|
networkSizeHint?: number;
|
|
85
97
|
/** Confidence in the network size estimate (0-1) */
|
|
86
98
|
networkSizeConfidence?: number;
|
|
99
|
+
/**
|
|
100
|
+
* What each member's OWN storage answered when it applied this record's operations at consensus,
|
|
101
|
+
* keyed by peer id. Advisory and **unsigned** — no hash covers it — and deliberately so: it is
|
|
102
|
+
* written by a member *after* the votes are cast, on the response it hands back, so no signed
|
|
103
|
+
* payload could carry it without a further round trip.
|
|
104
|
+
*
|
|
105
|
+
* Members set only their own entry, and only for a *conflict-shaped* pend refusal (one carrying
|
|
106
|
+
* `pending` or `missing`, per `isConflictFailure`) — the optimistic-concurrency verdict that a
|
|
107
|
+
* rival holds the blocks or already took the revision. Successes and bare-reason faults are
|
|
108
|
+
* omitted: a bare fault stays tolerated local divergence, mirroring the coordinator's own
|
|
109
|
+
* local-verdict arm.
|
|
110
|
+
*
|
|
111
|
+
* Why unsigned is acceptable: a hostile entry can only *downgrade* a reported pend success into a
|
|
112
|
+
* retryable conflict, which the writer answers by rebasing and trying again. The same member
|
|
113
|
+
* could already force strictly worse outcomes with a signed reject or conflict vote, so this adds
|
|
114
|
+
* no attack surface beyond retry pressure — and failing toward retry is the correct direction for
|
|
115
|
+
* optimistic concurrency. Never treat an entry here as evidence of anything but "retry".
|
|
116
|
+
*
|
|
117
|
+
* Old peers never set it and old coordinators ignore it, so it is wire-compatible in both
|
|
118
|
+
* directions.
|
|
119
|
+
*/
|
|
120
|
+
applyOutcomes?: { [peerId: string]: MemberApplyOutcome };
|
|
87
121
|
/** Transaction proceeded despite minority rejections */
|
|
88
122
|
disputed?: boolean;
|
|
89
123
|
/** Evidence of the dispute: which peers rejected and why */
|