@smthrs/journal 1.0.0-rc.16 → 1.0.0-rc.18
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 +20 -0
- package/README.md +26 -8
- package/dist/cjs/CallFact.d.ts +8 -8
- package/dist/cjs/Consensus.d.ts +26 -6
- package/dist/cjs/Consensus.d.ts.map +1 -1
- package/dist/cjs/Consensus.js +63 -22
- package/dist/cjs/Consensus.js.map +2 -2
- package/dist/cjs/EngineEvent.d.ts +23 -23
- package/dist/cjs/EngineEvent.d.ts.map +1 -1
- package/dist/cjs/EngineEvent.js +3 -2
- package/dist/cjs/EngineEvent.js.map +2 -2
- package/dist/cjs/ExecutionFact.d.ts +5 -5
- package/dist/cjs/Journal.d.ts +77 -2
- package/dist/cjs/Journal.d.ts.map +1 -1
- package/dist/cjs/Journal.js +1 -0
- package/dist/cjs/Journal.js.map +2 -2
- package/dist/cjs/JournalGeneration.d.ts +1 -1
- package/dist/cjs/JournalGeneration.d.ts.map +1 -1
- package/dist/cjs/JournalGeneration.js +10 -1
- package/dist/cjs/JournalGeneration.js.map +2 -2
- package/dist/cjs/JournalMetrics.d.ts +41 -5
- package/dist/cjs/JournalMetrics.d.ts.map +1 -1
- package/dist/cjs/JournalMetrics.js +10 -1
- package/dist/cjs/JournalMetrics.js.map +2 -2
- package/dist/cjs/RedactedLogger.d.ts.map +1 -1
- package/dist/cjs/RedactedLogger.js +5 -3
- package/dist/cjs/RedactedLogger.js.map +2 -2
- package/dist/cjs/Redaction.d.ts +18 -1
- package/dist/cjs/Redaction.d.ts.map +1 -1
- package/dist/cjs/Redaction.js +142 -12
- package/dist/cjs/Redaction.js.map +3 -3
- package/dist/cjs/SqlConsensus.d.ts +4 -3
- package/dist/cjs/SqlConsensus.d.ts.map +1 -1
- package/dist/cjs/SqlConsensus.js +92 -59
- package/dist/cjs/SqlConsensus.js.map +2 -2
- package/dist/cjs/SqlJournal.d.ts.map +1 -1
- package/dist/cjs/SqlJournal.js +370 -131
- package/dist/cjs/SqlJournal.js.map +3 -3
- package/dist/cjs/StepFact.d.ts +1 -1
- package/dist/cjs/TelemetryLog.d.ts +241 -0
- package/dist/cjs/TelemetryLog.d.ts.map +1 -0
- package/dist/cjs/TelemetryLog.js +349 -0
- package/dist/cjs/TelemetryLog.js.map +7 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/internal/EventTally.d.ts +31 -0
- package/dist/cjs/internal/EventTally.d.ts.map +1 -0
- package/dist/cjs/internal/EventTally.js +32 -0
- package/dist/cjs/internal/EventTally.js.map +7 -0
- package/dist/cjs/internal/JournalDigest.d.ts +24 -0
- package/dist/cjs/internal/JournalDigest.d.ts.map +1 -0
- package/dist/cjs/internal/JournalDigest.js +44 -0
- package/dist/cjs/internal/JournalDigest.js.map +7 -0
- package/dist/cjs/internal/JournalTestObserver.d.ts +41 -0
- package/dist/cjs/internal/JournalTestObserver.d.ts.map +1 -0
- package/dist/cjs/internal/JournalTestObserver.js +38 -0
- package/dist/cjs/internal/JournalTestObserver.js.map +7 -0
- package/dist/cjs/internal/TelemetryText.d.ts +28 -0
- package/dist/cjs/internal/TelemetryText.d.ts.map +1 -0
- package/dist/cjs/internal/TelemetryText.js +44 -0
- package/dist/cjs/internal/TelemetryText.js.map +7 -0
- package/dist/esm/CallFact.d.ts +8 -8
- package/dist/esm/Consensus.d.ts +26 -6
- package/dist/esm/Consensus.d.ts.map +1 -1
- package/dist/esm/Consensus.js +102 -21
- package/dist/esm/Consensus.js.map +1 -1
- package/dist/esm/EngineEvent.d.ts +23 -23
- package/dist/esm/EngineEvent.d.ts.map +1 -1
- package/dist/esm/EngineEvent.js +4 -2
- package/dist/esm/EngineEvent.js.map +1 -1
- package/dist/esm/ExecutionFact.d.ts +5 -5
- package/dist/esm/Journal.d.ts +77 -2
- package/dist/esm/Journal.d.ts.map +1 -1
- package/dist/esm/Journal.js +4 -1
- package/dist/esm/Journal.js.map +1 -1
- package/dist/esm/JournalGeneration.d.ts +1 -1
- package/dist/esm/JournalGeneration.d.ts.map +1 -1
- package/dist/esm/JournalGeneration.js +9 -1
- package/dist/esm/JournalGeneration.js.map +1 -1
- package/dist/esm/JournalMetrics.d.ts +41 -5
- package/dist/esm/JournalMetrics.d.ts.map +1 -1
- package/dist/esm/JournalMetrics.js +38 -6
- package/dist/esm/JournalMetrics.js.map +1 -1
- package/dist/esm/RedactedLogger.d.ts.map +1 -1
- package/dist/esm/RedactedLogger.js +9 -5
- package/dist/esm/RedactedLogger.js.map +1 -1
- package/dist/esm/Redaction.d.ts +18 -1
- package/dist/esm/Redaction.d.ts.map +1 -1
- package/dist/esm/Redaction.js +199 -16
- package/dist/esm/Redaction.js.map +1 -1
- package/dist/esm/SqlConsensus.d.ts +4 -3
- package/dist/esm/SqlConsensus.d.ts.map +1 -1
- package/dist/esm/SqlConsensus.js +34 -22
- package/dist/esm/SqlConsensus.js.map +1 -1
- package/dist/esm/SqlJournal.d.ts.map +1 -1
- package/dist/esm/SqlJournal.js +410 -108
- package/dist/esm/SqlJournal.js.map +1 -1
- package/dist/esm/StepFact.d.ts +1 -1
- package/dist/esm/TelemetryLog.d.ts +241 -0
- package/dist/esm/TelemetryLog.d.ts.map +1 -0
- package/dist/esm/TelemetryLog.js +519 -0
- package/dist/esm/TelemetryLog.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/EventTally.d.ts +31 -0
- package/dist/esm/internal/EventTally.d.ts.map +1 -0
- package/dist/esm/internal/EventTally.js +27 -0
- package/dist/esm/internal/EventTally.js.map +1 -0
- package/dist/esm/internal/JournalDigest.d.ts +24 -0
- package/dist/esm/internal/JournalDigest.d.ts.map +1 -0
- package/dist/esm/internal/JournalDigest.js +27 -0
- package/dist/esm/internal/JournalDigest.js.map +1 -0
- package/dist/esm/internal/JournalTestObserver.d.ts +41 -0
- package/dist/esm/internal/JournalTestObserver.d.ts.map +1 -0
- package/dist/esm/internal/JournalTestObserver.js +17 -0
- package/dist/esm/internal/JournalTestObserver.js.map +1 -0
- package/dist/esm/internal/TelemetryText.d.ts +28 -0
- package/dist/esm/internal/TelemetryText.d.ts.map +1 -0
- package/dist/esm/internal/TelemetryText.js +28 -0
- package/dist/esm/internal/TelemetryText.js.map +1 -0
- package/docs/README.md +6 -5
- package/docs/api.md +244 -49
- package/docs/concepts/owner-fence.md +4 -1
- package/docs/concepts/redaction.md +45 -2
- package/docs/concepts/state-event-authority.md +5 -4
- package/docs/concepts/two-channels.md +3 -2
- package/docs/guides/read-a-run.md +8 -6
- package/docs/guides/redact-log-output.md +4 -2
- package/docs/guides/testing.md +4 -2
- package/docs/installation.md +23 -9
- package/docs/quickstart.md +58 -3
- package/docs/troubleshooting.md +4 -2
- package/package.json +21 -9
- package/src/Consensus.ts +118 -28
- package/src/EngineEvent.ts +6 -2
- package/src/Journal.ts +85 -2
- package/src/JournalGeneration.ts +13 -1
- package/src/JournalMetrics.ts +53 -6
- package/src/RedactedLogger.ts +10 -4
- package/src/Redaction.ts +252 -16
- package/src/SqlConsensus.ts +135 -83
- package/src/SqlJournal.ts +604 -179
- package/src/TelemetryLog.ts +597 -0
- package/src/index.ts +6 -0
- package/src/internal/EventTally.ts +39 -0
- package/src/internal/JournalDigest.ts +30 -0
- package/src/internal/JournalTestObserver.ts +48 -0
- package/src/internal/TelemetryText.ts +31 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/EngineEvent.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Versioned engine history contracts over the open journal. These schemas do\n * not change journal admission or make history the engine's recovery store.\n *\n * @since 1.0.0\n */\n\nimport * as Cause from \"effect/Cause\"\nimport * as Effect from \"effect/Effect\"\nimport * as Schema from \"effect/Schema\"\nimport * as Event from \"./JournalEvent.ts\"\n\n/**\n * Required lineage coordinates for a root or derived run.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Lineage = Schema.Union([\n Schema.Struct({\n kind: Schema.Literal(\"root\"),\n runId: Event.RunId,\n lineageId: Event.LineageId,\n rootRunId: Event.RunId,\n round: Schema.Literal(0),\n parentRunId: Schema.Null\n }).check(Schema.makeFilter((value) => value.runId === value.rootRunId)),\n Schema.Struct({\n kind: Schema.Literals([\"child\", \"fork\", \"continuation\"]),\n runId: Event.RunId,\n lineageId: Event.LineageId,\n rootRunId: Event.RunId,\n round: Event.NonNegativeQuantity,\n parentRunId: Event.RunId\n }).check(Schema.makeFilter((value) =>\n value.runId !== value.parentRunId && value.runId !== value.rootRunId &&\n (value.kind !== \"continuation\" || value.round > 0)\n ))\n])\n\n/**\n * Required lineage coordinates for a root or derived run.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Lineage = typeof Lineage.Type\n\n/**\n * Encoded values only: class instances must first pass their own codec.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Success = Schema.TaggedStruct(\"Success\", { value: Schema.Json })\n\n/**\n * Failure channels stay distinct, including interruption and encoding failure.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Failure = Schema.TaggedStruct(\"Failure\", {\n reason: Schema.Literals([\"error\", \"defect\", \"interrupted\", \"encoding\"]),\n detail: Schema.Json\n})\n\n/**\n * Encoded success or a classified failure.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const ResultEnvelope = Schema.Union([Success, Failure])\n/**\n * Encoded success or a classified failure.\n *\n * @category models\n * @since 1.0.0\n */\nexport type ResultEnvelope = typeof ResultEnvelope.Type\n\nconst timing = { startedAtMs: Event.TimestampMs }\nconst live = {\n ...timing,\n heartbeatAtMs: Schema.optionalKey(Event.TimestampMs),\n checkpoint: Schema.optionalKey(Schema.Json),\n finishedAtMs: Schema.optionalKey(Schema.Never),\n result: Schema.optionalKey(Schema.Never)\n}\n\n/**\n * Completion and its outcome are inseparable; live states cannot carry either.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const AttemptLifecycle = Schema.Union([\n Schema.Struct({ state: Schema.Literal(\"running\"), ...live }),\n Schema.Struct({ state: Schema.Literal(\"suspended\"), ...live }),\n Schema.Struct({\n state: Schema.Literal(\"succeeded\"),\n ...timing,\n finishedAtMs: Event.TimestampMs,\n result: Success\n }),\n Schema.Struct({\n state: Schema.Literal(\"failed\"),\n ...timing,\n finishedAtMs: Event.TimestampMs,\n result: Failure\n })\n])\n\n/**\n * Wall clocks can move backwards; completion need not be after start.\n *\n * @category models\n * @since 1.0.0\n */\nexport type AttemptLifecycle = typeof AttemptLifecycle.Type\n\n/**\n * Complete identity and state of one versioned attempt event.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const AttemptPayload = Schema.Struct({\n version: Schema.Literal(2),\n lineage: Lineage,\n executionId: Event.RunId,\n stepKeyDigest: Event.DispatchId,\n attempt: Event.NonNegativeQuantity,\n lifecycle: AttemptLifecycle\n}).check(Schema.makeFilter((value) => value.executionId === value.lineage.runId))\n\n/**\n * Complete identity and state of one versioned attempt event.\n *\n * @category models\n * @since 1.0.0\n */\nexport type AttemptPayload = typeof AttemptPayload.Type\n\n/**\n * Durable wait identities; ownership and cancellation remain independent facts.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Wait = Schema.Union([\n Schema.TaggedStruct(\"Deferred\", { waitId: Event.WaitId }),\n Schema.TaggedStruct(\"Clock\", { waitId: Event.WaitId, dueAtMs: Event.TimestampMs })\n])\n\n/**\n * A complete execution observation, without operational ownership leases.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const ExecutionLifecycle = Schema.Union([\n Schema.Struct({ state: Schema.Literal(\"running\"), waits: Schema.Array(Wait) }),\n Schema.Struct({ state: Schema.Literal(\"suspended\"), waits: Schema.NonEmptyArray(Wait) }),\n Schema.Struct({ state: Schema.Literal(\"completed\"), result: ResultEnvelope })\n])\n\n/**\n * Versioned execution, deferred and clock observations. Every variant records\n * its semantic identity and encoded value independently of diagnostics.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const StatePayload = Schema.Struct({\n version: Schema.Literal(2),\n lineage: Lineage,\n executionId: Event.RunId,\n event: Schema.Union([\n Schema.TaggedStruct(\"Execution\", { lifecycle: ExecutionLifecycle }),\n Schema.TaggedStruct(\"DeferredCompleted\", { waitId: Event.WaitId, result: ResultEnvelope }),\n Schema.TaggedStruct(\"ClockScheduled\", {\n clockId: Event.CommandId,\n waitId: Event.WaitId,\n dueAtMs: Event.TimestampMs\n })\n ])\n}).check(Schema.makeFilter((value) => value.executionId === value.lineage.runId))\n\n/**\n * Versioned execution, deferred and clock observations.\n *\n * @category models\n * @since 1.0.0\n */\nexport type StatePayload = typeof StatePayload.Type\n\n/**\n * Event family for complete execution, deferred and clock observations.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const stateEventType = \"flows.engine.v2.state-event\"\n\n/**\n * New identity prevents old readers mistaking complete state for historical markers.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const attemptEventType = \"flows.engine.v2.attempt-lifecycle\"\n\n/**\n * Malformed, foreign, unsupported or inconsistent event evidence.\n *\n * @category errors\n * @since 1.0.0\n */\nexport class EventError extends Schema.TaggedError<EventError>()(\"@smthrs/journal/EngineEventError\", {\n code: Schema.Literals([\"malformed\", \"unsupported\", \"foreign\", \"transition\"]),\n message: Schema.String,\n cause: Schema.Unknown\n}) {}\n\n/**\n * Every consumer chooses its source allowlist and unknown-namespace policy.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface Consumer {\n readonly runId: Event.RunId\n readonly lineageId: Event.LineageId\n readonly rootRunId: Event.RunId\n readonly round: number\n readonly parentRunId: Event.RunId | null\n readonly sources: ReadonlyArray<Event.SourceId>\n readonly unknown: \"ignore\" | \"surface\"\n}\n\n/**\n * A known event or the explicitly selected extension outcome.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Decoded =\n | { readonly _tag: \"Attempt\"; readonly entry: Event.Entry; readonly payload: AttemptPayload }\n | { readonly _tag: \"State\"; readonly entry: Event.Entry; readonly payload: StatePayload }\n | { readonly _tag: \"Ignored\" }\n | { readonly _tag: \"Unknown\"; readonly entry: Event.Entry }\n\nconst strict = { onExcessProperty: \"error\" } as const\nconst decodeRow = (input: unknown) =>\n Effect.gen(function*() {\n const raw = yield* Schema.decodeUnknownEffect(Schema.toEncoded(Event.Entry))(input)\n return yield* Schema.decodeUnknownEffect(Event.Entry)(raw)\n })\nconst decodePayload = Schema.decodeUnknownSync(AttemptPayload, strict)\nconst decodeJson = Schema.decodeUnknownSync(Schema.Json)\n\n/**\n * Decode untrusted committed input. Unknown events in the known engine namespace\n * are unsupported errors, never ignored. Original schema/accessor errors stay\n * in cause; foreign identity includes the conflicting evidence in cause.\n *\n * @category decoders\n * @since 1.0.0\n */\nexport const decodeEntry = (input: unknown, consumer: Consumer): Effect.Effect<Decoded, EventError> =>\n Effect.gen(function*(): Effect.fn.Return<Decoded, unknown> {\n const entry = yield* decodeRow(input)\n if (entry.runId !== consumer.runId || !consumer.sources.includes(entry.sourceId)) {\n throw new EventError({\n code: \"foreign\",\n message: \"event run or source is outside the consumer scope\",\n cause: entry\n })\n }\n if (entry.eventType !== attemptEventType && entry.eventType !== stateEventType) {\n if (entry.eventType.startsWith(\"flows.engine.\")) {\n throw new EventError({\n code: \"unsupported\",\n message: \"unsupported engine event family or version\",\n cause: entry\n })\n }\n return consumer.unknown === \"ignore\" ? { _tag: \"Ignored\" } : { _tag: \"Unknown\", entry }\n }\n const decoded = entry.eventType === attemptEventType\n ? { _tag: \"Attempt\" as const, payload: yield* Schema.decodeUnknownEffect(AttemptPayload, strict)(entry.payload) }\n : { _tag: \"State\" as const, payload: yield* Schema.decodeUnknownEffect(StatePayload, strict)(entry.payload) }\n const { payload } = decoded\n if (\n payload.lineage.runId !== entry.runId || payload.lineage.lineageId !== consumer.lineageId ||\n payload.lineage.rootRunId !== consumer.rootRunId || payload.lineage.round !== consumer.round ||\n payload.lineage.parentRunId !== consumer.parentRunId\n ) {\n throw new EventError({\n code: \"foreign\",\n message: \"event lineage disagrees with its journal or consumer\",\n cause: payload.lineage\n })\n }\n // The optional journal side channel is disclosure only. Semantic lineage\n // lives in payload and cannot be replaced by diagnostic metadata.\n yield* Schema.decodeUnknownEffect(Schema.Json)(entry.meta)\n return { ...decoded, entry }\n }).pipe(Effect.catchCause((failure) => {\n const cause = Cause.squash(failure)\n return Effect.fail(\n cause instanceof EventError\n ? cause\n : new EventError({ code: \"malformed\", message: \"invalid engine event\", cause })\n )\n }))\n\n/**\n * Construct a versioned submission, validating before journal redaction.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const attempt = (\n payload: AttemptPayload,\n sourceId: Event.SourceId,\n sourceSeq: Event.SourceSeq,\n diagnostics: Schema.Json = null\n): Event.Input => {\n const validated = decodePayload(payload)\n return new Event.Input({\n runId: validated.lineage.runId,\n sourceId,\n sourceSeq,\n eventType: attemptEventType,\n payload: validated,\n meta: decodeJson(diagnostics)\n })\n}\n\n/**\n * Construct a versioned execution, deferred or clock submission. Existing\n * unversioned writers are unchanged and cannot manufacture missing lineage.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const stateEvent = (\n payload: StatePayload,\n sourceId: Event.SourceId,\n sourceSeq: Event.SourceSeq,\n diagnostics: Schema.Json = null\n): Event.Input => {\n const validated = Schema.decodeUnknownSync(StatePayload, strict)(payload)\n return new Event.Input({\n runId: validated.lineage.runId,\n sourceId,\n sourceSeq,\n eventType: stateEventType,\n payload: validated,\n meta: decodeJson(diagnostics)\n })\n}\n\n/**\n * Historical attempt markers deliberately remain incomplete evidence. No\n * result, timestamp, round or lineage root is invented for old rows.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const CurrentAttempt = Schema.Union([\n Schema.Struct({\n eventType: Schema.Literal(\"flows.engine.attempt-started\"),\n payload: Schema.Struct({\n version: Schema.optionalKey(Schema.Never),\n runId: Event.RunId,\n stepKeyDigest: Event.DispatchId,\n attempt: Event.NonNegativeQuantity,\n tier: Schema.Literals([\"sealed\", \"compensable\", \"irreversible\"])\n })\n }),\n Schema.Struct({\n eventType: Schema.Literal(\"flows.engine.attempt-finished\"),\n payload: Schema.Struct({\n version: Schema.optionalKey(Schema.Never),\n runId: Event.RunId,\n stepKeyDigest: Event.DispatchId,\n attempt: Event.NonNegativeQuantity,\n state: Schema.Literals([\"succeeded\", \"failed\"])\n })\n })\n])\n\n/**\n * Decode current markers using their recorded lineage, without upgrading bytes.\n *\n * @category decoders\n * @since 1.0.0\n */\nexport const decodeCurrentAttempt = (input: unknown, consumer: Consumer) =>\n Effect.gen(function*() {\n const entry = yield* decodeRow(input)\n const marker = yield* Schema.decodeUnknownEffect(CurrentAttempt)(entry)\n const meta = yield* Schema.decodeUnknownEffect(Schema.Struct({ lineageId: Event.LineageId }))(entry.meta)\n if (\n entry.runId !== consumer.runId || marker.payload.runId !== entry.runId ||\n meta.lineageId !== consumer.lineageId || !consumer.sources.includes(entry.sourceId)\n ) {\n throw new EventError({\n code: \"foreign\",\n message: \"current attempt marker is outside the consumer scope\",\n cause: entry\n })\n }\n return { entry, marker, lineageId: meta.lineageId }\n }).pipe(Effect.catchCause((failure) => {\n const cause = Cause.squash(failure)\n return Effect.fail(\n cause instanceof EventError\n ? cause\n : new EventError({ code: \"malformed\", message: \"invalid current attempt marker\", cause })\n )\n }))\n\n/**\n * Where a declaration was written, as a durable record may carry it.\n *\n * Repo-relative by contract: a journal is read on machines that are not the\n * one that wrote it, so an absolute path is at best noise and at worst an\n * operator's home directory published into a run's history. A writer that\n * cannot make a path relative omits the field.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const DeclaredAt = Schema.Struct({\n path: Schema.NonEmptyString.check(Schema.makeFilter((value) => !value.startsWith(\"/\"))),\n line: Event.NonNegativeQuantity\n})\n\n/**\n * A root that names the whole filesystem, which is no root at all.\n *\n * `process.cwd()` is `\"/\"` for a host a launcher started outside any\n * directory, and relativizing against it would make every absolute path\n * \"relative\": an operator's home directory, minus one leading slash, written\n * into a run's permanent history. The empty string is the same statement, and\n * a Windows drive root (`C:` or `C:\\`) is the same statement again. @private\n */\nconst isFilesystemRoot = (root: string): boolean => root === \"\" || root === \"/\" || /^[A-Za-z]:[\\\\/]?$/.test(root)\n\n/**\n * A declaration path as {@link DeclaredAt} may carry it: relative to the\n * root, or nothing.\n *\n * It lives beside the schema that refuses an absolute path, because obeying\n * that refusal is the writer's one job and every writer obeys it the same\n * way. A path outside the root is omitted rather than recorded with `..`\n * segments, because a reader resolving those would have to know the root,\n * which is exactly the machine-specific fact this strips. A root that is the\n * filesystem itself strips nothing, so it is read as no root.\n *\n * @category accessors\n * @since 1.0.0\n */\nexport const relativePath = (root: string | undefined, path: string): string | undefined => {\n if (root === undefined || isFilesystemRoot(root) || path === \"\") return undefined\n const base = root.endsWith(\"/\") ? root : `${root}/`\n if (!path.startsWith(base)) return undefined\n const relative = path.slice(base.length)\n return relative === \"\" ? undefined : relative\n}\n\n/**\n * One node of the graph a run was driven from.\n *\n * `kind` is open text because the two executors name kinds differently and\n * both are true: the plan scheduler's node is a `step`, an `agent` or a\n * `merge`, while the interpreter's is the authoring variant it was observed\n * at. A closed union here would force one of them to lie.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const NodeSummary = Schema.Struct({\n id: Schema.NonEmptyString,\n kind: Schema.String,\n dependsOn: Schema.Array(Schema.NonEmptyString),\n tier: Schema.Literals([\"sealed\", \"compensable\", \"irreversible\"]),\n key: Schema.optionalKey(Schema.String),\n generation: Schema.optionalKey(Event.NonNegativeQuantity),\n action: Schema.optionalKey(Schema.String),\n effects: Schema.optionalKey(Schema.Json),\n declaredAt: Schema.optionalKey(DeclaredAt)\n})\n\n/**\n * One edge of that graph, with the reason the builder drew it.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const EdgeSummary = Schema.Struct({\n from: Schema.NonEmptyString,\n to: Schema.NonEmptyString,\n reason: Schema.Literals([\"value\", \"continuation\", \"failure\"])\n})\n\n/**\n * The immutable name of a tree a host read declaration sites out of.\n *\n * Exactly the forty lowercase hex digits the only producer emits: a jj\n * working-copy commit id, or a git commit for a tree that still matches one\n * (`SourceRevision.objectId`). It is narrowed here rather than left as text\n * because a reader puts it straight into a contents route's `?ref=`, and\n * `DeclaredAt` beside it refuses an absolute path for the same class of\n * reason: a field that only ever holds one shape should refuse the others at\n * the boundary rather than at whatever spawns a process downstream.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const SourceRevision = Schema.NonEmptyString.check(Schema.makeFilter((value) => /^[0-9a-f]{40}$/.test(value)))\n\n/**\n * The graph, or one page of it, carried beside a plan record.\n *\n * `edges` is optional because only one writer can answer it honestly. A plan\n * names its edges through each node's `dependsOn` and knows no reason for\n * them; an interpreter knows the reason it drew each one. A writer without\n * reasons omits the field rather than labelling every edge `value`.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const NodeGraph = Schema.Struct({\n nodes: Schema.Array(NodeSummary),\n edges: Schema.optionalKey(Schema.Array(EdgeSummary)),\n /**\n * The revision of the tree the nodes on this page were read out of.\n *\n * A `declaredAt` is a path and a line, and neither says which bytes were\n * at that line: a working tree moves, so the same path after an edit or a\n * branch switch is a different file. Only the writer can answer this \u2014\n * like the root a path is made relative to \u2014 so it travels with the page\n * the sites travel on, and a reader can ask for the file AT this revision\n * instead of whatever is on disk when they look.\n *\n * Optional because only a writer served out of a version-controlled tree\n * can name one. A writer that cannot says nothing, and a reader that has\n * nothing shows no code rather than code it cannot bind (D-068).\n */\n sourceRevision: Schema.optionalKey(SourceRevision)\n})\n\n/**\n * A plan was recorded and a run is about to be driven under it.\n *\n * `nodes` is the node COUNT the record has always carried. The node list\n * arrives beside it as `graph`, optional and paged, because a journal entry\n * has a byte bound: what does not fit follows as {@link SubgraphAppended}\n * pages rather than being clipped.\n *\n * Everything an executor cannot honestly answer is optional rather than\n * invented. The interpreter drives a graph with no plan id, no plan digest\n * and no store to record an outcome with, and saying so is the point of this\n * schema.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const PlanRecordedPayload = Schema.Struct({\n planId: Schema.optionalKey(Schema.NonEmptyString),\n flow: Schema.NonEmptyString,\n digest: Schema.optionalKey(Schema.String),\n baseDigest: Schema.optionalKey(Schema.String),\n generation: Event.NonNegativeQuantity,\n nodes: Event.NonNegativeQuantity,\n outcome: Schema.optionalKey(Schema.String),\n page: Schema.optionalKey(Event.NonNegativeQuantity),\n pages: Schema.optionalKey(Event.NonNegativeQuantity),\n graph: Schema.optionalKey(NodeGraph)\n})\n\n/**\n * An elaboration appended a pre-keyed subgraph to the same plan, or the next\n * page of a graph too large for one record.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const SubgraphAppendedPayload = Schema.Struct({\n planId: Schema.optionalKey(Schema.NonEmptyString),\n flow: Schema.optionalKey(Schema.NonEmptyString),\n digest: Schema.optionalKey(Schema.String),\n baseDigest: Schema.optionalKey(Schema.String),\n generation: Event.NonNegativeQuantity,\n nodeIds: Schema.Array(Schema.NonEmptyString),\n page: Schema.optionalKey(Event.NonNegativeQuantity),\n pages: Schema.optionalKey(Event.NonNegativeQuantity),\n graph: Schema.optionalKey(NodeGraph)\n})\n\n/**\n * A plan node was admitted and its work is about to start.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const NodeScheduledPayload = Schema.Struct({\n planId: Schema.optionalKey(Schema.NonEmptyString),\n nodeId: Schema.NonEmptyString,\n kind: Schema.String,\n planKey: Schema.optionalKey(Schema.String),\n dispatchKey: Schema.optionalKey(Schema.String),\n attempt: Event.PositiveQuantity,\n priority: Schema.optionalKey(Schema.Int),\n waited: Schema.optionalKey(Event.NonNegativeQuantity),\n action: Schema.optionalKey(Schema.String)\n})\n\n/**\n * A bounded look at what a node settled with.\n *\n * `preview` is JSON text, redacted before it was encoded and cut to a fixed\n * ceiling afterwards, so a long value costs a durable row a known number of\n * bytes rather than however many it happens to hold. `truncated` says the cut\n * happened, which is also the warning that the text is a PREFIX of JSON and\n * no longer parses. `bytes` is the size of the encoding the preview was cut\n * from, so a reader can say how much was left out without being shown it; a\n * value too large for a writer to redact at all is named by the size of its\n * own encoding, with an empty preview and the flag set.\n *\n * Redaction comes first and truncation second on purpose: cutting the text\n * first can split a credential across the boundary, and a textual redactor\n * scanning the remains would no longer recognise it.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const NodeResultSummary = Schema.Struct({\n preview: Schema.String,\n bytes: Event.NonNegativeQuantity,\n truncated: Schema.Boolean\n})\n\n/**\n * A plan node reached an outcome.\n *\n * The outcomes are Skyframe's evaluation states: `built` ran,\n * `clean` was served from records, `failed` raised, `skipped` was never\n * reached, and `deferred` is a scheduling debt the plan scheduler alone\n * records.\n *\n * `attempts` is the executor's own count. For the plan scheduler it is the\n * node's; for the interpreter it is the highest durable attempt any of this\n * node's dispatches ran as, because the interpreter settles each node once\n * and a retry happens underneath it inside one dispatch.\n *\n * `stepKeyDigests` names the dispatches the node drove, and it is the join\n * `flows.engine.attempt-started` could not make on its own: an attempt record\n * carries a step key digest and no node id, so an attempt belongs to the node\n * whose settlement claims its digest. A retried dispatch keeps ONE digest \u2014\n * the attempt is folded into no key \u2014 so the list is distinct dispatches, not\n * attempts. A writer that derives no digests omits the field; a node that\n * dispatched nothing records an empty list, which is a different statement.\n *\n * `result` is what the node settled with: the success value for `built` and\n * `clean`, the typed failure for `failed`, bounded and redacted by the writer.\n * Absent when the writer kept none.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const NodeSettledPayload = Schema.Struct({\n planId: Schema.optionalKey(Schema.NonEmptyString),\n nodeId: Schema.NonEmptyString,\n planKey: Schema.optionalKey(Schema.String),\n dispatchKey: Schema.optionalKey(Schema.String),\n stepKeyDigests: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),\n outcome: Schema.Literals([\"built\", \"clean\", \"failed\", \"skipped\", \"deferred\"]),\n attempts: Event.NonNegativeQuantity,\n rebases: Schema.optionalKey(Event.NonNegativeQuantity),\n action: Schema.optionalKey(Schema.String),\n result: Schema.optionalKey(NodeResultSummary)\n})\n\n/**\n * A scheduled node's dispatch identity was invalidated and re-keyed.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const NodeInvalidatedPayload = Schema.Struct({\n planId: Schema.NonEmptyString,\n nodeId: Schema.NonEmptyString,\n planKey: Schema.String,\n from: Schema.String,\n to: Schema.String,\n reason: Schema.Literal(\"measured-inputs-changed\")\n})\n\n/**\n * The reconciliation seam returned a verdict for a deviation.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const NodeReconciledPayload = Schema.Struct({\n planId: Schema.NonEmptyString,\n nodeId: Schema.NonEmptyString,\n trigger: Schema.String,\n verdict: Schema.Json\n})\n\n/**\n * Where a declaration was written, as a durable record carries it.\n *\n * @category models\n * @since 1.0.0\n */\nexport type DeclaredAt = typeof DeclaredAt.Type\n\n/**\n * One node of the graph a run was driven from.\n *\n * @category models\n * @since 1.0.0\n */\nexport type NodeSummary = typeof NodeSummary.Type\n\n/**\n * One edge of the graph a run was driven from.\n *\n * @category models\n * @since 1.0.0\n */\nexport type EdgeSummary = typeof EdgeSummary.Type\n\n/**\n * The graph, or one page of it, carried beside a plan record.\n *\n * @category models\n * @since 1.0.0\n */\nexport type NodeGraph = typeof NodeGraph.Type\n\n/**\n * A plan was recorded and a run is about to be driven under it.\n *\n * @category models\n * @since 1.0.0\n */\nexport type PlanRecordedPayload = typeof PlanRecordedPayload.Type\n\n/**\n * An elaboration appended a subgraph, or the next page of a large graph.\n *\n * @category models\n * @since 1.0.0\n */\nexport type SubgraphAppendedPayload = typeof SubgraphAppendedPayload.Type\n\n/**\n * A plan node was admitted and its work is about to start.\n *\n * @category models\n * @since 1.0.0\n */\nexport type NodeScheduledPayload = typeof NodeScheduledPayload.Type\n\n/**\n * A bounded look at what a node settled with.\n *\n * @category models\n * @since 1.0.0\n */\nexport type NodeResultSummary = typeof NodeResultSummary.Type\n\n/**\n * A plan node reached an outcome.\n *\n * @category models\n * @since 1.0.0\n */\nexport type NodeSettledPayload = typeof NodeSettledPayload.Type\n\n/**\n * A scheduled node's dispatch identity was invalidated and re-keyed.\n *\n * @category models\n * @since 1.0.0\n */\nexport type NodeInvalidatedPayload = typeof NodeInvalidatedPayload.Type\n\n/**\n * The reconciliation seam's verdict for one deviation.\n *\n * @category models\n * @since 1.0.0\n */\nexport type NodeReconciledPayload = typeof NodeReconciledPayload.Type\n\n/**\n * The event type each node and plan payload is recorded under.\n *\n * Readers and writers share these identities, so a value here is stored\n * history and changing one requires migrating it.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const nodeEventTypes = {\n planRecorded: \"flows.engine.plan-recorded\",\n subgraphAppended: \"flows.engine.subgraph-appended\",\n nodeScheduled: \"flows.engine.node-scheduled\",\n nodeSettled: \"flows.engine.node-settled\",\n nodeInvalidated: \"flows.engine.node-invalidated\",\n nodeReconciled: \"flows.engine.node-reconciled\"\n} as const\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,YAAuB;AACvB,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AAQhB,MAAM,UAAU,OAAO,MAAM;AAAA,EAClC,OAAO,OAAO;AAAA,IACZ,MAAM,OAAO,QAAQ,MAAM;AAAA,IAC3B,OAAO,MAAM;AAAA,IACb,WAAW,MAAM;AAAA,IACjB,WAAW,MAAM;AAAA,IACjB,OAAO,OAAO,QAAQ,CAAC;AAAA,IACvB,aAAa,OAAO;AAAA,EACtB,CAAC,EAAE,MAAM,OAAO,WAAW,CAAC,UAAU,MAAM,UAAU,MAAM,SAAS,CAAC;AAAA,EACtE,OAAO,OAAO;AAAA,IACZ,MAAM,OAAO,SAAS,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AA,MACnB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACA,SAAO,EAAE,OAAO,QAAQ,WAAW,KAAK,UAAU;AACpD,CAAC,EAAE,KAAK,OAAO,WAAW,CAAC,YAAY;AACrC,QAAM,QAAQ,MAAM,OAAO,OAAO;AAClC,SAAO,OAAO;AAAA,IACZ,iBAAiB,aACb,QACA,IAAI,WAAW,EAAE,MAAM,aAAa,SAAS,kCAAkC,MAAM,CAAC;AAAA,EAC5F;AACF,CAAC,CAAC;
|
|
4
|
+
"sourcesContent": ["/**\n * Versioned engine history contracts over the open journal. These schemas do\n * not change journal admission or make history the engine's recovery store.\n *\n * @since 1.0.0\n */\n\nimport * as Cause from \"effect/Cause\"\nimport * as Effect from \"effect/Effect\"\nimport * as Schema from \"effect/Schema\"\nimport * as Event from \"./JournalEvent.ts\"\n\n/**\n * Required lineage coordinates for a root or derived run.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Lineage = Schema.Union([\n Schema.Struct({\n kind: Schema.Literal(\"root\"),\n runId: Event.RunId,\n lineageId: Event.LineageId,\n rootRunId: Event.RunId,\n round: Schema.Literal(0),\n parentRunId: Schema.Null\n }).check(Schema.makeFilter((value) => value.runId === value.rootRunId)),\n Schema.Struct({\n kind: Schema.Literals([\"child\", \"fork\", \"continuation\"]),\n runId: Event.RunId,\n lineageId: Event.LineageId,\n rootRunId: Event.RunId,\n round: Event.NonNegativeQuantity,\n parentRunId: Event.RunId\n }).check(Schema.makeFilter((value) =>\n value.runId !== value.parentRunId && value.runId !== value.rootRunId &&\n (value.kind !== \"continuation\" || value.round > 0)\n ))\n])\n\n/**\n * Required lineage coordinates for a root or derived run.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Lineage = typeof Lineage.Type\n\n/**\n * Encoded values only: class instances must first pass their own codec.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Success = Schema.TaggedStruct(\"Success\", { value: Schema.Json })\n\n/**\n * Failure channels stay distinct, including interruption and encoding failure.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Failure = Schema.TaggedStruct(\"Failure\", {\n reason: Schema.Literals([\"error\", \"defect\", \"interrupted\", \"encoding\"]),\n detail: Schema.Json\n})\n\n/**\n * Encoded success or a classified failure.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const ResultEnvelope = Schema.Union([Success, Failure])\n/**\n * Encoded success or a classified failure.\n *\n * @category models\n * @since 1.0.0\n */\nexport type ResultEnvelope = typeof ResultEnvelope.Type\n\nconst timing = { startedAtMs: Event.TimestampMs }\nconst live = {\n ...timing,\n heartbeatAtMs: Schema.optionalKey(Event.TimestampMs),\n checkpoint: Schema.optionalKey(Schema.Json),\n finishedAtMs: Schema.optionalKey(Schema.Never),\n result: Schema.optionalKey(Schema.Never)\n}\n\n/**\n * Completion and its outcome are inseparable; live states cannot carry either.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const AttemptLifecycle = Schema.Union([\n Schema.Struct({ state: Schema.Literal(\"running\"), ...live }),\n Schema.Struct({ state: Schema.Literal(\"suspended\"), ...live }),\n Schema.Struct({\n state: Schema.Literal(\"succeeded\"),\n ...timing,\n finishedAtMs: Event.TimestampMs,\n result: Success\n }),\n Schema.Struct({\n state: Schema.Literal(\"failed\"),\n ...timing,\n finishedAtMs: Event.TimestampMs,\n result: Failure\n })\n])\n\n/**\n * Wall clocks can move backwards; completion need not be after start.\n *\n * @category models\n * @since 1.0.0\n */\nexport type AttemptLifecycle = typeof AttemptLifecycle.Type\n\n/**\n * Complete identity and state of one versioned attempt event.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const AttemptPayload = Schema.Struct({\n version: Schema.Literal(2),\n lineage: Lineage,\n executionId: Event.RunId,\n stepKeyDigest: Event.DispatchId,\n attempt: Event.NonNegativeQuantity,\n lifecycle: AttemptLifecycle\n}).check(Schema.makeFilter((value) => value.executionId === value.lineage.runId))\n\n/**\n * Complete identity and state of one versioned attempt event.\n *\n * @category models\n * @since 1.0.0\n */\nexport type AttemptPayload = typeof AttemptPayload.Type\n\n/**\n * Durable wait identities; ownership and cancellation remain independent facts.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const Wait = Schema.Union([\n Schema.TaggedStruct(\"Deferred\", { waitId: Event.WaitId }),\n Schema.TaggedStruct(\"Clock\", { waitId: Event.WaitId, dueAtMs: Event.TimestampMs })\n])\n\n/**\n * A complete execution observation, without operational ownership leases.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const ExecutionLifecycle = Schema.Union([\n Schema.Struct({ state: Schema.Literal(\"running\"), waits: Schema.Array(Wait) }),\n Schema.Struct({ state: Schema.Literal(\"suspended\"), waits: Schema.NonEmptyArray(Wait) }),\n Schema.Struct({ state: Schema.Literal(\"completed\"), result: ResultEnvelope })\n])\n\n/**\n * Versioned execution, deferred and clock observations. Every variant records\n * its semantic identity and encoded value independently of diagnostics.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const StatePayload = Schema.Struct({\n version: Schema.Literal(2),\n lineage: Lineage,\n executionId: Event.RunId,\n event: Schema.Union([\n Schema.TaggedStruct(\"Execution\", { lifecycle: ExecutionLifecycle }),\n Schema.TaggedStruct(\"DeferredCompleted\", { waitId: Event.WaitId, result: ResultEnvelope }),\n Schema.TaggedStruct(\"ClockScheduled\", {\n clockId: Event.CommandId,\n waitId: Event.WaitId,\n dueAtMs: Event.TimestampMs\n })\n ])\n}).check(Schema.makeFilter((value) => value.executionId === value.lineage.runId))\n\n/**\n * Versioned execution, deferred and clock observations.\n *\n * @category models\n * @since 1.0.0\n */\nexport type StatePayload = typeof StatePayload.Type\n\n/**\n * Event family for complete execution, deferred and clock observations.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const stateEventType = \"flows.engine.v2.state-event\"\n\n/**\n * New identity prevents old readers mistaking complete state for historical markers.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const attemptEventType = \"flows.engine.v2.attempt-lifecycle\"\n\n/**\n * Malformed, foreign, unsupported or inconsistent event evidence.\n *\n * @category errors\n * @since 1.0.0\n */\nexport class EventError extends Schema.TaggedError<EventError>()(\"@smthrs/journal/EngineEventError\", {\n code: Schema.Literals([\"malformed\", \"unsupported\", \"foreign\", \"transition\"]),\n message: Schema.String,\n cause: Schema.Unknown\n}) {}\n\n/**\n * Every consumer chooses its source allowlist and unknown-namespace policy.\n *\n * @category models\n * @since 1.0.0\n */\nexport interface Consumer {\n readonly runId: Event.RunId\n readonly lineageId: Event.LineageId\n readonly rootRunId: Event.RunId\n readonly round: number\n readonly parentRunId: Event.RunId | null\n readonly sources: ReadonlyArray<Event.SourceId>\n readonly unknown: \"ignore\" | \"surface\"\n}\n\n/**\n * A known event or the explicitly selected extension outcome.\n *\n * @category models\n * @since 1.0.0\n */\nexport type Decoded =\n | { readonly _tag: \"Attempt\"; readonly entry: Event.Entry; readonly payload: AttemptPayload }\n | { readonly _tag: \"State\"; readonly entry: Event.Entry; readonly payload: StatePayload }\n | { readonly _tag: \"Ignored\" }\n | { readonly _tag: \"Unknown\"; readonly entry: Event.Entry }\n\nconst strict = { onExcessProperty: \"error\" } as const\nconst decodeRow = (input: unknown) =>\n Effect.gen(function*() {\n const raw = yield* Schema.decodeUnknownEffect(Schema.toEncoded(Event.Entry))(input)\n return yield* Schema.decodeUnknownEffect(Event.Entry)(raw)\n })\nconst decodePayload = Schema.decodeUnknownSync(AttemptPayload, strict)\nconst decodeJson = Schema.decodeUnknownSync(Schema.Json)\n\n/**\n * Decode untrusted committed input. Unknown events in the known engine namespace\n * are unsupported errors, never ignored. Original schema/accessor errors stay\n * in cause; foreign identity includes the conflicting evidence in cause.\n *\n * @category decoders\n * @since 1.0.0\n */\nexport const decodeEntry = (input: unknown, consumer: Consumer): Effect.Effect<Decoded, EventError> =>\n Effect.gen(function*(): Effect.fn.Return<Decoded, unknown> {\n const entry = yield* decodeRow(input)\n if (entry.runId !== consumer.runId || !consumer.sources.includes(entry.sourceId)) {\n throw new EventError({\n code: \"foreign\",\n message: \"event run or source is outside the consumer scope\",\n cause: entry\n })\n }\n if (entry.eventType !== attemptEventType && entry.eventType !== stateEventType) {\n if (entry.eventType.startsWith(\"flows.engine.\")) {\n throw new EventError({\n code: \"unsupported\",\n message: \"unsupported engine event family or version\",\n cause: entry\n })\n }\n return consumer.unknown === \"ignore\" ? { _tag: \"Ignored\" } : { _tag: \"Unknown\", entry }\n }\n const decoded = entry.eventType === attemptEventType\n ? { _tag: \"Attempt\" as const, payload: yield* Schema.decodeUnknownEffect(AttemptPayload, strict)(entry.payload) }\n : { _tag: \"State\" as const, payload: yield* Schema.decodeUnknownEffect(StatePayload, strict)(entry.payload) }\n const { payload } = decoded\n if (\n payload.lineage.runId !== entry.runId || payload.lineage.lineageId !== consumer.lineageId ||\n payload.lineage.rootRunId !== consumer.rootRunId || payload.lineage.round !== consumer.round ||\n payload.lineage.parentRunId !== consumer.parentRunId\n ) {\n throw new EventError({\n code: \"foreign\",\n message: \"event lineage disagrees with its journal or consumer\",\n cause: payload.lineage\n })\n }\n // The optional journal side channel is disclosure only. Semantic lineage\n // lives in payload and cannot be replaced by diagnostic metadata.\n yield* Schema.decodeUnknownEffect(Schema.Json)(entry.meta)\n return { ...decoded, entry }\n }).pipe(Effect.catchCause((failure) => {\n const cause = Cause.squash(failure)\n return Effect.fail(\n cause instanceof EventError\n ? cause\n : new EventError({ code: \"malformed\", message: \"invalid engine event\", cause })\n )\n }))\n\n/**\n * Construct a versioned submission, validating before journal redaction.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const attempt = (\n payload: AttemptPayload,\n sourceId: Event.SourceId,\n sourceSeq: Event.SourceSeq,\n diagnostics: Schema.Json = null\n): Event.Input => {\n const validated = decodePayload(payload)\n return new Event.Input({\n runId: validated.lineage.runId,\n sourceId,\n sourceSeq,\n eventType: attemptEventType,\n payload: validated,\n meta: decodeJson(diagnostics)\n })\n}\n\n/**\n * Construct a versioned execution, deferred or clock submission. Existing\n * unversioned writers are unchanged and cannot manufacture missing lineage.\n *\n * @category constructors\n * @since 1.0.0\n */\nexport const stateEvent = (\n payload: StatePayload,\n sourceId: Event.SourceId,\n sourceSeq: Event.SourceSeq,\n diagnostics: Schema.Json = null\n): Event.Input => {\n const validated = Schema.decodeUnknownSync(StatePayload, strict)(payload)\n return new Event.Input({\n runId: validated.lineage.runId,\n sourceId,\n sourceSeq,\n eventType: stateEventType,\n payload: validated,\n meta: decodeJson(diagnostics)\n })\n}\n\n/**\n * Historical attempt markers deliberately remain incomplete evidence. No\n * result, timestamp, round or lineage root is invented for old rows.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const CurrentAttempt = Schema.Union([\n Schema.Struct({\n eventType: Schema.Literal(\"flows.engine.attempt-started\"),\n payload: Schema.Struct({\n version: Schema.optionalKey(Schema.Never),\n runId: Event.RunId,\n stepKeyDigest: Event.DispatchId,\n attempt: Event.NonNegativeQuantity,\n tier: Schema.Literals([\"sealed\", \"compensable\", \"irreversible\"])\n })\n }),\n Schema.Struct({\n eventType: Schema.Literal(\"flows.engine.attempt-finished\"),\n payload: Schema.Struct({\n version: Schema.optionalKey(Schema.Never),\n runId: Event.RunId,\n stepKeyDigest: Event.DispatchId,\n attempt: Event.NonNegativeQuantity,\n state: Schema.Literals([\"succeeded\", \"failed\"])\n })\n })\n])\n\n/**\n * Decode current markers using their recorded lineage, without upgrading bytes.\n *\n * @category decoders\n * @since 1.0.0\n */\nexport const decodeCurrentAttempt = (input: unknown, consumer: Consumer) =>\n Effect.gen(function*() {\n const entry = yield* decodeRow(input)\n const marker = yield* Schema.decodeUnknownEffect(CurrentAttempt)(entry)\n const meta = yield* Schema.decodeUnknownEffect(Schema.Struct({ lineageId: Event.LineageId }))(entry.meta)\n if (\n entry.runId !== consumer.runId || marker.payload.runId !== entry.runId ||\n meta.lineageId !== consumer.lineageId || !consumer.sources.includes(entry.sourceId)\n ) {\n throw new EventError({\n code: \"foreign\",\n message: \"current attempt marker is outside the consumer scope\",\n cause: entry\n })\n }\n return { entry, marker, lineageId: meta.lineageId }\n }).pipe(Effect.catchCause((failure) => {\n const cause = Cause.squash(failure)\n return Effect.fail(\n cause instanceof EventError\n ? cause\n : new EventError({ code: \"malformed\", message: \"invalid current attempt marker\", cause })\n )\n }))\n\n/** A portable path never identifies a host or escapes the repository root. */\nconst isRepoRelativePath = (path: string): boolean =>\n path !== \"\" && !/^(?:[/\\\\~]|[A-Za-z][A-Za-z\\d+.-]*:)/.test(path) && !path.split(/[\\\\/]/).includes(\"..\")\n\n/**\n * Where a declaration was written, as a durable record may carry it.\n *\n * Repo-relative by contract: a journal is read on machines that are not the\n * one that wrote it, so an absolute path is at best noise and at worst an\n * operator's home directory published into a run's history. A writer that\n * cannot make a path relative omits the field.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const DeclaredAt = Schema.Struct({\n path: Schema.NonEmptyString.check(Schema.makeFilter(isRepoRelativePath)),\n line: Event.NonNegativeQuantity\n})\n\n/**\n * A root that names the whole filesystem, which is no root at all.\n *\n * `process.cwd()` is `\"/\"` for a host a launcher started outside any\n * directory, and relativizing against it would make every absolute path\n * \"relative\": an operator's home directory, minus one leading slash, written\n * into a run's permanent history. The empty string is the same statement, and\n * a Windows drive root (`C:` or `C:\\`) is the same statement again. @private\n */\nconst isFilesystemRoot = (root: string): boolean => root === \"\" || root === \"/\" || /^[A-Za-z]:[\\\\/]?$/.test(root)\n\n/**\n * A declaration path as {@link DeclaredAt} may carry it: relative to the\n * root, or nothing.\n *\n * It lives beside the schema that refuses an absolute path, because obeying\n * that refusal is the writer's one job and every writer obeys it the same\n * way. A path outside the root is omitted rather than recorded with `..`\n * segments, because a reader resolving those would have to know the root,\n * which is exactly the machine-specific fact this strips. A root that is the\n * filesystem itself strips nothing, so it is read as no root.\n *\n * @category accessors\n * @since 1.0.0\n */\nexport const relativePath = (root: string | undefined, path: string): string | undefined => {\n if (root === undefined || isFilesystemRoot(root) || path === \"\") return undefined\n const base = root.endsWith(\"/\") ? root : `${root}/`\n if (!path.startsWith(base)) return undefined\n const relative = path.slice(base.length)\n return isRepoRelativePath(relative) ? relative : undefined\n}\n\n/**\n * One node of the graph a run was driven from.\n *\n * `kind` is open text because the two executors name kinds differently and\n * both are true: the plan scheduler's node is a `step`, an `agent` or a\n * `merge`, while the interpreter's is the authoring variant it was observed\n * at. A closed union here would force one of them to lie.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const NodeSummary = Schema.Struct({\n id: Schema.NonEmptyString,\n kind: Schema.String,\n dependsOn: Schema.Array(Schema.NonEmptyString),\n tier: Schema.Literals([\"sealed\", \"compensable\", \"irreversible\"]),\n key: Schema.optionalKey(Schema.String),\n generation: Schema.optionalKey(Event.NonNegativeQuantity),\n action: Schema.optionalKey(Schema.String),\n effects: Schema.optionalKey(Schema.Json),\n declaredAt: Schema.optionalKey(DeclaredAt)\n})\n\n/**\n * One edge of that graph, with the reason the builder drew it.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const EdgeSummary = Schema.Struct({\n from: Schema.NonEmptyString,\n to: Schema.NonEmptyString,\n reason: Schema.Literals([\"value\", \"continuation\", \"failure\"])\n})\n\n/**\n * The immutable name of a tree a host read declaration sites out of.\n *\n * Exactly the forty lowercase hex digits the only producer emits: a jj\n * working-copy commit id, or a git commit for a tree that still matches one\n * (`SourceRevision.objectId`). It is narrowed here rather than left as text\n * because a reader puts it straight into a contents route's `?ref=`, and\n * `DeclaredAt` beside it refuses an absolute path for the same class of\n * reason: a field that only ever holds one shape should refuse the others at\n * the boundary rather than at whatever spawns a process downstream.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const SourceRevision = Schema.NonEmptyString.check(Schema.makeFilter((value) => /^[0-9a-f]{40}$/.test(value)))\n\n/**\n * The graph, or one page of it, carried beside a plan record.\n *\n * `edges` is optional because only one writer can answer it honestly. A plan\n * names its edges through each node's `dependsOn` and knows no reason for\n * them; an interpreter knows the reason it drew each one. A writer without\n * reasons omits the field rather than labelling every edge `value`.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const NodeGraph = Schema.Struct({\n nodes: Schema.Array(NodeSummary),\n edges: Schema.optionalKey(Schema.Array(EdgeSummary)),\n /**\n * The revision of the tree the nodes on this page were read out of.\n *\n * A `declaredAt` is a path and a line, and neither says which bytes were\n * at that line: a working tree moves, so the same path after an edit or a\n * branch switch is a different file. Only the writer can answer this \u2014\n * like the root a path is made relative to \u2014 so it travels with the page\n * the sites travel on, and a reader can ask for the file AT this revision\n * instead of whatever is on disk when they look.\n *\n * Optional because only a writer served out of a version-controlled tree\n * can name one. A writer that cannot says nothing, and a reader that has\n * nothing shows no code rather than code it cannot bind (D-068).\n */\n sourceRevision: Schema.optionalKey(SourceRevision)\n})\n\n/**\n * A plan was recorded and a run is about to be driven under it.\n *\n * `nodes` is the node COUNT the record has always carried. The node list\n * arrives beside it as `graph`, optional and paged, because a journal entry\n * has a byte bound: what does not fit follows as {@link SubgraphAppended}\n * pages rather than being clipped.\n *\n * Everything an executor cannot honestly answer is optional rather than\n * invented. The interpreter drives a graph with no plan id, no plan digest\n * and no store to record an outcome with, and saying so is the point of this\n * schema.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const PlanRecordedPayload = Schema.Struct({\n planId: Schema.optionalKey(Schema.NonEmptyString),\n flow: Schema.NonEmptyString,\n digest: Schema.optionalKey(Schema.String),\n baseDigest: Schema.optionalKey(Schema.String),\n generation: Event.NonNegativeQuantity,\n nodes: Event.NonNegativeQuantity,\n outcome: Schema.optionalKey(Schema.String),\n page: Schema.optionalKey(Event.NonNegativeQuantity),\n pages: Schema.optionalKey(Event.NonNegativeQuantity),\n graph: Schema.optionalKey(NodeGraph)\n})\n\n/**\n * An elaboration appended a pre-keyed subgraph to the same plan, or the next\n * page of a graph too large for one record.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const SubgraphAppendedPayload = Schema.Struct({\n planId: Schema.optionalKey(Schema.NonEmptyString),\n flow: Schema.optionalKey(Schema.NonEmptyString),\n digest: Schema.optionalKey(Schema.String),\n baseDigest: Schema.optionalKey(Schema.String),\n generation: Event.NonNegativeQuantity,\n nodeIds: Schema.Array(Schema.NonEmptyString),\n page: Schema.optionalKey(Event.NonNegativeQuantity),\n pages: Schema.optionalKey(Event.NonNegativeQuantity),\n graph: Schema.optionalKey(NodeGraph)\n})\n\n/**\n * A plan node was admitted and its work is about to start.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const NodeScheduledPayload = Schema.Struct({\n planId: Schema.optionalKey(Schema.NonEmptyString),\n nodeId: Schema.NonEmptyString,\n kind: Schema.String,\n planKey: Schema.optionalKey(Schema.String),\n dispatchKey: Schema.optionalKey(Schema.String),\n attempt: Event.PositiveQuantity,\n priority: Schema.optionalKey(Schema.Int),\n waited: Schema.optionalKey(Event.NonNegativeQuantity),\n action: Schema.optionalKey(Schema.String)\n})\n\n/**\n * A bounded look at what a node settled with.\n *\n * `preview` is JSON text, redacted before it was encoded and cut to a fixed\n * ceiling afterwards, so a long value costs a durable row a known number of\n * bytes rather than however many it happens to hold. `truncated` says the cut\n * happened, which is also the warning that the text is a PREFIX of JSON and\n * no longer parses. `bytes` is the size of the encoding the preview was cut\n * from, so a reader can say how much was left out without being shown it; a\n * value too large for a writer to redact at all is named by the size of its\n * own encoding, with an empty preview and the flag set.\n *\n * Redaction comes first and truncation second on purpose: cutting the text\n * first can split a credential across the boundary, and a textual redactor\n * scanning the remains would no longer recognise it.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const NodeResultSummary = Schema.Struct({\n preview: Schema.String,\n bytes: Event.NonNegativeQuantity,\n truncated: Schema.Boolean\n})\n\n/**\n * A plan node reached an outcome.\n *\n * The outcomes are Skyframe's evaluation states: `built` ran,\n * `clean` was served from records, `failed` raised, `skipped` was never\n * reached, and `deferred` is a scheduling debt the plan scheduler alone\n * records.\n *\n * `attempts` is the executor's own count. For the plan scheduler it is the\n * node's; for the interpreter it is the highest durable attempt any of this\n * node's dispatches ran as, because the interpreter settles each node once\n * and a retry happens underneath it inside one dispatch.\n *\n * `stepKeyDigests` names the dispatches the node drove, and it is the join\n * `flows.engine.attempt-started` could not make on its own: an attempt record\n * carries a step key digest and no node id, so an attempt belongs to the node\n * whose settlement claims its digest. A retried dispatch keeps ONE digest \u2014\n * the attempt is folded into no key \u2014 so the list is distinct dispatches, not\n * attempts. A writer that derives no digests omits the field; a node that\n * dispatched nothing records an empty list, which is a different statement.\n *\n * `result` is what the node settled with: the success value for `built` and\n * `clean`, the typed failure for `failed`, bounded and redacted by the writer.\n * Absent when the writer kept none.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const NodeSettledPayload = Schema.Struct({\n planId: Schema.optionalKey(Schema.NonEmptyString),\n nodeId: Schema.NonEmptyString,\n planKey: Schema.optionalKey(Schema.String),\n dispatchKey: Schema.optionalKey(Schema.String),\n stepKeyDigests: Schema.optionalKey(Schema.Array(Schema.NonEmptyString)),\n outcome: Schema.Literals([\"built\", \"clean\", \"failed\", \"skipped\", \"deferred\"]),\n attempts: Event.NonNegativeQuantity,\n rebases: Schema.optionalKey(Event.NonNegativeQuantity),\n action: Schema.optionalKey(Schema.String),\n result: Schema.optionalKey(NodeResultSummary)\n})\n\n/**\n * A scheduled node's dispatch identity was invalidated and re-keyed.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const NodeInvalidatedPayload = Schema.Struct({\n planId: Schema.NonEmptyString,\n nodeId: Schema.NonEmptyString,\n planKey: Schema.String,\n from: Schema.String,\n to: Schema.String,\n reason: Schema.Literal(\"measured-inputs-changed\")\n})\n\n/**\n * The reconciliation seam returned a verdict for a deviation.\n *\n * @category schemas\n * @since 1.0.0\n */\nexport const NodeReconciledPayload = Schema.Struct({\n planId: Schema.NonEmptyString,\n nodeId: Schema.NonEmptyString,\n trigger: Schema.String,\n verdict: Schema.Json\n})\n\n/**\n * Where a declaration was written, as a durable record carries it.\n *\n * @category models\n * @since 1.0.0\n */\nexport type DeclaredAt = typeof DeclaredAt.Type\n\n/**\n * One node of the graph a run was driven from.\n *\n * @category models\n * @since 1.0.0\n */\nexport type NodeSummary = typeof NodeSummary.Type\n\n/**\n * One edge of the graph a run was driven from.\n *\n * @category models\n * @since 1.0.0\n */\nexport type EdgeSummary = typeof EdgeSummary.Type\n\n/**\n * The graph, or one page of it, carried beside a plan record.\n *\n * @category models\n * @since 1.0.0\n */\nexport type NodeGraph = typeof NodeGraph.Type\n\n/**\n * A plan was recorded and a run is about to be driven under it.\n *\n * @category models\n * @since 1.0.0\n */\nexport type PlanRecordedPayload = typeof PlanRecordedPayload.Type\n\n/**\n * An elaboration appended a subgraph, or the next page of a large graph.\n *\n * @category models\n * @since 1.0.0\n */\nexport type SubgraphAppendedPayload = typeof SubgraphAppendedPayload.Type\n\n/**\n * A plan node was admitted and its work is about to start.\n *\n * @category models\n * @since 1.0.0\n */\nexport type NodeScheduledPayload = typeof NodeScheduledPayload.Type\n\n/**\n * A bounded look at what a node settled with.\n *\n * @category models\n * @since 1.0.0\n */\nexport type NodeResultSummary = typeof NodeResultSummary.Type\n\n/**\n * A plan node reached an outcome.\n *\n * @category models\n * @since 1.0.0\n */\nexport type NodeSettledPayload = typeof NodeSettledPayload.Type\n\n/**\n * A scheduled node's dispatch identity was invalidated and re-keyed.\n *\n * @category models\n * @since 1.0.0\n */\nexport type NodeInvalidatedPayload = typeof NodeInvalidatedPayload.Type\n\n/**\n * The reconciliation seam's verdict for one deviation.\n *\n * @category models\n * @since 1.0.0\n */\nexport type NodeReconciledPayload = typeof NodeReconciledPayload.Type\n\n/**\n * The event type each node and plan payload is recorded under.\n *\n * Readers and writers share these identities, so a value here is stored\n * history and changing one requires migrating it.\n *\n * @category constants\n * @since 1.0.0\n */\nexport const nodeEventTypes = {\n planRecorded: \"flows.engine.plan-recorded\",\n subgraphAppended: \"flows.engine.subgraph-appended\",\n nodeScheduled: \"flows.engine.node-scheduled\",\n nodeSettled: \"flows.engine.node-settled\",\n nodeInvalidated: \"flows.engine.node-invalidated\",\n nodeReconciled: \"flows.engine.node-reconciled\"\n} as const\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;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Schema.NullOr<Schema.brand<Schema.Int, "@smthrs/journal/TimestampMs">>;
|
|
26
26
|
readonly tokenDigest: Schema.NullOr<Schema.NonEmptyString>;
|
|
27
27
|
readonly point: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
28
|
-
readonly request: Schema.optional<Schema.NullOr<
|
|
28
|
+
readonly request: Schema.optional<Schema.NullOr<(typeof Schema.Json)>>;
|
|
29
29
|
}>>;
|
|
30
30
|
}>;
|
|
31
31
|
/** The value form of a native execution observation.
|
|
@@ -58,7 +58,7 @@ export declare const Fact: Schema.Struct<{
|
|
|
58
58
|
readonly wakeAtMs: Schema.NullOr<Schema.brand<Schema.Int, "@smthrs/journal/TimestampMs">>;
|
|
59
59
|
readonly tokenDigest: Schema.NullOr<Schema.NonEmptyString>;
|
|
60
60
|
readonly point: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
61
|
-
readonly request: Schema.optional<Schema.NullOr<
|
|
61
|
+
readonly request: Schema.optional<Schema.NullOr<(typeof Schema.Json)>>;
|
|
62
62
|
}>>;
|
|
63
63
|
}>;
|
|
64
64
|
}>;
|
|
@@ -93,7 +93,7 @@ export declare const View: Schema.Struct<{
|
|
|
93
93
|
readonly wakeAtMs: Schema.NullOr<Schema.brand<Schema.Int, "@smthrs/journal/TimestampMs">>;
|
|
94
94
|
readonly tokenDigest: Schema.NullOr<Schema.NonEmptyString>;
|
|
95
95
|
readonly point: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
96
|
-
readonly request: Schema.optional<Schema.NullOr<
|
|
96
|
+
readonly request: Schema.optional<Schema.NullOr<(typeof Schema.Json)>>;
|
|
97
97
|
}>>;
|
|
98
98
|
}>;
|
|
99
99
|
readonly current: Schema.Struct<{
|
|
@@ -114,7 +114,7 @@ export declare const View: Schema.Struct<{
|
|
|
114
114
|
readonly wakeAtMs: Schema.NullOr<Schema.brand<Schema.Int, "@smthrs/journal/TimestampMs">>;
|
|
115
115
|
readonly tokenDigest: Schema.NullOr<Schema.NonEmptyString>;
|
|
116
116
|
readonly point: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
117
|
-
readonly request: Schema.optional<Schema.NullOr<
|
|
117
|
+
readonly request: Schema.optional<Schema.NullOr<(typeof Schema.Json)>>;
|
|
118
118
|
}>>;
|
|
119
119
|
}>;
|
|
120
120
|
/** Redacted display observations; opaque wake tokens are never journal authority. */
|
|
@@ -136,7 +136,7 @@ export declare const View: Schema.Struct<{
|
|
|
136
136
|
readonly wakeAtMs: Schema.NullOr<Schema.brand<Schema.Int, "@smthrs/journal/TimestampMs">>;
|
|
137
137
|
readonly tokenDigest: Schema.NullOr<Schema.NonEmptyString>;
|
|
138
138
|
readonly point: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
139
|
-
readonly request: Schema.optional<Schema.NullOr<
|
|
139
|
+
readonly request: Schema.optional<Schema.NullOr<(typeof Schema.Json)>>;
|
|
140
140
|
}>>;
|
|
141
141
|
}>>>;
|
|
142
142
|
}>;
|
package/dist/cjs/Journal.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @since 0.1.0
|
|
9
9
|
*/
|
|
10
|
+
import type { WriteOptions } from "@smthrs/database/DurableWriter";
|
|
10
11
|
import * as Context from "effect/Context";
|
|
11
12
|
import * as Effect from "effect/Effect";
|
|
12
13
|
import * as Layer from "effect/Layer";
|
|
@@ -243,7 +244,9 @@ export declare const maxEntriesLimit = 10000;
|
|
|
243
244
|
* `limit` is at most `maxEntriesLimit` (10,000 entries). Optional `eventTypes`
|
|
244
245
|
* selects a nonempty list of at most 64 exact types before pagination; cursors remain canonical run
|
|
245
246
|
* sequences and `hasMore` describes matching entries. Omit it for the full run.
|
|
246
|
-
* Filtering does not bypass the run's compaction floor.
|
|
247
|
+
* Filtering does not bypass the run's compaction floor. `order: "desc"`
|
|
248
|
+
* reads the newest matching entries first; the default is `"asc"`. In either
|
|
249
|
+
* order, `after` is an exclusive lower sequence bound, not a reverse cursor.
|
|
247
250
|
*
|
|
248
251
|
* @category models
|
|
249
252
|
* @since 0.1.0
|
|
@@ -251,6 +254,7 @@ export declare const maxEntriesLimit = 10000;
|
|
|
251
254
|
export declare const EntriesOptions: Schema.Struct<{
|
|
252
255
|
readonly runId: Schema.brand<Schema.String, "@smthrs/journal/JournalEvent/RunId">;
|
|
253
256
|
readonly after: Schema.optionalKey<Schema.brand<Schema.Int, "@smthrs/journal/JournalEvent/Seq">>;
|
|
257
|
+
readonly order: Schema.optionalKey<Schema.Literals<readonly ["asc", "desc"]>>;
|
|
254
258
|
readonly eventTypes: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
255
259
|
readonly limit: Schema.Int;
|
|
256
260
|
}>;
|
|
@@ -450,6 +454,17 @@ export interface Service {
|
|
|
450
454
|
readonly generation: number;
|
|
451
455
|
readonly afterSeq: number;
|
|
452
456
|
}, JournalError>) | undefined;
|
|
457
|
+
/**
|
|
458
|
+
* Committed tail and rewind generation for every requested run, read together
|
|
459
|
+
* in one snapshot per batch. Unknown runs have generation 0, afterSeq -1 and
|
|
460
|
+
* maxSeq null. Optional acceleration for readers; adapters may omit it.
|
|
461
|
+
*/
|
|
462
|
+
readonly heads?: ((runIds: ReadonlyArray<RunId>) => Effect.Effect<ReadonlyArray<{
|
|
463
|
+
readonly runId: RunId;
|
|
464
|
+
readonly generation: number;
|
|
465
|
+
readonly afterSeq: number;
|
|
466
|
+
readonly maxSeq: number | null;
|
|
467
|
+
}>, JournalError>) | undefined;
|
|
453
468
|
readonly emitLossy: (input: Input) => Effect.Effect<EmitReceipt, JournalError>;
|
|
454
469
|
readonly emitDurable: (input: Input, owner: OwnerId) => Effect.Effect<DurableReceipt, JournalError>;
|
|
455
470
|
/**
|
|
@@ -466,6 +481,62 @@ export interface Service {
|
|
|
466
481
|
* `fence_lost` is exactly the zombie write the fence exists to reject.
|
|
467
482
|
*/
|
|
468
483
|
readonly emitDurableUnfenced: (input: Input) => Effect.Effect<DurableReceipt, JournalError>;
|
|
484
|
+
/**
|
|
485
|
+
* Queues a fenced lifecycle entry to commit with its run's next durable
|
|
486
|
+
* write through this journal, instead of in a transaction of its own: the
|
|
487
|
+
* next `emitDurable`, `emitDurableUnfenced`, `checkpoint`, `compact` or
|
|
488
|
+
* `transact` that names the run's partition, or `flush`. Called inside an
|
|
489
|
+
* open transaction it writes at once, as `emitDurable` does.
|
|
490
|
+
*
|
|
491
|
+
* Its sequence is allocated when it commits, ahead of whatever that write
|
|
492
|
+
* appends, so the run's journal reads in the order its entries were
|
|
493
|
+
* emitted and never commits one behind a reader's cursor. It is fenced on
|
|
494
|
+
* `owner` when it commits: an owner that lost the run meanwhile loses what
|
|
495
|
+
* it queued, and learns so from its own next fenced write. Until it
|
|
496
|
+
* commits no reader sees it, and a process that dies first loses it, as it
|
|
497
|
+
* would lose an entry it had not emitted yet. Use it for records a later write of the same run always
|
|
498
|
+
* follows before anything outside the run depends on them, such as a
|
|
499
|
+
* scheduler's records before the attempt that acts on them.
|
|
500
|
+
*
|
|
501
|
+
* An entry the journal knows is committed with the same content (see
|
|
502
|
+
* `recorded`) is dropped rather than queued: the write would only collide
|
|
503
|
+
* with it. A resumed walk re-emits every record it already wrote, so this
|
|
504
|
+
* keeps a replay from writing at all.
|
|
505
|
+
*
|
|
506
|
+
* A queued entry refused permanently (for example an identity conflict or
|
|
507
|
+
* exhausted producer sequence) is dropped, logged and counted without
|
|
508
|
+
* failing the host write. The next `flush` reports the loss once, after
|
|
509
|
+
* writing the remaining entries; an earlier flush failure leaves this report
|
|
510
|
+
* pending. A rolled-back transaction retains its entries and reports no
|
|
511
|
+
* loss. SQL failures retain the batch for retry.
|
|
512
|
+
*
|
|
513
|
+
* Optional: a journal without it is used through `emitDurable`.
|
|
514
|
+
*/
|
|
515
|
+
readonly emitDeferred?: ((input: Input, owner: OwnerId) => Effect.Effect<void, JournalError>) | undefined;
|
|
516
|
+
/**
|
|
517
|
+
* Reads the run's committed entries, its latest ones up to what this
|
|
518
|
+
* journal keeps in memory, so that a re-emission of one is answered without
|
|
519
|
+
* a write: `emitDeferred` drops an identical one, and `recorded` reports
|
|
520
|
+
* it. A resumed run calls it once before it replays.
|
|
521
|
+
*
|
|
522
|
+
* Optional: a journal without it answers every re-emission with a write.
|
|
523
|
+
*/
|
|
524
|
+
readonly recall?: ((runId: RunId) => Effect.Effect<void, JournalError>) | undefined;
|
|
525
|
+
/**
|
|
526
|
+
* Whether this journal knows `input` is committed: an entry with its
|
|
527
|
+
* producer identity (`sourceId` and `sourceSeq`) and its content, from its
|
|
528
|
+
* own commits, its startup read or `recall`. It reads nothing. `false` means
|
|
529
|
+
* not known, never absent: an entry with no `sourceSeq` is a new entry every
|
|
530
|
+
* time, and an input the journal refuses is reported by its emit.
|
|
531
|
+
*
|
|
532
|
+
* A caller that knows an entry is committed may skip re-emitting it. The
|
|
533
|
+
* skip is not a fenced write: the owner that skips learns of a lost run from
|
|
534
|
+
* its next write, so skip only an emit whose caller then does nothing the
|
|
535
|
+
* fence guards, such as a replay answered from a recorded attempt.
|
|
536
|
+
*
|
|
537
|
+
* Optional: a journal without it knows nothing.
|
|
538
|
+
*/
|
|
539
|
+
readonly recorded?: ((input: Input) => Effect.Effect<boolean>) | undefined;
|
|
469
540
|
/**
|
|
470
541
|
* Runs `effect`, a state projection plus the `emitDurable` calls describing
|
|
471
542
|
* it, inside ONE write transaction.
|
|
@@ -494,8 +565,12 @@ export interface Service {
|
|
|
494
565
|
*
|
|
495
566
|
* Nesting is safe: an inner `transact` becomes a savepoint of the outer
|
|
496
567
|
* one and defers its publication to the outermost commit.
|
|
568
|
+
*
|
|
569
|
+
* `options.partition` names the partition the transaction writes, such as
|
|
570
|
+
* the run it advances (`DurableWriter.WriteOptions`): it then serializes
|
|
571
|
+
* only with that run's writers. Omitted, it serializes with every writer.
|
|
497
572
|
*/
|
|
498
|
-
readonly transact: <A, E, R>(effect: Effect.Effect<A, E, R
|
|
573
|
+
readonly transact: <A, E, R>(effect: Effect.Effect<A, E, R>, options?: WriteOptions | undefined) => Effect.Effect<A, E | JournalError, R>;
|
|
499
574
|
/**
|
|
500
575
|
* Publishes a short, non-failing process-local update after the current
|
|
501
576
|
* transaction commits, or immediately when no transaction is open.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Journal.d.ts","sourceRoot":"","sources":["../../src/Journal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAkB,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;;;;;GAOG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAE5D;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,+QAe3B,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAA;;;;;;;AAE3D;;;;;;;;;;GAUG;AACH,qBAAa,YAAa,SAAQ,iBAKhC;CAAG;AAEL;;;;;GAKG;AACH,eAAO,MAAM,cAAc,oEAA4D,CAAA;AAEvF;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAA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AO,CAAM,KAAG,OAuC3D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,YAAW,OAAO,CAAC,OAAO,CAAM,KAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CACnC,CAAA"}
|
package/dist/cjs/Journal.js
CHANGED
|
@@ -111,6 +111,7 @@ const maxEntriesLimit = 1e4;
|
|
|
111
111
|
const EntriesOptions = Schema.Struct({
|
|
112
112
|
runId: import_JournalEvent.RunId,
|
|
113
113
|
after: Schema.optionalKey(import_JournalEvent.Seq),
|
|
114
|
+
order: Schema.optionalKey(Schema.Literals(["asc", "desc"])),
|
|
114
115
|
eventTypes: Schema.optionalKey(
|
|
115
116
|
Schema.Array(import_JournalEvent.Entry.fields.eventType).check(Schema.isMinLength(1), Schema.isMaxLength(64))
|
|
116
117
|
),
|
package/dist/cjs/Journal.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Journal.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Logical journal contract with durable lifecycle and lossy telemetry channels.\n *\n * The ownership fence and the lossless `emitDurable` / lossy `emitLossy`\n * split are described at https://journal.smithers.sh/concepts/owner-fence/\n * and https://journal.smithers.sh/concepts/two-channels/.\n *\n * @since 0.1.0\n */\n\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\nimport type * as Option from \"effect/Option\"\nimport * as PubSub from \"effect/PubSub\"\nimport * as Schema from \"effect/Schema\"\nimport type * as Scope from \"effect/Scope\"\nimport * as Stream from \"effect/Stream\"\nimport { Entry, RunId, Seq, SourceSeq } from \"./JournalEvent.ts\"\nimport type { Input } from \"./JournalEvent.ts\"\nimport type { OwnerId } from \"./OwnerId.ts\"\nimport type { Projection } from \"./Projection.ts\"\n\n/**\n * Defers a fold/cache update until the outermost durable write commits.\n * Returns false without running it when no managed commit is available.\n * Failed savepoints and retried transaction attempts never publish the update.\n *\n * @category transactions\n * @since 1.0.0\n */\nexport { afterCommit } from \"@smthrs/database/DurableWriter\"\n\n/**\n * Stable error codes returned by journal operations.\n *\n * `read_failed` identifies a database failure on a durable read path. Callers\n * can distinguish that retryable storage condition from an unclassified\n * `unknown` journal defect.\n *\n * @category models\n * @since 0.1.0\n */\nexport const JournalErrorCode = Schema.Literals([\n \"invalid_event\",\n \"idempotency_conflict\",\n \"sequence_conflict\",\n \"fence_lost\",\n \"queue_overflow\",\n \"journal_closed\",\n \"sink_failed\",\n \"read_failed\",\n \"decode_failed\",\n \"projection_failed\",\n \"checkpoint_invalid\",\n \"reader_behind\",\n \"compacted\",\n \"unknown\"\n])\n\n/**\n * Stable error codes returned by journal operations.\n *\n * @category models\n * @since 0.1.0\n */\nexport type JournalErrorCode = typeof JournalErrorCode.Type\n\n/**\n * Error raised by journal admission, persistence, replay, or projection.\n *\n * `checkpointSeq` is set on the compaction-aware codes: on `compacted` it is\n * the run's compaction floor, the checkpoint sequence a reader must resync\n * from, and on `reader_behind` it is the checkpoint a compaction refused to\n * truncate below.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class JournalError extends Schema.TaggedError<JournalError>()(\"@smthrs/journal/JournalError\", {\n code: JournalErrorCode,\n message: Schema.String,\n cause: Schema.optional(Schema.Unknown),\n checkpointSeq: Schema.optional(Seq)\n}) {}\n\n/**\n * Policy applied when the non-blocking admission queue is full.\n *\n * @category models\n * @since 0.1.0\n */\nexport const OverflowPolicy = Schema.Literals([\"reject\", \"drop-newest\", \"drop-oldest\"])\n\n/**\n * Policy applied when the non-blocking admission queue is full.\n *\n * @category models\n * @since 0.1.0\n */\nexport type OverflowPolicy = typeof OverflowPolicy.Type\n\n/**\n * Receipt for a newly admitted event.\n *\n * On the lossy channel, `seq` and `sourceSeq` are allocated synchronously and\n * returned before SQL commits. This `seq` is provisional: the SQL writer\n * moves it above the committed tail if another commit overtakes its reservation.\n * Use committed entries for durable cursors. On the durable channel, the same\n * receipt shape is returned only after the entry commits. `seq` orders the run;\n * `sourceSeq` identifies producer retries and does not change at commit.\n *\n * @category models\n * @since 0.1.0\n */\nexport const Accepted = Schema.TaggedStruct(\"Accepted\", {\n seq: Seq,\n sourceSeq: SourceSeq,\n evicted: Schema.optionalKey(Schema.Struct({\n policy: Schema.Literal(\"drop-oldest\"),\n count: Schema.Int.check(Schema.isGreaterThan(0))\n }))\n})\n\n/**\n * Receipt for a newly admitted event.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Accepted = typeof Accepted.Type\n\n/**\n * Receipt for an exact retry of an already pending or committed source event.\n *\n * `seq` is the original event's sequence, provisional while pending and\n * canonical after commit. A duplicate does not allocate another sequence or\n * enqueue another write. `status` distinguishes\n * an optimistic retry from one whose original event is already durable.\n *\n * @category models\n * @since 0.1.0\n */\nexport const Duplicate = Schema.TaggedStruct(\"Duplicate\", {\n seq: Seq,\n sourceSeq: SourceSeq,\n status: Schema.Literals([\"pending\", \"committed\"])\n})\n\n/**\n * Receipt for an exact producer retry.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Duplicate = typeof Duplicate.Type\n\n/**\n * Receipt for an event discarded by an explicit dropping policy.\n *\n * A dropped admission still consumes its synchronously allocated `seq` and\n * `sourceSeq`, so sequence gaps are expected.\n *\n * @category models\n * @since 0.1.0\n */\nexport const Dropped = Schema.TaggedStruct(\"Dropped\", {\n seq: Seq,\n sourceSeq: SourceSeq,\n policy: Schema.Literal(\"drop-newest\")\n})\n\n/**\n * Receipt for an event discarded by policy.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Dropped = typeof Dropped.Type\n\n/**\n * Receipt union for admission that may use the lossy queue.\n *\n * @category models\n * @since 0.1.0\n */\nexport const EmitReceipt = Schema.Union([Accepted, Duplicate, Dropped])\n\n/**\n * Receipt union for the lossy channel.\n *\n * @category models\n * @since 0.1.0\n */\nexport type EmitReceipt = typeof EmitReceipt.Type\n\n/**\n * Result of a synchronously durable journal admission.\n *\n * A durable admission is never dropped: it either commits, returns the\n * committed sequence of an exact producer retry, or fails.\n *\n * @category models\n * @since 0.1.0\n */\nexport const DurableReceipt = Schema.Union([Accepted, Duplicate])\n\n/**\n * Receipt union for the durable channel.\n *\n * @category models\n * @since 0.1.0\n */\nexport type DurableReceipt = typeof DurableReceipt.Type\n\n/**\n * Cursor used to replay a run and then follow its committed tail.\n *\n * @category models\n * @since 0.1.0\n */\nexport const StreamOptions = Schema.Struct({\n runId: RunId,\n afterSequence: Schema.optionalKey(Seq)\n})\n\n/**\n * Cursor used to replay a run and follow its committed tail.\n *\n * @category models\n * @since 0.1.0\n */\nexport type StreamOptions = typeof StreamOptions.Type\n\n/**\n * Largest page `entries` will read.\n *\n * A page is decoded into memory in full before the caller sees its first\n * entry, so an unbounded limit lets one call materialize a whole run. The\n * largest page any caller in this repository asks for is 512, so this\n * ceiling refuses only a limit that was going to be a memory incident.\n *\n * @since 1.0.0\n * @category constants\n */\nexport const maxEntriesLimit = 10_000\n\n/**\n * Cursor and page size for durable journal reads.\n *\n * `limit` is at most `maxEntriesLimit` (10,000 entries). Optional `eventTypes`\n * selects a nonempty list of at most 64 exact types before pagination; cursors remain canonical run\n * sequences and `hasMore` describes matching entries. Omit it for the full run.\n * Filtering does not bypass the run's compaction floor.\n *\n * @category models\n * @since 0.1.0\n */\nexport const EntriesOptions = Schema.Struct({\n runId: RunId,\n after: Schema.optionalKey(Seq),\n eventTypes: Schema.optionalKey(\n Schema.Array(Entry.fields.eventType).check(Schema.isMinLength(1), Schema.isMaxLength(64))\n ),\n limit: Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(maxEntriesLimit))\n})\n\n/**\n * Cursor and page size for durable journal reads.\n *\n * @category models\n * @since 0.1.0\n */\nexport type EntriesOptions = typeof EntriesOptions.Type\n\n/**\n * One page of canonical durable journal entries.\n *\n * @category models\n * @since 0.1.0\n */\nexport const EntriesPage = Schema.Struct({\n entries: Schema.Array(Entry),\n hasMore: Schema.Boolean\n})\n\n/**\n * One page of durable journal entries.\n *\n * @category models\n * @since 0.1.0\n */\nexport type EntriesPage = typeof EntriesPage.Type\n\n/**\n * A durable checkpoint: the caller-captured state that replays a run from\n * `seq` without the entries before it.\n *\n * `state` is the caller's own replay snapshot and round-trips verbatim: the\n * journal never interprets it, and redaction deliberately does not apply,\n * exactly as it does not apply to executable state. A checkpoint at `seq`\n * must subsume every entry with a sequence at or below `seq`: replay is\n * `state` plus `stream({ runId, afterSequence: seq })`.\n *\n * `compactedAtMs` is `null` until a compaction has truncated the entries\n * strictly below `seq`. The largest compacted `seq` for a run is its\n * compaction floor.\n *\n * Prior art: Temporal's mutable state, a durable snapshot pinned to a\n * history offset, with history below it never replayed\n * (`reference/temporal/common/persistence/data_interfaces.go`,\n * `WorkflowSnapshot`).\n *\n * @category models\n * @since 0.1.0\n */\nexport class Checkpoint extends Schema.Class<Checkpoint>(\"@smthrs/journal/Journal/Checkpoint\")({\n runId: RunId,\n seq: Seq,\n state: Schema.Unknown,\n createdAtMs: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n compactedAtMs: Schema.NullOr(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))\n}) {}\n\n/**\n * Arguments for writing a checkpoint.\n *\n * `seq` must name a committed entry of the run: the surviving row is what\n * keeps the run's durable `MAX(seq)` allocation floor at or above the\n * compaction boundary, so a process restarted after compaction can never\n * re-allocate a truncated sequence.\n *\n * @category models\n * @since 0.1.0\n */\nexport const CheckpointOptions = Schema.Struct({\n runId: RunId,\n seq: Seq,\n state: Schema.Unknown\n})\n\n/**\n * Arguments for writing a checkpoint.\n *\n * @category models\n * @since 0.1.0\n */\nexport type CheckpointOptions = typeof CheckpointOptions.Type\n\n/**\n * Arguments for compacting a run.\n *\n * `upTo` selects the checkpoint to truncate below; omitted, the run's latest\n * checkpoint is used.\n *\n * @category models\n * @since 0.1.0\n */\nexport const CompactOptions = Schema.Struct({\n runId: RunId,\n upTo: Schema.optionalKey(Seq)\n})\n\n/**\n * Arguments for compacting a run.\n *\n * @category models\n * @since 0.1.0\n */\nexport type CompactOptions = typeof CompactOptions.Type\n\n/**\n * Receipt for a completed compaction.\n *\n * `deleted` is `0` when the checkpoint was already the compaction floor, a\n * retried compaction is idempotent.\n *\n * @category models\n * @since 0.1.0\n */\nexport const Compacted = Schema.Struct({\n runId: RunId,\n checkpointSeq: Seq,\n deleted: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))\n})\n\n/**\n * Receipt for a completed compaction.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Compacted = typeof Compacted.Type\n\n/**\n * Journal operations.\n *\n * There are two sequence domains:\n *\n * - `seq` is reserved synchronously per run. A lossy reservation is provisional;\n * the SQL writer moves it above the committed tail if overtaken. The committed\n * sequence is the canonical order for replay, paging, streams, and projections.\n * - `sourceSeq` is assigned synchronously per `(runId, sourceId)`, or supplied\n * by the producer, and is the idempotency key for producer retries.\n *\n * Rejected or dropped admissions consume both allocations, so gaps are valid.\n * A retry the in-process index still holds returns `Duplicate` with the\n * original `seq` (provisional while pending) and consumes neither allocation.\n *\n * A retry it no longer holds is admitted optimistically and settled by\n * `UNIQUE (run_id, source_id, source_seq)` at the insert: admission issues no\n * dedup read, so the receipt is `Accepted`, the entry collapses onto the\n * committed row instead of doubling it, and a reused identity carrying\n * different bytes surfaces its `idempotency_conflict` through `flush` rather\n * than through the emit. The read is deliberately absent. `emitLossy` exists\n * to be callable from inside somebody else's open write transaction, and a\n * SELECT there waits on the writer that is waiting on the caller: the agent\n * executor's exit flush deadlocked exactly so. What a producer keeps in\n * exchange is the choice of what a collision means, through `Input.dedupe`.\n *\n * This table is Smithers' logical (domain) write-ahead log and is intended to\n * become the authoritative state history. The storage engine's own WAL\n * underneath it is a durability substrate only and is never consumed as the\n * application event API. A durable boundary must not advance a run or expose\n * its result until its lifecycle entry is committed. No local commit makes a\n * remote effect atomic, so external effects still need idempotency keys,\n * fencing tokens, or compensation.\n *\n * `emitDurable` allocates `seq` inside the writer's SQL transaction, so the\n * returned sequence is already committed and independent writers never fork\n * the per-run clock.\n *\n * Caveat on scope: the stores above this log (`RunStore`, `AttemptStore`,\n * `CacheStore`, and engine-store's `DurableEngineState`) hold the executable\n * authoritative state, and no state is derived from these entries today.\n * `transact` is what keeps the two halves consistent anyway: a state\n * transition and the lifecycle entry describing it are appended in ONE write\n * transaction, so a crash can never leave durable state the journal does not\n * explain (or an entry for a transition that never landed).\n *\n * The surface is split into two channels:\n *\n * - The lifecycle channel, `emitDurable`, returns `DurableReceipt`, so a\n * dropped lifecycle event is unrepresentable: the write commits, dedupes, or\n * fails with a typed error.\n * - The lossy channel, `emitLossy`, keeps the optimistic queue and its\n * overflow policies for telemetry, where `Dropped` receipts and\n * `drop-oldest` evictions are acceptable.\n *\n * `emitDurable` is fenced on the run's ownership as arbitrated by the\n * injected `Consensus` strategy: the caller hands over its `OwnerId`, the\n * durable insert only commits while that strategy still records the owner as\n * holding the run, and a reclaimed run fails the write with a `fence_lost`\n * error. The fence is mandatory on the lifecycle channel: a lifecycle write is\n * what advances a run, and a zombie owner must not advance anything. The one\n * escape is {@link Service.emitDurableUnfenced}, for the rare admission that\n * is genuinely ownerless.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Service {\n /**\n * The durable rewind generation and its archive boundary. An append-only\n * adapter may omit this operation, which means generation zero forever.\n * Rewinding adapters must advance the generation atomically with truncation.\n */\n readonly generation?:\n | ((runId: RunId) => Effect.Effect<{\n readonly generation: number\n readonly afterSeq: number\n }, JournalError>)\n | undefined\n readonly emitLossy: (input: Input) => Effect.Effect<EmitReceipt, JournalError>\n readonly emitDurable: (input: Input, owner: OwnerId) => Effect.Effect<DurableReceipt, JournalError>\n /**\n * The unfenced durable write: same durability and receipt contract as\n * {@link Service.emitDurable}, with no ownership fence.\n *\n * This exists ONLY for admissions that are genuinely ownerless: writes\n * whose correctness does not depend on who currently owns the run because\n * they are first-writer-wins by design. The canonical case is the\n * external-trigger admission: a deferred completion or clock-schedule\n * record delivered by a sweeper that owns nothing, where the dedup index,\n * not the fence, is the idempotency mechanism. A caller that holds an\n * `OwnerId` must use `emitDurable`; reaching for this channel to dodge a\n * `fence_lost` is exactly the zombie write the fence exists to reject.\n */\n readonly emitDurableUnfenced: (input: Input) => Effect.Effect<DurableReceipt, JournalError>\n /**\n * Runs `effect`, a state projection plus the `emitDurable` calls describing\n * it, inside ONE write transaction.\n *\n * This is the seam that makes the logical WAL crash-consistent with\n * executable state. The stores above the journal (`RunStore`,\n * `AttemptStore`, `CacheStore`, `DurableEngineState`) write through the same\n * `DurableWriter`, so their writes join this transaction as savepoints: either\n * the transition and its lifecycle entry both commit, or neither does. It is\n * the local analogue of Temporal closing mutable state into a mutation plus\n * event batches and submitting them as one persistence request\n * (`reference/temporal/service/history/workflow/transaction_impl.go`).\n *\n * A `Duplicate` receipt is unaffected: an exact producer retry still\n * collapses onto the already-committed sequence.\n *\n * Two consequences a caller must plan for:\n *\n * - Publication (`changes`, `stream`, and the in-process source-event index)\n * is deferred until the transaction commits, so a subscriber never\n * observes an entry that later rolls back, and a rolled-back producer\n * identity stays re-emittable rather than deduplicating against a\n * sequence that does not exist.\n * - Everything inside runs while a write transaction is open. Keep it to\n * storage work: no flow bodies, no host calls, no waits.\n *\n * Nesting is safe: an inner `transact` becomes a savepoint of the outer\n * one and defers its publication to the outermost commit.\n */\n readonly transact: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | JournalError, R>\n /**\n * Publishes a short, non-failing process-local update after the current\n * transaction commits, or immediately when no transaction is open.\n *\n * Returns false without publishing inside a raw SQL transaction whose\n * commit this journal cannot observe. A true result can mean deferred, not\n * already run. Failed savepoints and retries discard their registrations.\n * Test doubles that implement transactions must preserve this contract.\n */\n readonly whenCommitted: (update: Effect.Effect<void>) => Effect.Effect<boolean>\n /**\n * Replays the run's durable history from `afterSequence`, then follows it.\n *\n * This is the lossless follower. It pages the history rather than\n * materializing it, so the first entry arrives after one page rather than\n * after the whole run; it reports a sink loss that happens while it is\n * following; and a cursor below the run's compaction floor fails with\n * `compacted` and the sequence to resync from, never a silently shortened\n * history.\n */\n readonly stream: (options: StreamOptions) => Stream.Stream<Entry, JournalError>\n /**\n * Reads one page of the run's durable history in sequence order.\n *\n * `hasMore` reports whether another page follows. A cursor below the run's\n * compaction floor fails with `compacted`, exactly as `stream` does, so a\n * poller and a follower cannot disagree about what history exists.\n */\n readonly entries: (options: EntriesOptions) => Effect.Effect<EntriesPage, JournalError>\n /**\n * Subscribes to entries this process commits, across every run.\n *\n * This is a bounded SLIDING buffer sized by the layer's `capacity`: a slow\n * consumer silently loses entries, with no error and no gap signal. Use it\n * for a local tail or a UI feed, and use `stream` wherever a missing entry\n * would be a correctness bug, because that is the lossless path and the one\n * that reports sink losses.\n *\n * Only this process's commits arrive here. Another writer on the same\n * database publishes into its own buffer, which is the second reason\n * `stream` exists: it rechecks the durable tail.\n *\n * Published entries are deeply frozen, so one subscriber cannot mutate the\n * value another subscriber is about to read.\n */\n readonly changes: Effect.Effect<PubSub.Subscription<Entry>, never, Scope.Scope>\n readonly project: <S, E, R>(\n projection: Projection<S, E, R>,\n options: StreamOptions\n ) => Stream.Stream<S, JournalError, R>\n readonly flush: Effect.Effect<void, JournalError>\n /**\n * Durably records the state that replays the run from `options.seq`.\n *\n * The write shares `transact`'s discipline: it runs through the same\n * `DurableWriter`, so inside an open `transact` it joins the caller's\n * transaction as a savepoint and rolls back with it. `options.seq` must\n * name a committed entry and must lie above the run's compaction floor;\n * otherwise the write fails with `checkpoint_invalid`. Re-checkpointing an\n * uncompacted `seq` replaces its state: last writer wins.\n *\n * The write is fenced on the run's ownership through the consensus\n * strategy, exactly as `emitDurable` is: a reclaimed run fails with\n * `fence_lost`. The fence is mandatory: a zombie owner must not replace\n * replay state behind a live successor.\n */\n readonly checkpoint: (options: CheckpointOptions, owner: OwnerId) => Effect.Effect<Checkpoint, JournalError>\n /**\n * Reads the run's most recent checkpoint, compacted or not.\n *\n * A reader that fails with `compacted` resyncs here: apply\n * `checkpoint.state`, then continue from\n * `stream({ runId, afterSequence: checkpoint.seq })`.\n */\n readonly latestCheckpoint: (runId: RunId) => Effect.Effect<Option.Option<Checkpoint>, JournalError>\n /**\n * Deletes the run's entries strictly below a checkpoint, atomically with\n * advancing the run's compaction floor.\n *\n * Refusals are typed: `checkpoint_invalid` when the run has no checkpoint\n * to truncate below, `reader_behind` when a live in-process stream still\n * needs a sequence the truncation would delete, and `fence_lost` when the\n * supplied `owner` no longer holds the run. The fence is mandatory, so a\n * zombie owner can never truncate history behind a live successor. Readers\n * this process cannot see (pollers of `entries` and followers in other\n * processes) are protected by the read-side guard instead: any read whose cursor starts\n * below the floor fails with `compacted` and the floor to resync from,\n * never a silently shortened history.\n */\n readonly compact: (options: CompactOptions, owner: OwnerId) => Effect.Effect<Compacted, JournalError>\n}\n\n/**\n * Context service for durable lifecycle evidence and lossy telemetry.\n *\n * @category services\n * @since 0.1.0\n */\nexport class Journal extends Context.Service<Journal, Service>()(\"@smthrs/journal/Journal\") {}\n\n/**\n * Constructs a journal service from an implementation.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const make = (implementation: Service): Service => Journal.of(implementation)\n\nconst unavailable = (method: string): JournalError =>\n new JournalError({\n code: \"journal_closed\",\n message: `${method} is unavailable`\n })\n\n/**\n * Constructs a closed journal stub, optionally overriding individual methods.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const makeNoop = (overrides: Partial<Service> = {}): Service => {\n const service: Service = {\n emitLossy: Effect.fn(\"Journal.emitLossy\")(() => Effect.fail(unavailable(\"emitLossy\"))),\n emitDurable: Effect.fn(\"Journal.emitDurable\")(() => Effect.fail(unavailable(\"emitDurable\"))),\n emitDurableUnfenced: Effect.fn(\"Journal.emitDurableUnfenced\")(() =>\n Effect.fail(unavailable(\"emitDurableUnfenced\"))\n ),\n /**\n * The closed stub has no sink and therefore no transaction to open, so it\n * runs the effect directly, the same posture as\n * `DurableEngineState`'s in-memory twin, whose `transaction` has no crash\n * window to close. A test double that models rollback overrides it.\n */\n transact: <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E | JournalError, R> => effect,\n whenCommitted: (update) => Effect.as(update, true),\n stream: (options) =>\n Stream.unwrap(\n Effect.fn(\"Journal.stream\")((_options: StreamOptions) => Effect.succeed(Stream.fail(unavailable(\"stream\"))))(\n options\n )\n ),\n entries: Effect.fn(\"Journal.entries\")(() => Effect.fail(unavailable(\"entries\"))),\n changes: Effect.acquireRelease(\n PubSub.sliding<Entry>(1),\n PubSub.shutdown\n ).pipe(Effect.flatMap(PubSub.subscribe)),\n project: (projection, options) =>\n Stream.unwrap(\n Effect.fn(\"Journal.project\")(\n <S, E, R>(_projection: Projection<S, E, R>, _options: StreamOptions) =>\n Effect.succeed(Stream.fail(unavailable(\"project\")))\n )(projection, options)\n ),\n flush: Effect.fn(\"Journal.flush\")(() => Effect.fail(unavailable(\"flush\")))(),\n checkpoint: Effect.fn(\"Journal.checkpoint\")(() => Effect.fail(unavailable(\"checkpoint\"))),\n latestCheckpoint: Effect.fn(\"Journal.latestCheckpoint\")(() => Effect.fail(unavailable(\"latestCheckpoint\"))),\n compact: Effect.fn(\"Journal.compact\")(() => Effect.fail(unavailable(\"compact\")))\n }\n return Journal.of({ ...service, ...overrides })\n}\n\n/**\n * Provides a closed journal stub.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layerNoop = (overrides: Partial<Service> = {}): Layer.Layer<Journal> =>\n Layer.succeed(Journal)(makeNoop(overrides))\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * Logical journal contract with durable lifecycle and lossy telemetry channels.\n *\n * The ownership fence and the lossless `emitDurable` / lossy `emitLossy`\n * split are described at https://journal.smithers.sh/concepts/owner-fence/\n * and https://journal.smithers.sh/concepts/two-channels/.\n *\n * @since 0.1.0\n */\n\nimport type { WriteOptions } from \"@smthrs/database/DurableWriter\"\nimport * as Context from \"effect/Context\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\nimport type * as Option from \"effect/Option\"\nimport * as PubSub from \"effect/PubSub\"\nimport * as Schema from \"effect/Schema\"\nimport type * as Scope from \"effect/Scope\"\nimport * as Stream from \"effect/Stream\"\nimport { Entry, RunId, Seq, SourceSeq } from \"./JournalEvent.ts\"\nimport type { Input } from \"./JournalEvent.ts\"\nimport type { OwnerId } from \"./OwnerId.ts\"\nimport type { Projection } from \"./Projection.ts\"\n\n/**\n * Defers a fold/cache update until the outermost durable write commits.\n * Returns false without running it when no managed commit is available.\n * Failed savepoints and retried transaction attempts never publish the update.\n *\n * @category transactions\n * @since 1.0.0\n */\nexport { afterCommit } from \"@smthrs/database/DurableWriter\"\n\n/**\n * Stable error codes returned by journal operations.\n *\n * `read_failed` identifies a database failure on a durable read path. Callers\n * can distinguish that retryable storage condition from an unclassified\n * `unknown` journal defect.\n *\n * @category models\n * @since 0.1.0\n */\nexport const JournalErrorCode = Schema.Literals([\n \"invalid_event\",\n \"idempotency_conflict\",\n \"sequence_conflict\",\n \"fence_lost\",\n \"queue_overflow\",\n \"journal_closed\",\n \"sink_failed\",\n \"read_failed\",\n \"decode_failed\",\n \"projection_failed\",\n \"checkpoint_invalid\",\n \"reader_behind\",\n \"compacted\",\n \"unknown\"\n])\n\n/**\n * Stable error codes returned by journal operations.\n *\n * @category models\n * @since 0.1.0\n */\nexport type JournalErrorCode = typeof JournalErrorCode.Type\n\n/**\n * Error raised by journal admission, persistence, replay, or projection.\n *\n * `checkpointSeq` is set on the compaction-aware codes: on `compacted` it is\n * the run's compaction floor, the checkpoint sequence a reader must resync\n * from, and on `reader_behind` it is the checkpoint a compaction refused to\n * truncate below.\n *\n * @category errors\n * @since 0.1.0\n */\nexport class JournalError extends Schema.TaggedError<JournalError>()(\"@smthrs/journal/JournalError\", {\n code: JournalErrorCode,\n message: Schema.String,\n cause: Schema.optional(Schema.Unknown),\n checkpointSeq: Schema.optional(Seq)\n}) {}\n\n/**\n * Policy applied when the non-blocking admission queue is full.\n *\n * @category models\n * @since 0.1.0\n */\nexport const OverflowPolicy = Schema.Literals([\"reject\", \"drop-newest\", \"drop-oldest\"])\n\n/**\n * Policy applied when the non-blocking admission queue is full.\n *\n * @category models\n * @since 0.1.0\n */\nexport type OverflowPolicy = typeof OverflowPolicy.Type\n\n/**\n * Receipt for a newly admitted event.\n *\n * On the lossy channel, `seq` and `sourceSeq` are allocated synchronously and\n * returned before SQL commits. This `seq` is provisional: the SQL writer\n * moves it above the committed tail if another commit overtakes its reservation.\n * Use committed entries for durable cursors. On the durable channel, the same\n * receipt shape is returned only after the entry commits. `seq` orders the run;\n * `sourceSeq` identifies producer retries and does not change at commit.\n *\n * @category models\n * @since 0.1.0\n */\nexport const Accepted = Schema.TaggedStruct(\"Accepted\", {\n seq: Seq,\n sourceSeq: SourceSeq,\n evicted: Schema.optionalKey(Schema.Struct({\n policy: Schema.Literal(\"drop-oldest\"),\n count: Schema.Int.check(Schema.isGreaterThan(0))\n }))\n})\n\n/**\n * Receipt for a newly admitted event.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Accepted = typeof Accepted.Type\n\n/**\n * Receipt for an exact retry of an already pending or committed source event.\n *\n * `seq` is the original event's sequence, provisional while pending and\n * canonical after commit. A duplicate does not allocate another sequence or\n * enqueue another write. `status` distinguishes\n * an optimistic retry from one whose original event is already durable.\n *\n * @category models\n * @since 0.1.0\n */\nexport const Duplicate = Schema.TaggedStruct(\"Duplicate\", {\n seq: Seq,\n sourceSeq: SourceSeq,\n status: Schema.Literals([\"pending\", \"committed\"])\n})\n\n/**\n * Receipt for an exact producer retry.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Duplicate = typeof Duplicate.Type\n\n/**\n * Receipt for an event discarded by an explicit dropping policy.\n *\n * A dropped admission still consumes its synchronously allocated `seq` and\n * `sourceSeq`, so sequence gaps are expected.\n *\n * @category models\n * @since 0.1.0\n */\nexport const Dropped = Schema.TaggedStruct(\"Dropped\", {\n seq: Seq,\n sourceSeq: SourceSeq,\n policy: Schema.Literal(\"drop-newest\")\n})\n\n/**\n * Receipt for an event discarded by policy.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Dropped = typeof Dropped.Type\n\n/**\n * Receipt union for admission that may use the lossy queue.\n *\n * @category models\n * @since 0.1.0\n */\nexport const EmitReceipt = Schema.Union([Accepted, Duplicate, Dropped])\n\n/**\n * Receipt union for the lossy channel.\n *\n * @category models\n * @since 0.1.0\n */\nexport type EmitReceipt = typeof EmitReceipt.Type\n\n/**\n * Result of a synchronously durable journal admission.\n *\n * A durable admission is never dropped: it either commits, returns the\n * committed sequence of an exact producer retry, or fails.\n *\n * @category models\n * @since 0.1.0\n */\nexport const DurableReceipt = Schema.Union([Accepted, Duplicate])\n\n/**\n * Receipt union for the durable channel.\n *\n * @category models\n * @since 0.1.0\n */\nexport type DurableReceipt = typeof DurableReceipt.Type\n\n/**\n * Cursor used to replay a run and then follow its committed tail.\n *\n * @category models\n * @since 0.1.0\n */\nexport const StreamOptions = Schema.Struct({\n runId: RunId,\n afterSequence: Schema.optionalKey(Seq)\n})\n\n/**\n * Cursor used to replay a run and follow its committed tail.\n *\n * @category models\n * @since 0.1.0\n */\nexport type StreamOptions = typeof StreamOptions.Type\n\n/**\n * Largest page `entries` will read.\n *\n * A page is decoded into memory in full before the caller sees its first\n * entry, so an unbounded limit lets one call materialize a whole run. The\n * largest page any caller in this repository asks for is 512, so this\n * ceiling refuses only a limit that was going to be a memory incident.\n *\n * @since 1.0.0\n * @category constants\n */\nexport const maxEntriesLimit = 10_000\n\n/**\n * Cursor and page size for durable journal reads.\n *\n * `limit` is at most `maxEntriesLimit` (10,000 entries). Optional `eventTypes`\n * selects a nonempty list of at most 64 exact types before pagination; cursors remain canonical run\n * sequences and `hasMore` describes matching entries. Omit it for the full run.\n * Filtering does not bypass the run's compaction floor. `order: \"desc\"`\n * reads the newest matching entries first; the default is `\"asc\"`. In either\n * order, `after` is an exclusive lower sequence bound, not a reverse cursor.\n *\n * @category models\n * @since 0.1.0\n */\nexport const EntriesOptions = Schema.Struct({\n runId: RunId,\n after: Schema.optionalKey(Seq),\n order: Schema.optionalKey(Schema.Literals([\"asc\", \"desc\"])),\n eventTypes: Schema.optionalKey(\n Schema.Array(Entry.fields.eventType).check(Schema.isMinLength(1), Schema.isMaxLength(64))\n ),\n limit: Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(maxEntriesLimit))\n})\n\n/**\n * Cursor and page size for durable journal reads.\n *\n * @category models\n * @since 0.1.0\n */\nexport type EntriesOptions = typeof EntriesOptions.Type\n\n/**\n * One page of canonical durable journal entries.\n *\n * @category models\n * @since 0.1.0\n */\nexport const EntriesPage = Schema.Struct({\n entries: Schema.Array(Entry),\n hasMore: Schema.Boolean\n})\n\n/**\n * One page of durable journal entries.\n *\n * @category models\n * @since 0.1.0\n */\nexport type EntriesPage = typeof EntriesPage.Type\n\n/**\n * A durable checkpoint: the caller-captured state that replays a run from\n * `seq` without the entries before it.\n *\n * `state` is the caller's own replay snapshot and round-trips verbatim: the\n * journal never interprets it, and redaction deliberately does not apply,\n * exactly as it does not apply to executable state. A checkpoint at `seq`\n * must subsume every entry with a sequence at or below `seq`: replay is\n * `state` plus `stream({ runId, afterSequence: seq })`.\n *\n * `compactedAtMs` is `null` until a compaction has truncated the entries\n * strictly below `seq`. The largest compacted `seq` for a run is its\n * compaction floor.\n *\n * Prior art: Temporal's mutable state, a durable snapshot pinned to a\n * history offset, with history below it never replayed\n * (`reference/temporal/common/persistence/data_interfaces.go`,\n * `WorkflowSnapshot`).\n *\n * @category models\n * @since 0.1.0\n */\nexport class Checkpoint extends Schema.Class<Checkpoint>(\"@smthrs/journal/Journal/Checkpoint\")({\n runId: RunId,\n seq: Seq,\n state: Schema.Unknown,\n createdAtMs: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n compactedAtMs: Schema.NullOr(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)))\n}) {}\n\n/**\n * Arguments for writing a checkpoint.\n *\n * `seq` must name a committed entry of the run: the surviving row is what\n * keeps the run's durable `MAX(seq)` allocation floor at or above the\n * compaction boundary, so a process restarted after compaction can never\n * re-allocate a truncated sequence.\n *\n * @category models\n * @since 0.1.0\n */\nexport const CheckpointOptions = Schema.Struct({\n runId: RunId,\n seq: Seq,\n state: Schema.Unknown\n})\n\n/**\n * Arguments for writing a checkpoint.\n *\n * @category models\n * @since 0.1.0\n */\nexport type CheckpointOptions = typeof CheckpointOptions.Type\n\n/**\n * Arguments for compacting a run.\n *\n * `upTo` selects the checkpoint to truncate below; omitted, the run's latest\n * checkpoint is used.\n *\n * @category models\n * @since 0.1.0\n */\nexport const CompactOptions = Schema.Struct({\n runId: RunId,\n upTo: Schema.optionalKey(Seq)\n})\n\n/**\n * Arguments for compacting a run.\n *\n * @category models\n * @since 0.1.0\n */\nexport type CompactOptions = typeof CompactOptions.Type\n\n/**\n * Receipt for a completed compaction.\n *\n * `deleted` is `0` when the checkpoint was already the compaction floor, a\n * retried compaction is idempotent.\n *\n * @category models\n * @since 0.1.0\n */\nexport const Compacted = Schema.Struct({\n runId: RunId,\n checkpointSeq: Seq,\n deleted: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))\n})\n\n/**\n * Receipt for a completed compaction.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Compacted = typeof Compacted.Type\n\n/**\n * Journal operations.\n *\n * There are two sequence domains:\n *\n * - `seq` is reserved synchronously per run. A lossy reservation is provisional;\n * the SQL writer moves it above the committed tail if overtaken. The committed\n * sequence is the canonical order for replay, paging, streams, and projections.\n * - `sourceSeq` is assigned synchronously per `(runId, sourceId)`, or supplied\n * by the producer, and is the idempotency key for producer retries.\n *\n * Rejected or dropped admissions consume both allocations, so gaps are valid.\n * A retry the in-process index still holds returns `Duplicate` with the\n * original `seq` (provisional while pending) and consumes neither allocation.\n *\n * A retry it no longer holds is admitted optimistically and settled by\n * `UNIQUE (run_id, source_id, source_seq)` at the insert: admission issues no\n * dedup read, so the receipt is `Accepted`, the entry collapses onto the\n * committed row instead of doubling it, and a reused identity carrying\n * different bytes surfaces its `idempotency_conflict` through `flush` rather\n * than through the emit. The read is deliberately absent. `emitLossy` exists\n * to be callable from inside somebody else's open write transaction, and a\n * SELECT there waits on the writer that is waiting on the caller: the agent\n * executor's exit flush deadlocked exactly so. What a producer keeps in\n * exchange is the choice of what a collision means, through `Input.dedupe`.\n *\n * This table is Smithers' logical (domain) write-ahead log and is intended to\n * become the authoritative state history. The storage engine's own WAL\n * underneath it is a durability substrate only and is never consumed as the\n * application event API. A durable boundary must not advance a run or expose\n * its result until its lifecycle entry is committed. No local commit makes a\n * remote effect atomic, so external effects still need idempotency keys,\n * fencing tokens, or compensation.\n *\n * `emitDurable` allocates `seq` inside the writer's SQL transaction, so the\n * returned sequence is already committed and independent writers never fork\n * the per-run clock.\n *\n * Caveat on scope: the stores above this log (`RunStore`, `AttemptStore`,\n * `CacheStore`, and engine-store's `DurableEngineState`) hold the executable\n * authoritative state, and no state is derived from these entries today.\n * `transact` is what keeps the two halves consistent anyway: a state\n * transition and the lifecycle entry describing it are appended in ONE write\n * transaction, so a crash can never leave durable state the journal does not\n * explain (or an entry for a transition that never landed).\n *\n * The surface is split into two channels:\n *\n * - The lifecycle channel, `emitDurable`, returns `DurableReceipt`, so a\n * dropped lifecycle event is unrepresentable: the write commits, dedupes, or\n * fails with a typed error.\n * - The lossy channel, `emitLossy`, keeps the optimistic queue and its\n * overflow policies for telemetry, where `Dropped` receipts and\n * `drop-oldest` evictions are acceptable.\n *\n * `emitDurable` is fenced on the run's ownership as arbitrated by the\n * injected `Consensus` strategy: the caller hands over its `OwnerId`, the\n * durable insert only commits while that strategy still records the owner as\n * holding the run, and a reclaimed run fails the write with a `fence_lost`\n * error. The fence is mandatory on the lifecycle channel: a lifecycle write is\n * what advances a run, and a zombie owner must not advance anything. The one\n * escape is {@link Service.emitDurableUnfenced}, for the rare admission that\n * is genuinely ownerless.\n *\n * @category models\n * @since 0.1.0\n */\nexport interface Service {\n /**\n * The durable rewind generation and its archive boundary. An append-only\n * adapter may omit this operation, which means generation zero forever.\n * Rewinding adapters must advance the generation atomically with truncation.\n */\n readonly generation?:\n | ((runId: RunId) => Effect.Effect<{\n readonly generation: number\n readonly afterSeq: number\n }, JournalError>)\n | undefined\n /**\n * Committed tail and rewind generation for every requested run, read together\n * in one snapshot per batch. Unknown runs have generation 0, afterSeq -1 and\n * maxSeq null. Optional acceleration for readers; adapters may omit it.\n */\n readonly heads?:\n | ((runIds: ReadonlyArray<RunId>) => Effect.Effect<\n ReadonlyArray<{\n readonly runId: RunId\n readonly generation: number\n readonly afterSeq: number\n readonly maxSeq: number | null\n }>,\n JournalError\n >)\n | undefined\n readonly emitLossy: (input: Input) => Effect.Effect<EmitReceipt, JournalError>\n readonly emitDurable: (input: Input, owner: OwnerId) => Effect.Effect<DurableReceipt, JournalError>\n /**\n * The unfenced durable write: same durability and receipt contract as\n * {@link Service.emitDurable}, with no ownership fence.\n *\n * This exists ONLY for admissions that are genuinely ownerless: writes\n * whose correctness does not depend on who currently owns the run because\n * they are first-writer-wins by design. The canonical case is the\n * external-trigger admission: a deferred completion or clock-schedule\n * record delivered by a sweeper that owns nothing, where the dedup index,\n * not the fence, is the idempotency mechanism. A caller that holds an\n * `OwnerId` must use `emitDurable`; reaching for this channel to dodge a\n * `fence_lost` is exactly the zombie write the fence exists to reject.\n */\n readonly emitDurableUnfenced: (input: Input) => Effect.Effect<DurableReceipt, JournalError>\n /**\n * Queues a fenced lifecycle entry to commit with its run's next durable\n * write through this journal, instead of in a transaction of its own: the\n * next `emitDurable`, `emitDurableUnfenced`, `checkpoint`, `compact` or\n * `transact` that names the run's partition, or `flush`. Called inside an\n * open transaction it writes at once, as `emitDurable` does.\n *\n * Its sequence is allocated when it commits, ahead of whatever that write\n * appends, so the run's journal reads in the order its entries were\n * emitted and never commits one behind a reader's cursor. It is fenced on\n * `owner` when it commits: an owner that lost the run meanwhile loses what\n * it queued, and learns so from its own next fenced write. Until it\n * commits no reader sees it, and a process that dies first loses it, as it\n * would lose an entry it had not emitted yet. Use it for records a later write of the same run always\n * follows before anything outside the run depends on them, such as a\n * scheduler's records before the attempt that acts on them.\n *\n * An entry the journal knows is committed with the same content (see\n * `recorded`) is dropped rather than queued: the write would only collide\n * with it. A resumed walk re-emits every record it already wrote, so this\n * keeps a replay from writing at all.\n *\n * A queued entry refused permanently (for example an identity conflict or\n * exhausted producer sequence) is dropped, logged and counted without\n * failing the host write. The next `flush` reports the loss once, after\n * writing the remaining entries; an earlier flush failure leaves this report\n * pending. A rolled-back transaction retains its entries and reports no\n * loss. SQL failures retain the batch for retry.\n *\n * Optional: a journal without it is used through `emitDurable`.\n */\n readonly emitDeferred?: ((input: Input, owner: OwnerId) => Effect.Effect<void, JournalError>) | undefined\n /**\n * Reads the run's committed entries, its latest ones up to what this\n * journal keeps in memory, so that a re-emission of one is answered without\n * a write: `emitDeferred` drops an identical one, and `recorded` reports\n * it. A resumed run calls it once before it replays.\n *\n * Optional: a journal without it answers every re-emission with a write.\n */\n readonly recall?: ((runId: RunId) => Effect.Effect<void, JournalError>) | undefined\n /**\n * Whether this journal knows `input` is committed: an entry with its\n * producer identity (`sourceId` and `sourceSeq`) and its content, from its\n * own commits, its startup read or `recall`. It reads nothing. `false` means\n * not known, never absent: an entry with no `sourceSeq` is a new entry every\n * time, and an input the journal refuses is reported by its emit.\n *\n * A caller that knows an entry is committed may skip re-emitting it. The\n * skip is not a fenced write: the owner that skips learns of a lost run from\n * its next write, so skip only an emit whose caller then does nothing the\n * fence guards, such as a replay answered from a recorded attempt.\n *\n * Optional: a journal without it knows nothing.\n */\n readonly recorded?: ((input: Input) => Effect.Effect<boolean>) | undefined\n /**\n * Runs `effect`, a state projection plus the `emitDurable` calls describing\n * it, inside ONE write transaction.\n *\n * This is the seam that makes the logical WAL crash-consistent with\n * executable state. The stores above the journal (`RunStore`,\n * `AttemptStore`, `CacheStore`, `DurableEngineState`) write through the same\n * `DurableWriter`, so their writes join this transaction as savepoints: either\n * the transition and its lifecycle entry both commit, or neither does. It is\n * the local analogue of Temporal closing mutable state into a mutation plus\n * event batches and submitting them as one persistence request\n * (`reference/temporal/service/history/workflow/transaction_impl.go`).\n *\n * A `Duplicate` receipt is unaffected: an exact producer retry still\n * collapses onto the already-committed sequence.\n *\n * Two consequences a caller must plan for:\n *\n * - Publication (`changes`, `stream`, and the in-process source-event index)\n * is deferred until the transaction commits, so a subscriber never\n * observes an entry that later rolls back, and a rolled-back producer\n * identity stays re-emittable rather than deduplicating against a\n * sequence that does not exist.\n * - Everything inside runs while a write transaction is open. Keep it to\n * storage work: no flow bodies, no host calls, no waits.\n *\n * Nesting is safe: an inner `transact` becomes a savepoint of the outer\n * one and defers its publication to the outermost commit.\n *\n * `options.partition` names the partition the transaction writes, such as\n * the run it advances (`DurableWriter.WriteOptions`): it then serializes\n * only with that run's writers. Omitted, it serializes with every writer.\n */\n readonly transact: <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n options?: WriteOptions | undefined\n ) => Effect.Effect<A, E | JournalError, R>\n /**\n * Publishes a short, non-failing process-local update after the current\n * transaction commits, or immediately when no transaction is open.\n *\n * Returns false without publishing inside a raw SQL transaction whose\n * commit this journal cannot observe. A true result can mean deferred, not\n * already run. Failed savepoints and retries discard their registrations.\n * Test doubles that implement transactions must preserve this contract.\n */\n readonly whenCommitted: (update: Effect.Effect<void>) => Effect.Effect<boolean>\n /**\n * Replays the run's durable history from `afterSequence`, then follows it.\n *\n * This is the lossless follower. It pages the history rather than\n * materializing it, so the first entry arrives after one page rather than\n * after the whole run; it reports a sink loss that happens while it is\n * following; and a cursor below the run's compaction floor fails with\n * `compacted` and the sequence to resync from, never a silently shortened\n * history.\n */\n readonly stream: (options: StreamOptions) => Stream.Stream<Entry, JournalError>\n /**\n * Reads one page of the run's durable history in sequence order.\n *\n * `hasMore` reports whether another page follows. A cursor below the run's\n * compaction floor fails with `compacted`, exactly as `stream` does, so a\n * poller and a follower cannot disagree about what history exists.\n */\n readonly entries: (options: EntriesOptions) => Effect.Effect<EntriesPage, JournalError>\n /**\n * Subscribes to entries this process commits, across every run.\n *\n * This is a bounded SLIDING buffer sized by the layer's `capacity`: a slow\n * consumer silently loses entries, with no error and no gap signal. Use it\n * for a local tail or a UI feed, and use `stream` wherever a missing entry\n * would be a correctness bug, because that is the lossless path and the one\n * that reports sink losses.\n *\n * Only this process's commits arrive here. Another writer on the same\n * database publishes into its own buffer, which is the second reason\n * `stream` exists: it rechecks the durable tail.\n *\n * Published entries are deeply frozen, so one subscriber cannot mutate the\n * value another subscriber is about to read.\n */\n readonly changes: Effect.Effect<PubSub.Subscription<Entry>, never, Scope.Scope>\n readonly project: <S, E, R>(\n projection: Projection<S, E, R>,\n options: StreamOptions\n ) => Stream.Stream<S, JournalError, R>\n readonly flush: Effect.Effect<void, JournalError>\n /**\n * Durably records the state that replays the run from `options.seq`.\n *\n * The write shares `transact`'s discipline: it runs through the same\n * `DurableWriter`, so inside an open `transact` it joins the caller's\n * transaction as a savepoint and rolls back with it. `options.seq` must\n * name a committed entry and must lie above the run's compaction floor;\n * otherwise the write fails with `checkpoint_invalid`. Re-checkpointing an\n * uncompacted `seq` replaces its state: last writer wins.\n *\n * The write is fenced on the run's ownership through the consensus\n * strategy, exactly as `emitDurable` is: a reclaimed run fails with\n * `fence_lost`. The fence is mandatory: a zombie owner must not replace\n * replay state behind a live successor.\n */\n readonly checkpoint: (options: CheckpointOptions, owner: OwnerId) => Effect.Effect<Checkpoint, JournalError>\n /**\n * Reads the run's most recent checkpoint, compacted or not.\n *\n * A reader that fails with `compacted` resyncs here: apply\n * `checkpoint.state`, then continue from\n * `stream({ runId, afterSequence: checkpoint.seq })`.\n */\n readonly latestCheckpoint: (runId: RunId) => Effect.Effect<Option.Option<Checkpoint>, JournalError>\n /**\n * Deletes the run's entries strictly below a checkpoint, atomically with\n * advancing the run's compaction floor.\n *\n * Refusals are typed: `checkpoint_invalid` when the run has no checkpoint\n * to truncate below, `reader_behind` when a live in-process stream still\n * needs a sequence the truncation would delete, and `fence_lost` when the\n * supplied `owner` no longer holds the run. The fence is mandatory, so a\n * zombie owner can never truncate history behind a live successor. Readers\n * this process cannot see (pollers of `entries` and followers in other\n * processes) are protected by the read-side guard instead: any read whose cursor starts\n * below the floor fails with `compacted` and the floor to resync from,\n * never a silently shortened history.\n */\n readonly compact: (options: CompactOptions, owner: OwnerId) => Effect.Effect<Compacted, JournalError>\n}\n\n/**\n * Context service for durable lifecycle evidence and lossy telemetry.\n *\n * @category services\n * @since 0.1.0\n */\nexport class Journal extends Context.Service<Journal, Service>()(\"@smthrs/journal/Journal\") {}\n\n/**\n * Constructs a journal service from an implementation.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const make = (implementation: Service): Service => Journal.of(implementation)\n\nconst unavailable = (method: string): JournalError =>\n new JournalError({\n code: \"journal_closed\",\n message: `${method} is unavailable`\n })\n\n/**\n * Constructs a closed journal stub, optionally overriding individual methods.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const makeNoop = (overrides: Partial<Service> = {}): Service => {\n const service: Service = {\n emitLossy: Effect.fn(\"Journal.emitLossy\")(() => Effect.fail(unavailable(\"emitLossy\"))),\n emitDurable: Effect.fn(\"Journal.emitDurable\")(() => Effect.fail(unavailable(\"emitDurable\"))),\n emitDurableUnfenced: Effect.fn(\"Journal.emitDurableUnfenced\")(() =>\n Effect.fail(unavailable(\"emitDurableUnfenced\"))\n ),\n /**\n * The closed stub has no sink and therefore no transaction to open, so it\n * runs the effect directly, the same posture as\n * `DurableEngineState`'s in-memory twin, whose `transaction` has no crash\n * window to close. A test double that models rollback overrides it.\n */\n transact: <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E | JournalError, R> => effect,\n whenCommitted: (update) => Effect.as(update, true),\n stream: (options) =>\n Stream.unwrap(\n Effect.fn(\"Journal.stream\")((_options: StreamOptions) => Effect.succeed(Stream.fail(unavailable(\"stream\"))))(\n options\n )\n ),\n entries: Effect.fn(\"Journal.entries\")(() => Effect.fail(unavailable(\"entries\"))),\n changes: Effect.acquireRelease(\n PubSub.sliding<Entry>(1),\n PubSub.shutdown\n ).pipe(Effect.flatMap(PubSub.subscribe)),\n project: (projection, options) =>\n Stream.unwrap(\n Effect.fn(\"Journal.project\")(\n <S, E, R>(_projection: Projection<S, E, R>, _options: StreamOptions) =>\n Effect.succeed(Stream.fail(unavailable(\"project\")))\n )(projection, options)\n ),\n flush: Effect.fn(\"Journal.flush\")(() => Effect.fail(unavailable(\"flush\")))(),\n checkpoint: Effect.fn(\"Journal.checkpoint\")(() => Effect.fail(unavailable(\"checkpoint\"))),\n latestCheckpoint: Effect.fn(\"Journal.latestCheckpoint\")(() => Effect.fail(unavailable(\"latestCheckpoint\"))),\n compact: Effect.fn(\"Journal.compact\")(() => Effect.fail(unavailable(\"compact\")))\n }\n return Journal.of({ ...service, ...overrides })\n}\n\n/**\n * Provides a closed journal stub.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layerNoop = (overrides: Partial<Service> = {}): Layer.Layer<Journal> =>\n Layer.succeed(Journal)(makeNoop(overrides))\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,cAAyB;AACzB,aAAwB;AACxB,YAAuB;AAEvB,aAAwB;AACxB,aAAwB;AAExB,aAAwB;AACxB,0BAA6C;AAa7C,2BAA4B;AAYrB,MAAM,mBAAmB,OAAO,SAAS;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,E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AAA,IACxF,kBAAkB,OAAO,GAAG,0BAA0B,EAAE,MAAM,OAAO,KAAK,YAAY,kBAAkB,CAAC,CAAC;AAAA,IAC1G,SAAS,OAAO,GAAG,iBAAiB,EAAE,MAAM,OAAO,KAAK,YAAY,SAAS,CAAC,CAAC;AAAA,EACjF;AACA,SAAO,QAAQ,GAAG,EAAE,GAAG,SAAS,GAAG,UAAU,CAAC;AAChD;AAQO,MAAM,YAAY,CAAC,YAA8B,CAAC,MACvD,MAAM,QAAQ,OAAO,EAAE,SAAS,SAAS,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -21,7 +21,7 @@ export declare const initialize: Effect.Effect<void, import("effect/sql/SqlError
|
|
|
21
21
|
* @category lifecycle
|
|
22
22
|
* @since 1.0.0-rc.0
|
|
23
23
|
*/
|
|
24
|
-
export declare const onTruncate: (forget: (runIds: ReadonlyArray<string>) => void) => Effect.Effect<void, never, import("effect/Scope").Scope
|
|
24
|
+
export declare const onTruncate: (forget: (runIds: ReadonlyArray<string>) => void) => Effect.Effect<void, never, SqlClient.SqlClient | import("effect/Scope").Scope>;
|
|
25
25
|
/**
|
|
26
26
|
* Forgets cached identities and allocation floors after a committed truncation.
|
|
27
27
|
* The rewinder must quiesce producers and flush pending admissions first.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JournalGeneration.d.ts","sourceRoot":"","sources":["../../src/JournalGeneration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"JournalGeneration.d.ts","sourceRoot":"","sources":["../../src/JournalGeneration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA;AAEjD;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,kFAiCrB,CAAA;AAIF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,IAAI,mFAgBtE,CAAA;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GAAI,QAAQ,aAAa,CAAC,MAAM,CAAC,oDAMhD,CAAA"}
|
|
@@ -46,7 +46,16 @@ const initialize = Effect.gen(function* () {
|
|
|
46
46
|
after_seq ${Dialect.integer(sql)} NOT NULL CHECK (${Dialect.isInteger(sql, sql`after_seq`)} AND after_seq >= -1 AND after_seq <= 9007199254740991)
|
|
47
47
|
)
|
|
48
48
|
`;
|
|
49
|
-
|
|
49
|
+
const installed = sql`
|
|
50
|
+
SELECT to_regclass('flows_journal_generations') IS NOT NULL AS found
|
|
51
|
+
`;
|
|
52
|
+
yield* sql.onDialectOrElse({
|
|
53
|
+
pg: () => Effect.flatMap(
|
|
54
|
+
installed,
|
|
55
|
+
([row]) => row?.found === true ? Effect.void : Effect.asVoid(sql.withTransaction(create))
|
|
56
|
+
),
|
|
57
|
+
orElse: () => Effect.asVoid(create)
|
|
58
|
+
});
|
|
50
59
|
});
|
|
51
60
|
const journals = /* @__PURE__ */ new WeakMap();
|
|
52
61
|
const onTruncate = (forget2) => Effect.gen(function* () {
|