Skip to content

fix(node): start a source's warming allowance full, per ADR 041 - #2003

Merged
thiras merged 3 commits into
mainfrom
worktree-issue-1893-high-rate-pull
Sep 14, 2026
Merged

thiras merged 3 commits into
mainfrom
worktree-issue-1893-high-rate-pull

Conversation

@thiras

@thiras thiras commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1893 (does not close it — node_pull_topup stays ignored on a second, separate blocker described below).

Root cause of #1893's clean miss

The issue's premise that the miss was a silent PullMiss::Clean fold was wrong: an instrumented run shows the SERVER's decdn_serve_economics_refused_total ticking — the ADR 041 buy-margin gate skipped the seeder (PullMiss::BelowMargin, wire-identical NotFound).

Why: WarmingAllowance started a never-touched source's ledger at 0. The warm-up pull (a ~48 KiB speculative buy at 0.5 USDC/MB) debited rate × mb_of(bytes) = 500_000 and its single serve credited 0.9 × 500_000 = 450_000, leaving the seeder at −50_000. available() went false, so max_buy fell to the amortized floor (450_000 < the 500_000 quote) and every further buy from that seeder was skipped. At the default rate the same skim is ~1 µUSDC and invisible.

That contradicts ADR 041 §The per-source warming allowance: each source "carries an allowance capped at B", is cut off only "after the sink has spent its allowance B on duds", "each source's allowance resets to full" after a restart, and "a $5 budget … covers a large volume of unrecovered one-hit warming per source before it cuts a source off".

Change

  • crates/node/src/warming_allowance.rs: a source's first ledger entry holds the full budget (Bucket::full). Availability, the [-budget, +budget] clamp, credits and refill are unchanged. Docs updated.
  • Tests re-pinned to the ADR semantics:
    • unit: a_fresh_source_starts_with_the_full_budget, duds_spend_the_budget_then_block (replaces dud_drains_then_blocks, which encoded the one-dud cutoff);
    • node_origin_pull::attack_b_dud_flood_is_bounded_and_vindication_works: B = one market buy; one served dud stays warm, a second dud spends B, further buys refuse BelowMargin;
    • client_loopback::a_completed_serve_credits_the_source_through_the_background_aggregator: debits the whole budget to reach "spent".
  • crates/e2e/tests/node_pull_topup.rs: ignore reason + doc comment rewritten to the blocker that remains.

Remaining blocker (separate bug, not fixed here)

With the gate fixed, the fetch is admitted and streams, then stalls: the client fails upstream stalled: no progress for 30s. At the stall the SERVER shows decdn_node_pull_through_window_paused_total 4, no outbound stream, and no top-up / stall / refusal / voucher-reject counter movement on either node. Upstream paid ≈ 4.5 MB vs client paid ≈ 3 MB — one ramped credit window — so the pull leg is parked on RampPacer::Wait for a served-paid advance that never comes.

