Skip to content

fix(cli,node): read the node's buyer pools from the node, not a store beside it - #2081

Merged
thiras merged 3 commits into
mainfrom
fix/2078-pool-cli-node-store
Sep 20, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/2078-pool-cli-node-store

Conversation

@thiras

@thiras thiras commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Closes #2078.

The defect

Every decdn pool subcommand opened <data_dir>/buyer-pools.redb — the client's store. A daemon keeps its buyer state in <data_dir>/buyer.redb, so on a node host the CLI read and wrote a different file than the node it was pointed at, and Database::create manufactured that file where none existed. decdn pool list --config /etc/decdn/node.toml printed pools=0 on a node that had just logged a successful pool adoption, and left a stray 0660 store beside the daemon's 0600 ones.

The constraint that shapes the fix

redb takes a process-exclusive advisory lock for the lifetime of a Database, and even ReadOnlyDatabase "may not be opened concurrently with a Database". The daemon holds buyer.redb from bring-up through shutdown. The CLI can never read the node's buyer store from disk while the node is running — so #2078's suggested direction (1), "resolve the node's store", is not implementable live. The read has to come from the daemon.

What changed

New admin_v1_pools + decdn node pools — the buyer-side counterpart of admin_v1_lanes / decdn node lanes: every pool the buy leg tracks, the deposit it believes each holds, and the per-lane amount already signed away to each provider. A node with no [blockchain] wiring answers BUYER_POOL_UNAVAILABLE_CODE (-32011) rather than an empty list — "this node never pays for pulls" and "this node owns no pools" send an operator hunting a stranded deposit in opposite directions, and that ambiguity is what the method exists to remove.

A data dir containing buyer.redb is recognized as a daemon's, and each subcommand does the honest thing there:

Command On a node data dir
list Routes to the daemon over the admin RPC. Always prints store=<path>, so pools=0 names the file that produced it. An unreachable daemon is an error, not a fallback to the unrelated client store.
open / top-up Refused. They escrow USDC into a store the node never reads — manufacturing exactly the stranded deposit #2075 exists to prevent.
close --all / reclaim --all Refused. They enumerate from chain by keystore address, so they would close the pool the daemon is paying from right now. (runbook.md warned about this in prose; now it is a guard.)
close --pool / reclaim --pool Still run their on-chain leg — the stranded-pool recovery path — but no longer grade a no-op forget as a clean close. They name the daemon row they could not touch.

No pool command creates a store file inside a node's data dir any more.

Also fixed: the blind spot that hid the original stranded pool

reconcile_owned_pool returned on AdoptionCheck::AlreadyTracked before enumerating getPools, so report_stranded_pools was reachable only on the adoption path. The steady state — store intact, a deposit stranded by an earlier build — was permanently silent; only a direct getPools read surfaced the ~9.95 USDC the issue found.

The enumeration now runs on every bootstrap, and the stranded set is measured against the pool the store names rather than the one an adoption would have selected. A fully-redeemed Open pool is no longer listed: reclaim refunds deposit - totalRedeemed, so there is nothing to recover and the warning's own promise would be false.

decdn_buyer_pool_adoption_failures_total is deliberately not widened. Its documented meaning — and the runbook's reading of it — is "could not tell whether it already owned a pool and is about to open a second one". An enumeration failure on the already-tracked path was never going to adopt anything, so it warns instead.

Verification

  • cargo clippy --workspace --all-targets, cargo fmt --check, RUSTDOCFLAGS="-D warnings" cargo doc — clean.
  • cargo nextest run --workspace — 3649 passed. (One flaky retry in upstream_hash_mismatch_is_rejected, unrelated and untouched; passes in isolation.)
  • cargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(node_pull_pool_adopt)' — passes. Extended to drive the real decdn binary against the live daemon: node pools reports the adopted pool, pool list --config <node.toml> names buyer.redb and shows that pool, no buyer-pools.redb appears, and pool open is refused. This assertion caught a real bug in its own first draft — the pool open invocation was missing a required flag, so clap rejected it before the guard ran.
  • crates/cli/tests/pool_list.rs holds the regression: a data dir with a buyer.redb fails with a message naming that file and leaves no buyer-pools.redb behind.

Docs

docs/runbook.md § Cause (2) rewritten — its step 1 previously told operators pool list "shows nothing while the chain says otherwise", which on a node host was unconditional and so confirmed the hypothesis on a healthy node. Also adr/appendix-local-admin-http.md (method table), adr/012-client.md (the two-store relationship), README.md, CHANGELOG.md.

Deliberately out of scope

🤖 Generated with Claude Code

… beside it (#2078)

Every `decdn pool` subcommand opened `<data_dir>/buyer-pools.redb`, the
client's store. A daemon keeps its buyer state in `<data_dir>/buyer.redb`,
so on a node host the CLI read and wrote a different file than the node it
was pointed at — and `Database::create` manufactured that file where none
existed. `pool list` printed `pools=0` on a node that had just logged a
successful pool adoption.

redb holds a process-exclusive lock on `buyer.redb` for the daemon's
lifetime, and even `ReadOnlyDatabase` cannot open it concurrently, so the
CLI can never read that file from disk on a live node. The read has to
come from the daemon.

- `admin_v1_pools` + `decdn node pools`: the buyer-side counterpart of
  `admin_v1_lanes`. A node with no buyer leg answers
  `BUYER_POOL_UNAVAILABLE_CODE` rather than an empty list — "never pays
  for pulls" and "owns no pools" call for opposite operator responses.
- `pool list` routes to the daemon on a node data dir and always prints
  `store=<path>`, so `pools=0` names the file that produced it.
- `pool open` / `top-up` refuse there: they escrow USDC into a store the
  node never reads, manufacturing the stranded deposit #2075 prevents.
- `close --all` / `reclaim --all` refuse: they enumerate from chain by
  keystore address, so they would close the pool the daemon is paying from.
- `close --pool` / `reclaim --pool` still run their on-chain leg, but no
  longer grade a no-op `forget` as a clean close.

Also fixes the blind spot that hid the original stranded pool:
`reconcile_owned_pool` returned on `AlreadyTracked` before enumerating, so
`report_stranded_pools` was reachable only after an adoption. It now runs
every bootstrap, measured against the pool the store names, and skips
fully-redeemed pools that would refund nothing.
`decdn_buyer_pool_adoption_failures_total` is deliberately not widened.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI lite review requested due to automatic review settings September 20, 2026 13:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved critical and moderate findings affect node-store classification, pool lifecycle recovery, RPC errors, and pool output.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity · 1 Low severity

Open (3)
What changed in this PR

This PR routes node buyer-pool inspection through admin RPC, prevents unsafe client-store operations on node data directories, and improves stranded-pool reconciliation.

Changes:

  • Adds admin_v1_pools and decdn node pools.
  • Guards pool mutations and chain-wide operations on node data directories.
  • Updates reconciliation, tests, documentation, changelog, and ADRs.
File Reviewed change Findings
README.md Documents node pools. No findings.
docs/​runbook.md Updates buyer-pool diagnostics and recovery. nit (3 votes): Qualify the absence of stranded-pool warnings when enumeration fails. nit (1 vote): Update restart guidance for surviving closing/reclaimed rows.
crates/​node/​src/​runtime/​mod.rs Shares the buyer store with admin RPC. No findings.
crates/​node/​src/​channel_store.rs Uses the node-store filename. No findings.
crates/​node/​src/​buyer_channel.rs Sweeps stranded pools during bootstrap. critical (2 votes): A surviving closed/reclaimed row is treated as active after restart, preventing adoption of another pool and allowing reuse of the closed pool.
crates/​node/​src/​admin.rs Implements buyer-pool RPC handling. No findings.
crates/​incentive/​src/​buyer_pool_table.rs Defines client and node store constants. No findings.
crates/​incentive/​src/​buyer_pool_redb.rs Uses the client store constant. No findings.
crates/​e2e/​tests/​node_pull_pool_adopt.rs Adds live CLI regression coverage. No findings.
crates/​common/​src/​cli/​pool.rs Adds pool-list options and documentation. No findings.
crates/​common/​src/​cli/​node.rs Adds PoolsArgs. No findings.
crates/​common/​src/​cli/​mod.rs Exports pool CLI arguments. No findings.
crates/​common/​src/​admin.rs Adds buyer-pool DTOs, errors, and RPC method. nit (1 vote): The unavailable response is unreachable for a running daemon because buyer wiring is currently mandatory.
crates/​cli/​tests/​pool_list.rs Tests node/client store routing. No findings.
crates/​cli/​tests/​admin_rpc.rs Tests buyer-pool RPC behavior. No findings.
crates/​cli/​src/​commands/​pool.rs Adds classification, routing, guards, and rendering. critical (1 vote): Relying only on buyer.redb can misclassify a reset node directory and recreate buyer-pools.redb (also at lines 1316 and 1366). moderate (1 vote): Transport fallback text masks application RPC errors. moderate (1 vote): Normal output omits per-lane spend and delivery details.
crates/​cli/​src/​commands/​node.rs Implements decdn node pools. No findings.
CHANGELOG.md Records CLI and admin changes. nit (1 vote): Limit the defect description to store-backed pool commands.
adr/​appendix-local-admin-http.md Documents the new RPC method. No findings.
adr/​012-client.md Documents separate buyer stores. No findings.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/cli/src/commands/pool.rs Resolved
Comment thread crates/node/src/buyer_channel.rs Resolved
Comment thread docs/runbook.md Resolved
@github-actions

github-actions Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 83.29% (was 83.23%, ▲ +0.06%) — 83414/100143 lines

File Coverage Lines Δ
crates/cli/src/commands/node.rs 77.20% 1131/1465 ▼ 0.38%
crates/cli/src/commands/pool.rs 69.65% 778/1117 ▲ +4.69%
crates/common/src/admin.rs 95.07% 135/142 ▲ +1.21%
crates/common/src/cli/mod.rs 100.00% 3/3 ● 0.00%
crates/common/src/data_dir.rs 100.00% 28/28 new
crates/incentive/src/buyer_pool_redb.rs 94.25% 164/174 ● 0.00%
crates/node/src/admin.rs 92.14% 1125/1221 ▼ 0.57%
crates/node/src/buyer_channel.rs 69.13% 1337/1934 ▲ +5.90%
crates/node/src/channel_store.rs 86.80% 1078/1242 ● 0.00%
crates/node/src/runtime/mod.rs 47.91% 1168/2438 ▼ 0.04%
History
Commit Total Δ vs base
c6747b5 83.25% ▲ +0.02%
d98a9f4 83.27% ▲ +0.04%
88913b3 (HEAD) 83.29% ▲ +0.06%

@thiras

thiras commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

Review response

Both high findings were real and are fixed; details in the threads. Summary of what changed and what I'm not changing.

Fixed

1. Classifier keyed only on buyer.redb — the file an operator loses in exactly the reset this PR is about. The repo's own e2e deletes it. Now keys on the whole daemon store set, and the filename constants moved to a single home (decdn_common::data_dir) so the marker set cannot drift from the files the daemon actually opens.

2. Stale row pinned the buy leg to a closed pool — reuse_or_report reads the tracked row with no status check, so "restart the daemon" did not heal it and my runbook said it would. Bootstrap now checks the tracked pool against the chain's open set, drops a stale row, and adopts or opens a replacement. Predates this PR, but the PR made the wrong claim load-bearing, so it belongs here.

3. Runbook overstated warning absence — qualified on a completed sweep, with both failure log lines named.

Also taken: the CHANGELOG now says "every store-backed pool subcommand" (assign touches no store), and the list error no longer tells an operator to start a daemon that answered and refused — a Call error now gets its own wording.

Not changing

"Normal output omits per-lane spend and delivery details." Deliberate. write_buyer_pools renders the same five columns as write_pools (POOL OWNER TOKEN DEPOSIT LANES), which is the point — an operator comparing a client listing against a daemon listing should see one view, not two dialects. Per-lane detail is in --json on both paths, symmetrically. Adding lane rows to only the daemon table would break the symmetry the shared renderer exists to provide.

"The unavailable response is unreachable for a running daemon." Factually right — the production runtime always attaches the buyer store — but the arm is not dead code. It mirrors DHT_UNAVAILABLE_CODE, whose doc states the same posture, and it is exercised by unit and wire tests. The only alternatives for that arm are an empty list (precisely the ambiguity this method exists to remove) or an unwrap (denied workspace-wide). I've made the doc say plainly that production always wires it.

Verification

Full workspace suite, clippy -D warnings, rustfmt, rustdoc, and the crate-edge guard all clean. The anvil e2e re-run covers the live path end to end.

thiras and others added 2 commits September 20, 2026 16:41
…node-dir marker

Review follow-ups on #2078.

`reuse_or_report` reads the tracked buyer row with no status check, and
bootstrap answered `AlreadyTracked` for any row at all. A pool closed or
reclaimed out of band — which is what `decdn pool close --pool` from a
node host leaves behind, since it cannot write the daemon's store —
pinned every later pull to a pool `redeemMany` rejects every voucher
against, and restarting did not heal it. Bootstrap now checks the tracked
pool against the chain's open set, drops a stale row, and adopts or opens
a replacement. A chain that cannot be read leaves the row alone.

The CLI's node-data-dir classifier keyed on `buyer.redb` alone — the one
file an operator loses in exactly the reset this change is about, and the
one the `node_pull_pool_adopt` e2e deletes. It now keys on the whole
daemon store set and names the marker it found. The filename constants
were duplicated across `buyer_pool_table.rs` and `channel_store.rs`,
which is what made a partial set easy to write; they move to one home in
`decdn_common::data_dir`, which node, cli and incentive all already
depend on.

Also: `pool list` no longer tells an operator to start a daemon that
answered and refused, the runbook qualifies "no stranded warning" on a
completed sweep, and the CHANGELOG scopes the defect to store-backed
subcommands (`assign` touches no store).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review follow-ups on #2078.

The stale-row drop judged a tracked pool by its absence from the set of
pools read as `Open`, and a `getPool` call that faulted produced that
same absence. One transient RPC error at bootstrap — that call has no
retry — would delete the node's only record of a funded pool, and the
next miss would escrow a second deposit: the #2072 failure, self-
inflicted, and invisible, because the stranded-pool report cannot name a
pool it failed to read either.

`OwnedPools` now keeps "read, and not open" apart from "not known", and
`TrackedStatus` makes the third state explicit. A row is dropped only on
a successful read returning a non-`Open` status. An id `getPools` does
not list is unknown too: that view derives ids from `ownerPoolNonce` and
`closePool`/`reclaim` only change status, so it is append-only and an
absent id has no on-chain producer.

Corrected claims that were simply false:

- `redeemMany` does not reject every voucher on a closed pool; a
  `Closing` pool redeems until its dispute deadline. Fixed in the
  drop rationale, the CHANGELOG and the runbook's urgency argument.
- `BUYER_POOL_UNAVAILABLE_CODE` blamed a missing `[blockchain]` section.
  The runtime attaches the store unconditionally and a node without that
  section does not start, so the operator-facing message named a cause
  that cannot occur.
- Three comments asserted the daemon was running from mere file
  presence. The row survives because `decdn pool` has no code path to
  `buyer.redb`, not because of a lock.
- The ADR and CLI docs named only `buyer.redb` as the node marker, where
  the code checks the whole daemon store set.

The guards now run before chain coordinates are resolved, so they refuse
without demanding an `rpc_url`, and CLI subprocess tests pin them at
their call sites — deleting any one of them now fails the default CI
job. Daemon-path decode warnings move to stderr, matching the client
path, and `decdn node pools` names the admin URL it asked.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@thiras

thiras commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

Multi-agent review round — one critical regression found and fixed

Ran five specialised review agents over the branch. Three independently found the same critical bug, which I introduced in the previous round of review fixes. Pushed as 88913b30.

Critical: a failed status read deleted a live pool's row

open_pools swallowed a per-pool getPool error with only a warn!, so a pool whose status read faulted was indistinguishable from one the chain reported as closed. The stale-row drop added in d98a9f4e then deleted the row.

One transient RPC error at bootstrap — that call has no retry — would delete the node's only record of a funded pool, and the next miss would escrow a second deposit. That is the #2072 failure, self-inflicted, and silent: the stranded-pool report cannot name a pool whose read failed either, so nothing would have said so.

OwnedPools now keeps "read, and not Open" apart from "not known", and TrackedStatus makes the third state explicit. A row is dropped only on positive evidence.

The code reviewer supplied a correction that changed the fix: getPools is append-only. It derives ids from ownerPoolNonce, and closePool/reclaim only mutate status, so a pool is never delisted. An id it does not list therefore has no on-chain producer — an anomaly, not evidence of closure — and now reads as unknown too. That also meant one of my tests modelled a chain state the contract cannot produce; it has been rewritten to the realistic shape (listed, Status::Closed).

Pinned by a_tracked_pool_whose_status_read_failed_keeps_its_row and a_tracked_pool_the_chain_does_not_list_keeps_its_row.

Factual corrections

  • redeemMany does not reject every voucher on a closed pool. PaymentPool.sol:591-593 rejects Closed outright but Closing only once block.timestamp >= disputeDeadline — so inside the 48-72h window vouchers still redeem. That claim was load-bearing in the drop rationale, the CHANGELOG, and the runbook's "do not defer it" argument. All four corrected.
  • BUYER_POOL_UNAVAILABLE_CODE blamed a missing [blockchain] section. The runtime attaches the store unconditionally, and a node without that section fails config resolution and never starts. The operator-facing RPC message named a cause that cannot occur.
  • Three comments asserted daemon liveness from file presence, including an operator-facing stderr line. The row survives because decdn pool has no code path to buyer.redb — not because of a lock, which may not be held at all if the node is stopped.
  • The ADR and CLI docs named only buyer.redb as the node marker where the code checks the whole daemon store set.

Test gaps closed

  • Guards were unit-tested on the enum, never at their call sites — deleting the top-up or close --all guard left the default CI job green. Added CLI subprocess tests. Writing them surfaced that the guards ran after resolve_chain, so they demanded an rpc_url before refusing; moved earlier, which is both better behaviour and a test that fails for the right reason.
  • One test passed for the wrong reason. Asserter faults only on over-calls, so my "proven by mock consumption" claim was vacuous — the test stayed green against the pre-fix early return. It now asserts the queue drained.
  • Added the missing "the row survived" assertion to the failed-sweep test, and --json provenance assertions.

Deliberately not changed

  • Metric semantics. Two agents wanted a failed forget counted in decdn_buyer_pool_adoption_failures_total. That would give the counter two meanings and falsify the runbook's "any increment means the node was about to open a second pool". A node whose forget failed is stuck, not duplicating — it warns instead.
  • close --pool exiting 0. Suggested as a non-zero exit. Left as-is: the on-chain leg genuinely succeeded, and the warning now tells the operator to run decdn node pools to find out whether the closed pool is the one in use, rather than guessing.

Follow-ups worth their own issues

  1. decdn fetch / bundle pull open the client store on an unclassified data dir with the node's own keystore, so they can escrow a second pool under the node's operator address. Pre-existing and arguably worse than the path fixed here.
  2. crates/cli/src/commands/doctor/state.rs keeps a second, already-drifted copy of the daemon store-file list — it names a floor-loss.redb that nothing creates any more. Should point at DAEMON_STORE_FILES.
  3. No offline read path for a stopped node's buyer.redb, where redb's lock is released and a read-only open would work.

Full workspace suite 3662 passing, clippy/fmt/rustdoc/crate-edges clean, anvil e2e green.

@thiras
thiras merged commit b377d3e into main Sep 20, 2026
25 checks passed
@thiras
thiras deleted the fix/2078-pool-cli-node-store branch September 20, 2026 14:23
thiras added a commit that referenced this pull request Sep 21, 2026
…2085)

