Skip to content

fix(runtime): prune embedded cache by each dir's own build profile#537

Merged
DorianZheng merged 1 commit into
mainfrom
fix/embedded-runtime-profile-ttl
May 16, 2026
Merged

fix(runtime): prune embedded cache by each dir's own build profile#537
DorianZheng merged 1 commit into
mainfrom
fix/embedded-runtime-profile-ttl

Conversation

@DorianZheng

Copy link
Copy Markdown
Member

Summary

  • Embedded-runtime cache TTL bug fix. cleanup_stale() selected the stale TTL from the running process's BOXLITE_BUILD_PROFILE and applied it to every sibling dir in the shared runtimes/ parent. Release (v{VERSION}) and debug (v{VERSION}-{HASH}) caches share that parent, so a debug binary (1h TTL) would prematurely delete the release cache (intended 7d), and a release binary would let debug caches linger 7d.
  • Fix: the .complete stamp now records the build profile on line 2; ttl_for_stamp() classifies each dir from its own stamp during cleanup. This follows Cargo's global-cache GC model — retention is decided from the entry's own recorded metadata, not the identity of whoever runs cleanup. Unreadable / legacy version-only / unrecognized stamps conservatively fall back to the long (release) TTL, so a cache that can't be positively classified is never over-deleted. Staleness timing semantics are otherwise byte-for-byte unchanged (verified branch-by-branch).
  • Cross-platform: plain file I/O + the already-used cross-platform filetime; str::lines is CRLF-tolerant for Windows; no atime reliance.
  • Unrelated, bundled at maintainer request: make/dev.mk + make/test.mk add a SETUP_DONE guard and a run_integration_suites helper so the shared runtime is built once before the integration aggregators fan out, instead of each per-suite sub-make re-deriving runtime:debug / warm-cache.

Test plan

  • make clippy (--workspace --all-targets --all-features -- -D warnings) — clean; confirms the changed module compiles with embedded-runtime and no dead code (validates removal of the old stale_ttl() and that both TTL consts are still used).
  • New unit test ttl_for_stamp_classifies_by_recorded_profile — passes all four cases: debug→1h, release→7d, legacy version-only→7d, missing stamp→7d.
  • runtime::embedded module — 4/4 tests pass, no regression.
  • Residual (coverage, not correctness): the new two-line stamp write is not exercised end-to-end in stub mode (extraction_creates_complete_stamp early-returns with an empty manifest). The read/classify side is fully tested and the write is a plain format! + fs::write. Full extraction-path coverage requires make test:integration:rust (VM).

cleanup_stale() derived the stale TTL from the running process's
BOXLITE_BUILD_PROFILE and applied it to every sibling dir in the shared
runtimes/ parent. Since release (v{VERSION}) and debug
(v{VERSION}-{HASH}) dirs share that parent, a debug binary (1h TTL)
would delete the release cache that the 7d TTL was meant to protect,
and a release binary would let debug dirs linger 7d.

Record the build profile on line 2 of the .complete stamp and classify
each dir by its own stamp during cleanup (Cargo global-cache GC model:
retention decided from the entry's own metadata, never the cleaner's
identity). Unreadable / legacy version-only / unrecognized stamps fall
back to the long TTL so a cache we cannot positively classify is never
over-deleted. Staleness timing is otherwise unchanged.

Also: make/dev.mk and make/test.mk gain a SETUP_DONE guard and a
run_integration_suites helper so the shared runtime is built once
before the integration aggregators fan out, instead of each per-suite
sub-make re-deriving the phony runtime:debug / warm-cache prereqs.
@DorianZheng DorianZheng merged commit 7f4c42b into main May 16, 2026
31 checks passed
@DorianZheng DorianZheng deleted the fix/embedded-runtime-profile-ttl branch May 16, 2026 04:31
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.

1 participant