refactor(node): W1b-4 — seam capsule, CapsuleStore trait/handle carve (#1285)#69
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
… (#1285, #1298) Carves the on-disk capsule cache Node methods (cache_list_cached, cache_remove_cached, cache_fetch_and_cache, gap_fill_generation) into the CapsuleStore trait (seam 6's public surface), implemented by Node with the EXISTING method bodies moved unchanged from lib.rs. Also relocates maybe_backfill_capsule (previously in download.rs's `impl crate::Node` block) into the same trait, byte-identical. Lands the W1b-2-deferred self-reference bring-up hooks (set_self_ref/ arc_self) here, per the locked plan's tangle (b): they exist ONLY to let `&self` capsule read handlers spawn an owned-Arc background pull — a capsule-store concern, not a peer-network one. They stay a plain Weak<Node>/Arc<Node> pair for this behaviour-preserving pass; full struct decomposition into Arc<dyn CapsuleStore> is W1c's job. async_trait-boxed (matching the other seam traits) so it stays dyn-compatible for the future Arc<dyn CapsuleStore> handle (W1c). Every caller now brings CapsuleStore into scope: same-crate (peer.rs's set_self_ref call, content_serve.rs's maybe_backfill_capsule calls, chainwatch.rs's NodeGapFiller::gap_fill delegating to gap_fill_generation) via `use crate::CapsuleStore`, and the two EXTERNAL crates that call the cache_* methods directly on a dig_node_core::Node — dig-node-service's control.rs and dig-wallet's lib.rs — via `use dig_node_core::CapsuleStore`. No signature or behaviour changed anywhere. Depends on W1b-3 (merged, #1285). Co-Authored-By: Claude <noreply@anthropic.com>
MichaelTaylor3d
left a comment
There was a problem hiding this comment.
PASS (single correctness gate, §1.10 — behaviour-preserving trait-extraction).
Verified read-only against HEAD 79af7c4:
-
Zero logic change. All 5 method bodies (
cache_list_cached,cache_remove_cached,cache_fetch_and_cache,gap_fill_generation,maybe_backfill_capsule) carved intoseams/capsule/capsule_store.rsare byte-identical modulo path-qualification only:module_path→crate::module_path,backfill_on_miss_enabled()→crate::download::backfill_on_miss_enabled(),crate::Bytes32(..)→Bytes32(..)(import from digstore_core;crate::Bytes32is a re-export ofdigstore_core::Bytes32per lib.rs:40 — identical type),std::sync::Weak::upgrade→Weak::upgrade. No changed assertions/control flow. -
8 cross-crate use-sites are import-only. dig-node-service/src/control.rs (
use dig_node_core::{CapsuleStore, Node}) and dig-wallet/src/lib.rs (use dig_node_core::CapsuleStore) add ONLY theuseline so the now-trait methods resolve; no call-site signature/behaviour change. Internal seams (chainwatch.rs, peer.rs, content_serve.rs) likewise addCapsuleStoreto theiruse crate::{...}— import-only. -
set_self_ref/arc_self behaviour-preserving. Moved from the inline
impl Nodein lib.rs into the trait as plainWeak<Node>/Arc<Node>(fullArc<dyn CapsuleStore>correctly deferred to W1c). Bodies identical. -
Back-compat re-export
pub use seams::capsule::CapsuleStoreat crate root keeps the path importable; visibility not widened beyond the move. -
Versions agree (core 0.13.6, binary 0.47.6); version-increment gate green; 0 unresolved review threads; correctness CI green (Clippy, CodeQL, Analyze rust/actions/js, Test+coverage, Rustfmt, commitlint).
Merge-ready. NB for orchestrator: the three package-build jobs (.msi/.deb/.pkg) were still pending at review time — confirm green before merge per branch protection.
What
W1b-4 (5th of the 7 W1b sub-PRs, #1285): carve the cache_*/gap_fill/backfill `impl Node`
methods into a `CapsuleStore` trait + handle under `seams/capsule/`, and land the
`set_self_ref`/`arc_self` deferral from W1b-2 (this is their home per the locked plan's
tangle (b)). Byte-identical bodies relocated, no logic change.
Depends on W1b-3 (merged, origin/main @ 335ac46).
Closes nothing yet (tracking #1285).