It is rate- and top-up-independent: the same journey at the default rate with the default working deposit stalls at the same point. The warm-up completes because it fits inside PULL_WINDOW_FLOOR. No existing e2e pulls a multi-MB blob node-to-node through the fused serve-miss path. DECDN_NODE_LOG="warn,decdn_node=debug" surfaces daemon debug logs through the harness (the issue noted they didn't; RUST_LOG comes from that variable).

Verification

  • cargo nextest run -p decdn-node: 1119/1119, including the review follow-ups (vindication tests now require the second serve; cap and -budget floor pinned).
  • cargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(node_to_node_coalesce)': pass.
  • node_pull_topup (run with the ignore removed): gets past the margin gate (no serve_economics_refused), then hits the stall above.
  • Pre-commit: fmt, clippy, doc, deny pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j

A never-touched source's warming ledger started at zero, so a single
speculative buy served once (net fee skim) cut the source off from every
further market-price buy. ADR 041 gives each source an allowance capped at
B that duds spend down, cutting the source off only once B is exhausted.

At 0.5 USDC/MB one tiny warm-up blob drove the seeder negative in the
node_pull_topup e2e, so the next node-to-node pull refused BelowMargin and
the client saw a clean NotFound (#1893). The e2e now gets past that gate and
stalls later on a separate, rate-independent fused serve-miss pull stall; its
ignore reason and doc comment now describe that blocker.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j
@thiras thiras self-assigned this Sep 14, 2026
@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.74% (was 82.74%, ● 0.00%) — 77147/93241 lines

File Coverage Lines Δ
crates/node/src/blacklist_watcher.rs 74.28% 924/1244 ● 0.00%
crates/node/src/metrics.rs 94.68% 889/939 ● 0.00%
crates/node/src/serve_economics.rs 100.00% 91/91 ● 0.00%
crates/node/src/warming_allowance.rs 98.17% 375/382 ▼ 0.04%
History
Commit Total Δ vs base
f4b36c9 82.74% ● 0.00%
f78deaf 82.74% ● 0.00%
6085b23 (HEAD) 82.74% ● 0.00%

With every source starting full, a budget-sized debit plus one serve credit
already reads as available, so the vindication tests no longer told one
serve from two. Each now spends the source down first so only the second
credit flips it. credit_is_capped_at_budget asserts on the credited source,
debt_is_floored_at_minus_budget pins the floor, and the blacklist-watcher
fixture gets a real budget so its forget-the-tag assertion can fail.

Docs: debit_speculative states the concurrent overshoot and what the floor
bounds; the node_pull_topup doc and ignore reason name #1893 and drop
one-off measurements; leftover "more negative" and plan-task wording goes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j
@thiras
thiras marked this pull request as ready for review September 14, 2026 10:22
Copilot AI lite review requested due to automatic review settings September 14, 2026 10:22

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.

🟡 Changes recommended

A moderate concurrency race can discard early serve credits, and documentation follow-ups remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR starts each source’s warming ledger at its full budget and updates related tests, documentation, and blocker notes.

Changes:

  • Initializes first-use allowances at budget.
  • Updates allowance, integration, and fixture tests.
  • Revises terminology and documents the remaining node-pull stall.
File summaries
File Summary
crates/node/tests/node_origin_pull.rs Updated dud-flood and vindication coverage.
crates/node/tests/client_loopback.rs Updated asynchronous credit aggregation setup.
crates/node/src/warming_allowance.rs Implements full-budget initialization. Moderate: tag publication can race with initial debit and discard early serve credits; add regression coverage.
crates/node/src/serve_economics.rs Updated related documentation terminology.
crates/node/src/metrics.rs Updated ledger terminology. Nit: align the observability appendix wording with positive initial allowances.
crates/node/src/blacklist_watcher.rs Adjusted warming test fixtures.
crates/e2e/tests/node_pull_topup.rs Revised documentation for the remaining ignored-test blocker.
adr/041-refuse-to-serve.md Updated allowance wording. Nit: explicitly document full initial value and one-hit dud exhaustion semantics.
Review details

Suppressed comments (2)

adr/041-refuse-to-serve.md:110

  • The implementation and module docs now rely on the crucial invariant that a source's first ledger entry starts at B, but this ADR edit does not state that invariant in the normative allowance section or acceptance criterion 4. A reader can still implement the ADR with a zero-centered first entry and recreate the miss this PR fixes; please specify the initial full value and that one-hit duds only reduce the allowance until it is exhausted.
the credit. A drop leaves the source's allowance lower than its true profit and
loss. It can only throttle warming from that source. It can never over-fund the

crates/node/src/metrics.rs:479

  • The corresponding operator-facing description in adr/appendix-observability.md:121 still says a dropped credit leaves the ledger “more negative than its true profit and loss.” After the ledger now starts at a positive full allowance, that is not generally true; the remaining allowance can be positive while still lower than reality. Please update the appendix together with this terminology change so the observability contract matches the implementation.
    /// is conservative — it leaves the source's ledger lower than reality,
    /// never higher — so it can only block speculative warming,
  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

Comment thread crates/node/src/warming_allowance.rs Resolved
debit_speculative published the hash's source tag before taking the bucket
lock. A serve that resolved the tag in that gap could apply its credit to the
bucket this debit was about to create full, where the +budget cap discarded
it. The tag is now published while the lock is held, ahead of the debit, so
every credit the tag enables lands after the debit and no debit is ever
committed without its tag. The serve path still never takes the lock.

ADR 041 now states that a source's allowance starts full and that a dud does
not cut it off until the duds exhaust B (allowance section and acceptance
criterion 4); the observability appendix drops "more negative".

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013p4vAEc4scVHADBqA44K9j
@thiras
thiras merged commit f254977 into main Sep 14, 2026
25 checks passed
@thiras
thiras deleted the worktree-issue-1893-high-rate-pull branch September 14, 2026 15:05
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.

2 participants