Skip to content

Replay: harden recorder and deterministic clock edge cases#182

Merged
dgarson merged 1 commit intofeat/deterministic-replayfrom
codex/review-pr-and-address-concerns
Feb 24, 2026
Merged

Replay: harden recorder and deterministic clock edge cases#182
dgarson merged 1 commit intofeat/deterministic-replayfrom
codex/review-pr-and-address-concerns

Conversation

@dgarson
Copy link
Owner

@dgarson dgarson commented Feb 24, 2026

Motivation

  • Prevent external mutation of recorder internals and avoid surprising behavior when the recorder is disabled.
  • Fail fast on invalid deterministic clock start inputs to avoid downstream runtime errors.
  • Add tests to lock in the intended defensive and failure-mode semantics for replay primitives.

Description

  • Return a defensive copy from InMemoryReplayRecorder.getEvents() so callers cannot mutate #events (src/replay/recorder.ts).
  • Ensure synthetic events emitted while the recorder is disabled still advance #nextSeq so seq remains monotonic for disabled-mode emissions (src/replay/recorder.ts).
  • Validate and normalize deterministic clock start input in createDeterministicClock and throw a clear error for invalid timestamps (src/replay/clock.ts).
  • Add tests covering defensive getEvents() behavior, disabled-mode sequence increments, and invalid deterministic clock starts (src/replay/recorder.test.ts, src/replay/clock.test.ts).

Testing

  • Ran unit tests with pnpm vitest run src/replay/clock.test.ts src/replay/recorder.test.ts src/replay/types.test.ts src/replay/runner.test.ts src/replay/manifest.test.ts and all tests passed.
  • Ran formatting/type checks: pnpm exec oxfmt --check src/replay/clock.ts src/replay/clock.test.ts src/replay/recorder.ts src/replay/recorder.test.ts passed for the touched files.
  • pnpm check surfaced an existing unrelated formatting failure in src/gateway/hitl-request-store.ts that was not modified by this PR.

Codex Task

@dgarson dgarson merged commit c2668c0 into feat/deterministic-replay Feb 24, 2026
2 of 9 checks passed
dgarson added a commit that referenced this pull request Feb 24, 2026
* feat: scaffold deterministic replay framework

* feat(replay): add manifest schema validation helpers

* feat(sessions): add replay session manifest types and serialization helpers

Add session-level replay manifest types distinct from the replay bundle
format in src/replay/types.ts (Nate's work in PR #92).

- ReplaySessionManifest: session metadata for replay-capable sessions
- ReplaySessionEvent: session-level events in the replay lifecycle
- ReplaySessionEventLog: collection of session events
- Serialization helpers: parse/serialize functions
- Factory functions: createReplaySessionId, createReplaySessionManifest, createReplaySessionEvent
- exportSessionManifest stub: placeholder for future storage integration

Add 43 focused tests covering:
- Schema validation for all types
- Serialization round-trips
- Factory function behavior
- Edge cases and error handling

* feat(replay): parse replay events and normalize recording categories

* feat(sessions): add replay session manifest types and serialization helpers (#98)

Add session-level replay manifest types distinct from the replay bundle
format in src/replay/types.ts (Nate's work in PR #92).

- ReplaySessionManifest: session metadata for replay-capable sessions
- ReplaySessionEvent: session-level events in the replay lifecycle
- ReplaySessionEventLog: collection of session events
- Serialization helpers: parse/serialize functions
- Factory functions: createReplaySessionId, createReplaySessionManifest, createReplaySessionEvent
- exportSessionManifest stub: placeholder for future storage integration

Add 43 focused tests covering:
- Schema validation for all types
- Serialization round-trips
- Factory function behavior
- Edge cases and error handling

* docs: add deterministic replay architecture and TDD plan (#108)

* feat: scaffold deterministic replay framework

* feat(replay): add manifest schema validation helpers

* feat(sessions): add replay session manifest types and serialization helpers

Add session-level replay manifest types distinct from the replay bundle
format in src/replay/types.ts (Nate's work in PR #92).

- ReplaySessionManifest: session metadata for replay-capable sessions
- ReplaySessionEvent: session-level events in the replay lifecycle
- ReplaySessionEventLog: collection of session events
- Serialization helpers: parse/serialize functions
- Factory functions: createReplaySessionId, createReplaySessionManifest, createReplaySessionEvent
- exportSessionManifest stub: placeholder for future storage integration

Add 43 focused tests covering:
- Schema validation for all types
- Serialization round-trips
- Factory function behavior
- Edge cases and error handling

* feat(replay): parse replay events and normalize recording categories

* feat(sessions): add replay session manifest types and serialization helpers (#98)

Add session-level replay manifest types distinct from the replay bundle
format in src/replay/types.ts (Nate's work in PR #92).

- ReplaySessionManifest: session metadata for replay-capable sessions
- ReplaySessionEvent: session-level events in the replay lifecycle
- ReplaySessionEventLog: collection of session events
- Serialization helpers: parse/serialize functions
- Factory functions: createReplaySessionId, createReplaySessionManifest, createReplaySessionEvent
- exportSessionManifest stub: placeholder for future storage integration

Add 43 focused tests covering:
- Schema validation for all types
- Serialization round-trips
- Factory function behavior
- Edge cases and error handling

* docs: add deterministic replay architecture and TDD plan (#108)

* Replay: harden recorder and deterministic clock edge cases (#182)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant