GeezerVison is showing github.com — mcpx: one content-addressed cache for prepared dependencies, import graphs and flake resolutions · Issue #1908 · developing-today/code
mcpx: one content-addressed cache for prepared dependencies, import graphs and flake resolutions #1908DescriptionRelocated from dezren39/darwin-nix#187 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue references inside it are historical (dezren39/nix numbering).
Parent: #175
Summary
Three runtime issues each introduce a content-addressed cache, and each designs it alone: #103 a prepared dependency
directory, #104 a resolved import graph, #107 a resolved flake reference. The one cache mcpx has today is sized and
evicted for something far smaller. Built three times, they get three layouts, three eviction rules and three
concurrency bugs -- and #78 (daemon state and cache correctness) gets three more members. This issue owns one cache
mechanism; the three issues own what they put in it.
This is #181 collision 12.
Original notes
- non-ai auto-import dynamic if a script imports something that isnt avaialble
- if i import a file in another dir that has its own package.json/lock can it auto-import, prepare dependencies to be available whereever needed
- accept a flake url as an alternative exec env (devshell/shell.nix in default pwd or tempdir or ad-hoc flake that isfully isolated, path executed before script, script executed inside
Current state (05c78b2)
- Exec workdirs are content-addressed and evicted by count:
pruneWorkDirs (internal/runner/runner.go:808) keeps
defaults.ExecWorkDirs directories (internal/defaults/defaults.go:413). Each holds a generated client -- kilobytes.
- It is already one of three count-based pruners, each written separately:
prunePrograms (runner.go:768, generated
programs per workdir), pruneWorkDirs (:808) and pruneEntries (:847, entry points beside a user's script).
Their bounds (exec.programs: 64, exec.workDirs: 8, exec.entries: 8, internal/defaults/defaults.json:96-100)
are built-in defaults, not settings.
- Nothing is evicted by size or age, nothing pins an entry a running exec is using, and there is no listing or prune
command for cached state. Each pruner spares only the caller's own entry (if p == keep) and orders the rest by
mtime, so a concurrent run's directory is protected only by being recent.
The three proposals differ by orders of magnitude, which is the point this issue exists to make:
| Cache |
Proposed in |
Key (as proposed) |
Size of an entry |
prepared dependencies (node_modules, deno/bun cache) |
#103 |
dependency set |
tens to hundreds of MB |
| import graph |
#104 |
entry file hash + transitive mtimes |
kilobytes |
| flake resolution |
#107 |
reference + lock |
bytes -- but the store path it names lives in /nix/store and is collected by nix-collect-garbage unless mcpx holds a GC root |
Two more candidate tenants are proposed in sibling issues, and they should not become a fourth and fifth design:
#100's compiled JS (script.compile, "its own cache keyed by script hash + runtime" is an open question there) and
#105's uv environments per dependency set.
So "one cache" should mean one mechanism (layout, keys, index, eviction, pinning), not one blob store.
Approaches
A -- each issue keeps its own directory and pruning. What happens by default. Count-based eviction applied to
node_modules trees is unbounded in bytes, and three prune loops race each other and any running exec.
B -- generalise pruneWorkDirs to every kind: one root, evicted by count. One mechanism, little code. Count is the
wrong unit when entries differ by five orders of magnitude, and it still has no pinning, so a prune can delete the
dependencies of an exec that is running.
C -- recommended: one cache package with per-kind namespaces. <state>/cache/<kind>/<key>; keys are the SHA-256 of
canonical inputs (for #104, content hashes rather than mtimes, which are not stable across checkouts); entries are
created in a temp directory and renamed into place; a lease (lock file or refcount) pins an entry while an exec uses it;
eviction by total bytes and age, never touching a leased entry; #107's entries register and drop nix GC roots; limits
are settings (cache.maxBytes, cache.maxAge; names open), and mcpx cache lists and prunes (or the existing
status gains a section -- prefer that over a new command if it fits). Recommended because it is the only option that
gives the large kind a byte bound and every kind a guarantee that a running script's inputs are not deleted under it.
Open questions
Ease · Impact · Related
Ease M · Impact med-high -- cheap now, expensive after the first of #103/#104/#107 ships its own.
Related: #103, #104, #107 (users), #100 and #105 (candidate users: compiled JS, uv environments), #78 (cache
correctness), #181 (collision 12).
Security/auth deferred; see tracker. Activitydeveloping-today commented on Oct 28, 2026 dezren39 commented on Oct 28, 2026 History carried over from dezren39/darwin-nix#187 (verbatim, oldest first):
@dezren39 · 2026-09-30T12:07:49Z
Issues pass (2026-09-30, at 05c78b2).
@dezren39 · 2026-09-30T12:16:52Z
Issues pass (2026-09-30, architect follow-up). Open question added: the daemon's schema cache (hand-bumped cacheVersion, internal/daemon/registry.go:102-106, #78 item 3) is a fourth existing cache; whether it joins the mechanism is the same question as the three pruners. dezren39 commented on Oct 29, 2026 dezren39 commented on Oct 29, 2026 🤖 Agent note · done
Triage verdict
Dedupe: no duplicate — #1908 is the unique owner of the cache mechanism.
- mcpx: where a script's packages come from -- npm/deno/bun dependency configuration chain #1913 (prepared dependencies, was nix#103), mcpx: resolve a script's import graph statically and prepare missing dependencies #1915 (import graph, was nix#104) and mcpx: accept a flake ref as a program and as an execution environment #1921 (flake refs, was nix#107) each carry a "Cache: deferred to Phase 4: joiner with missing pre-join control messages stalls silently #187" header: they own what they put in the cache and explicitly defer the mechanism (layout, keys, eviction, leases) to this issue.
- mcpx: small correctness problems in daemon state and caches #1866 (was nix#78, daemon state and cache correctness) is related — its item 3 is the schema-cache question listed in this issue's open questions — but it does not own a unified cache mechanism.
- mcpx: Python as a first-class script language, 1:1 with TypeScript #1917 (Python/uv environments) names itself a tenant of this mechanism; mcpx: how the JavaScript runtime is chosen, what each does with TypeScript, and an automatic validate/compile step #1911's bundle step is a candidate tenant. Neither duplicates this issue.
- Searches for the mechanism itself (
pruneWorkDirs, "cache mechanism", "content-addressed cache") return only mcpx: one content-addressed cache for prepared dependencies, import graphs and flake resolutions #1908 and its tenants above.
Scope confirmed against current pkgs/mcpx on main (8124cc0):
Follow-up: implementation packet enqueued as queue task 3148 (kind small_fix, dedupe key repo-health:v1:fix:developing-today/code:issue:1908) carrying Approach C and the acceptance criteria intact, including answering the open questions on the PR rather than dropping them. Tenant integrations stay under their own issues.
Labels updated to mirror the queued follow-up.
dezren39 commented on Nov 3, 2026 agent-note:v1
state: triaged (coverage pass)
Coverage pass 2026-11-03: reviewed in the fleet-wide per-issue pass (drift / overlap / already-handled / stale / blockers / ordering). Verdict: still live; queued in repo-health-code-pilot as triage at priority 30 (priority/none). If this is already handled at current main, the triage closes it with evidence; if it needs splitting, the triage files the split.
Found via: coverage pass 2026-11-03 dezren39 commented on Nov 4, 2026 🤖 Agent note · handed off
dezren39 commented on Nov 4, 2026 dezren39 commented on Nov 4, 2026 🤖 Agent note · done — resolved on current main
Resolution evidence (verified against current main b6f36bf355d1bdd9e59cad083312868b71e92e8a)
pkgs/mcpx/internal/cache/cache.go implements the shared per-kind cache, canonical SHA-256 keys, atomic puts, leases, listing, byte/age/count eviction and shared pruning (Limits/Key lines 39-72; Put 150-187; leases 199-216; List 253-258; Evict/Prune/victim selection 352-418).
pkgs/mcpx/internal/runner/runner.go acquires leases for running workdirs/programs and routes the three historical pruners through cache.Prune (425-471, 1341-1389). pkgs/mcpx/internal/cli/cache.go provides list/prune/remove; cache limits are configurable in defaults.
- The implementation PR mcpx: one content-addressed cache mechanism (internal/cache) — #1908 Approach C #2555 is MERGED (
674c4c6); hardening PR fix(mcpx): cache — traversal rejection, Put self-eviction, eviction lease re-check (#2566) #2838 (42435d6) and lease-scan fix fix(mcpx/cache): Scan skips beside-file leases so Prune can never delete a live lease (#3112) #3728 (70a595a) are also MERGED. No open PR for mcpx: one content-addressed cache for prepared dependencies, import graphs and flake resolutions #1908.
- PR mcpx: one content-addressed cache mechanism (internal/cache) — #1908 Approach C #2555 explicitly records the daemon schema cache as a deliberate non-join assigned to mcpx: small correctness problems in daemon state and caches #1866 item 3, and says cache tenants remain owned by their separate issues. Neither is an untracked gap in this mechanism issue.
This tracker is resolved and closed. No follow-up task was enqueued because the shared mechanism is delivered; remaining tenant work is intentionally separate.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|