fatedb 0.0.0-stage → 0.10.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 +21 -0
- package/README.md +264 -2
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +3 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.js +256 -0
- package/dist/client.d.ts +152 -0
- package/dist/client.js +416 -0
- package/dist/cloudflare.d.ts +197 -0
- package/dist/cloudflare.js +159 -0
- package/dist/datalog/ast.d.ts +35 -0
- package/dist/datalog/ast.js +40 -0
- package/dist/datalog/evaluator.d.ts +14 -0
- package/dist/datalog/evaluator.js +395 -0
- package/dist/datalog/fact-source.d.ts +30 -0
- package/dist/datalog/fact-source.js +1 -0
- package/dist/datalog/fingerprint.d.ts +12 -0
- package/dist/datalog/fingerprint.js +50 -0
- package/dist/datalog/parser.d.ts +3 -0
- package/dist/datalog/parser.js +302 -0
- package/dist/datalog/value.d.ts +34 -0
- package/dist/datalog/value.js +104 -0
- package/dist/domain/date-validation.d.ts +2 -0
- package/dist/domain/date-validation.js +32 -0
- package/dist/domain/fact-value.d.ts +91 -0
- package/dist/domain/fact-value.js +167 -0
- package/dist/domain/fact.d.ts +14 -0
- package/dist/domain/fact.js +47 -0
- package/dist/domain/failure.d.ts +44 -0
- package/dist/domain/failure.js +30 -0
- package/dist/domain/graph-id.d.ts +7 -0
- package/dist/domain/graph-id.js +10 -0
- package/dist/domain/histogram.d.ts +29 -0
- package/dist/domain/histogram.js +48 -0
- package/dist/domain/identifiers.d.ts +26 -0
- package/dist/domain/identifiers.js +75 -0
- package/dist/domain/numbers.d.ts +12 -0
- package/dist/domain/numbers.js +77 -0
- package/dist/domain/projection.d.ts +252 -0
- package/dist/domain/projection.js +51 -0
- package/dist/domain/query-metrics.d.ts +31 -0
- package/dist/domain/query-metrics.js +35 -0
- package/dist/domain/read-token.d.ts +37 -0
- package/dist/domain/read-token.js +93 -0
- package/dist/domain/result.d.ts +22 -0
- package/dist/domain/result.js +16 -0
- package/dist/domain/schema-observation.d.ts +20 -0
- package/dist/domain/schema-observation.js +61 -0
- package/dist/domain/string-order.d.ts +2 -0
- package/dist/domain/string-order.js +15 -0
- package/dist/domain/vocabulary.d.ts +101 -0
- package/dist/domain/vocabulary.js +276 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +14 -0
- package/dist/projection-config.d.ts +3 -0
- package/dist/projection-config.js +212 -0
- package/dist/server/access.d.ts +32 -0
- package/dist/server/access.js +117 -0
- package/dist/server/admin.d.ts +233 -0
- package/dist/server/admin.js +483 -0
- package/dist/server/authorization.d.ts +35 -0
- package/dist/server/authorization.js +76 -0
- package/dist/server/console-assets.d.ts +6 -0
- package/dist/server/console-assets.js +2 -0
- package/dist/server/console.d.ts +8 -0
- package/dist/server/console.js +301 -0
- package/dist/server/index.d.ts +122 -0
- package/dist/server/index.js +487 -0
- package/dist/server/mcp.d.ts +31 -0
- package/dist/server/mcp.js +169 -0
- package/dist/server/telemetry-do.d.ts +31 -0
- package/dist/server/telemetry-do.js +342 -0
- package/dist/server/telemetry.d.ts +27 -0
- package/dist/server/telemetry.js +191 -0
- package/dist/storage/constants.d.ts +20 -0
- package/dist/storage/constants.js +21 -0
- package/dist/storage/environment.d.ts +438 -0
- package/dist/storage/environment.js +145 -0
- package/dist/storage/facts.d.ts +41 -0
- package/dist/storage/facts.js +73 -0
- package/dist/storage/http.d.ts +55 -0
- package/dist/storage/http.js +169 -0
- package/dist/storage/keys.d.ts +50 -0
- package/dist/storage/keys.js +84 -0
- package/dist/storage/layout.d.ts +67 -0
- package/dist/storage/layout.js +134 -0
- package/dist/storage/log.d.ts +41 -0
- package/dist/storage/log.js +137 -0
- package/dist/storage/manifest.d.ts +26 -0
- package/dist/storage/manifest.js +206 -0
- package/dist/storage/operations.d.ts +303 -0
- package/dist/storage/operations.js +719 -0
- package/dist/storage/partition.d.ts +125 -0
- package/dist/storage/partition.js +816 -0
- package/dist/storage/projection.d.ts +72 -0
- package/dist/storage/projection.js +1349 -0
- package/dist/storage/root.d.ts +120 -0
- package/dist/storage/root.js +596 -0
- package/dist/storage/segment.d.ts +145 -0
- package/dist/storage/segment.js +451 -0
- package/dist/storage/shard.d.ts +82 -0
- package/dist/storage/shard.js +710 -0
- package/dist/storage/source.d.ts +60 -0
- package/dist/storage/source.js +199 -0
- package/dist/telemetry/model.d.ts +123 -0
- package/dist/telemetry/model.js +292 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.js +6 -0
- package/package.json +82 -4
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { DurableObject } from "cloudflare:workers";
|
|
2
|
+
import type { FactDraft } from "../domain/fact.js";
|
|
3
|
+
import { type AppendInput, type AppendResult, type Claim, type Handoff, type HandoffInput, type PartitionRpc, type PartitionStats, type StorageEnv, type Tail } from "./environment.js";
|
|
4
|
+
import { type PartitionLayout } from "./layout.js";
|
|
5
|
+
import { type LogRows } from "./log.js";
|
|
6
|
+
export type { AppendInput, AppendResult, Claim, Handoff, HandoffInput, PartitionStats, Tail, TokenRecord, } from "./environment.js";
|
|
7
|
+
export declare class PartitionDO extends DurableObject<StorageEnv> implements PartitionRpc {
|
|
8
|
+
private readonly sql;
|
|
9
|
+
private rows;
|
|
10
|
+
private known;
|
|
11
|
+
private lastIndexerStart;
|
|
12
|
+
private lastImmediateStart;
|
|
13
|
+
private readonly state;
|
|
14
|
+
private readonly work;
|
|
15
|
+
private readonly service;
|
|
16
|
+
private readonly counters;
|
|
17
|
+
constructor(ctx: DurableObjectState, env: StorageEnv);
|
|
18
|
+
private load;
|
|
19
|
+
private remember;
|
|
20
|
+
private rememberGraph;
|
|
21
|
+
/**
|
|
22
|
+
* Takes a newer layout, and keeps it before answering: a partition that knows a layout refuses
|
|
23
|
+
* tokens whose home it is not (rule claimsFence). A partition the layout added closes the epochs
|
|
24
|
+
* before its era (rule newPartitionsStartAtTheirEpoch).
|
|
25
|
+
*/
|
|
26
|
+
private learn;
|
|
27
|
+
/** Index shards keep themselves scheduled; partitions ask the root to start them and learn its published watermark. */
|
|
28
|
+
private ensureIndexer;
|
|
29
|
+
private noteIndexed;
|
|
30
|
+
private countCall;
|
|
31
|
+
private callsIn;
|
|
32
|
+
private scheduleCheck;
|
|
33
|
+
/** The index check: starts the shards if the index has not reached every row held, trims, and stays set while rows are held. */
|
|
34
|
+
alarm(): Promise<void>;
|
|
35
|
+
private setState;
|
|
36
|
+
append(input: AppendInput): Promise<AppendResult>;
|
|
37
|
+
/** Stores the write with the next group commit, briefly coalescing under sustained load to cut SQLite row writes. */
|
|
38
|
+
private enqueue;
|
|
39
|
+
/**
|
|
40
|
+
* The token moved here within the token window: asks its earlier homes first (rule
|
|
41
|
+
* movedTokensAreClaimed). One that holds it answers the write; otherwise none of them will store
|
|
42
|
+
* it from now on, and it is stored here.
|
|
43
|
+
*/
|
|
44
|
+
private claimThenStore;
|
|
45
|
+
/**
|
|
46
|
+
* Another partition, now the token's home, asks whether this one holds it. Keeps the asker's
|
|
47
|
+
* layout first, so from now on this partition refuses the token (rule claimsFence), and waits for
|
|
48
|
+
* a write of the token it is storing.
|
|
49
|
+
*/
|
|
50
|
+
claim(input: Readonly<{
|
|
51
|
+
graph: string;
|
|
52
|
+
partition: number;
|
|
53
|
+
tokenHash: string;
|
|
54
|
+
layout: PartitionLayout;
|
|
55
|
+
}>): Promise<Claim>;
|
|
56
|
+
/**
|
|
57
|
+
* Partition 0 only: keeps a layout the root is about to publish, starting its newest era one past
|
|
58
|
+
* the last epoch this partition closed (rule layoutThroughPartitionZero). No shard's watermark
|
|
59
|
+
* is past that epoch, since every shard reads this partition on every flush. Called again with
|
|
60
|
+
* the same version, as a root that restarted does, it answers the epoch it chose.
|
|
61
|
+
*/
|
|
62
|
+
install(input: Readonly<{
|
|
63
|
+
graph: string;
|
|
64
|
+
partition: number;
|
|
65
|
+
layout: PartitionLayout;
|
|
66
|
+
}>): Promise<Readonly<{
|
|
67
|
+
since: number;
|
|
68
|
+
at: number;
|
|
69
|
+
}>>;
|
|
70
|
+
/** The answer to a write whose client request token is already stored: the first write, or a conflict. */
|
|
71
|
+
private replay;
|
|
72
|
+
private rememberToken;
|
|
73
|
+
/** Commits what is pending as one atomic SQLite transaction, waits until durable, then takes what arrived meanwhile. */
|
|
74
|
+
private flush;
|
|
75
|
+
private insertRow;
|
|
76
|
+
/**
|
|
77
|
+
* Closes the epochs before the current one and hands an index shard the facts in its buckets
|
|
78
|
+
* above `from`, whole epochs at a time, until it has read about `maxFacts` facts or handed about
|
|
79
|
+
* `maxBytes` bytes of them: a shard that falls behind catches up in steps both sides can hold,
|
|
80
|
+
* instead of asking for everything at once. The closed epoch is stored before it is reported (rule
|
|
81
|
+
* closedEpochsStayClosed), and later writes are stamped above it.
|
|
82
|
+
*/
|
|
83
|
+
handoff(input: HandoffInput): Promise<Handoff>;
|
|
84
|
+
/** The session's transactions above the reader's watermark, and how far rows are deleted. (Not `tail`: Workers reserve that name for Tail Workers.) */
|
|
85
|
+
sessionTail(input: Readonly<{
|
|
86
|
+
session: string;
|
|
87
|
+
watermark: number;
|
|
88
|
+
}>): Promise<Tail>;
|
|
89
|
+
/** Transactions in epochs above `epoch`, in key order, parsing rows only as they are reached. */
|
|
90
|
+
private txsAbove;
|
|
91
|
+
private rememberParsed;
|
|
92
|
+
watermark(input: Readonly<{
|
|
93
|
+
watermark: number;
|
|
94
|
+
}>): Promise<void>;
|
|
95
|
+
/** The rows above `after`, as the graph's log reader reads them, and how far rows are archived. */
|
|
96
|
+
logRows(input: Readonly<{
|
|
97
|
+
after: number;
|
|
98
|
+
limit: number;
|
|
99
|
+
}>): Promise<LogRows>;
|
|
100
|
+
/**
|
|
101
|
+
* The highest row whose transactions are all at or below `watermark`, so a backfill can anchor
|
|
102
|
+
* live log tailing at `watermark` without scanning earlier history.
|
|
103
|
+
*/
|
|
104
|
+
logHead(input: Readonly<{
|
|
105
|
+
watermark: number;
|
|
106
|
+
}>): Promise<Readonly<{
|
|
107
|
+
seq: number;
|
|
108
|
+
ts: number;
|
|
109
|
+
offset: number;
|
|
110
|
+
archived: number;
|
|
111
|
+
}>>;
|
|
112
|
+
/** One trim at a time: the index check and the root's watermark both start one. */
|
|
113
|
+
private trim;
|
|
114
|
+
/**
|
|
115
|
+
* Writes the rows the index holds and the token window has passed to the graph's log, in chunks
|
|
116
|
+
* of at most MAX_CHUNK_BYTES, then deletes them. Small chunks coalesce until MIN_ARCHIVE_BYTES,
|
|
117
|
+
* MIN_ARCHIVE_ROWS, or the coalesce age backstop to avoid tiny R2 Class A PUTs. A chunk starts
|
|
118
|
+
* after the last row archived, which is stored only once its PUT succeeded: a retry after a
|
|
119
|
+
* crash writes the same key again, with at least the rows it had, so chunks never overlap.
|
|
120
|
+
*/
|
|
121
|
+
private archiveAndTrim;
|
|
122
|
+
stats(): Promise<PartitionStats>;
|
|
123
|
+
}
|
|
124
|
+
/** About how many bytes a fact takes as a WireFact in JSON: what bounds a handoff, and the shard's memory with it. */
|
|
125
|
+
export declare function factBytes(f: FactDraft): number;
|