Repository navigation
Conversation
… in the background An approved turn waited up to 4 s on the hosted recall call even though the approval already pins the snapshot by sha256. - After a turn verifies, the snapshot is cached beside the approval. - The next matching turn is served from it at once when it still matches the approval digest (and is under 7 days old). The same paid hosted request then runs in the background, so billing is unchanged (the server charges per delivered pack). - If that request does not verify (superseded or missing record, payment failure, deadline), the cache entry is dropped and the next turn waits for a live answer as before. A changed record can be served once more before it is withheld. - Revocation discards the cache. stop() waits for pending revalidations. Task Master 167.
…one-hour window From an independent review: - A turn that overlaps a pending revalidation for the same approval waits for it (within the 4 s deadline) instead of serving the cache again; this also prevents a late verified write from restoring an entry a newer revalidation dropped. - A cached turn carries no pack id, so outcomes are not attributed to the earlier pack; the cached pack id is in the activity record. - The cache serves only within an hour of a live verification, and a timestamp from a clock far ahead is not trusted. - The cached path also checks the profile's memory mode. - Documented: a failed payment or superseded record can let one cached turn through before it is withheld.
…; count billed requests From the completion review: - After the 4 s wait times out, a foreground recall can run beside the background revalidation. A per-approval generation, bumped on every drop, stops a late verified result from restoring an entry a newer recall dropped. - The lifecycle test now asserts each served turn made exactly one hosted (billed) request. Known limit: if the daemon stops abruptly mid-revalidation, the entry remains and can serve one more turn within its one-hour window.
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.
Task Master 167.
Problem. An approved archive-recall turn waited up to 4 s for the hosted call, even though the local approval already pins the snapshot by sha256.
What changes
Caching. Once a turn verifies live, its snapshot is cached next to the approval in
recall-cache.json.Serving from the cache. The next matching turn uses the cached snapshot immediately if both hold:
The same paid hosted request then runs in the background. The server charges per delivered pack, so each served turn still makes one billed request.
Failed revalidation. If the background request doesn't verify (superseded or missing record, payment failure, deadline), the entry is dropped and the next turn waits for a live answer, as before.
Overlapping turns. A turn that overlaps a pending revalidation waits for it.
Pack ID. A cached turn carries no pack id; the background pack is in the activity log.
Revocation discards the cache, and
stop()waits for pending revalidations.Decision for Josh: each served turn still triggers one billed request. But if that request fails (payment, network, or a superseded record), the cached turn has already been delivered. That gives at most one unbilled or stale turn per approval, within an hour of the last live verification. If that's not acceptable, the alternative is to drop this PR, or to serve from the cache only when the previous request succeeded within a few minutes.
Verification
vitest runon Node 22.23.4: 80 files, 689 tests pass. Tests added or changed:tests/runtime/archive-recall-cache.test.ts: tampered, expired and other-owner cache entries;tests/runtime/hosted-lifecycle-security.test.ts: the one-turn lag, overlap serialization, and revocation clearing the cache.Update (1b68e2f), from the completion review