Skip to content

v4: port paid peering — ledgers, budgets, invoice settlement and access state #1369

Backlog

Description

@chappie-daemon

Target: v4 (before the #869 cutover). Filed from the v3 delta audit. #1036 records the port of the peering settings into behaviour as of 2026-11-02; this is the product that landed after it and is not in that issue's table.

v3 shipped, in order (all on main):

PR Date What
#1087 11-09 paid peering billing ledger, operator side
#1088 11-15 deliver paid peering invoices, gate feeds on payment
#1089 11-16 renew, lapse and expose paid peering access
#1167 11-18 buyer invoice ledger and budget primitives
#1168 11-20 decide and pay peer invoices within budgets
#1169 11-22 ingest and surface auto-paid peer invoices

Source: src/services/peering-billing-service.ts, src/services/peering-buyer-service.ts, src/repositories/peering-invoice-repository.ts, src/repositories/peering-payment-repository.ts, src/app/peering-sync-worker.ts, src/cli/commands/peering.ts, six migrations (migrations/20261109_120000 … 20261125_120000), and docs/PEERING.md (18,956 bytes) as the operator-facing contract.

v4 today: the settings types and validation exist (crates/nostream-config/src/settings.rs:805-860, PeeringScope/PeeringTerm/PeeringPeer/PeeringSettings) and NIP-11 advertises the fee object (crates/nostream-relay/src/nip11.rs). No ledger, no invoice, no decision path, no access state, no feed gating: git grep -i "auto_pay\|paid_peering\|on_demand" crates/ at rewrite/main returns nothing.

Oracle for the port: v3's Gherkin features, which are behaviour, not prose — test/integration/features/peering/paid-peering-ledger.feature, peering-buyer-ledger.feature, peering-auto-pay.feature, peering-admin.feature, plus peering-sync.feature. Re-express them as Rust cases rather than inventing a spec.

Scope: the two ledgers and their budget windows, invoice issuance and delivery, the pay/decline decision with its audit row, access state (active, renewed, lapsed) and what a lapsed peer can retrieve, and the CLI surface that inspects them.

Acceptance: each named v3 feature file has a v4 counterpart that passes; a lapsed peer's feed stops and says why; a decision outside budget is refused with the same shape v3 refuses with; the migration carries existing v3 invoice rows or states why it does not.

Activity

  1. added
    rewrite
    post-v4
    on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    post-v4rewrite

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions