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
Governance config: one-time bootstrap load + two-level lazy TTL (stop fetching GET /v1/governance/{agent} on every run start) #114
tokenops_run() calls governance_config_for(service) on every run start / agent hop unless an explicit governor= is passed (src/tokenops/control/run.py:224-226).
Embedded mode routes through governance_cache.py (process cache keyed (store_path, agent), invalidated on Store governance writes) — effectively free after the first call.
Remote / HTTP mode routes client.governance_config_for -> HttpStore.governance_config_for -> GET /v1/governance/{agent} with no cache. Every run start is a blocking round trip to the plane for config that only changes on Admin edits.
Under the HTTP hard-dependency (see #55, #60), and given TokenOps runs per turn, this adds a plane round trip to every turn purely for near-static config.
Desired behavior
Client-side governance-config cache that:
Loads once on application bootstrap (or lazily on first use) and is held in an in-memory store keyed by (base_url, agent).
Two-level TTL, both evaluated lazily on request arrival (when a run hits the agent) — not on a background timer:
Soft TTL: past it, the cached value is still served for this run, and a background refresh is kicked off to rebuild from a fresh GET /v1/governance/{agent}. No request blocks.
Hard TTL: past it, the cache entry is considered stale-unsafe — the next request blocks on a synchronous rebuild before building the Governor.
On a successful fetch (foreground or background), the entry is replaced and both TTL clocks reset.
Explicit invalidation still works (Admin edit -> clear_governance_config_cache, or a plane-push/webhook later).
Activity