Title: mcpx testing: which tests an agent runs, and never the full suite locally · Issue #1966 · developing-today/code · GitHub
Open Graph Title: mcpx testing: which tests an agent runs, and never the full suite locally · Issue #1966 · developing-today/code
X Title: mcpx testing: which tests an agent runs, and never the full suite locally · Issue #1966 · developing-today/code
Description: Relocated from dezren39/darwin-nix#127 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#127 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#127 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/1966
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx testing: which tests an agent runs, and never the full suite locally","articleBody":"Relocated from dezren39/nix#127 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: #99\n\n## Summary\n\nDecide **which tests an agent working on mcpx runs, and when**, so that no agent runs the whole suite as a habit. The rule: an agent runs the smallest set that covers its change -- the edited packages' unit tests, a named handful of e2e tests, and the guard tests for any registry it touched -- and leaves the full suite to CI (#95). This issue decides the tiers, how an agent finds the tests that touch a change, what is never run locally, and how a CI failure is reproduced. The page that tells agents all this is #131.\n\n## Original notes\n\n> - testing\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(The second line is also the joint strategy's framing in #91 and the CI tree's preamble in #95. This issue owns its *agent-side* half: what an agent runs locally. The CI half -- keeping the full run short -- is #95.)\n\n## Current state (re-checked at 05c78b2)\n\nPer-package cost, CI run 36693030957 at 05c78b2 (ubuntu-latest, `go test ./... -count=1`, step total 148 s, the rest is compilation). The d0b7e01 run 36673523537 had e2e at 100.7 s of a 135 s step; e2e grows with every test.\n\n| Package | Time | Notes |\n| --- | --- | --- |\n| `internal/e2e` | **108.9 s** | 209 tests, serial (no `t.Parallel()` anywhere), each drives the real binary |\n| `internal/tui` | 8.6 s | |\n| `internal/pool` | 1.6 s | |\n| `internal/events`, `internal/mcpserver` | ~1.0-1.3 s each | |\n| every other package | \u003c 0.6 s | 25 packages |\n| `nix build .#mcpx` | 70 s | re-runs 18 unit packages in `checkPhase` (`package.nix:73-82`) |\n\nFacts that shape the policy:\n\n- **e2e sees every change, through the binary, not through imports.** `go list -test -deps ./internal/e2e` lists only `internal/api` and `internal/testsupport`. The binary under test is built by a `go build ./cmd/mcpx` *subprocess* (`internal/testsupport/build.go:54-74`). So Go's own dependency graph cannot say which e2e tests a change affects -- by that graph almost no change affects e2e, and in reality every change does.\n- **Stale green risk (not reproduced; nobody has checked it yet).** `go help test`: results are cached for runs using only cacheable flags (`-run` is one), and a cached result is reused while the *test binary*, the env vars it reads and the files *it* opens are unchanged. The files the `go build` subprocess reads are not tracked. So after editing, say, `internal/runner`, `go test ./internal/e2e -run '^TestX$'` would plausibly print `ok ... (cached)` without building the new binary. CI is safe (`-count=1`, `mcpx.yml:65`). Any local e2e run must use `-count=1`. The same applies to a local `go test ./...`: its e2e line may have been cached.\n- **`-run` is an unanchored regexp** (`go help testflag`): `-run TestEveryExec` also matches any longer name. Use `-run '^(TestA|TestB)$'`; subtests `-run '^TestA$/^case$'`.\n- **Local e2e runs no longer leak daemons (#52, fixed in #182).** `newEnv`'s cleanup now runs `stop --all`, which reads the `daemon-\u003ckey>.json` info files instead of recomputing the socket path, and logs a failure instead of discarding it (`internal/e2e/e2e_test.go:71-85`). `newEnv` also sets `MCPX_AUTOSTART_IDLE_EXIT=60s` (`:68`, `:92`), so a daemon that escapes an interrupted run dies within a minute instead of 4h. `TestEnvCleanupStopsTheDaemonItStarted` (`:2630`) guards it and was falsified by reverting the fix. What remains: `testsupport` still leaves its `mcpx-bin-*` and `mcpx-fake-*` temp dirs behind on every test-binary run (`build.go:27,57`, `os.MkdirTemp` with no removal).\n- Existing file split in e2e helps a little: `exec_test.go`, `settings_test.go`, `v1ops_test.go`, `proto_test.go`, `consumer_test.go`, `runtime_test.go`, `logs_test.go`, `multiconfig_test.go`, `unread_test.go` (#171) -- but `e2e_test.go` holds 129 of the 209 tests.\n- No test recipe exists anywhere: the repo-root `justfile` has no mcpx recipes, `pkgs/mcpx` has no justfile; `scripts/` has only `bench.sh` and `stress.sh` (manual, real servers).\n- History: #65 was merged with its own check red and unread. Whatever the local policy, reading the PR's CI result before merging is part of it.\n- **In practice, integrators do run the full suite locally, repeatedly.** PR bodies: #69 and #70 \"Suite 2× clean\", #171 \"Suite 3× clean before my change and 2× after\", #182 \"Suite 3× clean\" plus a daemon count across the runs. The merge protocol the integrating agents follow asks for this. It is the only repeat-run flake detection mcpx has until #130's CI jobs exist. The policy below therefore has to say who runs the full suite (the integrator, before merging), not only who does not.\n\n## Proposed policy (the tiers)\n\n| Tier | When | Command | Typical cost |\n| --- | --- | --- | --- |\n| T0 format/vet | always, touched packages | `gofmt -l \u003cfiles>`; `go vet ./internal/\u003cpkg>/` | \u003c 2 s |\n| T1 unit | always, each package with an edited `.go` file | `go test -count=1 ./internal/\u003cpkg>/` | \u003c 2 s each (tui 8.6 s) |\n| T1b dependents | only when an *exported* identifier changed | the same, for packages that import it (`go list -f '{{.ImportPath}} {{join .Imports \" \"}}' ./...` reverse lookup) | seconds |\n| T2 targeted e2e | when behaviour visible through the binary changed | `go test -count=1 ./internal/e2e -run '^(TestA\\|TestB)$'` | ~0.5 s/test average + one binary build; budget ~15 tests / ~30 s |\n| T3 guards | when a registry was touched (flag, `/v1` op, setting, default constant) | the guard for that registry (list in #129), e.g. `-run '^TestEveryExecFlagChangesSomething$'` | seconds |\n| T4 build | only when `package.nix`, `go.mod`/`go.sum` or `vendorHash` changed | `nix build .#mcpx` | 70 s |\n| Full suite | **never locally for a routine change**; CI on push (#95). The integrator merging a PR is the exception (rule 7) | -- | ~110 s of serial e2e plus compilation, and growing |\n\nRules around the tiers:\n\n1. **Never run** `go test ./...` or an unfiltered `go test ./internal/e2e` locally, unless the user asks for it by name or you are the integrator merging (rule 7). The reason is cost: ~110 s of serial e2e plus compilation, paid again on every run, and the number grows with every e2e test. There used to be a second reason: each run left daemons alive for up to 4 h (#52). #182 removed that one. The cost reason remains.\n2. **Always `-count=1`** for e2e (stale green above). For unit packages the cache is correct and welcome.\n3. **Push, then read CI.** The full run is CI's job; an agent must read the result of the PR's check before declaring done or merging (#65).\n4. **Harness changes** (`internal/testsupport/**`, `newEnv`, the fake servers) affect every e2e test: run a small sample locally (`^(TestNoOrphanProcessesAfterStop|TestEnvCleanupStopsTheDaemonItStarted|TestEveryDeclaredRouteAnswersOverTheSocket)$`) and let CI run the rest.\n5. **Reproducing a CI failure:** re-run only the failing test(s), by exact name, with the same run seed and shuffle order the CI shard printed (seed design and env var name: #93; shard layout: #95). If it does not reproduce once, it is treated as a possible flake and handled by #130 (`-count=N`, `-race`), not by re-running the whole suite.\n6. ~~**Stopgap until #52 lands (unverified):** `newEnv` passes `os.Environ()` through, and the setting's derived env name is `MCPX_AUTOSTART_IDLE_EXIT` (`internal/settings/schema.go:225-230`), so exporting e.g. `MCPX_AUTOSTART_IDLE_EXIT=2m` before a T2 run should bound any leak to two minutes. Check that no e2e test asserts the default first.~~ **Done in #182:** `newEnv` sets `MCPX_AUTOSTART_IDLE_EXIT=60s` itself (`internal/e2e/e2e_test.go:68,92`), so there is nothing to export.\n7. **The integrator's pre-merge run is the exception, and it is deliberate.** Whoever merges a PR runs the full suite locally more than once (current practice: 2-3 times, see Current state). Until #130 moves repeat runs and `-race` into CI, that is the only place mcpx looks for order- and timing-dependent flakes. Once #130's per-PR repeat job and nightly stress job exist, this step can drop to a single run or leave the local routine entirely.\n\n## Approaches: how an agent finds the tests touching a change\n\n### A -- judgment and grep (least recommended)\nThe agent reads its diff, greps `internal/e2e` for the feature's name, and picks tests. Costs nothing to set up. Risks: every agent picks differently; tests named for a behaviour rather than the flag or op (most of `e2e_test.go`) are missed; and an uncertain agent falls back to \"run everything\", which is the behaviour this issue exists to stop. Acceptable only as the documented fallback when C selects nothing.\n\n### B -- a maintained map from package/feature to tests\nSplit `e2e_test.go` by feature and keep a map (`testdata/test-map.yaml` or comments) from `internal/\u003cpkg>` and feature names to e2e files or regexes. Deterministic and readable. Costs: the map drifts as soon as a test is added under the wrong key, splitting `e2e_test.go` is a large mechanical diff, and the feature inventory is owned by #97 -- a second map here would compete with it. Worth doing only if #97's inventory becomes that map (then C can read it).\n\n### C -- a selection script with a just recipe (recommended)\n`scripts/affected-tests.sh` (or `go run ./internal/testsupport/affected`, to avoid bash portability questions) plus a recipe such as `just mcpx-test-affected [base]`:\n1. `git diff --name-only \u003cbase>...HEAD -- pkgs/mcpx` (default base: `origin/main`).\n2. Each edited `.go` file -> its package -> T1. If exported identifiers changed, add importers (T1b).\n3. For e2e: pull the *names* the diff touches -- setting paths in `internal/settings/wire.go`, op names in `internal/api/ops*.go`, flag names in `internal/cli`, CLI command names, fake-server tool names -- and select e2e test functions whose bodies mention them; add the guard tests for any registry file touched (T3).\n4. Print the commands and an estimate from per-test durations (from CI's `go test -json` artifact, #95). Dry-run by default; `--run` executes them with `-count=1`.\n5. If nothing is selected, say \"no e2e selected; CI runs the full suite\" -- never fall back to all.\n\nRecommended because it gives every agent the same answer for zero context cost, it is checkable (CI can later compare its selection with the tests that actually failed, i.e. measure the miss rate), and a miss costs one CI round-trip rather than a bug, since CI still runs everything. The same selector can later feed a PR fast lane in #95 if that tree wants one.\n\n## Open questions\n\n- Confirm the stale-cache hypothesis once, in a scratch worktree (safe to run now that #182 fixed #52): edit a non-imported package, run `go test ./internal/e2e -run '^TestX$'` twice without `-count=1`, look for `(cached)`.\n- Where the recipe lives: repo-root `justfile` (the nix repo's) vs a new `pkgs/mcpx/justfile` vs only `scripts/`. A root recipe is discoverable; a package-local one keeps mcpx self-contained.\n- The T2 budget: a count (~15 tests) or a time (~30 s)? Time is what matters; count is what an agent can see before running.\n- The env var the run seed arrives in, and how a shard prints it (#93, #95).\n- Should T0 include the linters #95 adopts (e.g. `golangci-lint run ./internal/\u003cpkg>/...`)? Probably yes once they exist.\n\n## Ease · Impact · Related\n\n**Ease** S for the policy text; M with the selection script (C) · **Impact** high\n**Depends on / related**: #52 (closed, fixed in #182; \"never locally\" now rests on cost alone), #93 (run seed, reproduction), #95 (full suite, shards, `go test -json` timings), #97 (feature inventory, if B's map is ever built), #65 (read the check before merging), #91; siblings #131 (states this policy), #129 (T3 list), #130 (non-reproducible failures; moves the integrator's repeat runs into CI).\n\nSecurity/auth deferred; see tracker.\n\n## Acceptance criteria\n\n- The test-tier rule is decided and recorded: an agent runs the smallest set covering its change (edited packages' unit tests, a named handful of e2e tests, guard tests for any registry it touched) and never the full suite locally as a habit; the full suite is CI's job.\n- How an agent finds the tests that touch a change is defined (mechanism or documented procedure).\n- How a CI failure is reproduced locally is defined.\n- The decisions are handed to the contributor page (#1976) in a form it can carry verbatim.\n- The work described in the Summary/Scope above is delivered via a branch + PR (no direct push to main); verification runs in GitHub Actions CI, not on the sandbox.\n- Evidence (the recorded rule) is recorded on this issue before it is closed.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-28T22:48:36Z","url":"https://github.com/developing-today/code/issues/1966"}
| 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:d109fc77-f3e4-5550-ae36-1bad31abbec3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EA20:161654:48EB4E:5F6073:6B061E9B |
| html-safe-nonce | 50c535ed06a3b1d92e4fa11ee223d0e02aa11a040689d42c677ca828ff38fddd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQTIwOjE2MTY1NDo0OEVCNEU6NUY2MDczOjZCMDYxRTlCIiwidmlzaXRvcl9pZCI6IjMxODQxNDUwMzI1NTkzMzcxMTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 610a3cdb4a39f2185f57da14c334c52df958502ee5ad4497d0425713fe59ce28 |
| hovercard-subject-tag | issue:6088929762 |
| 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/1966/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6700d5b86cbc6162e4b94fe07fc188ff498ca64f0a1a29a1ee0d73fd023d1f51/developing-today/code/issues/1966 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6700d5b86cbc6162e4b94fe07fc188ff498ca64f0a1a29a1ee0d73fd023d1f51/developing-today/code/issues/1966 |
| og:image:alt | Relocated from dezren39/darwin-nix#127 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