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.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +264 -2
  3. package/dist/bin.d.ts +2 -0
  4. package/dist/bin.js +3 -0
  5. package/dist/cli.d.ts +15 -0
  6. package/dist/cli.js +256 -0
  7. package/dist/client.d.ts +152 -0
  8. package/dist/client.js +416 -0
  9. package/dist/cloudflare.d.ts +197 -0
  10. package/dist/cloudflare.js +159 -0
  11. package/dist/datalog/ast.d.ts +35 -0
  12. package/dist/datalog/ast.js +40 -0
  13. package/dist/datalog/evaluator.d.ts +14 -0
  14. package/dist/datalog/evaluator.js +395 -0
  15. package/dist/datalog/fact-source.d.ts +30 -0
  16. package/dist/datalog/fact-source.js +1 -0
  17. package/dist/datalog/fingerprint.d.ts +12 -0
  18. package/dist/datalog/fingerprint.js +50 -0
  19. package/dist/datalog/parser.d.ts +3 -0
  20. package/dist/datalog/parser.js +302 -0
  21. package/dist/datalog/value.d.ts +34 -0
  22. package/dist/datalog/value.js +104 -0
  23. package/dist/domain/date-validation.d.ts +2 -0
  24. package/dist/domain/date-validation.js +32 -0
  25. package/dist/domain/fact-value.d.ts +91 -0
  26. package/dist/domain/fact-value.js +167 -0
  27. package/dist/domain/fact.d.ts +14 -0
  28. package/dist/domain/fact.js +47 -0
  29. package/dist/domain/failure.d.ts +44 -0
  30. package/dist/domain/failure.js +30 -0
  31. package/dist/domain/graph-id.d.ts +7 -0
  32. package/dist/domain/graph-id.js +10 -0
  33. package/dist/domain/histogram.d.ts +29 -0
  34. package/dist/domain/histogram.js +48 -0
  35. package/dist/domain/identifiers.d.ts +26 -0
  36. package/dist/domain/identifiers.js +75 -0
  37. package/dist/domain/numbers.d.ts +12 -0
  38. package/dist/domain/numbers.js +77 -0
  39. package/dist/domain/projection.d.ts +252 -0
  40. package/dist/domain/projection.js +51 -0
  41. package/dist/domain/query-metrics.d.ts +31 -0
  42. package/dist/domain/query-metrics.js +35 -0
  43. package/dist/domain/read-token.d.ts +37 -0
  44. package/dist/domain/read-token.js +93 -0
  45. package/dist/domain/result.d.ts +22 -0
  46. package/dist/domain/result.js +16 -0
  47. package/dist/domain/schema-observation.d.ts +20 -0
  48. package/dist/domain/schema-observation.js +61 -0
  49. package/dist/domain/string-order.d.ts +2 -0
  50. package/dist/domain/string-order.js +15 -0
  51. package/dist/domain/vocabulary.d.ts +101 -0
  52. package/dist/domain/vocabulary.js +276 -0
  53. package/dist/index.d.ts +15 -0
  54. package/dist/index.js +14 -0
  55. package/dist/projection-config.d.ts +3 -0
  56. package/dist/projection-config.js +212 -0
  57. package/dist/server/access.d.ts +32 -0
  58. package/dist/server/access.js +117 -0
  59. package/dist/server/admin.d.ts +233 -0
  60. package/dist/server/admin.js +483 -0
  61. package/dist/server/authorization.d.ts +35 -0
  62. package/dist/server/authorization.js +76 -0
  63. package/dist/server/console-assets.d.ts +6 -0
  64. package/dist/server/console-assets.js +2 -0
  65. package/dist/server/console.d.ts +8 -0
  66. package/dist/server/console.js +301 -0
  67. package/dist/server/index.d.ts +122 -0
  68. package/dist/server/index.js +487 -0
  69. package/dist/server/mcp.d.ts +31 -0
  70. package/dist/server/mcp.js +169 -0
  71. package/dist/server/telemetry-do.d.ts +31 -0
  72. package/dist/server/telemetry-do.js +342 -0
  73. package/dist/server/telemetry.d.ts +27 -0
  74. package/dist/server/telemetry.js +191 -0
  75. package/dist/storage/constants.d.ts +20 -0
  76. package/dist/storage/constants.js +21 -0
  77. package/dist/storage/environment.d.ts +438 -0
  78. package/dist/storage/environment.js +145 -0
  79. package/dist/storage/facts.d.ts +41 -0
  80. package/dist/storage/facts.js +73 -0
  81. package/dist/storage/http.d.ts +55 -0
  82. package/dist/storage/http.js +169 -0
  83. package/dist/storage/keys.d.ts +50 -0
  84. package/dist/storage/keys.js +84 -0
  85. package/dist/storage/layout.d.ts +67 -0
  86. package/dist/storage/layout.js +134 -0
  87. package/dist/storage/log.d.ts +41 -0
  88. package/dist/storage/log.js +137 -0
  89. package/dist/storage/manifest.d.ts +26 -0
  90. package/dist/storage/manifest.js +206 -0
  91. package/dist/storage/operations.d.ts +303 -0
  92. package/dist/storage/operations.js +719 -0
  93. package/dist/storage/partition.d.ts +125 -0
  94. package/dist/storage/partition.js +816 -0
  95. package/dist/storage/projection.d.ts +72 -0
  96. package/dist/storage/projection.js +1349 -0
  97. package/dist/storage/root.d.ts +120 -0
  98. package/dist/storage/root.js +596 -0
  99. package/dist/storage/segment.d.ts +145 -0
  100. package/dist/storage/segment.js +451 -0
  101. package/dist/storage/shard.d.ts +82 -0
  102. package/dist/storage/shard.js +710 -0
  103. package/dist/storage/source.d.ts +60 -0
  104. package/dist/storage/source.js +199 -0
  105. package/dist/telemetry/model.d.ts +123 -0
  106. package/dist/telemetry/model.js +292 -0
  107. package/dist/version.d.ts +4 -0
  108. package/dist/version.js +6 -0
  109. package/package.json +82 -4
@@ -0,0 +1,120 @@
1
+ import { DurableObject } from "cloudflare:workers";
2
+ import { type ReportAnswer, type RootRpc, type RootStatus, type ShardReport, type StorageEnv } from "./environment.js";
3
+ import { type Layout } from "./layout.js";
4
+ export type { Load, ReportAnswer, RootStatus, ShardReport } from "./environment.js";
5
+ export declare function growthTarget(input: Readonly<{
6
+ partitions: number;
7
+ callsPerSecond: number | null;
8
+ overloaded: boolean;
9
+ growAboveCalls: number;
10
+ }>): number | null;
11
+ export declare class GraphRootDO extends DurableObject<StorageEnv> implements RootRpc {
12
+ private readonly sql;
13
+ private graph;
14
+ private current;
15
+ private readonly shards;
16
+ private readonly publish;
17
+ private readonly scaling;
18
+ private readonly counters;
19
+ private readonly errors;
20
+ /** Why this root cannot take calls: a layout of 0.1 that no layout here can hold. */
21
+ private unreadable;
22
+ constructor(ctx: DurableObjectState, env: StorageEnv);
23
+ private load;
24
+ /**
25
+ * A root written before layouts could change kept a fixed one, `layout`, and its shards' reports
26
+ * by shard number, `shards`: their layout is the first of the graph's, and their shards the
27
+ * leaves of a full tree (layout.ts), so the graph keeps its data.
28
+ */
29
+ private adoptFixedLayout;
30
+ private remember;
31
+ /**
32
+ * Stores the root's state with these changes, then takes them: what the root acts on is always
33
+ * what it stored, so a write storage refuses changes nothing a restart would undo.
34
+ */
35
+ private requireGraph;
36
+ private requireLayout;
37
+ private store;
38
+ /** The graph's layout, made on first use with the instance's initial partitions and one index shard, or the counts given. */
39
+ layout(input: Readonly<{
40
+ graph: string;
41
+ partitions?: number;
42
+ shards?: number;
43
+ }>): Promise<Layout>;
44
+ /**
45
+ * Makes the graph's layout, and an empty manifest so the graph is listed before its first write.
46
+ * An operator who knows the load to come may give it more partitions or shards to start with.
47
+ */
48
+ create(input: Readonly<{
49
+ graph: string;
50
+ partitions?: number;
51
+ shards?: number;
52
+ }>): Promise<Readonly<{
53
+ layout: Layout;
54
+ created: boolean;
55
+ }>>;
56
+ report(input: ShardReport): Promise<ReportAnswer>;
57
+ /**
58
+ * Sets the alarm that writes the next manifest. It counts as set from the call on, so reports
59
+ * meanwhile do not set it again, and is forgotten if storage refuses it: a report or an alarm
60
+ * retry sets it again, instead of every later report taking it as set.
61
+ */
62
+ private schedule;
63
+ /** A Worker saw a partition refuse a call because it was overloaded. */
64
+ overloaded(input: Readonly<{
65
+ graph: string;
66
+ }>): Promise<void>;
67
+ /**
68
+ * Starts the index shards and answers the published watermark so restarted partitions can trim.
69
+ * Publishing a manifest clears the start throttle (specs/shard-idle-wake.spock), so a write
70
+ * arriving right after a shard stops on a clean confirm tick immediately wakes it.
71
+ */
72
+ ensureIndexing(input: Readonly<{
73
+ graph: string;
74
+ immediate?: boolean;
75
+ force?: boolean;
76
+ }>): Promise<Readonly<{
77
+ watermark: number;
78
+ }>>;
79
+ private startShards;
80
+ /** Grows the graph to `partitions` now, as its load would. For operators and tests. */
81
+ resize(input: Readonly<{
82
+ graph: string;
83
+ partitions: number;
84
+ }>): Promise<Layout>;
85
+ /** Splits an index shard now, as its asking would. For operators and tests. */
86
+ split(input: Readonly<{
87
+ graph: string;
88
+ prefix: number;
89
+ }>): Promise<Layout>;
90
+ private considerGrowth;
91
+ private considerSplit;
92
+ /** Installs a layout with more partitions in partition 0, then publishes it with the epoch partition 0 chose. */
93
+ private grow;
94
+ private publishGrowth;
95
+ private fail;
96
+ /** The lowest watermark of the layout's shards, once each has reported; until then, what was published. */
97
+ private graphWatermark;
98
+ /**
99
+ * Each bucket's segments, from the shard that owns it, or from the deepest ancestor that still
100
+ * owns it when the new half has never reported yet. Once the owning shard has reported, its
101
+ * bucket list is authoritative (an omitted bucket was compacted to empty and must not fall back).
102
+ */
103
+ private manifestBuckets;
104
+ private putManifest;
105
+ /**
106
+ * Syncs `published` from R2 once after boot or a failed SQL update so a restart or split never
107
+ * overwrites R2's manifest with a lower watermark.
108
+ */
109
+ private syncPublishedFromR2;
110
+ alarm(): Promise<void>;
111
+ /**
112
+ * Wakes every configured projection matching this graph once the manifest passes what it was last
113
+ * woken for. Returns whether any wake failed so the root schedules a retry alarm (RFD0016,
114
+ * specs/projection-delivery.spock).
115
+ */
116
+ private notifyProjections;
117
+ /** Partitions only need the watermark to trim, so a slow partition must not hold up the next manifest. */
118
+ private notifyPartitions;
119
+ status(): Promise<RootStatus>;
120
+ }