Repository navigation
feat(water-leak): add durable journal-backed recovery service - #9
Conversation
Adds Firmboot.WaterLeak.Durable, a single-writer service that journals
every new valid command in 512-byte SHA-256-chained slots and syncs
before replying, so accepted readings, pending warnings and the first
acknowledgement receipt survive the tested local process crashes.
Sequence gaps are buffered and reported, never filled in.
- lib/firmboot/water_leak/durable{,/codec,/journal,/transition}.ex
- test/firmboot/durable_test.exs: 14 tests, including all 720 arrival
permutations of a six-reading fixture and 56 operation x crash-point
cases (before write, partial write, after write, after sync)
- docs/durable-recovery.md: API, commit boundary, format and limits
- mix.exs: extra_applications [:crypto] for the slot chain
Provenance: extracted from the unpushed local commit 7c29853
("chore: land estate governance sync", 2026-09-15), which had swept
this work in alongside governance files that must not land. That
branch is kept at refs/rescued/20261008-firmboot-unpushed/
chore/bump-standards-pins in the local clone; triage note
dev-notes/inbox/2026-10-08-firmboot-and-fleet-branch-triage.md.
Not carried over: the branch's rewrite of recovery_experiment.ex and
water_leak_test.exs (they would revert #4's checkpoint tests), its
timing-measurement runner and recorded result, and its assurance
register, which depends on scripts/assurance.py (Python is banned in
the estate). The doc was trimmed to claim only what this change's
code and tests reproduce. @doc added to every public function.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015bTuGfwCcvjrmNFejydTML
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (7)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📜 Recent review details⏰ Context from checks skipped due to timeout. (8)
🧰 Additional context used🪛 LanguageTooldocs/durable-recovery.md[typographical] ~70-~70: Two consecutive dots (DOUBLE_PUNCTUATION) [typographical] ~70-~70: Two consecutive dots (DOUBLE_PUNCTUATION) [uncategorized] ~113-~113: If this is a compound adjective that modifies the following noun, use a hyphen. (EN_COMPOUND_ADJECTIVE_INTERNAL) 🔇 Additional comments (8)
📝 SummarySummary by CodeRabbit
WalkthroughAdds a durable water-leak service that validates commands, records them in a bounded journal, and replays records on startup. The change also adds recovery and integrity checks, service status reporting, tests, and documentation. ChangesDurable recovery service
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~60 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Caller
participant Durable
participant Transition
participant Journal
Caller->>Durable: submit(operation_id, command)
Durable->>Transition: classify retry or apply command
Transition-->>Durable: command reply and updated state
Durable->>Journal: append and sync record
Journal-->>Durable: updated journal
Durable-->>Caller: return reply after successful append
Merge Risk: ⚪ Minimal · up to This change adds a self-contained durable water-leak service with journaled recovery. It does not modify existing modules, and no blocking defects were found. The tests run only locally, not in CI. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The service validates bounded commands, synchronizes them before replying, and stops on uncertain write outcomes. Its guarantees depend on trusted callers and a trusted journal file. Production access and filesystem ownership are not established, so this is a limited assessment rather than assurance of deployment safety. Retained concerns Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 65.12% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 43 functions across 6 files. (1 skipped: 1 unsupported.) ✅ Autofix completed ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. I’m a rabbit with a journal to keep, Comment |
|
Add Carrot credits or activate Agent usage billing to use Autopilot |
Fixes Applied SuccessfullyFixed 6 file(s) based on 1 failed pre-merge check. A follow-up PR containing fixes has been created.
Time taken: |
This follow-up PR contains CodeRabbit auto-fixes for #9. **Files modified:** - `lib/firmboot/water_leak/durable.ex` - `lib/firmboot/water_leak/durable/codec.ex` - `lib/firmboot/water_leak/durable/journal.ex` - `lib/firmboot/water_leak/durable/transition.ex` - `mix.exs` - `test/firmboot/durable_test.exs` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
Summary
This adds
Firmboot.WaterLeak.Durable, a finite, disk-backed, single-writer version of the water-warning experiment.The work existed only in an unpushed local commit,
7c29853("chore: land estate governance sync", 2026-09-15). That commit had swept it in alongside governance files that must not land. Its workflows do not parse, and its composite actions are not in the template. This PR extracts only the durable-recovery code, its tests and its doc onto a fresh branch frommain@7c2b90a.Files:
lib/firmboot/water_leak/durable.exanddurable/{codec,journal,transition}.ex: the service, the fixed binary schema, the chained journal and deterministic replay.test/firmboot/durable_test.exs: 14 tests.docs/durable-recovery.md: the API, the commit boundary, the journal format, bounds and the stated limits.mix.exs:extra_applications: [:crypto], needed for:crypto.hash/2. There are no new dependencies.No linked issue.
Type of change
Firmboot.WaterLeak,RecoveryExperimentand Add checkpoint recovery, CI evidence checks, and proof artifacts #4's checkpoint replay are untouched.docs/durable-recovery.md.mix.exsline above. No workflow is changed.📌 New pins
b154e0a736768161ee350c6c660a61666cf1bdd5uses:change, noactions.lockchange, no new Hex dependency (mix.lockis untouched) and no container digest.:cryptois an OTP application that ships with Erlang.How has this been verified?
Everything was run locally in the PR worktree at the head above, with system Elixir 1.18.3 on OTP 27.
MIX_ENV=test mix test: 59 tests, 0 failures. That is the existing 45 plus the 14 new durable tests.before_write,partial_write,after_writeandafter_sync, and the final state is compared against an independent fixture.mix format --check-formatted: exit 0.reuse lint: compliant, 89/89 files with copyright and licence information.testblocks, a test named "all 720 arrival permutations…", andfor index <- 0..13, point <- [4 points](56 cases).git log -1 --show-signature: good ED25519 signature, asrequired_signaturesneeds.verify.yml) runs the Agda and Lean checks, the experiment runners, the lock check andreuse lint, but nevermix test. The 14 new tests are therefore verified locally only. That gap is pre-existing and also applies to the existing 45 tests. It is recorded as a finding for the owner to schedule, and this PR deliberately does not changeverify.yml(see Notes).Checklist
mix test,mix format --check-formattedandreuse lint, as above.REUSE.tomlannotations rather than in-file headers, the same as every existinglib/anddocs/file:lib/**andtest/**are MPL-2.0,docs/**is CC-BY-SA-4.0. No file was relicensed.Notes for reviewers
7c29853. These stay in the local rescue refrefs/rescued/20261008-firmboot-unpushed/chore/bump-standards-pins, with a triage note in the owner's dev-notes inbox:recovery_experiment.exandwater_leak_test.exs. It is a different design from Add checkpoint recovery, CI evidence checks, and proof artifacts #4's checkpoint replay, which merged later, and taking it would revert Add checkpoint recovery, CI evidence checks, and proof artifacts #4's tests;docs/evidence/recovery-local.json);ASSURANCE.md,docs/assurance/*), which is read only by an extendedscripts/assurance.py. Python is banned in the estate, so porting the checker is a separate decision;README.md,CONTINUITY.md,PURPOSE.md,VERIFICATION.mdandREUSE.tomledits.verify.ymlis untouched. Adding amix teststep is the natural follow-up. Under the estate's KYAML rule, an edited workflow has to be converted in the same PR, but only once the repo's gates are known to read KYAML. That can't be established for firmboot yet: it has no governance caller, andgh actions-lock --verify-localon flow-style YAML has not been measured. So the step is left for a separate PR rather than half-done here.@docis on every public function in the four new modules. The@impl trueGenServer callbacks take their docs from the behaviour.🤖 Generated with Claude Code
https://claude.ai/code/session_015bTuGfwCcvjrmNFejydTML