Title: mcpx: one content-addressed cache for prepared dependencies, import graphs and flake resolutions · Issue #1908 · developing-today/code · GitHub
Open Graph Title: mcpx: one content-addressed cache for prepared dependencies, import graphs and flake resolutions · Issue #1908 · developing-today/code
X Title: mcpx: one content-addressed cache for prepared dependencies, import graphs and flake resolutions · Issue #1908 · developing-today/code
Description: Relocated 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/ni...
Open Graph Description: Relocated 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 referenc...
X Description: Relocated 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 refe...
Opengraph URL: https://github.com/developing-today/code/issues/1908
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx: one content-addressed cache for prepared dependencies, import graphs and flake resolutions","articleBody":"Relocated from dezren39/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).\n\nParent: #175\n\n## Summary\n\nThree runtime issues each introduce a content-addressed cache, and each designs it alone: #103 a prepared dependency\ndirectory, #104 a resolved import graph, #107 a resolved flake reference. The one cache mcpx has today is sized and\nevicted for something far smaller. Built three times, they get three layouts, three eviction rules and three\nconcurrency bugs -- and #78 (daemon state and cache correctness) gets three more members. This issue owns one cache\nmechanism; the three issues own what they put in it.\n\nThis is #181 collision 12.\n\n## Original notes\n\n> - non-ai auto-import dynamic if a script imports something that isnt avaialble\n\n> - 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\n\n> - 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 \n\n## Current state (05c78b2)\n\n- Exec workdirs are content-addressed and evicted **by count**: `pruneWorkDirs` (`internal/runner/runner.go:808`) keeps\n `defaults.ExecWorkDirs` directories (`internal/defaults/defaults.go:413`). Each holds a generated client -- kilobytes.\n- It is already one of three count-based pruners, each written separately: `prunePrograms` (`runner.go:768`, generated\n programs per workdir), `pruneWorkDirs` (`:808`) and `pruneEntries` (`:847`, entry points beside a user's script).\n Their bounds (`exec.programs: 64`, `exec.workDirs: 8`, `exec.entries: 8`, `internal/defaults/defaults.json:96-100`)\n are built-in defaults, not settings.\n- Nothing is evicted by size or age, nothing pins an entry a running exec is using, and there is no listing or prune\n command for cached state. Each pruner spares only the caller's own entry (`if p == keep`) and orders the rest by\n mtime, so a concurrent run's directory is protected only by being recent.\n\nThe three proposals differ by orders of magnitude, which is the point this issue exists to make:\n\n| Cache | Proposed in | Key (as proposed) | Size of an entry |\n| --- | --- | --- | --- |\n| prepared dependencies (`node_modules`, deno/bun cache) | #103 | dependency set | tens to hundreds of MB |\n| import graph | #104 | entry file hash + transitive mtimes | kilobytes |\n| 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 |\n\nTwo more candidate tenants are proposed in sibling issues, and they should not become a fourth and fifth design:\n#100's compiled JS (`script.compile`, \"its own cache keyed by script hash + runtime\" is an open question there) and\n#105's uv environments per dependency set.\n\nSo \"one cache\" should mean one **mechanism** (layout, keys, index, eviction, pinning), not one blob store.\n\n## Approaches\n\n**A -- each issue keeps its own directory and pruning.** What happens by default. Count-based eviction applied to\n`node_modules` trees is unbounded in bytes, and three prune loops race each other and any running exec.\n\n**B -- generalise `pruneWorkDirs` to every kind: one root, evicted by count.** One mechanism, little code. Count is the\nwrong unit when entries differ by five orders of magnitude, and it still has no pinning, so a prune can delete the\ndependencies of an exec that is running.\n\n**C -- recommended: one cache package with per-kind namespaces.** `\u003cstate>/cache/\u003ckind>/\u003ckey>`; keys are the SHA-256 of\ncanonical inputs (for #104, content hashes rather than mtimes, which are not stable across checkouts); entries are\ncreated in a temp directory and renamed into place; a lease (lock file or refcount) pins an entry while an exec uses it;\neviction by total bytes and age, never touching a leased entry; #107's entries register and drop nix GC roots; limits\nare settings (`cache.maxBytes`, `cache.maxAge`; names open), and `mcpx cache` lists and prunes (or the existing\n`status` gains a section -- prefer that over a new command if it fits). Recommended because it is the only option that\ngives the large kind a byte bound and every kind a guarantee that a running script's inputs are not deleted under it.\n\n## Open questions\n\n- Should #103 cache at all, or lean on the runtimes' own content-addressed caches (`DENO_DIR`, bun's global cache with\n hardlinks, npm's cache) and have mcpx cache only the resolved manifest? That would shrink the large kind to bytes.\n- Who evicts -- the daemon, or any process that writes? Eviction racing between a daemon and a standalone CLI run is\n the #78 bug class.\n- Do the existing exec workdirs (and the program and entry pruners) move onto this, or stay as they are? If they move,\n their three built-in bounds become settings of the mechanism rather than three more constants.\n- Timing: this has to be settled before the first of #103/#104/#107 ships a cache. After that, it is a migration.\n- The daemon's schema cache is a fourth existing cache with its own invalidation, a hand-bumped `cacheVersion` (`internal/daemon/registry.go:102-106`; #78 item 3). Whether it joins the mechanism (keyed by content instead of a version constant) is the same question as the pruners.\n\n## Ease · Impact · Related\n\n**Ease** M · **Impact** med-high -- cheap now, expensive after the first of #103/#104/#107 ships its own.\nRelated: #103, #104, #107 (users), #100 and #105 (candidate users: compiled JS, uv environments), #78 (cache\ncorrectness), #181 (collision 12).\n\nSecurity/auth deferred; see tracker.\n\n\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-28T22:25:24Z","url":"https://github.com/developing-today/code/issues/1908"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a1066869-8840-8a83-9fd9-446a79140b66 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C2BE:1D2D33:2C7567:3A8449:6B06160D |
| html-safe-nonce | b8732abbc224ea7a50a3d2f1c5abd5cd2f6aa2f872c0c0a5a73141a630a1634f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkJFOjFEMkQzMzoyQzc1Njc6M0E4NDQ5OjZCMDYxNjBEIiwidmlzaXRvcl9pZCI6Ijc5OTgyNjE3OTQ4NDYwNTU3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | fce9a042c0f5381708b8e4888715de44905a77d81bd2b50aad59a21e2981126f |
| hovercard-subject-tag | issue:6088624585 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/1908/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9fac4c6e5cb0cc8ee6c827556f5ba396e0d5ff29e6a87aff972b6e36d0233175/developing-today/code/issues/1908 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9fac4c6e5cb0cc8ee6c827556f5ba396e0d5ff29e6a87aff972b6e36d0233175/developing-today/code/issues/1908 |
| og:image:alt | Relocated 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 referenc... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 97d4714e567728e1f85f88b0cf68c89f0f8a3dc41e8869af7aeb8195ad990374 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 866f202ebf7ac5aff8f633417d9fd8a53818a977 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width