feat(history): two-phase commit journaling and idempotency fingerprinting #43
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/issue-5-journal"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Motivation
Issue #5: interacting with remote CalDAV servers has no distributed-transaction guarantee, so mutations must be journaled locally before dispatch and their outcomes committed atomically afterwards. This implements the two-phase commit boundary and idempotency fingerprinting specified in
docs/issues/005-two-phase-journal-idempotency.md.Changes
src/history/fingerprint.rs(new): canonical SHA-256 request fingerprint over HTTP method, normalized route, recursively key-sorted JSON body, baseline ETags and approval digest; transport IDs and tokens are excluded. Format:sha256:<64-char-hex>.src/history/journal.rs(new):JournalServicewith two-phase boundary:prepare_operation(Phase 1): insertsoperationsrow withstate = 'prepared'; same key + identical fingerprint returnsPrepareResult::Replay(recorded outcome, no new dispatch); divergent fingerprint returnsJournalError::IdempotencyConflict; any journal failure surfaces asJournalUnavailableso no remote write can proceed.commit_operation_result(Phase 3): single SQLite transaction updatesoperations.state(applied/failed/unknown) +result_jsonand appends alllife_eventsatomically.get_operationfor recorded-outcome retrieval.src/domain/mod.rs:OperationStatenow matches the baseline schema (prepared,applied,failed,unknown,needs_reconciliation) withFromStr/Display/as_str.tests/history_journal_tests.rs(new): scenarios R01 (identical replay returns recorded outcome, single recorded event), R02 (same key, different fingerprint ->idempotency_conflict, journal untouched), R04 (journal unavailable blocks dispatch), plus result-commit atomicity and NotFound behaviour.Verification
nix develop --command cargo test— all suites pass (58 tests), including the newhistory_journal_tests(R01, R02, R04, atomicity, NotFound).nix develop --command cargo clippy --all-targets -- -D warnings— clean.nix develop --command cargo fmt --check— clean.Related Issues
Closes #5
feat(history): two-phase commit journaling and idempotency fingerprinting (#5)to feat(history): two-phase commit journaling and idempotency fingerprinting