* fix(cli,node): source the doctor's store-file list from data_dir (#2083)

`decdn doctor` kept its own copy of the names of the store files a daemon
owns, and that copy had drifted: it listed `floor-loss.redb`, which nothing
creates. The list drives doctor's permission and zero-length checks, so a
fifth daemon store would have been checked by nothing.

The iteration now comes from `decdn_common::data_dir::DAEMON_STORE_FILES`
plus `CLIENT_BUYER_DB_FILE`, the same names `channel_store.rs` and
`buyer_pool_redb.rs` already use. A new `channel_store` test opens a
`PersistentPoolStateStore` in a temp dir and asserts every
`DAEMON_STORE_FILES` entry exists afterwards and that no `.redb` file
outside the set was created — the claim `daemon_marker` rests on, and with
it the node-vs-client classification from #2078.

Two stale docs go with it: `buyer_pool_table`'s module doc named a
floor-loss family and the wrong module for `PersistentPoolStateStore`, and
the node's buyer-table adapter said it viewed `lanes.redb`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(cli): let whoami report a keystore the shared password does not open (#2008)

`decdn whoami` resolved one password and applied it to both the node and
the client keystore. `key-gen` writes those two at different times and
prompts for each, so they can hold different passwords — and when they did,
the first `Mac Mismatch` aborted the command. Nothing printed: not the node
id, not the paths, not the address of the keystore whose password was
correct.

