@smthrs/journal 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 +149 -0
- package/LICENSE +21 -0
- package/README.md +206 -2
- package/dist/cjs/CallFact.d.ts +129 -0
- package/dist/cjs/CallFact.d.ts.map +1 -0
- package/dist/cjs/CallFact.js +106 -0
- package/dist/cjs/CallFact.js.map +7 -0
- package/dist/cjs/Consensus.d.ts +440 -0
- package/dist/cjs/Consensus.d.ts.map +1 -0
- package/dist/cjs/Consensus.js +251 -0
- package/dist/cjs/Consensus.js.map +7 -0
- package/dist/cjs/EngineEvent.d.ts +890 -0
- package/dist/cjs/EngineEvent.d.ts.map +1 -0
- package/dist/cjs/EngineEvent.js +383 -0
- package/dist/cjs/EngineEvent.js.map +7 -0
- package/dist/cjs/ExecutionFact.d.ts +216 -0
- package/dist/cjs/ExecutionFact.d.ts.map +1 -0
- package/dist/cjs/ExecutionFact.js +303 -0
- package/dist/cjs/ExecutionFact.js.map +7 -0
- package/dist/cjs/Journal.d.ts +617 -0
- package/dist/cjs/Journal.d.ts.map +1 -0
- package/dist/cjs/Journal.js +190 -0
- package/dist/cjs/Journal.js.map +7 -0
- package/dist/cjs/JournalEvent.d.ts +421 -0
- package/dist/cjs/JournalEvent.d.ts.map +1 -0
- package/dist/cjs/JournalEvent.js +281 -0
- package/dist/cjs/JournalEvent.js.map +7 -0
- package/dist/cjs/JournalGeneration.d.ts +34 -0
- package/dist/cjs/JournalGeneration.d.ts.map +1 -0
- package/dist/cjs/JournalGeneration.js +72 -0
- package/dist/cjs/JournalGeneration.js.map +7 -0
- package/dist/cjs/JournalMetrics.d.ts +72 -0
- package/dist/cjs/JournalMetrics.d.ts.map +1 -0
- package/dist/cjs/JournalMetrics.js +55 -0
- package/dist/cjs/JournalMetrics.js.map +7 -0
- package/dist/cjs/Migrations.d.ts +42 -0
- package/dist/cjs/Migrations.d.ts.map +1 -0
- package/dist/cjs/Migrations.js +58 -0
- package/dist/cjs/Migrations.js.map +7 -0
- package/dist/cjs/OwnerId.d.ts +40 -0
- package/dist/cjs/OwnerId.d.ts.map +1 -0
- package/dist/cjs/OwnerId.js +40 -0
- package/dist/cjs/OwnerId.js.map +7 -0
- package/dist/cjs/Projection.d.ts +29 -0
- package/dist/cjs/Projection.d.ts.map +1 -0
- package/dist/cjs/Projection.js +25 -0
- package/dist/cjs/Projection.js.map +7 -0
- package/dist/cjs/RedactedLogger.d.ts +121 -0
- package/dist/cjs/RedactedLogger.d.ts.map +1 -0
- package/dist/cjs/RedactedLogger.js +235 -0
- package/dist/cjs/RedactedLogger.js.map +7 -0
- package/dist/cjs/Redaction.d.ts +350 -0
- package/dist/cjs/Redaction.d.ts.map +1 -0
- package/dist/cjs/Redaction.js +928 -0
- package/dist/cjs/Redaction.js.map +7 -0
- package/dist/cjs/SqlConsensus.d.ts +44 -0
- package/dist/cjs/SqlConsensus.d.ts.map +1 -0
- package/dist/cjs/SqlConsensus.js +243 -0
- package/dist/cjs/SqlConsensus.js.map +7 -0
- package/dist/cjs/SqlJournal.d.ts +173 -0
- package/dist/cjs/SqlJournal.d.ts.map +1 -0
- package/dist/cjs/SqlJournal.js +1568 -0
- package/dist/cjs/SqlJournal.js.map +7 -0
- package/dist/cjs/StepFact.d.ts +66 -0
- package/dist/cjs/StepFact.d.ts.map +1 -0
- package/dist/cjs/StepFact.js +68 -0
- package/dist/cjs/StepFact.js.map +7 -0
- package/dist/cjs/index.d.ts +95 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +63 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/JournalInternalFault.d.ts +37 -0
- package/dist/cjs/internal/JournalInternalFault.d.ts.map +1 -0
- package/dist/cjs/internal/JournalInternalFault.js +43 -0
- package/dist/cjs/internal/JournalInternalFault.js.map +7 -0
- package/dist/cjs/migrations/0001_initial.d.ts +15 -0
- package/dist/cjs/migrations/0001_initial.d.ts.map +1 -0
- package/dist/cjs/migrations/0001_initial.js +54 -0
- package/dist/cjs/migrations/0001_initial.js.map +7 -0
- package/dist/cjs/migrations/0002_checkpoints.d.ts +27 -0
- package/dist/cjs/migrations/0002_checkpoints.d.ts.map +1 -0
- package/dist/cjs/migrations/0002_checkpoints.js +48 -0
- package/dist/cjs/migrations/0002_checkpoints.js.map +7 -0
- package/dist/cjs/migrations/0003_startup_index.d.ts +15 -0
- package/dist/cjs/migrations/0003_startup_index.d.ts.map +1 -0
- package/dist/cjs/migrations/0003_startup_index.js +40 -0
- package/dist/cjs/migrations/0003_startup_index.js.map +7 -0
- package/dist/cjs/migrations/0004_dedup.d.ts +15 -0
- package/dist/cjs/migrations/0004_dedup.d.ts.map +1 -0
- package/dist/cjs/migrations/0004_dedup.js +57 -0
- package/dist/cjs/migrations/0004_dedup.js.map +7 -0
- package/dist/cjs/migrations/0005_run_event_type.d.ts +15 -0
- package/dist/cjs/migrations/0005_run_event_type.d.ts.map +1 -0
- package/dist/cjs/migrations/0005_run_event_type.js +40 -0
- package/dist/cjs/migrations/0005_run_event_type.js.map +7 -0
- package/dist/cjs/migrations/0006_consensus.d.ts +22 -0
- package/dist/cjs/migrations/0006_consensus.d.ts.map +1 -0
- package/dist/cjs/migrations/0006_consensus.js +84 -0
- package/dist/cjs/migrations/0006_consensus.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/test/Notifying.d.ts +65 -0
- package/dist/cjs/test/Notifying.d.ts.map +1 -0
- package/dist/cjs/test/Notifying.js +62 -0
- package/dist/cjs/test/Notifying.js.map +7 -0
- package/dist/cjs/test/TestJournal.d.ts +43 -0
- package/dist/cjs/test/TestJournal.d.ts.map +1 -0
- package/dist/cjs/test/TestJournal.js +43 -0
- package/dist/cjs/test/TestJournal.js.map +7 -0
- package/dist/esm/CallFact.d.ts +129 -0
- package/dist/esm/CallFact.d.ts.map +1 -0
- package/dist/esm/CallFact.js +96 -0
- package/dist/esm/CallFact.js.map +1 -0
- package/dist/esm/Consensus.d.ts +440 -0
- package/dist/esm/Consensus.d.ts.map +1 -0
- package/dist/esm/Consensus.js +454 -0
- package/dist/esm/Consensus.js.map +1 -0
- package/dist/esm/EngineEvent.d.ts +890 -0
- package/dist/esm/EngineEvent.d.ts.map +1 -0
- package/dist/esm/EngineEvent.js +614 -0
- package/dist/esm/EngineEvent.js.map +1 -0
- package/dist/esm/ExecutionFact.d.ts +216 -0
- package/dist/esm/ExecutionFact.d.ts.map +1 -0
- package/dist/esm/ExecutionFact.js +374 -0
- package/dist/esm/ExecutionFact.js.map +1 -0
- package/dist/esm/Journal.d.ts +617 -0
- package/dist/esm/Journal.d.ts.map +1 -0
- package/dist/esm/Journal.js +323 -0
- package/dist/esm/Journal.js.map +1 -0
- package/dist/esm/JournalEvent.d.ts +421 -0
- package/dist/esm/JournalEvent.d.ts.map +1 -0
- package/dist/esm/JournalEvent.js +517 -0
- package/dist/esm/JournalEvent.js.map +1 -0
- package/dist/esm/JournalGeneration.d.ts +34 -0
- package/dist/esm/JournalGeneration.d.ts.map +1 -0
- package/dist/esm/JournalGeneration.js +65 -0
- package/dist/esm/JournalGeneration.js.map +1 -0
- package/dist/esm/JournalMetrics.d.ts +72 -0
- package/dist/esm/JournalMetrics.d.ts.map +1 -0
- package/dist/esm/JournalMetrics.js +79 -0
- package/dist/esm/JournalMetrics.js.map +1 -0
- package/dist/esm/Migrations.d.ts +42 -0
- package/dist/esm/Migrations.d.ts.map +1 -0
- package/dist/esm/Migrations.js +59 -0
- package/dist/esm/Migrations.js.map +1 -0
- package/dist/esm/OwnerId.d.ts +40 -0
- package/dist/esm/OwnerId.d.ts.map +1 -0
- package/dist/esm/OwnerId.js +33 -0
- package/dist/esm/OwnerId.js.map +1 -0
- package/dist/esm/Projection.d.ts +29 -0
- package/dist/esm/Projection.d.ts.map +1 -0
- package/dist/esm/Projection.js +13 -0
- package/dist/esm/Projection.js.map +1 -0
- package/dist/esm/RedactedLogger.d.ts +121 -0
- package/dist/esm/RedactedLogger.d.ts.map +1 -0
- package/dist/esm/RedactedLogger.js +445 -0
- package/dist/esm/RedactedLogger.js.map +1 -0
- package/dist/esm/Redaction.d.ts +350 -0
- package/dist/esm/Redaction.d.ts.map +1 -0
- package/dist/esm/Redaction.js +1584 -0
- package/dist/esm/Redaction.js.map +1 -0
- package/dist/esm/SqlConsensus.d.ts +44 -0
- package/dist/esm/SqlConsensus.d.ts.map +1 -0
- package/dist/esm/SqlConsensus.js +252 -0
- package/dist/esm/SqlConsensus.js.map +1 -0
- package/dist/esm/SqlJournal.d.ts +173 -0
- package/dist/esm/SqlJournal.d.ts.map +1 -0
- package/dist/esm/SqlJournal.js +1858 -0
- package/dist/esm/SqlJournal.js.map +1 -0
- package/dist/esm/StepFact.d.ts +66 -0
- package/dist/esm/StepFact.d.ts.map +1 -0
- package/dist/esm/StepFact.js +50 -0
- package/dist/esm/StepFact.js.map +1 -0
- package/dist/esm/index.d.ts +95 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +95 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/JournalInternalFault.d.ts +37 -0
- package/dist/esm/internal/JournalInternalFault.d.ts.map +1 -0
- package/dist/esm/internal/JournalInternalFault.js +28 -0
- package/dist/esm/internal/JournalInternalFault.js.map +1 -0
- package/dist/esm/migrations/0001_initial.d.ts +15 -0
- package/dist/esm/migrations/0001_initial.d.ts.map +1 -0
- package/dist/esm/migrations/0001_initial.js +32 -0
- package/dist/esm/migrations/0001_initial.js.map +1 -0
- package/dist/esm/migrations/0002_checkpoints.d.ts +27 -0
- package/dist/esm/migrations/0002_checkpoints.d.ts.map +1 -0
- package/dist/esm/migrations/0002_checkpoints.js +38 -0
- package/dist/esm/migrations/0002_checkpoints.js.map +1 -0
- package/dist/esm/migrations/0003_startup_index.d.ts +15 -0
- package/dist/esm/migrations/0003_startup_index.d.ts.map +1 -0
- package/dist/esm/migrations/0003_startup_index.js +18 -0
- package/dist/esm/migrations/0003_startup_index.js.map +1 -0
- package/dist/esm/migrations/0004_dedup.d.ts +15 -0
- package/dist/esm/migrations/0004_dedup.d.ts.map +1 -0
- package/dist/esm/migrations/0004_dedup.js +38 -0
- package/dist/esm/migrations/0004_dedup.js.map +1 -0
- package/dist/esm/migrations/0005_run_event_type.d.ts +15 -0
- package/dist/esm/migrations/0005_run_event_type.d.ts.map +1 -0
- package/dist/esm/migrations/0005_run_event_type.js +18 -0
- package/dist/esm/migrations/0005_run_event_type.js.map +1 -0
- package/dist/esm/migrations/0006_consensus.d.ts +22 -0
- package/dist/esm/migrations/0006_consensus.d.ts.map +1 -0
- package/dist/esm/migrations/0006_consensus.js +69 -0
- package/dist/esm/migrations/0006_consensus.js.map +1 -0
- package/dist/esm/test/Notifying.d.ts +65 -0
- package/dist/esm/test/Notifying.d.ts.map +1 -0
- package/dist/esm/test/Notifying.js +62 -0
- package/dist/esm/test/Notifying.js.map +1 -0
- package/dist/esm/test/TestJournal.d.ts +43 -0
- package/dist/esm/test/TestJournal.d.ts.map +1 -0
- package/dist/esm/test/TestJournal.js +27 -0
- package/dist/esm/test/TestJournal.js.map +1 -0
- package/docs/README.md +164 -0
- package/docs/api.md +639 -0
- package/docs/concepts/compaction.md +157 -0
- package/docs/concepts/idempotency.md +127 -0
- package/docs/concepts/owner-fence.md +124 -0
- package/docs/concepts/redaction.md +218 -0
- package/docs/concepts/state-event-authority.md +159 -0
- package/docs/concepts/two-channels.md +167 -0
- package/docs/guides/commit-state-and-entry.md +114 -0
- package/docs/guides/compact-a-run.md +134 -0
- package/docs/guides/fold-a-projection.md +106 -0
- package/docs/guides/read-a-run.md +139 -0
- package/docs/guides/redact-log-output.md +94 -0
- package/docs/guides/testing.md +124 -0
- package/docs/guides/write-lifecycle-events.md +110 -0
- package/docs/installation.md +133 -0
- package/docs/quickstart.md +143 -0
- package/docs/troubleshooting.md +214 -0
- package/package.json +263 -3
- package/src/CallFact.ts +117 -0
- package/src/Consensus.ts +683 -0
- package/src/EngineEvent.ts +823 -0
- package/src/ExecutionFact.ts +433 -0
- package/src/Journal.ts +688 -0
- package/src/JournalEvent.ts +654 -0
- package/src/JournalGeneration.ts +77 -0
- package/src/JournalMetrics.ts +89 -0
- package/src/Migrations.ts +62 -0
- package/src/OwnerId.ts +42 -0
- package/src/Projection.ts +31 -0
- package/src/RedactedLogger.ts +483 -0
- package/src/Redaction.ts +1784 -0
- package/src/SqlConsensus.ts +344 -0
- package/src/SqlJournal.ts +2732 -0
- package/src/StepFact.ts +69 -0
- package/src/index.ts +109 -0
- package/src/internal/JournalInternalFault.ts +40 -0
- package/src/migrations/0001_initial.ts +41 -0
- package/src/migrations/0002_checkpoints.ts +46 -0
- package/src/migrations/0003_startup_index.ts +19 -0
- package/src/migrations/0004_dedup.ts +43 -0
- package/src/migrations/0005_run_event_type.ts +19 -0
- package/src/migrations/0006_consensus.ts +83 -0
- package/src/test/Notifying.ts +101 -0
- package/src/test/TestJournal.ts +52 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SqlJournal.js","sourceRoot":"","sources":["../../src/SqlJournal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAC1F,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,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M;QACN,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC;QAClC,OAAO;QACP,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,GAAG,EAAE,CACrC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAC/E,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAC9B,CACF,EAAE;QACH,UAAU;QACV,gBAAgB;QAChB,OAAO;KACR,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEJ;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,OAA0B,EAC2D,EAAE,CACvF,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;AAEtC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,OAA0B,EAC+C,EAAE,CAC3E,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA","sourcesContent":["/**\n * SQLite-backed logical journal with durable and lossy channels.\n *\n * Lossy telemetry events remain optimistic until the single scoped writer\n * commits them, so a process crash can lose accepted-but-unwritten telemetry.\n * Lifecycle events use `emitDurable` and return after commit, except inside\n * `transact`, where their savepoint completes before the outer commit.\n *\n * Governing design: `packages/smithers/flows/journal/docs/concepts/two-channels.md`.\n * Prior-art decision: `packages/smithers/flows/sync/docs/concepts/replay-then-follow.md`.\n *\n * The replay-then-follow stream follows Effect's `EventJournal` and OpenCode's\n * upstream event stream design. The bounded send queue deliberately deviates\n * from their synchronous durable writes by reserving a provisional per-run\n * sequence before admission. Both channels finalize canonical order at commit.\n * SQLite retry and transaction behavior comes through `@smthrs/database`.\n *\n * @since 0.1.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport { afterCommit, DatabaseError, DurableWriter } from \"@smthrs/database/DurableWriter\"\nimport * as Cause from \"effect/Cause\"\nimport * as Clock from \"effect/Clock\"\nimport * as Deferred from \"effect/Deferred\"\nimport * as Effect from \"effect/Effect\"\nimport * as Exit from \"effect/Exit\"\nimport * as Layer from \"effect/Layer\"\nimport * as Metric from \"effect/Metric\"\nimport * as Option from \"effect/Option\"\nimport * as PubSub from \"effect/PubSub\"\nimport * as Queue from \"effect/Queue\"\nimport * as Result from \"effect/Result\"\nimport * as Schema from \"effect/Schema\"\nimport * as Scope from \"effect/Scope\"\nimport * as Semaphore from \"effect/Semaphore\"\nimport * as Stream from \"effect/Stream\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\nimport type * as SqlError from \"effect/unstable/sql/SqlError\"\nimport { Consensus } from \"./Consensus.ts\"\nimport { JournalInternalFault } from \"./internal/JournalInternalFault.ts\"\nimport {\n Checkpoint,\n CheckpointOptions,\n type Compacted,\n CompactOptions,\n type DurableReceipt,\n type EmitReceipt,\n EntriesOptions,\n type EntriesPage,\n Journal,\n JournalError,\n make as makeJournal,\n maxEntriesLimit,\n type OverflowPolicy,\n type Service,\n StreamOptions\n} from \"./Journal.ts\"\nimport {\n type Dedupe,\n Entry,\n Input,\n makeEventId,\n RunId,\n type Seq,\n type SourceId,\n type SourceSeq\n} from \"./JournalEvent.ts\"\nimport * as JournalGeneration from \"./JournalGeneration.ts\"\nimport * as JournalMetrics from \"./JournalMetrics.ts\"\nimport { OwnerId } from \"./OwnerId.ts\"\nimport type { Projection } from \"./Projection.ts\"\nimport * as Redaction from \"./Redaction.ts\"\nimport * as SqlConsensus from \"./SqlConsensus.ts\"\n\n/** JSON text carrying an arbitrary decoded value. */\nconst UnknownFromJsonString = Schema.fromJsonString(Schema.Unknown)\n\n/**\n * Automatic checkpoint-and-compact policy for the SQL journal.\n *\n * Disabled unless set on {@link SqlJournalOptions}. Once a run's committed\n * entry count reaches `entryThreshold`, the journal asks `capture` for the\n * caller's replay state at the run's durable tail, writes it as a checkpoint\n * at that sequence, and compacts the entries strictly below it.\n *\n * Both channels run the policy after their allocation permit is free. Lossy\n * commits fork scoped maintenance so the sole queue consumer keeps draining;\n * durable emits await their attempt. `flush` awaits registered maintenance.\n * `capture` may read or emit without blocking unrelated allocation. A capture is interrupted\n * after 30 seconds so caller code cannot wedge journal admission indefinitely.\n *\n * A failed or refused attempt (a live stream behind the boundary, a capture\n * failure) is logged at warning, damped for `entryThreshold`\n * further committed entries, and never surfaced to the emit that triggered\n * it.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface CompactionPolicy {\n readonly entryThreshold: number\n readonly capture: (runId: RunId, upTo: Seq) => Effect.Effect<unknown, unknown>\n}\n\n/**\n * SQL journal queue and batching options.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface SqlJournalOptions {\n /**\n * Bound on the number of ENTRIES held in two places at once: the lossy\n * admission queue, where `overflow` decides what happens when it is full,\n * and the sliding `changes` buffer, where a slow subscriber silently loses\n * the entries that fall out of it.\n *\n * It bounds entries, not bytes. Set {@link SqlJournalOptions.maxEntryBytes}\n * to bound the size of one entry as well; with it unset a handful of very\n * large payloads is still the memory bill.\n */\n readonly capacity: number\n /** Policy applied when the lossy admission queue is full. */\n readonly overflow: OverflowPolicy\n /** Entries the queued writer commits per transaction. */\n readonly batchSize?: number | undefined\n /**\n * Upper bound on the in-process source-event index, the map that answers\n * producer idempotency from memory.\n *\n * The index is a cache, never the authority, and a MISS costs a receipt, not\n * correctness. On a miss for an explicit producer sequence the entry is\n * admitted optimistically without any read: `emitLossy` returns `Accepted`\n * where a resident entry would have returned `Duplicate`, and the insert\n * collapses onto the committed row through the unique index\n * `(run_id, source_id, source_seq)` rather than doubling it. A CHANGED retry\n * behind an evicted entry therefore surfaces `idempotency_conflict` from\n * `flush`, not from the emit. See `admitFromIndex` for why the read is gone:\n * `emitLossy` is called from inside other write transactions, and the\n * pre-admission SELECT deadlocked `@smthrs/agent`'s exit flush against the\n * engine's own writer, measured at over 120 s versus about half a second\n * without it.\n *\n * Bounding the cache keeps startup decode and resident memory O(bound) rather\n * than O(total events ever written), mirroring Temporal's refusal to hold\n * unbounded history in a shard (`service/history`). The separate\n * sequence-floor maps start empty and grow only with runs and producers this\n * layer instance touches; they are lazy, not governed by this bound.\n *\n * Idempotency compares canonical persisted JSON after redaction. Two inputs\n * that redact to the same value are therefore the same event, and JSON's\n * encoding intentionally treats `NaN` and `null` as the same `null` value.\n */\n readonly sourceEventCache?: number | undefined\n /**\n * Largest single entry the journal admits, measured in UTF-8 bytes of the\n * encoded `payload` plus `meta`.\n *\n * Unset by default, which means unbounded: `capacity` bounds how MANY entries\n * the admission queue and the `changes` buffer hold, never how large one is,\n * so without this a handful of multi-megabyte payloads is the memory bill,\n * and every one of them is replayed to each sync subscriber and time-travel\n * consumer on every read. Set it where the journal is fed by untrusted or\n * unbounded producers.\n *\n * The bound is checked after encoding and BEFORE any sequence is allocated or\n * anything is queued, so a refused entry costs no sequence and leaves no gap.\n * An entry over the bound fails `invalid_event`.\n */\n readonly maxEntryBytes?: number | undefined\n /**\n * Scrub applied to every `payload` and `meta` before it is encoded for\n * persistence.\n *\n * Journal rows are permanent and are replayed verbatim to sync subscribers\n * and time-travel consumers, so a credential that reaches `payload_json` is\n * a durable, broadly readable leak. Redaction therefore defaults to\n * `Redaction.make()`; pass `Redaction.makeNoop()` to persist payloads\n * verbatim by choice.\n */\n readonly redact?: Redaction.Redactor | undefined\n /**\n * Automatic checkpoint-and-compact policy. Off by default: without it the\n * journal never deletes an entry, and checkpointing stays a caller-driven\n * `checkpoint` / `compact` call.\n */\n readonly compaction?: CompactionPolicy | undefined\n}\n\n/** Default retained window of the source-event index. */\nconst defaultSourceEventCache = 4096\n\n/** Bounds caller-supplied compaction capture work before the attempt is damped. */\nconst compactionCaptureTimeout = \"30 seconds\"\n\ninterface QueuedEntry {\n readonly runId: RunId\n readonly seq: Seq\n readonly eventId: string\n readonly sourceId: SourceId\n readonly sourceSeq: SourceSeq\n readonly emittedAtMs: number\n readonly eventType: string\n readonly payloadJson: string\n readonly metaJson: string\n /** The producer's reading of a collision on this entry's identity. */\n readonly dedupe: Dedupe\n}\n\ninterface JournalRow {\n readonly run_id: string\n readonly seq: number\n readonly event_id: string\n readonly source_id: string\n readonly source_seq: number\n readonly emitted_at_ms: number\n readonly event_type: string\n readonly payload_json: string\n readonly meta_json: string\n}\n\ninterface CheckpointRow {\n readonly run_id: string\n readonly seq: number\n readonly state_json: string\n readonly created_at_ms: number\n readonly compacted_at_ms: number | null\n}\n\ninterface Prepared {\n readonly validated: Input\n readonly payloadJson: string\n readonly metaJson: string\n}\n\ntype Commit =\n | { readonly entry: Entry; readonly inserted: true }\n | { readonly entry: Pick<Entry, \"seq\">; readonly inserted: false }\n\ninterface SettledCommit {\n readonly queued: QueuedEntry\n readonly commit: Commit\n}\n\ninterface EntryLoss {\n readonly queued: QueuedEntry\n readonly cause: JournalError\n}\n\ninterface BatchOutcome {\n readonly commits: ReadonlyArray<SettledCommit>\n readonly losses: ReadonlyArray<EntryLoss>\n}\n\ninterface RunBarrier {\n /**\n * Serializes one run's admission decisions against the moment a compaction\n * closes the run, so \"read the gate, then admit\" is one critical section.\n *\n * Never held across a wait on the database outside a transaction the holder\n * already owns; `admitFromIndex` in `SqlJournal.layer` states the lock order\n * between this permit and the writer transaction.\n */\n readonly semaphore: Semaphore.Semaphore\n /**\n * Serializes compactions of one run inside their SQL transactions. Never\n * held during the drain or while requesting a database connection.\n */\n readonly compactionLock: Semaphore.Semaphore\n /**\n * Serializes the compaction policy's per-run bookkeeping.\n *\n * A third lock rather than a reuse of either one above: the bookkeeping ends\n * by running a compaction, and a compaction takes `compactionLock` and\n * `semaphore` through `withCompactionBarrier`, so counting under either of\n * those would deadlock against the work it schedules. No admission path takes\n * this one.\n */\n readonly maintenance: Semaphore.Semaphore\n /** Holders and waiters that can still use this exact barrier. */\n users: number\n /** Open while a compaction owns the run; every admission awaits it. */\n compaction: Deferred.Deferred<void> | undefined\n}\n\ntype RunAdmission<A> =\n | { readonly _tag: \"Done\"; readonly value: A }\n | { readonly _tag: \"Wait\"; readonly gate: Deferred.Deferred<void> }\n\ninterface SourceEvent {\n readonly seq: Seq\n readonly eventType: string\n readonly payloadJson: string\n readonly metaJson: string\n readonly status: \"pending\" | \"committed\"\n}\n\ntype Status = \"open\" | \"closing\" | \"closed\"\n\ninterface State {\n status: Status\n /**\n * The most recent batch the optimistic writer lost. It is a *report*, not a\n * latch: the writer survives a failed batch, so a transient outage must not\n * revoke the lossy channel, and with it the durable delivery paths that call\n * `flush`, for the rest of the process's life.\n *\n * Each loss is reported to whoever was waiting on it (`flushWaiters`, live\n * streams) and, via `lossEpoch`, to at most one later `flush` and to every\n * live stream that had not yet observed it. After that the report is spent\n * and the journal is usable again the moment the database is.\n */\n sinkFailure: JournalError | undefined\n /** Incremented on every lost batch; identifies an unreported loss. */\n lossEpoch: number\n /** The highest `lossEpoch` already reported to a `flush` caller. */\n flushedLossEpoch: number\n pending: number\n readonly pendingByRun: Map<RunId, Set<QueuedEntry>>\n readonly sequences: Map<RunId, number>\n readonly sourceSequences: Map<string, number>\n readonly sourceEvents: Map<string, SourceEvent>\n readonly flushWaiters: Set<Deferred.Deferred<void, JournalError>>\n}\n\nconst error = (code: JournalError[\"code\"], message: string, cause?: unknown): JournalError =>\n new JournalError({\n code,\n message,\n ...(cause === undefined ? {} : { cause })\n })\n\nconst sourceKey = (runId: RunId, sourceId: SourceId): string => `${runId.length}:${runId}${sourceId.length}:${sourceId}`\n\nconst sourceEventKey = (runId: RunId, sourceId: SourceId, sourceSeq: SourceSeq): string =>\n `${sourceKey(runId, sourceId)}:${sourceSeq}`\n\n/**\n * Sorts a PARSED JSON tree so two encodings of one value compare equal.\n *\n * The argument is always `JSON.parse` output. That precondition is the whole\n * safety argument: parse output has no prototype `toJSON`, no cycle, and no\n * leaf JSON cannot represent, so this walk needs none of the handling\n * {@link Redaction.redact} carries. Running it over a raw value instead is\n * what broke: it rebuilt objects from `Object.keys`, so `{ at: new Date(...) }`\n * persisted as `{\"at\":{}}` under `Redaction.makeNoop()` while the default\n * redactor persisted the ISO string, and a redactor returning a cycle\n * recursed until the stack gave out and killed the emit with a defect instead\n * of a `JournalError`.\n *\n * `@smthrs/canonical` is the repository's general-purpose implementation, but\n * journal cannot add that dependency while this release's lockfiles are frozen.\n */\nconst canonicalizeFingerprint = (value: unknown, depth: number): unknown => {\n if (depth > Redaction.maxDepth) {\n throw new RangeError(`journal value nests deeper than ${Redaction.maxDepth} containers`)\n }\n if (Array.isArray(value)) return value.map((element) => canonicalizeFingerprint(element, depth + 1))\n if (value === null || typeof value !== \"object\") return value\n const record = value as Record<string, unknown>\n return Object.fromEntries(\n Object.keys(record).sort().map((key) => [key, canonicalizeFingerprint(record[key], depth + 1)])\n )\n}\n\n/**\n * Encodes a value as JSON, reporting anything the encoder refuses as a typed\n * failure.\n *\n * The encoder's failure channel covers every value it declines, a `BigInt` and\n * a cycle included, so nothing here has to catch a throw. What used to reach\n * the emit as a `Die` came from the canonicalizer running BEFORE this, over a\n * raw value it was never given the guards for; {@link encodeFingerprint} runs\n * it after.\n */\nconst encodeJson = (value: unknown, field: string): Result.Result<string, JournalError> =>\n Schema.encodeUnknownResult(UnknownFromJsonString)(value).pipe(\n Result.mapError((cause) => error(\"invalid_event\", `${field} must be JSON-serializable`, cause))\n )\n\n/**\n * The persisted bytes of one field: JSON, with object members in a stable key\n * order.\n *\n * Encoding happens FIRST and canonicalization runs over the parsed result, so\n * the bytes keep exactly the `JSON.stringify` semantics they had before\n * idempotency became key-order independent: a `Date` is its ISO string, an\n * `undefined` member is dropped, `NaN` is `null`. Canonicalizing the raw value\n * instead silently destroyed every one of those.\n *\n * Nesting is bounded at `Redaction.maxDepth`, the same ceiling the default\n * redactor enforces one step earlier, so a value that reaches this walk through\n * `Redaction.makeNoop()` is refused as `invalid_event` rather than exhausting\n * the stack as a defect.\n */\nconst encodeFingerprint = (value: unknown, field: string): Result.Result<string, JournalError> =>\n Result.flatMap(encodeJson(value, field), (json) =>\n Result.try({\n try: () => JSON.stringify(canonicalizeFingerprint(JSON.parse(json), 0)),\n catch: (cause) => error(\"invalid_event\", `${field} could not be canonicalized`, cause)\n }))\n\n/**\n * Whether one write is fenced on a run's persisted ownership.\n *\n * The journal used to pass `OwnerId | undefined` and fence only when the value\n * happened to be present, so an untyped caller that omitted the argument\n * silently selected the unfenced path on three public methods. The tag makes\n * the choice explicit: only `emitDurableUnfenced` and the internal\n * auto-compaction path construct `unfenced`, and they say so at the call site.\n */\ntype Fence =\n | { readonly _tag: \"Owned\"; readonly owner: OwnerId }\n | { readonly _tag: \"Unfenced\" }\n\n/** The one unfenced write posture, named so a call site cannot mean it by accident. */\nconst unfenced: Fence = { _tag: \"Unfenced\" }\n\nconst decodeOwner = Schema.decodeUnknownResult(OwnerId)\n\n/**\n * Decodes the mandatory owner of a fenced method.\n *\n * A missing, null, or malformed owner is a caller contract violation, not a\n * lost race: reporting it as `fence_lost` would tell the caller another\n * process owns the run and send it looking for a conflict that never\n * happened.\n */\nconst requireFence = (owner: unknown, method: string): Result.Result<Fence, JournalError> =>\n Result.match(decodeOwner(owner), {\n onFailure: (cause) => Result.fail(error(\"invalid_event\", `${method} requires a well-formed owner fence`, cause)),\n onSuccess: (value) => Result.succeed<Fence>({ _tag: \"Owned\", owner: value })\n })\n\nconst decodeInput = Schema.decodeUnknownResult(Input)\nconst decodeEntry = Schema.decodeUnknownEffect(Entry)\n/**\n * The read and maintenance boundaries decode the schemas they publish.\n *\n * `EntriesOptions`, `StreamOptions`, `CheckpointOptions`, `CompactOptions` and\n * `RunId` already carry every invariant these methods need, and hand-checking a\n * subset of them here let the read side disagree with the write side about what\n * an identifier is.\n */\nconst decodeEntriesOptions = Schema.decodeUnknownResult(EntriesOptions)\nconst decodeStreamOptions = Schema.decodeUnknownResult(StreamOptions)\nconst decodeCheckpointOptions = Schema.decodeUnknownResult(CheckpointOptions)\nconst decodeCompactOptions = Schema.decodeUnknownResult(CompactOptions)\nconst decodeRunId = Schema.decodeUnknownResult(RunId)\n\nconst decodeRow = (row: JournalRow): Effect.Effect<Entry, JournalError> =>\n Effect.all({\n payload: Schema.decodeUnknownEffect(UnknownFromJsonString)(row.payload_json),\n meta: Schema.decodeUnknownEffect(UnknownFromJsonString)(row.meta_json)\n }).pipe(\n Effect.map(({ meta, payload }) => ({\n runId: row.run_id as RunId,\n seq: Number(row.seq),\n eventId: row.event_id,\n sourceId: row.source_id,\n sourceSeq: Number(row.source_seq),\n emittedAtMs: Number(row.emitted_at_ms),\n eventType: row.event_type,\n payload,\n meta\n })),\n Effect.flatMap(decodeEntry),\n Effect.mapError((cause) => error(\"decode_failed\", \"could not decode a durable journal row\", cause))\n )\n\nconst decodeCheckpoint = Schema.decodeUnknownEffect(Checkpoint)\n\nconst decodeCheckpointRow = (row: CheckpointRow): Effect.Effect<Checkpoint, JournalError> =>\n Schema.decodeUnknownEffect(UnknownFromJsonString)(row.state_json).pipe(\n Effect.flatMap((state) =>\n decodeCheckpoint({\n runId: row.run_id,\n seq: Number(row.seq),\n state,\n createdAtMs: Number(row.created_at_ms),\n compactedAtMs: row.compacted_at_ms === null ? null : Number(row.compacted_at_ms)\n })\n ),\n Effect.mapError((cause) => error(\"decode_failed\", \"could not decode a durable checkpoint row\", cause))\n )\n\n/** Freezes the one object graph shared by every changes subscriber. */\nconst freezePublished = <A>(value: A): A => {\n const seen = new WeakSet<object>()\n const walk = (node: unknown): void => {\n if (node === null || typeof node !== \"object\") return\n /* v8 ignore next -- decoded JSON and Entry instances are acyclic, but this guard keeps the walk total */\n if (seen.has(node)) return\n seen.add(node)\n for (const key of Reflect.ownKeys(node)) {\n walk((node as Record<PropertyKey, unknown>)[key])\n }\n Object.freeze(node)\n }\n walk(value)\n return value\n}\n\ninterface ValidatedOptions {\n readonly batchSize: number\n readonly sourceEventCache: number\n readonly maxEntryBytes: number | undefined\n readonly redact: Redaction.Redactor\n}\n\n/**\n * UTF-8 size of the bytes an entry persists.\n *\n * `TextEncoder` rather than `Buffer.byteLength` because this module has no\n * other `node:` import and the journal's browser-facing consumers bundle it.\n */\nconst encodedBytes = (encoder: TextEncoder, payloadJson: string, metaJson: string): number =>\n encoder.encode(payloadJson).length + encoder.encode(metaJson).length\n\nconst validateOptions = (options: SqlJournalOptions): Effect.Effect<ValidatedOptions, JournalError> =>\n Effect.suspend(() => {\n if (!Number.isSafeInteger(options.capacity) || options.capacity <= 0) {\n return Effect.fail(error(\"invalid_event\", \"capacity must be a positive safe integer\"))\n }\n const batchSize = options.batchSize ?? Math.min(options.capacity, 64)\n if (!Number.isSafeInteger(batchSize) || batchSize <= 0) {\n return Effect.fail(error(\"invalid_event\", \"batchSize must be a positive safe integer\"))\n }\n const sourceEventCache = options.sourceEventCache ?? defaultSourceEventCache\n if (!Number.isSafeInteger(sourceEventCache) || sourceEventCache <= 0) {\n return Effect.fail(error(\"invalid_event\", \"sourceEventCache must be a positive safe integer\"))\n }\n if (\n options.maxEntryBytes !== undefined &&\n (!Number.isSafeInteger(options.maxEntryBytes) || options.maxEntryBytes <= 0)\n ) {\n return Effect.fail(error(\"invalid_event\", \"maxEntryBytes must be a positive safe integer\"))\n }\n if (\n options.compaction !== undefined &&\n (!Number.isSafeInteger(options.compaction.entryThreshold) || options.compaction.entryThreshold <= 0)\n ) {\n return Effect.fail(error(\"invalid_event\", \"compaction.entryThreshold must be a positive safe integer\"))\n }\n return Effect.succeed({\n batchSize,\n sourceEventCache,\n maxEntryBytes: options.maxEntryBytes,\n redact: options.redact ?? Redaction.make()\n })\n })\n\nconst isJournalError = Schema.is(JournalError)\n\n/**\n * Constructs the SQL journal over the context's SQL client, durable writer,\n * and consensus strategy.\n *\n * `emitLossy` validates and admits telemetry to the non-blocking queue;\n * `emitDurable` allocates and commits inside the database transaction, fenced\n * through `Consensus.guard` in that same transaction.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const make = (\n options: SqlJournalOptions\n): Effect.Effect<Service, JournalError, Consensus | DurableWriter | SqlClient.SqlClient | Scope.Scope> =>\n Effect.gen(function*() {\n const { batchSize, maxEntryBytes, redact, sourceEventCache } = yield* validateOptions(options)\n // `batchSize` sizes the writer's transactions. `stream` pages the durable\n // tail through `entries`, whose `limit` is bounded by `maxEntriesLimit`,\n // so a larger batch must not leak into the read boundary: a layer that\n // was accepted with `batchSize: 16384` streamed nothing but\n // `invalid_event` before this clamp.\n const readPageSize = Math.min(batchSize, maxEntriesLimit)\n const sql = yield* Effect.service(SqlClient.SqlClient)\n const writer = yield* DurableWriter\n const consensus = yield* Consensus\n yield* JournalGeneration.initialize.pipe(\n Effect.mapError((cause) => error(\"read_failed\", \"could not initialize journal generations\", cause))\n )\n /** One encoder for the layer: constructing one per emit measured slower. */\n const byteCounter = new TextEncoder()\n\n // Hash the same encoded content the ordinary dedup check compares.\n // A JSON tuple keeps boundaries unambiguous without retaining payloads.\n const contentFingerprint = (eventType: string, payloadJson: string, metaJson: string) =>\n Effect.tryPromise({\n try: () =>\n crypto.subtle.digest(\"SHA-256\", byteCounter.encode(JSON.stringify([eventType, payloadJson, metaJson]))),\n catch: (cause) => error(\"sink_failed\", \"could not fingerprint journal content\", cause)\n }).pipe(\n Effect.map((digest) =>\n Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\")\n )\n )\n\n const queue = yield* Queue.dropping<QueuedEntry>(options.capacity)\n const changes = yield* PubSub.sliding<Entry>(options.capacity)\n const wakes = new Map<RunId, Set<PubSub.PubSub<void>>>()\n /**\n * The durable cursor of every live in-process stream, per run: the\n * highest committed sequence the stream has read from the store, or its\n * starting `afterSequence`. `compact` refuses to truncate below a\n * registered cursor, so a live follower's next durable page is never\n * deleted out from under it. Readers this process cannot see, pagers\n * of `entries`, followers in other processes, are covered by the\n * read-side `compacted` guard instead.\n */\n const readers = new Map<RunId, Set<{ cursor: number }>>()\n /**\n * Only the most recent `sourceEventCache` events are decoded at startup.\n * Older events stay durable-only: their idempotency is enforced by the\n * writer's `(run_id, source_id, source_seq)` re-check, so the process\n * never has to hold the whole history to stay correct.\n */\n const sourceEventRows = yield* sql<JournalRow>`\n SELECT run_id, seq, event_id, source_id, source_seq, emitted_at_ms,\n event_type, payload_json, meta_json\n FROM flows_journal_events\n ORDER BY emitted_at_ms DESC, run_id DESC, seq DESC\n LIMIT ${sourceEventCache}\n `.pipe(\n Effect.mapError((cause) => error(\"sink_failed\", \"could not initialize journal source events\", cause))\n )\n const durableEntries = yield* Effect.forEach(sourceEventRows, decodeRow)\n const initialized = yield* Effect.fromResult(\n Result.gen(function*() {\n // The two allocation floors start EMPTY and are filled one run at a\n // time by `ensureFloors`. They used to be seeded by two unbounded\n // `GROUP BY` aggregations, one entry per run that ever wrote an\n // event, one per `(run_id, source_id)` pair, so layer construction\n // scanned the whole table and built a map proportional to total\n // history, which is exactly what the bound below exists to avoid.\n const sequences = new Map<RunId, number>()\n const sourceSequences = new Map<string, number>()\n const sourceEvents = new Map<string, SourceEvent>()\n // Seeded oldest-first so the map's insertion order stays the\n // eviction order once `retain` starts adding newer events.\n for (const entry of [...durableEntries].reverse()) {\n if (\n !Number.isSafeInteger(entry.seq) ||\n !Number.isSafeInteger(entry.sourceSeq) ||\n entry.seq === Number.MAX_SAFE_INTEGER ||\n entry.sourceSeq === Number.MAX_SAFE_INTEGER\n ) {\n return yield* Result.fail(\n error(\"decode_failed\", \"durable event sequence is outside the allocatable safe integer range\")\n )\n }\n sourceEvents.set(sourceEventKey(entry.runId, entry.sourceId, entry.sourceSeq), {\n seq: entry.seq,\n eventType: entry.eventType,\n payloadJson: yield* encodeFingerprint(entry.payload, \"payload\"),\n metaJson: yield* encodeFingerprint(entry.meta, \"meta\"),\n status: \"committed\"\n })\n }\n return {\n sequences,\n sourceSequences,\n sourceEvents\n }\n })\n )\n const state: State = {\n status: \"open\",\n sinkFailure: undefined,\n lossEpoch: 0,\n flushedLossEpoch: 0,\n pending: 0,\n pendingByRun: new Map(),\n sequences: initialized.sequences,\n sourceSequences: initialized.sourceSequences,\n sourceEvents: initialized.sourceEvents,\n flushWaiters: new Set()\n }\n // The permit protects only synchronous in-memory reservation. It must\n // never be held while waiting on SQLite: an enclosing `transact` owns a\n // database transaction, so DB -> allocator and allocator -> DB ordering\n // would otherwise deadlock concurrent lifecycle writers.\n const allocation = yield* Semaphore.make(1)\n // Close this scope AFTER the journal's flushing finalizer. Dynamically\n // forking directly into the layer scope would register interruption\n // finalizers ahead of the flush that must await these attempts.\n const maintenanceScope = yield* Scope.make()\n yield* Effect.addFinalizer((exit) => Scope.close(maintenanceScope, exit))\n let pendingMaintenance = 0\n const compactionCounts = new Map<RunId, number>()\n const compactingRuns = new Set<RunId>()\n const runBarriers = new Map<RunId, RunBarrier>()\n const runDrainWaiters = new Map<RunId, Set<Deferred.Deferred<void>>>()\n const activeWritesByRun = new Map<RunId, number>()\n\n const barrierFor = (runId: RunId): RunBarrier => {\n const existing = runBarriers.get(runId)\n if (existing !== undefined) return existing\n const created: RunBarrier = {\n semaphore: Semaphore.makeUnsafe(1),\n compactionLock: Semaphore.makeUnsafe(1),\n maintenance: Semaphore.makeUnsafe(1),\n users: 0,\n compaction: undefined\n }\n runBarriers.set(runId, created)\n return created\n }\n\n /** A waiter owns a reference too, before it can yield on any permit. */\n const withRunBarrier = <A, E, R>(\n runId: RunId,\n use: (barrier: RunBarrier) => Effect.Effect<A, E, R>\n ): Effect.Effect<A, E, R> =>\n Effect.suspend(() => {\n const barrier = barrierFor(runId)\n barrier.users += 1\n return use(barrier).pipe(Effect.ensuring(Effect.sync(() => {\n barrier.users -= 1\n })))\n })\n\n /** Flush is the retirement boundary; allocation floors remain monotonic. */\n const retireQuiescentRuns = (): void => {\n for (const [runId, barrier] of runBarriers) {\n if (\n barrier.users > 0 || barrier.compaction !== undefined ||\n state.pendingByRun.has(runId) || activeWritesByRun.has(runId) ||\n runDrainWaiters.has(runId) || readers.has(runId) || wakes.has(runId) ||\n compactingRuns.has(runId)\n ) continue\n runBarriers.delete(runId)\n compactionCounts.delete(runId)\n }\n }\n\n /** Blocks new admissions while a compaction owns the run. */\n const withRunAdmission = <A, E, R>(\n runId: RunId,\n effect: Effect.Effect<A, E, R>\n ): Effect.Effect<A, E, R> =>\n withRunBarrier(runId, (barrier) =>\n barrier.semaphore.withPermit(\n Effect.suspend((): Effect.Effect<RunAdmission<A>, E, R> => {\n const gate = barrier.compaction\n return gate === undefined\n ? Effect.map(effect, (value): RunAdmission<A> => ({ _tag: \"Done\", value }))\n : Effect.succeed<RunAdmission<A>>({ _tag: \"Wait\", gate })\n })\n ).pipe(\n Effect.flatMap((attempt): Effect.Effect<A, E, R> =>\n attempt._tag === \"Done\"\n ? Effect.succeed(attempt.value)\n : Deferred.await(attempt.gate).pipe(\n Effect.andThen(withRunAdmission(runId, effect))\n )\n )\n ))\n\n /** Acquires batch run permits in stable order so mixed-run batches cannot deadlock. */\n const withRunPermits = <A, E, R>(\n runIds: ReadonlyArray<RunId>,\n effect: Effect.Effect<A, E, R>\n ): Effect.Effect<A, E, R> => {\n const ordered = [...new Set(runIds)].sort()\n const acquire = (index: number): Effect.Effect<A, E, R> =>\n index === ordered.length\n ? effect\n : withRunBarrier(ordered[index]!, (barrier) => barrier.semaphore.withPermit(acquire(index + 1)))\n return acquire(0)\n }\n\n const admitRunPending = (queued: QueuedEntry): void => {\n const pending = state.pendingByRun.get(queued.runId) ?? new Set<QueuedEntry>()\n pending.add(queued)\n state.pendingByRun.set(queued.runId, pending)\n }\n\n const completeRunDrain = (runId: RunId): void => {\n if ((state.pendingByRun.get(runId)?.size ?? 0) + (activeWritesByRun.get(runId) ?? 0) > 0) return\n const waiters = runDrainWaiters.get(runId)\n runDrainWaiters.delete(runId)\n for (const waiter of waiters ?? []) {\n Deferred.doneUnsafe(waiter, Effect.void)\n }\n }\n\n const settleRunPending = (batch: ReadonlyArray<QueuedEntry>): void => {\n for (const queued of batch) {\n // Every batched entry was counted by `admitRunPending` when it was\n // admitted, so the run always has a count to settle here.\n const pending = state.pendingByRun.get(queued.runId)!\n pending.delete(queued)\n if (pending.size > 0) continue\n state.pendingByRun.delete(queued.runId)\n completeRunDrain(queued.runId)\n }\n }\n\n const endRunWrite = (runId: RunId): void => {\n // `withActiveRunWrite` counted this write in before running it, and\n // releases through here exactly once.\n const remaining = activeWritesByRun.get(runId)! - 1\n if (remaining > 0) {\n activeWritesByRun.set(runId, remaining)\n return\n }\n activeWritesByRun.delete(runId)\n completeRunDrain(runId)\n }\n\n /**\n * Register only INSIDE the writer transaction, after SQL acquisition.\n * A parked writer has touched neither SQL nor the allocation floors, so\n * the SQL lock orders it after the compactor's commit. It then allocates\n * its canonical seq above the surviving checkpoint/tail. An explicit\n * sourceSeq chosen earlier is an identity, not a replay cursor; the\n * insert still checks that identity against rows and retained tombstones.\n * No SQL owner may drain a writer parked on that owner's connection.\n */\n const withActiveRunWrite = <A, E, R>(\n runId: RunId,\n effect: Effect.Effect<A, E, R>\n ): Effect.Effect<A, E, R> =>\n withRunBarrier(runId, () =>\n Effect.suspend(() => {\n activeWritesByRun.set(runId, (activeWritesByRun.get(runId) ?? 0) + 1)\n return effect.pipe(Effect.ensuring(Effect.sync(() => endRunWrite(runId))))\n }))\n\n const awaitRunDrained = (runId: RunId): Effect.Effect<void> =>\n Effect.suspend(() => {\n if ((state.pendingByRun.get(runId)?.size ?? 0) + (activeWritesByRun.get(runId) ?? 0) === 0) {\n return Effect.void\n }\n const waiter = Deferred.makeUnsafe<void>()\n const waiters = runDrainWaiters.get(runId) ?? new Set()\n waiters.add(waiter)\n runDrainWaiters.set(runId, waiters)\n // No cleanup on the way out: `completeRunDrain` deletes the whole\n // set as it completes it, and an interrupted waiter is a Deferred\n // nobody awaits that the next drain of this run discards. Deleting\n // it here would only add an unreachable branch.\n return Deferred.await(waiter)\n })\n\n /**\n * Top-level compaction drains with admission OPEN, acquires SQL before\n * either run lock or the gate, then rechecks the drain. Raced work makes\n * it release SQL and retry. No connection owner waits on work needing SQL.\n *\n * An enclosing managed OR raw SQL transaction cannot release its SQL by\n * returning from our savepoint. Skip both drains there and persist this\n * run's pending entries inline, using the batch insert path under the\n * same transaction and gate. The pending set includes entries already\n * taken by the batch fiber but still waiting for SQL. Keep them queued\n * and counted until that fiber settles: rollback must leave its work\n * intact, and after commit it collapses onto the inline inserts by identity.\n * Publication is owned by the outer commit, exactly as for durable emits.\n * Raw SQL has no managed publication boundary; replay remains authoritative.\n *\n * A reservation allocated before compaction is NOT a committed cursor.\n * The inline insert raises its canonical seq above the durable tail,\n * even if its reservation is below the checkpoint being compacted. Thus\n * it survives replay after that checkpoint with its source identity and\n * content checks unchanged. Leaving it queued without inserting would\n * instead let the new floor reject the old reservation as `compacted`.\n * Already compacted reservations retain that existing loss behavior.\n *\n * The final drain check and gate closure share a short admission permit,\n * released before SQL work. Cold floor reads hold no run permit. Durable\n * writes register only after SQL acquisition. Concurrent compactors also\n * acquire SQL before their compaction lock. All gates/locks unwind before\n * retry or cancellation; no run lock or closed gate waits for SQL.\n */\n const withCompactionBarrier = <A, E, R>(\n runId: RunId,\n effect: Effect.Effect<A, E, R>\n ): Effect.Effect<A, Exclude<E, SqlError.SqlError> | DatabaseError, R> =>\n Effect.flatMap(Effect.serviceOption(sql.transactionService), (enclosing) =>\n withRunBarrier(runId, (barrier) => {\n const nested = Option.isSome(enclosing)\n const attempt: Effect.Effect<A, Exclude<E, SqlError.SqlError> | DatabaseError, R> =\n (nested ? Effect.void : awaitRunDrained(runId)).pipe(\n Effect.andThen(writer.write(\n barrier.compactionLock.withPermit(Effect.uninterruptibleMask((restore) =>\n barrier.semaphore.withPermit(Effect.sync(() => {\n if (\n !nested && (state.pendingByRun.get(runId)?.size ?? 0) + (activeWritesByRun.get(runId) ?? 0) > 0\n ) {\n return undefined\n }\n const gate = Deferred.makeUnsafe<void>()\n barrier.compaction = gate\n return gate\n })).pipe(Effect.flatMap((gate) =>\n gate === undefined ?\n Effect.succeed(Option.none<A>()) :\n restore(Effect.gen(function*() {\n if (nested) {\n const outcome = yield* insertBatch([...state.pendingByRun.get(runId) ?? []])\n // The batch still owns loss reporting and pending\n // settlement; neither may escape an outer rollback.\n for (const { queued, commit } of outcome.commits) {\n yield* settleCommit(queued, commit, restore)\n }\n }\n return yield* Effect.asSome(effect)\n })).pipe(Effect.ensuring(Effect.sync(() => {\n barrier.compaction = undefined\n Deferred.doneUnsafe(gate, Effect.void)\n })))\n ))\n ))\n )),\n Effect.flatMap((result) =>\n Option.isSome(result) ? Effect.succeed(result.value) : attempt\n )\n )\n return attempt\n }))\n\n /**\n * Raises the in-process seq allocation floor for a run.\n *\n * Both emit paths call this at the moment they allocate, so the floor\n * never names a seq some writer has already taken. It used to move only\n * in `rememberCommitted`, which `settleCommit` parks until the outermost\n * COMMIT, so a durable emit inside an open `transact` left the floor\n * behind, `emitLossy` allocated the same seq from it, and the lossy\n * INSERT hit `PRIMARY KEY (run_id, seq)`.\n *\n * The floor only ever rises. `insertOne` can settle on a raced duplicate\n * whose row was written by another process at a higher seq, and that\n * still has to raise the floor here.\n */\n const raiseSequenceFloor = (runId: RunId, seq: number): void => {\n state.sequences.set(runId, Math.max(state.sequences.get(runId) ?? 0, seq + 1))\n }\n\n /** Raises the in-process producer-sequence allocation floor. */\n const raiseSourceSequenceFloor = (runId: RunId, sourceId: SourceId, sourceSeq: number): void => {\n const key = sourceKey(runId, sourceId)\n state.sourceSequences.set(key, Math.max(state.sourceSequences.get(key) ?? 0, sourceSeq + 1))\n }\n\n /**\n * Adds an entry to the bounded source-event index, evicting the\n * least-recently added *committed* entry when the bound is exceeded.\n *\n * Uncommitted entries are never evicted: they are not in the database\n * yet, so memory is the only place their identity exists. Committed ones\n * are always re-derivable from `flows_journal_events`, which is what\n * makes the bound safe.\n */\n const retain = (identity: string, event: SourceEvent): void => {\n state.sourceEvents.delete(identity)\n state.sourceEvents.set(identity, event)\n if (state.sourceEvents.size <= sourceEventCache) {\n return\n }\n for (const [candidate, retained] of state.sourceEvents) {\n if (retained.status !== \"committed\" || candidate === identity) {\n continue\n }\n state.sourceEvents.delete(candidate)\n return\n }\n }\n\n const completeFlushWaiters = (exit: Effect.Effect<void, JournalError>): void => {\n const waiters = Array.from(state.flushWaiters)\n state.flushWaiters.clear()\n for (const waiter of waiters) {\n Deferred.doneUnsafe(waiter, exit)\n }\n }\n\n const flushInternal: Effect.Effect<void, JournalError> = Effect.suspend(() => {\n // A loss that happened while nothing was registered still has to reach\n // a caller, so the first flush after it reports it, once. A later\n // flush has nothing to do with the lost batch and must succeed, or a\n // single transient outage would stall every durable delivery that\n // flushes (`DeferredPersistence.completeDeferred`, `recordClockScheduled`)\n // for the process's lifetime.\n if (state.sinkFailure !== undefined && state.lossEpoch > state.flushedLossEpoch) {\n state.flushedLossEpoch = state.lossEpoch\n return Effect.fail(state.sinkFailure)\n }\n if (state.status === \"closed\") {\n return Effect.fail(error(\"journal_closed\", \"journal is closed\"))\n }\n if (state.pending === 0 && pendingMaintenance === 0) {\n return Effect.void\n }\n const waiter = Deferred.makeUnsafe<void, JournalError>()\n state.flushWaiters.add(waiter)\n return Deferred.await(waiter).pipe(\n Effect.ensuring(Effect.sync(() => {\n state.flushWaiters.delete(waiter)\n }))\n )\n }).pipe(Effect.ensuring(Effect.sync(retireQuiescentRuns)))\n\n const prepare = (input: Input, emittedAtMs: number): Result.Result<Prepared, JournalError> =>\n Result.gen(function*() {\n if (state.status !== \"open\") {\n return yield* Result.fail(error(\"journal_closed\", \"journal is closed\"))\n }\n // `RunId`, `SourceId`, and `Input.eventType` carry the non-empty and\n // well-formed-UTF-16 checks themselves, so decode is the whole\n // identifier contract. The service used to re-check emptiness here,\n // which let a caller hold an identifier that decoded and then failed\n // at the write.\n const validated = yield* Result.mapError(\n decodeInput(input),\n (cause) => error(\"invalid_event\", \"event violates the journal input contract\", cause)\n )\n if (!Number.isSafeInteger(emittedAtMs) || emittedAtMs < 0) {\n return yield* Result.fail(\n error(\"invalid_event\", \"emittedAtMs must be a non-negative safe integer\")\n )\n }\n // Redaction happens here, at the single point every channel funnels\n // through, so no write path can bypass it (issue #46). A redaction\n // failure carries no cause: whatever the redactor or a hostile getter\n // threw can quote the unredacted value, and that value never reached\n // the journal, so the error must not be the place it leaks from.\n const redactedPayload = yield* Result.try({\n try: () => redact(validated.payload),\n catch: () => error(\"invalid_event\", \"payload could not be redacted\")\n })\n const redactedMeta = yield* Result.try({\n try: () => redact(validated.meta ?? null),\n catch: () => error(\"invalid_event\", \"meta could not be redacted\")\n })\n const payloadJson = yield* encodeFingerprint(redactedPayload, \"payload\")\n const metaJson = yield* encodeFingerprint(redactedMeta, \"meta\")\n // Measured on the encoded bytes, and here rather than at admission,\n // so a refused entry costs no sequence and leaves no gap in the run.\n if (maxEntryBytes !== undefined) {\n const bytes = encodedBytes(byteCounter, payloadJson, metaJson)\n if (bytes > maxEntryBytes) {\n return yield* Result.fail(\n error(\n \"invalid_event\",\n `event is ${bytes} bytes, over the ${maxEntryBytes}-byte maxEntryBytes bound`\n )\n )\n }\n }\n return { validated, payloadJson, metaJson }\n })\n\n const compareSourceEvent = (\n prepared: Prepared,\n sourceSeq: SourceSeq,\n existing: SourceEvent\n ): Result.Result<EmitReceipt, JournalError> => {\n const { metaJson, payloadJson, validated } = prepared\n if (\n validated.dedupe !== \"identity\" && (\n existing.eventType !== validated.eventType ||\n existing.payloadJson !== payloadJson ||\n existing.metaJson !== metaJson\n )\n ) {\n return Result.fail(error(\n \"idempotency_conflict\",\n `source event ${validated.sourceId}:${sourceSeq} for run ${validated.runId} was reused with different content`\n ))\n }\n return Result.succeed({\n _tag: \"Duplicate\",\n seq: existing.seq,\n sourceSeq,\n status: existing.status\n })\n }\n\n /**\n * Answers an explicit producer identity from memory alone, before\n * anything is allocated.\n *\n * This performs NO read. That is the whole point of it: `emitLossy` is\n * the channel a producer reaches for precisely because it may be called\n * from inside somebody else's open write transaction, and this used to\n * issue a SELECT here for every explicit sequence. The executor's exit\n * flush in `@smthrs/agent` runs inside the engine's write transaction,\n * so that read waited on the writer that was waiting on the flush and\n * the run stalled at 0% CPU: measured, that case did not finish in\n * 120 s with the read and takes about half a second without it. What the\n * read used to answer, a producer identity that is already durable but\n * no longer in the bounded index, the unique index\n * `(run_id, source_id, source_seq)` answers at insert time instead: the\n * queued insert runs first and reads only the row it actually collided\n * with, inside the writer's own transaction where a read cannot\n * deadlock against it.\n *\n * A cache miss therefore admits optimistically. The receipt is\n * `Accepted` where it would once have been `Duplicate`, which the lossy\n * channel already allows for: `Accepted` is admission to the queue, not\n * a commit, and the entry still collapses onto the committed row rather\n * than doubling it.\n *\n * Lock order: lossy admission checks cached identities without SQL,\n * reads cold allocation floors outside run permits on a miss, then\n * rechecks the identity and reserves sequences under\n * the permit using max(read floor, in-memory floor). Durable writers\n * raise those caches at allocation time and take no run permit. Batches\n * take the writer transaction before run permits, so their SQL already\n * owns the connection. Compaction drains with admission open, acquires\n * SQL before its run locks, then rechecks the drain and closes the gate.\n * At top level, raced work makes it release SQL and drain again. Inside\n * an enclosing transaction it persists pending entries inline instead;\n * draining there would wait on work needing its own connection. Durable\n * writes register as active only after acquiring SQL. No permit or\n * closed gate ever waits for a SQL connection, and\n * a transaction-owning producer cannot encounter a compactor's gate or\n * permit: that compactor cannot acquire SQL until the producer commits.\n *\n * Reading floors under a permit would invert the batch's order: a new\n * producer waits on the batch's connection while the batch waits on its\n * permit. Moving batch permits before the transaction would instead\n * block even readless admission from inside an enclosing transaction.\n * Keep floor reads outside permits and collision reads inside the\n * writer transaction. `ensureFloors` documents cache lifetime, including\n * the quiescent truncation contract that permits floor invalidation.\n */\n const admitFromIndex = (prepared: Prepared): Result.Result<EmitReceipt | undefined, JournalError> => {\n const { validated } = prepared\n const sourceSeq = validated.sourceSeq\n if (sourceSeq === undefined) return Result.succeed(undefined)\n if (\n !Number.isSafeInteger(sourceSeq) ||\n sourceSeq < 0 ||\n sourceSeq === Number.MAX_SAFE_INTEGER\n ) {\n return Result.fail(\n error(\"invalid_event\", \"journal sequence is outside the allocatable safe integer range\")\n )\n }\n const cached = state.sourceEvents.get(sourceEventKey(validated.runId, validated.sourceId, sourceSeq))\n return cached === undefined ? Result.succeed(undefined) : compareSourceEvent(prepared, sourceSeq, cached)\n }\n\n /**\n * The in-memory half of a lossy admission: the identity check, the\n * allocation, and the queue offer. It runs under the run permit and\n * performs no I/O there; `admitFromIndex` documents the lock order that\n * keeps.\n */\n const admitQueued = (\n prepared: Prepared,\n floors: { readonly seq: number; readonly sourceSeq: number },\n emittedAtMs: number\n ): Effect.Effect<EmitReceipt, JournalError> =>\n Effect.suspend(() => {\n // Preparation precedes the floor read and admission waits. Check\n // closure and the identity again only after acquiring the permit,\n // before allocating or returning a cached duplicate.\n if (state.status !== \"open\") {\n return Effect.fail(error(\"journal_closed\", \"journal is closed\"))\n }\n return Effect.flatMap(\n Effect.fromResult(admitFromIndex(prepared)),\n (indexed) =>\n indexed !== undefined\n ? Effect.succeed(indexed)\n : allocation.withPermit(Effect.fromResult(\n Result.gen(function*() {\n const { metaJson, payloadJson, validated } = prepared\n const key = sourceKey(validated.runId, validated.sourceId)\n const nextSourceSeq = Math.max(\n floors.sourceSeq,\n state.sourceSequences.get(key) ?? 0\n )\n // An explicit producer sequence was validated by\n // `admitFromIndex`, and an implicit one is the floor\n // `ensureFloors` already proved to be a non-negative\n // safe integer. Only exhaustion is left: the allocator\n // cannot advance past MAX_SAFE_INTEGER, and neither can\n // the identity that follows it.\n const sourceSeq: SourceSeq = validated.sourceSeq ?? (nextSourceSeq as SourceSeq)\n if (sourceSeq === Number.MAX_SAFE_INTEGER) {\n return yield* Result.fail(\n error(\n \"invalid_event\",\n \"journal sequence is outside the allocatable safe integer range\"\n )\n )\n }\n const nextSeq = Math.max(\n floors.seq,\n state.sequences.get(validated.runId) ?? 0\n )\n if (nextSeq === Number.MAX_SAFE_INTEGER) {\n return yield* Result.fail(\n error(\n \"invalid_event\",\n \"journal sequence is outside the allocatable safe integer range\"\n )\n )\n }\n const seq = nextSeq as Seq\n raiseSequenceFloor(validated.runId, seq)\n state.sourceSequences.set(key, Math.max(nextSourceSeq, sourceSeq + 1))\n\n const queued: QueuedEntry = {\n runId: validated.runId,\n seq,\n eventId: makeEventId(validated.runId, validated.sourceId, sourceSeq),\n sourceId: validated.sourceId,\n sourceSeq,\n emittedAtMs,\n eventType: validated.eventType,\n payloadJson,\n metaJson,\n dedupe: validated.dedupe ?? \"content\"\n }\n let evicted: QueuedEntry | undefined\n if (Queue.sizeUnsafe(queue) >= options.capacity && options.overflow === \"drop-oldest\") {\n const exit = Queue.takeUnsafe(queue)\n /* v8 ignore next -- size and take run synchronously while the journal and queue are open */\n if (exit === undefined || !Exit.isSuccess(exit)) {\n return yield* Result.fail(\n error(\"journal_closed\", \"journal admission queue is unavailable\")\n )\n }\n evicted = exit.value\n const evictedIdentity = sourceEventKey(\n evicted.runId,\n evicted.sourceId,\n evicted.sourceSeq\n )\n state.sourceEvents.delete(evictedIdentity)\n state.pending = Math.max(0, state.pending - 1)\n settleRunPending([evicted])\n }\n const accepted = Queue.offerUnsafe(queue, queued)\n if (!accepted) {\n if (options.overflow === \"reject\") {\n return yield* Result.fail(\n error(\"queue_overflow\", \"journal admission queue is full\")\n )\n }\n return {\n _tag: \"Dropped\",\n seq,\n sourceSeq,\n policy: \"drop-newest\"\n } satisfies EmitReceipt\n }\n\n retain(sourceEventKey(validated.runId, validated.sourceId, sourceSeq), {\n seq,\n eventType: validated.eventType,\n payloadJson,\n metaJson,\n status: \"pending\"\n })\n state.pending += 1\n admitRunPending(queued)\n if (evicted !== undefined) {\n return {\n _tag: \"Accepted\",\n seq,\n sourceSeq,\n evicted: {\n policy: \"drop-oldest\",\n count: 1\n }\n } satisfies EmitReceipt\n }\n return {\n _tag: \"Accepted\",\n seq,\n sourceSeq\n } satisfies EmitReceipt\n })\n ))\n )\n })\n\n const queuedEmit: Service[\"emitLossy\"] = Effect.fn(\"Journal.emitLossy\")((input: Input) =>\n Effect.annotateCurrentSpan({\n runId: input.runId,\n sourceId: input.sourceId,\n eventType: input.eventType\n }).pipe(\n Effect.andThen(Clock.currentTimeMillis.pipe(Effect.map(Math.floor))),\n Effect.flatMap((emittedAtMs) =>\n Effect.flatMap(\n withRunAdmission(\n input.runId,\n Effect.suspend(() =>\n Effect.fromResult(Result.gen(function*() {\n const prepared = yield* prepare(input, emittedAtMs)\n const indexed = yield* admitFromIndex(prepared)\n return { prepared, indexed }\n }))\n )\n ),\n ({ prepared, indexed }) =>\n // A cached duplicate needs neither allocation floor, including\n // after startup when the identity index is warm but floors are\n // cold. On a miss, release the permit before reading SQL, then\n // recheck identity and allocation under a fresh admission.\n indexed !== undefined ? Effect.succeed(indexed) : Effect.flatMap(\n ensureFloors(prepared.validated),\n (floors) => withRunAdmission(prepared.validated.runId, admitQueued(prepared, floors, emittedAtMs))\n )\n )\n ),\n Effect.tap((receipt) => Metric.update(JournalMetrics.lossy[receipt._tag], 1))\n )\n )\n\n /**\n * The run's compaction floor: the largest checkpoint sequence whose\n * lower entries have been truncated, or `undefined` while the run has\n * never been compacted.\n */\n const compactionFloor = (runId: RunId): Effect.Effect<number | undefined, SqlError.SqlError> =>\n Effect.map(\n sql<{ readonly floor: number | null }>`\n SELECT MAX(seq) AS floor FROM flows_journal_checkpoints\n WHERE run_id = ${runId} AND compacted_at_ms IS NOT NULL\n `,\n (rows) => {\n const floor = rows[0]?.floor\n return floor === null || floor === undefined ? undefined : Number(floor)\n }\n )\n\n const readPage: Service[\"entries\"] = Effect.fn(\"Journal.entries\")((pageOptions) =>\n Effect.gen(function*() {\n // Snapshot the caller-owned list before the first suspension so its\n // validated bound is also the bound passed to the SQL client.\n const options = {\n ...pageOptions,\n ...(Array.isArray(pageOptions.eventTypes)\n ? { eventTypes: [...pageOptions.eventTypes] } :\n {})\n }\n yield* Effect.annotateCurrentSpan({\n runId: options.runId,\n limit: options.limit,\n ...(options.eventTypes === undefined ? {} : { eventTypes: options.eventTypes }),\n ...(options.after === undefined ? {} : { after: options.after })\n })\n // `EntriesOptions` already carries every one of these invariants: a\n // well-formed non-empty `runId`, a `Seq` cursor, and a `limit`\n // between 1 and `maxEntriesLimit`. Hand-checking them here let the\n // read boundary disagree with the write boundary, and it did: a\n // lone-surrogate run id was refused at `emit` and answered with an\n // empty page at `entries`.\n yield* Effect.fromResult(Result.mapError(\n decodeEntriesOptions(options),\n (cause) => error(\"invalid_event\", \"entries options violate the journal read contract\", cause)\n ))\n const after = options.after ?? -1\n // With several types SQLite can prefer the run/sequence index to\n // avoid sorting, scanning every unrelated event instead. Require\n // the journal-owned type index; only matching rows may be sorted.\n const rows = yield* (options.eventTypes === undefined ?\n sql<JournalRow>`\n SELECT run_id, seq, event_id, source_id, source_seq, emitted_at_ms,\n event_type, payload_json, meta_json\n FROM flows_journal_events\n WHERE run_id = ${options.runId} AND seq > ${after}\n ORDER BY seq ASC\n LIMIT ${options.limit + 1}\n ` :\n sql<JournalRow>`\n SELECT run_id, seq, event_id, source_id, source_seq, emitted_at_ms,\n event_type, payload_json, meta_json\n FROM flows_journal_events ${Dialect.indexHint(sql, \"flows_journal_events_run_event_type_idx\")}\n WHERE run_id = ${options.runId} AND ${sql.in(\"event_type\", options.eventTypes)} AND seq > ${after}\n ORDER BY seq ASC\n LIMIT ${options.limit + 1}\n `).pipe(\n Effect.mapError((cause) => error(\"read_failed\", \"durable journal read failed\", cause))\n )\n // The floor is read AFTER the page. Truncation and the floor\n // advance commit atomically, so any deletion that could have\n // shortened the page above is visible in this floor read, and a\n // cursor at or above `floor - 1` therefore read a complete page.\n // The converse order would let a compaction commit between the two\n // reads and hand back a silently gapped history.\n const floor = yield* compactionFloor(options.runId).pipe(\n Effect.mapError((cause) => error(\"read_failed\", \"durable journal read failed\", cause))\n )\n if (floor !== undefined && after < floor - 1) {\n return yield* Effect.fail(\n new JournalError({\n code: \"compacted\",\n message: `run ${options.runId} is compacted through sequence ${floor}; resync from its checkpoint`,\n checkpointSeq: floor as Seq\n })\n )\n }\n const page = rows.slice(0, options.limit)\n const entries = yield* Effect.forEach(page, decodeRow)\n return {\n entries,\n hasMore: rows.length > options.limit\n } satisfies EntriesPage\n })\n )\n\n const subscribeRun = (runId: RunId) =>\n Effect.gen(function*() {\n const wake = yield* PubSub.sliding<void>(1)\n const subscription = yield* PubSub.subscribe(wake)\n yield* Effect.acquireRelease(\n Effect.sync(() => {\n const subscribers = wakes.get(runId) ?? new Set()\n subscribers.add(wake)\n wakes.set(runId, subscribers)\n }),\n () =>\n Effect.sync(() => {\n const subscribers = wakes.get(runId)\n subscribers?.delete(wake)\n if (subscribers?.size === 0) {\n wakes.delete(runId)\n }\n }).pipe(Effect.andThen(PubSub.shutdown(wake)))\n )\n return subscription\n })\n\n const stream = (streamOptions: StreamOptions): Stream.Stream<Entry, JournalError> =>\n Stream.unwrap(\n Effect.fn(\"Journal.stream\")(function*() {\n yield* Effect.annotateCurrentSpan({\n runId: streamOptions.runId,\n ...(streamOptions.afterSequence === undefined ? {} : { afterSequence: streamOptions.afterSequence })\n })\n yield* Effect.fromResult(Result.mapError(\n decodeStreamOptions(streamOptions),\n (cause) => error(\"invalid_event\", \"stream options violate the journal read contract\", cause)\n ))\n const wake = yield* subscribeRun(streamOptions.runId)\n // The cursor lives in a registered box for the stream's lifetime\n // so `compact` can see how far every live follower has read.\n const reader = { cursor: streamOptions.afterSequence ?? -1 }\n yield* Effect.acquireRelease(\n Effect.sync(() => {\n const registered = readers.get(streamOptions.runId) ?? new Set()\n registered.add(reader)\n readers.set(streamOptions.runId, registered)\n }),\n () =>\n Effect.sync(() => {\n const registered = readers.get(streamOptions.runId)\n registered?.delete(reader)\n if (registered?.size === 0) {\n readers.delete(streamOptions.runId)\n }\n })\n )\n // A live consumer is told about losses that happen while it is\n // following, and only about those: a loss it never overlapped is\n // already spent by the time it subscribes.\n const subscribedLossEpoch = state.lossEpoch\n const readPages = (initialCursor: number): Stream.Stream<Entry, JournalError> =>\n Stream.paginate(initialCursor, (cursor) =>\n Effect.suspend(() =>\n state.sinkFailure !== undefined && state.lossEpoch > subscribedLossEpoch\n ? Effect.fail(state.sinkFailure)\n : readPage({\n runId: streamOptions.runId,\n ...(cursor < 0 ? {} : { after: cursor as Seq }),\n limit: readPageSize\n })\n ).pipe(\n Effect.map((page) => {\n const last = page.entries.at(-1)\n if (last !== undefined) {\n // Both channels append above the committed tail, so no\n // pending reservation can later commit below this cursor.\n reader.cursor = last.seq\n }\n return [\n page.entries,\n page.hasMore ? Option.some(reader.cursor) : Option.none<number>()\n ] as const\n })\n ))\n const historical = readPages(reader.cursor)\n // PubSub is only a local fast path. Another journal process cannot\n // publish into it, so a bounded poll must recheck both the durable\n // tail and the compaction floor while the follower is otherwise idle.\n // One raced wake keeps the live tail in the consumer fiber instead\n // of merging two background streams, which also preserves a plain\n // interruption cause when the consumer is cancelled.\n const live = Stream.fromEffectRepeat(\n Effect.raceFirst(PubSub.take(wake), Effect.sleep(\"1 second\"))\n ).pipe(Stream.flatMap(() =>\n readPages(reader.cursor)\n ))\n return Stream.concat(historical, live)\n })()\n )\n\n /**\n * The owner fence for the fenced append, for checkpoint, and for\n * compaction: the injected strategy's commit-time admission (R3),\n * evaluated inside the caller's write transaction. `DurableWriter`\n * serializes write transactions, so no reclaim can commit between the\n * guard and the statements that run beside it in the same transaction.\n * A strategy that cannot answer is a sink failure, never a lost fence;\n * its cause is preserved so the writer's retry classification still sees\n * a transient conflict through the wrapper.\n */\n const fenceGuard = (\n runId: RunId,\n owner: OwnerId\n ): Effect.Effect<void, JournalError> =>\n consensus.guard(runId, owner).pipe(\n Effect.mapError((cause) =>\n cause.code === \"fence_lost\"\n ? error(\"fence_lost\", cause.message)\n : error(\"sink_failed\", \"consensus guard failed\", cause)\n )\n )\n\n /**\n * Reads the row or compacted identity a duplicate emit collides with.\n * The insert guard in migration 0004 extends the event table's unique\n * constraints to identities retained by compaction. Tombstones return\n * only a receipt sequence and never produce a replayable entry.\n *\n * On the queued channel this runs only AFTER the insert, on the row that\n * insert's `ON CONFLICT DO NOTHING` actually refused: the unique index is\n * the admission decision there, so a batch of entries that collide with\n * nothing costs no lookups at all, and the one a collision costs happens\n * inside the writer's own transaction. See {@link insertOne} for why the\n * durable channel still asks first.\n *\n * The lookup covers BOTH unique constraints the insert can conflict on:\n * `UNIQUE (event_id)` and `UNIQUE (run_id, source_id, source_seq)`. It is\n * tempting to keep only the first, because `makeEventId` is injective in\n * exactly that triple, but that argument holds only for rows this\n * journal minted. `TimeTravelStore.createFork` copies a parent's rows\n * under the child's `run_id` with `'fork:' || run_id || ':' || event_id`,\n * so a forked run carries rows whose triple is live and whose event id it\n * will never mint. Looking those up by event id alone finds nothing, and\n * the caller reports the resulting empty insert as `fence_lost`, a\n * healthy fork failing with \"someone else owns this run\".\n */\n const selectExisting = (\n queued: QueuedEntry\n ): Effect.Effect<Commit | undefined, JournalError | SqlError.SqlError> =>\n Effect.gen(function*() {\n const existing = yield* sql<JournalRow & { readonly content_hash: string | null }>`\n SELECT run_id, seq, event_id, source_id, source_seq, emitted_at_ms,\n event_type, payload_json, meta_json, NULL AS content_hash\n FROM flows_journal_events\n WHERE event_id = ${queued.eventId}\n OR (\n run_id = ${queued.runId}\n AND source_id = ${queued.sourceId}\n AND source_seq = ${queued.sourceSeq}\n )\n UNION ALL\n SELECT run_id, seq, event_id, source_id, source_seq, 0 AS emitted_at_ms,\n '' AS event_type, '' AS payload_json, '' AS meta_json, content_hash\n FROM flows_journal_dedup\n WHERE event_id = ${queued.eventId}\n OR (\n run_id = ${queued.runId}\n AND source_id = ${queued.sourceId}\n AND source_seq = ${queued.sourceSeq}\n )\n ORDER BY seq ASC\n LIMIT 1\n `\n if (existing.length === 0) {\n return undefined\n }\n const row = existing[0]!\n if (\n queued.dedupe !== \"identity\" && (\n row.content_hash === null\n ? row.event_type !== queued.eventType ||\n row.payload_json !== queued.payloadJson ||\n row.meta_json !== queued.metaJson\n : row.content_hash !==\n (yield* contentFingerprint(queued.eventType, queued.payloadJson, queued.metaJson))\n )\n ) {\n return yield* Effect.fail(\n error(\n \"idempotency_conflict\",\n `source event ${queued.sourceId}:${queued.sourceSeq} for run ${queued.runId} was reused with different content`\n )\n )\n }\n return {\n entry: row.content_hash === null ? yield* decodeRow(row) : { seq: Number(row.seq) as Seq },\n inserted: false\n }\n })\n\n /**\n * When the fence is `Owned` the insert is admitted by the consensus\n * strategy's `guard` in the same serialized write transaction, following\n * Temporal's shard `rangeID` check\n * (`service/history/shard/context_impl.go`, `renewRangeLocked`): a\n * zombie owner whose run was reclaimed cannot append, and fails with\n * `fence_lost` before any row is written.\n *\n * The fence outranks dedup. The guard runs BEFORE the INSERT, so a\n * fenced insert consults the dedup index only for an owner the strategy\n * has confirmed; Temporal conditions every request on the `rangeID`\n * before anything else. Answering a zombie's resubmission from the dedup\n * index would launder its lost fence into a `Duplicate` receipt for work\n * the live owner committed; a confirmed owner's conflict, by contrast,\n * is a genuine duplicate (its own earlier commit, or a forked run's\n * copied row).\n *\n * The queued channel is decided by the constraint alone. The ownerless\n * DURABLE path keeps its up-front lookup, and the reason is measured\n * rather than aesthetic: with two connections open on one file, removing\n * it left `emitDurableUnfenced` transactions overlapping, so one of them\n * blocked in SQLite's synchronous busy wait until the driver's\n * `busy_timeout` expired. The two-connection case in `JournalDurable`\n * went from 17 ms and no write retries to 5.4 s and one, three runs each\n * way. That is a read this channel is buying scheduling room with, and\n * it is affordable here: a durable emit already reads its allocation\n * floor in the same transaction, and its caller is by definition not\n * flushing from inside somebody else's.\n */\n const insertOne = (\n queued: QueuedEntry,\n fence: Fence,\n enforceCompactionFloor = false\n ): Effect.Effect<Commit, JournalError | SqlError.SqlError> =>\n Effect.gen(function*() {\n if (fence._tag === \"Owned\") {\n yield* fenceGuard(queued.runId, fence.owner)\n } else if (!enforceCompactionFloor) {\n const duplicate = yield* selectExisting(queued)\n if (duplicate !== undefined) {\n return duplicate\n }\n }\n // Admission reservations are provisional. Allocate above the durable\n // tail in this transaction so a queued entry can never commit behind\n // a reader's cursor, even when another connection overtook it.\n const insert = enforceCompactionFloor\n ? sql<JournalRow>`\n INSERT INTO flows_journal_events (\n run_id, seq, event_id, source_id, source_seq, emitted_at_ms,\n event_type, payload_json, meta_json\n )\n SELECT\n ${queued.runId},\n (SELECT ${Dialect.greatest(sql)}(${queued.seq}, COALESCE(MAX(seq), -1) + 1)\n FROM flows_journal_events WHERE run_id = ${queued.runId}),\n ${queued.eventId},\n ${queued.sourceId},\n ${queued.sourceSeq},\n ${queued.emittedAtMs},\n ${queued.eventType},\n ${queued.payloadJson},\n ${queued.metaJson}\n WHERE NOT EXISTS (\n SELECT 1 FROM flows_journal_checkpoints\n WHERE run_id = ${queued.runId}\n AND compacted_at_ms IS NOT NULL\n AND seq >= ${queued.seq}\n ) AND NOT EXISTS (\n SELECT 1 FROM flows_journal_events\n WHERE run_id = ${queued.runId} AND seq >= ${Number.MAX_SAFE_INTEGER - 1}\n )\n ON CONFLICT DO NOTHING\n RETURNING run_id, seq, event_id, source_id, source_seq, emitted_at_ms,\n event_type, payload_json, meta_json\n `\n : sql<JournalRow>`\n INSERT INTO flows_journal_events (\n run_id, seq, event_id, source_id, source_seq, emitted_at_ms,\n event_type, payload_json, meta_json\n ) VALUES (\n ${queued.runId},\n ${queued.seq},\n ${queued.eventId},\n ${queued.sourceId},\n ${queued.sourceSeq},\n ${queued.emittedAtMs},\n ${queued.eventType},\n ${queued.payloadJson},\n ${queued.metaJson}\n )\n ON CONFLICT DO NOTHING\n RETURNING run_id, seq, event_id, source_id, source_seq, emitted_at_ms,\n event_type, payload_json, meta_json\n `\n const inserted = yield* insert\n if (inserted.length > 0) {\n return {\n entry: yield* decodeRow(inserted[0]!),\n inserted: true\n }\n }\n // The INSERT produced no row, so a unique constraint fired: the\n // guard above already confirmed a fenced owner, so this collision\n // is a genuine duplicate, never a laundered lost fence.\n const racedDuplicate = yield* selectExisting(queued)\n if (racedDuplicate !== undefined) {\n return racedDuplicate\n }\n // The insert produced no row and names no committed identity. Before\n // reporting sequence exhaustion, ask whether compaction moved the\n // floor above this reservation: that is a drop, and\n // the caller needs the floor to resync from. A durable write cannot\n // reach this case, because it allocates above the surviving\n // checkpoint row, so the read costs nothing on that path.\n {\n const floor = yield* compactionFloor(queued.runId)\n if (floor !== undefined && queued.seq <= floor) {\n return yield* Effect.fail(\n new JournalError({\n code: \"compacted\",\n message:\n `queued sequence ${queued.seq} for run ${queued.runId} was dropped below compaction floor ${floor}`,\n checkpointSeq: floor as Seq\n })\n )\n }\n }\n return yield* Effect.fail(\n error(\n \"invalid_event\",\n \"journal sequence is outside the allocatable safe integer range\"\n )\n )\n })\n\n /** Shared transactional insert path; the caller already owns SQL. */\n const insertBatch = (batch: ReadonlyArray<QueuedEntry>): Effect.Effect<BatchOutcome, SqlError.SqlError> =>\n Effect.gen(function*() {\n const results = yield* Effect.forEach(\n batch,\n (queued) => Effect.map(Effect.result(insertOne(queued, unfenced, true)), (result) => ({ queued, result }))\n )\n const commits: Array<SettledCommit> = []\n const losses: Array<EntryLoss> = []\n for (const settled of results) {\n if (Result.isSuccess(settled.result)) {\n commits.push({ queued: settled.queued, commit: settled.result.success })\n } else if (isJournalError(settled.result.failure)) {\n losses.push({ queued: settled.queued, cause: settled.result.failure })\n } else {\n return yield* Effect.fail(settled.result.failure)\n }\n }\n return { commits, losses }\n })\n\n // Transaction first, run permits second. Admissions read floors before\n // taking a permit; compaction also acquires SQL before its run locks.\n // No holder of a run permit or closed gate can wait on this batch's\n // connection (see `admitFromIndex` and `withCompactionBarrier`).\n const persistBatch = (\n batch: ReadonlyArray<QueuedEntry>\n ): Effect.Effect<BatchOutcome, JournalError> =>\n writer.write(withRunPermits(\n batch.map((queued) => queued.runId),\n insertBatch(batch)\n )).pipe(\n // Every per-entry `JournalError` is settled inside the transaction\n // above, so the only failure that escapes is the transaction itself:\n // a database outage, which is what `sink_failed` names.\n Effect.mapError((cause) => error(\"sink_failed\", \"journal sink failed\", cause))\n )\n\n const publish = (commits: ReadonlyArray<Commit>): Effect.Effect<void> =>\n Effect.forEach(\n commits,\n (commit) => {\n if (!commit.inserted) {\n return Effect.void\n }\n return PubSub.publish(changes, freezePublished(commit.entry)).pipe(\n Effect.andThen(\n Effect.forEach(\n wakes.get(commit.entry.runId) ?? [],\n (wake) => PubSub.publish(wake, undefined),\n { discard: true }\n )\n ),\n Effect.asVoid\n )\n },\n { discard: true }\n )\n\n const rememberCommitted = (queued: QueuedEntry, seq: Seq): void => {\n retain(sourceEventKey(queued.runId, queued.sourceId, queued.sourceSeq), {\n seq,\n eventType: queued.eventType,\n payloadJson: queued.payloadJson,\n metaJson: queued.metaJson,\n status: \"committed\"\n })\n raiseSequenceFloor(queued.runId, seq)\n raiseSourceSequenceFloor(queued.runId, queued.sourceId, queued.sourceSeq)\n }\n\n /**\n * Reads the durable allocation floor for a run (or a producer). Durable\n * allocation calls this inside its transaction; lossy admission calls\n * it before taking any run permit.\n *\n * The pinned Node SQLite driver begins IMMEDIATE transactions, acquiring\n * the writer lock before this floor read. A caller-supplied SQL client\n * may instead use DEFERRED transactions, whose lock upgrade can fail\n * with SQLITE_BUSY_SNAPSHOT. In either case DurableWriter retries the\n * whole transaction, floor read included, against committed state.\n * The cross-connection allocation invariant is exercised by\n * `packages/smithers/flows/journal/test/JournalDurable.test.ts` (\"emitDurable never\n * collides when two connections write one run concurrently\").\n *\n * Governing design: `packages/smithers/flows/journal/docs/concepts/two-channels.md`.\n */\n const nextDurable = (\n column: \"seq\" | \"source_seq\",\n runId: RunId,\n sourceId: SourceId | undefined\n ): Effect.Effect<number, SqlError.SqlError> =>\n Effect.map(\n column === \"seq\"\n ? sql<{ readonly next: number | null }>`\n SELECT MAX(seq) + 1 AS next FROM flows_journal_events WHERE run_id = ${runId}\n `\n : sql<{ readonly next: number | null }>`\n SELECT MAX(source_seq) + 1 AS next FROM (\n SELECT MAX(source_seq) AS source_seq FROM flows_journal_events\n WHERE run_id = ${runId} AND source_id = ${sourceId!}\n UNION ALL\n SELECT MAX(source_seq) AS source_seq FROM flows_journal_dedup\n WHERE run_id = ${runId} AND source_id = ${sourceId!}\n )\n `,\n (rows) => Number(rows[0]?.next ?? 0)\n )\n\n /**\n * Reads a run's durable allocation floors when the in-process cache has\n * not observed them yet.\n *\n * `emitLossy` allocates from the index alone, it queues rather than\n * writing, so it cannot read the database mid-allocation, which is why\n * the floors used to be seeded for every run at construction. Reading\n * them on first use instead keeps the index proportional to the runs this\n * process touches rather than to total history, and the durable read is\n * the same `MAX(...) + 1` the seed computed.\n *\n * This function never mutates the cache. Its SQL reads deliberately run\n * without the allocator and without the run permit; the caller later\n * takes the run permit and then the short allocator permit, re-checks\n * the monotonic cache, and reserves both sequences in one synchronous\n * step. A floor read outside the permit is a lower bound: every\n * in-process writer raises the cache at allocation time, and the only\n * cache invalidation is `JournalGeneration.forget`, whose contract\n * requires quiescent producers and flushed admissions, so it cannot\n * overlap this read-to-reservation interval. Retention evicts committed\n * identities only; run retirement and compaction leave allocation floors\n * intact. Compaction also preserves the checkpoint entry and producer\n * dedup rows for cold reads. Reading under the permit is what deadlocked\n * against the batch writer; see `admitFromIndex`.\n *\n * A producer that supplies its own `sourceSeq` allocates nothing from\n * the producer floor, so that floor is not read for it. This is what\n * makes the explicit path readless end to end once the run's own `seq`\n * floor is known, which it is from the first entry any producer writes\n * for the run.\n */\n const ensureFloors = (\n input: Input\n ): Effect.Effect<{ readonly seq: number; readonly sourceSeq: number }, JournalError> =>\n Effect.suspend(() => {\n const runId = input.runId\n const key = sourceKey(runId, input.sourceId)\n const seq = state.sequences.get(runId)\n const sourceSeq = input.sourceSeq === undefined ? state.sourceSequences.get(key) : 0\n if (seq !== undefined && sourceSeq !== undefined) {\n return Effect.succeed({ seq, sourceSeq })\n }\n return Effect.all({\n seq: seq === undefined ? nextDurable(\"seq\", runId, undefined) : Effect.succeed(seq),\n sourceSeq: sourceSeq === undefined\n ? nextDurable(\"source_seq\", runId, input.sourceId)\n : Effect.succeed(sourceSeq)\n }).pipe(\n Effect.mapError((cause) => error(\"sink_failed\", \"could not read journal allocation floor\", cause)),\n Effect.flatMap((floors) => {\n if (\n !Number.isSafeInteger(floors.seq) ||\n floors.seq < 0 ||\n !Number.isSafeInteger(floors.sourceSeq) ||\n floors.sourceSeq < 0\n ) {\n return Effect.fail(\n error(\"invalid_event\", \"journal sequence is outside the allocatable safe integer range\")\n )\n }\n return Effect.succeed(floors)\n })\n )\n })\n\n /**\n * Records a committed entry in the in-process index and publishes it,\n * immediately outside a transaction, or deferred to its owning writer.\n * A raw SQL transaction has no managed commit boundary: skip this optional\n * publication rather than exposing uncommitted data. Database replay stays\n * authoritative, including for tail subscribers.\n */\n const settleCommit = (\n queued: QueuedEntry,\n commit: Commit,\n restoreMaintenance: (effect: Effect.Effect<void>) => Effect.Effect<void>\n ): Effect.Effect<Effect.Effect<void>> =>\n Effect.gen(function*() {\n const mandatory = Effect.sync(() => rememberCommitted(queued, commit.entry.seq)).pipe(\n Effect.andThen(publish([commit]))\n )\n // Restore the durable caller's policy, not unconditional interruption.\n // A cancellation finalizer may journal before releasing resources;\n // even interruptible(void) here re-delivers its pending interruption\n // after COMMIT and abandons that cleanup. Ordinary callers still make\n // a slow capture interruptible when the writer publishes after COMMIT.\n const maintenance = restoreMaintenance(noteCommitted(queued.runId, commit.inserted ? 1 : 0))\n const enclosing = yield* Effect.serviceOption(sql.transactionService)\n if (Option.isNone(enclosing)) {\n yield* mandatory\n return maintenance\n }\n yield* afterCommit(mandatory.pipe(Effect.andThen(maintenance)), sql)\n return Effect.void\n })\n\n /**\n * Opens (or joins) the write transaction that keeps the logical WAL\n * atomic with the executable state it describes.\n *\n * The shared writer owns publication across retries, nested savepoint\n * rollbacks, and transactions opened by other stores on the same client.\n */\n const transact: Service[\"transact\"] = <A, E, R>(\n effect: Effect.Effect<A, E, R>\n ): Effect.Effect<A, E | JournalError, R> =>\n writer.write(effect).pipe(\n Effect.catchIf(\n (cause): cause is DatabaseError => cause instanceof DatabaseError,\n (cause) => Effect.fail(error(\"sink_failed\", \"journal transaction failed\", cause))\n )\n )\n\n const writeDurable = (\n input: Input,\n fence: Fence\n ): Effect.Effect<DurableReceipt, JournalError> =>\n Effect.uninterruptibleMask((restoreMaintenance) =>\n restoreMaintenance(Effect.gen(function*() {\n yield* Effect.annotateCurrentSpan({\n runId: input.runId,\n sourceId: input.sourceId,\n eventType: input.eventType\n })\n const emittedAtMs = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor))\n const prepared = yield* Effect.fromResult(prepare(input, emittedAtMs))\n const committed = yield* Effect.gen(function*() {\n const { metaJson, payloadJson, validated } = prepared\n return yield* Effect.uninterruptibleMask((restore) =>\n restore(writer.write(withActiveRunWrite(\n prepared.validated.runId,\n Effect.gen(function*() {\n // Read only for a producer that allocates from this floor. A\n // supplied sequence is not allocated, so reading the floor\n // for it costs a query whose answer is discarded.\n const durableSourceSeq = validated.sourceSeq === undefined\n ? yield* nextDurable(\"source_seq\", validated.runId, validated.sourceId)\n : 0\n const durableSeq = yield* nextDurable(\"seq\", validated.runId, undefined)\n const reserved = yield* allocation.withPermit(Effect.fromResult(Result.gen(function*() {\n const key = sourceKey(validated.runId, validated.sourceId)\n const sourceSeq: SourceSeq = validated.sourceSeq ??\n (Math.max(\n durableSourceSeq,\n state.sourceSequences.get(key) ?? 0\n ) as SourceSeq)\n if (\n !Number.isSafeInteger(sourceSeq) ||\n sourceSeq < 0 ||\n sourceSeq === Number.MAX_SAFE_INTEGER\n ) {\n return yield* Result.fail(\n error(\"invalid_event\", \"journal sequence is outside the allocatable safe integer range\")\n )\n }\n const seq = Math.max(\n durableSeq,\n state.sequences.get(validated.runId) ?? 0\n ) as Seq\n if (!Number.isSafeInteger(seq) || seq === Number.MAX_SAFE_INTEGER) {\n return yield* Result.fail(\n error(\"invalid_event\", \"journal sequence is outside the allocatable safe integer range\")\n )\n }\n // Claim the seq NOW, not at commit: a concurrent `emitLossy`\n // allocates from this floor alone, and `settleCommit` parks\n // the commit-time raise until the outermost COMMIT.\n // Re-entering the transaction body is idempotent because the\n // floor only rises. An abandoned attempt leaves the number\n // unused, which is a gap: allocation is `MAX(seq) + 1` and\n // replay is `ORDER BY seq`, so neither reads a gap as anything.\n raiseSequenceFloor(validated.runId, seq)\n // Claim the producer sequence at the same allocation seam.\n // Without this, a lossy emit from the same producer can read\n // the pre-transaction source floor and reuse this identity\n // while an enclosing `transact` is still open.\n raiseSourceSequenceFloor(validated.runId, validated.sourceId, sourceSeq)\n return { seq, sourceSeq }\n })))\n const { seq, sourceSeq } = reserved\n const queued: QueuedEntry = {\n runId: validated.runId,\n seq,\n eventId: makeEventId(validated.runId, validated.sourceId, sourceSeq),\n sourceId: validated.sourceId,\n sourceSeq,\n emittedAtMs,\n eventType: validated.eventType,\n payloadJson,\n metaJson,\n dedupe: validated.dedupe ?? \"content\"\n }\n const commit = yield* insertOne(queued, fence)\n return { commit, queued, sourceSeq }\n })\n ))).pipe(\n /**\n * `writer.write` is a retrying transaction: its body replays on\n * `SQLITE_BUSY(_SNAPSHOT)` and can still abort at COMMIT after the\n * body succeeded. Cache mutation and publication therefore happen\n * strictly after the transaction returns, so subscribers never\n * observe a rolled-back entry and a replayed body never publishes\n * twice. Mirrors the queued path, which publishes in a `.tap`\n * outside `persistBatch`. Only the transaction is restored: an\n * interruption that lands after it returns waits for the index\n * update and publication, so a committed row always reaches\n * `changes`.\n *\n * Under `transact` \"after the transaction returns\" is not yet\n * \"after COMMIT\": this write is a savepoint of the caller's\n * transaction, so `settleCommit` parks both effects until the\n * outermost transaction commits. The active-write reference\n * is released before that outer commit, which lets automatic\n * compaction drain the run before its maintenance transaction.\n */\n Effect.flatMap((written) =>\n Effect.gen(function*() {\n const maintenance = yield* settleCommit(written.queued, written.commit, restoreMaintenance)\n const receipt: DurableReceipt = written.commit.inserted\n ? { _tag: \"Accepted\", seq: written.commit.entry.seq, sourceSeq: written.sourceSeq }\n : {\n _tag: \"Duplicate\",\n seq: written.commit.entry.seq,\n sourceSeq: written.sourceSeq,\n status: \"committed\"\n }\n yield* Metric.update(JournalMetrics.durable[receipt._tag], 1)\n return { maintenance, receipt }\n })\n )\n )\n )\n }).pipe(\n Effect.mapError((cause) =>\n isJournalError(cause) ? cause : error(\"sink_failed\", \"durable journal write failed\", cause)\n )\n )\n yield* committed.maintenance\n return committed.receipt\n }))\n )\n\n const emitDurable: Service[\"emitDurable\"] = Effect.fn(\"Journal.emitDurable\")((\n input: Input,\n owner: OwnerId\n ) =>\n Effect.flatMap(\n Effect.fromResult(requireFence(owner, \"emitDurable\")),\n (fence) => writeDurable(input, fence)\n )\n )\n\n const emitDurableUnfenced: Service[\"emitDurableUnfenced\"] = Effect.fn(\"Journal.emitDurableUnfenced\")((\n input: Input\n ) => writeDurable(input, unfenced))\n\n const emitLossy: Service[\"emitLossy\"] = queuedEmit\n\n const checkpointInternal = (\n checkpointOptions: CheckpointOptions,\n fence: Fence\n ): Effect.Effect<Checkpoint, JournalError> =>\n Effect.gen(function*() {\n yield* Effect.annotateCurrentSpan({\n runId: checkpointOptions.runId,\n seq: checkpointOptions.seq\n })\n yield* Effect.fromResult(Result.mapError(\n decodeCheckpointOptions(checkpointOptions),\n (cause) => error(\"invalid_event\", \"checkpoint options violate the journal contract\", cause)\n ))\n // The state round-trips verbatim: it is replay input, so redaction\n // deliberately does not apply, rewriting it would resume the run\n // with the wrong data. A secret that must not persist belongs in a\n // `Redacted` field of the caller's own state schema.\n const stateJson = yield* Effect.fromResult(encodeJson(checkpointOptions.state, \"state\"))\n const receiptState = yield* Schema.decodeUnknownEffect(UnknownFromJsonString)(stateJson).pipe(\n Effect.mapError(\n /* v8 ignore next -- encodeJson produced these valid JSON bytes immediately above */\n (cause) => error(\"decode_failed\", \"could not decode persisted checkpoint state\", cause)\n )\n )\n const createdAtMs = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor))\n return yield* writer.write(Effect.gen(function*() {\n if (fence._tag === \"Owned\") {\n yield* fenceGuard(checkpointOptions.runId, fence.owner)\n }\n // The target must be a committed entry: the surviving row is what\n // keeps the run's durable `MAX(seq)` allocation floor at or above\n // the compaction boundary, so a process restarted after\n // compaction can never re-allocate a truncated sequence.\n const target = yield* sql<{ readonly ok: number }>`\n SELECT 1 AS ok FROM flows_journal_events\n WHERE run_id = ${checkpointOptions.runId} AND seq = ${checkpointOptions.seq}\n `\n if (target.length === 0) {\n return yield* Effect.fail(error(\n \"checkpoint_invalid\",\n `checkpoint sequence ${checkpointOptions.seq} names no committed entry of run ${checkpointOptions.runId}`\n ))\n }\n const floor = yield* compactionFloor(checkpointOptions.runId)\n if (floor !== undefined && checkpointOptions.seq <= floor) {\n return yield* Effect.fail(\n new JournalError({\n code: \"checkpoint_invalid\",\n message: `run ${checkpointOptions.runId} is already compacted through sequence ${floor}`,\n checkpointSeq: floor as Seq\n })\n )\n }\n yield* sql`\n INSERT INTO flows_journal_checkpoints (run_id, seq, state_json, created_at_ms)\n VALUES (${checkpointOptions.runId}, ${checkpointOptions.seq}, ${stateJson}, ${createdAtMs})\n ON CONFLICT (run_id, seq) DO UPDATE SET\n state_json = excluded.state_json,\n created_at_ms = excluded.created_at_ms\n `\n return new Checkpoint({\n runId: checkpointOptions.runId,\n seq: checkpointOptions.seq,\n state: receiptState,\n createdAtMs,\n compactedAtMs: null\n })\n })).pipe(\n Effect.mapError((cause) =>\n isJournalError(cause) ? cause : error(\"sink_failed\", \"durable checkpoint write failed\", cause)\n )\n )\n })\n\n const checkpoint: Service[\"checkpoint\"] = Effect.fn(\"Journal.checkpoint\")((\n checkpointOptions: CheckpointOptions,\n owner: OwnerId\n ) =>\n Effect.flatMap(\n Effect.fromResult(requireFence(owner, \"checkpoint\")),\n (fence) => checkpointInternal(checkpointOptions, fence)\n )\n )\n\n const latestCheckpoint: Service[\"latestCheckpoint\"] = Effect.fn(\"Journal.latestCheckpoint\")((runId: RunId) =>\n Effect.gen(function*() {\n yield* Effect.annotateCurrentSpan({ runId })\n yield* Effect.fromResult(Result.mapError(\n decodeRunId(runId),\n (cause) => error(\"invalid_event\", \"runId violates the journal identifier contract\", cause)\n ))\n const rows = yield* sql<CheckpointRow>`\n SELECT run_id, seq, state_json, created_at_ms, compacted_at_ms\n FROM flows_journal_checkpoints\n WHERE run_id = ${runId}\n ORDER BY seq DESC\n LIMIT 1\n `.pipe(Effect.mapError((cause) => error(\"read_failed\", \"durable checkpoint read failed\", cause)))\n const row = rows[0]\n return row === undefined ? Option.none() : Option.some(yield* decodeCheckpointRow(row))\n })\n )\n\n const compactInternal = (\n compactOptions: CompactOptions,\n fence: Fence\n ): Effect.Effect<Compacted, JournalError> =>\n Effect.gen(function*() {\n yield* Effect.annotateCurrentSpan({\n runId: compactOptions.runId,\n ...(compactOptions.upTo === undefined ? {} : { upTo: compactOptions.upTo })\n })\n yield* Effect.fromResult(Result.mapError(\n decodeCompactOptions(compactOptions),\n (cause) => error(\"invalid_event\", \"compact options violate the journal contract\", cause)\n ))\n const compactedAtMs = yield* Clock.currentTimeMillis.pipe(Effect.map(Math.floor))\n return yield* withCompactionBarrier(\n compactOptions.runId,\n Effect.gen(function*() {\n if (fence._tag === \"Owned\") {\n yield* fenceGuard(compactOptions.runId, fence.owner)\n }\n const upTo = compactOptions.upTo\n const rows = upTo === undefined\n ? yield* sql<CheckpointRow>`\n SELECT run_id, seq, state_json, created_at_ms, compacted_at_ms\n FROM flows_journal_checkpoints\n WHERE run_id = ${compactOptions.runId}\n ORDER BY seq DESC\n LIMIT 1\n `\n : yield* sql<CheckpointRow>`\n SELECT run_id, seq, state_json, created_at_ms, compacted_at_ms\n FROM flows_journal_checkpoints\n WHERE run_id = ${compactOptions.runId} AND seq = ${upTo}\n `\n const row = rows[0]\n if (row === undefined) {\n return yield* Effect.fail(error(\n \"checkpoint_invalid\",\n `run ${compactOptions.runId} has no checkpoint${\n upTo === undefined ? \"\" : ` at sequence ${upTo}`\n } to compact to`\n ))\n }\n const checkpointSeq = Number(row.seq) as Seq\n if (row.compacted_at_ms !== null) {\n // A retried compaction: the floor is already here and the rows\n // below it are already gone.\n return { runId: compactOptions.runId, checkpointSeq, deleted: 0 } satisfies Compacted\n }\n for (const reader of readers.get(compactOptions.runId) ?? []) {\n if (reader.cursor < checkpointSeq - 1) {\n return yield* Effect.fail(\n new JournalError({\n code: \"reader_behind\",\n message:\n `a live stream of run ${compactOptions.runId} still needs sequences below checkpoint ${checkpointSeq}`,\n checkpointSeq\n })\n )\n }\n }\n const doomed = yield* sql<{ readonly total: number }>`\n SELECT COUNT(*) AS total FROM flows_journal_events\n WHERE run_id = ${compactOptions.runId} AND seq < ${checkpointSeq}\n `\n // Retain identities atomically with deletion, in bounded pages.\n // These records never participate in replay, but preserve exact\n // retries and producer allocation floors after a fresh open.\n let after = -1\n while (true) {\n const retiring = yield* sql<JournalRow>`\n SELECT run_id, seq, event_id, source_id, source_seq, emitted_at_ms,\n event_type, payload_json, meta_json\n FROM flows_journal_events\n WHERE run_id = ${compactOptions.runId} AND seq > ${after} AND seq < ${checkpointSeq}\n ORDER BY seq ASC LIMIT 256\n `\n if (retiring.length === 0) break\n for (const entry of retiring) {\n const fingerprint = yield* contentFingerprint(entry.event_type, entry.payload_json, entry.meta_json)\n yield* sql`\n INSERT INTO flows_journal_dedup (run_id, source_id, source_seq, event_id, seq, content_hash)\n VALUES (${entry.run_id}, ${entry.source_id}, ${entry.source_seq}, ${entry.event_id},\n ${entry.seq}, ${fingerprint})\n `\n }\n after = Number(retiring[retiring.length - 1]!.seq)\n }\n // Strictly below the checkpoint: the checkpointed entry survives,\n // holding the run's `MAX(seq)` allocation floor. Superseded\n // checkpoints go with their entries; the truncation and the floor\n // advance are one transaction, so a crash between them is\n // unrepresentable.\n yield* sql`\n DELETE FROM flows_journal_events\n WHERE run_id = ${compactOptions.runId} AND seq < ${checkpointSeq}\n `\n yield* sql`\n DELETE FROM flows_journal_checkpoints\n WHERE run_id = ${compactOptions.runId} AND seq < ${checkpointSeq}\n `\n yield* sql`\n UPDATE flows_journal_checkpoints\n SET compacted_at_ms = ${compactedAtMs}\n WHERE run_id = ${compactOptions.runId} AND seq = ${checkpointSeq}\n `\n return {\n runId: compactOptions.runId,\n checkpointSeq,\n deleted: Number(doomed[0]?.total ?? 0)\n } satisfies Compacted\n })\n ).pipe(\n Effect.mapError((cause) =>\n isJournalError(cause) ? cause : error(\"sink_failed\", \"journal compaction failed\", cause)\n )\n )\n })\n\n const compact: Service[\"compact\"] = Effect.fn(\"Journal.compact\")((\n compactOptions: CompactOptions,\n owner: OwnerId\n ) =>\n Effect.flatMap(\n Effect.fromResult(requireFence(owner, \"compact\")),\n (fence) => compactInternal(compactOptions, fence)\n )\n )\n\n const compactionPolicy = options.compaction\n\n const countEntries = (runId: RunId): Effect.Effect<number, SqlError.SqlError> =>\n Effect.map(\n sql<{ readonly total: number }>`\n SELECT COUNT(*) AS total FROM flows_journal_events WHERE run_id = ${runId}\n `,\n (rows) => Number(rows[0]?.total ?? 0)\n )\n\n /**\n * One automatic checkpoint-and-compact attempt at the run's durable\n * tail. Runs post-commit; a failure or refusal is logged and damped,\n * the counter restarts, so the next attempt waits for another\n * `entryThreshold` commits, and is never surfaced to the emit whose\n * settlement crossed the threshold.\n */\n const policyCompact = (policy: CompactionPolicy, runId: RunId): Effect.Effect<void> =>\n Effect.gen(function*() {\n const tail = yield* sql<{ readonly last: number | null }>`\n SELECT MAX(seq) AS last FROM flows_journal_events WHERE run_id = ${runId}\n `\n const last = tail[0]?.last\n if (last === null || last === undefined) {\n return\n }\n const upTo = Number(last) as Seq\n const captured = yield* Effect.timeoutOrElse(policy.capture(runId, upTo), {\n duration: compactionCaptureTimeout,\n orElse: () =>\n Effect.fail(\n new JournalInternalFault({\n code: \"compaction_capture_timeout\",\n message: `journal compaction capture for run ${runId} exceeded ${compactionCaptureTimeout}`\n })\n )\n })\n // The policy is the journal's OWN post-commit maintenance, not a\n // caller's mutating entrypoint: it owns no run and holds no fence,\n // so it drives the internal channel. The attempt only ever\n // truncates below a tail the run's own commits produced, a retry is\n // idempotent (a re-attempt after a reclaim compacts the same\n // committed prefix the live owner also sees), and every failure is\n // damped below, never surfaced to the emit that crossed the\n // threshold.\n yield* checkpointInternal({ runId, seq: upTo, state: captured }, unfenced)\n yield* compactInternal({ runId, upTo }, unfenced)\n compactionCounts.set(runId, yield* countEntries(runId))\n }).pipe(\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.failCause(cause as Cause.Cause<never>)\n : Effect.sync(() => {\n compactionCounts.set(runId, 0)\n }).pipe(\n Effect.andThen(\n Effect.logWarning(\"journal auto-compaction failed; retrying after the next threshold\", cause)\n )\n )\n )\n )\n\n /**\n * Counts a run's committed entries toward the compaction policy and\n * triggers an attempt at the threshold. Lossy settlements register and\n * fork it; durable settlements await it. Registration and handoff are\n * uninterruptible so cancellation cannot leak the maintenance count.\n *\n * The count is seeded lazily from the durable COUNT on the run's first\n * committed entry in this process, mirroring `ensureFloors`, so a\n * restarted process still compacts a long pre-existing history. The\n * durable COUNT already includes the rows the caller is reporting: they\n * committed before this settlement ran.\n *\n * The read-modify-write runs under the run's `maintenance` permit because\n * the seeding COUNT is an awaited SQL read. Without the permit two\n * settlements that overlapped both observed an unseeded counter, both\n * issued the COUNT, and the later reply overwrote the newer count with a\n * stale one: measured with `entryThreshold: 10`, ten committed events\n * produced zero capture calls and no checkpoint. A settlement that\n * commits BETWEEN the seeding COUNT and the counter write is now counted\n * twice instead, which only brings an attempt forward, and\n * {@link policyCompact} re-seeds the counter from a fresh COUNT when it\n * finishes, so the error does not accumulate.\n *\n * The permit is released before the compaction runs. Holding it across\n * `policyCompact` would make a slow `capture` block every other\n * settlement of the same run, which is the stall {@link settleCommit}\n * moved this work off the allocation permit to avoid.\n */\n const noteCommitted = (runId: RunId, committed: number, background = false): Effect.Effect<void> => {\n const policy = compactionPolicy\n if (policy === undefined || committed <= 0) {\n return Effect.void\n }\n return Effect.uninterruptibleMask((restore) =>\n withRunBarrier(runId, (barrier) =>\n restore(barrier.maintenance.withPermit(\n Effect.gen(function*() {\n if (compactingRuns.has(runId)) {\n return false\n }\n const known = compactionCounts.get(runId)\n const current = known === undefined ? yield* countEntries(runId) : known + committed\n compactionCounts.set(runId, current)\n if (current < policy.entryThreshold) {\n return false\n }\n compactingRuns.add(runId)\n pendingMaintenance += 1\n return true\n })\n )).pipe(\n Effect.flatMap((triggered) => {\n if (!triggered) return Effect.void\n const attempt = policyCompact(policy, runId).pipe(Effect.ensuring(Effect.sync(() => {\n compactingRuns.delete(runId)\n pendingMaintenance -= 1\n if (state.pending === 0 && pendingMaintenance === 0) completeFlushWaiters(Effect.void)\n })))\n // The sole queue consumer must never await a compaction barrier:\n // that barrier may need another batch from this very consumer.\n return background\n ? Effect.asVoid(Effect.forkIn(Effect.interruptible(attempt), maintenanceScope))\n : restore(attempt)\n }),\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.failCause(cause as Cause.Cause<never>)\n : Effect.logWarning(\"journal compaction policy bookkeeping failed\", cause)\n )\n ))\n )\n }\n\n const recordCommits = (\n commits: ReadonlyArray<SettledCommit>\n ): void => {\n for (const { commit, queued } of commits) {\n rememberCommitted(queued, commit.entry.seq)\n }\n }\n\n const settle = (count: number): void => {\n state.pending = Math.max(0, state.pending - count)\n if (state.pending === 0 && pendingMaintenance === 0) {\n completeFlushWaiters(Effect.void)\n }\n }\n\n /** Reports entries that left the queue without durable commits. */\n const reportLoss = (cause: JournalError, batch: ReadonlyArray<QueuedEntry>): void => {\n for (const queued of batch) {\n const identity = sourceEventKey(queued.runId, queued.sourceId, queued.sourceSeq)\n // Allocation is serialized until this batch settles, so no newer\n // admission can replace this exact identity before the deletion.\n state.sourceEvents.delete(identity)\n }\n state.sinkFailure = cause\n state.lossEpoch += 1\n state.pending = Math.max(0, state.pending - batch.length)\n // A waiter that is already registered is the flush the loss belongs\n // to, so reporting it there spends the report; only a loss nobody was\n // waiting on is left for the next flush to pick up.\n if (state.flushWaiters.size > 0) {\n state.flushedLossEpoch = state.lossEpoch\n }\n completeFlushWaiters(Effect.fail(cause))\n for (const subscribers of wakes.values()) {\n for (const wake of subscribers) {\n PubSub.publishUnsafe(wake, undefined)\n }\n }\n }\n\n /**\n * Makes a lost batch visible to an operator. `reportLoss` only reaches a\n * flush caller or a live stream, and a telemetry producer usually has\n * neither, so the loss is also logged and counted here.\n */\n // Callers supply one refused entry or a batch taken with a minimum of one.\n const observeLoss = (cause: JournalError, batch: ReadonlyArray<QueuedEntry>): Effect.Effect<void> =>\n Effect.andThen(\n Metric.update(JournalMetrics.lost(cause.code), batch.length),\n Effect.logWarning(\n `journal lost ${batch.length} lossy entries (${cause.code}) for runs ${\n [...new Set(batch.map((queued) => queued.runId))].join(\", \")\n }`,\n cause\n )\n )\n\n // A failed transaction loses the whole batch. Release its per-run drain\n // counts before reporting the failure so a waiting compactor can retry\n // against the same database outage instead of waiting forever.\n const failSink = (cause: JournalError, batch: ReadonlyArray<QueuedEntry>): void => {\n settleRunPending(batch)\n reportLoss(cause, batch)\n }\n\n // One failed batch loses that batch and is reported as such; it never\n // ends the writer. Only interruption (scope closure) stops the loop, so\n // the queue keeps draining as soon as the database is healthy again.\n const writeBatch = Queue.takeBetween(queue, 1, batchSize).pipe(\n Effect.flatMap((batch) =>\n persistBatch(batch).pipe(\n Effect.tap((outcome) => Effect.sync(() => recordCommits(outcome.commits))),\n Effect.tap((outcome) => publish(outcome.commits.map(({ commit }) => commit))),\n // The transaction has committed and publication is complete. Drop\n // the barrier counts before policy compaction takes this run's\n // permit. Maintenance has its own global flush count.\n Effect.tap(() => Effect.sync(() => settleRunPending(batch))),\n // Register maintenance BEFORE settling the batch, so flush cannot\n // observe a gap between queued work and its policy attempt.\n Effect.tap((outcome) => {\n const perRun = new Map<RunId, number>()\n outcome.commits.forEach(({ commit, queued }) => {\n if (!commit.inserted) {\n return\n }\n perRun.set(queued.runId, (perRun.get(queued.runId) ?? 0) + 1)\n })\n return Effect.forEach(perRun, ([runId, committed]) => noteCommitted(runId, committed, true), {\n discard: true\n })\n }),\n Effect.tap((outcome) =>\n // Observed before it is reported, so a flush the report wakes\n // already sees the loss in the log and the registry.\n Effect.uninterruptible(Effect.andThen(\n Effect.forEach(outcome.losses, (loss) => observeLoss(loss.cause, [loss.queued]), { discard: true }),\n Effect.sync(() => {\n for (const loss of outcome.losses) {\n reportLoss(loss.cause, [loss.queued])\n }\n settle(outcome.commits.length)\n })\n ))\n ),\n Effect.catch((cause) =>\n Effect.uninterruptible(\n Effect.andThen(observeLoss(cause, batch), Effect.sync(() => failSink(cause, batch)))\n )\n ),\n // Defects only: an interruption is scope closure, and it must end\n // the writer rather than be reported as a lost batch.\n Effect.catchDefect((defect) => {\n const cause = error(\"sink_failed\", \"journal writer failed\", Cause.die(defect))\n return Effect.uninterruptible(\n Effect.andThen(observeLoss(cause, batch), Effect.sync(() => failSink(cause, batch)))\n )\n })\n )\n )\n )\n\n const drain = Effect.forever(writeBatch)\n\n yield* Effect.forkScoped(drain)\n yield* Effect.addFinalizer(() =>\n Effect.gen(function*() {\n // A scope finalizer runs once, and nothing else moves the status, so\n // the journal is always `open` here.\n yield* Effect.sync(() => {\n state.status = \"closing\"\n })\n // The last flush is the last chance to say that queued entries were\n // lost; nothing is left to report the failure to once this returns.\n yield* flushInternal.pipe(\n Effect.catch((cause) => Effect.logWarning(\"journal final flush failed while closing\", cause))\n )\n yield* Effect.sync(() => {\n state.status = \"closed\"\n })\n yield* Queue.shutdown(queue)\n yield* PubSub.shutdown(changes)\n wakes.clear()\n })\n )\n\n const project = <S, E, R>(\n projection: Projection<S, E, R>,\n streamOptions: StreamOptions\n ): Stream.Stream<S, JournalError, R> =>\n Stream.unwrap(\n Effect.fn(\"Journal.project\")(\n <S2, E2, R2>(\n activeProjection: Projection<S2, E2, R2>,\n activeOptions: StreamOptions\n ) =>\n Effect.annotateCurrentSpan({\n projection: activeProjection.name,\n runId: activeOptions.runId,\n ...(activeOptions.afterSequence === undefined ? {} : { afterSequence: activeOptions.afterSequence })\n }).pipe(Effect.andThen(Effect.succeed(\n stream(activeOptions).pipe(\n Stream.scanEffect(activeProjection.initial, (state, entry) =>\n Effect.suspend(() => activeProjection.reduce(state, entry)).pipe(\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.failCause(cause as Cause.Cause<never>)\n : Effect.fail(\n error(\n \"projection_failed\",\n `projection ${activeProjection.name} failed`,\n cause\n )\n )\n )\n ))\n )\n )))\n )(projection, streamOptions)\n )\n\n yield* JournalGeneration.onTruncate((runIds) => {\n for (const runId of runIds) {\n state.sequences.delete(runId as RunId)\n const prefix = `${runId.length}:${runId}`\n for (const key of state.sourceSequences.keys()) {\n if (key.startsWith(prefix)) state.sourceSequences.delete(key)\n }\n for (const key of state.sourceEvents.keys()) {\n if (key.startsWith(prefix)) state.sourceEvents.delete(key)\n }\n }\n })\n\n return makeJournal({\n generation: (runId) =>\n sql<{ readonly generation: number; readonly afterSeq: number }>`\n SELECT generation, after_seq AS \"afterSeq\" FROM flows_journal_generations WHERE run_id = ${runId}\n `.pipe(\n Effect.map((rows) => rows[0] ?? { generation: 0, afterSeq: -1 }),\n Effect.mapError((cause) => error(\"read_failed\", \"could not read journal generation\", cause))\n ),\n emitLossy,\n emitDurable,\n emitDurableUnfenced,\n transact,\n whenCommitted: (update) =>\n Effect.flatMap(\n Effect.serviceOption(sql.transactionService),\n (transaction) => Option.isNone(transaction) ? Effect.as(update, true) : afterCommit(update, sql)\n ),\n stream,\n entries: readPage,\n changes: PubSub.subscribe(changes),\n project,\n flush: Effect.fn(\"Journal.flush\")(() =>\n Effect.suspend(() => Effect.annotateCurrentSpan({ pending: state.pending })).pipe(\n Effect.andThen(flushInternal)\n )\n )(),\n checkpoint,\n latestCheckpoint,\n compact\n })\n })\n\n/**\n * Provides the SQL journal over an explicitly injected consensus strategy.\n *\n * The strategy in context arbitrates the owner fence: `emitDurable`,\n * `checkpoint`, and `compact` join its `guard` inside their write\n * transaction. Provide the SAME strategy instance to every service that must\n * agree on ownership — `RunStore.layerWith` in particular — because\n * `Consensus.layerLocal` keeps its leases per layer build.\n *\n * @category layers\n * @since 1.0.0\n */\nexport const layerWith = (\n options: SqlJournalOptions\n): Layer.Layer<Journal, JournalError, Consensus | DurableWriter | SqlClient.SqlClient> =>\n Layer.effect(Journal, make(options))\n\n/**\n * Provides the SQL journal fenced by the database-backed strategy,\n * `SqlConsensus`, over the same client. Use {@link layerWith} to inject a\n * different strategy.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layer = (\n options: SqlJournalOptions\n): Layer.Layer<Journal, JournalError, DurableWriter | SqlClient.SqlClient> =>\n layerWith(options).pipe(Layer.provide(SqlConsensus.layer))\n"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** Durable observations owned by an agent checkpoint action.
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
*/
|
|
4
|
+
import * as Context from "effect/Context";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
/** Invocation and retry coordinates remain distinct across replay.
|
|
7
|
+
* @category schemas
|
|
8
|
+
* @since 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
export declare const Step: Schema.Struct<{
|
|
11
|
+
readonly stepId: Schema.String;
|
|
12
|
+
readonly executionId: Schema.String;
|
|
13
|
+
readonly action: Schema.String;
|
|
14
|
+
readonly attempt: Schema.Int;
|
|
15
|
+
readonly ask: Schema.Union<readonly [Schema.Int, Schema.Literal<"repair">]>;
|
|
16
|
+
readonly retry: Schema.Int;
|
|
17
|
+
readonly scope: Schema.String;
|
|
18
|
+
}>;
|
|
19
|
+
/** Decoded invocation coordinates.
|
|
20
|
+
* @category models
|
|
21
|
+
* @since 1.0.0
|
|
22
|
+
*/
|
|
23
|
+
export type Step = typeof Step.Type;
|
|
24
|
+
/** The first recorded observation, including its original generation and time.
|
|
25
|
+
* @category schemas
|
|
26
|
+
* @since 1.0.0
|
|
27
|
+
*/
|
|
28
|
+
export declare const Fact: Schema.Struct<{
|
|
29
|
+
readonly version: Schema.Literal<1>;
|
|
30
|
+
readonly step: Schema.Struct<{
|
|
31
|
+
readonly stepId: Schema.String;
|
|
32
|
+
readonly executionId: Schema.String;
|
|
33
|
+
readonly action: Schema.String;
|
|
34
|
+
readonly attempt: Schema.Int;
|
|
35
|
+
readonly ask: Schema.Union<readonly [Schema.Int, Schema.Literal<"repair">]>;
|
|
36
|
+
readonly retry: Schema.Int;
|
|
37
|
+
readonly scope: Schema.String;
|
|
38
|
+
}>;
|
|
39
|
+
readonly generation: Schema.Int;
|
|
40
|
+
readonly frame: Schema.Int;
|
|
41
|
+
readonly ordinal: Schema.Int;
|
|
42
|
+
readonly cell: Schema.String;
|
|
43
|
+
readonly at: Schema.Number;
|
|
44
|
+
readonly eventType: Schema.String;
|
|
45
|
+
readonly sourceSequence: Schema.Int;
|
|
46
|
+
readonly payload: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
47
|
+
}>;
|
|
48
|
+
/** Decoded checkpoint observation.
|
|
49
|
+
* @category models
|
|
50
|
+
* @since 1.0.0
|
|
51
|
+
*/
|
|
52
|
+
export type Fact = typeof Fact.Type;
|
|
53
|
+
declare const Annotation_base: Context.ServiceClass<Annotation, "@smthrs/journal/StepFact/Annotation", {}>;
|
|
54
|
+
/** Marks a checkpoint whose saved success is the fact to publish.
|
|
55
|
+
* @category services
|
|
56
|
+
* @since 1.0.0
|
|
57
|
+
*/
|
|
58
|
+
export declare class Annotation extends Annotation_base {
|
|
59
|
+
}
|
|
60
|
+
/** Native outbox event, committed with its owning checkpoint.
|
|
61
|
+
* @category events
|
|
62
|
+
* @since 1.0.0
|
|
63
|
+
*/
|
|
64
|
+
export declare const eventType = "flows.harness.step-fact.v1";
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=StepFact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepFact.d.ts","sourceRoot":"","sources":["../../src/StepFact.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAQvC;;;GAGG;AACH,eAAO,MAAM,IAAI;;;;;;;;EAQf,CAAA;AAEF;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAA;AAEnC;;;GAGG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;EAWf,CAAA;AAEF;;;GAGG;AACH,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAA;;AAEnC;;;GAGG;AAGH,qBAAa,UAAW,SAAQ,eAAwE;CAAG;AAE3G;;;GAGG;AACH,eAAO,MAAM,SAAS,+BAA+B,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** Durable observations owned by an agent checkpoint action.
|
|
2
|
+
* @since 1.0.0
|
|
3
|
+
*/
|
|
4
|
+
import * as Context from "effect/Context";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
const nonnegative = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(Number.MAX_SAFE_INTEGER));
|
|
7
|
+
const positive = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1), Schema.isLessThanOrEqualTo(Number.MAX_SAFE_INTEGER));
|
|
8
|
+
/** Invocation and retry coordinates remain distinct across replay.
|
|
9
|
+
* @category schemas
|
|
10
|
+
* @since 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
export const Step = Schema.Struct({
|
|
13
|
+
stepId: Schema.String.check(Schema.isPattern(/^[0-9a-f]{64}$/)),
|
|
14
|
+
executionId: Schema.String,
|
|
15
|
+
action: Schema.String,
|
|
16
|
+
attempt: positive,
|
|
17
|
+
ask: Schema.Union([nonnegative, Schema.Literal("repair")]),
|
|
18
|
+
retry: positive,
|
|
19
|
+
scope: Schema.String
|
|
20
|
+
});
|
|
21
|
+
/** The first recorded observation, including its original generation and time.
|
|
22
|
+
* @category schemas
|
|
23
|
+
* @since 1.0.0
|
|
24
|
+
*/
|
|
25
|
+
export const Fact = Schema.Struct({
|
|
26
|
+
version: Schema.Literal(1),
|
|
27
|
+
step: Step,
|
|
28
|
+
generation: nonnegative,
|
|
29
|
+
frame: Schema.Int.check(Schema.isGreaterThanOrEqualTo(-1)),
|
|
30
|
+
ordinal: nonnegative,
|
|
31
|
+
cell: Schema.String,
|
|
32
|
+
at: Schema.Number.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
33
|
+
eventType: Schema.String.check(Schema.isPattern(/^control\.agent\.[a-z-]+$/)),
|
|
34
|
+
sourceSequence: nonnegative,
|
|
35
|
+
payload: Schema.Json
|
|
36
|
+
});
|
|
37
|
+
/** Marks a checkpoint whose saved success is the fact to publish.
|
|
38
|
+
* @category services
|
|
39
|
+
* @since 1.0.0
|
|
40
|
+
*/
|
|
41
|
+
// The annotation is a marker with no fields; its presence is the entire contract.
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
43
|
+
export class Annotation extends Context.Service()("@smthrs/journal/StepFact/Annotation") {
|
|
44
|
+
}
|
|
45
|
+
/** Native outbox event, committed with its owning checkpoint.
|
|
46
|
+
* @category events
|
|
47
|
+
* @since 1.0.0
|
|
48
|
+
*/
|
|
49
|
+
export const eventType = "flows.harness.step-fact.v1";
|
|
50
|
+
//# sourceMappingURL=StepFact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepFact.js","sourceRoot":"","sources":["../../src/StepFact.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAClC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAChC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CACpD,CAAA;AACD,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,mBAA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,qCAAqC,CAAC;CAAG;AAE3G;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,4BAA4B,CAAA","sourcesContent":["/** Durable observations owned by an agent checkpoint action.\n * @since 1.0.0\n */\n\nimport * as Context from \"effect/Context\"\nimport * as Schema from \"effect/Schema\"\n\nconst nonnegative = Schema.Int.check(\n Schema.isGreaterThanOrEqualTo(0),\n Schema.isLessThanOrEqualTo(Number.MAX_SAFE_INTEGER)\n)\nconst positive = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1), Schema.isLessThanOrEqualTo(Number.MAX_SAFE_INTEGER))\n\n/** Invocation and retry coordinates remain distinct across replay.\n * @category schemas\n * @since 1.0.0\n */\nexport const Step = Schema.Struct({\n stepId: Schema.String.check(Schema.isPattern(/^[0-9a-f]{64}$/)),\n executionId: Schema.String,\n action: Schema.String,\n attempt: positive,\n ask: Schema.Union([nonnegative, Schema.Literal(\"repair\")]),\n retry: positive,\n scope: Schema.String\n})\n\n/** Decoded invocation coordinates.\n * @category models\n * @since 1.0.0\n */\nexport type Step = typeof Step.Type\n\n/** The first recorded observation, including its original generation and time.\n * @category schemas\n * @since 1.0.0\n */\nexport const Fact = Schema.Struct({\n version: Schema.Literal(1),\n step: Step,\n generation: nonnegative,\n frame: Schema.Int.check(Schema.isGreaterThanOrEqualTo(-1)),\n ordinal: nonnegative,\n cell: Schema.String,\n at: Schema.Number.check(Schema.isGreaterThanOrEqualTo(0)),\n eventType: Schema.String.check(Schema.isPattern(/^control\\.agent\\.[a-z-]+$/)),\n sourceSequence: nonnegative,\n payload: Schema.Json\n})\n\n/** Decoded checkpoint observation.\n * @category models\n * @since 1.0.0\n */\nexport type Fact = typeof Fact.Type\n\n/** Marks a checkpoint whose saved success is the fact to publish.\n * @category services\n * @since 1.0.0\n */\n// The annotation is a marker with no fields; its presence is the entire contract.\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport class Annotation extends Context.Service<Annotation, {}>()(\"@smthrs/journal/StepFact/Annotation\") {}\n\n/** Native outbox event, committed with its owning checkpoint.\n * @category events\n * @since 1.0.0\n */\nexport const eventType = \"flows.harness.step-fact.v1\"\n"]}
|