Title: mcpx testing: deterministic execution as a long-term aspiration (retrofit vs Rust rewrite) · Issue #1963 · developing-today/code · GitHub
Open Graph Title: mcpx testing: deterministic execution as a long-term aspiration (retrofit vs Rust rewrite) · Issue #1963 · developing-today/code
X Title: mcpx testing: deterministic execution as a long-term aspiration (retrofit vs Rust rewrite) · Issue #1963 · developing-today/code
Description: Relocated from dezren39/darwin-nix#126 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#126 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#126 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/1963
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx testing: deterministic execution as a long-term aspiration (retrofit vs Rust rewrite)","articleBody":"Relocated from dezren39/nix#126 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: #93\n\n## Summary\n\nThe simple, explicitly requested issue: consider **deterministic execution** as a long-term design aspiration, two ways -- retrofit mcpx (inject clock, randomness, filesystem, process spawn and network behind interfaces) or a Rust rewrite, which the notes call \"not a plan at all\". Not a plan to build either; a short record of what each would take, what blocks it, and the cheap steps that pay off regardless.\n\n## Original notes\n\n> - think a hack job of antithesis/tigerbeetle. this is the primary testing method is throw insane amount of variations. if something is found outside this system and a test that could have had missed it, make a different generator that uses the same seed and makes an infinite amount of things matching the offensive shape.\n> - we aren't shooting for deterministic execution to start, maybe we should but no. consider it a longterm design aspiration to retrofit or for rewrite in rust (not a plan at all, but could see it). separate simple issue for considering both those things.\n\n## Current state\n\n- Execution is nondeterministic by design today: Go goroutine scheduling; 78 `time.Now()` calls in non-test `internal/` code (05c78b2); ids from `crypto/rand` in `pool`, `tasks`, `elicit`, `artifacts`, `mcpserver`, `logging/trace`; 11 `exec.Command` sites; unix sockets (Deno/Bun) and TCP (Node) back to the daemon. The daemon's idle exit runs on wall-clock time. It is a setting, `autostart.idleExit` (default `4h`, `internal/defaults/defaults.json:138`; a setting since #56, not hardcoded), which #182 sets to 60 s for e2e.\n- Some seams already exist: `pool.ReapIdle(now time.Time)` takes the clock as a parameter (`internal/pool/pool.go:697`); e2e isolates state/cache/config/registry/idle-exit by env (`internal/e2e/e2e_test.go:52-68`).\n- The seeded-input design (#121, #124) reproduces inputs and test order, not interleavings. This issue is the other half.\n- Go 1.25+ ships `testing/synctest`: inside a \"bubble\", `time` uses a fake clock that advances only when every goroutine in the bubble is durably blocked. Its own docs say to avoid the real network and external processes inside a bubble (`go doc testing/synctest`).\n\n## What blocks determinism in mcpx\n\n| Source | Retrofit difficulty | Why |\n| --- | --- | --- |\n| Wall clock / timers | Low-medium | inject a `Clock`; or run in-process components under `synctest` |\n| `crypto/rand` ids | Low | inject an id source; seeded in tests |\n| Filesystem | Medium | an `fs` seam for state/cache/artifacts; `t.TempDir` already isolates |\n| Goroutine scheduling | High | Go has no deterministic scheduler; `synctest` makes time deterministic, not interleavings |\n| Unix sockets / TCP / HTTP | High | real kernel I/O; in-process `net.Pipe` transports only for components that can run in one process |\n| **Runtime subprocesses (deno, bun, node)** | **Not feasible** | separate processes with their own event loops, JITs and clocks; the core of `mcpx exec` |\n| Real MCP servers (#97 real-software subset) | Not feasible | third-party processes |\n\n## Approaches\n\n### A -- Rust rewrite for determinism (least recommended; \"not a plan at all\", agreed)\nWhat it would buy: Rust async simulation frameworks (e.g. madsim, turmoil for tokio) simulate time and network in one process, TigerBeetle/FoundationDB-style. What it would *not* buy: determinism for the deno/bun/node subprocess that runs every script, or for real MCP servers -- the part of mcpx most likely to misbehave. A full rewrite of a working Go codebase for a property it still would not achieve end to end is the wrong trade. Worth revisiting only if a rewrite happens for other reasons.\n\n### B -- full retrofit: every nondeterminism source behind an interface, a simulated daemon\nClock, ids, fs, spawn and network all injected; a test harness runs the daemon, pool, events and a fake MCP server in one process on simulated transports, seeded from the run seed, VOPR-style. Achievable for the daemon's *internal* logic (pool admission/reaping, task lifecycle, elicitation broker, event store #6, state/cache #78), and it would find real concurrency bugs. Costs: interfaces threaded through most packages, a simulated transport layer, and it still stops at the runtime subprocess boundary. L-XL effort for partial coverage.\n\n### C -- incremental seams where they pay today; Antithesis-style tooling as the end-to-end answer (recommended)\n- Add seams only when a test needs them: a `Clock` for idle-exit (already configurable through `autostart.idleExit`, but a test of it still waits in real time), seeded id sources, `ReapIdle`-style `now` parameters.\n- Use `testing/synctest` for in-process concurrent components (pool, tasks, elicit, events): deterministic time and \"wait until everything is blocked\" instead of `time.Sleep` polling -- which also removes the flake-prone sleeps found in #125.\n- Derive every injected randomness source from the run seed (#121) so partial determinism composes with seeded inputs.\n- For true end-to-end determinism including the runtime subprocesses, the realistic path is a deterministic hypervisor (Antithesis runs unmodified containers), not a rewrite. That needs a container image. One now exists: #182 added `pkgs/mcpx/Containerfile` (debian bookworm-slim runtime, bun, 413 MB; `docs/container.md`). It has no CI job and no tests yet (#134). This is a prerequisite that is now met, not a plan.\n- Why C: each step is small, useful on its own (fewer flakes, faster tests), and moves toward B without committing to it.\n\n## Open questions\n\n- Is idle-exit the first `Clock` seam? #182 fixed #52 without one (cleanup plus a 60 s idle exit), so a bug no longer forces it. It is still the seam whose tests otherwise wait in real time.\n- Which in-process components would `synctest` cover without refactoring (does anything inside them touch real sockets or processes)?\n- The container image exists (#182). Is running it under a deterministic hypervisor worth one experiment once #134 gives it a CI job?\n\n## Ease · Impact · Related\n\n**Ease** S (this issue: record + first seam list) · C incremental: S per seam · B: L-XL · A: XL, not planned · **Impact** low now, med long-term (flake reduction is the near-term win)\n**Depends on / related:** #121, #124, #125; #52 (closed, fixed in #182), #78 (state/cache), #6 (event store), #97 and #134 (the container image and its CI job, real-software subset), #99 (flake policy).\n\nSecurity/auth deferred; see tracker.\n\n## Acceptance criteria\n\n- A short record exists (on this issue or in the docs tree and linked here) comparing the two routes to deterministic execution — retrofit (clock, randomness, filesystem, process spawn, network behind interfaces) vs a Rust rewrite — with what each would take and what blocks it.\n- The cheap steps that pay off regardless of route are listed, and each is either filed as its own issue or explicitly dropped with a reason.\n- No implementation is started under this issue (it is explicitly not a plan to build either route).\n- Evidence (the record's location) is recorded on this issue before it is closed.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-28T22:47:24Z","url":"https://github.com/developing-today/code/issues/1963"}
| 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:ade9898b-45e7-b7a8-e77c-df9f96b59176 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A60C:3AD124:4BEA65:62E086:6B061D8C |
| html-safe-nonce | 1a22726fcb50638d65fea974b1c15589f61223f594114341df7c60db5cb92cf6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjBDOjNBRDEyNDo0QkVBNjU6NjJFMDg2OjZCMDYxRDhDIiwidmlzaXRvcl9pZCI6IjUzNjI2Mjg5OTg1ODc2MjA3NDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f7df9c3735bcb75ede6f9add2593fd3cdebcb91635bc1b3ecddd8361c5b3ba73 |
| hovercard-subject-tag | issue:6088915180 |
| 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/1963/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6c8fd1b9c8792b3a48a79acee6057a1a07b9f187c5104af65aec2f6b009b5d54/developing-today/code/issues/1963 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6c8fd1b9c8792b3a48a79acee6057a1a07b9f187c5104af65aec2f6b009b5d54/developing-today/code/issues/1963 |
| og:image:alt | Relocated from dezren39/darwin-nix#126 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 | 9a7c5824b75ea2ec5e3de73a483229c7bb9f32a774ffd401f010dd9bacf1483d |
| 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 | b25c3080e84402f75431d8dc7a96b2635219cec7 |
| 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