The shared password stays the common case and is still tried first. A
keystore it does not open now degrades its own line to a note naming the
keystore and the reason, and on a TTY that keystore gets one prompt of its
own before the note. Every other line still prints and the command exits 0,
which is what the module doc already promised for the node id and the paths.

`eth_address_line` returns the line plus a retry flag instead of a
`Result`, so the decrypt failure is a value the caller can act on rather
than an abort, and the retry decision stays testable without a TTY.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(cli): refuse a fetch into a node data dir nobody named (#2082)

`decdn pool` refuses to escrow into a `decdn-node` daemon's data dir
(#2078). `decdn fetch` and `decdn bundle pull` opened the client store on
the same resolved `data_dir` with no such check — and the keystore defaults
to that dir too, so on a node host they opened a client pool under the
node's OWN operator address. The daemon then reports that deposit as
stranded and tells the operator to close a pool a human may be fetching
against, and after a store reset its adoption path can take the pool over,
putting two independent watermarks on one lane.

A human buying on a node host is a legitimately separate client, so the
rule is weaker than `pool`'s: an explicit `--data-dir` naming the node's dir
is accepted, and an implicit one is not. `identity.data_dir` from
`~/.decdn/node.toml` is the implicit case, so `ResolvedChain` now carries
which step of the ladder produced the dir, not just the path.

The classifier moves out of `pool.rs` into `commands::buyer_store`, where
`fetch` and `bundle pull` can reach it, and the guard and the store open
are fused: `open_client_store_for_escrow` and `open_client_store_for_buy`
return the store, so a future subcommand cannot reach one without passing
the check.

ADR 012 records the asymmetry beside the store-split paragraph — it was an
omission there, not a decision.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* feat(cli,incentive): read a stopped node's buyer store off disk (#2084)

#2081 routed `decdn pool list` on a node data dir through `admin_v1_pools`
and deliberately did not fall back to the client store, because falling back
to a different file with unrelated contents is the defect #2078 was about.
The consequence was that a stopped node's `buyer.redb` became readable by
nothing: a post-mortem after a crash, or a look at a host that is down for
maintenance, had no route.

redb holds its process-exclusive lock only for the lifetime of an open
`Database`, so the impossibility is specific to a running daemon — and the
lock is also what tells the two cases apart. On a refused admin connection,
`pool list` now tries `ReadOnlyBuyerPoolStore::open_file` against the
daemon's own `buyer.redb`:

- it opens, so no daemon holds it: render it, labelled `store=… (read from
  disk; no daemon running)` and `source=node_store_offline` under `--json`,
  its own value rather than the client store's;
- it is write-locked, so a daemon IS running: the admin URL or admin_port is
  wrong, which is a better answer than "start decdn-node";
- anything else: the previous error, plus what the disk read found.

`ReadOnlyBuyerPoolStore` takes a file path rather than a data dir, and never
creates — `open_read_only` cannot, which is what keeps #2078 closed. A
`DatabaseError::RepairAborted` gets its own `StoreError::NeedsRepair`,
because a crashed daemon's store is exactly the file that needs redb's
repair pass and a read-only open cannot run one.

Read-only and read-write loads share one decode-and-skip implementation:
`load_all_from` is generic over `redb::ReadableDatabase`, so the skip
semantics cannot fork between them.

Clearing a stopped daemon's row from `pool close` / `reclaim` is a separate
decision and is not included: it needs the write lock this type deliberately
does not take.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* feat(cli): add pool list --all, the chain-authoritative pool view (#2077)

`decdn pool list` read only the local buyer store, so it could not show a
pool whose store row was gone — which is exactly the situation an operator
runs it in. A reset `identity.data_dir` loses the only local record of a
funded `PaymentPool` deposit; the operator's first instinct is `pool list`,
and it printed nothing, because the store is the thing that was lost.

`--all` enumerates `getPools` by the keystore address and shows every pool
in every lifecycle state with its on-chain deposit, total redeemed, and
reclaim window, marking which ones the local record tracks. `close --all`
and `reclaim --all` already worked this way; `list` was the odd one out.

The `TRACKED` column distinguishes `no` from `?`: a store that could not be
read at all leaves it unknown rather than claiming every pool is untracked,
since an unreadable store is the case the flag exists for. `--all` is NOT
refused on a node's data dir — the sweep refusal covers the two commands
that write, and a node host is where this view is most needed.

`PoolListArgs` now flattens `PoolChainArgs`, as `close` and `reclaim` do, so
every `pool` subcommand shares one precedence path. `--data-dir` is
unchanged; the chain flags are new and only `--all` reads them.

The runbook section that had to be written around this gap now uses it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* docs(changelog): record the five CLI fixes (#2084, #2083, #2082, #2077, #2008)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* test(e2e): drive pool list --all through the store-loss it exists for (#2077)

The unit tests cover the renderers; nothing covered the chain read. This
journey opens a real pool on anvil, deletes the client store — the reset a
moved volume performs — and shows that `pool list` then reports nothing
while `pool list --all` still names the pool, its escrowed deposit, and
`tracked=false`. That sequence is the issue, not a listing shape.

No node is involved: a chain read and a store read, nothing paid.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(cli): print the root cause on a whoami keystore note (#2008)

The note carried the full error chain, whose outer layer already repeats the
keystore path the note names. The innermost message is the useful part and
is what separates a wrong password from a broken file: the line now reads
`… did not open with this password: Mac Mismatch`, which is the string the
issue's repro produced as a fatal error.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(cli): an undecodable local row is unknown, not untracked, under --all (#2077)

`tracked_pool_ids` built its set from `BuyerLoad.pools` and dropped
`BuyerLoad.skipped`, so a pool whose local row exists but will not decode
rendered as `TRACKED=no` / `tracked: false`. That is a false claim with a
wrong remedy attached: `no` sends the operator to `pool close` to recover a
stranded deposit, when the store does hold a row for that pool and what it
needs is the record repaired. `pool_id` is the table's primary key, so it
survives whatever corrupted the value bytes — the id is always known.

`daemon_pool_ids` dropped `BuyerPoolsResponse.skipped` the same way. That
field crosses the admin wire precisely because the daemon cannot decode
those rows either.

`TrackedPools` now carries both sets and `verdict` answers per pool:
`Some(true)` decoded, `None` for a row that will not decode, `Some(false)`
for no row at all. `None` for the whole store still means it could not be
read, which `local_store_read` distinguishes in `--json`. The verdict is
per-pool on purpose — one bad row must not blank the column for the pools
either side of it.

`--all` also names the undecodable ids on stderr now, so it is no longer the
one listing that stays silent about a deposit stranded by an unreadable
record.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(cli,incentive,node): review findings on the CLI batch

**`pool list --all` was neither read-only nor loud.** Its TRACKED lookup
opened the client store with `RedbBuyerPoolStore::open`, which creates —
so the command documented as writing nothing manufactured the very store
it reports on, and a lost store (the condition the flag exists to surface)
became indistinguishable from one tracking nothing. Every local read on
that path now goes through `ReadOnlyBuyerPoolStore`, and an absent store is
an answer (nothing tracked), not an unknown.

Five failures were swallowed by `.ok()` behind a single `?` glyph: a
zero-length store whose own error says "restore from backup", a store
another `decdn fetch` holds, a crashed daemon's unrepaired file, a
malformed `--admin-url`, and `--timeout-ms 0`. Each now names itself on
stderr. On a node dir only `AlreadyOpen` routes to the admin RPC — that is
the one failure meaning "a daemon holds this file"; the rest are about the
file and are reported as such.

`write_chain_pools` gained `local_store=read|unreadable`. Without it the
table showed a column of `?` with no way to tell "no local answer at all"
from "these rows will not decode" — a distinction only `--json` carried,
for remedies that are opposites.

**The `AlreadyOpen` message shipped garbled.** Two missing line
continuations baked 14-space runs into the operator-facing string for the
PR's headline new diagnosis. `cargo fmt` does not touch string literals and
the test grepped for `"admin URL"`, which the pre-fix message also
contains — so the assertion now pins the claim that actually distinguishes
them.

**`StoreError` stopped prescribing a caller's remedy.** `NeedsRepair` named
`decdn-node` in a shared error type reachable from a client store; it now
states the condition and the call site names the process. New `Absent`
variant: a data dir whose store was deleted to force re-adoption is a
routine state, not an errno.

**`TrackedPools` is a map.** Two sets left disjointness to prose, and
`from_wire` dropped ids `PoolId::from_str` rejected — silently rendering a
pool the daemon is paying from as `no`, which reads as a deposit to
recover. One unparseable id now makes the whole answer unknown.
`decdn-node` pins the other half of the drift guard where the spelling is
produced.

**`BuyerStoreOwner::Client` carries its dir**, so `open_for_write` takes no
path: a verdict about one directory can no longer authorize a store in
another.

**`whoami` prints the reason before prompting.** The report is buffered, so
the retry prompt appeared with no context — and for a failure no password
can fix (a `0o644` keystore) it pointed at the password instead of the
mode. A prompt that cannot be read is annotated rather than reusing the
first attempt's note, which after a prompt reads as the password just
typed. The unused `Clone` on the secret-bearing `KeystorePassword` is gone.

**Stale docs.** Three more `lanes.redb` claims in `channel_store.rs` — one
asserting both tables share a file, which is false. Six changelog-voice
docstrings. A test docstring that had detached onto a helper, leaving its
test undocumented and asserting behavior this batch reversed. A dead match
arm. `PoolCommand::List` promised a `store=` line `--all` does not emit and
named one of four `source` values.

**Tests:** the `--all` sweep refusal must not reach `list` (nothing pinned
it); `local_store=unreadable` end to end; the wire round-trip on both
sides; a re-delete in the anvil journey so its no-creation assertion is
about `--all` rather than the plain listing that legitimately re-creates.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

decdn pool commands read the client's buyer-pools.redb, not the node's buyer.redb

2 participants