8000 feat: migrate WAL call sites to WAL-0xx error codes — #277 (4/6) by adityamukho · Pull Request #363 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

feat: migrate WAL call sites to WAL-0xx error codes — #277 (4/6) - #363

Merged
adityamukho merged 1 commit into
mainfrom
error-codes-277-wal
Aug 25, 2026
Merged

adityamukho merged 1 commit into
mainfrom
error-codes-277-wal

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Summary

Part of #360, one of six per-category rollout PRs toward the #277 structured error codes umbrella (foundation PR #357 already merged). Migrates all 6 bail!/anyhow! call sites in src/wal.rs to bail_coded!/err_coded! with their real WAL-0xx codes.

  • WAL-001 invalid WAL magic number
  • WAL-002 unsupported WAL version
  • WAL-003 fact serialised size exceeds the WAL per-entry maximum (~4080 bytes)
  • WAL-004 fact serialised size exceeds u32 range — practically unreachable, WAL-003's limit fires first
  • WAL-005 WAL num_facts exceeds platform usize — unreachable on any 64-bit target (usize == u64 there)
  • WAL-006 failed to delete the .wal sidecar file after checkpoint

src/error.rs gains ErrorCode::Wal001..Wal006 REGISTRY entries (exhaustiveness match test extended accordingly). docs/ERROR_REFERENCE.md's WAL-002/003/004/006 "Error text" lines are rewritten from a concrete example value to the canonical {}-placeholder template form, per the #277 design spec, so the registry↔doc sync test (error::tests::registry_is_a_subset_of_error_reference_doc) can compare them byte-for-byte; the concrete example now lives in each entry's prose instead. WAL-001/005 needed no rewrite (no dynamic content).

Scope note

Stayed strictly within src/wal.rs, src/error.rs (only the WAL registry additions — a merge conflict with the sibling category PRs' own registry additions there is expected and normal), docs/ERROR_REFERENCE.md, and CHANGELOG.md. Did not touch parser.rs, src/storage/, or the query executor modules, which are being migrated concurrently in separate PRs (#358, #359, #361).

Test plan

  • tests/error_codes_wal_test.rs (new): exercises WAL-001, WAL-002, and WAL-003 through the public Minigraf API — WAL corruption and replay failure on reopen, and a live oversized transact.
  • src/wal.rs's own test module: direct call-site coverage for all six codes, including WAL-006 via a directory-at-the-WAL-path trick (portable, no permission-denial setup needed). WAL-004/005 have no dedicated trigger test — genuinely unreachable in practice, as noted above — but are covered by error.rs's registry↔doc sync test and exhaustiveness test.
  • cargo test — full suite green (725 lib tests + all integration suites + doctests).
  • cargo clippy --all-features -- -D warnings — clean.
  • cargo fmt --check — clean.

Closes #360

🤖 Generated with Claude Code

https://claude.ai/code/session_01P7e4uTBWtM8fMZiPZc4bCw

Part of #360, one of six per-category rollout PRs toward the #277
structured error codes umbrella. Migrates all 6 bail!/anyhow! call
sites in src/wal.rs to bail_coded!/err_coded! with their real WAL-0xx
codes from docs/ERROR_REFERENCE.md:

- WAL-001 invalid WAL magic number
- WAL-002 unsupported WAL version
- WAL-003 fact serialised size exceeds the WAL per-entry maximum
- WAL-004 fact serialised size exceeds u32 range (practically
  unreachable — WAL-003's limit fires first)
- WAL-005 WAL num_facts exceeds platform usize (unreachable on any
  64-bit target)
- WAL-006 failed to delete the WAL sidecar file after checkpoint

Adds src/error.rs's ErrorCode::Wal001..Wal006 REGISTRY entries and
extends the exhaustiveness match test. Rewrites ERROR_REFERENCE.md's
WAL-002/003/004/006 "Error text" lines from a concrete example value
to the canonical {}-placeholder template form (per the #277 design
spec) so the registry<->doc sync test compares them byte-for-byte;
the concrete example now lives in each entry's prose instead.

Regression tests: tests/error_codes_wal_test.rs exercises WAL-001,
WAL-002, and WAL-003 through the public Minigraf API (WAL corruption
on reopen, replay failure on reopen, and a live oversized transact).
src/wal.rs's own test module adds direct-call-site coverage for all
six codes, including WAL-006 via a directory-at-the-WAL-path trick
that's portable without needing a permission-denial setup.

Closes #360

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P7e4uTBWtM8fMZiPZc4bCw
@codecov
codecov Bot commented Aug 25, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit efb4f5d into main Aug 25, 2026
17 checks passed
@adityamukho
adityamukho deleted the error-codes-277-wal branch August 25, 2026 13:18
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.

error codes: migrate WAL call sites to WAL-0xx codes

1 participant

0