@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.
Files changed (93) hide show
  1. package/dist/context/builder.d.ts +68 -0
  2. package/dist/context/builder.js +127 -0
  3. package/dist/context/index.d.ts +2 -0
  4. package/dist/context/index.js +2 -0
  5. package/dist/context/merger.d.ts +25 -0
  6. package/dist/context/merger.js +125 -0
  7. package/dist/core/actions.d.ts +1 -0
  8. package/dist/core/actions.js +1 -0
  9. package/dist/core/errors.d.ts +8 -0
  10. package/dist/core/errors.js +36 -0
  11. package/dist/core/events.d.ts +10 -0
  12. package/dist/core/events.js +24 -0
  13. package/dist/core/factory.d.ts +35 -0
  14. package/dist/core/factory.js +27 -0
  15. package/dist/core/inbox.d.ts +119 -0
  16. package/dist/core/inbox.js +217 -0
  17. package/dist/core/mutations.d.ts +80 -0
  18. package/dist/core/mutations.js +127 -0
  19. package/dist/core/records.d.ts +1 -0
  20. package/dist/core/records.js +1 -0
  21. package/dist/core/types.d.ts +615 -0
  22. package/dist/core/types.js +109 -0
  23. package/dist/dependencies/graph.d.ts +25 -0
  24. package/dist/dependencies/graph.js +92 -0
  25. package/dist/dependencies/index.d.ts +1 -0
  26. package/dist/dependencies/index.js +1 -0
  27. package/dist/dsl/context-proxy.d.ts +20 -0
  28. package/dist/dsl/context-proxy.js +64 -0
  29. package/dist/dsl/index.d.ts +4 -0
  30. package/dist/dsl/index.js +4 -0
  31. package/dist/dsl/program.d.ts +314 -0
  32. package/dist/dsl/program.js +756 -0
  33. package/dist/dsl/session.d.ts +45 -0
  34. package/dist/dsl/session.js +93 -0
  35. package/dist/dsl/templates-index.d.ts +1 -0
  36. package/dist/dsl/templates-index.js +1 -0
  37. package/dist/dsl/templates.d.ts +85 -0
  38. package/dist/dsl/templates.js +110 -0
  39. package/dist/index.d.ts +15 -0
  40. package/dist/index.js +15 -0
  41. package/dist/lifecycle/index.d.ts +2 -0
  42. package/dist/lifecycle/index.js +2 -0
  43. package/dist/lifecycle/scopes.d.ts +38 -0
  44. package/dist/lifecycle/scopes.js +50 -0
  45. package/dist/lifecycle/watchdog.d.ts +16 -0
  46. package/dist/lifecycle/watchdog.js +66 -0
  47. package/dist/models/actions.d.ts +10 -0
  48. package/dist/models/actions.js +68 -0
  49. package/dist/models/index.d.ts +2 -0
  50. package/dist/models/index.js +2 -0
  51. package/dist/models/router.d.ts +187 -0
  52. package/dist/models/router.js +353 -0
  53. package/dist/scheduler/clock.d.ts +45 -0
  54. package/dist/scheduler/clock.js +92 -0
  55. package/dist/scheduler/decision.d.ts +72 -0
  56. package/dist/scheduler/decision.js +63 -0
  57. package/dist/scheduler/index.d.ts +6 -0
  58. package/dist/scheduler/index.js +6 -0
  59. package/dist/scheduler/locks.d.ts +18 -0
  60. package/dist/scheduler/locks.js +106 -0
  61. package/dist/scheduler/ready-queue.d.ts +32 -0
  62. package/dist/scheduler/ready-queue.js +40 -0
  63. package/dist/scheduler/runtime.d.ts +486 -0
  64. package/dist/scheduler/runtime.js +3445 -0
  65. package/dist/scheduler/telemetry.d.ts +111 -0
  66. package/dist/scheduler/telemetry.js +177 -0
  67. package/dist/scheduler/worker.d.ts +158 -0
  68. package/dist/scheduler/worker.js +744 -0
  69. package/dist/storage/artifacts.d.ts +17 -0
  70. package/dist/storage/artifacts.js +90 -0
  71. package/dist/storage/findings.d.ts +12 -0
  72. package/dist/storage/findings.js +70 -0
  73. package/dist/storage/index.d.ts +8 -0
  74. package/dist/storage/index.js +8 -0
  75. package/dist/storage/memory.d.ts +11 -0
  76. package/dist/storage/memory.js +21 -0
  77. package/dist/storage/mutation-log.d.ts +41 -0
  78. package/dist/storage/mutation-log.js +140 -0
  79. package/dist/storage/outbox.d.ts +30 -0
  80. package/dist/storage/outbox.js +59 -0
  81. package/dist/storage/persistence.d.ts +183 -0
  82. package/dist/storage/persistence.js +999 -0
  83. package/dist/storage/policy.d.ts +80 -0
  84. package/dist/storage/policy.js +268 -0
  85. package/dist/storage/session.d.ts +140 -0
  86. package/dist/storage/session.js +447 -0
  87. package/dist/tools/registry.d.ts +125 -0
  88. package/dist/tools/registry.js +308 -0
  89. package/dist/transitions/index.d.ts +2 -0
  90. package/dist/transitions/index.js +1 -0
  91. package/dist/transitions/validate.d.ts +4 -0
  92. package/dist/transitions/validate.js +1118 -0
  93. package/package.json +21 -0
