fix(template): prefer the newer of live-cache and bundled snapshot#396
Merged
Conversation
loadTemplate() returned the live cache whenever it existed, at any age, assuming a live capture is always at least as fresh as the bundle. That inverts in a no-CC deployment (the Hetzner container): the async refresh can never run there, so the volume's live cache freezes at its last capture while shipped releases advance the bundled template. The stale cache then shadows every bundled-template update until the cache file is removed by hand. Observed 2026-05-28: a May-10 CC 2.1.138 live cache shadowed the freshly baked 2.1.154 bundle in dario 4.8.14 — `dario doctor` read "live capture, CC v2.1.138 (18d old)" despite the new image, and the template only updated after the cache was moved aside manually. Now a stale cache wins only if it was captured more recently than the bundle; otherwise the bundle is used. A fresh cache (age < TTL) still always wins. No infra change and no CC required in the container.
Contributor
Compat test: ✅ PASSEDRan Output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
loadTemplate()returns the live cache (~/.dario/cc-template.live.json) whenever it exists — at any age. Both the fresh and the stale branch justreturn cached, on the assumption that a live capture is always at least as fresh as the bundled snapshot.That assumption inverts in a no-CC deployment (the Hetzner
askalf-dariocontainer, which has noclaudebinary): the asyncrefreshLiveFingerprintAsync()can never run, so the volume's live cache freezes at its last capture while shipped releases advance the bundled template. The stale cache then shadows every bundled-template update until the cache file is removed by hand.Observed
2026-05-28: a May-10 CC 2.1.138 live cache shadowed the freshly baked 2.1.154 bundle in dario 4.8.14.
dario doctorreadTemplate: live capture, CC v2.1.138 (18d old)despite the new image — the re-bake + release + container pull had zero effect on the served fingerprint. It only updated after the cache file was moved aside and dario restarted.The fix
On a stale cache (age ≥ TTL), prefer whichever of the live cache and the bundled snapshot was captured more recently, instead of blindly keeping the cache:
Number.isFiniteguards a malformed bundle date (falls back to the cache). No infra change, no CC required in the container.tsc --noEmitclean.