@hypercarrier/pi-team-durable 0.0.0-stage → 0.1.0-rc.2

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 (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +209 -2
  3. package/dist/authority/anchor.d.ts +10 -0
  4. package/dist/authority/anchor.js +19 -0
  5. package/dist/authority/card-types.d.ts +152 -0
  6. package/dist/authority/card-types.js +123 -0
  7. package/dist/authority/contracts.d.ts +19 -0
  8. package/dist/authority/contracts.js +45 -0
  9. package/dist/authority/delivery.d.ts +60 -0
  10. package/dist/authority/delivery.js +158 -0
  11. package/dist/authority/graph-card.d.ts +4 -0
  12. package/dist/authority/graph-card.js +39 -0
  13. package/dist/authority/graph-control.d.ts +299 -0
  14. package/dist/authority/graph-control.js +1009 -0
  15. package/dist/authority/incremental-graph-control.d.ts +156 -0
  16. package/dist/authority/incremental-graph-control.js +1051 -0
  17. package/dist/authority/index.d.ts +15 -0
  18. package/dist/authority/index.js +15 -0
  19. package/dist/authority/interrupt.d.ts +11 -0
  20. package/dist/authority/interrupt.js +26 -0
  21. package/dist/authority/limits.d.ts +7 -0
  22. package/dist/authority/limits.js +7 -0
  23. package/dist/authority/notifier.d.ts +32 -0
  24. package/dist/authority/notifier.js +89 -0
  25. package/dist/authority/observation-store.d.ts +104 -0
  26. package/dist/authority/observation-store.js +226 -0
  27. package/dist/authority/observation.d.ts +13 -0
  28. package/dist/authority/observation.js +143 -0
  29. package/dist/authority/panel.d.ts +121 -0
  30. package/dist/authority/panel.js +44 -0
  31. package/dist/authority/projection.d.ts +5 -0
  32. package/dist/authority/projection.js +15 -0
  33. package/dist/authority/rc7-contract.json +9390 -0
  34. package/dist/authority/runtime.d.ts +106 -0
  35. package/dist/authority/runtime.js +115 -0
  36. package/dist/authority/state.d.ts +165 -0
  37. package/dist/authority/state.js +28 -0
  38. package/dist/authority/store.d.ts +144 -0
  39. package/dist/authority/store.js +675 -0
  40. package/dist/authority/sync.d.ts +13 -0
  41. package/dist/authority/sync.js +78 -0
  42. package/dist/authority/task-version-ref.d.ts +3 -0
  43. package/dist/authority/task-version-ref.js +5 -0
  44. package/dist/authority/tools.d.ts +105 -0
  45. package/dist/authority/tools.js +302 -0
  46. package/dist/testing.d.ts +11 -0
  47. package/dist/testing.js +10 -0
  48. package/package.json +63 -4
@@ -0,0 +1,156 @@
1
+ import { type GraphVersionRef, type GraphApplyInput, type GraphTaskTransitionInput, type GraphTaskState, type GraphTaskView, type GraphAttemptView, type GraphRevision, type GraphControlEvent, type GraphApplyResult, type GraphTransitionResult, type GraphControlSnapshot } from "./graph-control.ts";
2
+ type StoredTaskDefinition = GraphRevision["tasks"][number];
3
+ type StoredReceipt = GraphControlSnapshot["receipts"][number];
4
+ type EventOf<K extends GraphControlEvent["kind"]> = Extract<GraphControlEvent, {
5
+ kind: K;
6
+ }>;
7
+ type AttemptStartedEvent = EventOf<"attempt_started">;
8
+ type AttemptBlockedEvent = EventOf<"attempt_blocked">;
9
+ type AttemptResumedEvent = EventOf<"attempt_resumed">;
10
+ type AttemptCompletedEvent = EventOf<"attempt_completed">;
11
+ type AttemptSupersededEvent = EventOf<"attempt_superseded">;
12
+ type TaskCancelledEvent = EventOf<"task_cancelled">;
13
+ type FailureEdgeExhaustedEvent = EventOf<"failure_edge_exhausted">;
14
+ interface AttemptFold {
15
+ started: AttemptStartedEvent;
16
+ blocked?: AttemptBlockedEvent;
17
+ resumed?: AttemptResumedEvent;
18
+ completed?: AttemptCompletedEvent;
19
+ superseded?: AttemptSupersededEvent;
20
+ cancellation?: TaskCancelledEvent;
21
+ exhausted?: FailureEdgeExhaustedEvent;
22
+ endedAt?: string;
23
+ endedSequence?: number;
24
+ }
25
+ interface DerivedTask {
26
+ definition: StoredTaskDefinition;
27
+ state: GraphTaskState;
28
+ activationKey?: string;
29
+ inputAttemptIds: Record<string, string>;
30
+ acceptedAttemptId?: string;
31
+ attemptsStarted: number;
32
+ }
33
+ declare function digest(value: unknown): string;
34
+ interface TaskNode {
35
+ definition: StoredTaskDefinition;
36
+ cancellation?: TaskCancelledEvent;
37
+ currentContext?: string;
38
+ demand: number;
39
+ traversals: number;
40
+ activations: Map<string, AttemptFold>;
41
+ derived?: DerivedTask;
42
+ view?: GraphTaskView;
43
+ }
44
+ /** Current-state representation. History and replay receipts have separate owners. */
45
+ export interface GraphMaterializedHead {
46
+ sequence: number;
47
+ revision?: Omit<GraphRevision, "tasks">;
48
+ topology: Array<{
49
+ key: string;
50
+ needs: string[];
51
+ }>;
52
+ projections: Record<string, string>;
53
+ ready: Record<string, string[]>;
54
+ occupied: Record<string, string[]>;
55
+ }
56
+ export interface GraphMaterializedTask {
57
+ id: string;
58
+ attemptsStarted: number;
59
+ node?: Omit<TaskNode, "activations">;
60
+ attempts: AttemptFold[];
61
+ }
62
+ export declare class GraphTaskRequired extends Error {
63
+ readonly ids: string[];
64
+ constructor(ids: string[]);
65
+ }
66
+ export declare class IncrementalGraphTaskController {
67
+ private readonly graphRevisions;
68
+ private readonly events;
69
+ private readonly receipts;
70
+ private readonly attempts;
71
+ private readonly attemptCounts;
72
+ private readonly activeAttempts;
73
+ private nodes;
74
+ private dependents;
75
+ private ranks;
76
+ private readonly dirty;
77
+ private readonly ready;
78
+ private readonly occupied;
79
+ private sequence;
80
+ private projections;
81
+ private readonly changed;
82
+ private restoredRevisionCount;
83
+ private structuralTasks;
84
+ private commandRecordedAt?;
85
+ private readonly clock;
86
+ constructor(clock?: () => Date);
87
+ /** Migration only. The caller validates the source with the reference controller. */
88
+ static fromSnapshot(snapshot: GraphControlSnapshot, clock?: () => Date): IncrementalGraphTaskController;
89
+ static restore(head: GraphMaterializedHead, records: ReadonlyMap<string, GraphMaterializedTask>, clock?: () => Date): IncrementalGraphTaskController;
90
+ headUpdate(): {
91
+ sequence: number;
92
+ projections: {
93
+ [k: string]: string;
94
+ };
95
+ ready: {
96
+ [k: string]: string[];
97
+ };
98
+ occupied: {
99
+ [k: string]: string[];
100
+ };
101
+ };
102
+ materializedHead(): GraphMaterializedHead;
103
+ materializedTask(id: string): GraphMaterializedTask;
104
+ changes(): {
105
+ taskIds: string[];
106
+ revisions: GraphRevision[];
107
+ events: GraphControlEvent[];
108
+ receipts: import("./graph-control.ts").StoredReceipt[];
109
+ };
110
+ restoreReceipt(receipt: StoredReceipt): void;
111
+ snapshot(): GraphControlSnapshot;
112
+ currentGraphVersion(): GraphVersionRef | undefined;
113
+ hasOperationReceipt(operationId: string): boolean;
114
+ applyGraph(input: GraphApplyInput): GraphApplyResult & {
115
+ replayed: boolean;
116
+ };
117
+ transition(input: GraphTaskTransitionInput): GraphTransitionResult & {
118
+ replayed: boolean;
119
+ };
120
+ readTask(taskId: string): GraphTaskView;
121
+ readTasks(): GraphTaskView[];
122
+ attemptStartedSequence(id: string): number;
123
+ readAttempts(taskId?: string): GraphAttemptView[];
124
+ selectReadyFrontier(): GraphTaskView[];
125
+ trace(): {
126
+ graphRevisions: GraphRevision[];
127
+ tasks: GraphTaskView[];
128
+ attempts: GraphAttemptView[];
129
+ events: GraphControlEvent[];
130
+ };
131
+ private claim;
132
+ private block;
133
+ private resume;
134
+ private complete;
135
+ private cancel;
136
+ private assertWorker;
137
+ private invalid;
138
+ private command;
139
+ private append;
140
+ private nextSequence;
141
+ private currentRevision;
142
+ private definition;
143
+ private installGraph;
144
+ private fold;
145
+ private rebuild;
146
+ private flush;
147
+ private indexView;
148
+ private readyIds;
149
+ private occupiedTask;
150
+ private activeAttemptIds;
151
+ private attemptsToSupersede;
152
+ private deriveNode;
153
+ private toView;
154
+ }
155
+ export declare function prerequisiteProjection(task: DerivedTask | undefined): string;
156
+ export { digest as graphControlFingerprint };