Repository navigation
fix(cli): clear the local row of a pool that is no longer Open - #2450
Merged
Merged
Conversation
After a closePool or reclaim mined, only the first, fully successful run cleared the client-store row. If that clear faulted, or the receipt was unreadable but the tx mined, every re-run stopped at a status refusal or skip before it touched the store, and a later fetch reused a closing or closed pool whose vouchers redeemMany rejects. Every close / reclaim that reads a pool as Closing or Closed now clears its row: close --pool and reclaim --pool on their refusal (exit codes are unchanged), close --all and reclaim --all on their skip. The clear is compare-and-delete, and reclaim --pool uses the on-chain owner so its refusal still needs no keystore unlock. A daemon data dir keeps its "row untouched" report. close --all now counts a landed close whose row-clear faulted as closed, not "failed to close". The error carries a CloseUnrecorded marker, the summary gains a "row not cleared" count, and the sweep still exits nonzero, keeping the landed-but-unrecorded exit policy. Closes #2425 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The implementation safely uses compare-and-delete, preserves intended exit behavior, and covers the affected paths.
0 open findings
What changed in this PR
Repairs stale client pool bookkeeping after pools become Closing or Closed.
Changes:
- Clears stale rows on close/reclaim refusals and batch skips.
- Separately tallies landed closes whose row cleanup failed.
- Adds regression coverage and user-facing release notes.
| File | Description |
|---|---|
crates/cli/src/commands/pool.rs |
Implements cleanup and batch classification. |
crates/cli/src/commands/pool/tests.rs |
Tests cleanup, fault handling, and tallies. |
CHANGELOG.md |
Documents the corrected behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit b856787 in the Show a line coverage summary of the most impacted files.
Updated |
Review follow-ups for #2425: - Every pool close/reclaim row-clear now deletes only a row on the command's chain and PaymentPool. A pool id repeats across deployments, so a refusal against an old --payment-pool-address could delete the live row for the same id on the current deployment. - reclaim --pool opens the client store best-effort on its refusal path: a store another process holds warns instead of replacing the refusal. - A skipped Closing/Closed pool whose row-clear faults counts as "row not cleared" and fails the sweep, the same as a landed close; reclaim --all prints the count too. - forget_not_open owns the not-Open guard and returns NotOpenClear, so no caller can clear an Open pool's row. - CloseUnrecorded renders its store fault inline next to "failed"; reclaim_all matches ErrorClass exhaustively; refusals keep their full chain; docs follow the new behavior. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When a
closePoolorreclaimmined but its run could not clear the client-store row (the clear faulted, or the tx's outcome was unknown), every re-run stopped at a status refusal or skip before it touched the store. The row survived, and a later fetch reused a closing or closed pool whose vouchersredeemManyrejects.Each
close/reclaimthat reads a pool asClosingorClosednow clears its row:close --poolrefusalclose --allskipreclaim --poolrefusal (SkipInWindow/SkipClosed)reclaim --allskip (SkipInWindow/SkipClosed)pool close/pool reclaim(forget_on) deletes only a row on the command's chain andPaymentPool. The landed-tx paths are included. A pool id repeats across deployments, so a command against an old--payment-pool-addressmust leave the live row for the same id alone.LocalBookkeeping::DaemonOwnedkeeps its "row untouched" report.row not clearedand fails the sweep, so a failed repair does not read as success.From the #2430 review:
close --allcounted a landed close whose row-clear faulted as "failed to close". That error is now aCloseUnrecorded, whichBatchTally::record_errorcounts as closed plusrow not cleared. The sweep still exits nonzero, which keeps the existing policy ("exit non-zero when a landed on-chain effect cannot be recorded locally"). The message puts the store fault next to "failed" and names a re-run ofclose --pool, which now clears the row.Closes #2425
Reviewer notes
LocalBookkeeping::forget_not_open,NotOpenClearandforget_on(crates/cli/src/commands/pool.rs).forget_not_openowns the not-Open guard, so anOpenpool or the hidden invalidsol!status never touches the store.forget_onreads the row and deletes it in two transactions. That is safe because the client redb is held exclusively by this process.LocalBookkeeping::Storeshape. It now holds{ store: &dyn BuyerPoolStore, deployment }, so the tests can useMemoryBuyerPoolStoreand a faulting store. ItsDebugderive was dropped because the trait object has noDebug.--poolexit code,pool list(still read-only), and the reclaim landed-path row-clear (still a warning).Asserterqueue duringget_receiptand takes the receipt answer. The tally is tested on the realgrade_local_forgeterror instead.reclaim()/close()wiring itself is not unit-tested. Its logic sits in tested helpers (refuse_reclaim,refuse_close,forget_not_open).crates/e2e/tests/cli_pool_reclaim_precheck.rs(close on-chain from the fixture, then assert that the CLI re-run clears the row) is a possible follow-up.Verification
cargo fmt -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run -p decdn-cli: 735 passedCARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-itemspre-commit run(all hooks pass)CHANGELOG.mdentry added. The older entry that said only the reclaim clears the row is updated.🤖 Generated with Claude Code