Title: mcpx: design a comprehensive docs and testing strategy · Issue #1892 · developing-today/code · GitHub
Open Graph Title: mcpx: design a comprehensive docs and testing strategy · Issue #1892 · developing-today/code
X Title: mcpx: design a comprehensive docs and testing strategy · Issue #1892 · developing-today/code
Description: Relocated from dezren39/darwin-nix#91 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...
Open Graph Description: Relocated from dezren39/darwin-nix#91 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 reference...
X Description: Relocated from dezren39/darwin-nix#91 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 refer...
Opengraph URL: https://github.com/developing-today/code/issues/1892
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx: design a comprehensive docs and testing strategy","articleBody":"Relocated from dezren39/nix#91 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: #181\n\n## Summary\n\nOne strategy for how mcpx is **tested** and **documented**, decided once, so that the test suite, the CI that runs it, the policies agents follow, and the book that explains mcpx all pull the same way. This is a joint design issue: it sits at the top of both the testing tree (sub-trackers below) and the documentation tree (its top tracker is #89).\n\nThe testing half has one stated priority from the notes -- **CI as short as possible** -- and one stated focus -- **strong tests at each step of the lifecycle**. Everything below serves those two.\n\n## Original notes\n\n> make an issue to design a comprehensive docs/testing strategy:\n\n> - testing\n\n> - importantly, as we add more testing agents should not run every single test basically ever. below documents a rough idea of a ci job design/policy, the main priority is being short as possible.\n\n> - a general goal is to ensure all features have one or more integration tests\n\n(Every other `- testing` bullet is quoted verbatim in the leaf issue that owns it; see the sub-trackers. The `- documentation` bullets are owned by the documentation tracker.)\n\n## Current state (written at d0b7e01; re-checked at 05c78b2, after #171 and #182)\n\n| Fact | Where |\n| --- | --- |\n| 735 `func Test*` across 64 files; 209 of them in `internal/e2e` (719 / 61 / 199 at d0b7e01) | `rg -c '^func Test' --glob '*_test.go'` |\n| **No** `Fuzz*`, `Benchmark*`, property tests, `math/rand`, or `t.Parallel()` anywhere | same `rg` |\n| e2e drives the real binary (`testsupport.MCPXBinary`, built once per test binary) against a fake MCP server (`internal/testsupport/fakemcp`), isolated by `MCPX_STATE_DIR`/`MCPX_CACHE_DIR`/`MCPX_CONFIG`/`MCPX_REGISTRY_URL`/`MCPX_AUTOSTART_IDLE_EXIT` | `internal/e2e/e2e_test.go:35-92`, `internal/testsupport/build.go` |\n| One CI job, `.github/workflows/mcpx.yml`: ~22 s setup, **148 s** `go test ./... -count=1`, **70 s** `nix build` (at d0b7e01: ~32 s, 135 s, 60 s) | run 36693030957 (05c78b2); run 36673523537 (d0b7e01) |\n| Per-package: `internal/e2e` **108.9 s**, `internal/tui` 8.6 s, every other package \u003c 2 s (e2e was 100.7 s at d0b7e01) | same runs, `--log` |\n| `nix build` re-runs 18 unit packages in `checkPhase`, so unit tests run twice per CI run | `pkgs/mcpx/package.nix:72-82` |\n| No formatter or linter runs on mcpx in CI; `plugin/opencode/mcpx/daemon.test.ts` is never run by CI | `.github/workflows/` has `mcpx.yml`, `opencode.yml` only |\n| About 25 guard tests already exist as a pattern (listed in #129), among them `TestEveryExecFlagChangesSomething` (`e2e_test.go:2877`; covers 4 of 23 exec flags), `TestEveryDeclaredRouteAnswersOverTheSocket` (`v1ops_test.go:287`; asserts only \"not 404/5xx\") and `TestNoPackageRedeclaresADefault` (`defaults/guard_test.go:92`). The \"declared but never read\" audit and guard landed in #171 (`internal/settings/consumed_test.go`). Its inverse is #172 (in flight). The #171 guard proves a setting is *read*, not that reading it matters: `registry.pageSize` passed it (#179). #129 owns the stronger guard (#181 collision 15) | #129, #171, #172, #179 |\n| ~~The e2e suite leaks daemons (#52), so \"just run everything\" is actively harmful on a dev machine today.~~ **Fixed in #182:** cleanup runs `stop --all` through the `daemon-\u003ckey>.json` info files, and `newEnv` sets `MCPX_AUTOSTART_IDLE_EXIT=60s` (`e2e_test.go:68,79,92`). `TestEnvCleanupStopsTheDaemonItStarted` (`:2630`) guards it and was falsified by reverting the fix. \"Just run everything\" is now a cost problem (~110 s of serial e2e), not a leak. `testsupport` still leaves its temp dirs behind (`build.go:27,57`) | #182, #127, #129 |\n| The e2e harness passes the caller's whole environment (`os.Environ()`, `e2e_test.go:52`) to the binary, and the opencode plugin exports `MCPX_DAEMON_ENDPOINT` into every shell (`plugin/opencode/mcpx-session.ts:701`), so e2e run from opencode can reach the user's real daemon and real `HOME`/XDG config (from reading the code; unchanged by #182) | #138 |\n| ~~The Go cache in CI has never restored (`cache-dependency-path` isn't set), which costs about 31 s of compiling per run~~ **Fixed in #182:** `cache-dependency-path: pkgs/mcpx/go.sum` (`mcpx.yml:50`). The rest of #135's caching design (nix store cache, the `checkPhase` double run, sparse checkout) is still open | #135, #143 |\n| A static binary is **not** blocked by the code. With `CGO_ENABLED=0` Go uses its pure-Go `os/user` and `net`, and the result is a fully static, working linux binary (verified in #182: a 21 MB linux/arm64 \"statically linked\" ELF; `--build-arg CGO_ENABLED=0` on the Containerfile runs `--version`, `ls`, `call` and `exec`). The *shipped* artifacts are not static **by choice**: the nix package uses the nixpkgs cgo default and wraps a PATH suffix (`package.nix:96`), and the Containerfile leaves `ARG CGO_ENABLED=1` (`Containerfile:39`). What is open is policy, and only on Linux: pure-Go `os/user` reads `/etc/passwd`, not NSS/LDAP, and the pure-Go resolver bypasses NSS modules. On macOS `CGO_ENABLED=0` changes nothing (since Go 1.20 `net` and `os/user` there do not use cgo in either mode). `exec` also needs a JS runtime anyway. mcpx does not compile for Windows (`Setpgid`/`Setsid`/`syscall.Kill` with no build tags, e.g. `internal/runner/runner.go:413,428`, `internal/mcpclient/stdio.go:69,202`, `internal/cli/client.go:312`) | #136, #134 |\n| A Containerfile exists (#182): `pkgs/mcpx/Containerfile` (3 stages pinned by tag and digest, `debian:bookworm-slim` runtime, ships bun with `MCPX_SCRIPT_RUNTIME=bun`, 413 MB), `.dockerignore`, `docs/container.md`. There is no CI job and there are no container tests | #134, #136 |\n\nHistory that motivates the strategy -- each of these was found by accident, not by design:\n\n- a flaky test surfaced only on the lead's **third** full-suite run (matches PR #46, \"One run in three panicked\"); the race fixed in PR #61 shows up about 1 run in 5, and only under `-race`, which CI doesn't use;\n- a registry test reached the internet and failed only in CI (#65);\n- two tests passed on macOS and failed on Linux (#35);\n- flags accepted and silently ignored (#74, fixed in #75, now guarded by `TestEveryExecFlagChangesSomething`, whose own first assertion passed either way until the table's without-flag half caught it);\n- e2e daemons leaking for four hours (#52, fixed in #182);\n- a brand-new guard (#171's `consumed_test.go`) passing a setting that no ordinary caller can make matter (`registry.pageSize`, #179): proof that a guard has to be falsified too (#181 collision 15, owned by #129).\n\n## Strategy (the layers, and who owns each)\n\n| Layer | What it proves | Tree |\n| --- | --- | --- |\n| Unit | a package does what it says | policies |\n| Property / fuzz, **one seed per run** | a function holds for inputs nobody thought of; every escaped bug becomes a generator for its shape | fuzz & seeds |\n| Guard (meta) tests | a whole *class* of bug cannot recur (every flag, every route, every default, every declared field) | policies |\n| Integration (binary and app entrypoint, mock MCP servers) | every feature works end to end | integration & environments |\n| Real-software subset | the pinned real MCP servers still work | integration & environments |\n| Environment matrix | nix, container, local, remote, other OSes | integration & environments |\n| CI | all of the above, sharded to a time budget, plus formatters and linters | CI |\n| Docs-as-tests | code blocks and generated references in the book are executed/diffed in CI, so docs cannot drift | joint (decided here, built by docs + CI trees) |\n\n## Approaches\n\n### A -- keep bolting on (least recommended)\nKeep the single `mcpx.yml` job, add fuzz tests and docs ad hoc as features land. Cheapest today. Risks: CI time grows linearly with every e2e test (already ~110 s serial at 05c78b2), randomness enters without a seed discipline so failures are unreproducible, docs examples drift from the binary, and each accidental discovery above stays accidental. Every future bug costs a human noticing it.\n\n### B -- testing first, docs later\nBuild the testing trees (seeds, CI sharding, integration matrix, policies) now and write the book afterwards against a stable suite. Sound, and the order most projects take. The cost is that the book's examples become a second, untested copy of behaviour, and the two efforts pick incompatible conventions (where examples live, which binary builds them, what \"supported environment\" means).\n\n### C -- one lifecycle strategy, docs as a test surface (recommended)\nMake the decisions that both halves depend on here, once, then let the trees proceed in parallel:\n1. **Seed discipline first** (fuzz tree): every source of randomness in any test derives from one run seed. This must land before anyone adds a random test, or the first flaky fuzz failure is unreproducible.\n2. **CI skeleton second** (CI tree): a test workflow with an init job (which also mints the seed), a matrix, and a budget job. Formatters/linters join the matrix. Existing `mcpx.yml` keeps only the vendorHash repair and nix build.\n3. **Policies in parallel** (policies tree): what agents run locally, one test per bug, guard tests per bug class, flake handling.\n4. **Integration coverage and environments** (integration tree), which lean on 1 and 2.\n5. **Docs as a test surface** (joint): every runnable code block in the book is extracted and run by CI against the built binary, and generated references (`mcpx man`, OpenAPI from `mcpx api`, the settings table) are regenerated and diffed. The docs tree owns the book; the CI tree owns the job that runs its examples.\n\nRecommended because it makes the one irreversible choice (how random inputs are generated) before any data exists, and because docs that execute are the cheapest integration tests mcpx will ever get.\n\n## Tree\n\n| Tracker | Leaves | First step |\n| --- | --- | --- |\n| #93 fuzzing and property tests with one seed per run | #121 #123 #124 #125 #122 #126 | #121 seed format and derivation |\n| #95 fast, sharded CI with a time budget, linters and auto-format | #135 #143 #140 #139 #141 #142 | #143 first iteration (3 e2e shards, baseline; its Go-cache line already landed in #182) |\n| #97 integration tests for every feature, across environments | #138 (bug) #132 #133 #134 #137 #136 | #138 build the e2e environment from an allowlist |\n| #99 policies for agents | #127 #131 #128 #129 #130 | #127 + #131 which tests an agent runs, and the contributor page |\n| #89 documentation: the book -- overview, manual and compendium (XL / high) | #90 #92 #94 #96 #98 | #117 choose the generator; #158 is the critical path for the install story |\n\n- [ ] #93 mcpx testing: fuzzing and property tests with one seed per run\n- [ ] #95 mcpx testing: a fast, sharded CI with a time budget, linters and auto-format\n- [ ] #97 mcpx testing: integration tests for every feature, across environments\n- [ ] #99 mcpx testing: policies for agents -- what to run, a test per bug, guards per bug class\n- [ ] #89 mcpx docs: the book -- overview, manual and compendium (tracker)\n\n### Proposed order across trees\n0. **Done (#182, 05c78b2):** #52's leak (info-file `stop --all` cleanup, a 60 s idle exit in `newEnv`, a leak test falsified by reverting the fix); the CI Go-cache line (`mcpx.yml:50`); a Containerfile (`pkgs/mcpx/Containerfile`, no CI job yet). Before that, #171 landed the \"declared but never read\" settings guard.\n1. **Now, cheap, no dependencies:** #138 (a correctness hole), #127 + #131 (stop agents running the full suite), #143 (roughly halves CI wall time; its cache line is already in), and **#129's settings effect guard** (#181 collision 15), which must land before or with #172 (in flight) rather than wait for step 4.\n2. **The one irreversible decision:** #121 seed format, then #123 engine and #124 generator versioning. No randomised test lands before #121.\n3. **CI shape:** #135, #140, #139, #141, #142.\n4. **Policies that need the seed and CI:** #128, the rest of #129, #130.\n5. **Integration and environments:** #132, #133, #134, #137, then #136.\n6. **Research, any time:** #126 and #122.\n\n> Reconciled: two issue-writing sessions ran against this tree at once. The later pass duplicated the #97 and #95 branches. Its duplicates are closed, and their surviving issues are the leaves listed above: #132-#138 under #97, and #135 and #139-#143 under #95. The two genuinely new findings were moved across as comments on #134 and #141, and in the 2026-09-30 issues pass every remaining unique fact, argument and open question from #160-#170 was carried into its survivor's body (each closed duplicate has a comment listing what moved where). The 23 leaves listed above are the tree.\n\n### Ease / impact\n| Tracker | Ease | Impact |\n| --- | --- | --- |\n| #93 | L | high |\n| #95 | L | high |\n| #97 | XL | high |\n| #99 | M | high |\n\n## Open questions\n\n- Where does the contributor/agent test policy live? `pkgs/mcpx/AGENTS.md` today is **user-facing** (how an agent *uses* mcpx; 109 lines, no mention of tests), and anything added there is loaded into every consuming agent's context. A separate `CONTRIBUTING.md` / `docs/testing.md` referenced from a short AGENTS.md line is likely better -- decided in the policies tree (#131 recommends `docs/testing.md` plus a short nested `pkgs/mcpx/internal/AGENTS.md`, which opencode attaches only when an agent reads mcpx source).\n- Should `mcpx.yml` be renamed/split into `test.yaml` + `build.yaml`, or keep its name (branch protection rules and Renovate references point at job names)?\n- Is the docs-as-tests job part of the main test matrix (blocks merges) or a separate workflow (warns only) at first?\n- #49 (CI for every flake package) overlaps the CI tree: one workflow design or two?\n\n## Ease · Impact · Related\n\n**Ease** XL (as a tree; this issue itself is S once the children are settled) · **Impact** high\n**Related**: #181 (parent), #49, #52 (closed, fixed in #182), #78, #79, #47, #48, #35, #65, #74, #75; #171 (merged: the \"declared but never read\" settings audit and guard), #172 (its inverse, in flight), #179 (the setting #171's guard passed; #181 collision 15, owned by #129); #89 (documentation top tracker).\n\nSecurity/auth deferred; see tracker.\n\n\n\n\n\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-28T22:18:10Z","url":"https://github.com/developing-today/code/issues/1892"}
| 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:79aa2856-e48b-9d5a-8897-047be4a20ad6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A5E0:8AD7D:295895:379D48:6B0616F7 |
| html-safe-nonce | 80356b91992b9821528c10adb073298d82acd425221f6e72185a1b18535dd6c5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNUUwOjhBRDdEOjI5NTg5NTozNzlENDg6NkIwNjE2RjciLCJ2aXNpdG9yX2lkIjoiMzc3OTExMjQ4MTExMzY0Mjc0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 11d73a1ca3bc46190a43c178e9bdb3804eb31117a04b1c4711ad7b6dfd8ca8be |
| hovercard-subject-tag | issue:6088524101 |
| 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/1892/issue_layout |
| twitter:image | https://opengraph.githubassets.com/aa45f61160937cbb0627529402c23e4c52d62f67fb5b3f1ec5e0fb8467ea9421/developing-today/code/issues/1892 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/aa45f61160937cbb0627529402c23e4c52d62f67fb5b3f1ec5e0fb8467ea9421/developing-today/code/issues/1892 |
| og:image:alt | Relocated from dezren39/darwin-nix#91 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 reference... |
| 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