Skip to content

test(indexer): mixed schema_version fixtures and stop-on-unknown coverage - #43

Open
jdjioe5-cpu wants to merge 1 commit into
Kinlock-Org:mainfrom
jdjioe5-cpu:test/mixed-schema-version-indexer
Open

jdjioe5-cpu wants to merge 1 commit into
Kinlock-Org:mainfrom
jdjioe5-cpu:test/mixed-schema-version-indexer

Conversation

@jdjioe5-cpu

Copy link
Copy Markdown

What and why

Implements test coverage and fixtures for indexer mixed schema_version event streams and stop-on-unknown error behavior per Roadmap rows M2-10 and M2-14 (Closes #34). Proves that the indexer gracefully processes interleaved event versions without double counting, reproduces identical state on replay, and halts with full batch rollback when encountering unknown versions or missing version tags.

Changes

  • services/indexer/src/handlers/lock-created.ts: Exported lockCreatedV2 forward-compatible handler stub.
  • services/indexer/src/handlers/released.ts: Exported releasedV2 forward-compatible handler stub.
  • services/indexer/src/handlers/index.ts: Registered lockCreatedV2 and releasedV2 under version 2 in HANDLERS.
  • services/indexer/test/fixtures/events/mixed-versions.json: Generated 15-event fixture interleaving v1 and v2 events, specifically covering Lock 3 created with v2 and released across v2 and v1 tranches.
  • services/indexer/test/helpers/fixtures.ts: Exported mixedFixture and mixedFixtureLocks loader helpers.
  • services/indexer/test/ingest.test.ts: Added suite describe("ingest: mixed schema_versions (v1 + v2) and stop-on-unknown (M2-10, M2-14)"):
    • Verified mixed v1/v2 event streams process accurately to expected terminal states without double counting (Lock 3 marked Completed).
    • Proved database snapshot determinism across repeated replay runs and variable page sizes (1, 4, 100).
    • Verified Hard Rule 8.2 stop-on-unknown: unknown schema_version (0, 99) halts immediately with UnsupportedEventError and rolls back without dirty writes.
    • Verified missing schema_version halts immediately with DecodeError and rolls back cursor and events.
  • ROADMAP.md: Updated M2-10 and M2-14 to DONE, refreshed Phase 3 (76%) and overall (41%) progress snapshots, and added Section 17 Changelog entry.

Hard rules / invariants touched

  • Hard Rule 8.2: Stop on unknown event type or unknown schema_version rather than silently skip or discard.
  • Hard Rule 8.1: Append-only event ingestion (chain_events integrity).

Tests

Commands executed locally and verified all green:

  • pnpm test (vitest run):
    Test Files: 15 passed (15)
    Tests: 171 passed (171)
  • pnpm typecheck (tsc --noEmit): Scope 2 of 3 packages clean (0 errors)
  • pnpm lint (biome check .): Checked 74 files, 0 errors
  • pnpm build (tsc -p tsconfig.json): All packages build clean

Docs / ADR

  • ROADMAP.md: Updated Section 3 Progress snapshot and Section 17 Changelog; row status updated.

Roadmap

  • Rows touched: M2-10 (DONE), M2-14 (DONE).
  • Changelog entry added: yes.

Assumptions and open questions

None. No business logic in existing v1 handlers was modified, and zero migrations or core SDK code touched.

…rage

- Closes Kinlock-Org#34

- Covers Roadmap rows M2-10 and M2-14

- Add forward-compatible v2 handler stubs (lockCreatedV2, releasedV2) registered in HANDLERS

- Add synthesized mixed-versions.json fixture covering interleaved v1 and v2 schema events on the same lock (Lock 3)

- Verify ingest handles mixed event streams without double counting or state corruption

- Prove identical database state when replayed multiple times across varying batch sizes (1, 4, 100)

- Add stop-on-unknown coverage verifying schema_version 0 and 99 halt ingest immediately with UnsupportedEventError

- Add missing schema_version coverage verifying DecodeError triggers atomic batch rollback

- Update ROADMAP.md row statuses and changelog entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mixed schema_version: replay fixtures and handler tests for every event version

2 participants