← Back to Pull requests

Introduce a wal abstraction: local append, witness ack, S3 as source of truth #46

Closed
unknown closed this pull request without merging on Sep 16, 2026 14:56 UTC
View on GitHub
unknown unknown commented on Sep 16, 2026 12:07 UTC
Author

This PR implements the write-ahead log (WAL) abstraction: local append-first durability, witness acknowledgment via a WAL buffer service, and S3 as the ultimate source of truth.

Summary of Changes

1. Protocol (proto/wal.proto & pkg/api/wal/v1alpha1):
- WalBuffer service with Append (bidi streaming with Hello / HelloAck handshake and Ack), Flush, and Tail RPCs.
- Go protobuf and gRPC bindings.

2. WAL Record & Segment Storage (pkg/wal):
- 52-byte record header with Castagnoli CRC32C checksums and binary serialization.
- LocalSegmentStore supporting automatic rotation at 64MB and scanning on open that automatically detects and drops torn trailing records.

3. WAL Buffer Service (pkg/wal/buffer & cmd/wal-buffer):
- Startup epoch incrementing and manifest management (wal/manifest.json).
- Group commit engine batching incoming records (up to 5ms or 1MB) with fsync to local disk before sending witness acks.
- Preserves (epoch, global_seq) ordering on client replay of previously acked records.
- Periodic, size-based, and RPC-triggered S3 flushes writing segment objects (wal/segments/<epoch>-<first_seq>-<last_seq>.wal), updating manifest, and broadcasting S3 acks.
- Tail streaming from S3 segments, memory tail cache, and live group commits.

4. Client Library (pkg/wal/client):
- Implements Stream interface (Append, Wait, Flush, Watermarks, Close).
- Append writes and fsyncs locally first before network transmission.
- Background replication loop with automatic reconnection and replaying unacknowledged records.
- Degraded mode / backpressure when retained bytes exceed --max-retained-bytes.
- Local segment cleanup only after records are S3-acknowledged.

5. Kubernetes Manifests, Dockerfiles, and Tests:
- k8s/wal.yaml defining StatefulSet (replicas: 1, emptyDir), headless Service, and PodDisruptionBudget (maxUnavailable: 0).
- cmd/wal-client-test client test runner utility.
- Dockerfiles for wal-buffer and wal-client-test.
- Comprehensive unit tests in pkg/wal, pkg/wal/buffer, and pkg/wal/client.
- E2E test in tests/e2e/wal_e2e_test.go verifying client append, buffer restart with emptyDir, and tail ordering.

Fixes #45

Diff: 288 lines (+216 / -72) across 3 files Reviewer: justinsb Review duration: 168m
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 288 lines diff across 3 files
0.40
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.339
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #46"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.8% (MEDIUM) · Higher = larger blast radius
39.8%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 15.7% · Safe to merge
15.7%