@@ -0,0 +1,486 @@
1
+ import { MutationLog } from '../storage/mutation-log.js';
2
+ import { PriorityInheritance, ReadyQueue, type RuntimeClock } from './index.js';
3
+ import type { EffectRecord, EffectSubmission, EffectState, JsonValue, LaneRecord, LaneStepOutput, Outcome, ResumeInput, RuntimeState, RuntimeError, ForkAffinityMode, PrivacyLabel, PrivacyTaint, ProvenanceRef, ResumePoint, ResultRecord } from '../core/types.js';
4
+ import { QuarantineScope } from '../lifecycle/scopes.js';
5
+ import { PulseSession } from '../dsl/session.js';
6
+ import type { ProgramRef } from '../dsl/templates.js';
7
+ import { FactInbox, ObservationInbox, type FactInboxDedupeArchive, type FactInboxDedupeArchiveBatch } from '../core/inbox.js';
8
+ import { EffectOutbox } from '../storage/outbox.js';
9
+ import { type RuntimePersistenceBackend, type RuntimePersistenceSnapshot } from '../storage/persistence.js';
10
+ import { type RuntimeLogSink, type RuntimeSessionStore, type SessionLogExport, type SessionLogExportOptions } from '../storage/session.js';
11
+ import { ResourceLockManager } from './locks.js';
12
+ import { type Mutation } from '../core/mutations.js';
13
+ import { type MergePlan } from '../context/merger.js';
14
+ import { ModelRouter, type ModelHostPolicy, type ModelRegistry } from '../models/router.js';
15
+ import { SessionStoragePolicy, type StoragePolicyConfig } from '../storage/policy.js';
16
+ import { type RuntimeTelemetryExporter, type RuntimeTelemetrySnapshot } from './telemetry.js';
17
+ import { type ArtifactPublication } from '../storage/artifacts.js';
18
+ import { type FindingPublication } from '../storage/findings.js';
19
+ import { RuntimeToolRegistry } from '../tools/registry.js';
20
+ import { type SchedulerDecisionConfig } from './decision.js';
21
+ export interface LaneStepContext {
22
+ lane: Readonly<LaneRecord>;
23
+ state: Readonly<RuntimeState>;
24
+ resumeInput?: ResumeInput;
25
+ now: number;
26
+ observe?: (event: {
27
+ type: 'progress' | 'chunk' | 'trace' | 'warning' | 'diagnostic';
28
+ data: JsonValue;
29
+ }) => void;
30
+ }
31
+ export interface LaneProgram {
32
+ id: string;
33
+ version: string;
34
+ entry?: string;
35
+ step: (context: LaneStepContext) => LaneStepOutput;
36
+ errorBoundary?: (error: RuntimeError, context: LaneStepContext) => LaneStepOutput;
37
+ seriesMember?: ResumePoint;
38
+ seriesMemberProgram?: LaneProgram;
39
+ seriesKeys?: string[];
40
+ seriesOnMemberFailure?: 'continue' | 'abort';
41
+ }
42
+ export interface EffectObservation {
43
+ type: 'progress' | 'chunk' | 'trace' | 'warning' | 'diagnostic';
44
+ data: JsonValue;
45
+ }
46
+ export type EffectObservationEmitter = (observation: EffectObservation) => void;
47
+ export interface EffectArtifactOutput {
48
+ mediaType: string;
49
+ content: Uint8Array | string;
50
+ privacy?: 'public' | 'cloud_allowed' | 'local_only';
51
+ privacyTaints?: PrivacyTaint[];
52
+ derivedFrom?: ProvenanceRef[];
53
+ }
54
+ export interface EffectExecution {
55
+ value: JsonValue;
56
+ normalized?: JsonValue;
57
+ artifact?: EffectArtifactOutput;
58
+ summary?: JsonValue;
59
+ privacy?: 'public' | 'cloud_allowed' | 'local_only';
60
+ privacyTaints?: PrivacyTaint[];
61
+ sideEffectState?: 'none' | 'applied' | 'known' | 'unknown';
62
+ executionRef?: JsonValue;
63
+ executionState?: 'succeeded' | 'failed' | 'remote_unknown';
64
+ status?: 'succeeded' | 'failed' | 'cancelled';
65
+ error?: RuntimeError;
66
+ rejectedOutput?: {
67
+ value: JsonValue;
68
+ privacy?: 'public' | 'cloud_allowed' | 'local_only';
69
+ privacyTaints?: PrivacyTaint[];
70
+ derivedFrom?: ProvenanceRef[];
71
+ };
72
+ metadata?: JsonValue;
73
+ observations?: EffectObservation[];
74
+ }
75
+ export type EffectExecutor = (effect: Readonly<EffectRecord>, signal: AbortSignal, emitObservation?: EffectObservationEmitter) => Promise<EffectExecution>;
76
+ export interface EffectHandle {
77
+ id: string;
78
+ status(): EffectState;
79
+ requestCancel(reason: string): void;
80
+ }
81
+ export type HostCommand = {
82
+ type: 'reply';
83
+ agentId: string;
84
+ effectId: string;
85
+ value: JsonValue;
86
+ } | {
87
+ type: 'cancel';
88
+ agentId: string;
89
+ reason: string;
90
+ } | {
91
+ type: 'cancel_effect';
92
+ agentId: string;
93
+ effectId: string;
94
+ reason: string;
95
+ } | {
96
+ type: 'set_lane_priority';
97
+ laneId: string;
98
+ priority: number;
99
+ };
100
+ interface EffectCompletionFact {
101
+ [key: string]: JsonValue;
102
+ type: 'effect_completion';
103
+ effectId: string;
104
+ attemptId: string;
105
+ execution: JsonValue;
106
+ status: 'succeeded' | 'failed' | 'cancelled';
107
+ error?: JsonValue;
108
+ dispatchError?: JsonValue;
109
+ }
110
+ interface LLMPreparationFact {
111
+ [key: string]: JsonValue;
112
+ type: 'llm_preparation';
113
+ effectId: string;
114
+ generation: number;
115
+ status: 'prepared' | 'stale';
116
+ projectionRef?: string;
117
+ }
118
+ interface EffectReconcileFact {
119
+ [key: string]: JsonValue;
120
+ type: 'effect_reconcile';
121
+ effectId: string;
122
+ attemptId: string;
123
+ value: JsonValue;
124
+ status: 'succeeded' | 'failed' | 'cancelled';
125
+ error?: JsonValue;
126
+ }
127
+ interface SchedulerDecisionFact {
128
+ [key: string]: JsonValue;
129
+ type: 'scheduler_decision';
130
+ decisionId: string;
131
+ candidateEpoch: number;
132
+ orderedLaneIds: string[];
133
+ modelId: string;
134
+ }
135
+ type RuntimeFact = HostCommand | EffectCompletionFact | LLMPreparationFact | EffectReconcileFact | SchedulerDecisionFact;
136
+ export interface RuntimeConfig {
137
+ maxLaneStepsPerTick?: number;
138
+ maxTickMs?: number;
139
+ agingIntervalMs?: number;
140
+ agingCap?: number;
141
+ maxTotalLanes?: number;
142
+ maxQueuedEffects?: number;
143
+ maxRunning?: Partial<Record<'llm' | 'tool' | 'agent' | 'none', number>>;
144
+ forkAffinity?: ForkAffinityMode;
145
+ historySoftTokens?: number;
146
+ historyHardTokens?: number;
147
+ maxResultSummaryBytes?: number;
148
+ maxConsecutiveControlErrors?: number;
149
+ maxRuntimeMs?: number;
150
+ sessionId?: string;
151
+ maxAgentDepth?: number;
152
+ watchdogNoProgressThreshold?: number;
153
+ watchdogRepeatedActionThreshold?: number;
154
+ maxPreparingLLMs?: number;
155
+ maxPreparedLLMs?: number;
156
+ writerPreferenceBound?: number;
157
+ maxObservationEntries?: number;
158
+ maxObservationBytes?: number;
159
+ clock?: RuntimeClock;
160
+ trustedSanitizerIds?: string[];
161
+ storagePolicy?: StoragePolicyConfig;
162
+ persistence?: RuntimePersistenceSnapshot;
163
+ programs?: LaneProgram[];
164
+ models?: ModelRegistry;
165
+ hostPolicy?: ModelHostPolicy;
166
+ modelRouter?: ModelRouter;
167
+ tools?: RuntimeToolRegistry;
168
+ toolVersions?: Record<string, string>;
169
+ policyVersion?: string;
170
+ routerVersion?: string;
171
+ effectExecutor?: EffectExecutor;
172
+ /**
173
+ * Let an application opt into Runtime-owned Human Effect handling while
174
+ * still supplying a combined executor for model and tool effects.
175
+ * Existing custom executors keep their historical behavior by default.
176
+ */
177
+ builtinHumanEffects?: boolean;
178
+ effectSubmissionPreparer?: (submission: EffectSubmission) => EffectSubmission;
179
+ telemetryExporter?: RuntimeTelemetryExporter;
180
+ auditLogSink?: RuntimeLogSink;
181
+ auditLogPrivacy?: PrivacyLabel;
182
+ persistenceBackend?: RuntimePersistenceBackend;
183
+ sessionStore?: RuntimeSessionStore;
184
+ /** Optional durable membership view used to safely compact FactInbox dedupe ids. */
185
+ factInboxDedupeArchive?: FactInboxDedupeArchive;
186
+ /** Internal restore CAS baseline; differs from the hydrated envelope digest. */
187
+ persistenceExpectedDigest?: string;
188
+ budget?: RuntimeBudgetConfig;
189
+ schedulerDecision?: SchedulerDecisionConfig;
190
+ }
191
+ export interface RuntimeBudgetConfig {
192
+ maxTotalAttempts?: number;
193
+ maxLLMAttempts?: number;
194
+ maxToolAttempts?: number;
195
+ maxCostByCurrency?: Record<string, number>;
196
+ }
197
+ /**
198
+ * A warm start adopts the final Global Context from an explicit PulseSession.
199
+ * `agentId` remains a source-compatible alias for the pre-session API.
200
+ */
201
+ export interface WarmStartSpec {
202
+ sessionId?: string;
203
+ agentId?: string;
204
+ globalVersion?: number | 'latest' | 'final';
205
+ include?: 'facts' | 'facts_and_findings';
206
+ relevanceRefs?: string[];
207
+ }
208
+ export type AgentPriority = 'background' | 'normal' | 'high' | 'urgent';
209
+ export interface AgentPolicyRef {
210
+ id: string;
211
+ }
212
+ export interface AgentLimits {
213
+ id?: string;
214
+ timeoutMs?: number;
215
+ maxActiveLanes?: number;
216
+ }
217
+ export interface AgentCreateRequest {
218
+ goal: string;
219
+ program: LaneProgram | ProgramRef;
220
+ agentId?: string;
221
+ priority?: number | AgentPriority;
222
+ policy?: AgentPolicyRef;
223
+ policyId?: string;
224
+ limits?: AgentLimits;
225
+ limitsId?: string;
226
+ maxActiveLanes?: number;
227
+ warmStart?: WarmStartSpec;
228
+ parentAgentId?: string;
229
+ inheritedFloor?: number;
230
+ }
231
+ export interface BackgroundAgentInfo {
232
+ agentId: string;
233
+ rootLaneId: string;
234
+ state: NonNullable<import('../core/types.js').AgentRecord['state']>;
235
+ detached: true;
236
+ }
237
+ export interface AgentHandle {
238
+ id: string;
239
+ agentId: string;
240
+ laneId: string;
241
+ }
242
+ export declare class ProgramRegistry {
243
+ private readonly records;
244
+ register(program: LaneProgram): void;
245
+ get(programId: string, programVersion?: string): LaneProgram | undefined;
246
+ resolve(ref: ProgramRef): LaneProgram;
247
+ has(programId: string, programVersion?: string): boolean;
248
+ entries(): IterableIterator<[string, LaneProgram]>;
249
+ }
250
+ export declare class PulseRuntime {
251
+ readonly state: RuntimeState;
252
+ /** Host-facing read-only effect inspection. Returned records are detached snapshots. */
253
+ readonly effects: {
254
+ inspect: (effectId: string) => EffectRecord | undefined;
255
+ };
256
+ /** Host-facing read-only result lookup. Returned records are detached snapshots. */
257
+ readonly results: {
258
+ get: (resultRef: string) => ResultRecord | undefined;
259
+ };
260
+ private shuttingDown;
261
+ private readonly telemetryExporter;
262
+ private readonly auditLogSink;
263
+ private readonly auditLogPrivacy;
264
+ private readonly persistenceBackend;
265
+ private readonly sessionStore;
266
+ private readonly enforcingRecoveryPrograms;
267
+ private readonly toolVersions;
268
+ private readonly recoveryCompatibility;
269
+ private readonly policyVersion;
270
+ private readonly routerVersion;
271
+ private readonly budget;
272
+ private persistenceDigest;
273
+ private readonly budgetCost;
274
+ private persistencePending;
275
+ private persistenceScheduled;
276
+ private persistenceDirty;
277
+ private dispatchPersistencePending;
278
+ private dispatchPersistenceReady;
279
+ private readonly executionYieldPending;
280
+ readonly mutationLog: MutationLog;
281
+ readonly outbox: EffectOutbox;
282
+ readonly clock: RuntimeClock;
283
+ readonly ready: ReadyQueue;
284
+ readonly quarantine: QuarantineScope;
285
+ readonly priorityInheritance: PriorityInheritance;
286
+ readonly resourceLocks: ResourceLockManager;
287
+ readonly storagePolicy: SessionStoragePolicy;
288
+ readonly factInbox: FactInbox<RuntimeFact>;
289
+ readonly observationInbox: ObservationInbox;
290
+ readonly programs: ProgramRegistry;
291
+ readonly models: ModelRegistry;
292
+ readonly modelRouter: ModelRouter;
293
+ readonly tools: RuntimeToolRegistry;
294
+ private readonly executions;
295
+ private readonly lockReleases;
296
+ private readonly waitDeadlineTimers;
297
+ private readonly lockBlocked;
298
+ private readonly grantedLockReleases;
299
+ /** Every lock request id an Effect ever issued (across attempts), keyed by Effect id, so terminal cleanup never misses a queued request. */
300
+ private readonly lockRequests;
301
+ /** Consecutive background persistence failures; reset on the next successful write. */
302
+ private persistenceFailures;
303
+ private persistenceBackoff;
304
+ private readonly executor;
305
+ private factInboxDedupeArchive;
306
+ private readonly customExecutor;
307
+ private readonly builtinHumanEffects;
308
+ private enqueueSeq;
309
+ private readonly maxSteps;
310
+ private readonly maxTickMs;
311
+ private readonly maxConsecutiveControlErrors;
312
+ private readonly maxRuntimeAt?;
313
+ private readonly watchdogNoProgressThreshold;
314
+ private readonly watchdogRepeatedActionThreshold;
315
+ private readonly maxAgentDepth;
316
+ private readonly maxPreparingLLMs;
317
+ private readonly maxPreparedLLMs;
318
+ private readonly effectSubmissionPreparer;
319
+ private readonly schedulerDecisionCoordinator;
320
+ private readonly schedulerDecisionConfig;
321
+ private readonly schedulerDecisionModelId;
322
+ private readonly schedulerDecisionMaxReorderDistance;
323
+ private readonly schedulerDecisionReserveEvery;
324
+ private readonly schedulerDecisionIncludeGoals;
325
+ private schedulerDecisionEpoch;
326
+ private schedulerDecisionRequestSeq;
327
+ private schedulerDecisionDispatches;
328
+ private schedulerDecisionCache;
329
+ private readonly schedulerDecisionRequests;
330
+ private readonly preparingLLMs;
331
+ private readonly sessionId;
332
+ private hostCommandSeq;
333
+ private factWaiters;
334
+ private wakeScheduled;
335
+ private inDrain;
336
+ private wakeError;
337
+ private tickBudget;
338
+ static restore(backend: RuntimePersistenceBackend, config?: Omit<RuntimeConfig, 'persistence'>): Promise<PulseRuntime>;
339
+ constructor(config?: RuntimeConfig);
340
+ register(program: LaneProgram): void;
341
+ createAgent(request: AgentCreateRequest): AgentHandle;
342
+ createAgent(goal: string, program: LaneProgram, agentId?: string): AgentHandle;
343
+ start(agentId: string): PulseSession;
344
+ requestCancel(agentId: string, reason?: string): void;
345
+ setLanePriority(laneId: string, priority: number): void;
346
+ effectHandle(effectId: string): EffectHandle;
347
+ inspectLane(laneId: string): JsonValue;
348
+ detachAgent(agentId: string): BackgroundAgentInfo;
349
+ attachAgent(agentId: string): void;
350
+ backgroundAgents(): BackgroundAgentInfo[];
351
+ exportPersistence(): RuntimePersistenceSnapshot;
352
+ createFactInboxDedupeArchiveBatch(through?: number): FactInboxDedupeArchiveBatch;
353
+ compactFactInboxDedupeThrough(batch: FactInboxDedupeArchiveBatch): number;
354
+ persist(backend: RuntimePersistenceBackend): Promise<void>;
355
+ flushPersistence(): Promise<void>;
356
+ checkpoint(backend: RuntimePersistenceBackend, options?: {
357
+ compactEventsThrough?: number;
358
+ }): Promise<RuntimePersistenceSnapshot>;
359
+ mergeProposals(agentId: string, proposalIds?: string[]): MergePlan;
360
+ private emit;
361
+ private assertRecoveryPrograms;
362
+ private persistenceCompatibility;
363
+ private assertRecoveryCompatibility;
364
+ private currentToolVersions;
365
+ private tryEmit;
366
+ private rejectHostCommand;
367
+ private prepareStepOutput;
368
+ private prepareRegisteredToolSubmission;
369
+ private executeRegisteredEffect;
370
+ private journalEffect;
371
+ private enqueueFact;
372
+ enqueueHostCommand(command: HostCommand): void;
373
+ private enqueueEffectCompletion;
374
+ private enqueueLLMPreparation;
375
+ private enqueueEffectReconcile;
376
+ private scheduleWake;
377
+ private enqueueReadyItem;
378
+ enqueueLane(laneId: string): void;
379
+ private requestSchedulerDecision;
380
+ private applySchedulerDecision;
381
+ private selectReadyLane;
382
+ private scheduleRuntimeTimer;
383
+ private scheduleRuntimeDelay;
384
+ private seriesStep;
385
+ tick(): number;
386
+ run(): Promise<Outcome>;
387
+ run(maxTicks: number): Promise<Outcome>;
388
+ run(agentId: string, maxTicks?: number): Promise<Outcome>;
389
+ runAgent(agentId: string, maxTicks?: number): Promise<Outcome>;
390
+ waitForIdle(): Promise<void>;
391
+ shutdown(timeoutMs?: number): Promise<{
392
+ status: 'stopped' | 'timed_out';
393
+ unresolvedEffectIds: string[];
394
+ quarantine: string[];
395
+ }>;
396
+ inspect(): JsonValue;
397
+ telemetry(): RuntimeTelemetrySnapshot;
398
+ exportTelemetry(timestamp?: number): Promise<RuntimeTelemetrySnapshot>;
399
+ exportAuditLog(options?: SessionLogExportOptions): Promise<SessionLogExport>;
400
+ private assertStorageAdmission;
401
+ private schedulePersistence;
402
+ private persistenceState;
403
+ private markArtifactsPersisted;
404
+ /**
405
+ * Reconcile the storage policy with the (candidate) runtime state.
406
+ *
407
+ * Cost model: keys whose content is immutable once written (events, versioned
408
+ * Lane/global snapshots, LLM request snapshots, resume inputs, fact envelopes,
409
+ * published results) are only serialized and hashed on first sight; later
410
+ * syncs skip them with a map lookup. Only genuinely mutable records (waits,
411
+ * artifacts) are re-put every time. Pins are recomputed from scratch, which is
412
+ * a set-diff over keys, not over bodies.
413
+ */
414
+ private syncStoragePolicy;
415
+ private hasQueuedEffects;
416
+ private hasDueTimer;
417
+ private hasPendingTickCleanup;
418
+ private hasPendingHostInteraction;
419
+ private waitForFact;
420
+ private completeFinishedChildAgents;
421
+ completeEffect(effectId: string, execution: EffectExecution, status?: 'succeeded' | 'failed' | 'cancelled', error?: RuntimeError, additionalMutations?: Mutation[]): boolean;
422
+ markRemoteUnknown(effectId: string, sideEffectState: 'none' | 'applied' | 'known' | 'unknown'): void;
423
+ reconcileEffect(effectId: string, value: JsonValue, status?: 'succeeded' | 'failed' | 'cancelled', error?: RuntimeError): void;
424
+ reconcileEffectWith(effectId: string, resolver: (executionRef: JsonValue | undefined, effect: Readonly<EffectRecord>, signal: AbortSignal) => Promise<{
425
+ status: 'succeeded' | 'failed' | 'cancelled' | 'unknown';
426
+ output?: JsonValue;
427
+ error?: RuntimeError;
428
+ }>, signal?: AbortSignal): Promise<{
429
+ status: 'succeeded' | 'failed' | 'cancelled' | 'unknown';
430
+ output?: JsonValue;
431
+ error?: RuntimeError;
432
+ }>;
433
+ reconcileRegisteredEffect(effectId: string, signal?: AbortSignal): Promise<{
434
+ status: 'succeeded' | 'failed' | 'cancelled' | 'unknown';
435
+ output?: JsonValue;
436
+ error?: RuntimeError;
437
+ }>;
438
+ abandonEffect(effectId: string): void;
439
+ cancelEffect(effectId: string, graceMs?: number, reason?: string, additionalMutations?: Mutation[]): boolean;
440
+ publishArtifact(publication: ArtifactPublication): import('../core/types.js').ArtifactRecord;
441
+ publishFinding(publication: FindingPublication): import('../core/types.js').FindingRecord;
442
+ readArtifact(ref: string): Uint8Array;
443
+ pinArtifact(ref: string): void;
444
+ unpinArtifact(ref: string): void;
445
+ markArtifactPersisted(ref: string): void;
446
+ cancelAgent(agentId: string, reason?: string, additionalMutations?: Mutation[], commandTransactionId?: string): boolean;
447
+ private finalizeCancellations;
448
+ explain(laneId?: string): JsonValue;
449
+ retryEffect(effectId: string, delayMs: number): void;
450
+ private readyRetryEffect;
451
+ private scheduleRetry;
452
+ private dispatchQueuedEffects;
453
+ private dispatchQueuedEffectsNow;
454
+ private prepareLLMEffect;
455
+ private expireEffect;
456
+ private requestEffectCancellation;
457
+ private quarantineEffect;
458
+ private propagateCancelledLanes;
459
+ private runningCount;
460
+ budgetUsage(): {
461
+ attempts: number;
462
+ costByCurrency: Record<string, number>;
463
+ };
464
+ private budgetRejection;
465
+ private recordBudgetMetadata;
466
+ private acquireEffectLocks;
467
+ /**
468
+ * Release everything an Effect may hold on the lock manager: granted locks,
469
+ * grants that arrived asynchronously, and requests still waiting in a queue.
470
+ * This must run unconditionally on every terminal path. An Effect that was
471
+ * cancelled while still *waiting* for a lock never had an entry in
472
+ * `lockReleases`; skipping the cleanup in that case leaves a ghost request
473
+ * that later receives the grant and holds the resource forever.
474
+ */
475
+ private releaseEffectLocks;
476
+ private enqueueNewReadyLanes;
477
+ private commitAgentState;
478
+ private commitLaneControlInput;
479
+ private failLane;
480
+ private refreshWaits;
481
+ private scheduleWaitDeadline;
482
+ private cancelWaitDeadline;
483
+ private expireWait;
484
+ private recomputePriorityInheritance;
485
+ }
486
+ export {};