P4-W3: Sink abstraction for export job delivery#124
Conversation
Add SinkType enum (LocalFile, Webhook, Database), SinkConfig struct, async ExportSink trait, and DeliveryReceipt/DeliveryMetadata types to core. Implement LocalFileSink (writes to disk) and WebhookSink (POSTs to validated URL) in the API server. DatabaseSink is defined as a config-parseable stub with runtime delivery deferred. Export jobs accept an optional sink config; data is always stored in-memory for backward-compatible download, and additionally delivered to the configured sink. ExportJobStatus gains delivered_to and delivery_status fields. Comprehensive tests cover both sink implementations and API integration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: d59c5cadaef6
Remote Review — P4-W3: Sink abstractionCI status: Formatting ✅ | Clippy ✅ | Tests ✅ | Build ✅ | Cargo Audit ⏳ (independent) Review against focus areas1. SinkConfig validation (path traversal / SSRF) ✅
2. Backward compatibility ✅
3. Memory management ✅ (with note)
4. Error handling ✅
5. Trait design ✅
6. No wallet-only assumptions ✅
VerdictNo blocking issues. The remote review pass is clear — this packet is ready to merge from the PR-comment review perspective. Non-blocking notes for future iterations
|
Sink delivery (especially webhook POST with up to 30s timeout) was performed while holding the export_jobs RwLock write guard, blocking all other export operations. Restructure to: acquire lock briefly to mark completed and store data, release lock, perform sink delivery, then briefly re-lock to record delivery outcome. Only clones the export body when a sink is configured. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: d0e774e443dc
Review feedback fix appliedBlocking issue from local review: Sink delivery was holding the Fix (commit 4dbcd9d): Restructured the export task to use short lock scopes:
Only clones the export body when a sink is actually configured (no performance cost for the no-sink path). All 772 tests pass. CI green (fmt ✅, clippy ✅, tests ✅, build ✅, audit ✅). Ready to merge. |
Summary
SinkTypeenum (LocalFile,Webhook,Database, withObjectStoragereserved),SinkConfigstruct with per-type validation, asyncExportSinktrait,DeliveryReceipt, andDeliveryMetadata.tokio::fs; WebhookSink POSTs with configurable headers, content-type, and metadata headers.ExportJobRequestaccepts optional sink config;ExportJobStatusgainsdelivered_toanddelivery_statusfields (omitted when no sink is used, preserving backward compatibility).Validation
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace— all green).Test plan
cargo fmt --all --checkpassescargo clippy --workspace --all-targets -- -D warningspassescargo test --workspacepasses (772 tests)🤖 Generated with Claude Code