@smthrs/engine-store 0.0.0-stage → 1.0.0-rc.3
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/CHANGELOG.md +247 -0
- package/LICENSE +21 -0
- package/README.md +146 -2
- package/dist/cjs/ArtifactGc.d.ts +235 -0
- package/dist/cjs/ArtifactGc.d.ts.map +1 -0
- package/dist/cjs/ArtifactGc.js +183 -0
- package/dist/cjs/ArtifactGc.js.map +7 -0
- package/dist/cjs/ArtifactSync.d.ts +164 -0
- package/dist/cjs/ArtifactSync.d.ts.map +1 -0
- package/dist/cjs/ArtifactSync.js +144 -0
- package/dist/cjs/ArtifactSync.js.map +7 -0
- package/dist/cjs/CacheSync.d.ts +112 -0
- package/dist/cjs/CacheSync.d.ts.map +1 -0
- package/dist/cjs/CacheSync.js +64 -0
- package/dist/cjs/CacheSync.js.map +7 -0
- package/dist/cjs/DeferredClockFold.d.ts +354 -0
- package/dist/cjs/DeferredClockFold.d.ts.map +1 -0
- package/dist/cjs/DeferredClockFold.js +335 -0
- package/dist/cjs/DeferredClockFold.js.map +7 -0
- package/dist/cjs/DisasterRecovery.d.ts +431 -0
- package/dist/cjs/DisasterRecovery.d.ts.map +1 -0
- package/dist/cjs/DisasterRecovery.js +453 -0
- package/dist/cjs/DisasterRecovery.js.map +7 -0
- package/dist/cjs/DurableEngineState.d.ts +776 -0
- package/dist/cjs/DurableEngineState.d.ts.map +1 -0
- package/dist/cjs/DurableEngineState.js +1536 -0
- package/dist/cjs/DurableEngineState.js.map +7 -0
- package/dist/cjs/EngineStore.d.ts +158 -0
- package/dist/cjs/EngineStore.d.ts.map +1 -0
- package/dist/cjs/EngineStore.js +398 -0
- package/dist/cjs/EngineStore.js.map +7 -0
- package/dist/cjs/EngineStoreMetrics.d.ts +276 -0
- package/dist/cjs/EngineStoreMetrics.d.ts.map +1 -0
- package/dist/cjs/EngineStoreMetrics.js +135 -0
- package/dist/cjs/EngineStoreMetrics.js.map +7 -0
- package/dist/cjs/Errors.d.ts +22 -0
- package/dist/cjs/Errors.d.ts.map +1 -0
- package/dist/cjs/Errors.js +39 -0
- package/dist/cjs/Errors.js.map +7 -0
- package/dist/cjs/EventTypes.d.ts +27 -0
- package/dist/cjs/EventTypes.d.ts.map +1 -0
- package/dist/cjs/EventTypes.js +37 -0
- package/dist/cjs/EventTypes.js.map +7 -0
- package/dist/cjs/ExecutionFacts.d.ts +59 -0
- package/dist/cjs/ExecutionFacts.d.ts.map +1 -0
- package/dist/cjs/ExecutionFacts.js +123 -0
- package/dist/cjs/ExecutionFacts.js.map +7 -0
- package/dist/cjs/ExecutionSnapshot.d.ts +117 -0
- package/dist/cjs/ExecutionSnapshot.d.ts.map +1 -0
- package/dist/cjs/ExecutionSnapshot.js +111 -0
- package/dist/cjs/ExecutionSnapshot.js.map +7 -0
- package/dist/cjs/Inconsistency.d.ts +154 -0
- package/dist/cjs/Inconsistency.d.ts.map +1 -0
- package/dist/cjs/Inconsistency.js +135 -0
- package/dist/cjs/Inconsistency.js.map +7 -0
- package/dist/cjs/Migrations.d.ts +56 -0
- package/dist/cjs/Migrations.d.ts.map +1 -0
- package/dist/cjs/Migrations.js +78 -0
- package/dist/cjs/Migrations.js.map +7 -0
- package/dist/cjs/OwnerIdentity.d.ts +91 -0
- package/dist/cjs/OwnerIdentity.d.ts.map +1 -0
- package/dist/cjs/OwnerIdentity.js +65 -0
- package/dist/cjs/OwnerIdentity.js.map +7 -0
- package/dist/cjs/PlanInputStore.d.ts +110 -0
- package/dist/cjs/PlanInputStore.d.ts.map +1 -0
- package/dist/cjs/PlanInputStore.js +224 -0
- package/dist/cjs/PlanInputStore.js.map +7 -0
- package/dist/cjs/PlanMergeStore.d.ts +113 -0
- package/dist/cjs/PlanMergeStore.d.ts.map +1 -0
- package/dist/cjs/PlanMergeStore.js +255 -0
- package/dist/cjs/PlanMergeStore.js.map +7 -0
- package/dist/cjs/PlanScheduler.d.ts +363 -0
- package/dist/cjs/PlanScheduler.d.ts.map +1 -0
- package/dist/cjs/PlanScheduler.js +1090 -0
- package/dist/cjs/PlanScheduler.js.map +7 -0
- package/dist/cjs/Reconciliation.d.ts +175 -0
- package/dist/cjs/Reconciliation.d.ts.map +1 -0
- package/dist/cjs/Reconciliation.js +119 -0
- package/dist/cjs/Reconciliation.js.map +7 -0
- package/dist/cjs/ReplayOnly.d.ts +91 -0
- package/dist/cjs/ReplayOnly.d.ts.map +1 -0
- package/dist/cjs/ReplayOnly.js +52 -0
- package/dist/cjs/ReplayOnly.js.map +7 -0
- package/dist/cjs/Retention.d.ts +113 -0
- package/dist/cjs/Retention.d.ts.map +1 -0
- package/dist/cjs/Retention.js +99 -0
- package/dist/cjs/Retention.js.map +7 -0
- package/dist/cjs/RunCatalogRead.d.ts +17 -0
- package/dist/cjs/RunCatalogRead.d.ts.map +1 -0
- package/dist/cjs/RunCatalogRead.js +33 -0
- package/dist/cjs/RunCatalogRead.js.map +7 -0
- package/dist/cjs/RunChangeFeed.d.ts +75 -0
- package/dist/cjs/RunChangeFeed.d.ts.map +1 -0
- package/dist/cjs/RunChangeFeed.js +96 -0
- package/dist/cjs/RunChangeFeed.js.map +7 -0
- package/dist/cjs/RunState.d.ts +116 -0
- package/dist/cjs/RunState.d.ts.map +1 -0
- package/dist/cjs/RunState.js +76 -0
- package/dist/cjs/RunState.js.map +7 -0
- package/dist/cjs/Selection.d.ts +495 -0
- package/dist/cjs/Selection.d.ts.map +1 -0
- package/dist/cjs/Selection.js +288 -0
- package/dist/cjs/Selection.js.map +7 -0
- package/dist/cjs/SelectionStore.d.ts +141 -0
- package/dist/cjs/SelectionStore.d.ts.map +1 -0
- package/dist/cjs/SelectionStore.js +229 -0
- package/dist/cjs/SelectionStore.js.map +7 -0
- package/dist/cjs/StepBoundary.d.ts +501 -0
- package/dist/cjs/StepBoundary.d.ts.map +1 -0
- package/dist/cjs/StepBoundary.js +619 -0
- package/dist/cjs/StepBoundary.js.map +7 -0
- package/dist/cjs/StepCacheFold.d.ts +148 -0
- package/dist/cjs/StepCacheFold.d.ts.map +1 -0
- package/dist/cjs/StepCacheFold.js +131 -0
- package/dist/cjs/StepCacheFold.js.map +7 -0
- package/dist/cjs/StepSandbox.d.ts +78 -0
- package/dist/cjs/StepSandbox.d.ts.map +1 -0
- package/dist/cjs/StepSandbox.js +75 -0
- package/dist/cjs/StepSandbox.js.map +7 -0
- package/dist/cjs/WakeBus.d.ts +116 -0
- package/dist/cjs/WakeBus.d.ts.map +1 -0
- package/dist/cjs/WakeBus.js +89 -0
- package/dist/cjs/WakeBus.js.map +7 -0
- package/dist/cjs/WorkspaceSandbox.d.ts +619 -0
- package/dist/cjs/WorkspaceSandbox.d.ts.map +1 -0
- package/dist/cjs/WorkspaceSandbox.js +711 -0
- package/dist/cjs/WorkspaceSandbox.js.map +7 -0
- package/dist/cjs/index.d.ts +157 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +95 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/ActionPersistence.d.ts +276 -0
- package/dist/cjs/internal/ActionPersistence.d.ts.map +1 -0
- package/dist/cjs/internal/ActionPersistence.js +1395 -0
- package/dist/cjs/internal/ActionPersistence.js.map +7 -0
- package/dist/cjs/internal/ArtifactRoots.d.ts +38 -0
- package/dist/cjs/internal/ArtifactRoots.d.ts.map +1 -0
- package/dist/cjs/internal/ArtifactRoots.js +89 -0
- package/dist/cjs/internal/ArtifactRoots.js.map +7 -0
- package/dist/cjs/internal/AttemptAdmission.d.ts +53 -0
- package/dist/cjs/internal/AttemptAdmission.d.ts.map +1 -0
- package/dist/cjs/internal/AttemptAdmission.js +52 -0
- package/dist/cjs/internal/AttemptAdmission.js.map +7 -0
- package/dist/cjs/internal/AttemptLifecycle.d.ts +245 -0
- package/dist/cjs/internal/AttemptLifecycle.d.ts.map +1 -0
- package/dist/cjs/internal/AttemptLifecycle.js +112 -0
- package/dist/cjs/internal/AttemptLifecycle.js.map +7 -0
- package/dist/cjs/internal/AttemptProbe.d.ts +53 -0
- package/dist/cjs/internal/AttemptProbe.d.ts.map +1 -0
- package/dist/cjs/internal/AttemptProbe.js +66 -0
- package/dist/cjs/internal/AttemptProbe.js.map +7 -0
- package/dist/cjs/internal/CacheAdmission.d.ts +79 -0
- package/dist/cjs/internal/CacheAdmission.d.ts.map +1 -0
- package/dist/cjs/internal/CacheAdmission.js +71 -0
- package/dist/cjs/internal/CacheAdmission.js.map +7 -0
- package/dist/cjs/internal/CacheAgeHistory.d.ts +27 -0
- package/dist/cjs/internal/CacheAgeHistory.d.ts.map +1 -0
- package/dist/cjs/internal/CacheAgeHistory.js +61 -0
- package/dist/cjs/internal/CacheAgeHistory.js.map +7 -0
- package/dist/cjs/internal/CacheAgeVerdicts.d.ts +15 -0
- package/dist/cjs/internal/CacheAgeVerdicts.d.ts.map +1 -0
- package/dist/cjs/internal/CacheAgeVerdicts.js +73 -0
- package/dist/cjs/internal/CacheAgeVerdicts.js.map +7 -0
- package/dist/cjs/internal/CacheOutputPolicy.d.ts +24 -0
- package/dist/cjs/internal/CacheOutputPolicy.d.ts.map +1 -0
- package/dist/cjs/internal/CacheOutputPolicy.js +75 -0
- package/dist/cjs/internal/CacheOutputPolicy.js.map +7 -0
- package/dist/cjs/internal/CachePublication.d.ts +97 -0
- package/dist/cjs/internal/CachePublication.d.ts.map +1 -0
- package/dist/cjs/internal/CachePublication.js +80 -0
- package/dist/cjs/internal/CachePublication.js.map +7 -0
- package/dist/cjs/internal/CallFacts.d.ts +15 -0
- package/dist/cjs/internal/CallFacts.d.ts.map +1 -0
- package/dist/cjs/internal/CallFacts.js +97 -0
- package/dist/cjs/internal/CallFacts.js.map +7 -0
- package/dist/cjs/internal/CopiedRecord.d.ts +61 -0
- package/dist/cjs/internal/CopiedRecord.d.ts.map +1 -0
- package/dist/cjs/internal/CopiedRecord.js +134 -0
- package/dist/cjs/internal/CopiedRecord.js.map +7 -0
- package/dist/cjs/internal/DeferredPersistence.d.ts +108 -0
- package/dist/cjs/internal/DeferredPersistence.d.ts.map +1 -0
- package/dist/cjs/internal/DeferredPersistence.js +270 -0
- package/dist/cjs/internal/DeferredPersistence.js.map +7 -0
- package/dist/cjs/internal/EffectRecords.d.ts +92 -0
- package/dist/cjs/internal/EffectRecords.d.ts.map +1 -0
- package/dist/cjs/internal/EffectRecords.js +63 -0
- package/dist/cjs/internal/EffectRecords.js.map +7 -0
- package/dist/cjs/internal/EngineJj.d.ts +30 -0
- package/dist/cjs/internal/EngineJj.d.ts.map +1 -0
- package/dist/cjs/internal/EngineJj.js +42 -0
- package/dist/cjs/internal/EngineJj.js.map +7 -0
- package/dist/cjs/internal/EngineStateSchema.d.ts +68 -0
- package/dist/cjs/internal/EngineStateSchema.d.ts.map +1 -0
- package/dist/cjs/internal/EngineStateSchema.js +58 -0
- package/dist/cjs/internal/EngineStateSchema.js.map +7 -0
- package/dist/cjs/internal/ExecutionSnapshotRead.d.ts +162 -0
- package/dist/cjs/internal/ExecutionSnapshotRead.d.ts.map +1 -0
- package/dist/cjs/internal/ExecutionSnapshotRead.js +199 -0
- package/dist/cjs/internal/ExecutionSnapshotRead.js.map +7 -0
- package/dist/cjs/internal/ExecutionSnapshotRelations.d.ts +39 -0
- package/dist/cjs/internal/ExecutionSnapshotRelations.d.ts.map +1 -0
- package/dist/cjs/internal/ExecutionSnapshotRelations.js +105 -0
- package/dist/cjs/internal/ExecutionSnapshotRelations.js.map +7 -0
- package/dist/cjs/internal/ExitEncoding.d.ts +180 -0
- package/dist/cjs/internal/ExitEncoding.d.ts.map +1 -0
- package/dist/cjs/internal/ExitEncoding.js +236 -0
- package/dist/cjs/internal/ExitEncoding.js.map +7 -0
- package/dist/cjs/internal/FileBoundarySnapshot.d.ts +14 -0
- package/dist/cjs/internal/FileBoundarySnapshot.d.ts.map +1 -0
- package/dist/cjs/internal/FileBoundarySnapshot.js +51 -0
- package/dist/cjs/internal/FileBoundarySnapshot.js.map +7 -0
- package/dist/cjs/internal/FileEnumeration.d.ts +127 -0
- package/dist/cjs/internal/FileEnumeration.d.ts.map +1 -0
- package/dist/cjs/internal/FileEnumeration.js +194 -0
- package/dist/cjs/internal/FileEnumeration.js.map +7 -0
- package/dist/cjs/internal/HostReflection.d.ts +80 -0
- package/dist/cjs/internal/HostReflection.d.ts.map +1 -0
- package/dist/cjs/internal/HostReflection.js +43 -0
- package/dist/cjs/internal/HostReflection.js.map +7 -0
- package/dist/cjs/internal/JournalRecords.d.ts +325 -0
- package/dist/cjs/internal/JournalRecords.d.ts.map +1 -0
- package/dist/cjs/internal/JournalRecords.js +122 -0
- package/dist/cjs/internal/JournalRecords.js.map +7 -0
- package/dist/cjs/internal/NodeJournal.d.ts +157 -0
- package/dist/cjs/internal/NodeJournal.d.ts.map +1 -0
- package/dist/cjs/internal/NodeJournal.js +192 -0
- package/dist/cjs/internal/NodeJournal.js.map +7 -0
- package/dist/cjs/internal/Ordering.d.ts +14 -0
- package/dist/cjs/internal/Ordering.d.ts.map +1 -0
- package/dist/cjs/internal/Ordering.js +25 -0
- package/dist/cjs/internal/Ordering.js.map +7 -0
- package/dist/cjs/internal/PlanInputs.d.ts +14 -0
- package/dist/cjs/internal/PlanInputs.d.ts.map +1 -0
- package/dist/cjs/internal/PlanInputs.js +78 -0
- package/dist/cjs/internal/PlanInputs.js.map +7 -0
- package/dist/cjs/internal/PlanMerges.d.ts +178 -0
- package/dist/cjs/internal/PlanMerges.d.ts.map +1 -0
- package/dist/cjs/internal/PlanMerges.js +125 -0
- package/dist/cjs/internal/PlanMerges.js.map +7 -0
- package/dist/cjs/internal/ProvenanceSlot.d.ts +30 -0
- package/dist/cjs/internal/ProvenanceSlot.d.ts.map +1 -0
- package/dist/cjs/internal/ProvenanceSlot.js +53 -0
- package/dist/cjs/internal/ProvenanceSlot.js.map +7 -0
- package/dist/cjs/internal/ResultEnvelope.d.ts +88 -0
- package/dist/cjs/internal/ResultEnvelope.d.ts.map +1 -0
- package/dist/cjs/internal/ResultEnvelope.js +90 -0
- package/dist/cjs/internal/ResultEnvelope.js.map +7 -0
- package/dist/cjs/internal/RetentionOps.d.ts +414 -0
- package/dist/cjs/internal/RetentionOps.d.ts.map +1 -0
- package/dist/cjs/internal/RetentionOps.js +354 -0
- package/dist/cjs/internal/RetentionOps.js.map +7 -0
- package/dist/cjs/internal/RunCatalogOps.d.ts +118 -0
- package/dist/cjs/internal/RunCatalogOps.d.ts.map +1 -0
- package/dist/cjs/internal/RunCatalogOps.js +85 -0
- package/dist/cjs/internal/RunCatalogOps.js.map +7 -0
- package/dist/cjs/internal/RunCoordinator.d.ts +78 -0
- package/dist/cjs/internal/RunCoordinator.d.ts.map +1 -0
- package/dist/cjs/internal/RunCoordinator.js +123 -0
- package/dist/cjs/internal/RunCoordinator.js.map +7 -0
- package/dist/cjs/internal/RunDriver.d.ts +192 -0
- package/dist/cjs/internal/RunDriver.d.ts.map +1 -0
- package/dist/cjs/internal/RunDriver.js +1584 -0
- package/dist/cjs/internal/RunDriver.js.map +7 -0
- package/dist/cjs/internal/RunLifecycle.d.ts +22 -0
- package/dist/cjs/internal/RunLifecycle.d.ts.map +1 -0
- package/dist/cjs/internal/RunLifecycle.js +63 -0
- package/dist/cjs/internal/RunLifecycle.js.map +7 -0
- package/dist/cjs/internal/RunListing.d.ts +78 -0
- package/dist/cjs/internal/RunListing.d.ts.map +1 -0
- package/dist/cjs/internal/RunListing.js +171 -0
- package/dist/cjs/internal/RunListing.js.map +7 -0
- package/dist/cjs/internal/RunListingError.d.ts +35 -0
- package/dist/cjs/internal/RunListingError.d.ts.map +1 -0
- package/dist/cjs/internal/RunListingError.js +47 -0
- package/dist/cjs/internal/RunListingError.js.map +7 -0
- package/dist/cjs/internal/RuntimeGraph.d.ts +73 -0
- package/dist/cjs/internal/RuntimeGraph.d.ts.map +1 -0
- package/dist/cjs/internal/RuntimeGraph.js +180 -0
- package/dist/cjs/internal/RuntimeGraph.js.map +7 -0
- package/dist/cjs/internal/SandboxedExecution.d.ts +80 -0
- package/dist/cjs/internal/SandboxedExecution.d.ts.map +1 -0
- package/dist/cjs/internal/SandboxedExecution.js +104 -0
- package/dist/cjs/internal/SandboxedExecution.js.map +7 -0
- package/dist/cjs/internal/StateTransaction.d.ts +44 -0
- package/dist/cjs/internal/StateTransaction.d.ts.map +1 -0
- package/dist/cjs/internal/StateTransaction.js +52 -0
- package/dist/cjs/internal/StateTransaction.js.map +7 -0
- package/dist/cjs/internal/StepFacts.d.ts +14 -0
- package/dist/cjs/internal/StepFacts.d.ts.map +1 -0
- package/dist/cjs/internal/StepFacts.js +58 -0
- package/dist/cjs/internal/StepFacts.js.map +7 -0
- package/dist/cjs/internal/TypedEvents.d.ts +14 -0
- package/dist/cjs/internal/TypedEvents.d.ts.map +1 -0
- package/dist/cjs/internal/TypedEvents.js +37 -0
- package/dist/cjs/internal/TypedEvents.js.map +7 -0
- package/dist/cjs/migrations/0001_initial.d.ts +17 -0
- package/dist/cjs/migrations/0001_initial.d.ts.map +1 -0
- package/dist/cjs/migrations/0001_initial.js +61 -0
- package/dist/cjs/migrations/0001_initial.js.map +7 -0
- package/dist/cjs/migrations/0002_selection_store.d.ts +15 -0
- package/dist/cjs/migrations/0002_selection_store.d.ts.map +1 -0
- package/dist/cjs/migrations/0002_selection_store.js +56 -0
- package/dist/cjs/migrations/0002_selection_store.js.map +7 -0
- package/dist/cjs/migrations/0003_plan_inputs.d.ts +13 -0
- package/dist/cjs/migrations/0003_plan_inputs.d.ts.map +1 -0
- package/dist/cjs/migrations/0003_plan_inputs.js +90 -0
- package/dist/cjs/migrations/0003_plan_inputs.js.map +7 -0
- package/dist/cjs/migrations/0004_plan_environment.d.ts +14 -0
- package/dist/cjs/migrations/0004_plan_environment.d.ts.map +1 -0
- package/dist/cjs/migrations/0004_plan_environment.js +56 -0
- package/dist/cjs/migrations/0004_plan_environment.js.map +7 -0
- package/dist/cjs/migrations/0005_plan_merges.d.ts +14 -0
- package/dist/cjs/migrations/0005_plan_merges.d.ts.map +1 -0
- package/dist/cjs/migrations/0005_plan_merges.js +82 -0
- package/dist/cjs/migrations/0005_plan_merges.js.map +7 -0
- package/dist/cjs/migrations/0006_execution_listing.d.ts +15 -0
- package/dist/cjs/migrations/0006_execution_listing.d.ts.map +1 -0
- package/dist/cjs/migrations/0006_execution_listing.js +101 -0
- package/dist/cjs/migrations/0006_execution_listing.js.map +7 -0
- package/dist/cjs/migrations/0007_run_parent_sequence.d.ts +15 -0
- package/dist/cjs/migrations/0007_run_parent_sequence.d.ts.map +1 -0
- package/dist/cjs/migrations/0007_run_parent_sequence.js +40 -0
- package/dist/cjs/migrations/0007_run_parent_sequence.js.map +7 -0
- package/dist/cjs/migrations/0008_deferred_consumption.d.ts +16 -0
- package/dist/cjs/migrations/0008_deferred_consumption.d.ts.map +1 -0
- package/dist/cjs/migrations/0008_deferred_consumption.js +45 -0
- package/dist/cjs/migrations/0008_deferred_consumption.js.map +7 -0
- package/dist/cjs/migrations/0009_deferred_clock_facts.d.ts +24 -0
- package/dist/cjs/migrations/0009_deferred_clock_facts.d.ts.map +1 -0
- package/dist/cjs/migrations/0009_deferred_clock_facts.js +141 -0
- package/dist/cjs/migrations/0009_deferred_clock_facts.js.map +7 -0
- package/dist/cjs/migrations/0010_pending_cancellation.d.ts +15 -0
- package/dist/cjs/migrations/0010_pending_cancellation.d.ts.map +1 -0
- package/dist/cjs/migrations/0010_pending_cancellation.js +41 -0
- package/dist/cjs/migrations/0010_pending_cancellation.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/test/TestStores.d.ts +89 -0
- package/dist/cjs/test/TestStores.d.ts.map +1 -0
- package/dist/cjs/test/TestStores.js +98 -0
- package/dist/cjs/test/TestStores.js.map +7 -0
- package/dist/esm/ArtifactGc.d.ts +235 -0
- package/dist/esm/ArtifactGc.d.ts.map +1 -0
- package/dist/esm/ArtifactGc.js +268 -0
- package/dist/esm/ArtifactGc.js.map +1 -0
- package/dist/esm/ArtifactSync.d.ts +164 -0
- package/dist/esm/ArtifactSync.d.ts.map +1 -0
- package/dist/esm/ArtifactSync.js +176 -0
- package/dist/esm/ArtifactSync.js.map +1 -0
- package/dist/esm/CacheSync.d.ts +112 -0
- package/dist/esm/CacheSync.d.ts.map +1 -0
- package/dist/esm/CacheSync.js +94 -0
- package/dist/esm/CacheSync.js.map +1 -0
- package/dist/esm/DeferredClockFold.d.ts +354 -0
- package/dist/esm/DeferredClockFold.d.ts.map +1 -0
- package/dist/esm/DeferredClockFold.js +472 -0
- package/dist/esm/DeferredClockFold.js.map +1 -0
- package/dist/esm/DisasterRecovery.d.ts +431 -0
- package/dist/esm/DisasterRecovery.d.ts.map +1 -0
- package/dist/esm/DisasterRecovery.js +523 -0
- package/dist/esm/DisasterRecovery.js.map +1 -0
- package/dist/esm/DurableEngineState.d.ts +776 -0
- package/dist/esm/DurableEngineState.d.ts.map +1 -0
- package/dist/esm/DurableEngineState.js +1648 -0
- package/dist/esm/DurableEngineState.js.map +1 -0
- package/dist/esm/EngineStore.d.ts +158 -0
- package/dist/esm/EngineStore.d.ts.map +1 -0
- package/dist/esm/EngineStore.js +403 -0
- package/dist/esm/EngineStore.js.map +1 -0
- package/dist/esm/EngineStoreMetrics.d.ts +276 -0
- package/dist/esm/EngineStoreMetrics.d.ts.map +1 -0
- package/dist/esm/EngineStoreMetrics.js +260 -0
- package/dist/esm/EngineStoreMetrics.js.map +1 -0
- package/dist/esm/Errors.d.ts +22 -0
- package/dist/esm/Errors.d.ts.map +1 -0
- package/dist/esm/Errors.js +22 -0
- package/dist/esm/Errors.js.map +1 -0
- package/dist/esm/EventTypes.d.ts +27 -0
- package/dist/esm/EventTypes.d.ts.map +1 -0
- package/dist/esm/EventTypes.js +27 -0
- package/dist/esm/EventTypes.js.map +1 -0
- package/dist/esm/ExecutionFacts.d.ts +59 -0
- package/dist/esm/ExecutionFacts.d.ts.map +1 -0
- package/dist/esm/ExecutionFacts.js +96 -0
- package/dist/esm/ExecutionFacts.js.map +1 -0
- package/dist/esm/ExecutionSnapshot.d.ts +117 -0
- package/dist/esm/ExecutionSnapshot.d.ts.map +1 -0
- package/dist/esm/ExecutionSnapshot.js +95 -0
- package/dist/esm/ExecutionSnapshot.js.map +1 -0
- package/dist/esm/Inconsistency.d.ts +154 -0
- package/dist/esm/Inconsistency.d.ts.map +1 -0
- package/dist/esm/Inconsistency.js +133 -0
- package/dist/esm/Inconsistency.js.map +1 -0
- package/dist/esm/Migrations.d.ts +56 -0
- package/dist/esm/Migrations.d.ts.map +1 -0
- package/dist/esm/Migrations.js +91 -0
- package/dist/esm/Migrations.js.map +1 -0
- package/dist/esm/OwnerIdentity.d.ts +91 -0
- package/dist/esm/OwnerIdentity.d.ts.map +1 -0
- package/dist/esm/OwnerIdentity.js +99 -0
- package/dist/esm/OwnerIdentity.js.map +1 -0
- package/dist/esm/PlanInputStore.d.ts +110 -0
- package/dist/esm/PlanInputStore.d.ts.map +1 -0
- package/dist/esm/PlanInputStore.js +207 -0
- package/dist/esm/PlanInputStore.js.map +1 -0
- package/dist/esm/PlanMergeStore.d.ts +113 -0
- package/dist/esm/PlanMergeStore.d.ts.map +1 -0
- package/dist/esm/PlanMergeStore.js +244 -0
- package/dist/esm/PlanMergeStore.js.map +1 -0
- package/dist/esm/PlanScheduler.d.ts +363 -0
- package/dist/esm/PlanScheduler.d.ts.map +1 -0
- package/dist/esm/PlanScheduler.js +1321 -0
- package/dist/esm/PlanScheduler.js.map +1 -0
- package/dist/esm/Reconciliation.d.ts +175 -0
- package/dist/esm/Reconciliation.d.ts.map +1 -0
- package/dist/esm/Reconciliation.js +175 -0
- package/dist/esm/Reconciliation.js.map +1 -0
- package/dist/esm/ReplayOnly.d.ts +91 -0
- package/dist/esm/ReplayOnly.d.ts.map +1 -0
- package/dist/esm/ReplayOnly.js +59 -0
- package/dist/esm/ReplayOnly.js.map +1 -0
- package/dist/esm/Retention.d.ts +113 -0
- package/dist/esm/Retention.d.ts.map +1 -0
- package/dist/esm/Retention.js +139 -0
- package/dist/esm/Retention.js.map +1 -0
- package/dist/esm/RunCatalogRead.d.ts +17 -0
- package/dist/esm/RunCatalogRead.d.ts.map +1 -0
- package/dist/esm/RunCatalogRead.js +17 -0
- package/dist/esm/RunCatalogRead.js.map +1 -0
- package/dist/esm/RunChangeFeed.d.ts +75 -0
- package/dist/esm/RunChangeFeed.d.ts.map +1 -0
- package/dist/esm/RunChangeFeed.js +81 -0
- package/dist/esm/RunChangeFeed.js.map +1 -0
- package/dist/esm/RunState.d.ts +116 -0
- package/dist/esm/RunState.d.ts.map +1 -0
- package/dist/esm/RunState.js +109 -0
- package/dist/esm/RunState.js.map +1 -0
- package/dist/esm/Selection.d.ts +495 -0
- package/dist/esm/Selection.d.ts.map +1 -0
- package/dist/esm/Selection.js +482 -0
- package/dist/esm/Selection.js.map +1 -0
- package/dist/esm/SelectionStore.d.ts +141 -0
- package/dist/esm/SelectionStore.d.ts.map +1 -0
- package/dist/esm/SelectionStore.js +215 -0
- package/dist/esm/SelectionStore.js.map +1 -0
- package/dist/esm/StepBoundary.d.ts +501 -0
- package/dist/esm/StepBoundary.d.ts.map +1 -0
- package/dist/esm/StepBoundary.js +919 -0
- package/dist/esm/StepBoundary.js.map +1 -0
- package/dist/esm/StepCacheFold.d.ts +148 -0
- package/dist/esm/StepCacheFold.d.ts.map +1 -0
- package/dist/esm/StepCacheFold.js +201 -0
- package/dist/esm/StepCacheFold.js.map +1 -0
- package/dist/esm/StepSandbox.d.ts +78 -0
- package/dist/esm/StepSandbox.d.ts.map +1 -0
- package/dist/esm/StepSandbox.js +70 -0
- package/dist/esm/StepSandbox.js.map +1 -0
- package/dist/esm/WakeBus.d.ts +116 -0
- package/dist/esm/WakeBus.d.ts.map +1 -0
- package/dist/esm/WakeBus.js +121 -0
- package/dist/esm/WakeBus.js.map +1 -0
- package/dist/esm/WorkspaceSandbox.d.ts +619 -0
- package/dist/esm/WorkspaceSandbox.d.ts.map +1 -0
- package/dist/esm/WorkspaceSandbox.js +985 -0
- package/dist/esm/WorkspaceSandbox.js.map +1 -0
- package/dist/esm/index.d.ts +157 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +157 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/ActionPersistence.d.ts +276 -0
- package/dist/esm/internal/ActionPersistence.d.ts.map +1 -0
- package/dist/esm/internal/ActionPersistence.js +2306 -0
- package/dist/esm/internal/ActionPersistence.js.map +1 -0
- package/dist/esm/internal/ArtifactRoots.d.ts +38 -0
- package/dist/esm/internal/ArtifactRoots.d.ts.map +1 -0
- package/dist/esm/internal/ArtifactRoots.js +76 -0
- package/dist/esm/internal/ArtifactRoots.js.map +1 -0
- package/dist/esm/internal/AttemptAdmission.d.ts +53 -0
- package/dist/esm/internal/AttemptAdmission.d.ts.map +1 -0
- package/dist/esm/internal/AttemptAdmission.js +52 -0
- package/dist/esm/internal/AttemptAdmission.js.map +1 -0
- package/dist/esm/internal/AttemptLifecycle.d.ts +245 -0
- package/dist/esm/internal/AttemptLifecycle.d.ts.map +1 -0
- package/dist/esm/internal/AttemptLifecycle.js +104 -0
- package/dist/esm/internal/AttemptLifecycle.js.map +1 -0
- package/dist/esm/internal/AttemptProbe.d.ts +53 -0
- package/dist/esm/internal/AttemptProbe.d.ts.map +1 -0
- package/dist/esm/internal/AttemptProbe.js +83 -0
- package/dist/esm/internal/AttemptProbe.js.map +1 -0
- package/dist/esm/internal/CacheAdmission.d.ts +79 -0
- package/dist/esm/internal/CacheAdmission.d.ts.map +1 -0
- package/dist/esm/internal/CacheAdmission.js +72 -0
- package/dist/esm/internal/CacheAdmission.js.map +1 -0
- package/dist/esm/internal/CacheAgeHistory.d.ts +27 -0
- package/dist/esm/internal/CacheAgeHistory.d.ts.map +1 -0
- package/dist/esm/internal/CacheAgeHistory.js +49 -0
- package/dist/esm/internal/CacheAgeHistory.js.map +1 -0
- package/dist/esm/internal/CacheAgeVerdicts.d.ts +15 -0
- package/dist/esm/internal/CacheAgeVerdicts.d.ts.map +1 -0
- package/dist/esm/internal/CacheAgeVerdicts.js +54 -0
- package/dist/esm/internal/CacheAgeVerdicts.js.map +1 -0
- package/dist/esm/internal/CacheOutputPolicy.d.ts +24 -0
- package/dist/esm/internal/CacheOutputPolicy.d.ts.map +1 -0
- package/dist/esm/internal/CacheOutputPolicy.js +73 -0
- package/dist/esm/internal/CacheOutputPolicy.js.map +1 -0
- package/dist/esm/internal/CachePublication.d.ts +97 -0
- package/dist/esm/internal/CachePublication.d.ts.map +1 -0
- package/dist/esm/internal/CachePublication.js +116 -0
- package/dist/esm/internal/CachePublication.js.map +1 -0
- package/dist/esm/internal/CallFacts.d.ts +15 -0
- package/dist/esm/internal/CallFacts.d.ts.map +1 -0
- package/dist/esm/internal/CallFacts.js +83 -0
- package/dist/esm/internal/CallFacts.js.map +1 -0
- package/dist/esm/internal/CopiedRecord.d.ts +61 -0
- package/dist/esm/internal/CopiedRecord.d.ts.map +1 -0
- package/dist/esm/internal/CopiedRecord.js +165 -0
- package/dist/esm/internal/CopiedRecord.js.map +1 -0
- package/dist/esm/internal/DeferredPersistence.d.ts +108 -0
- package/dist/esm/internal/DeferredPersistence.d.ts.map +1 -0
- package/dist/esm/internal/DeferredPersistence.js +240 -0
- package/dist/esm/internal/DeferredPersistence.js.map +1 -0
- package/dist/esm/internal/EffectRecords.d.ts +92 -0
- package/dist/esm/internal/EffectRecords.d.ts.map +1 -0
- package/dist/esm/internal/EffectRecords.js +94 -0
- package/dist/esm/internal/EffectRecords.js.map +1 -0
- package/dist/esm/internal/EngineJj.d.ts +30 -0
- package/dist/esm/internal/EngineJj.d.ts.map +1 -0
- package/dist/esm/internal/EngineJj.js +29 -0
- package/dist/esm/internal/EngineJj.js.map +1 -0
- package/dist/esm/internal/EngineStateSchema.d.ts +68 -0
- package/dist/esm/internal/EngineStateSchema.d.ts.map +1 -0
- package/dist/esm/internal/EngineStateSchema.js +53 -0
- package/dist/esm/internal/EngineStateSchema.js.map +1 -0
- package/dist/esm/internal/ExecutionSnapshotRead.d.ts +162 -0
- package/dist/esm/internal/ExecutionSnapshotRead.d.ts.map +1 -0
- package/dist/esm/internal/ExecutionSnapshotRead.js +218 -0
- package/dist/esm/internal/ExecutionSnapshotRead.js.map +1 -0
- package/dist/esm/internal/ExecutionSnapshotRelations.d.ts +39 -0
- package/dist/esm/internal/ExecutionSnapshotRelations.d.ts.map +1 -0
- package/dist/esm/internal/ExecutionSnapshotRelations.js +81 -0
- package/dist/esm/internal/ExecutionSnapshotRelations.js.map +1 -0
- package/dist/esm/internal/ExitEncoding.d.ts +180 -0
- package/dist/esm/internal/ExitEncoding.d.ts.map +1 -0
- package/dist/esm/internal/ExitEncoding.js +361 -0
- package/dist/esm/internal/ExitEncoding.js.map +1 -0
- package/dist/esm/internal/FileBoundarySnapshot.d.ts +14 -0
- package/dist/esm/internal/FileBoundarySnapshot.d.ts.map +1 -0
- package/dist/esm/internal/FileBoundarySnapshot.js +29 -0
- package/dist/esm/internal/FileBoundarySnapshot.js.map +1 -0
- package/dist/esm/internal/FileEnumeration.d.ts +127 -0
- package/dist/esm/internal/FileEnumeration.d.ts.map +1 -0
- package/dist/esm/internal/FileEnumeration.js +236 -0
- package/dist/esm/internal/FileEnumeration.js.map +1 -0
- package/dist/esm/internal/HostReflection.d.ts +80 -0
- package/dist/esm/internal/HostReflection.d.ts.map +1 -0
- package/dist/esm/internal/HostReflection.js +98 -0
- package/dist/esm/internal/HostReflection.js.map +1 -0
- package/dist/esm/internal/JournalRecords.d.ts +325 -0
- package/dist/esm/internal/JournalRecords.d.ts.map +1 -0
- package/dist/esm/internal/JournalRecords.js +306 -0
- package/dist/esm/internal/JournalRecords.js.map +1 -0
- package/dist/esm/internal/NodeJournal.d.ts +157 -0
- package/dist/esm/internal/NodeJournal.d.ts.map +1 -0
- package/dist/esm/internal/NodeJournal.js +298 -0
- package/dist/esm/internal/NodeJournal.js.map +1 -0
- package/dist/esm/internal/Ordering.d.ts +14 -0
- package/dist/esm/internal/Ordering.d.ts.map +1 -0
- package/dist/esm/internal/Ordering.js +14 -0
- package/dist/esm/internal/Ordering.js.map +1 -0
- package/dist/esm/internal/PlanInputs.d.ts +14 -0
- package/dist/esm/internal/PlanInputs.d.ts.map +1 -0
- package/dist/esm/internal/PlanInputs.js +57 -0
- package/dist/esm/internal/PlanInputs.js.map +1 -0
- package/dist/esm/internal/PlanMerges.d.ts +178 -0
- package/dist/esm/internal/PlanMerges.d.ts.map +1 -0
- package/dist/esm/internal/PlanMerges.js +113 -0
- package/dist/esm/internal/PlanMerges.js.map +1 -0
- package/dist/esm/internal/ProvenanceSlot.d.ts +30 -0
- package/dist/esm/internal/ProvenanceSlot.d.ts.map +1 -0
- package/dist/esm/internal/ProvenanceSlot.js +39 -0
- package/dist/esm/internal/ProvenanceSlot.js.map +1 -0
- package/dist/esm/internal/ResultEnvelope.d.ts +88 -0
- package/dist/esm/internal/ResultEnvelope.d.ts.map +1 -0
- package/dist/esm/internal/ResultEnvelope.js +83 -0
- package/dist/esm/internal/ResultEnvelope.js.map +1 -0
- package/dist/esm/internal/RetentionOps.d.ts +414 -0
- package/dist/esm/internal/RetentionOps.d.ts.map +1 -0
- package/dist/esm/internal/RetentionOps.js +576 -0
- package/dist/esm/internal/RetentionOps.js.map +1 -0
- package/dist/esm/internal/RunCatalogOps.d.ts +118 -0
- package/dist/esm/internal/RunCatalogOps.d.ts.map +1 -0
- package/dist/esm/internal/RunCatalogOps.js +120 -0
- package/dist/esm/internal/RunCatalogOps.js.map +1 -0
- package/dist/esm/internal/RunCoordinator.d.ts +78 -0
- package/dist/esm/internal/RunCoordinator.d.ts.map +1 -0
- package/dist/esm/internal/RunCoordinator.js +115 -0
- package/dist/esm/internal/RunCoordinator.js.map +1 -0
- package/dist/esm/internal/RunDriver.d.ts +192 -0
- package/dist/esm/internal/RunDriver.d.ts.map +1 -0
- package/dist/esm/internal/RunDriver.js +2334 -0
- package/dist/esm/internal/RunDriver.js.map +1 -0
- package/dist/esm/internal/RunLifecycle.d.ts +22 -0
- package/dist/esm/internal/RunLifecycle.d.ts.map +1 -0
- package/dist/esm/internal/RunLifecycle.js +49 -0
- package/dist/esm/internal/RunLifecycle.js.map +1 -0
- package/dist/esm/internal/RunListing.d.ts +78 -0
- package/dist/esm/internal/RunListing.d.ts.map +1 -0
- package/dist/esm/internal/RunListing.js +146 -0
- package/dist/esm/internal/RunListing.js.map +1 -0
- package/dist/esm/internal/RunListingError.d.ts +35 -0
- package/dist/esm/internal/RunListingError.d.ts.map +1 -0
- package/dist/esm/internal/RunListingError.js +27 -0
- package/dist/esm/internal/RunListingError.js.map +1 -0
- package/dist/esm/internal/RuntimeGraph.d.ts +73 -0
- package/dist/esm/internal/RuntimeGraph.d.ts.map +1 -0
- package/dist/esm/internal/RuntimeGraph.js +182 -0
- package/dist/esm/internal/RuntimeGraph.js.map +1 -0
- package/dist/esm/internal/SandboxedExecution.d.ts +80 -0
- package/dist/esm/internal/SandboxedExecution.d.ts.map +1 -0
- package/dist/esm/internal/SandboxedExecution.js +107 -0
- package/dist/esm/internal/SandboxedExecution.js.map +1 -0
- package/dist/esm/internal/StateTransaction.d.ts +44 -0
- package/dist/esm/internal/StateTransaction.d.ts.map +1 -0
- package/dist/esm/internal/StateTransaction.js +54 -0
- package/dist/esm/internal/StateTransaction.js.map +1 -0
- package/dist/esm/internal/StepFacts.d.ts +14 -0
- package/dist/esm/internal/StepFacts.d.ts.map +1 -0
- package/dist/esm/internal/StepFacts.js +35 -0
- package/dist/esm/internal/StepFacts.js.map +1 -0
- package/dist/esm/internal/TypedEvents.d.ts +14 -0
- package/dist/esm/internal/TypedEvents.d.ts.map +1 -0
- package/dist/esm/internal/TypedEvents.js +14 -0
- package/dist/esm/internal/TypedEvents.js.map +1 -0
- package/dist/esm/migrations/0001_initial.d.ts +17 -0
- package/dist/esm/migrations/0001_initial.d.ts.map +1 -0
- package/dist/esm/migrations/0001_initial.js +41 -0
- package/dist/esm/migrations/0001_initial.js.map +1 -0
- package/dist/esm/migrations/0002_selection_store.d.ts +15 -0
- package/dist/esm/migrations/0002_selection_store.d.ts.map +1 -0
- package/dist/esm/migrations/0002_selection_store.js +34 -0
- package/dist/esm/migrations/0002_selection_store.js.map +1 -0
- package/dist/esm/migrations/0003_plan_inputs.d.ts +13 -0
- package/dist/esm/migrations/0003_plan_inputs.d.ts.map +1 -0
- package/dist/esm/migrations/0003_plan_inputs.js +70 -0
- package/dist/esm/migrations/0003_plan_inputs.js.map +1 -0
- package/dist/esm/migrations/0004_plan_environment.d.ts +14 -0
- package/dist/esm/migrations/0004_plan_environment.d.ts.map +1 -0
- package/dist/esm/migrations/0004_plan_environment.js +33 -0
- package/dist/esm/migrations/0004_plan_environment.js.map +1 -0
- package/dist/esm/migrations/0005_plan_merges.d.ts +14 -0
- package/dist/esm/migrations/0005_plan_merges.d.ts.map +1 -0
- package/dist/esm/migrations/0005_plan_merges.js +59 -0
- package/dist/esm/migrations/0005_plan_merges.js.map +1 -0
- package/dist/esm/migrations/0006_execution_listing.d.ts +15 -0
- package/dist/esm/migrations/0006_execution_listing.d.ts.map +1 -0
- package/dist/esm/migrations/0006_execution_listing.js +81 -0
- package/dist/esm/migrations/0006_execution_listing.js.map +1 -0
- package/dist/esm/migrations/0007_run_parent_sequence.d.ts +15 -0
- package/dist/esm/migrations/0007_run_parent_sequence.d.ts.map +1 -0
- package/dist/esm/migrations/0007_run_parent_sequence.js +18 -0
- package/dist/esm/migrations/0007_run_parent_sequence.js.map +1 -0
- package/dist/esm/migrations/0008_deferred_consumption.d.ts +16 -0
- package/dist/esm/migrations/0008_deferred_consumption.d.ts.map +1 -0
- package/dist/esm/migrations/0008_deferred_consumption.js +24 -0
- package/dist/esm/migrations/0008_deferred_consumption.js.map +1 -0
- package/dist/esm/migrations/0009_deferred_clock_facts.d.ts +24 -0
- package/dist/esm/migrations/0009_deferred_clock_facts.d.ts.map +1 -0
- package/dist/esm/migrations/0009_deferred_clock_facts.js +127 -0
- package/dist/esm/migrations/0009_deferred_clock_facts.js.map +1 -0
- package/dist/esm/migrations/0010_pending_cancellation.d.ts +15 -0
- package/dist/esm/migrations/0010_pending_cancellation.d.ts.map +1 -0
- package/dist/esm/migrations/0010_pending_cancellation.js +19 -0
- package/dist/esm/migrations/0010_pending_cancellation.js.map +1 -0
- package/dist/esm/test/TestStores.d.ts +89 -0
- package/dist/esm/test/TestStores.d.ts.map +1 -0
- package/dist/esm/test/TestStores.js +103 -0
- package/dist/esm/test/TestStores.js.map +1 -0
- package/docs/README.md +113 -0
- package/docs/api.md +1494 -0
- package/docs/concepts/attempts-and-replay.md +149 -0
- package/docs/concepts/cache-admission.md +265 -0
- package/docs/concepts/call-facts.md +86 -0
- package/docs/concepts/durable-waits.md +175 -0
- package/docs/concepts/execution-facts.md +90 -0
- package/docs/concepts/ownership-and-fencing.md +128 -0
- package/docs/concepts/step-boundaries.md +148 -0
- package/docs/concepts/workspace-transactions.md +199 -0
- package/docs/event-types.md +14 -0
- package/docs/guides/back-up-and-restore.md +164 -0
- package/docs/guides/collect-unreferenced-artifacts.md +128 -0
- package/docs/guides/compose-a-durable-engine.md +146 -0
- package/docs/guides/coordinate-two-processes.md +120 -0
- package/docs/guides/defer-work-with-selection.md +171 -0
- package/docs/guides/delete-old-run-history.md +154 -0
- package/docs/guides/drive-a-plan.md +314 -0
- package/docs/guides/observe-engine-metrics.md +98 -0
- package/docs/guides/observe-executions.md +187 -0
- package/docs/guides/reclaim-runs-from-a-dead-host.md +133 -0
- package/docs/guides/share-a-cache-across-machines.md +134 -0
- package/docs/guides/testing.md +123 -0
- package/docs/installation.md +102 -0
- package/docs/quickstart.md +215 -0
- package/docs/troubleshooting.md +347 -0
- package/package.json +438 -3
- package/src/ArtifactGc.ts +408 -0
- package/src/ArtifactSync.ts +278 -0
- package/src/CacheSync.ts +131 -0
- package/src/DeferredClockFold.ts +586 -0
- package/src/DisasterRecovery.ts +888 -0
- package/src/DurableEngineState.ts +2656 -0
- package/src/EngineStore.ts +656 -0
- package/src/EngineStoreMetrics.ts +331 -0
- package/src/Errors.ts +28 -0
- package/src/EventTypes.ts +27 -0
- package/src/ExecutionFacts.ts +125 -0
- package/src/ExecutionSnapshot.ts +186 -0
- package/src/Inconsistency.ts +253 -0
- package/src/Migrations.ts +95 -0
- package/src/OwnerIdentity.ts +125 -0
- package/src/PlanInputStore.ts +292 -0
- package/src/PlanMergeStore.ts +330 -0
- package/src/PlanScheduler.ts +1806 -0
- package/src/Reconciliation.ts +224 -0
- package/src/ReplayOnly.ts +95 -0
- package/src/Retention.ts +214 -0
- package/src/RunCatalogRead.ts +27 -0
- package/src/RunChangeFeed.ts +125 -0
- package/src/RunState.ts +137 -0
- package/src/Selection.ts +683 -0
- package/src/SelectionStore.ts +353 -0
- package/src/StepBoundary.ts +1165 -0
- package/src/StepCacheFold.ts +244 -0
- package/src/StepSandbox.ts +110 -0
- package/src/WakeBus.ts +167 -0
- package/src/WorkspaceSandbox.ts +1604 -0
- package/src/index.ts +185 -0
- package/src/internal/ActionPersistence.ts +2687 -0
- package/src/internal/ArtifactRoots.ts +92 -0
- package/src/internal/AttemptAdmission.ts +76 -0
- package/src/internal/AttemptLifecycle.ts +163 -0
- package/src/internal/AttemptProbe.ts +90 -0
- package/src/internal/CacheAdmission.ts +133 -0
- package/src/internal/CacheAgeHistory.ts +58 -0
- package/src/internal/CacheAgeVerdicts.ts +61 -0
- package/src/internal/CacheOutputPolicy.ts +82 -0
- package/src/internal/CachePublication.ts +153 -0
- package/src/internal/CallFacts.ts +87 -0
- package/src/internal/CopiedRecord.ts +201 -0
- package/src/internal/DeferredPersistence.ts +459 -0
- package/src/internal/EffectRecords.ts +136 -0
- package/src/internal/EngineJj.ts +30 -0
- package/src/internal/EngineStateSchema.ts +92 -0
- package/src/internal/ExecutionSnapshotRead.ts +298 -0
- package/src/internal/ExecutionSnapshotRelations.ts +121 -0
- package/src/internal/ExitEncoding.ts +453 -0
- package/src/internal/FileBoundarySnapshot.ts +39 -0
- package/src/internal/FileEnumeration.ts +334 -0
- package/src/internal/HostReflection.ts +128 -0
- package/src/internal/JournalRecords.ts +396 -0
- package/src/internal/NodeJournal.ts +340 -0
- package/src/internal/Ordering.ts +14 -0
- package/src/internal/PlanInputs.ts +62 -0
- package/src/internal/PlanMerges.ts +123 -0
- package/src/internal/ProvenanceSlot.ts +52 -0
- package/src/internal/ResultEnvelope.ts +118 -0
- package/src/internal/RetentionOps.ts +865 -0
- package/src/internal/RunCatalogOps.ts +174 -0
- package/src/internal/RunCoordinator.ts +215 -0
- package/src/internal/RunDriver.ts +3152 -0
- package/src/internal/RunLifecycle.ts +53 -0
- package/src/internal/RunListing.ts +210 -0
- package/src/internal/RunListingError.ts +37 -0
- package/src/internal/RuntimeGraph.ts +253 -0
- package/src/internal/SandboxedExecution.ts +165 -0
- package/src/internal/StateTransaction.ts +71 -0
- package/src/internal/StepFacts.ts +36 -0
- package/src/internal/TypedEvents.ts +29 -0
- package/src/migrations/0001_initial.ts +51 -0
- package/src/migrations/0002_selection_store.ts +38 -0
- package/src/migrations/0003_plan_inputs.ts +75 -0
- package/src/migrations/0004_plan_environment.ts +34 -0
- package/src/migrations/0005_plan_merges.ts +60 -0
- package/src/migrations/0006_execution_listing.ts +86 -0
- package/src/migrations/0007_run_parent_sequence.ts +19 -0
- package/src/migrations/0008_deferred_consumption.ts +27 -0
- package/src/migrations/0009_deferred_clock_facts.ts +163 -0
- package/src/migrations/0010_pending_cancellation.ts +20 -0
- package/src/test/TestStores.ts +145 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RetentionOps.js","sourceRoot":"","sources":["../../../src/internal/RetentionOps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAA;AAClD,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAA;AAC5D,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAA;AACtD,OAAO,KAAK,KAAK,MAAM,cAAc,C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MAAM,GAAsB,MAAM,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,OAAsB,EAAE,EAAE,CACzF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;QACzE,MAAM,QAAQ,GAAG,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;QACzD,kEAAkE;QAClE,uEAAuE;QACvE,kEAAkE;QAClE,iEAAiE;QACjE,oEAAoE;QACpE,qCAAqC;QACrC,OAAO,KAAK,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAA;IACzD,CAAC,CAAC,CACH,CAAA;IAED,OAAO,EAAE,MAAM,EAAE,CAAA;AACnB,CAAC,CAAC,CAAA;AAEJ;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,KAAK,GAAyE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAChH,IAAI,EAAE,CACP,CAAA","sourcesContent":["/**\n * Retention: the one operation that deletes finished run state.\n *\n * Nothing in the composition removed a `flows_runs` row or anything that hangs\n * off one. Every run a workspace ever finished stayed in `.flows/engine.db`\n * with its attempts, its persisted deferred completions and clock deadlines,\n * its journal entries, and its checkpoints, and journal compaction is off by\n * default (`SqlJournal` `Options.compaction`), so the file only grew. This\n * module is the deletion side, and the whole of it: one operation, run\n * explicitly.\n *\n * Three properties make it safe to run against a live workspace.\n *\n * - **One transaction.** Every delete runs inside a single `journal.transact`,\n * so a crash leaves either a run with all of its rows or none of them —\n * never a run row whose history is gone, or history whose run row is gone.\n * - **Terminal and aged only.** A run is a candidate only when its status is\n * `completed`, `failed`, or `cancelled` AND it finished before the cutoff.\n * A running, pending, or suspended run is never a candidate at any age.\n * - **Nothing a live run still needs.** A candidate is retained when a live\n * run stands on either side of it in the lineage, over BOTH relations that\n * make one run the parent of another: the `flows_run_parents` edge a spawned\n * child is recorded under, and the reserved `parent_run_id` column the\n * rounds of one trampoline lineage are chained through. Upward: an aged\n * terminal run with a live ancestor stays, because a parent reads a settled\n * child's result out of its run row (`agent/await`) and a parent parked on\n * an approval, a deferred, or a timer can be parked for longer than the\n * threshold before it ever asks. Downward: an aged terminal run whose\n * descendant is still live stays, because deleting it would leave that\n * descendant's `parent_run_id` pointing at nothing and would drop the live\n * descendant's lineage edges with the `flows_run_parents_gc` trigger.\n * - **Explicit.** Nothing schedules this. Automatic retention stays opt-in,\n * for the reason `ArtifactGc` states: deletion is the irreversible\n * direction, and a human approving a plan must be approving the deletions.\n *\n * Journal history is deleted outright rather than compacted to a checkpoint.\n * `Journal.checkpoint` and `Journal.compact` are owner-fenced — `SqlJournal`'s\n * `fenceGuard` requires a consensus lease held by the exact owner passed in —\n * so neither can be called for a finished, ownerless run at all. Deleting the run's entries and checkpoints is strictly stronger than\n * compacting them to a checkpoint, and it happens in the same transaction as\n * the run row, which is the property a compaction could not have given.\n *\n * The operation is idempotent. With a positive integer limit and a fixed,\n * finite, acyclic run lineage, each successful non-dry pass deletes at least\n * one collectable run until none remain. Continuation children are selected\n * before parents; parents pinned by excluded children do not consume the\n * bound. Runs protected by age or live lineage remain until eligible.\n *\n * @since 0.1.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Journal from \"@smthrs/journal/Journal\"\nimport * as JournalEvent from \"@smthrs/journal/JournalEvent\"\nimport * as RunStore from \"@smthrs/run-store/RunStore\"\nimport * as Clock from \"effect/Clock\"\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\nimport * as Schema from \"effect/Schema\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\nimport type { SqlError } from \"effect/unstable/sql/SqlError\"\n\n/**\n * Stable error codes returned by retention.\n *\n * @category models\n * @since 0.1.0\n */\nexport const RetentionErrorCode = Schema.Literals([\"scan_failed\", \"delete_failed\"])\n\n/**\n * Stable error codes returned by retention.\n *\n * @category models\n * @since 0.1.0\n */\nexport type RetentionErrorCode = typeof RetentionErrorCode.Type\n\n/**\n * A retention pass that could not complete.\n *\n * `scan_failed` means the candidate set could not be computed and nothing was\n * deleted. `delete_failed` means the candidate set held but a delete refused;\n * the transaction rolled back, so nothing was deleted then either, and\n * re-running converges once the cause is fixed.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class RetentionError extends Schema.TaggedError<RetentionError>()(\n \"@smthrs/engine-store/RetentionError\",\n {\n code: RetentionErrorCode,\n message: Schema.String,\n cause: Schema.optional(Schema.Unknown)\n }\n) {}\n\n/**\n * Options for one retention pass.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface RetainOptions {\n /**\n * How long a run must have been finished to be collected, in milliseconds.\n * A run's age is measured from `finished_at_ms`, or from `created_at_ms`\n * for a terminal row that never recorded one. Zero collects every terminal\n * run; a negative value is read as zero.\n */\n readonly olderThanMs: number\n /**\n * Largest number of runs one pass deletes. Defaults to\n * {@link defaultLimit}. Retention is idempotent, so a workspace with more\n * aged runs than the bound converges over repeated passes instead of\n * holding one long write transaction open. A negative value is read as\n * zero, so a pass under a mistyped bound deletes nothing.\n */\n readonly limit?: number | undefined\n /** Compute and report the pass without deleting anything. */\n readonly dryRun?: boolean | undefined\n}\n\n/**\n * What one retention pass did, or — under `dryRun` — would do.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface RetainReport {\n /** Runs finished at or before this instant were candidates. */\n readonly cutoffMs: number\n /** The runs deleted, oldest first. */\n readonly runIds: ReadonlyArray<string>\n /**\n * Aged terminal runs left in place because a descendant of theirs is not\n * terminal, or is terminal and is not being deleted by this pass. They\n * become collectable once that descendant is. At most `limit` of them are\n * reported, the oldest first, so the report costs no more than the pass.\n */\n readonly retainedForLiveDescendants: ReadonlyArray<string>\n /**\n * Aged terminal runs left in place because an ancestor of theirs is not\n * terminal. That ancestor can still read the run's settled result through\n * `agent/await`, which answers out of the run row. They become collectable\n * once every ancestor is terminal — a terminal ancestor holds nothing back,\n * whatever its own age. A run retained for both reasons is reported under\n * {@link retainedForLiveDescendants}, and at most `limit` runs are reported.\n */\n readonly retainedForLiveAncestors: ReadonlyArray<string>\n readonly runs: number\n readonly attempts: number\n readonly clockDeadlines: number\n readonly deferredCompletions: number\n readonly journalEntries: number\n readonly journalCheckpoints: number\n /** Producer identities journal compaction kept after deleting event payloads. */\n readonly journalIdentities: number\n /** Time-travel archive rows; always zero where that table is not installed. */\n readonly archiveEntries: number\n /** Time-travel receipt rows reached through their audits. */\n readonly timeTravelReceipts: number\n readonly dryRun: boolean\n}\n\n/**\n * Explicit run retention.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Service {\n /**\n * Deletes up to `limit` aged terminal runs and their dependents atomically.\n * With a positive integer limit and a fixed, finite, acyclic lineage, each\n * successful non-dry pass makes progress until all collectable runs are gone,\n * including continuation chains longer than the bound. Age and live-lineage\n * protection still apply. Explicit only; nothing schedules this operation.\n */\n readonly retain: (\n options: RetainOptions\n ) => Effect.Effect<RetainReport, RetentionError | Journal.JournalError>\n}\n\n/**\n * Service tag for run retention.\n *\n * @category services\n * @since 0.1.0\n */\nexport class Retention extends Context.Service<Retention, Service>()(\"@smthrs/engine-store/Retention\") {}\n\n/**\n * Runs deleted by one pass when the caller names no bound. Large enough that\n * an ordinary workspace finishes in one pass, small enough that the write\n * transaction stays short on a workspace that has never been collected.\n *\n * @category constants\n * @since 0.1.0\n */\nexport const defaultLimit = 1000\n\n/**\n * Run ids per `IN (...)` list. SQLite's default host-parameter ceiling is 999.\n *\n * @category constants\n * @since 0.1.0\n */\nconst chunkSize = 500\n\n/**\n * One table a deleted run leaves rows in.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface RunScopedTable {\n readonly table: string\n /** The column naming the run. */\n readonly column: string\n /**\n * Whether the migration ladder this package composes installs the table.\n *\n * A ladder table missing from an engine database is a broken schema, so\n * {@link installedTables} can be asked to keep it and let the delete refuse.\n * A table beyond the ladder belongs to a store the host may simply not have\n * composed, and is skipped when the catalog does not list it.\n */\n readonly ladder: boolean\n /**\n * Whether the table also holds the runs' journal companion streams\n * (`JournalEvent.companionRunId`), which name a run through a derived id\n * rather than the run id itself. {@link companionStreams} lists them.\n */\n readonly companions?: boolean | undefined\n}\n\n/**\n * The journal companion streams a run owns beside its own stream. A deleted\n * run's companion streams go with it.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const companionStreams: ReadonlyArray<string> = [RunStore.companionStream]\n\n/**\n * Every table a deleted run leaves rows in, and the column naming the run.\n *\n * ONE inventory, because two passes read it: {@link Service.retain} over the\n * engine ladder, and `Retention.collect` over whatever a host's file holds. A\n * table listed by only one of them is a table the other leaks forever. Tables\n * are listed rather than discovered from foreign keys because the set spans\n * six packages that migrate into one database, and a silently missing entry is\n * exactly that leak.\n *\n * The run rows themselves are not here: they go last and in generation order,\n * which {@link deleteRuns} does after this list.\n * `flows_time_travel_receipts` is reached through its audit rather than listed\n * here because the upstream table has no run column: its `audit_id` points to\n * `flows_time_travel_audits.id`, whose row carries `run_id`.\n *\n * @category constants\n * @since 0.1.0\n */\nexport const runScopedTables: ReadonlyArray<RunScopedTable> = [\n { table: \"flows_deferred_completions\", column: \"execution_id\", ladder: true },\n { table: \"flows_clock_deadlines\", column: \"execution_id\", ladder: true },\n { table: \"flows_attempts\", column: \"run_id\", ladder: true },\n { table: \"flows_journal_events\", column: \"run_id\", ladder: true, companions: true },\n { table: \"flows_journal_checkpoints\", column: \"run_id\", ladder: true, companions: true },\n { table: \"flows_journal_dedup\", column: \"run_id\", ladder: true, companions: true },\n { table: \"flows_consensus_leases\", column: \"run_id\", ladder: true },\n { table: \"flows_step_cache_recorded\", column: \"recorded_run_id\", ladder: true },\n { table: \"flows_time_travel_archive\", column: \"run_id\", ladder: false },\n { table: \"flows_time_travel_snapshots\", column: \"run_id\", ladder: false },\n { table: \"flows_time_travel_audits\", column: \"run_id\", ladder: false },\n { table: \"flows_time_travel_edges\", column: \"child_run_id\", ladder: false },\n { table: \"control_run_messages\", column: \"run_id\", ladder: false },\n { table: \"control_runs\", column: \"run_id\", ladder: false }\n]\n\n/**\n * The statuses a run can never leave.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const terminalStatuses: ReadonlyArray<string> = [\"completed\", \"failed\", \"cancelled\"]\n\n/** `terminalStatuses` as a SQL list, for the lineage prelude below. */\nconst terminalList = terminalStatuses.map((status) => `'${status}'`).join(\", \")\n\n/**\n * The prelude every scan opens with: which runs a live run stands above, and\n * which it stands below.\n *\n * Two relations make one run the parent of another, and a walk over either one\n * alone misses half the lineage. A SPAWNED child records its parent as a\n * `flows_run_parents` edge, one row per parent so a diamond records both, and\n * leaves `parent_run_id` NULL: the engine reserves that column for the rounds\n * of one trampoline lineage (`RunDriver.continueLineage`). The edge is the\n * relation every `agent/await` depends on. `link` is both relations as one\n * edge list.\n *\n * `under_live` is every run reachable downward from a run that is not\n * terminal. Those runs have a live ancestor, which can still read a settled\n * result out of their run row. `over_live` is every run reachable upward from\n * one. Those runs have a live descendant, whose own lineage the\n * `flows_run_parents_gc` trigger would drop with them. An edge whose parent\n * row is gone is not reachable from `live` at all, so it holds nothing back,\n * and since only terminal runs are ever deleted it never can.\n *\n * The walks carry run ids and nothing else, so `UNION` makes them terminate on\n * their own: a corrupt edge that closed a cycle adds a row the set already\n * holds, and the walk stops. That matters because these reads run inside the\n * pass's write transaction. They are SQLite-specific, like the `sqlite_master`\n * probe below, and rc.0 is SQLite-only.\n *\n * `parentEdges: false` drops the `flows_run_parents` half of `link`. A\n * database that carries the run rows but not the engine's edge table — the\n * control plane's, which migrates the run store and the journal and nothing\n * else — has no edges to walk, and reading the missing table would fail the\n * whole scan. The `parent_run_id` half still runs, so the continuation\n * lineage is guarded there too. The retention pass itself always walks both.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const lineagePrelude = (\n options: { readonly parentEdges: boolean }\n): string => `\n WITH RECURSIVE\n link(child_id, parent_id) AS (\n ${\n options.parentEdges\n ? `SELECT child_id, parent_id FROM flows_run_parents\n UNION\n `\n : ``\n}SELECT run_id, parent_run_id FROM flows_runs WHERE parent_run_id IS NOT NULL\n ),\n live(run_id) AS (\n SELECT run_id FROM flows_runs WHERE status NOT IN (${terminalList})\n ),\n under_live(run_id) AS (\n SELECT link.child_id FROM link JOIN live ON live.run_id = link.parent_id\n UNION\n SELECT link.child_id FROM link JOIN under_live ON under_live.run_id = link.parent_id\n ),\n over_live(run_id) AS (\n SELECT link.parent_id FROM link JOIN live ON live.run_id = link.child_id\n UNION\n SELECT link.parent_id FROM link JOIN over_live ON over_live.run_id = link.child_id\n )\n `\n\n/**\n * The bound one pass may delete, as both passes read it.\n *\n * Clamped, not interpolated: SQLite reads a negative `LIMIT` as no limit at\n * all, which would make a mistyped bound a full sweep, and rejects `NaN` or a\n * fraction as a datatype mismatch. Anything that is not a non-negative safe\n * integer is read as zero, so the pass deletes nothing.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const normalizeLimit = (limit: number | undefined): number => {\n const bound = limit ?? defaultLimit\n return Number.isSafeInteger(bound) && bound >= 0 ? bound : 0\n}\n\n/**\n * Which runs a pass may delete, and which it must keep, as CTEs.\n *\n * `eligible` is every terminal run older than the cutoff that no live run\n * stands above or below. `blocked` is every other run plus every ancestor of\n * one over `parent_run_id`: a continuation parent must outlive every child\n * excluded by age or live lineage, and this propagates that exclusion before\n * any bound is applied. `inclusive` says whether a run finished exactly at\n * the cutoff is old enough.\n */\nconst scanPrelude = (\n sql: SqlClient.SqlClient,\n options: {\n readonly cutoffMs: number\n readonly inclusive: boolean\n readonly parentEdges: boolean\n readonly pins?: ReadonlyArray<string> | undefined\n }\n) =>\n sql`\n ${sql.unsafe(lineagePrelude({ parentEdges: options.parentEdges }))},\n eligible(run_id) AS (\n SELECT run_id FROM flows_runs\n WHERE ${sql.in(\"status\", terminalStatuses)}\n AND ${\n options.inclusive\n ? sql`COALESCE(finished_at_ms, created_at_ms) <= ${options.cutoffMs}`\n : sql`COALESCE(finished_at_ms, created_at_ms) < ${options.cutoffMs}`\n }\n AND run_id NOT IN (SELECT run_id FROM under_live)\n AND run_id NOT IN (SELECT run_id FROM over_live)\n AND ${\n options.pins === undefined || options.pins.length === 0 ?\n sql.literal(\"1 = 1\")\n : sql`run_id NOT IN ${sql.in(options.pins)}`\n }\n ),\n blocked(run_id) AS (\n SELECT run_id FROM flows_runs WHERE run_id NOT IN (SELECT run_id FROM eligible)\n UNION\n SELECT runs.parent_run_id FROM flows_runs AS runs\n JOIN blocked ON blocked.run_id = runs.run_id\n WHERE runs.parent_run_id IS NOT NULL\n )\n `\n\n/**\n * The runs one pass deletes: at most `limit` of them, children before parents.\n *\n * The one candidate query, shared by {@link Service.retain} and\n * `Retention.collect`. A trampoline parent always finishes before its\n * successor, so an oldest-first window over a lineage longer than the bound\n * held only ancestors, each pinned by the round just outside the window, and\n * every later pass selected the same window and deleted nothing. Depth walks\n * from roots, visiting each continuation row once; corrupt cycles have no\n * root and cannot enter the deletion set. Excluded runs and their ancestors\n * are dropped before the bound, so pinned parents cannot consume it. The\n * result is presented oldest first.\n *\n * @category getters\n * @since 1.0.0\n */\nexport const candidatesOf = (\n sql: SqlClient.SqlClient,\n options: {\n readonly cutoffMs: number\n readonly inclusive: boolean\n readonly parentEdges: boolean\n readonly pins?: ReadonlyArray<string> | undefined\n readonly limit: number\n }\n): Effect.Effect<ReadonlyArray<Candidate>, SqlError> =>\n sql<{ readonly run_id: string; readonly parent_run_id: string | null }>`\n ${scanPrelude(sql, options)},\n depths(run_id, depth) AS (\n SELECT run_id, 0 FROM flows_runs WHERE parent_run_id IS NULL\n UNION ALL\n SELECT runs.run_id, depths.depth + 1 FROM flows_runs AS runs\n JOIN depths ON runs.parent_run_id = depths.run_id\n ),\n selected AS (\n SELECT runs.run_id, runs.parent_run_id,\n COALESCE(runs.finished_at_ms, runs.created_at_ms) AS finished_at_ms\n FROM flows_runs AS runs JOIN depths ON depths.run_id = runs.run_id\n WHERE runs.run_id NOT IN (SELECT run_id FROM blocked)\n ORDER BY depths.depth DESC, COALESCE(runs.finished_at_ms, runs.created_at_ms), runs.run_id\n LIMIT ${normalizeLimit(options.limit)}\n )\n SELECT run_id, parent_run_id FROM selected ORDER BY finished_at_ms, run_id\n `.pipe(\n Effect.map((rows): ReadonlyArray<Candidate> =>\n rows.map((row) => ({ runId: row.run_id, parentRunId: row.parent_run_id }))\n )\n )\n\n/** Classifies a read of the scan phase, where nothing has been deleted yet. */\nconst scanning = (what: string) => (cause: unknown): RetentionError =>\n new RetentionError({ code: \"scan_failed\", message: `${what} could not be read`, cause })\n\n/** Classifies a statement of the delete phase, which rolls the pass back. */\nconst deleting = (what: string) => (cause: unknown): RetentionError =>\n new RetentionError({ code: \"delete_failed\", message: `${what} could not be collected`, cause })\n\nconst chunksOf = (ids: ReadonlyArray<string>): ReadonlyArray<ReadonlyArray<string>> => {\n const chunks: Array<ReadonlyArray<string>> = []\n for (let offset = 0; offset < ids.length; offset += chunkSize) {\n chunks.push(ids.slice(offset, offset + chunkSize))\n }\n return chunks\n}\n\n/**\n * A run a pass proposes to delete, and the run it names as its parent.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Candidate {\n readonly runId: string\n readonly parentRunId: string | null\n}\n\n/** A run and the candidate it names as its parent. */\ninterface ChildEdge {\n readonly runId: string\n readonly parentRunId: string\n}\n\n/**\n * What one deletion pass removed, or would remove under `dryRun`.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface DeletionReport {\n /** The candidates deleted, in the order they were given. */\n readonly runIds: ReadonlyArray<string>\n /** Candidates kept because a run outside the pass still names them. */\n readonly pinned: ReadonlyArray<string>\n /**\n * Rows counted per table, `flows_runs` included, zeroes omitted. Counted\n * whether or not the pass deletes, so a dry run reports the same numbers.\n */\n readonly deleted: Readonly<Record<string, number>>\n}\n\n/** Reads the installed SQLite table names once for inventory decisions. */\nconst installedTableNames = (sql: SqlClient.SqlClient): Effect.Effect<ReadonlySet<string>, RetentionError> =>\n Dialect.tables(sql).pipe(\n Effect.map((rows) => new Set(rows.map((row) => row.name))),\n Effect.mapError(scanning(\"the schema catalog\"))\n )\n\n/**\n * The {@link runScopedTables} entries this database actually has.\n *\n * `assumeLadder` keeps every entry the ladder installs whether the catalog\n * lists it or not. {@link Service.retain} passes `true`: this package composes\n * the run-store, journal, step-cache and engine migrations, so a ladder table\n * missing from the file it is pointed at is a broken schema, and a delete that\n * refuses says so. `Retention.collect` passes `false`, because it also runs\n * against the control plane's database, which migrates the run store and the\n * journal and nothing else; there a missing ladder table is a host that\n * composed fewer stores, and the pass still owes it a complete sweep of what\n * it has.\n *\n * The catalog read is SQLite-specific, like the lineage prelude above and the\n * `flows_run_parents_gc` trigger this package ships. rc.0 is SQLite-only.\n *\n * @category getters\n * @since 0.1.0\n */\nexport const installedTables = (\n sql: SqlClient.SqlClient,\n options: { readonly assumeLadder: boolean }\n): Effect.Effect<ReadonlyArray<RunScopedTable>, RetentionError> =>\n installedTableNames(sql).pipe(\n Effect.map((present) =>\n runScopedTables.filter((entry) => (options.assumeLadder && entry.ladder) || present.has(entry.table))\n )\n )\n\nconst countIn = (sql: SqlClient.SqlClient, table: string, column: string, ids: ReadonlyArray<string>) =>\n Effect.reduce(chunksOf(ids), () => 0, (total, chunk) =>\n sql<{ readonly total: number }>`\n SELECT COUNT(*) AS total FROM ${sql.unsafe(table)} WHERE ${sql.in(column, chunk)}\n `.pipe(\n Effect.map((rows) => rows.reduce((sum, row) => sum + Number(row.total), total)),\n Effect.mapError(deleting(table))\n ))\n\nconst deleteIn = (sql: SqlClient.SqlClient, table: string, column: string, ids: ReadonlyArray<string>) =>\n Effect.forEach(\n chunksOf(ids),\n (chunk) =>\n sql`DELETE FROM ${sql.unsafe(table)} WHERE ${sql.in(column, chunk)}`.pipe(\n Effect.mapError(deleting(table))\n ),\n { discard: true }\n )\n\nconst countTimeTravelReceipts = (sql: SqlClient.SqlClient, ids: ReadonlyArray<string>) =>\n Effect.reduce(chunksOf(ids), () => 0, (total, chunk) =>\n sql<{ readonly total: number }>`\n SELECT COUNT(*) AS total\n FROM flows_time_travel_receipts\n WHERE audit_id IN (\n SELECT id FROM flows_time_travel_audits WHERE ${sql.in(\"run_id\", chunk)}\n )\n `.pipe(\n Effect.map((rows) => rows.reduce((sum, row) => sum + Number(row.total), total)),\n Effect.mapError(deleting(\"flows_time_travel_receipts\"))\n ))\n\nconst deleteTimeTravelReceipts = (sql: SqlClient.SqlClient, ids: ReadonlyArray<string>) =>\n Effect.forEach(\n chunksOf(ids),\n (chunk) =>\n sql`\n DELETE FROM flows_time_travel_receipts\n WHERE audit_id IN (\n SELECT id FROM flows_time_travel_audits WHERE ${sql.in(\"run_id\", chunk)}\n )\n `.pipe(Effect.mapError(deleting(\"flows_time_travel_receipts\"))),\n { discard: true }\n )\n\n/** Every run whose parent is a candidate, candidates included. */\nconst childrenOf = (sql: SqlClient.SqlClient, candidateIds: ReadonlyArray<string>) =>\n Effect.reduce(\n chunksOf(candidateIds),\n (): Array<ChildEdge> => [],\n (accumulated, chunk) =>\n // `parent_run_id` is the match predicate, so every row this returns\n // has one.\n sql<{ readonly run_id: string; readonly parent_run_id: string }>`\n SELECT run_id, parent_run_id FROM flows_runs WHERE ${sql.in(\"parent_run_id\", chunk)}\n `.pipe(\n Effect.map((rows) => {\n for (const row of rows) {\n accumulated.push({ runId: row.run_id, parentRunId: row.parent_run_id })\n }\n return accumulated\n }),\n Effect.mapError(scanning(\"the run lineage\"))\n )\n )\n\n/**\n * Drops from `doomed` every candidate that must outlive this pass, and\n * every ancestor of one.\n *\n * A candidate whose child is not being deleted has to stay: `flows_runs`\n * carries a self-referential foreign key on `parent_run_id`, so deleting\n * it would orphan a row that still exists. Retention is upward-closed for\n * the same reason — once a candidate is retained, the candidate it points\n * at is still referenced and is retained too.\n */\nconst pinAncestors = (\n doomed: Set<string>,\n retained: Set<string>,\n parentOf: ReadonlyMap<string, string | null>,\n from: string\n): void => {\n let current: string | undefined = from\n while (current !== undefined && doomed.has(current)) {\n doomed.delete(current)\n retained.add(current)\n current = parentOf.get(current) ?? undefined\n }\n}\n\n/**\n * Groups the doomed runs so that no group holds a run and one of its\n * doomed descendants. Deleting a parent while its child row still exists\n * violates the foreign key, and SQLite evaluates it per row rather than at\n * commit, so the delete runs deepest generation first.\n */\nconst generations = (\n doomed: ReadonlySet<string>,\n parentOf: ReadonlyMap<string, string | null>\n): ReadonlyArray<ReadonlyArray<string>> => {\n const depths = new Map<string, number>()\n const depthOf = (runId: string): number => {\n const known = depths.get(runId)\n if (known !== undefined) return known\n const parent = parentOf.get(runId) ?? undefined\n const depth = parent !== undefined && doomed.has(parent) ? depthOf(parent) + 1 : 0\n depths.set(runId, depth)\n return depth\n }\n const byDepth = new Map<number, Array<string>>()\n for (const runId of doomed) {\n const depth = depthOf(runId)\n const bucket = byDepth.get(depth)\n if (bucket === undefined) byDepth.set(depth, [runId])\n else bucket.push(runId)\n }\n return Array.from(byDepth.keys())\n .sort((left, right) => right - left)\n .map((depth) => byDepth.get(depth)!)\n}\n\n/**\n * Deletes `candidates` and every row the inventory says names them.\n *\n * The one deletion in this package. Both passes call it, so neither can be\n * holding a shorter table list than the other, and neither can be deleting\n * run rows in an order the self-referential foreign key refuses: a handoff\n * parent always sorts before its successor, so a pass that deleted in age\n * order broke as soon as one lineage straddled a chunk boundary.\n *\n * The caller owns the transaction. Nothing here is atomic on its own, and a\n * pass that removed the dependents of every candidate and then refused on the\n * run rows would have destroyed history it could not put back.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const deleteRuns = (\n sql: SqlClient.SqlClient,\n candidates: ReadonlyArray<Candidate>,\n options: { readonly dryRun: boolean; readonly assumeLadder: boolean }\n): Effect.Effect<DeletionReport, RetentionError> =>\n Effect.gen(function*() {\n const installed = yield* installedTableNames(sql)\n const tables = runScopedTables.filter((entry) =>\n (options.assumeLadder && entry.ladder) || installed.has(entry.table)\n )\n const hasTimeTravelReceipts = installed.has(\"flows_time_travel_receipts\") &&\n installed.has(\"flows_time_travel_audits\")\n const candidateIds = candidates.map((candidate) => candidate.runId)\n const parentOf = new Map(candidates.map((candidate) => [candidate.runId, candidate.parentRunId]))\n const doomed = new Set(candidateIds)\n const pinned = new Set<string>()\n const candidateSet = new Set(candidateIds)\n // The foreign key, which no lineage filter covers: a child row that is\n // terminal and simply outside this pass — younger than the cutoff, or past\n // the bound — still points at its parent.\n for (const child of yield* childrenOf(sql, candidateIds)) {\n if (candidateSet.has(child.runId)) continue\n pinAncestors(doomed, pinned, parentOf, child.parentRunId)\n }\n // `candidates` arrives oldest first, so this reads in the order the pass\n // collected.\n const runIds = candidateIds.filter((runId) => doomed.has(runId))\n\n const companionIds = runIds.flatMap((runId) =>\n companionStreams.map((stream) => JournalEvent.companionRunId(stream, runId))\n )\n const idsFor = (entry: RunScopedTable): ReadonlyArray<string> =>\n entry.companions === true ? [...runIds, ...companionIds] : runIds\n\n const deleted: Record<string, number> = {}\n if (hasTimeTravelReceipts) {\n const total = yield* countTimeTravelReceipts(sql, runIds)\n if (total > 0) deleted[\"flows_time_travel_receipts\"] = total\n }\n for (const entry of tables) {\n const total = yield* countIn(sql, entry.table, entry.column, idsFor(entry))\n if (total > 0) deleted[entry.table] = total\n }\n if (runIds.length > 0) deleted[\"flows_runs\"] = runIds.length\n\n if (!options.dryRun) {\n // Receipts have no run column, so remove them through their audits\n // before the ordinary inventory reaches and deletes those audit rows.\n if (hasTimeTravelReceipts) yield* deleteTimeTravelReceipts(sql, runIds)\n for (const entry of tables) yield* deleteIn(sql, entry.table, entry.column, idsFor(entry))\n // Last, and deepest generation first. The `flows_run_parents_gc`\n // trigger drops each run's DAG edges as its row goes.\n for (const generation of generations(doomed, parentOf)) {\n yield* deleteIn(sql, \"flows_runs\", \"run_id\", generation)\n }\n }\n\n return { runIds, pinned: Array.from(pinned), deleted }\n })\n\n/**\n * Builds the retention operation over the composition's own durable tables.\n *\n * The scan reads `flows_runs` directly, the way `DurableEngineState` and\n * `ArtifactGc` do: this package composes the run-store, journal, and engine\n * migrations, so the schema is its own.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const make = (): Effect.Effect<Service, never, SqlClient.SqlClient | Journal.Journal> =>\n Effect.gen(function*() {\n const sql = yield* Effect.service(SqlClient.SqlClient)\n const journal = yield* Journal.Journal\n\n /**\n * Aged terminal runs held by live lineage or an excluded continuation\n * descendant. An upward exclusion takes precedence over a live ancestor.\n *\n * These runs are never candidates — `candidatesOf` excludes them — so this\n * read exists to say WHY a workspace with aged runs collected fewer than\n * it holds. It carries the pass's own bound so the report costs no more\n * than the pass does.\n */\n const retainedByLineage = (cutoffMs: number, limit: number) =>\n sql<{ readonly run_id: string; readonly live_descendant: number }>`\n ${scanPrelude(sql, { cutoffMs, inclusive: true, parentEdges: true })}\n SELECT\n run_id,\n (run_id IN (SELECT run_id FROM over_live) OR EXISTS (\n SELECT 1 FROM flows_runs AS child\n WHERE child.parent_run_id = flows_runs.run_id\n AND child.run_id IN (SELECT run_id FROM blocked)\n )) AS live_descendant\n FROM flows_runs\n WHERE ${sql.in(\"status\", terminalStatuses)}\n AND COALESCE(finished_at_ms, created_at_ms) <= ${cutoffMs}\n AND run_id IN (SELECT run_id FROM blocked)\n ORDER BY COALESCE(finished_at_ms, created_at_ms), run_id\n LIMIT ${limit}\n `.pipe(Effect.mapError(scanning(\"the run lineage\")))\n\n const pass = (options: RetainOptions, cutoffMs: number) =>\n Effect.gen(function*() {\n const limit = normalizeLimit(options.limit)\n const candidates = yield* candidatesOf(sql, { cutoffMs, inclusive: true, parentEdges: true, limit }).pipe(\n Effect.mapError(scanning(\"the run table\"))\n )\n const retained = new Set<string>()\n const retainedAbove = new Set<string>()\n // Why the workspace kept aged runs this pass. These never entered the\n // candidate set, so this only classifies them. It runs before the\n // deletes so the report describes the file the pass was handed.\n for (const held of yield* retainedByLineage(cutoffMs, limit)) {\n if (Number(held.live_descendant) > 0) retained.add(held.run_id)\n else retainedAbove.add(held.run_id)\n }\n // The whole deletion, shared with `Retention.collect` so the two\n // passes cannot hold different table lists or different orders. This\n // database is the engine's own ladder, so a table of it that the\n // catalog does not list is a broken schema and the delete says so.\n const removed = yield* deleteRuns(sql, candidates, {\n dryRun: options.dryRun === true,\n assumeLadder: true\n })\n\n return {\n cutoffMs,\n runIds: removed.runIds,\n retainedForLiveDescendants: Array.from(retained).sort(),\n retainedForLiveAncestors: Array.from(retainedAbove).sort(),\n runs: removed.runIds.length,\n attempts: removed.deleted[\"flows_attempts\"] ?? 0,\n clockDeadlines: removed.deleted[\"flows_clock_deadlines\"] ?? 0,\n deferredCompletions: removed.deleted[\"flows_deferred_completions\"] ?? 0,\n journalEntries: removed.deleted[\"flows_journal_events\"] ?? 0,\n journalCheckpoints: removed.deleted[\"flows_journal_checkpoints\"] ?? 0,\n journalIdentities: removed.deleted[\"flows_journal_dedup\"] ?? 0,\n archiveEntries: removed.deleted[\"flows_time_travel_archive\"] ?? 0,\n timeTravelReceipts: removed.deleted[\"flows_time_travel_receipts\"] ?? 0,\n dryRun: options.dryRun === true\n } satisfies RetainReport\n })\n\n const retain: Service[\"retain\"] = Effect.fn(\"Retention.retain\")((options: RetainOptions) =>\n Effect.gen(function*() {\n const nowMs = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor))\n const cutoffMs = nowMs - Math.max(0, options.olderThanMs)\n // One commit: `transact` joins the run-row deletes, the dependent\n // deletes, and the journal truncation into a single write transaction,\n // so a crash can never leave a run without its history or history\n // without its run. A transaction that cannot commit fails as the\n // `JournalError` it is rather than being laundered into a retention\n // code that would claim to know why.\n return yield* journal.transact(pass(options, cutoffMs))\n })\n )\n\n return { retain }\n })\n\n/**\n * Provides run retention. Nothing schedules `retain()`; invoking it stays an\n * explicit caller decision.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layer: Layer.Layer<Retention, never, SqlClient.SqlClient | Journal.Journal> = Layer.effect(Retention)(\n make()\n)\n"]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace run catalog read.
|
|
3
|
+
*
|
|
4
|
+
* `@smthrs/sync` serves a workspace subscription over a `RunCatalog`, and
|
|
5
|
+
* every implementation of that service was static (`layerStatic`,
|
|
6
|
+
* `layerNoop`) or in-process (`makeMemory`, which hears only about runs the
|
|
7
|
+
* same process registered). A follower composed against any of them saw the
|
|
8
|
+
* runs that existed when it started and never learned of another run, so a
|
|
9
|
+
* second engine writing to the same workspace was invisible to it. This
|
|
10
|
+
* module is the durable half of the fix: the read that says which runs the
|
|
11
|
+
* workspace has right now, taken from `flows_runs` itself.
|
|
12
|
+
*
|
|
13
|
+
* The read is a full set rather than a cursor tail, for one reason: retention
|
|
14
|
+
* deletes runs. A follower that only ever appended what appeared after a
|
|
15
|
+
* cursor would keep every collected run in its view forever and hold a
|
|
16
|
+
* journal stream open for each one. Reading the set makes both directions
|
|
17
|
+
* work, and the workspace's own bound keeps the cost of it flat.
|
|
18
|
+
*
|
|
19
|
+
* Nothing here polls. The interval belongs to the catalog that consumes this
|
|
20
|
+
* read (`RunCatalog.makePolling` in `@smthrs/sync`), so the durable side has
|
|
21
|
+
* no policy and no fiber of its own.
|
|
22
|
+
*
|
|
23
|
+
* @since 0.1.0
|
|
24
|
+
*/
|
|
25
|
+
import * as Context from "effect/Context";
|
|
26
|
+
import * as Effect from "effect/Effect";
|
|
27
|
+
import * as Layer from "effect/Layer";
|
|
28
|
+
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
|
29
|
+
import * as RunListing from "./RunListing.ts";
|
|
30
|
+
import { RunCatalogError } from "./RunListingError.ts";
|
|
31
|
+
/**
|
|
32
|
+
* Stable error codes returned by the catalog read.
|
|
33
|
+
*
|
|
34
|
+
* @category models
|
|
35
|
+
* @since 0.1.0
|
|
36
|
+
*/
|
|
37
|
+
export { RunCatalogErrorCode } from "./RunListingError.ts";
|
|
38
|
+
/**
|
|
39
|
+
* A catalog read that could not complete.
|
|
40
|
+
*
|
|
41
|
+
* `list_failed` means the workspace's run set could not be read. The caller
|
|
42
|
+
* keeps whatever view it already had; the read is idempotent, so the next one
|
|
43
|
+
* converges once the cause is fixed.
|
|
44
|
+
*
|
|
45
|
+
* @category errors
|
|
46
|
+
* @since 0.1.0
|
|
47
|
+
*/
|
|
48
|
+
export { RunCatalogError } from "./RunListingError.ts";
|
|
49
|
+
/**
|
|
50
|
+
* Options for one catalog read.
|
|
51
|
+
*
|
|
52
|
+
* @category models
|
|
53
|
+
* @since 0.1.0
|
|
54
|
+
*/
|
|
55
|
+
export interface ListOptions {
|
|
56
|
+
/**
|
|
57
|
+
* Largest number of runs the read returns. Defaults to
|
|
58
|
+
* {@link defaultLimit}. A workspace with more runs than the bound is
|
|
59
|
+
* followed by its most recent ones; an older run stays readable through a
|
|
60
|
+
* run-scoped subscription, which names it directly.
|
|
61
|
+
*/
|
|
62
|
+
readonly limit?: number | undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The workspace's run set.
|
|
66
|
+
*
|
|
67
|
+
* @category models
|
|
68
|
+
* @since 0.1.0
|
|
69
|
+
*/
|
|
70
|
+
export interface Service {
|
|
71
|
+
/** Revision-consistent, filtered keyset page of execution rows. */
|
|
72
|
+
readonly listRuns: RunListing.Service["listRuns"];
|
|
73
|
+
/**
|
|
74
|
+
* Every run the workspace has, oldest first, bounded by the read. "Oldest"
|
|
75
|
+
* is the run table's own row order, which is the order `RunStore.create`
|
|
76
|
+
* inserted them: SQLite hands a new row an identifier above every one in
|
|
77
|
+
* the table, and reuses one only after the highest is deleted, so deletion
|
|
78
|
+
* by retention does not reorder what is left.
|
|
79
|
+
*/
|
|
80
|
+
readonly listRunIds: (options?: ListOptions) => Effect.Effect<ReadonlyArray<string>, RunCatalogError>;
|
|
81
|
+
}
|
|
82
|
+
declare const RunCatalogRead_base: Context.ServiceClass<RunCatalogRead, "@smthrs/engine-store/RunCatalogRead", Service>;
|
|
83
|
+
/**
|
|
84
|
+
* Service tag for the workspace run catalog read.
|
|
85
|
+
*
|
|
86
|
+
* @category services
|
|
87
|
+
* @since 0.1.0
|
|
88
|
+
*/
|
|
89
|
+
export declare class RunCatalogRead extends RunCatalogRead_base {
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Runs one read returns when the caller names no bound. Large enough that an
|
|
93
|
+
* ordinary workspace is returned whole, small enough that a workspace which
|
|
94
|
+
* has never been collected does not hand a follower an unbounded list.
|
|
95
|
+
*
|
|
96
|
+
* @category constants
|
|
97
|
+
* @since 0.1.0
|
|
98
|
+
*/
|
|
99
|
+
export declare const defaultLimit = 10000;
|
|
100
|
+
/**
|
|
101
|
+
* Builds the catalog read over the composition's own run table.
|
|
102
|
+
*
|
|
103
|
+
* The read goes to `flows_runs` directly, the way `DurableEngineState`,
|
|
104
|
+
* `ArtifactGc`, and `RetentionOps` do: this package composes the run-store
|
|
105
|
+
* migrations, so the schema is its own.
|
|
106
|
+
*
|
|
107
|
+
* @category constructors
|
|
108
|
+
* @since 0.1.0
|
|
109
|
+
*/
|
|
110
|
+
export declare const make: () => Effect.Effect<Service, never, SqlClient.SqlClient>;
|
|
111
|
+
/**
|
|
112
|
+
* Provides the workspace run catalog read.
|
|
113
|
+
*
|
|
114
|
+
* @category layers
|
|
115
|
+
* @since 0.1.0
|
|
116
|
+
*/
|
|
117
|
+
export declare const layer: Layer.Layer<RunCatalogRead, never, SqlClient.SqlClient>;
|
|
118
|
+
//# sourceMappingURL=RunCatalogOps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunCatalogOps.d.ts","sourceRoot":"","sources":["../../../src/internal/RunCatalogOps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAC1D,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD;;;;;GAKG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;;;;;;;GASG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACpC;AAED;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACjD;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,WAAW,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,CAAA;CACtG;;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,mBAEnC;CAAG;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,QAAS,CAAA;AAElC;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI,QAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,SAAS,CAgDrE,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,EAAE,SAAS,CAAC,SAAS,CAAwC,CAAA"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workspace run catalog read.
|
|
3
|
+
*
|
|
4
|
+
* `@smthrs/sync` serves a workspace subscription over a `RunCatalog`, and
|
|
5
|
+
* every implementation of that service was static (`layerStatic`,
|
|
6
|
+
* `layerNoop`) or in-process (`makeMemory`, which hears only about runs the
|
|
7
|
+
* same process registered). A follower composed against any of them saw the
|
|
8
|
+
* runs that existed when it started and never learned of another run, so a
|
|
9
|
+
* second engine writing to the same workspace was invisible to it. This
|
|
10
|
+
* module is the durable half of the fix: the read that says which runs the
|
|
11
|
+
* workspace has right now, taken from `flows_runs` itself.
|
|
12
|
+
*
|
|
13
|
+
* The read is a full set rather than a cursor tail, for one reason: retention
|
|
14
|
+
* deletes runs. A follower that only ever appended what appeared after a
|
|
15
|
+
* cursor would keep every collected run in its view forever and hold a
|
|
16
|
+
* journal stream open for each one. Reading the set makes both directions
|
|
17
|
+
* work, and the workspace's own bound keeps the cost of it flat.
|
|
18
|
+
*
|
|
19
|
+
* Nothing here polls. The interval belongs to the catalog that consumes this
|
|
20
|
+
* read (`RunCatalog.makePolling` in `@smthrs/sync`), so the durable side has
|
|
21
|
+
* no policy and no fiber of its own.
|
|
22
|
+
*
|
|
23
|
+
* @since 0.1.0
|
|
24
|
+
*/
|
|
25
|
+
import * as Context from "effect/Context";
|
|
26
|
+
import * as Effect from "effect/Effect";
|
|
27
|
+
import * as Layer from "effect/Layer";
|
|
28
|
+
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
|
29
|
+
import * as RunListing from "./RunListing.js";
|
|
30
|
+
import { RunCatalogError } from "./RunListingError.js";
|
|
31
|
+
/**
|
|
32
|
+
* Stable error codes returned by the catalog read.
|
|
33
|
+
*
|
|
34
|
+
* @category models
|
|
35
|
+
* @since 0.1.0
|
|
36
|
+
*/
|
|
37
|
+
export { RunCatalogErrorCode } from "./RunListingError.js";
|
|
38
|
+
/**
|
|
39
|
+
* A catalog read that could not complete.
|
|
40
|
+
*
|
|
41
|
+
* `list_failed` means the workspace's run set could not be read. The caller
|
|
42
|
+
* keeps whatever view it already had; the read is idempotent, so the next one
|
|
43
|
+
* converges once the cause is fixed.
|
|
44
|
+
*
|
|
45
|
+
* @category errors
|
|
46
|
+
* @since 0.1.0
|
|
47
|
+
*/
|
|
48
|
+
export { RunCatalogError } from "./RunListingError.js";
|
|
49
|
+
/**
|
|
50
|
+
* Service tag for the workspace run catalog read.
|
|
51
|
+
*
|
|
52
|
+
* @category services
|
|
53
|
+
* @since 0.1.0
|
|
54
|
+
*/
|
|
55
|
+
export class RunCatalogRead extends Context.Service()("@smthrs/engine-store/RunCatalogRead") {
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Runs one read returns when the caller names no bound. Large enough that an
|
|
59
|
+
* ordinary workspace is returned whole, small enough that a workspace which
|
|
60
|
+
* has never been collected does not hand a follower an unbounded list.
|
|
61
|
+
*
|
|
62
|
+
* @category constants
|
|
63
|
+
* @since 0.1.0
|
|
64
|
+
*/
|
|
65
|
+
export const defaultLimit = 10_000;
|
|
66
|
+
/**
|
|
67
|
+
* Builds the catalog read over the composition's own run table.
|
|
68
|
+
*
|
|
69
|
+
* The read goes to `flows_runs` directly, the way `DurableEngineState`,
|
|
70
|
+
* `ArtifactGc`, and `RetentionOps` do: this package composes the run-store
|
|
71
|
+
* migrations, so the schema is its own.
|
|
72
|
+
*
|
|
73
|
+
* @category constructors
|
|
74
|
+
* @since 0.1.0
|
|
75
|
+
*/
|
|
76
|
+
export const make = () => Effect.gen(function* () {
|
|
77
|
+
const sql = yield* Effect.service(SqlClient.SqlClient);
|
|
78
|
+
const listing = yield* RunListing.make();
|
|
79
|
+
// Newest first by `rowid`, then reversed. `rowid` is the order the
|
|
80
|
+
// workspace gained its runs, and reading it backwards walks the table's
|
|
81
|
+
// own b-tree, so the bound costs one seek rather than a sort of every
|
|
82
|
+
// run: `flows_runs` carries no index on `created_at_ms`, and two runs
|
|
83
|
+
// created in the same millisecond do not order by it at all.
|
|
84
|
+
//
|
|
85
|
+
// `flows_runs` has a TEXT primary key, so its `rowid` is not an alias of
|
|
86
|
+
// a declared column and SQLite documents that a rebuild may reassign it.
|
|
87
|
+
// The order the rebuild leaves is what this read depends on, not the
|
|
88
|
+
// numbers, and `VACUUM INTO` — the hot backup this release ships, and the
|
|
89
|
+
// only rebuild in the supported path (the release policy) — preserves
|
|
90
|
+
// it. `RunCatalogCatchUp.test.ts` pins that across a real backup and
|
|
91
|
+
// reopen, including after retention has deleted rows out of the middle
|
|
92
|
+
// and the end.
|
|
93
|
+
const listRunIds = Effect.fn("RunCatalog.listRunIds")((options) => Effect.gen(function* () {
|
|
94
|
+
const limit = options?.limit ?? defaultLimit;
|
|
95
|
+
if (!Number.isSafeInteger(limit) || limit < 0) {
|
|
96
|
+
return yield* Effect.fail(new RunCatalogError({
|
|
97
|
+
code: "invalid_options",
|
|
98
|
+
message: "the run catalog limit must be a non-negative safe integer"
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
return yield* sql `
|
|
102
|
+
SELECT run_id FROM flows_runs
|
|
103
|
+
ORDER BY rowid DESC
|
|
104
|
+
LIMIT ${limit}
|
|
105
|
+
`.pipe(Effect.map((rows) => rows.map((row) => row.run_id).reverse()), Effect.mapError((cause) => new RunCatalogError({
|
|
106
|
+
code: "list_failed",
|
|
107
|
+
message: "the workspace run set could not be read",
|
|
108
|
+
cause
|
|
109
|
+
})));
|
|
110
|
+
}));
|
|
111
|
+
return { listRunIds, ...listing };
|
|
112
|
+
});
|
|
113
|
+
/**
|
|
114
|
+
* Provides the workspace run catalog read.
|
|
115
|
+
*
|
|
116
|
+
* @category layers
|
|
117
|
+
* @since 0.1.0
|
|
118
|
+
*/
|
|
119
|
+
export const layer = Layer.effect(RunCatalogRead)(make());
|
|
120
|
+
//# sourceMappingURL=RunCatalogOps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunCatalogOps.js","sourceRoot":"","sources":["../../../src/internal/RunCatalogOps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAA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AG,CAAC,EAAE,CAAC;YAC9C,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CACvB,IAAI,eAAe,CAAC;gBAClB,IAAI,EAAE,iBAAiB;gBACvB,OAAO,EAAE,2DAA2D;aACrE,CAAC,CACH,CAAA;QACH,CAAC;QACD,OAAO,KAAK,CAAC,CAAC,GAAG,CAA6B;;;kBAGpC,KAAK;SACd,CAAC,IAAI,CACJ,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,EAC7D,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CACxB,IAAI,eAAe,CAAC;YAClB,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,yCAAyC;YAClD,KAAK;SACN,CAAC,CACH,CACF,CAAA;IACH,CAAC,CAAC,CACH,CAAA;IAED,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,CAAA;AACnC,CAAC,CAAC,CAAA;AAEJ;;;;;GAKG;AACH,MAAM,CAAC,MAAM,KAAK,GAA4D,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA","sourcesContent":["/**\n * The workspace run catalog read.\n *\n * `@smthrs/sync` serves a workspace subscription over a `RunCatalog`, and\n * every implementation of that service was static (`layerStatic`,\n * `layerNoop`) or in-process (`makeMemory`, which hears only about runs the\n * same process registered). A follower composed against any of them saw the\n * runs that existed when it started and never learned of another run, so a\n * second engine writing to the same workspace was invisible to it. This\n * module is the durable half of the fix: the read that says which runs the\n * workspace has right now, taken from `flows_runs` itself.\n *\n * The read is a full set rather than a cursor tail, for one reason: retention\n * deletes runs. A follower that only ever appended what appeared after a\n * cursor would keep every collected run in its view forever and hold a\n * journal stream open for each one. Reading the set makes both directions\n * work, and the workspace's own bound keeps the cost of it flat.\n *\n * Nothing here polls. The interval belongs to the catalog that consumes this\n * read (`RunCatalog.makePolling` in `@smthrs/sync`), so the durable side has\n * no policy and no fiber of its own.\n *\n * @since 0.1.0\n */\n\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\nimport * as RunListing from \"./RunListing.ts\"\nimport { RunCatalogError } from \"./RunListingError.ts\"\n\n/**\n * Stable error codes returned by the catalog read.\n *\n * @category models\n * @since 0.1.0\n */\nexport { RunCatalogErrorCode } from \"./RunListingError.ts\"\n\n/**\n * A catalog read that could not complete.\n *\n * `list_failed` means the workspace's run set could not be read. The caller\n * keeps whatever view it already had; the read is idempotent, so the next one\n * converges once the cause is fixed.\n *\n * @category errors\n * @since 0.1.0\n */\nexport { RunCatalogError } from \"./RunListingError.ts\"\n\n/**\n * Options for one catalog read.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface ListOptions {\n /**\n * Largest number of runs the read returns. Defaults to\n * {@link defaultLimit}. A workspace with more runs than the bound is\n * followed by its most recent ones; an older run stays readable through a\n * run-scoped subscription, which names it directly.\n */\n readonly limit?: number | undefined\n}\n\n/**\n * The workspace's run set.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Service {\n /** Revision-consistent, filtered keyset page of execution rows. */\n readonly listRuns: RunListing.Service[\"listRuns\"]\n /**\n * Every run the workspace has, oldest first, bounded by the read. \"Oldest\"\n * is the run table's own row order, which is the order `RunStore.create`\n * inserted them: SQLite hands a new row an identifier above every one in\n * the table, and reuses one only after the highest is deleted, so deletion\n * by retention does not reorder what is left.\n */\n readonly listRunIds: (options?: ListOptions) => Effect.Effect<ReadonlyArray<string>, RunCatalogError>\n}\n\n/**\n * Service tag for the workspace run catalog read.\n *\n * @category services\n * @since 0.1.0\n */\nexport class RunCatalogRead extends Context.Service<RunCatalogRead, Service>()(\n \"@smthrs/engine-store/RunCatalogRead\"\n) {}\n\n/**\n * Runs one read returns when the caller names no bound. Large enough that an\n * ordinary workspace is returned whole, small enough that a workspace which\n * has never been collected does not hand a follower an unbounded list.\n *\n * @category constants\n * @since 0.1.0\n */\nexport const defaultLimit = 10_000\n\n/**\n * Builds the catalog read over the composition's own run table.\n *\n * The read goes to `flows_runs` directly, the way `DurableEngineState`,\n * `ArtifactGc`, and `RetentionOps` do: this package composes the run-store\n * migrations, so the schema is its own.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const make = (): Effect.Effect<Service, never, SqlClient.SqlClient> =>\n Effect.gen(function*() {\n const sql = yield* Effect.service(SqlClient.SqlClient)\n const listing = yield* RunListing.make()\n\n // Newest first by `rowid`, then reversed. `rowid` is the order the\n // workspace gained its runs, and reading it backwards walks the table's\n // own b-tree, so the bound costs one seek rather than a sort of every\n // run: `flows_runs` carries no index on `created_at_ms`, and two runs\n // created in the same millisecond do not order by it at all.\n //\n // `flows_runs` has a TEXT primary key, so its `rowid` is not an alias of\n // a declared column and SQLite documents that a rebuild may reassign it.\n // The order the rebuild leaves is what this read depends on, not the\n // numbers, and `VACUUM INTO` — the hot backup this release ships, and the\n // only rebuild in the supported path (the release policy) — preserves\n // it. `RunCatalogCatchUp.test.ts` pins that across a real backup and\n // reopen, including after retention has deleted rows out of the middle\n // and the end.\n const listRunIds: Service[\"listRunIds\"] = Effect.fn(\"RunCatalog.listRunIds\")((options?: ListOptions) =>\n Effect.gen(function*() {\n const limit = options?.limit ?? defaultLimit\n if (!Number.isSafeInteger(limit) || limit < 0) {\n return yield* Effect.fail(\n new RunCatalogError({\n code: \"invalid_options\",\n message: \"the run catalog limit must be a non-negative safe integer\"\n })\n )\n }\n return yield* sql<{ readonly run_id: string }>`\n SELECT run_id FROM flows_runs\n ORDER BY rowid DESC\n LIMIT ${limit}\n `.pipe(\n Effect.map((rows) => rows.map((row) => row.run_id).reverse()),\n Effect.mapError((cause) =>\n new RunCatalogError({\n code: \"list_failed\",\n message: \"the workspace run set could not be read\",\n cause\n })\n )\n )\n })\n )\n\n return { listRunIds, ...listing }\n })\n\n/**\n * Provides the workspace run catalog read.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layer: Layer.Layer<RunCatalogRead, never, SqlClient.SqlClient> = Layer.effect(RunCatalogRead)(make())\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coordinates keyed drain executions.
|
|
3
|
+
*
|
|
4
|
+
* Adapted nearly verbatim from
|
|
5
|
+
* `reference/opencode/packages/smithers/flows/core/src/session/run-coordinator.ts`:
|
|
6
|
+
* `Deferred` joins, `FiberSet` ownership, coalesced wakes, and
|
|
7
|
+
* `uninterruptibleMask` preserve its start-or-join semantics. This adaptation
|
|
8
|
+
* drops the source's `force` drain argument because no engine-store drain has
|
|
9
|
+
* a second execution mode; the successor flag carries coordinator scheduling.
|
|
10
|
+
*
|
|
11
|
+
* @since 0.1.0
|
|
12
|
+
*/
|
|
13
|
+
import { Effect, type Scope } from "effect";
|
|
14
|
+
/**
|
|
15
|
+
* Serializes drain execution for each key while allowing distinct keys to run
|
|
16
|
+
* concurrently.
|
|
17
|
+
*
|
|
18
|
+
* @since 0.1.0
|
|
19
|
+
* @category models
|
|
20
|
+
*/
|
|
21
|
+
export interface RunCoordinator<Key, E> {
|
|
22
|
+
/**
|
|
23
|
+
* Snapshots keys with an execution owned by this coordinator.
|
|
24
|
+
*
|
|
25
|
+
* @since 0.1.0
|
|
26
|
+
* @category operations
|
|
27
|
+
*/
|
|
28
|
+
readonly active: Effect.Effect<ReadonlySet<Key>>;
|
|
29
|
+
/**
|
|
30
|
+
* Starts a drain while idle or joins the active drain for the key.
|
|
31
|
+
*
|
|
32
|
+
* @since 0.1.0
|
|
33
|
+
* @category operations
|
|
34
|
+
*/
|
|
35
|
+
readonly run: (key: Key) => Effect.Effect<void, E>;
|
|
36
|
+
/**
|
|
37
|
+
* Joins the active drain for the key, and starts none while idle.
|
|
38
|
+
*
|
|
39
|
+
* @since 1.0.0
|
|
40
|
+
* @category operations
|
|
41
|
+
*/
|
|
42
|
+
readonly join: (key: Key) => Effect.Effect<void, E>;
|
|
43
|
+
/**
|
|
44
|
+
* Starts an idle key without joining or requesting another active drain.
|
|
45
|
+
*
|
|
46
|
+
* @since 1.0.0
|
|
47
|
+
* @category operations
|
|
48
|
+
*/
|
|
49
|
+
readonly schedule: (key: Key) => Effect.Effect<void>;
|
|
50
|
+
/** Reserves an idle key, then starts its drain only while the supplied durable readiness holds. */
|
|
51
|
+
readonly scheduleIf: (key: Key, ready: Effect.Effect<boolean>) => Effect.Effect<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Ensures one coalesced drain follows the active drain for the key.
|
|
54
|
+
*
|
|
55
|
+
* @since 0.1.0
|
|
56
|
+
* @category operations
|
|
57
|
+
*/
|
|
58
|
+
readonly wake: (key: Key) => Effect.Effect<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Interrupts the active drain for the key and waits for its cleanup.
|
|
61
|
+
*
|
|
62
|
+
* @since 0.1.0
|
|
63
|
+
* @category operations
|
|
64
|
+
*/
|
|
65
|
+
readonly interrupt: (key: Key) => Effect.Effect<void>;
|
|
66
|
+
/** Sends interruption without awaiting cleanup; safe for a short commit publication. */
|
|
67
|
+
readonly requestInterrupt: (key: Key) => Effect.Effect<void>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Creates a scoped coordinator for keyed drain effects.
|
|
71
|
+
*
|
|
72
|
+
* @since 0.1.0
|
|
73
|
+
* @category constructors
|
|
74
|
+
*/
|
|
75
|
+
export declare const make: <Key, E, R>(options: {
|
|
76
|
+
readonly drain: (key: Key) => Effect.Effect<void, E, R>;
|
|
77
|
+
}) => Effect.Effect<RunCoordinator<Key, E>, never, Scope.Scope | R>;
|
|
78
|
+
//# sourceMappingURL=RunCoordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunCoordinator.d.ts","sourceRoot":"","sources":["../../../src/internal/RunCoordinator.ts"],"names":[],"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GAAI,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS;IACvC,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;CACxD,KAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,CAgI5D,CAAA"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coordinates keyed drain executions.
|
|
3
|
+
*
|
|
4
|
+
* Adapted nearly verbatim from
|
|
5
|
+
* `reference/opencode/packages/smithers/flows/core/src/session/run-coordinator.ts`:
|
|
6
|
+
* `Deferred` joins, `FiberSet` ownership, coalesced wakes, and
|
|
7
|
+
* `uninterruptibleMask` preserve its start-or-join semantics. This adaptation
|
|
8
|
+
* drops the source's `force` drain argument because no engine-store drain has
|
|
9
|
+
* a second execution mode; the successor flag carries coordinator scheduling.
|
|
10
|
+
*
|
|
11
|
+
* @since 0.1.0
|
|
12
|
+
*/
|
|
13
|
+
import { Cause, Deferred, Effect, Exit, Fiber, FiberSet } from "effect";
|
|
14
|
+
/**
|
|
15
|
+
* Creates a scoped coordinator for keyed drain effects.
|
|
16
|
+
*
|
|
17
|
+
* @since 0.1.0
|
|
18
|
+
* @category constructors
|
|
19
|
+
*/
|
|
20
|
+
export const make = (options) => Effect.gen(function* () {
|
|
21
|
+
const active = new Map();
|
|
22
|
+
const fork = yield* FiberSet.makeRuntime();
|
|
23
|
+
const makeEntry = () => ({
|
|
24
|
+
done: Deferred.makeUnsafe(),
|
|
25
|
+
pendingWake: false,
|
|
26
|
+
stopping: false
|
|
27
|
+
});
|
|
28
|
+
const start = (key, entry, successor = false, onlyIf = Effect.succeed(true)) => {
|
|
29
|
+
const ready = Deferred.makeUnsafe();
|
|
30
|
+
const owner = fork((successor ? Effect.yieldNow : Deferred.await(ready)).pipe(Effect.andThen(onlyIf), Effect.flatMap((ready) => ready ? Effect.suspend(() => options.drain(key)) : Effect.void), Effect.onError((cause) => Cause.hasInterruptsOnly(cause)
|
|
31
|
+
? Effect.void
|
|
32
|
+
: Effect.logWarning(`engine-store: coordinated drain failed for ${String(key)}`, cause)), Effect.onExit((exit) => Effect.sync(() => settle(key, entry, exit))), Effect.exit, Effect.asVoid));
|
|
33
|
+
entry.owner = owner;
|
|
34
|
+
if (!successor)
|
|
35
|
+
Deferred.doneUnsafe(ready, Effect.void);
|
|
36
|
+
};
|
|
37
|
+
const settle = (key, entry, exit) => {
|
|
38
|
+
if (Exit.isSuccess(exit) && !entry.stopping && entry.pendingWake) {
|
|
39
|
+
entry.pendingWake = false;
|
|
40
|
+
start(key, entry, true);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const successor = entry.pendingWake ? makeEntry() : undefined;
|
|
44
|
+
if (successor === undefined)
|
|
45
|
+
active.delete(key);
|
|
46
|
+
else {
|
|
47
|
+
active.set(key, successor);
|
|
48
|
+
start(key, successor, true);
|
|
49
|
+
}
|
|
50
|
+
Deferred.doneUnsafe(entry.done, exit);
|
|
51
|
+
};
|
|
52
|
+
const startIdle = (key, onlyIf) => {
|
|
53
|
+
const next = makeEntry();
|
|
54
|
+
active.set(key, next);
|
|
55
|
+
start(key, next, false, onlyIf);
|
|
56
|
+
return next;
|
|
57
|
+
};
|
|
58
|
+
const run = (key) => Effect.uninterruptibleMask((restore) => {
|
|
59
|
+
const entry = active.get(key);
|
|
60
|
+
if (entry !== undefined) {
|
|
61
|
+
/* v8 ignore next -- stopping is a cooperative-scheduler handoff covered by the cleanup race test */
|
|
62
|
+
if (entry.stopping)
|
|
63
|
+
return restore(Deferred.await(entry.done).pipe(Effect.andThen(run(key))));
|
|
64
|
+
return restore(Deferred.await(entry.done));
|
|
65
|
+
}
|
|
66
|
+
return restore(Deferred.await(startIdle(key).done));
|
|
67
|
+
});
|
|
68
|
+
const join = (key) => Effect.suspend(() => {
|
|
69
|
+
const entry = active.get(key);
|
|
70
|
+
return entry === undefined ? Effect.void : Deferred.await(entry.done);
|
|
71
|
+
});
|
|
72
|
+
const schedule = (key) => Effect.sync(() => {
|
|
73
|
+
if (!active.has(key))
|
|
74
|
+
startIdle(key);
|
|
75
|
+
});
|
|
76
|
+
const scheduleIf = (key, ready) => Effect.sync(() => {
|
|
77
|
+
if (!active.has(key))
|
|
78
|
+
startIdle(key, ready);
|
|
79
|
+
});
|
|
80
|
+
const wake = (key) => Effect.sync(() => {
|
|
81
|
+
const entry = active.get(key);
|
|
82
|
+
if (entry !== undefined) {
|
|
83
|
+
entry.pendingWake = true;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
startIdle(key);
|
|
87
|
+
});
|
|
88
|
+
const interrupt = (key) => Effect.suspend(() => {
|
|
89
|
+
const entry = active.get(key);
|
|
90
|
+
if (entry?.owner === undefined)
|
|
91
|
+
return Effect.void;
|
|
92
|
+
entry.stopping = true;
|
|
93
|
+
entry.pendingWake = false;
|
|
94
|
+
return Fiber.interrupt(entry.owner);
|
|
95
|
+
});
|
|
96
|
+
const requestInterrupt = (key) => Effect.withFiber((fiber) => Effect.sync(() => {
|
|
97
|
+
const entry = active.get(key);
|
|
98
|
+
if (entry?.owner === undefined)
|
|
99
|
+
return;
|
|
100
|
+
entry.stopping = true;
|
|
101
|
+
entry.pendingWake = false;
|
|
102
|
+
entry.owner.interruptUnsafe(fiber.id);
|
|
103
|
+
}));
|
|
104
|
+
return {
|
|
105
|
+
active: Effect.fn("RunCoordinator.active")(() => Effect.sync(() => new Set(active.keys())))(),
|
|
106
|
+
run: Effect.fn("RunCoordinator.run")(run),
|
|
107
|
+
join: Effect.fn("RunCoordinator.join")(join),
|
|
108
|
+
schedule: Effect.fn("RunCoordinator.schedule")(schedule),
|
|
109
|
+
scheduleIf: Effect.fn("RunCoordinator.scheduleIf")(scheduleIf),
|
|
110
|
+
wake: Effect.fn("RunCoordinator.wake")(wake),
|
|
111
|
+
interrupt: Effect.fn("RunCoordinator.interrupt")(interrupt),
|
|
112
|
+
requestInterrupt: Effect.fn("RunCoordinator.requestInterrupt")(requestInterrupt)
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
//# sourceMappingURL=RunCoordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunCoordinator.js","sourceRoot":"","sources":["../../../src/internal/RunCoordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAc,MAAM,QAAQ,CAAA;AAiEnF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAY,OAE/B,EAAiE,EAAE,CAClE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAA;IACvC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAkB,CAAA;IAE1D,MAAM,SAAS,GAAG,GAAa,EAAE,CAAC,CAAC;QACjC,IAAI,EAAE,QAAQ,CAAC,UAAU,EAAW;QACpC,WAAW,EAAE,KAAK;QAClB,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAA;IAEF,MAAM,KAAK,GAAG,CACZ,GAAQ,EACR,KAAe,EACf,SAAS,GAAG,KAAK,EACjB,SAAiC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAC/C,EAAE;QACR,MAAM,KAAK,GAAG,QAAQ,CAAC,UAAU,EAAQ,CAAA;QACzC,MAAM,KAAK,GAAG,IAAI,CAChB,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CACxD,MAAM,CAAC,OAAO,CAAC,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CAAC,EAAE,CAAC,2BAA2B,CAAC,CAAC,UAAU,CAAC;QAC9D,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC;QAC5C,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAC,SAAS,CAAC;QAC3D,gBAAgB,EAAE,MAAM,CAAC,EAAE,CAAC,iCAAiC,CAAC,CAAC,gBAAgB,CAAC;KACjF,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["/**\n * Coordinates keyed drain executions.\n *\n * Adapted nearly verbatim from\n * `reference/opencode/packages/smithers/flows/core/src/session/run-coordinator.ts`:\n * `Deferred` joins, `FiberSet` ownership, coalesced wakes, and\n * `uninterruptibleMask` preserve its start-or-join semantics. This adaptation\n * drops the source's `force` drain argument because no engine-store drain has\n * a second execution mode; the successor flag carries coordinator scheduling.\n *\n * @since 0.1.0\n */\n\nimport { Cause, Deferred, Effect, Exit, Fiber, FiberSet, type Scope } from \"effect\"\n\n/**\n * Serializes drain execution for each key while allowing distinct keys to run\n * concurrently.\n *\n * @since 0.1.0\n * @category models\n */\nexport interface RunCoordinator<Key, E> {\n /**\n * Snapshots keys with an execution owned by this coordinator.\n *\n * @since 0.1.0\n * @category operations\n */\n readonly active: Effect.Effect<ReadonlySet<Key>>\n /**\n * Starts a drain while idle or joins the active drain for the key.\n *\n * @since 0.1.0\n * @category operations\n */\n readonly run: (key: Key) => Effect.Effect<void, E>\n /**\n * Joins the active drain for the key, and starts none while idle.\n *\n * @since 1.0.0\n * @category operations\n */\n readonly join: (key: Key) => Effect.Effect<void, E>\n /**\n * Starts an idle key without joining or requesting another active drain.\n *\n * @since 1.0.0\n * @category operations\n */\n readonly schedule: (key: Key) => Effect.Effect<void>\n /** Reserves an idle key, then starts its drain only while the supplied durable readiness holds. */\n readonly scheduleIf: (key: Key, ready: Effect.Effect<boolean>) => Effect.Effect<void>\n /**\n * Ensures one coalesced drain follows the active drain for the key.\n *\n * @since 0.1.0\n * @category operations\n */\n readonly wake: (key: Key) => Effect.Effect<void>\n /**\n * Interrupts the active drain for the key and waits for its cleanup.\n *\n * @since 0.1.0\n * @category operations\n */\n readonly interrupt: (key: Key) => Effect.Effect<void>\n /** Sends interruption without awaiting cleanup; safe for a short commit publication. */\n readonly requestInterrupt: (key: Key) => Effect.Effect<void>\n}\n\ntype Entry<E> = {\n readonly done: Deferred.Deferred<void, E>\n owner?: Fiber.Fiber<void, never>\n pendingWake: boolean\n stopping: boolean\n}\n\n/**\n * Creates a scoped coordinator for keyed drain effects.\n *\n * @since 0.1.0\n * @category constructors\n */\nexport const make = <Key, E, R>(options: {\n readonly drain: (key: Key) => Effect.Effect<void, E, R>\n}): Effect.Effect<RunCoordinator<Key, E>, never, Scope.Scope | R> =>\n Effect.gen(function*() {\n const active = new Map<Key, Entry<E>>()\n const fork = yield* FiberSet.makeRuntime<R, void, never>()\n\n const makeEntry = (): Entry<E> => ({\n done: Deferred.makeUnsafe<void, E>(),\n pendingWake: false,\n stopping: false\n })\n\n const start = (\n key: Key,\n entry: Entry<E>,\n successor = false,\n onlyIf: Effect.Effect<boolean> = Effect.succeed(true)\n ): void => {\n const ready = Deferred.makeUnsafe<void>()\n const owner = fork(\n (successor ? Effect.yieldNow : Deferred.await(ready)).pipe(\n Effect.andThen(onlyIf),\n Effect.flatMap((ready) => ready ? Effect.suspend(() => options.drain(key)) : Effect.void),\n Effect.onError((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.void\n : Effect.logWarning(`engine-store: coordinated drain failed for ${String(key)}`, cause)\n ),\n Effect.onExit((exit) => Effect.sync(() => settle(key, entry, exit))),\n Effect.exit,\n Effect.asVoid\n )\n )\n entry.owner = owner\n if (!successor) Deferred.doneUnsafe(ready, Effect.void)\n }\n\n const settle = (key: Key, entry: Entry<E>, exit: Exit.Exit<void, E>): void => {\n if (Exit.isSuccess(exit) && !entry.stopping && entry.pendingWake) {\n entry.pendingWake = false\n start(key, entry, true)\n return\n }\n\n const successor = entry.pendingWake ? makeEntry() : undefined\n if (successor === undefined) active.delete(key)\n else {\n active.set(key, successor)\n start(key, successor, true)\n }\n Deferred.doneUnsafe(entry.done, exit)\n }\n\n const startIdle = (key: Key, onlyIf?: Effect.Effect<boolean>): Entry<E> => {\n const next = makeEntry()\n active.set(key, next)\n start(key, next, false, onlyIf)\n return next\n }\n\n const run = (key: Key): Effect.Effect<void, E> =>\n Effect.uninterruptibleMask((restore) => {\n const entry = active.get(key)\n if (entry !== undefined) {\n /* v8 ignore next -- stopping is a cooperative-scheduler handoff covered by the cleanup race test */\n if (entry.stopping) return restore(Deferred.await(entry.done).pipe(Effect.andThen(run(key))))\n return restore(Deferred.await(entry.done))\n }\n\n return restore(Deferred.await(startIdle(key).done))\n })\n\n const join = (key: Key): Effect.Effect<void, E> =>\n Effect.suspend(() => {\n const entry = active.get(key)\n return entry === undefined ? Effect.void : Deferred.await(entry.done)\n })\n\n const schedule = (key: Key): Effect.Effect<void> =>\n Effect.sync(() => {\n if (!active.has(key)) startIdle(key)\n })\n\n const scheduleIf = (key: Key, ready: Effect.Effect<boolean>): Effect.Effect<void> =>\n Effect.sync(() => {\n if (!active.has(key)) startIdle(key, ready)\n })\n\n const wake = (key: Key): Effect.Effect<void> =>\n Effect.sync(() => {\n const entry = active.get(key)\n if (entry !== undefined) {\n entry.pendingWake = true\n return\n }\n\n startIdle(key)\n })\n\n const interrupt = (key: Key): Effect.Effect<void> =>\n Effect.suspend(() => {\n const entry = active.get(key)\n if (entry?.owner === undefined) return Effect.void\n entry.stopping = true\n entry.pendingWake = false\n return Fiber.interrupt(entry.owner)\n })\n\n const requestInterrupt = (key: Key): Effect.Effect<void> =>\n Effect.withFiber((fiber) =>\n Effect.sync(() => {\n const entry = active.get(key)\n if (entry?.owner === undefined) return\n entry.stopping = true\n entry.pendingWake = false\n entry.owner.interruptUnsafe(fiber.id)\n })\n )\n\n return {\n active: Effect.fn(\"RunCoordinator.active\")(() => Effect.sync(() => new Set(active.keys())))(),\n run: Effect.fn(\"RunCoordinator.run\")(run),\n join: Effect.fn(\"RunCoordinator.join\")(join),\n schedule: Effect.fn(\"RunCoordinator.schedule\")(schedule),\n scheduleIf: Effect.fn(\"RunCoordinator.scheduleIf\")(scheduleIf),\n wake: Effect.fn(\"RunCoordinator.wake\")(wake),\n interrupt: Effect.fn(\"RunCoordinator.interrupt\")(interrupt),\n requestInterrupt: Effect.fn(\"RunCoordinator.requestInterrupt\")(requestInterrupt)\n }\n })\n"]}
|