Skip to content

Cooperative close: node-as-buyer periodic reconcile of node→node channels #972

Closed

Description

@alpergundogdu

Follow-up to #947 (closed). On a cache miss a node pulls from an upstream provider and acts as the client, opening a buyer-side PaymentChannel (crates/incentive/src/buyer_channel.rs, #744). Today it "lets the upstream close & settle — or reclaims its own deposit after expiry." There is no fast path: idle buyer channels lock the node's deposit until expiry.

Scope (node-as-buyer side)

A periodic reconcile task in the node runtime that, for idle/quiescent buyer channels, runs the client-initiated cooperative-close flow (issue for that lands first — this builds on it) to reclaim the deposit immediately instead of waiting for expiry.

  • Pick idle channels (no voucher activity for N intervals — voucher_activity.rs already tracks this).
  • Drive the request-waiver + submit-cooperativeClose flow against the upstream.
  • Best-effort: on decline/offline, leave the existing expiry-reclaim path untouched.

Out of scope

  • The client flow primitive itself (separate issue — this depends on it).

Refs: ADR 003 §node→node + §Cooperative close, #744 (buyer channels), #957 (provider waiver).

Activity

  1. added
    status:blocked
    design:economics
    kind:feature
    prio:medium
    on Jun 22, 2026
  2. github-actions commented on Jun 22, 2026

    @github-actions

    🎯 Triage report

    Issue #972 requests a periodic background task in the node runtime to cooperatively close idle buyer-side PaymentChannels opened when the node acts as a client during cache-miss upstream pulls (crates/incentive/src/buyer_channel.rs). Without this, idle channels lock the node's USDC deposit until expiry. The implementation builds directly on the client-initiated cooperative-close primitive tracked in #971, which must land first.

    📊 Assessment

    Dimension Value Reasoning
    Type Enhancement New periodic reconcile task; no existing behavior broken
    Labels enhancement, technical, economics, blocked, medium Feature addition in Rust; touches payment channels and deposit recovery; explicitly blocked on #971; deposit-lock is a capital-efficiency issue, not a correctness blocker
    Coding agent Suitable (once #971 merges) Well-scoped: detect idle channels via voucher_activity.rs, invoke the cooperative-close flow from #971, fall back gracefully. Unambiguous success criteria. Ready to assign after the dependency lands.

    🔗 Similar issues

    💡 Notes and suggestions

    Implementation sketch

    • Add a ReconcileTask in crates/node/src/ as a tokio::spawn loop with a configurable interval.
    • Query voucher_activity.rs for buyer channels idle for ≥ N intervals (N should be config-tunable via config-types).
    • For each idle channel, run the client cooperative-close flow from Cooperative close: client-initiated fast refund (request waiver + submit on-chain) #971: send CooperativeCloseRequest → receive CooperativeCloseAuth → submit cooperativeClose on-chain via the binding in crates/incentive/src/payment_channel.rs.
    • On any failure (provider offline, declined, network error) log at warn level and continue — the existing expiry-reclaim path is the safety net; do not disrupt it.
    • Unit tests: (a) mock upstream declining waiver → assert expiry path is left undisturbed; (b) mock upstream accepting → assert cooperativeClose is submitted.

    Key files to touch

    • crates/node/src/ — new reconcile task wiring
    • crates/incentive/src/buyer_channel.rs — idle-detection hook / state query
    • crates/incentive/src/voucher_activity.rs — source of idle-interval data
    • crates/incentive/src/payment_channel.rs — existing cooperativeClose on-chain binding
    • config-types — optional: expose the idle-interval threshold as a tunable

    Anti-panic note: all indexing and Result handling must use combinators (no unwrap/expect) per the workspace Clippy deny policy.

    Generated by Agentic Triage for issue #972 · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

design:economicskind:featureprio:mediumstatus:blocked

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions