feat: stream many-observer readings - #772
Conversation
📝 WalkthroughWalkthroughThe observer runtime now supports cardinality-aware lazy reading plans. Lane observations stream many-observer readings against a pinned tick, settle receipts for completion or cancellation, and manage activity through idempotent leases. Documentation and type-check coverage describe the new many-observer flow. ChangesMany Observer Runtime
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Release Preflight
If this PR is from a |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/domain/api/ObserverRuntime.ts`:
- Around line 83-88: Validate the value returned by plan.readings() in
observerReadings before returning it for the many-cardinality branch. Reuse the
existing E_OBSERVER_PLAN validation behavior used by
createObserver/createManyObserver, and raise a domain WarpError for undefined or
non-async-iterable results instead of allowing consumer-side TypeError failures.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c540a57e-effa-419d-84fc-0c7fb1f7c5f5
📒 Files selected for processing (10)
docs/topics/api/README.mdsrc/application/RuntimeActivity.tssrc/application/RuntimeLaneAdapter.tssrc/domain/api/ObserverRuntime.tstest/type-check/generated-users.tstest/type-check/v19-consumer.tstest/unit/application/RuntimeActivity.test.tstest/unit/application/RuntimeLaneAdapter.test.tstest/unit/domain/ObserverRuntime.test.tsvitest.config.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,js,jsx}: Do not use direct imports fromsrc/infrastructure/**insrc/domain/**orsrc/ports/**; depend on a port instead.
Do not use direct Node built-ins insrc/domain/**orsrc/ports/**; use a port instead.
Files:
vitest.config.tstest/unit/application/RuntimeActivity.test.tstest/type-check/v19-consumer.tstest/unit/domain/ObserverRuntime.test.tstest/type-check/generated-users.tssrc/application/RuntimeActivity.tssrc/domain/api/ObserverRuntime.tstest/unit/application/RuntimeLaneAdapter.test.tssrc/application/RuntimeLaneAdapter.ts
src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.{ts,tsx,js,jsx}: Do not introduceany,as any,as unknown as,unknown(outside adapters),Record<string, unknown>(outside adapters),*Likeplaceholder types,JSON.parse/JSON.stringify(outside adapters),fetch(outside adapters),process.env(outside adapters),@ts-ignore, orz.any()in core code; use validated boundary models and ports instead.
Use constructor-injected ports for external capabilities; do not rely on ambient dependencies for I/O, clocks, persistence, or entropy.
Do not createutils.ts,helpers.ts,misc.ts, orcommon.ts; name files after the actual concept they model.
Prefer one file per class, type, or object; if a file accumulates peer concepts, split it.
Keep helper corridors, fake shape trust, transitional duplication, and compile-time theater out of the codebase; runtime-honest TypeScript must reflect actual behavior.
No enum usage; prefer runtime-backed domain forms and unions.
Do not use boolean trap parameters; prefer named option objects or separate methods.
Avoid magic strings or numbers when a named constant should exist.
Keep domain bytes asUint8Array;Bufferbelongs in infrastructure adapters.
Files:
src/application/RuntimeActivity.tssrc/domain/api/ObserverRuntime.tssrc/application/RuntimeLaneAdapter.ts
src/domain/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
src/domain/**/*.{ts,tsx,js,jsx}: Insrc/domain/**, do not useDate.now(),new Date(),Date(),performance.now(),Math.random(),crypto.randomUUID(),crypto.getRandomValues(),setTimeout,setInterval, rawnew Error(...)/new TypeError(...), or direct imports from Node built-ins; time, entropy, and external capabilities must enter through ports or parameters, and domain errors should extendWarpError.
Construct domain objects only in core when doing so establishes validated runtime truth; do not build infrastructure adapters, host APIs, persistence implementations, wall clocks, or entropy sources inside core.
Prefer discriminated unions and explicit result types instead of boolean-flag bags, and model expected failures as return values rather than exceptions.
src/domain/must not import host APIs or Node-specific globals; hexagonal architecture boundaries are mandatory.
Domain code must not use the wall clock directly; time must enter through a port or parameter.
Files:
src/domain/api/ObserverRuntime.ts
src/domain/**/!(*.test).{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use explicit domain concepts with validated constructors,
Object.freeze, andinstanceofdispatch; domain objects should be runtime-backed nouns, not ad hoc shape bags.
Files:
src/domain/api/ObserverRuntime.ts
🔇 Additional comments (14)
src/domain/api/ObserverRuntime.ts (2)
6-20: LGTM!
22-63: LGTM!test/unit/domain/ObserverRuntime.test.ts (1)
1-84: LGTM!src/application/RuntimeActivity.ts (2)
5-7: LGTM!Also applies to: 17-39
58-65: LGTM!test/unit/application/RuntimeActivity.test.ts (1)
28-56: LGTM!src/application/RuntimeLaneAdapter.ts (3)
3-30: LGTM!
58-184: LGTM!
201-259: LGTM!test/unit/application/RuntimeLaneAdapter.test.ts (1)
1-10: LGTM!Also applies to: 89-148, 149-190, 191-220, 222-242, 244-283, 333-340
vitest.config.ts (1)
33-33: LGTM!docs/topics/api/README.md (1)
178-187: LGTM!Also applies to: 222-227
test/type-check/generated-users.ts (1)
2-5: LGTM!Also applies to: 31-46
test/type-check/v19-consumer.ts (1)
40-47: LGTM!Also applies to: 94-94
Release Preflight
If this PR is from a |
Summary
manyObserver reading-plan factories while preserving the exactly-one APIIssue
Refs #712
Prerequisite for #760
Depends on the cold bounded-materialization work tracked by #738.
Test plan
ADR checks