agent-orchestrator / rules
Cursor rule4 starsChanged 7 months agoMITView on GitHub
Issue #84 RunStore.listRuns() metadata cache: lifetime and contract rules for polling callers and the cache itself
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,531 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository61 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/ai-workspace-projections.mdcCursor rule
- .cursor/rules/mcp-tool-configs.mdcCursor rule
- .cursor/rules/node-typescript.mdcCursor rule
- .cursor/rules/worker-posture.mdcCursor rule
- .cursor/rules/worker-safety.mdcCursor rule
- await-pr-checksSkill
- commitSkill
- create-agentSkill
- create-issueSkill
- create-mcpSkill
- create-planSkill
- create-prSkill
- create-ruleSkill
- create-skillSkill
- create-test-planSkill
- implement-planSkill
- load-contextSkill
- mergeprepSkill
- orchestrate-create-planSkill
- orchestrate-create-test-planSkill
- orchestrate-implement-planSkill
- orchestrate-resolve-pr-commentsSkill
- orchestrate-reviewSkill
- publish-releaseSkill
- resolve-conflictsSkill
- resolve-issue-commentsSkill
- resolve-pr-commentsSkill
- resolve-review-findingsSkill
- review-prSkill
- reviewSkill
- run-test-planSkill
- setup-worktreeSkill
- update-contextSkill
- await-pr-checksSkill
- commitSkill
- create-agentSkill
- create-issueSkill
- create-mcpSkill
- create-planSkill
- create-prSkill
- create-ruleSkill
- create-skillSkill
- create-test-planSkill
- implement-planSkill
- load-contextSkill
- orchestrate-create-planSkill
- orchestrate-create-test-planSkill
- orchestrate-implement-planSkill
- orchestrate-resolve-pr-commentsSkill
- orchestrate-reviewSkill
- publish-releaseSkill
- resolve-conflictsSkill
- resolve-issue-commentsSkill
- resolve-pr-commentsSkill
- review-prSkill
- reviewSkill
- run-test-planSkill
- setup-worktreeSkill
- The first 60 shown.
The file
We split this runstore-listruns-cache.mdc into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 36
When adding a new polling caller, accept the long-lived store as a parameter (or capture it in a closure) rather than reaching for new …
- Very specific: line 58
loadMeta(runId)stays cache-free: Only listRuns() consults the cache.
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: "Issue #84 RunStore.listRuns() metadata cache: lifetime and contract rules for polling callers and the cache itself"
globs:
- "src/runStore.ts"
- "src/observability.ts"
- "src/daemon/**/*.ts"
- "src/orchestratorService.ts"
alwaysApply: false
---
<!-- Generated from .agents/ by scripts/sync-ai-workspace.mjs. Do not edit directly. -->
# RunStore listRuns() Metadata Cache
Issue #84 added a private, stat-validated `RunStore.listRuns()` metadata
cache so the daemon and `watch` stop re-reading every `meta.json` on every
poll. Contract details and benchmark instructions live in
`docs/development/run-metadata-cache.md`.
## Reuse one long-lived store per polling loop
Code that calls `RunStore` (and `OrchestrationStore`) on a recurring tick
must construct the store once at the start of the loop and thread the
same instance through every refresh. Spinning up a `new RunStore(...)`
inside the per-tick path discards the in-memory `listRuns()` cache between
calls, so the bulk `meta.json` scan repeats every tick — the exact
regression issue #84 fixed.
Concrete examples of polling/snapshot callers in this repository:
`agent-orchestrator watch` (`src/daemon/daemonCli.ts`), the daemon's
`get_observability_snapshot` IPC handler (`src/orchestratorService.ts`),
and any future periodic exporter or dashboard refresh path. One-shot
commands (`runs`, `--json` snapshots, prune) may construct stores per call
because they exit after one read.
When adding a new polling caller, accept the long-lived store as a
parameter (or capture it in a closure) rather than reaching for
`new RunStore(paths.home)` inside the hot loop. The cache only helps if
the instance survives.
## Keep the cache private, stat-validated, and out of loadMeta
Changes inside `RunStore` itself must preserve three properties that the
cache depends on, because relaxing any of them quietly broadens the
stale-read surface that issue #84 set out to bound.
- **Private to the instance.** The cache lives on a single `RunStore` and
is not exposed via a public invalidation or inspection hook. External
callers must not be invited to manipulate cache freshness, because that
turns a predictable stat-validated cache into a coordination problem
across the daemon, IPC clients, and tests.
- **Stat-validated with bigint `mtimeNs + size`.** Cache entries are keyed
on `stat(meta.json, { bigint: true }).mtimeNs` and `size`. Do not
substitute directory mtime, `mtimeMs`, content hashes, or `fs.watch`
signals — atomic `writeAtomicJson` replacement bumps both `mtimeNs` and
often `size`, and the bigint variant is the only stat shape that
survives sub-millisecond writes on fast disks.
- **`loadMeta(runId)` stays cache-free.** Only `listRuns()` consults the
cache. `loadMeta` is the freshness escape hatch for targeted reads
(idempotency lookups, terminal reconciliation, internal mutators); it
must continue to read `meta.json` directly from disk every call. Caching
it would broaden the stale-read surface beyond the bulk scans the cache
was designed for.
Returned `RunMeta` values from `listRuns()` are JSON-cloned defensive
copies, and cached entries are JSON-normalized at write time. Skipping
either clone would let one caller poison every later snapshot via shared
object mutation. The detailed contract — including eviction, refresh
points, and the deferred persistent-index decision — lives in
`docs/development/run-metadata-cache.md`.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

