Move the store, lease and caching code stealth-factory/opscope#613 built inside agent-usage into opscope-core, unchanged, so other widgets can use it.
Context / problem
Everything stealth-factory/opscope#613 built lives in widgets/src/widgets/agent-usage/. lease.rs and sharing.rs use no agent-usage types except one path helper. The reading half of Caches in shared.rs is tied to agent-usage. Part of stealth-factory/opscope#630.
Scope
In:
core/src/readings/with the lease and store code, used astc::readings.- agent-usage's
Cachesembedstc::readings::Cache.cached(),cached_file(),remember_refusal()andkept()stay as thin wrappers. - The store path goes through
tc::state_dir(). check.rs: addaccount_tag,held_forandbackoffto the helpers widgets may not redefine.- A section in
docs/internals.md.
Out:
- Any new behaviour, key change or schema change. That is the next issue.
Acceptance
- agent-usage uses the same file name, schema and key strings, so an old and a new agent-usage keep sharing. A test opens a store written by the old code.
- Every existing lease, store and
held_fortest passes from core. cargo testpasses on Linux and on macOS.- The PR states the binary size change and that
lddis unchanged.
Agent notes
- agent-usage computes its own state path (
claude.rssnapshot_state_home). It differs fromtc::state_dir()only when XDG_STATE_HOME is set but empty, or HOME is unset. Make sure the file name staysagent-usage.sqlitein the same directory. - About 40 direct uses of
caches.live,.good,.failsoutsideshared.rsneed a field-path change. rusqlite(bundled) andsha2are already core dependencies, so no crate is added.
Activity
2🔗 Related PRs
-
stealth-factory/opscope#619 - feat(agent-usage): share vendor readings across panes (OPS-274) [merged] stealth-factory/opscope#485 - perf(agent-usage): read logs less, less often - windowed, gated, budgeted and persisted (OPS-208) [merged]
📝 Issue Planner
-
Check the box below or use the
@coderabbitai plancommand to generate an implementation plan and prompts that you can use with your favorite coding assistant.- Create Plan
🧪 Issue enrichment is currently in open beta.
-
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:issue_enrichment: auto_enrich: enabled: false
💬 Have feedback or questions? Drop into our discord!
OPS-283