@sekiban/dcb-runtime 0.2.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/LICENSE +86 -0
- package/README.md +13 -0
- package/dist/allocator/AllocatorDurableObject.d.ts +36 -0
- package/dist/allocator/AllocatorDurableObject.js +658 -0
- package/dist/allocator/IssuanceLedger.d.ts +188 -0
- package/dist/allocator/IssuanceLedger.js +608 -0
- package/dist/allocator/IssuanceReconciler.d.ts +41 -0
- package/dist/allocator/IssuanceReconciler.js +191 -0
- package/dist/allocator/OrderClock.d.ts +41 -0
- package/dist/allocator/OrderClock.js +92 -0
- package/dist/allocator/SortableUniqueId.d.ts +46 -0
- package/dist/allocator/SortableUniqueId.js +156 -0
- package/dist/allocator/types.d.ts +52 -0
- package/dist/allocator/types.js +1 -0
- package/dist/bootstrap/BootstrapCoordinatorDurableObject.d.ts +28 -0
- package/dist/bootstrap/BootstrapCoordinatorDurableObject.js +357 -0
- package/dist/bootstrap/BootstrapStoreAdapter.d.ts +51 -0
- package/dist/bootstrap/BootstrapStoreAdapter.js +162 -0
- package/dist/bootstrap/OperatorBootstrap.d.ts +20 -0
- package/dist/bootstrap/OperatorBootstrap.js +104 -0
- package/dist/bootstrap/manifest.d.ts +9 -0
- package/dist/bootstrap/manifest.js +115 -0
- package/dist/bootstrap/types.d.ts +75 -0
- package/dist/bootstrap/types.js +1 -0
- package/dist/cli/OperatorRepairCli.d.ts +11 -0
- package/dist/cli/OperatorRepairCli.js +108 -0
- package/dist/cloudflare.d.ts +164 -0
- package/dist/cloudflare.js +19487 -0
- package/dist/commit/CommitWorker.d.ts +101 -0
- package/dist/commit/CommitWorker.js +921 -0
- package/dist/commit/types.d.ts +25 -0
- package/dist/commit/types.js +13 -0
- package/dist/completeness/GlobalCompletenessReconciler.d.ts +77 -0
- package/dist/completeness/GlobalCompletenessReconciler.js +572 -0
- package/dist/completeness/types.d.ts +85 -0
- package/dist/completeness/types.js +6 -0
- package/dist/composition.d.ts +123 -0
- package/dist/composition.js +237 -0
- package/dist/cosmos.d.ts +11 -0
- package/dist/cosmos.js +1411 -0
- package/dist/d1-mv.d.ts +8 -0
- package/dist/d1-mv.js +2001 -0
- package/dist/d1.d.ts +16 -0
- package/dist/d1.js +3418 -0
- package/dist/diagnostics/G60DurableHop.d.ts +99 -0
- package/dist/diagnostics/G60DurableHop.js +248 -0
- package/dist/diagnostics/G65Admission.d.ts +23 -0
- package/dist/diagnostics/G65Admission.js +43 -0
- package/dist/diagnostics/G65DirectRing.d.ts +33 -0
- package/dist/diagnostics/G65DirectRing.js +85 -0
- package/dist/diagnostics/G69AdmissionAttempt.d.ts +43 -0
- package/dist/diagnostics/G69AdmissionAttempt.js +22 -0
- package/dist/downstream/DeliveryCore.d.ts +127 -0
- package/dist/downstream/DeliveryCore.js +304 -0
- package/dist/downstream/Doorbell.d.ts +43 -0
- package/dist/downstream/Doorbell.js +137 -0
- package/dist/downstream/DownstreamAdapter.d.ts +52 -0
- package/dist/downstream/DownstreamAdapter.js +299 -0
- package/dist/downstream/ExclusionLookup.d.ts +36 -0
- package/dist/downstream/ExclusionLookup.js +50 -0
- package/dist/downstream/InconsistencyDetector.d.ts +27 -0
- package/dist/downstream/InconsistencyDetector.js +82 -0
- package/dist/downstream/OutboxDrain.d.ts +35 -0
- package/dist/downstream/OutboxDrain.js +126 -0
- package/dist/downstream/types.d.ts +77 -0
- package/dist/downstream/types.js +64 -0
- package/dist/eventIdentity.d.ts +30 -0
- package/dist/eventIdentity.js +49 -0
- package/dist/eventRecord.d.ts +26 -0
- package/dist/eventRecord.js +53 -0
- package/dist/g42-probe.d.ts +9 -0
- package/dist/g42-probe.js +9 -0
- package/dist/http/SerializedQueryWorker.d.ts +58 -0
- package/dist/http/SerializedQueryWorker.js +497 -0
- package/dist/http/commitResponse.d.ts +46 -0
- package/dist/http/commitResponse.js +80 -0
- package/dist/http/testServiceId.d.ts +17 -0
- package/dist/http/testServiceId.js +14 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.js +19926 -0
- package/dist/journal/JournalDurableObject.d.ts +30 -0
- package/dist/journal/JournalDurableObject.js +481 -0
- package/dist/journal/JournalFirstTouchProbe.d.ts +190 -0
- package/dist/journal/JournalFirstTouchProbe.js +375 -0
- package/dist/journal/types.d.ts +116 -0
- package/dist/journal/types.js +52 -0
- package/dist/mv/MaterializedViewCatchUp.d.ts +60 -0
- package/dist/mv/MaterializedViewCatchUp.js +353 -0
- package/dist/mv/MaterializedViewRuntime.d.ts +80 -0
- package/dist/mv/MaterializedViewRuntime.js +328 -0
- package/dist/mv/MaterializedViewStore.d.ts +257 -0
- package/dist/mv/MaterializedViewStore.js +875 -0
- package/dist/mv/UnsafeWindowMaterializedView.d.ts +112 -0
- package/dist/mv/UnsafeWindowMaterializedView.js +495 -0
- package/dist/mv/index.d.ts +8 -0
- package/dist/mv/index.js +2357 -0
- package/dist/projection/LiveProjectionWorker.d.ts +86 -0
- package/dist/projection/LiveProjectionWorker.js +240 -0
- package/dist/projection/ProjectionRuntime.d.ts +113 -0
- package/dist/projection/ProjectionRuntime.js +346 -0
- package/dist/projection/ProjectorRegistry.d.ts +51 -0
- package/dist/projection/ProjectorRegistry.js +116 -0
- package/dist/query/ProjectionQueryStore.d.ts +102 -0
- package/dist/query/ProjectionQueryStore.js +185 -0
- package/dist/query/QueryRegistry.d.ts +22 -0
- package/dist/query/QueryRegistry.js +36 -0
- package/dist/read/SerializedReadWorker.d.ts +36 -0
- package/dist/read/SerializedReadWorker.js +225 -0
- package/dist/repair/RepairWorker.d.ts +72 -0
- package/dist/repair/RepairWorker.js +461 -0
- package/dist/safeWindow.d.ts +20 -0
- package/dist/safeWindow.js +36 -0
- package/dist/scope/ControlRouteScope.d.ts +22 -0
- package/dist/scope/ControlRouteScope.js +36 -0
- package/dist/scope/ScopeName.d.ts +34 -0
- package/dist/scope/ScopeName.js +67 -0
- package/dist/service/ServiceIdentityProvider.d.ts +35 -0
- package/dist/service/ServiceIdentityProvider.js +56 -0
- package/dist/store/CosmosEventStore.d.ts +126 -0
- package/dist/store/CosmosEventStore.js +950 -0
- package/dist/store/D1EventStore.d.ts +111 -0
- package/dist/store/D1EventStore.js +1111 -0
- package/dist/store/PostgresEventStore.d.ts +35 -0
- package/dist/store/PostgresEventStore.js +811 -0
- package/dist/store/provider.d.ts +25 -0
- package/dist/store/provider.js +32 -0
- package/dist/store/types.d.ts +205 -0
- package/dist/store/types.js +18 -0
- package/dist/tag/EventDigest.d.ts +40 -0
- package/dist/tag/EventDigest.js +158 -0
- package/dist/tag/TagDurableObject.d.ts +286 -0
- package/dist/tag/TagDurableObject.js +4071 -0
- package/dist/tag/TagSqlMeasurement.d.ts +26 -0
- package/dist/tag/TagSqlMeasurement.js +44 -0
- package/dist/tag/TagSqlSchema.d.ts +29 -0
- package/dist/tag/TagSqlSchema.js +211 -0
- package/dist/tag/types.d.ts +173 -0
- package/dist/tag/types.js +3 -0
- package/dist/tagstate/TagStateDurableObject.d.ts +57 -0
- package/dist/tagstate/TagStateDurableObject.js +499 -0
- package/dist/trace/AttributionRatio.d.ts +12 -0
- package/dist/trace/AttributionRatio.js +68 -0
- package/dist/trace/CloudflareTracing.d.ts +7 -0
- package/dist/trace/CloudflareTracing.js +9 -0
- package/dist/trace/CommitTrace.d.ts +405 -0
- package/dist/trace/CommitTrace.js +1008 -0
- package/dist/trace/CommitTraceConsoleSink.d.ts +68 -0
- package/dist/trace/CommitTraceConsoleSink.js +114 -0
- package/dist/trace/CommitTraceVerifier.d.ts +22 -0
- package/dist/trace/CommitTraceVerifier.js +295 -0
- package/dist/trace/ObservationStream.d.ts +118 -0
- package/dist/trace/ObservationStream.js +148 -0
- package/package.json +71 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type { AllocatedCandidate, AllocationCandidate, ClosedPrefixCertificate } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Minimum age before reconciler may force-tombstone a never-contacted target.
|
|
4
|
+
* Matches {@link RESERVATION_WINDOW_MS}: the writer has until tag reservation
|
|
5
|
+
* expiry to acquire; elapsed time is only a trigger to inspect and fence.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ISSUANCE_NEVER_CONTACTED_GRACE_MS = 30000;
|
|
8
|
+
export declare const ISSUANCE_LEDGER_VERSION = 1;
|
|
9
|
+
export declare const ATTEMPT_KEY_PREFIX = "attempt:";
|
|
10
|
+
export declare const ISSUANCE_COUNT_KEY = "issuance:unresolved-count";
|
|
11
|
+
export declare const ISSUANCE_RECOVERY_KEY = "issuance:recovery-schedule";
|
|
12
|
+
export declare const ISSUANCE_MIGRATION_KEY = "issuance:migration";
|
|
13
|
+
export declare const ISSUANCE_MIGRATION_PROOF_PREFIX = "issuance:migration-proof:";
|
|
14
|
+
export declare const ISSUANCE_PREFIX_KEY = "issuance:closed-prefix";
|
|
15
|
+
export declare const LEGACY_INVENTORIED_PREFIX = "issuance:legacy-inventoried:";
|
|
16
|
+
export declare const ENVELOPE_PREFIX = "issuance:envelope:";
|
|
17
|
+
export declare const TARGET_PREFIX = "issuance:target:";
|
|
18
|
+
export declare const ISSUED_INDEX_PREFIX = "issuance:issued:";
|
|
19
|
+
export declare const UNRESOLVED_INDEX_PREFIX = "issuance:unresolved:";
|
|
20
|
+
export declare const DEFAULT_WRITER_EPOCH = 0;
|
|
21
|
+
export declare const MAX_TARGET_TAGS = 32;
|
|
22
|
+
export declare const MAX_TAG_LENGTH = 256;
|
|
23
|
+
export type TargetClosureStatus = "pending" | "installed-and-covered" | "absent-and-irrevocably-fenced";
|
|
24
|
+
export interface IssuanceEnvelope {
|
|
25
|
+
readonly ledgerVersion: typeof ISSUANCE_LEDGER_VERSION;
|
|
26
|
+
readonly serviceId: string;
|
|
27
|
+
readonly allocatorLineageId: string;
|
|
28
|
+
readonly attemptId: string;
|
|
29
|
+
readonly candidateIndex: number;
|
|
30
|
+
readonly eventId: string;
|
|
31
|
+
readonly suid: string;
|
|
32
|
+
readonly canonicalTargetTags: readonly string[];
|
|
33
|
+
readonly pinnedWriterEpoch: number;
|
|
34
|
+
readonly identityDigest: string;
|
|
35
|
+
/** Wall time when the envelope was registered; drives never-contacted grace. */
|
|
36
|
+
readonly issuedAtMs: number;
|
|
37
|
+
}
|
|
38
|
+
export interface TargetClosureRecord {
|
|
39
|
+
readonly tag: string;
|
|
40
|
+
status: TargetClosureStatus;
|
|
41
|
+
readonly envelopeDigest: string;
|
|
42
|
+
}
|
|
43
|
+
export interface IssuanceMigrationState {
|
|
44
|
+
readonly cutInstalledAt: number;
|
|
45
|
+
readonly legacyInventoryCursor: string | null;
|
|
46
|
+
readonly inventoryComplete: boolean;
|
|
47
|
+
readonly migrationProofId: string | null;
|
|
48
|
+
readonly legacyInventorySummary?: LegacyInventorySummary;
|
|
49
|
+
}
|
|
50
|
+
export interface IssuanceRecoverySchedule {
|
|
51
|
+
readonly nextDueAt: number;
|
|
52
|
+
readonly cursor: string | null;
|
|
53
|
+
readonly attempts: number;
|
|
54
|
+
}
|
|
55
|
+
export interface AllocationCandidateWithMembership extends AllocationCandidate {
|
|
56
|
+
readonly targetTags?: readonly string[];
|
|
57
|
+
readonly pinnedWriterEpoch?: number;
|
|
58
|
+
}
|
|
59
|
+
export interface TagResolutionObservation {
|
|
60
|
+
readonly terminalStatus: Exclude<TargetClosureStatus, "pending">;
|
|
61
|
+
readonly obligationDigest?: string;
|
|
62
|
+
readonly tombstoneEpoch?: number;
|
|
63
|
+
}
|
|
64
|
+
export interface TargetResolutionEvidence {
|
|
65
|
+
readonly serviceId: string;
|
|
66
|
+
readonly allocatorLineageId: string;
|
|
67
|
+
readonly attemptId: string;
|
|
68
|
+
readonly candidateIndex: number;
|
|
69
|
+
readonly suid: string;
|
|
70
|
+
readonly tag: string;
|
|
71
|
+
readonly identityDigest: string;
|
|
72
|
+
readonly pinnedWriterEpoch: number;
|
|
73
|
+
readonly tagObservation: TagResolutionObservation;
|
|
74
|
+
}
|
|
75
|
+
export type LegacyAttemptClassification = "legacy-vector-only" | "legacy-resolved-registration" | "legacy-unresolved-registration" | "legacy-unclassifiable-blocking";
|
|
76
|
+
export interface LegacyInventoryRecord {
|
|
77
|
+
readonly inventoriedAt: number;
|
|
78
|
+
readonly classification: LegacyAttemptClassification;
|
|
79
|
+
readonly reason: string;
|
|
80
|
+
}
|
|
81
|
+
export interface LegacyInventorySummary {
|
|
82
|
+
readonly vectorOnly: number;
|
|
83
|
+
readonly resolvedRegistration: number;
|
|
84
|
+
readonly unresolvedRegistration: number;
|
|
85
|
+
readonly unclassifiableBlocking: number;
|
|
86
|
+
}
|
|
87
|
+
export declare class IssuanceLedgerError extends Error {
|
|
88
|
+
constructor(message: string);
|
|
89
|
+
}
|
|
90
|
+
export declare function canonicalizeTargetTags(tags: readonly string[]): readonly string[];
|
|
91
|
+
export declare function identityDigest(input: {
|
|
92
|
+
serviceId: string;
|
|
93
|
+
allocatorLineageId: string;
|
|
94
|
+
attemptId: string;
|
|
95
|
+
candidateIndex: number;
|
|
96
|
+
eventId: string;
|
|
97
|
+
suid: string;
|
|
98
|
+
canonicalTargetTags: readonly string[];
|
|
99
|
+
pinnedWriterEpoch: number;
|
|
100
|
+
}): string;
|
|
101
|
+
export declare function envelopeKey(attemptId: string, candidateIndex: number): string;
|
|
102
|
+
export declare function targetKey(attemptId: string, candidateIndex: number, tag: string): string;
|
|
103
|
+
export declare function issuedIndexKey(suid: string, attemptId: string, candidateIndex: number): string;
|
|
104
|
+
export declare function unresolvedIndexKey(suid: string, attemptId: string, candidateIndex: number): string;
|
|
105
|
+
export declare function parseIndexEntry(key: string, prefix: string): {
|
|
106
|
+
suid: string;
|
|
107
|
+
attemptId: string;
|
|
108
|
+
candidateIndex: number;
|
|
109
|
+
} | undefined;
|
|
110
|
+
export declare function buildEnvelope(input: {
|
|
111
|
+
serviceId: string;
|
|
112
|
+
allocatorLineageId: string;
|
|
113
|
+
attemptId: string;
|
|
114
|
+
candidate: AllocatedCandidate;
|
|
115
|
+
targetTags: readonly string[];
|
|
116
|
+
pinnedWriterEpoch: number;
|
|
117
|
+
issuedAtMs: number;
|
|
118
|
+
}): IssuanceEnvelope;
|
|
119
|
+
export declare function membershipMatches(left: readonly string[], right: readonly string[]): boolean;
|
|
120
|
+
export declare function registerIssuanceInTransaction(txn: DurableObjectTransaction, input: {
|
|
121
|
+
serviceId: string;
|
|
122
|
+
allocatorLineageId: string;
|
|
123
|
+
attemptId: string;
|
|
124
|
+
candidates: readonly AllocatedCandidate[];
|
|
125
|
+
candidateMembership: ReadonlyMap<number, {
|
|
126
|
+
tags: readonly string[];
|
|
127
|
+
pinnedWriterEpoch: number;
|
|
128
|
+
}>;
|
|
129
|
+
migration: IssuanceMigrationState | undefined;
|
|
130
|
+
}): Promise<void>;
|
|
131
|
+
/** Arm when a recovery schedule exists and reconciliation is due (or overdue). */
|
|
132
|
+
export declare function shouldArmIssuanceRecovery(schedule: IssuanceRecoverySchedule | undefined, now: number): boolean;
|
|
133
|
+
export declare const ISSUANCE_RECOVERY_ALARM_ARMED_KEY = "issuance:recovery-alarm-armed-at";
|
|
134
|
+
type RecoveryAlarmStorage = Pick<DurableObjectStorage, "get" | "getAlarm" | "setAlarm" | "deleteAlarm" | "put" | "list">;
|
|
135
|
+
/**
|
|
136
|
+
* Align the durable recovery alarm with {@link ISSUANCE_RECOVERY_KEY}.nextDueAt without
|
|
137
|
+
* pushing a pending earlier alarm later while work remains outstanding.
|
|
138
|
+
*/
|
|
139
|
+
export declare function syncIssuanceRecoveryAlarm(storage: RecoveryAlarmStorage, now: number): Promise<void>;
|
|
140
|
+
type IssuanceIndexReader = Pick<DurableObjectStorage, "list">;
|
|
141
|
+
export declare function countUnresolvedEntries(reader: IssuanceIndexReader): Promise<number>;
|
|
142
|
+
export declare function leastUnresolvedEntry(reader: IssuanceIndexReader): Promise<{
|
|
143
|
+
suid: string;
|
|
144
|
+
attemptId: string;
|
|
145
|
+
candidateIndex: number;
|
|
146
|
+
} | undefined>;
|
|
147
|
+
export declare function predecessorIssuedSuid(reader: IssuanceIndexReader, exclusiveSuid: string): Promise<string | null>;
|
|
148
|
+
export declare function computeClosedPrefixSuid(reader: IssuanceIndexReader, txn: DurableObjectTransaction, allocatedWatermark: string | null, migration: IssuanceMigrationState | undefined): Promise<{
|
|
149
|
+
closedPrefixSuid: string | null;
|
|
150
|
+
unresolvedCount: number;
|
|
151
|
+
status: "ready" | "unreconciled";
|
|
152
|
+
}>;
|
|
153
|
+
export declare function buildCertificateSnapshot(reader: IssuanceIndexReader, txn: DurableObjectTransaction, input: {
|
|
154
|
+
serviceId: string;
|
|
155
|
+
allocatorLineageId: string;
|
|
156
|
+
allocatedWatermark: string | null;
|
|
157
|
+
generatedAt: number;
|
|
158
|
+
}): Promise<ClosedPrefixCertificate>;
|
|
159
|
+
export declare function parseTargetResolutionEvidence(raw: unknown): TargetResolutionEvidence;
|
|
160
|
+
export declare function applyTargetResolution(txn: DurableObjectTransaction, evidence: TargetResolutionEvidence): Promise<{
|
|
161
|
+
candidateResolved: boolean;
|
|
162
|
+
duplicate: boolean;
|
|
163
|
+
}>;
|
|
164
|
+
export declare function registrationProbe(txn: DurableObjectTransaction, attemptId: string, candidateIndex: number): Promise<{
|
|
165
|
+
envelope: boolean;
|
|
166
|
+
unresolvedIndex: boolean;
|
|
167
|
+
issuedIndex: boolean;
|
|
168
|
+
exactCount: boolean;
|
|
169
|
+
recoverySchedule: boolean;
|
|
170
|
+
}>;
|
|
171
|
+
type StorageListReader = Pick<DurableObjectStorage, "list">;
|
|
172
|
+
export declare function pageLegacyInventoryInTransaction(txn: DurableObjectTransaction, input: {
|
|
173
|
+
pageSize: number;
|
|
174
|
+
faultInjection?: "after-cursor-persist";
|
|
175
|
+
}, reader?: StorageListReader): Promise<{
|
|
176
|
+
pageCount: number;
|
|
177
|
+
nextCursor: string | null;
|
|
178
|
+
inventoryComplete: boolean;
|
|
179
|
+
}>;
|
|
180
|
+
export declare function completeMigrationProofInTransaction(txn: DurableObjectTransaction, input: {
|
|
181
|
+
migrationProofId: string;
|
|
182
|
+
boundEvidence: Record<string, unknown>;
|
|
183
|
+
}): Promise<void>;
|
|
184
|
+
export declare function parseCandidateMembership(raw: unknown): {
|
|
185
|
+
tags: readonly string[];
|
|
186
|
+
pinnedWriterEpoch: number;
|
|
187
|
+
} | undefined;
|
|
188
|
+
export {};
|