Title: mcpx testing: guard tests that close a whole bug class · Issue #1971 · developing-today/code · GitHub
Open Graph Title: mcpx testing: guard tests that close a whole bug class · Issue #1971 · developing-today/code
X Title: mcpx testing: guard tests that close a whole bug class · Issue #1971 · developing-today/code
Description: Relocated from dezren39/darwin-nix#129 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#129 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#129 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/1971
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx testing: guard tests that close a whole bug class","articleBody":"Relocated from dezren39/nix#129 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\nWhen a bug is one instance of a **class** -- a declaration and its use live apart, and the same shape has shipped before -- the fix adds a **guard test** that fails for *every* member of the class, present and future, not just the instance found. mcpx already has more of these than the strategy doc lists; this issue inventories them, finds where the existing ones leak, picks how guards are written, and lists the guards worth adding next. It also sets the rule for when a bug \"is a class\". It **owns #181 collision 15**: a setting must be able to *change behaviour*, not merely be read. That guard is due before or with #172.\n\n## Original notes\n\n> - testing\n> - agents should make at least 1 simple, new test for every bug observed from any source, when cheap to do so-- aggresively test many permutations. \n\n(Guards are the per-class extension of \"at least 1 simple, new test for every bug\": the per-instance policy is #128.)\n\n## Current state: guards that exist at 05c78b2\n\nThere are about twenty-five, not three. The ones that matter here, by mechanism:\n\n| Guard | Class it closes | Mechanism | Tier |\n| --- | --- | --- | --- |\n| `TestEveryExecFlagChangesSomething` (`internal/e2e/e2e_test.go:2877`, from #74/#75) | a flag accepted and ignored | **hand table** + runtime probe (with vs without) | e2e |\n| `TestEveryDeclaredRouteAnswersOverTheSocket` (`internal/e2e/v1ops_test.go:287`) | a declared `/v1` op that 404s | registry enumeration (`api.Ops()`) + runtime probe | e2e |\n| `TestEveryDaemonRouteIsDeclared`, `TestEveryDeclaredOpHasARoute`, `TestEveryNonStreamingOpIsReachableAsAnMCPTool` (`internal/api/parity_test.go:54,73,87`) | route/op/MCP-tool drift | source scan of `internal/daemon/*.go` + registry enumeration | unit |\n| `TestNoPackageRedeclaresADefault` (`internal/defaults/guard_test.go:92`) | a constant outside `defaults.json` | **regex source scan** with a reasoned allowlist and an `outOfScope` list | unit |\n| `TestEverySettingIsReachableFromAllThreeSurfaces`, `TestEveryDefaultSurvivesItsOwnValidator`, `TestEverySettingSaysWhoReadsIt` (`internal/settings/registry_test.go:27,41,287`) | settings registry consistency | registry enumeration | unit |\n| `TestEverySettingIsReadSomewhere`, `TestNoHandRolledSettingEnv`, `TestThePluginReadsNoUndeclaredSetting` (`internal/settings/consumed_test.go:73,145,209`, from #171) | a setting declared and never read; a registry-owned variable read by hand; the plugin honouring an undeclared variable | registry enumeration + **regex source scan** for a `Set` accessor call outside the settings package (`accessorRead`/`readViaHelper`, `:54,60`), one-entry allowlist with a reason (`paths.config`, `:66`) | unit |\n| `TestTheDocumentationListsEverySetting` (`internal/settings/docs_test.go:19`) | docs drift | registry vs `docs/configuration.md` | unit |\n| `TestEverySettingIsReachableOverV1` (`internal/e2e/settings_test.go:173`), `TestEverySettingTheSchemaAdvertisesActuallyWorks` (`e2e_test.go:1879`) | registry vs served surfaces | runtime probe | e2e |\n| Nine effect tests in `internal/e2e/unread_test.go:48-184` (from #171), e.g. `TestPoolDefaultsAreReachableFromTheEnvironment`, `TestScriptEnvIsReachableFromTheEnvironment` | a wired setting that changes nothing | **hand-picked** runtime probes: set the value as a user would, assert an observable change | e2e |\n| `TestNoOrphanProcessesAfterStop` (`e2e_test.go:534`) | MCP children surviving `stop` | runtime probe | e2e |\n| `TestEnvCleanupStopsTheDaemonItStarted` (`e2e_test.go:2630`, from #182) | a test env's daemon surviving its cleanup (#52) | runtime probe; falsified by reverting the fix | e2e |\n| `TestEveryTuiViewProducesRowsFromRealData`, `TestEveryConsoleMethodIsCoveredAndNameIsKept`, `TestEveryModernRequestCarriesVersionAndCapabilities`, ... | various | mixed | mixed |\n\nThe \"declared but never read\" audit landed as #171. Its inverse (\"read but never declared\", 44 `MCPX_*` variables) is #172 and is in flight. `TestEverySettingSaysWhoReadsIt` checks only that a setting *declares* a scope; `TestEverySettingIsReadSomewhere` checks that something reads it. **Nothing checks that reading it can change anything** (leak 5 below).\n\n### Where the existing guards leak\n\n1. **`TestEveryExecFlagChangesSomething` does not enumerate the flags.** It has four rows (`--export`, `--launcher`, `--prefix`, `--typecheck`) and a comment \"Add a row when you add a flag\". The exec/run flag set has 23 flags (`internal/cli/commands.go:435-481`), including three that #75 fixed (`--no-launcher`, `--allow-repeat`, `--no-capture-console`) with no row. A new flag with no row passes. The class is not closed; it relies on memory, the thing the guard exists to replace. Its *probe* half is the model to copy: each row asserts the outcome with the flag and its absence without, and that half caught #75's own first `--typecheck` assertion, which matched output present either way.\n2. **Regex source scanning misses spellings.** PR #56: `TestNoPackageRedeclaresADefault` matched `\"5 * time.Minute\"` while gofmt writes `5*time.Minute` in call arguments, so nine live constants were invisible to it. A guard that silently passes is worse than none; it was found by accident.\n3. **Allowlists are one-way doors.** `outOfScope` in `guard_test.go` still exempts seven whole packages and one file (`guard_test.go:86-90`) \"owned by work happening in parallel\"; nothing makes it shrink.\n4. **Nothing fails when a test reaches the network** (#65 fixed the one instance via `MCPX_REGISTRY_URL`, `e2e_test.go:57`). #52 is fixed (#182): cleanup is `stop --all` with the error logged, not discarded (`e2e_test.go:71-85`), and `TestEnvCleanupStopsTheDaemonItStarted` checks one env's daemon dies. Still unguarded: a daemon started outside `newEnv`, and `testsupport`'s `mcpx-bin-*`/`mcpx-fake-*` dirs, which are never removed (`internal/testsupport/build.go:27,57`).\n5. **`consumed_test.go` proves a setting is read, not that reading it matters.** `registry.pageSize` is read (`internal/cli/registry.go:265`, `internal/daemon/ops.go:285`) but consulted only inside `if limit \u003c= 0` (`internal/registry/registry.go:154-155`). Every ordinary caller passes a positive limit: `--limit` defaults to 20 (`internal/cli/registry.go:26`), and the daemon falls back to `registry.limit` (`internal/daemon/ops.go:275-276`). So it passed #171's sweep while inert (#179). The scan sees a read; it cannot see that the read is unreachable. `unread_test.go` has the right shape, a with/without probe, but covers nine hand-picked settings out of 149. This is #181 collision 15, owned here (next section).\n6. **A guard's name can overclaim.** `TestEverySettingIsReachableFromAllThreeSurfaces` (`internal/settings/registry_test.go:27-39`) checks that a flag name exists, that the variable is `MCPX_`-prefixed and that the setting is documented. That is name shape, not reachability. The e2e `TestEverySettingIsReachableOverV1` is the one that probes.\n7. **An allowlist entry's reason is prose nothing checks, and one is false.** `consumed_test.go:67-70` exempts `paths.config` as \"read by config.SearchPath from `MCPX_PATHS_CONFIG` directly\" (repeated in `docs/declared-but-unread.md:93-96`). Nothing reads `MCPX_PATHS_CONFIG`; the search path reads `MCPX_CONFIG` (`internal/config/config.go:549`). The exemption hid a setting that is dead on all three channels (#5). An allowlist reason that names a mechanism should be a mechanism a test can check (the variable is read somewhere, the function exists), or say \"declared, not read\" plainly.\n\n## Owns #181 collision 15: a setting must be able to change behaviour\n\n**Owns #181 collision 15:** the stronger settings guard. Every registry setting must be able to change an observable outcome through an ordinary caller, not merely be read. #179 (`registry.pageSize`) is the instance; this issue owns the class.\n\n- **Model:** #75's exec flag table (`e2e_test.go:2877`) asserts, per row, the outcome with the flag and its absence without. #171's `unread_test.go` already does the same for nine settings by hand (set the value the way a user would, as an env var or config key and not a Go field, then assert a change).\n- **Shape (Approach C below, applied to `settings.Registry()`):** a unit-speed completeness test fails when a setting has neither an effect probe nor an exemption with a reason. Exemptions ratchet down (e.g. plugin-scoped settings the Go side cannot observe, and `paths.config`, #5). The e2e probes set a non-default value through an ordinary caller and assert a with/without difference. A negative test plants an inert setting, read only behind an unreachable branch as `registry.pageSize` is, and expects the guard to fail.\n- **Timing:** apply it **before or with #172** (in flight), which will move up to 44 more `MCPX_*` variables into the registry (its recommended option declares the inbound ones and allowlists the outbound). Each should arrive with a probe row or a reasoned exemption, not be audited afterwards. Of the whole tree, this is the one part of #99 that is time-sensitive.\n- **Scale:** 149 settings at 05c78b2 (unique `Path:` entries in `internal/settings/*.go`), with more to come from #172. A probe per setting in e2e is too slow for every PR. Keep the completeness half at unit speed (T3 in #127). Group probes by surface, so that one daemon checks many settings. #124's `settings.precedence` generator can supply the non-default values.\n\n## When a bug \"is a class\"\n\nAdd a guard (in the fix PR, or file `testing` + `implement` and link it) when any of these holds:\n- the same shape has shipped before (#74 was the third \"accepted and ignored\");\n- the bug is drift between a declaration and its use (registry vs reader, op table vs route, flag vs options struct, docs vs code);\n- the fix edits a table, registry or allowlist;\n- the bug depended on the environment the test ran in (network, OS, leftover processes).\n\n## Approaches: how guards are written\n\n### A -- source scanning with regexes (least recommended)\nWalk `.go` files and match text, as `TestNoPackageRedeclaresADefault`, `daemonRoutes` and #171's `consumed_test.go` do. Quick to write and needs no registry. Risks: formatting changes the text (the gofmt miss above), comments and strings produce false hits, renames produce false passes, a match proves a call exists but not that it is reachable (leak 5), and failures read as \"line 212 matched a pattern\" rather than \"setting X is never read\". Keep only where nothing better exists, and if so parse with `go/parser`/`go/ast` (or `golang.org/x/tools/go/packages` for type info) rather than regexes.\n\n### B -- enumerate the registry (reflection over data)\nIterate `settings.Registry()`, `api.Ops()`, `flag.FlagSet.VisitAll`, the command table, and assert properties per entry. Unit-speed, exact, cannot be fooled by spelling -- most of the table above is this. Limitation: it proves declarations are *consistent*, not that they *work*; a registry entry nothing reads passes every B guard, and so does one that is read but cannot matter (`registry.pageSize`).\n\n### C -- enumerate, require a probe per entry, prove the guard can fail (recommended)\n1. **Enumerate** the registry (B) as the source of truth.\n2. **Completeness:** a unit test fails when an entry has neither a probe row nor an exemption *with a reason* (the `allowed` map style in `guard_test.go`). Fixes leak 1: a new flag without a row fails in milliseconds, locally, at T1/T3 of #127.\n3. **Probe:** each row proves an observable effect in both directions (the #75 with/without pattern); probes that need the binary live in e2e and run in CI.\n4. **Ratchet:** exemption lists may only shrink -- a test pins their length, or CI compares it to `main`.\n5. **Negative test:** every guard's checker is a function with its own test that feeds it a planted violation and expects a failure (fixes leak 2's lesson: a guard that cannot fail is not tested).\n6. Use AST scanning (not regex) only for classes with no registry. (#171's \"declared but never read\" guard used a regex scan, which is enough to find a read but, as leak 5 shows, not to prove it matters; step 3's probe is what closes that.)\n\nRecommended because it closes the gap the current exec guard has (enumeration), keeps the cheap half (completeness) in unit time so agents actually run it, and makes the guards themselves falsifiable.\n\n## Candidate new guards\n\n| Guard | Class | Mechanism (per C) | Owner / coordination |\n| --- | --- | --- | --- |\n| **Every setting can change an observable outcome** | read but inert (#179, `registry.pageSize`) | `settings.Registry()` vs a probe table; completeness at unit speed; with/without probes in e2e; ratcheted exemptions; planted-inert negative test | **here -- #181 collision 15; first implement task, before or with #172** |\n| Every exec/run flag has a row or an exemption | accepted and ignored (#74) | `VisitAll` over the exec flag set vs the table | here |\n| Every command's flags, not just exec | same, other commands | command table enumeration; rows per command | here |\n| ~~Every setting in the registry is read by something~~ | declared, never read | **done in #171** (`consumed_test.go`, regex scan for a `Set` accessor read) | superseded by the row above for \"read but inert\" |\n| No two concurrent runs share a generated path | #69, #70, #73 (three instances in three PRs) | property over the runner's naming function (a content hash of every input that changes the program), plus a concurrent e2e probe per artifact kind | here; candidate |\n| Every flag mcpx passes to a runtime has the effect it is passed for | an inert subprocess flag (#108) | An acceptance check (\"the runtime exits 0 with this argv\") would **not** have caught #108: Node 24 accepts `--experimental-strip-types` and it is simply inert. Use a **pinned capability matrix** instead: real argv against a fixture per TypeScript construct per runtime, failing when the matrix *changes*, so an inert flag shows up as the Node column losing its `enum` rows. Keep the cheap exit-0 check as a first half, since it still catches a typo or an upgrade that drops a flag. Deno's permission flags (`--allow-*`, `--no-check`) are the same exposure: no test file mentions them | here; #108 (in flight) owns the fix, #100 the runtime matrix |\n| Every documented capability exists | a documented capability that does not exist (#102, #106) | Split the ask. Mechanical where a registry is behind it: #102's tool list vs the generated client, #106's CLI vs `/v1/exec` resolution; those should not wait. Prose gets a marker table, which is probably #132's feature inventory with one more column (build it once). Prose-linting is rejected outright: there is no honest mechanism for it | here + #132 (#97) |\n| Every CLI flag has non-empty usage and appears in `mcpx --help`/`mcpx man` | undocumented knob | enumerate flag sets vs generated man (`package.nix:88-89` builds it from the binary) | docs tree for the book; here for the test |\n| Every `/v1` op has a CLI command, or a listed exemption | CLI parity (#76) | `api.Ops()` vs command table; exemption list starts as #76's table and ratchets down | #76 |\n| Every feature has an integration test | untested feature | reads #97's inventory file, checks each named test exists (`go test -list`) | **#97 owns the inventory**; this issue owns only the rule that a guard reads it |\n| No test reaches the network | #65 | see sub-choice below | here + #95 |\n| No test leaves a process (or temp dir) behind | #52 (fixed in #182 per env) | `TestMain` in `internal/e2e`: after `m.Run()`, find processes whose argv contains this run's temp prefix, kill them and fail; remove `mcpx-bin-*`/`mcpx-fake-*`. #182 already stopped discarding the `stop` error and added the per-env test | here (suite-wide backstop) |\n| Quarantined tests have an issue link and an unexpired date | permanent quarantine | scan for the quarantine helper | #130 |\n\n### Sub-choice: enforcing \"no network\"\n\n- **Env only (weakest):** set `HTTP_PROXY`/`HTTPS_PROXY` to a dead port (`http://127.0.0.1:9`) in `newEnv` and a unit `TestMain`. Catches Go HTTP clients that honour proxy env (including the spawned `mcpx` binary); misses raw dials and anything in `NO_PROXY`.\n- **In-process dialer guard:** replace `http.DefaultTransport`'s `DialContext` in `TestMain` to refuse non-loopback. Precise for unit tests; cannot reach the `mcpx` subprocess or the JS runtimes.\n- **No network in the CI test step (recommended, plus the env layer locally):** run tests in a network namespace (`unshare -rn` / `systemd-run --property=PrivateNetwork=yes` / a container with `--network none`) after `go mod download`. Catches everything, including deno/bun/node. Linux-only, so it lives in CI (#95); macOS keeps the env layer.\n\n## Tasks\n\n- [ ] Implement: **settings effect guard (#181 collision 15)** -- completeness over `settings.Registry()`, probes grouped by surface, a planted-inert negative test. Before or with #172.\n- [ ] Implement: enumerate the exec/run flag set in `TestEveryExecFlagChangesSomething` (completeness + exemptions), rows for the #75 flags.\n- [ ] Implement: negative tests for existing checker-style guards (`defaults`, `parity`, `consumed`).\n- [ ] Implement: no-network (env layer now; namespace via #95).\n- [ ] Implement: process/temp-dir sweep `TestMain` (#52 itself is fixed by #182; this is the suite-wide backstop and the temp-dir cleanup).\n- [ ] Decide which other candidates become issues.\n\n## Open questions\n\n- Should the completeness half of an e2e guard be a separate unit test (runs at T1), or stay inside the e2e test (runs only in CI)? Proposed: separate.\n- ~~Does the \"declared but never read\" audit produce a registry-level guard (B/C) or an AST scan (A with `go/ast`)?~~ Answered by #171: a regex scan (A's mechanism, `consumed_test.go:54,60`) over registry enumeration. The effect guard above is the C half it lacks.\n- Which settings cannot be probed from Go at all (plugin-scoped ones read only by TypeScript, `paths.config`)? Do they get a TypeScript-side probe in the plugin's `bun test`, which CI does not run yet (#141)?\n- Where do exemption lists live: in the test file (current style) or in a data file several guards share?\n\n## Ease · Impact · Related\n\n**Ease** M (policy S; each guard S-M) · **Impact** high\n**Depends on / related**: #74, #75, #76, #65, #52 (closed, fixed in #182), #56 (the defaults-guard miss), #69/#70/#73 (the shared-path class), #97 (integration inventory), #95 (no-network CI step), #93 (generators for probe inputs); #171 (merged: the read guard), #172 (in flight: its inverse; lands with or after the effect guard), #179 (in flight: the `registry.pageSize` instance), #181 (collision 15, owned here); siblings #127 (T3 guards list), #128, #130, #131.\n\nSecurity/auth deferred; see tracker.\n\n## Acceptance criteria\n\n- The existing guard tests are inventoried on this issue, with where each leaks (class members it cannot catch) named.\n- The rule for when a bug \"is a class\" is recorded, and the house style for writing guards is pinned.\n- The #181 collision-15 guard — a setting must be able to change behaviour, not merely be read — is landed, or scheduled before/with #172 as the body requires.\n- The guards worth adding next are listed, with follow-up issues filed for any not landed here.\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 (CI links or guard output as applicable) is recorded on this issue before it is closed.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-28T22:51:00Z","url":"https://github.com/developing-today/code/issues/1971"}
| 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:b0591c14-7c3f-b6d2-3153-f8d04e89b485 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CE88:335506:573933:74B542:6B0625E5 |
| html-safe-nonce | 878dee4814ee63d64ab26aed9e67e89451e97839b3694c4b4cafa470d2d7d277 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRTg4OjMzNTUwNjo1NzM5MzM6NzRCNTQyOjZCMDYyNUU1IiwidmlzaXRvcl9pZCI6IjY5MTAzMDU3Mjc2Njg0MzAzMDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 050cba5848d6fe28cc4e73d31feebead22060c318344f726395376a5f4dc10b7 |
| hovercard-subject-tag | issue:6088959417 |
| 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/1971/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a4e7f709a593b01ff65384961b86f4647efb2d2195cfc4cb9028812b13e9c499/developing-today/code/issues/1971 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a4e7f709a593b01ff65384961b86f4647efb2d2195cfc4cb9028812b13e9c499/developing-today/code/issues/1971 |
| og:image:alt | Relocated from dezren39/darwin-nix#129 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 | 9e10bb0ecc0bd0f8692aa89586ee9b54e498d7ab9f244a44cdb5b93653a125ce |
| 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 | 32e57d5cc2ce6ce92ec6dceb65858344750c27c2 |
| 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