Skip to content

Per-record checksum and corruption detection #4

@mairinkdev

Description

@mairinkdev

Summary

Add checksum (e.g. CRC-32) for each record (payload or header+payload—document which). Validate checksum on every read/scan; return a rich error (offset, file position, reason) when corruption is detected.

Scope

  • Compute checksum when encoding (using existing header format from Day 2); verify when decoding in read/scan paths.
  • Define checksum scope in docs/file-format.md (payload only vs header+payload).
  • Error type: include offset, file position, and message (e.g. "checksum mismatch at offset X, position Y").
  • Tests: append valid records; corrupt one byte in a record (in payload or checksum field); next read/scan must fail with the corruption error and not panic. Optionally: corrupt padding/magic and assert appropriate errors.

Acceptance criteria

  • Every record read or scanned is checksum-verified.
  • Corruption produces a deterministic, informative error (no unwrap in hot path).
  • Tests prove that corruption is detected and reported correctly.

Suggested commit

feat: add per-record checksum verification and corruption errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions