Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
The control store and eventing runtime are now Context.Services with their own layers. The store opens and checkpoints its database through the layer scope, and every method returns an Effect with typed failures instead of throwing. Each bun:sqlite transaction stays one synchronous Effect.try step, so SQL, ordering, leases, pruning and durability are unchanged. serve.ts runs the eventing handlers and ingest on the server's one ManagedRuntime and maps failures with catchTags to the same HTTP statuses as before. Eventing telemetry records Effect metrics directly, OTLP field errors are a Schema.TaggedError in the error channel, and checkpoints use the Effect snapshot helpers.
Makisuo
force-pushed
the
feat/local-eventing-effect-first
branch
from
September 18, 2026 22:48
98322a4 to
1ac39c9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #363 (merged), rebased onto
main.What changes
The Local eventing code from #363 was synchronous and threw its errors. They were already
Schema.TaggedErrorclasses, butserve.tscaught them with try/catch andinstanceof. Now:control-store.ts:LocalEventingControlStoreis aContext.Servicewithstatic readonly layer = Layer.effect(this, this.make). It readsLocalEventingControlConfig, which the app root provides. The database opens and closes through the layer scope (acquireRelease, with a WAL checkpoint on close), replacing the manualacquireReleaseinstartServer. Every method returns anEffectand fails withEventingControlStoreError, the consumer errors, orOutboxAdministrationInvalid. It no longer throws or builds a plainError. Each bun:sqlite transaction is still oneEffect.trystep. The SQL, ordering, lease, pruning and durability logic did not change.openControlStore,validateControlSnapshot,writeControlSnapshotandrestoreControlSnapshotreplace the static helpers.runtime.ts:LocalEventingRuntimeis a service too. Its layer provides the store, and aLocalEventingProjectorsreference supplies the projectors. The four existing errors now travel in the error channel, and a non-JSON fingerprint fails withSourceOccurrenceInvalid. TheResult.getOrThrowcalls are gone. Registry commits go throughSynchronizedRef.modifyEffect, so a stale activation always fails as a conflict, even when it runs outside the maintenance gate.otlp.ts/encode.ts:OtlpFieldErroris now aSchema.TaggedError, and the imperative encoder still throws it. Normalization returnsEffect<…, OtlpFieldError>. A malformed record is still counted and skipped. The unusedOTLP_LOG_ADAPTERis removed.telemetry.ts: theEventingTelemetry.record()interface and itsrunForkbridge are replaced byobserveEventing, which updates Effect metrics from the Effect code. The labels are the same bounded set. The ingest-path runtime operations and activation carry spans; claim and ack polling do not.serve.ts: telemetry and the eventing services now share oneManagedRuntime, the one that already ran per-request spans. The layers are memoized, so the store opens once.ingestand every eventing handler are Effects run throughrunSpan, and they map failures withEffect.catchTags. The maintenance gate gainsexclusiveEffect, built onacquireUseReleaseso it always reopens.readBoundedJsonis an Effect.consumer-auth.ts/local-token.ts/checkpoints.ts: the consumer token load is an Effect.readRealFilethrows aLocalFileNotRealTaggedError instead of a plainError. Checkpoint creation validates the control snapshot inside its Effect flow instead of through a nestedrunPromise.HTTP statuses are unchanged
OtlpFieldErrorProjectionActivationConflict/ProjectionActivationInvalid/ unexpected commit failureMaintenanceInProgress/RequestBodyTooLarge/local/eventing/outboxbad query / store failureA defect in a handler lands in the same fallback status the old catch-all produced.
One edge case now behaves differently: if closing the staging store fails during
restoreControlSnapshot, the failure is logged instead of rethrown, because a scope finalizer cannot fail. The target snapshot has already been written and validated by then.Tests
The existing suites now call the Effect APIs, and every behavioral assertion is kept.
test/eventing-test-support.tsholds the helpers. The telemetry assertions read an isolatedMetric.MetricRegistryinstead of a recording stub. The collision test also covers a defect, which stays a 503.bun run --cwd apps/cli typecheck: clean.oxlintrc.effect.json --quiet) andoxfmt --checkon the changed files: cleanknip --workspace apps/cli: clean🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.