Skip to content

test(control): adversarial restart replay invariants#187

Merged
hadamrd merged 2 commits into
trunkfrom
loop/169-test-control-adversarial-restart-replay
Jun 3, 2026
Merged

test(control): adversarial restart replay invariants#187
hadamrd merged 2 commits into
trunkfrom
loop/169-test-control-adversarial-restart-replay

Conversation

@hadamrd
Copy link
Copy Markdown
Owner

@hadamrd hadamrd commented Jun 3, 2026

Fixes #169

Acceptance criteria

  • Appends interleaved frontier, memory, task, critic, and worker events to the durable event log.
  • Reopens SQLite and replays a strict projection from sequence zero.
  • Compares replayed projection cursors and materialized state against BootContext.
  • Covers duplicate idempotency keys and out-of-order/stale projection cursor advancement attempts.

Test evidence

  • PYTHONPATH=/tmp/wt-loop-169/src pytest -q tests/test_control_restart_replay.py::TestControlRestartReplayInvariants
  • uv run ruff format --check src/forge_loop/eventlog/__init__.py src/forge_loop/eventlog/projections.py src/forge_loop/eventlog/sqlite.py src/forge_loop/eventlog/store.py tests/test_control_restart_replay.py
  • uv run ruff check src/forge_loop/eventlog/__init__.py src/forge_loop/eventlog/projections.py src/forge_loop/eventlog/sqlite.py src/forge_loop/eventlog/store.py tests/test_control_restart_replay.py
  • uv run mypy src/forge_loop/eventlog
  • uv run pyright src/forge_loop/eventlog

Notes

  • Lumen discovery skipped because mcp__lumen__semantic_search was unavailable.
  • Configured pre-commit was attempted; Ruff and mypy passed, but repo-wide pyright failed on existing unrelated errors because the hook ignores file arguments.

Add a strict restart replay suite for #169 that appends interleaved frontier, memory, task, critic, and worker events with duplicate idempotency keys, reopens the durable event log, replays projections from zero, and compares the replayed tail against BootContext projection cursors. Introduce guarded projection cursor advancement so stale or past-tail updates fail instead of silently blessing an unsafe replay position.
@hadamrd hadamrd added the critic:blocking Critic found blocking issues label Jun 3, 2026
Copy link
Copy Markdown
Owner Author

@hadamrd hadamrd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[sev2/tests] replay_projection is a new public function, but the tests only cover successful replay. Add an adversarial test where projection.apply() raises partway through replay and assert the stored projection cursor remains at its original sequence; that exercises the helper's promised failure behavior instead of only the lower-level cursor guard.

"""Persist a cursor only when it is monotonic and within the log tail."""
...


Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[sev2/tests] replay_projection is a new public function, but the tests only cover successful replay. Add an adversarial test where projection.apply() raises partway through replay and assert the stored projection cursor remains at its original sequence; that exercises the helper's promised failure behavior instead of only the lower-level cursor guard.

Copy link
Copy Markdown
Owner Author

@hadamrd hadamrd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manifesto violations:

  • [sev2] testing.md#TE-002def replay_projection( event_log: ProjectionEventLog, projection_name: str, projection: Projection, ) -> Pro → Add a sad-path test for replay_projection using a projection that raises during apply, then assert advance_projection_cursor was not persisted and the original cursor is unchanged.

@hadamrd hadamrd merged commit da24745 into trunk Jun 3, 2026
2 checks passed
@hadamrd hadamrd deleted the loop/169-test-control-adversarial-restart-replay branch June 3, 2026 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

critic:blocking Critic found blocking issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(control): adversarial restart replay invariant suite

1 participant