@hunterzhu/pulse-runtime 0.1.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/dist/context/builder.d.ts +68 -0
- package/dist/context/builder.js +127 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.js +2 -0
- package/dist/context/merger.d.ts +25 -0
- package/dist/context/merger.js +125 -0
- package/dist/core/actions.d.ts +1 -0
- package/dist/core/actions.js +1 -0
- package/dist/core/errors.d.ts +8 -0
- package/dist/core/errors.js +36 -0
- package/dist/core/events.d.ts +10 -0
- package/dist/core/events.js +24 -0
- package/dist/core/factory.d.ts +35 -0
- package/dist/core/factory.js +27 -0
- package/dist/core/inbox.d.ts +119 -0
- package/dist/core/inbox.js +217 -0
- package/dist/core/mutations.d.ts +80 -0
- package/dist/core/mutations.js +127 -0
- package/dist/core/records.d.ts +1 -0
- package/dist/core/records.js +1 -0
- package/dist/core/types.d.ts +615 -0
- package/dist/core/types.js +109 -0
- package/dist/dependencies/graph.d.ts +25 -0
- package/dist/dependencies/graph.js +92 -0
- package/dist/dependencies/index.d.ts +1 -0
- package/dist/dependencies/index.js +1 -0
- package/dist/dsl/context-proxy.d.ts +20 -0
- package/dist/dsl/context-proxy.js +64 -0
- package/dist/dsl/index.d.ts +4 -0
- package/dist/dsl/index.js +4 -0
- package/dist/dsl/program.d.ts +314 -0
- package/dist/dsl/program.js +756 -0
- package/dist/dsl/session.d.ts +45 -0
- package/dist/dsl/session.js +93 -0
- package/dist/dsl/templates-index.d.ts +1 -0
- package/dist/dsl/templates-index.js +1 -0
- package/dist/dsl/templates.d.ts +85 -0
- package/dist/dsl/templates.js +110 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +15 -0
- package/dist/lifecycle/index.d.ts +2 -0
- package/dist/lifecycle/index.js +2 -0
- package/dist/lifecycle/scopes.d.ts +38 -0
- package/dist/lifecycle/scopes.js +50 -0
- package/dist/lifecycle/watchdog.d.ts +16 -0
- package/dist/lifecycle/watchdog.js +66 -0
- package/dist/models/actions.d.ts +10 -0
- package/dist/models/actions.js +68 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.js +2 -0
- package/dist/models/router.d.ts +187 -0
- package/dist/models/router.js +353 -0
- package/dist/scheduler/clock.d.ts +45 -0
- package/dist/scheduler/clock.js +92 -0
- package/dist/scheduler/decision.d.ts +72 -0
- package/dist/scheduler/decision.js +63 -0
- package/dist/scheduler/index.d.ts +6 -0
- package/dist/scheduler/index.js +6 -0
- package/dist/scheduler/locks.d.ts +18 -0
- package/dist/scheduler/locks.js +106 -0
- package/dist/scheduler/ready-queue.d.ts +32 -0
- package/dist/scheduler/ready-queue.js +40 -0
- package/dist/scheduler/runtime.d.ts +486 -0
- package/dist/scheduler/runtime.js +3445 -0
- package/dist/scheduler/telemetry.d.ts +111 -0
- package/dist/scheduler/telemetry.js +177 -0
- package/dist/scheduler/worker.d.ts +158 -0
- package/dist/scheduler/worker.js +744 -0
- package/dist/storage/artifacts.d.ts +17 -0
- package/dist/storage/artifacts.js +90 -0
- package/dist/storage/findings.d.ts +12 -0
- package/dist/storage/findings.js +70 -0
- package/dist/storage/index.d.ts +8 -0
- package/dist/storage/index.js +8 -0
- package/dist/storage/memory.d.ts +11 -0
- package/dist/storage/memory.js +21 -0
- package/dist/storage/mutation-log.d.ts +41 -0
- package/dist/storage/mutation-log.js +140 -0
- package/dist/storage/outbox.d.ts +30 -0
- package/dist/storage/outbox.js +59 -0
- package/dist/storage/persistence.d.ts +183 -0
- package/dist/storage/persistence.js +999 -0
- package/dist/storage/policy.d.ts +80 -0
- package/dist/storage/policy.js +268 -0
- package/dist/storage/session.d.ts +140 -0
- package/dist/storage/session.js +447 -0
- package/dist/tools/registry.d.ts +125 -0
- package/dist/tools/registry.js +308 -0
- package/dist/transitions/index.d.ts +2 -0
- package/dist/transitions/index.js +1 -0
- package/dist/transitions/validate.d.ts +4 -0
- package/dist/transitions/validate.js +1118 -0
- package/package.json +21 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { JsonValue, RuntimeEvent, RuntimeState } from '../core/types.js';
|
|
2
|
+
import { type FactInboxDedupeArchiveBatch, type FactInboxDedupeArchiveWriter, type FactInboxSnapshot } from '../core/inbox.js';
|
|
3
|
+
import { FileRuntimeSessionStore, SqliteRuntimeSessionStore, type RuntimeSessionStore, type SessionSnapshot } from './session.js';
|
|
4
|
+
import { EffectOutbox, type OutboxSnapshot } from './outbox.js';
|
|
5
|
+
import { MutationLog, type MutationLogSnapshot } from './mutation-log.js';
|
|
6
|
+
import type { QuarantineEntry, QuarantineScope } from '../lifecycle/scopes.js';
|
|
7
|
+
import { SessionStoragePolicy, type StoragePolicySnapshot } from './policy.js';
|
|
8
|
+
export interface RuntimePersistenceSnapshot {
|
|
9
|
+
schemaVersion: 1;
|
|
10
|
+
state: SessionSnapshot;
|
|
11
|
+
mutationLog: MutationLogSnapshot;
|
|
12
|
+
outbox: OutboxSnapshot;
|
|
13
|
+
quarantine?: QuarantineEntry[];
|
|
14
|
+
storage?: StoragePolicySnapshot;
|
|
15
|
+
factInbox?: FactInboxSnapshot;
|
|
16
|
+
snapshotBodies?: 'inline' | 'external';
|
|
17
|
+
externalSnapshotRefs?: string[];
|
|
18
|
+
checkpoint?: {
|
|
19
|
+
schemaVersion: 1;
|
|
20
|
+
logWatermark: number;
|
|
21
|
+
eventWatermark?: number;
|
|
22
|
+
state: SessionSnapshot;
|
|
23
|
+
};
|
|
24
|
+
resultBodies?: 'inline' | 'external';
|
|
25
|
+
externalResultRefs?: string[];
|
|
26
|
+
eventArchive?: {
|
|
27
|
+
through: number;
|
|
28
|
+
};
|
|
29
|
+
compatibility?: RuntimePersistenceCompatibility;
|
|
30
|
+
integrity?: {
|
|
31
|
+
algorithm: 'sha256';
|
|
32
|
+
digest: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface RuntimePersistenceCompatibility {
|
|
36
|
+
schemaVersion: 1;
|
|
37
|
+
programVersions: Record<string, string>;
|
|
38
|
+
toolVersions: Record<string, string>;
|
|
39
|
+
policyVersion?: string;
|
|
40
|
+
routerVersion?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface RuntimeResultStore {
|
|
43
|
+
save(ref: string, value: JsonValue): Promise<void>;
|
|
44
|
+
load(ref: string): Promise<JsonValue | undefined>;
|
|
45
|
+
}
|
|
46
|
+
export interface RuntimeSnapshotStore {
|
|
47
|
+
save(ref: string, value: JsonValue): Promise<void>;
|
|
48
|
+
load(ref: string): Promise<JsonValue | undefined>;
|
|
49
|
+
}
|
|
50
|
+
export interface RuntimeEventArchive {
|
|
51
|
+
append(events: RuntimeEvent[]): Promise<void>;
|
|
52
|
+
read(fromSeq: number, toSeq?: number): Promise<RuntimeEvent[]>;
|
|
53
|
+
}
|
|
54
|
+
/** Atomic, idempotent file-backed body store usable as both ResultStore and SnapshotStore. */
|
|
55
|
+
export declare class FileRuntimeContentStore implements RuntimeResultStore, RuntimeSnapshotStore {
|
|
56
|
+
readonly directory: string;
|
|
57
|
+
constructor(directory: string);
|
|
58
|
+
save(ref: string, value: JsonValue): Promise<void>;
|
|
59
|
+
load(ref: string): Promise<JsonValue | undefined>;
|
|
60
|
+
private pathFor;
|
|
61
|
+
private readEnvelope;
|
|
62
|
+
private withLock;
|
|
63
|
+
}
|
|
64
|
+
/** SQLite-backed result/snapshot body store with idempotent writes and conflict detection. */
|
|
65
|
+
export declare class SqliteRuntimeContentStore implements RuntimeResultStore, RuntimeSnapshotStore {
|
|
66
|
+
readonly filePath: string;
|
|
67
|
+
readonly namespace: 'result' | 'snapshot';
|
|
68
|
+
private database;
|
|
69
|
+
private tail;
|
|
70
|
+
constructor(filePath: string, namespace: 'result' | 'snapshot');
|
|
71
|
+
save(ref: string, value: JsonValue): Promise<void>;
|
|
72
|
+
load(ref: string): Promise<JsonValue | undefined>;
|
|
73
|
+
close(): Promise<void>;
|
|
74
|
+
private open;
|
|
75
|
+
private enqueue;
|
|
76
|
+
}
|
|
77
|
+
/** SQLite-backed fact event archive with idempotent sequence append and range reads. */
|
|
78
|
+
export declare class SqliteRuntimeEventArchive implements RuntimeEventArchive {
|
|
79
|
+
readonly filePath: string;
|
|
80
|
+
private database;
|
|
81
|
+
private tail;
|
|
82
|
+
constructor(filePath: string);
|
|
83
|
+
append(events: RuntimeEvent[]): Promise<void>;
|
|
84
|
+
read(fromSeq: number, toSeq?: number): Promise<RuntimeEvent[]>;
|
|
85
|
+
close(): Promise<void>;
|
|
86
|
+
private open;
|
|
87
|
+
private enqueue;
|
|
88
|
+
}
|
|
89
|
+
/** Atomic file-backed EventArchive with idempotent sequence append and range reads. */
|
|
90
|
+
export declare class FileRuntimeEventArchive implements RuntimeEventArchive {
|
|
91
|
+
readonly directory: string;
|
|
92
|
+
private readonly filePath;
|
|
93
|
+
constructor(directory: string);
|
|
94
|
+
append(events: RuntimeEvent[]): Promise<void>;
|
|
95
|
+
read(fromSeq: number, toSeq?: number): Promise<RuntimeEvent[]>;
|
|
96
|
+
private readEnvelope;
|
|
97
|
+
private writeEnvelope;
|
|
98
|
+
private withLock;
|
|
99
|
+
}
|
|
100
|
+
/** Durable file-backed membership archive for compacted FactInbox ids. */
|
|
101
|
+
export declare class FileRuntimeFactInboxDedupeArchive implements FactInboxDedupeArchiveWriter {
|
|
102
|
+
readonly directory: string;
|
|
103
|
+
readonly archiveId = "pulse.fact-inbox-dedupe.file.v1";
|
|
104
|
+
private readonly filePath;
|
|
105
|
+
private entries;
|
|
106
|
+
constructor(directory: string);
|
|
107
|
+
get watermark(): number;
|
|
108
|
+
contains(eventId: string, receivedSeq?: number): boolean;
|
|
109
|
+
digestThrough(through: number): string;
|
|
110
|
+
append(batch: FactInboxDedupeArchiveBatch): Promise<void>;
|
|
111
|
+
private withLock;
|
|
112
|
+
}
|
|
113
|
+
/** Durable SQLite membership archive for compacted FactInbox ids. */
|
|
114
|
+
export declare class SqliteRuntimeFactInboxDedupeArchive implements FactInboxDedupeArchiveWriter {
|
|
115
|
+
readonly filePath: string;
|
|
116
|
+
readonly archiveId = "pulse.fact-inbox-dedupe.sqlite.v1";
|
|
117
|
+
private database;
|
|
118
|
+
private tail;
|
|
119
|
+
private entries;
|
|
120
|
+
constructor(filePath: string);
|
|
121
|
+
get watermark(): number;
|
|
122
|
+
contains(eventId: string, receivedSeq?: number): boolean;
|
|
123
|
+
digestThrough(through: number): string;
|
|
124
|
+
append(batch: FactInboxDedupeArchiveBatch): Promise<void>;
|
|
125
|
+
close(): Promise<void>;
|
|
126
|
+
private open;
|
|
127
|
+
private enqueue;
|
|
128
|
+
}
|
|
129
|
+
export interface RuntimePersistenceBackend {
|
|
130
|
+
load(): Promise<RuntimePersistenceSnapshot | undefined>;
|
|
131
|
+
save(snapshot: RuntimePersistenceSnapshot, expectedDigest?: string): Promise<void>;
|
|
132
|
+
sessionStore?: RuntimeSessionStore;
|
|
133
|
+
resultStore?: RuntimeResultStore;
|
|
134
|
+
snapshotStore?: RuntimeSnapshotStore;
|
|
135
|
+
eventArchive?: RuntimeEventArchive;
|
|
136
|
+
factInboxDedupeArchive?: FactInboxDedupeArchiveWriter;
|
|
137
|
+
}
|
|
138
|
+
export declare function withRuntimePersistenceIntegrity(snapshot: RuntimePersistenceSnapshot): RuntimePersistenceSnapshot;
|
|
139
|
+
export declare function validateRuntimePersistenceSnapshot(snapshot: RuntimePersistenceSnapshot | JsonValue): void;
|
|
140
|
+
export declare class FileRuntimePersistenceBackend implements RuntimePersistenceBackend {
|
|
141
|
+
readonly filePath: string;
|
|
142
|
+
private pending;
|
|
143
|
+
readonly sessionStore: FileRuntimeSessionStore;
|
|
144
|
+
readonly factInboxDedupeArchive: FileRuntimeFactInboxDedupeArchive;
|
|
145
|
+
constructor(filePath: string);
|
|
146
|
+
load(): Promise<RuntimePersistenceSnapshot | undefined>;
|
|
147
|
+
save(snapshot: RuntimePersistenceSnapshot, expectedDigest?: string): Promise<void>;
|
|
148
|
+
}
|
|
149
|
+
/** Durable single-snapshot backend using Node's built-in SQLite transaction support. */
|
|
150
|
+
export declare class SqliteRuntimePersistenceBackend implements RuntimePersistenceBackend {
|
|
151
|
+
readonly filePath: string;
|
|
152
|
+
private database;
|
|
153
|
+
private tail;
|
|
154
|
+
readonly resultStore: SqliteRuntimeContentStore;
|
|
155
|
+
readonly snapshotStore: SqliteRuntimeContentStore;
|
|
156
|
+
readonly eventArchive: SqliteRuntimeEventArchive;
|
|
157
|
+
readonly factInboxDedupeArchive: SqliteRuntimeFactInboxDedupeArchive;
|
|
158
|
+
readonly sessionStore: SqliteRuntimeSessionStore;
|
|
159
|
+
constructor(filePath: string);
|
|
160
|
+
load(): Promise<RuntimePersistenceSnapshot | undefined>;
|
|
161
|
+
save(snapshot: RuntimePersistenceSnapshot, expectedDigest?: string): Promise<void>;
|
|
162
|
+
close(): Promise<void>;
|
|
163
|
+
private open;
|
|
164
|
+
private enqueue;
|
|
165
|
+
}
|
|
166
|
+
export declare function exportRuntimePersistence(state: RuntimeState, mutationLog: MutationLog, outbox: EffectOutbox, quarantine?: QuarantineScope, storagePolicy?: SessionStoragePolicy, factInbox?: FactInboxSnapshot, compatibility?: RuntimePersistenceCompatibility): RuntimePersistenceSnapshot;
|
|
167
|
+
export declare function exportRuntimeCheckpoint(state: RuntimeState, mutationLog: MutationLog, outbox: EffectOutbox, quarantine?: QuarantineScope, storagePolicy?: SessionStoragePolicy, options?: {
|
|
168
|
+
compactEventsThrough?: number;
|
|
169
|
+
}, factInbox?: FactInboxSnapshot, compatibility?: RuntimePersistenceCompatibility): RuntimePersistenceSnapshot;
|
|
170
|
+
export declare function externalizeRuntimeResultBodies(snapshot: RuntimePersistenceSnapshot, store: RuntimeResultStore): Promise<RuntimePersistenceSnapshot>;
|
|
171
|
+
export declare function externalizeRuntimeSnapshotBodies(snapshot: RuntimePersistenceSnapshot, store: RuntimeSnapshotStore): Promise<RuntimePersistenceSnapshot>;
|
|
172
|
+
export declare function hydrateRuntimeSnapshotBodies(snapshot: RuntimePersistenceSnapshot, store: RuntimeSnapshotStore): Promise<RuntimePersistenceSnapshot>;
|
|
173
|
+
export declare function hydrateRuntimeResultBodies(snapshot: RuntimePersistenceSnapshot, store: RuntimeResultStore): Promise<RuntimePersistenceSnapshot>;
|
|
174
|
+
export declare function serializeRuntimePersistence(state: RuntimeState, mutationLog: MutationLog, outbox: EffectOutbox, storagePolicy?: SessionStoragePolicy): JsonValue;
|
|
175
|
+
export declare function importRuntimePersistence(snapshot: RuntimePersistenceSnapshot | JsonValue): {
|
|
176
|
+
state: RuntimeState;
|
|
177
|
+
mutationLog: MutationLog;
|
|
178
|
+
outbox: EffectOutbox;
|
|
179
|
+
quarantine?: QuarantineEntry[];
|
|
180
|
+
storagePolicy?: SessionStoragePolicy;
|
|
181
|
+
factInbox?: FactInboxSnapshot;
|
|
182
|
+
compatibility?: RuntimePersistenceCompatibility;
|
|
183
|
+
};
|