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
{{ message }}
Repository navigation
Commit eed2a0e
Browse filesBrowse the repository at this point in the historyBrowse files
feat(web): cache the DCA plan's admission screen for 5 minutes (#856) (#870)
* feat(web): cache the DCA plan's admission screen for 5 minutes (#856)
/rules?budget=... reloads every 15s, and each reload re-screened every
allowlisted asset against the database through build_screen_report --
twenty times more often than the screen actually changes. Cache that
one report (not the plan: budget/buffer still vary per request) on a
new ScreenCache, keyed on (config_path, db_path), with an injectable
clock (the reader's own now_ts, never a second time.time() read) and a
thread-safe TTL of 300s (a HIT is exclusive of the boundary -- an entry
exactly 300s old is stale, matching guards.py's own attest_due_ts
semantics). The cache lives on ServeConfig, scoped to one deployment
and shared by every ThreadingHTTPServer thread; the lock is held
across a miss's rebuild, deliberately, to avoid a thundering herd on a
single-operator dashboard.
select_universe/build_dca_plan gain a screen_report_fn injection point
(defaulting to build_screen_report, so every existing caller --
including the CLI -- is unaffected); read_dca_plan is the one caller
that passes the cache lookup instead.
The payload gains screen_age, a presentation-ready sentence ("Asset
screen from 2m ago; refreshes every 5 min.") computed server-side from
_human_age, and the /rules card shows it under the plan's state line.
Read-only; no behaviour change beyond the screen the plan is built
from being up to 5 minutes stale, which the card now says out loud.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(web): a cached screen's age is never negative (#856)
A request stamped before a later-stamped one built the entry (it waited
on the lock) read "-1s ago". Clamp the age to 0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(web): the DCA card's screen line says when no screen ran, and states the cache's own TTL (#856)
- awaiting card: screen_age is a worded 'not run yet' field, not a bare dash
- the refresh interval is ScreenCache.TTL_SECONDS handed through, not prose
- no screen age passed means not-screened, never a silent '0s ago'
- an entry a whole TTL in the request's future (clock stepped back) is a miss
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(web): the screen cache key carries the allowlist and quote currency (#873)
config.yaml is re-read per request, so an asset added at the same path was
reported 'not screened' for up to 5 minutes. Also pins that a cache hit still
reads the budget and the DCA rules fresh.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(web): a same-query read after a rule insert shows the rule, so a per-query plan cache fails (#856)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
0 commit comments