Skip to content

perf(node): consolidate chain-event watchers into one multiplexed getLogs poller - #1747

Merged
alpergundogdu merged 8 commits into
mainfrom
claude/eth-calls-efficiency-882ad9
Aug 19, 2026
Merged

alpergundogdu merged 8 commits into
mainfrom
claude/eth-calls-efficiency-882ad9

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Summary

Third and final eth_call-efficiency PR (follows #1727, #1737). Collapses the per-watcher eth_getLogs tail-polls into one multiplexed get_logs per tick, and routes the last stray get_block_number read through the shared SharedHead. A node now issues one getLogs + one eth_blockNumber per event_poll_interval instead of one of each per watcher.

The problem

Five chain-event watchers (settlement, capacity-bond, slash, blacklist, rate-bounds) each ran their own resumable_watcher loop issuing a separate eth_getLogs every event_poll_interval, plus the blacklist watcher did its own get_block_number for enumeration snapshots. That's ~5 getLogs + a stray block# read every tick, forever, per node.

The change

  • One MultiplexedPoller owns a merged filter (address: [3 contracts] + a topic0 OR-set over all watched signatures) and a set of registered routes. One tick reads head once via SharedHead, issues one get_logs per backfill window over the merged filter, and demuxes each log by (address, topic0) to the owning route.
  • Per-route cursors (not one shared cursor): each route keeps its own CursorStart/cursor, so settlement's durable FromCheckpoint deep-backfill, per-route error isolation, and reorg rewind are all preserved. A route whose sink errors holds its cursor and re-scans next tick (idempotent) while sibling routes keep advancing. In steady state every route's cursor equals head — a single idle poll.
  • Each watcher migrates from self-spawning a loop to returning a Route; the runtime builds one poller and spawns it. Enumerate-at-pinned-block resyncs stay per-watcher (driven by the poller calling each sink's on_tick_complete).
  • Blacklist enumeration block# → SharedHead (the one remaining stray get_block_number), so it's TTL-cached and shared rather than a fresh per-boot read.
  • Shutdown collapses to a single late stop (after router.shutdown()), because capacity-bond's staker set gates DHT Store admission / stake-lane shedding and must stay live through drain. blacklist/rate-bounds move early→late (harmless: no cursor to flush, not drain-consulted).
  • The old single-loop driver (resumable_watcher::{run,run_tick,WatcherConfig,spawn,fire_tick_success}) is deleted; the cursor vocabulary (CursorStart, LogSink, WatcherHandle, resolve_*) is kept and reused.

Net effect

getLogs per tick: ~5 → 1. eth_blockNumber per tick: shared single-flight (already), now with the last stray reader folded in. Scales flat with watcher count instead of linearly.

Notes

  • Slash's .topic2(operator) server-side filter is dropped (a merged filter can't scope topic2 to only SlashRecorded); the in-sink operator == self guard already makes this safe — documented at the drop site.
  • Demux keys (address, topic0) are unique across routes (build-time dup-key check backstops at boot): PaymentPool carries settlement (5 sigs incl. PoolOpened) + rate-bounds (RateBoundsUpdated); CapacityBond carries capacity-bond (5 sigs) + slash (SlashRecorded); ContentBlacklist is single-route.

Testing

  • Poller unit tests (17): per-route demux, dup-key build error, floor gate (incl. None-block applied), error isolation + sibling advance + idempotent re-scan, multi-window partial-progress-then-error, one-getLogs-per-tick (discriminating vs an unmerged design), idle-tick reconcile, shutdown flush, head-read-failure backoff, panic-fires-every-route, and shutdown edge-suppression (verified non-vacuous — each assertion fails if its !shutdown.is_cancelled() guard is deleted).
  • Per-watcher route-shape tests: each watcher's Route asserts its exact topic0 set + CursorStart (catches a silently-dropped topic0).
  • Blacklist block#-via-SharedHead single-flight test (one eth_blockNumber for two reads).
  • Full decdn-node suite green (916 tests) on latest main; clippy -D warnings + fmt clean.

Observability

The dead origin-watcher metrics were already removed in #1737. This PR removes the per-watcher liveness gauges that no longer apply and keeps the poller's own tick/liveness signals.

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings August 18, 2026 17:19

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.

Pull request overview

This PR completes the node-side chain-read efficiency sweep by consolidating five independent eth_getLogs tail-poll loops into a single multiplexed poller that issues one merged get_logs per tick (plus the shared eth_blockNumber read via SharedHead), while preserving per-watcher cursor semantics, error isolation, and shutdown ordering.

Changes:

  • Introduces chain_events::multiplexed_poller to merge watcher filters and demux logs by (address, topic0) into per-route sinks with independent cursors.
  • Migrates existing watchers (settlement, capacity-bond registry, slash, blacklist, rate-bounds) from spawning their own watcher loops to registering Routes on the shared poller, and updates shutdown sequencing accordingly.
  • Updates tests/metrics/docs to reflect the new shared-poller architecture and verifies reduced RPC call counts and correct routing/cursor behavior.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/node/src/chain_events/multiplexed_poller.rs New multiplexed poller implementation (merged filter, demux, per-route cursors/hooks, spawn).
crates/node/src/chain_events/resumable_watcher.rs Refactors old watcher-loop module into shared cursor/sink vocabulary + WatcherHandle.
crates/node/src/chain_events/mod.rs Switches chain-event architecture docs and module wiring to the multiplexed poller.
crates/node/src/runtime/mod.rs Wires all watcher routes into one poller and collapses shutdown handling to a single handle.
crates/node/src/payment_settlement.rs Converts settlement watcher into a returned Route; service now owns only the redeemer task.
crates/node/src/dht/capacity_bond_registry.rs Converts capacity-bond watcher into a Route feeding projections (staker set + bindings).
crates/node/src/slash_watcher.rs Converts slash watcher into (SlashStore, Route); documents dropped topic2 filter and adds route-shape tests.
crates/node/src/blacklist_watcher.rs Converts blacklist watcher into a Route using a sink factory to observe the poller shutdown token; routes enumeration block# through SharedHead.
crates/node/src/rate_bounds_watcher.rs Converts rate-bounds watcher into a Route and adds route-shape unit test.
crates/node/src/chain_events/shared_head.rs Updates end-to-end caching test to drive multiple poller loops instead of old watcher loops.
crates/node/src/chain_events/backfill.rs Updates module docs to reference the multiplexed poller loop.
crates/node/src/dht/chain_projection.rs Removes watcher-handle ownership from projections (poller task is runtime-owned now).
crates/node/src/dht/chain_staker_set.rs Updates projection ownership docs/signature for poller-based refresh.
crates/node/src/dht/node_address.rs Updates projection ownership docs/signature for poller-based refresh.
crates/node/src/metrics.rs Updates metric docs to reference multiplexed_poller::run as the emitting loop.
crates/common/src/config/resolved.rs Updates config docs to reference MultiplexedPoller as the event_poll_interval_ms consumer.
crates/node/tests/anvil_settlement_e2e.rs Updates e2e to spawn a single-route poller so settlement route runs during the test, and shuts it down explicitly.

💡 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/chain_events/mod.rs Resolved
@github-actions

github-actions Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.91% (was 80.72%, ▲ +0.20%) — 58866/72753 lines

File Coverage Lines Δ
crates/common/src/config/resolved.rs 100.00% 33/33 ● 0.00%
crates/node/src/blacklist_watcher.rs 75.04% 890/1186 ▲ +0.96%
crates/node/src/chain_events/backfill.rs 97.56% 40/41 ● 0.00%
crates/node/src/chain_events/mod.rs 94.25% 82/87 ▼ 3.45%
crates/node/src/chain_events/multiplexed_poller.rs 89.30% 1043/1168 new
crates/node/src/chain_events/resumable_watcher.rs 92.07% 209/227 ▲ +2.06%
crates/node/src/chain_events/shared_head.rs 93.72% 179/191 ▼ 0.61%
crates/node/src/dht/capacity_bond_registry.rs 78.28% 566/723 ▲ +1.04%
crates/node/src/dht/chain_projection.rs 84.75% 50/59 ▲ +10.12%
crates/node/src/dht/chain_staker_set.rs 86.21% 100/116 ▲ +2.17%
crates/node/src/dht/node_address.rs 83.78% 93/111 ▲ +2.20%
crates/node/src/metrics.rs 95.09% 968/1018 ● 0.00%
crates/node/src/payment_settlement.rs 45.99% 533/1159 ▲ +1.66%
crates/node/src/rate_bounds_watcher.rs 60.19% 65/108 ▲ +60.19%
crates/node/src/runtime/mod.rs 48.76% 1080/2215 ▲ +0.65%
crates/node/src/slash_watcher.rs 59.78% 266/445 ▲ +4.12%
History
Commit Total Δ vs base
cb47bc0 80.92% ▲ +0.20%
f602aec (HEAD) 80.91% ▲ +0.20%

alpergundogdu and others added 7 commits August 18, 2026 18:33
ContractReads::block_number now reads through the shared, TTL-cached
SharedHead single-flight (crate::chain_events::shared_head) instead of
issuing its own eth_blockNumber via contract.provider().get_block_number(),
so the boot enumeration snapshot no longer costs a separate per-boot head
read on top of every other watcher's shared head.

Post-change grep for get_block_number in crates/node/src (only doc/comment
references and the shared_head.rs/mod.rs production+test call sites remain;
no direct call left in blacklist_watcher.rs):

crates/node/src/blacklist_watcher.rs:162:    /// (`get_block_number`).
crates/node/src/blacklist_watcher.rs:343:        .context("get_block_number for the ContentBlacklist enumeration snapshot")?;
crates/node/src/chain_events/shared_head.rs:134:            "get_block_number",
crates/node/src/chain_events/shared_head.rs:135:            self.provider.get_block_number(),
crates/node/src/chain_events/shared_head.rs:418:    /// first for the very same fault. (`timed` only attaches its `get_block_number`
crates/node/src/chain_events/mod.rs:98:/// `get_logs`, `shared_head`'s `get_block_number`, and each follow-up RPC a
crates/node/src/chain_events/mod.rs:278:        assert_eq!(timed(None, "get_block_number", ok).await.ok(), Some(7));
crates/node/src/chain_events/mod.rs:293:        let err = timed(None, "get_block_number", provider.get_block_number())
crates/node/src/chain_events/mod.rs:299:                .is_some_and(|e| e.contains("get_block_number timed out after")),

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…plexed_poller

Adds the empty multiplexed_poller module skeleton. No behavior change.
…demux)

Adds MultiplexedPoller: a new eth_getLogs polling driver, sibling to
resumable_watcher::run, that scans one merged filter per backfill window and
demuxes each log to its owning route by (address, topic0). Per-route cursors
(not one shared cursor) preserve each route's own resume floor and let a
route whose sink errors hold its cursor and re-scan while sibling routes keep
advancing and persisting; the tick still returns Err on any route error so
the shared loop backs off. A head-read or get_logs failure fails the whole
tick before any route-specific step runs, firing on_backoff for every route.

ErasedSink type-erases LogSink (blanket-impl'd) so routes with different
concrete sinks share one Vec<Box<dyn ErasedSink>>. MultiplexedPollerBuilder
rejects a duplicate (address, topic0) route key at build time as a wiring
bug. WatcherHandle gains a `new` constructor so this sibling driver can spawn
its own task and hand back the same handle type resumable_watcher uses.

Widens CursorStart::{seed, initial_from, persist, flush} and
resumable_watcher::fire to pub(crate) so this driver reuses the exact,
already-tested cursor machinery rather than forking it.

Unit-tested against a mocked provider (11 tests): demux by (address, topic0),
per-route floor gating, error isolation with sibling advance and idempotent
re-scan on retry, one get_logs per tick across N routes (wiremock counting
harness), idle-tick reconcile, shutdown flush, head-read failure, and the
panic guard firing every route's on_task_panic. No watcher migrates to this
driver yet -- that follows in a separate change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…iscrimination, None-block apply, multi-window error

Closes coverage gaps flagged in the Task 2 review (design/correctness
approved, only test coverage was missing). Test-only: no production code
in multiplexed_poller.rs or resumable_watcher.rs changes.

- shutdown_suppresses_established_and_backoff_edges_but_not_tick_success:
  drives one healthy tick (on_established + on_tick_success fire once,
  on_backoff doesn't), then a second succeeding tick under a cancelled
  shutdown token (on_tick_success still increments; on_established/
  on_backoff fire no new edge). Pins fire_route_hooks's
  !shutdown.is_cancelled() guard on both edges.

- n_routes_share_one_getlogs_per_tick: CountingRpc's mock head now
  increments by one block per real eth_blockNumber RPC instead of staying
  static, so every poller tick has a non-empty merged range and issues a
  get_logs (previously only tick 1 did; every later tick was idle, so the
  old `< ROUTES * ticks` bound would have passed even against a regression
  back to one get_logs loop per route). Tightened the assertion to
  `getlogs <= ticks + 2`, which actually discriminates merged (~1 per tick)
  from unmerged (~ROUTES per tick).

- none_block_number_log_is_applied_not_gated: a log with block_number: None
  must reach apply rather than being silently gated -- the floor gate is
  `is_some_and`, which is false (not true) on None, so this is the "never
  silently drop" direction the gate's doc already claims but no test
  exercised.

- multi_window_error_holds_cursor_at_failed_windows_start: max_backfill_span
  1 with floor=1/head=3 (3 windows); a route erroring on the second window
  must hold its cursor at that window's start (2) -- past the completed
  first window but short of the unscanned third -- with only the completed
  window's checkpoint persisted. Mirrors resumable_watcher.rs's
  sink_error_leaves_cursor_and_checkpoint_at_last_completed_window, carried
  over to the per-route tick_floor/errored machinery.

Module test count 11 -> 14 (3 new + n_routes_share_one_getlogs_per_tick
tightened in place); full decdn-node suite 883 -> 886, all green.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The previous shutdown_suppresses_established_and_backoff_edges_but_not_tick_success
test was vacuous for both edges it claimed to cover:

- on_established: it established the route on an uncancelled tick 1, then
  cancelled shutdown for tick 2. By tick 2 !r.established was already false,
  so the !shutdown.is_cancelled() clause was never reached -- deleting that
  guard would still have passed.
- on_backoff: tick 2 was a success (idle), so the r.errored branch that
  guards on_backoff was never entered either.

Split into 4 focused tests, mirroring resumable_watcher.rs's
shutdown_suppresses_the_established_edge / shutdown_suppresses_the_backoff_edge:

- established_edge_fires_on_first_healthy_tick_when_not_cancelled (positive)
- shutdown_during_first_tick_suppresses_established_edge (negative): a new
  CancelInReconcile sink cancels the shared token from inside
  on_tick_complete -- strictly after run_tick's per-window boundary check
  (which only runs between windows) but before fire_route_hooks reads the
  token -- so !r.established is still true and only the
  !shutdown.is_cancelled() guard can withhold the edge. Cancelling before
  calling run_tick at all (tried first) instead trips that window-boundary
  check and returns Ok early, short-circuiting the tick before it reaches
  hook-firing -- which is why on_tick_success didn't fire either in that
  draft, the tell that the construction was wrong rather than the code.
- backoff_edge_fires_on_a_failing_tick_when_not_cancelled (positive)
- shutdown_during_failing_tick_suppresses_backoff_edge (negative):
  CancelInReconcile { bail: true } cancels the token AND fails
  on_tick_complete in the same call, so r.errored is genuinely true and the
  backoff branch is entered, isolating the guard as the only thing
  withholding the hook.

Verified non-vacuity directly: temporarily deleted each
!shutdown.is_cancelled() guard in fire_route_hooks and confirmed the
corresponding negative test (and only that one) fails, then restored.

Test-only change. Module count 17 (14 -> 17: -1 removed vacuous test, +4
new). cargo clippy -p decdn-node --all-targets -- -D warnings and cargo fmt
-- --check both clean.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…s to routes, delete per-watcher getLogs loops

Migrate all five chain-event watchers (settlement, capacity-bond, slash,
blacklist, rate-bounds) to return an un-spawned `Route`, and wire the runtime
to run ONE `MultiplexedPoller`: one merged `eth_getLogs` per tick, demuxed by
`(address, topic0)` into per-route sinks, replacing five independent
`resumable_watcher::run` loops.

- settlement `bootstrap` -> `(Self, Route)` (redeemer still spawns; the poller
  flushes the PoolOpened checkpoint on shutdown; `shutdown` keeps the final
  redeem sweep, watcher-less).
- slash drops the wire-level `.topic2` operator scoping (merged filter can't
  scope topic2; `decode_recorded`'s operator==self guard already makes it safe)
  and the SLASH_MAX_BACKOFF override (shared loop uses WATCHER_MAX_BACKOFF).
- blacklist registers a `SinkSource::Factory` so its sink still observes the
  poller's single shutdown token; the initial-sync readiness oneshot survives.
- capacity-bond returns a Route; the projection keep-alive `Arc<WatcherHandle>`
  is dropped from ChainProjection (the poller is the one owned task).

Runtime: collect the 5 Routes into a MultiplexedPollerBuilder, `build()?`
(dup-key check surfaces a wiring bug at boot), spawn once -> one poller handle
on ChainHandlers/ShutdownHandles. The staggered per-watcher stops collapse to
a SINGLE `poller.shutdown()` at the LATE point (after `router.shutdown`),
forced by capacity-bond's staker set gating DHT admission through drain;
blacklist/rate-bounds move early->late (no cursor, not drain-consulted).

Delete the dead single-loop driver from resumable_watcher.rs (`run`,
`run_tick`, `WatcherConfig`, `spawn`, `fire_tick_success`, `PanicGuard` +
driver-only tests); keep the cursor vocabulary, LogSink, WatcherHandle, and the
pure resolve_* helpers. Remove the `#![allow(dead_code)]` from
multiplexed_poller.rs. Make the poller wiring `pub` (mirrors shared_head) so the
external anvil settlement e2e can drive a single-route poller.

Greps:
  rg "resumable_watcher::(run|run_tick|spawn|WatcherConfig)" crates/  -> clean
  rg "get_logs" crates/node/src  -> only the poller's one call site
  rg "allow\(dead_code\)" crates/node/src/chain_events/multiplexed_poller.rs -> clean

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…nch; fix stale watcher docs

Adds a fast unit test per chain watcher (settlement, capacity-bond, slash,
blacklist, rate-bounds) asserting its exact Route topic0s and CursorStart
shape, so a silently-dropped topic0 fails in CI instead of only surfacing at
runtime. Adds a debug_assert on the unreachable unresolved-Factory sink
branch in the multiplexed poller so a future wiring bug fails loudly in
debug/test builds. Rewords stale/overclaiming comments left over from the
resumable_watcher -> multiplexed poller migration.
@alpergundogdu
alpergundogdu force-pushed the claude/eth-calls-efficiency-882ad9 branch from 846b59c to 1b4ee8a Compare August 18, 2026 17:49
The --all-features clippy job lints the anvil-e2e test, where the new
MultiplexedPoller `built` binding was too similar to the pre-existing
forge `build` binding. Rename to `poller`.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu
alpergundogdu force-pushed the claude/eth-calls-efficiency-882ad9 branch from 1b4ee8a to f602aec Compare August 18, 2026 17:52
@alpergundogdu
alpergundogdu merged commit 7022ac6 into main Aug 19, 2026
26 checks passed
@alpergundogdu
alpergundogdu deleted the claude/eth-calls-efficiency-882ad9 branch August 19, 2026 07:20
alpergundogdu added a commit that referenced this pull request Aug 20, 2026
* feat(config): add [cache.serve_economics] policy/discount/n_max

Adds the refuse-to-serve economics config block (ADR 041): policy
("off"/"margin"), discount (converted to basis points), n_max, and
per-source warming_budget/warming_refill, mirroring the existing
[cache.tinylfu] pattern (raw type, resolved type, defaults + resolve +
load-time validation). Updates every hand-built ResolvedCache fixture
and exhaustive CacheConfig destructure across cli/node to carry the
new field, and adds it to the operator-facing config template.

* feat(node): ServeEconomicsPolicy trait + MarginPolicy/OffPolicy (ADR 041)

* feat(incentive,node): FeeRouter getShares binding + OperatorShares cell

* feat(node): FeeRouter SharesUpdated watcher route (reuses #1747 poller)

Registers a Route for FeeRouter.SharesUpdated into the existing
multiplexed getLogs poller, mirroring rate_bounds_watcher.rs: decodes
each event into the shared OperatorShares cell (narrowed via
operator_bps_from_shares), with a periodic authoritative getShares()
re-read as a safety net against a missed log. Adds matching
fee_shares_watcher_{last_tick_timestamp_seconds,task_panicked}
metrics fields/recorders alongside the rate-bounds watcher's.

* feat(node): wire serve-economics policy, operator-shares refresh, estimator decoupling

* feat(node): PullMiss::BelowMargin (-> NotFound) + serve_economics_refused metric

Adds the PullMiss::BelowMargin variant, its miss_answer arm (wire-identical
to Clean's NotFound, so the serve-economics buy ceiling never leaks to the
client), and a dedicated decdn_serve_economics_refused_total counter. Task 8
wires the buy-loop gate that actually produces this variant and increments
the metric.

* test(node): guard PullMiss::or precedence + document BelowMargin ranking

Adds below_margin_never_masks_or_is_masked_by_a_local_fault, asserting both
argument orders for LocalFault-over-BelowMargin and BelowMargin-over-Clean in
the walk fold. Extends the or() doc comment to explain why BelowMargin
outranks Clean in the fold.

* feat(node): per-source serve-vindicated warming allowance for serve economics

* feat(node): apply serve-economics gate + warming allowance in the buy loop (ADR 041)

Wire the ADR 041 buy-side profitability gate into the node-to-node cache-miss
buy loop. A new `economic_ceiling` helper derives this node's sell rate and the
policy's two-regime buy cap per ranked candidate: a quote above the cap is
refused (metered `serve_economics_refused`, folded into the walk as
`PullMiss::BelowMargin`), and a quote merely above the amortized profit floor is
bought but flagged speculative. The cap is folded into the effective stream
ceiling so a bait-and-switch above it aborts mid-pull. On a clean speculative
pull each of the three buy paths (buffered `pull_from_candidate`, progressive
`NodeProgressivePull::finish`, gap-driven `run_pull_leg`) debits the source's
per-source `WarmingAllowance` by the full buy cost.

Adds the shared `warming: Arc<WarmingAllowance>` field to `NodeOriginConfig`,
constructed once in runtime bring-up and threaded through `ChainHandlers`.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(node): serve-credit + eviction-forget the warming allowance (ADR 041)

Complete the ADR 041 warming-allowance loop's serve and eviction sides. The
client handler now holds the shared `WarmingAllowance` and the live operator
fee-share cell; on each clean serve (`serve_leg` and `delivery`, beside the ADR
040 `observe_hit` sighting) it credits the realized operator margin —
`(operator_bps / 10_000) · P_sell · MB(served)` — back to the source that
speculatively warmed the blob. `credit_serve` is a no-op for an untagged hash, so
own-namespace / non-speculative serves cost one map lookup.

The eviction driver forgets an evicted hash's source tag on a successful
`release_for_eviction`, so a reused cache slot can never credit a stale source.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* test(node): serve-economics integration + adversarial guards (ADR 041)

Adds node-loopback coverage for the ADR 041 buy-side gate: a bait-and-switch
abort (HC-2, probe quote clears the gate then the real StreamResponse quote
exceeds the composed ceiling), Attack A (a malicious upstream quoting exactly
at the amortized ceiling with heat pinned to n_max, bounding the buyer's
measured loss against one realized resale), Attack B (a per-source dud-flood
that drains a source's warming allowance after one dud, refuses further
at-market cold buys from that source, leaves an independent source untouched,
and confirms serve-vindication on a re-served blob), and an own-namespace test
proving the gate is never consulted on the local-origin serve path even under
the most restrictive possible settings.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix(node): forget warming tag on governance/admin cache eviction (ADR 041)

WarmingAllowance::forget only ran from the eviction-driver sweep, leaving the
hash->source provenance tag in place when a blob left the cache via the
blacklist takedown watcher or the admin `decdn node evict` RPC. Thread the
shared WarmingAllowance Arc into both production removal paths and forget the
tag on a successful evict, so a re-admitted hash can never spuriously credit a
stale source's allowance.

* docs(adr): add ADR 041 — refuse-to-serve economics

Records the buy-side ServeEconomicsPolicy gate: two-regime buy ceiling
max(P_sell, amortized), per-source serve-vindicated warming allowance,
and the Attack A / Attack B adversarial reasoning implemented in this
branch. Adds 041 to the ADR book list and the architecture reading order.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 <[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.

2 participants