M-3: Diagnostics.streamReplayEvents + snapshotReplayEvents (R-017 single-emit) #112

Open
opened 2026-05-12 19:37:03 +00:00 by KofTwentyTwo · 0 comments
KofTwentyTwo commented 2026-05-12 19:37:03 +00:00 (Migrated from github.com)

Goal

Diagnostics.streamReplayEvents + snapshotReplayEvents. Replay event emission is a side effect of API event emission (one call → one replay row + one bus event), preserving R-017.

Scope

  • streamReplayEvents(since:) -> AsyncStream<ReplayEntry>
  • snapshotReplayEvents(range:) -> [ReplayEntry]
  • Replay-event side-effect contract: every API event emission ALSO writes one replay row
  • Single-emit invariant (G-008 / OQ-T5)

Files

  • packages/JarvisAPI/Sources/JarvisAPI/Surfaces/Diagnostics+Adapter.swift
  • packages/Replay/Sources/Replay/ReplayLog.swift — side-effect emit wiring

Acceptance

  • Stream API delivers events incrementally
  • Snapshot returns range
  • Memory.applyOp(.add, …) produces ONE replay row AND one bus event (R-017)
  • Replay roundtrip asserted in scenario S-DIAG-007

Test

S-DIAG-007 asserts 1:1 invariant between bus emit and replay row.

Parent epic

#7

Source

.planning/architecture/JARVIS-API-MIGRATION-PLAN.md §2.4 (M-3.4)
.planning/architecture/REVIEW-MIGRATION-RISK.md R-017

## Goal Diagnostics.streamReplayEvents + snapshotReplayEvents. Replay event emission is a side effect of API event emission (one call → one replay row + one bus event), preserving R-017. ## Scope - `streamReplayEvents(since:) -> AsyncStream<ReplayEntry>` - `snapshotReplayEvents(range:) -> [ReplayEntry]` - Replay-event side-effect contract: every API event emission ALSO writes one replay row - Single-emit invariant (G-008 / OQ-T5) ## Files - `packages/JarvisAPI/Sources/JarvisAPI/Surfaces/Diagnostics+Adapter.swift` - `packages/Replay/Sources/Replay/ReplayLog.swift` — side-effect emit wiring ## Acceptance - [ ] Stream API delivers events incrementally - [ ] Snapshot returns range - [ ] `Memory.applyOp(.add, …)` produces ONE replay row AND one bus event (R-017) - [ ] Replay roundtrip asserted in scenario `S-DIAG-007` ## Test `S-DIAG-007` asserts 1:1 invariant between bus emit and replay row. ## Parent epic #7 ## Source `.planning/architecture/JARVIS-API-MIGRATION-PLAN.md` §2.4 (M-3.4) `.planning/architecture/REVIEW-MIGRATION-RISK.md` R-017
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: KofTwentyTwo/Jarvis#112