You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scan_cached_modules skips any directory under <cache>/modules whose name is not a lowercase 64-hex store id. Those bytes are excluded from both the total the sweep measures and the candidate set it can evict.
So the modules cache is bounded at cap only for content the node recognises. Anything else under that directory is invisible to the bound and can grow without limit, while still consuming the same disk the bound exists to protect.
Why it is filed rather than fixed inline
The fix is not a typo correction — it needs a decision about what the sweep should do with content it cannot identify, and there are two defensible answers:
Count it, refuse to delete it. The bound stays honest about disk consumed, and the sweep evicts more recognised capsules to compensate. Costs recognised content to protect unrecognised bytes, which may be exactly backwards.
Delete it. Simple and self-correcting, but the sweep would then remove files it does not understand from a directory it does not exclusively own. That is the kind of thing that is fine until the once it is not.
Smuggling either into a refactor PR would have been the wrong place to make that call.
Context
crates/dig-node-core/src/lib.rs — Node::scan_cached_modules, the hex64 filter.
Node::evict_modules_locked consumes the scan result as both the total and the candidate set, which is what makes one filter govern both halves.
Decide the semantics, then make the total and the candidate set agree with that decision explicitly rather than by both inheriting one filter. State the choice in the sweep's doc comment — the current behaviour is not written down anywhere, which is why it survived a fold that rewrote everything around it.
Evidence
A test that fails without the fix: place a directory with a non-hex64 name holding N bytes under <cache>/modules, run the sweep with a cap below the true total, and assert the outcome matches whichever semantics is chosen. Today the sweep behaves as though those bytes do not exist.
Found during the dig-sex fold (parent: https://github.com/DIG-Network/dig_ecosystem/issues/3134, PR #264).
Task
scan_cached_modulesskips any directory under<cache>/moduleswhose name is not a lowercase 64-hex store id. Those bytes are excluded from both the total the sweep measures and the candidate set it can evict.So the modules cache is bounded at
caponly for content the node recognises. Anything else under that directory is invisible to the bound and can grow without limit, while still consuming the same disk the bound exists to protect.Why it is filed rather than fixed inline
The fix is not a typo correction — it needs a decision about what the sweep should do with content it cannot identify, and there are two defensible answers:
Smuggling either into a refactor PR would have been the wrong place to make that call.
Context
crates/dig-node-core/src/lib.rs—Node::scan_cached_modules, the hex64 filter.Node::evict_modules_lockedconsumes the scan result as both the total and the candidate set, which is what makes one filter govern both halves.Scope
Decide the semantics, then make the total and the candidate set agree with that decision explicitly rather than by both inheriting one filter. State the choice in the sweep's doc comment — the current behaviour is not written down anywhere, which is why it survived a fold that rewrote everything around it.
Evidence
A test that fails without the fix: place a directory with a non-hex64 name holding N bytes under
<cache>/modules, run the sweep with a cap below the true total, and assert the outcome matches whichever semantics is chosen. Today the sweep behaves as though those bytes do not exist.