feat: add initial

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2026-02-26 21:52:50 +01:00
commit 3162971c89
48 changed files with 3041 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
# SQ-005: WAL Segment Reader
**Status:** `[ ] TODO`
**Blocked by:** SQ-004
**Priority:** High
## Description
Implement the WAL segment reader that reads messages from segment files, supporting seek-to-offset and forward scanning.
## Files to Create/Modify
- `crates/sq-storage/src/wal/reader.rs` - WalReader with open, read_from, iterator
## WalReader API
```rust
pub struct WalReader<F: FileSystem> {
fs: Arc<F>,
}
impl<F: FileSystem> WalReader<F> {
pub fn new(fs: Arc<F>) -> Self;
pub async fn read_segment(&self, path: &Path) -> Result<Vec<Message>>;
pub async fn read_from_offset(&self, path: &Path, offset: u64) -> Result<Vec<Message>>;
pub async fn read_segment_header(&self, path: &Path) -> Result<SegmentHeader>;
}
```
## Acceptance Criteria (using InMemoryFileSystem)
- [ ] Write N messages with writer, read all back with reader, verify equality
- [ ] Read from a specific offset in the middle of a segment
- [ ] Corrupted record mid-segment: reader returns error for that record, can report partial results
- [ ] Empty segment (header only): reader yields zero messages
- [ ] Invalid magic bytes: reader returns descriptive error
- [ ] Truncated record at end of segment (partial write): reader stops cleanly at last complete record