Skip to content

Non-hex64 directories under <cache>/modules escape the size cap entirely #265

Description

@MichaelTaylor3d

Found during the dig-sex fold (parent: https://github.com/DIG-Network/dig_ecosystem/issues/3134, PR #264).

Task

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.rsNode::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.
  • The bound this weakens is the #1934 disk-exhaustion bound, whose two regression tests were rewritten in PR feat(cache): fold the tier/relevance/eviction decisions onto dig-sex 0.2 #264 to run the real policy.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:maintenancereal work that changes nothing a user can perceive

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions