Title: mcpx: the nix derivation's generated man page, completions and version are unverified, and one of them is not reproducible · Issue #1895 · developing-today/code · GitHub
Open Graph Title: mcpx: the nix derivation's generated man page, completions and version are unverified, and one of them is not reproducible · Issue #1895 · developing-today/code
X Title: mcpx: the nix derivation's generated man page, completions and version are unverified, and one of them is not reproducible · Issue #1895 · developing-today/code
Description: Relocated from dezren39/darwin-nix#178 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#178 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#178 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/1895
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx: the nix derivation's generated man page, completions and version are unverified, and one of them is not reproducible","articleBody":"Relocated from dezren39/nix#178 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: #177\n\n## Summary\n\n`pkgs/mcpx/package.nix` `postInstall` produces three artefacts from the binary it just built — a man page, three shell completion scripts, and a version string injected by `ldflags`. **Nothing asserts any of them, one of them is not reproducible, and the version exists in three places that no test keeps in agreement.** These are release prerequisites: #158 designs tags, release artefacts and install channels on top of a derivation whose generated half is currently unchecked, and a release that ships a man page dated by whichever day the builder ran is a release that cannot be rebuilt bit-for-bit.\n\nThis issue owns the three defects in `postInstall` and the version fan-out. It does **not** own the platform matrix (#136), the CI workflow shape and caching design (#135), the container image (#134), or the release pipeline (#158). (It previously named #161 and #168; both were closed as duplicates — the survivors are #134 and #135.)\n\n## What was verified\n\nAll checks at `8001f23`, which is one commit ahead of the `d0b7e01` the earlier issues were written against; nothing in this area changed between them. **Every row was re-checked at `05c78b2` in the 2026-09-30 issues pass and every one still holds**: `internal/cli/manual.go:335` still stamps `time.Now()`; `package.nix:19` and `:61` and `cmd/mcpx/main.go:18` still carry three separate `0.1.0` literals; `internal/testsupport/build.go:63` still builds without ldflags; and `rg` over every `*_test.go` still finds no reference to `ManPage`, `CmdMan` or `CmdCompletion`. #171 and #182 changed nothing here.\n\n| Claim | How verified | Result |\n| --- | --- | --- |\n| The man page stamps a build date | `internal/cli/manual.go:335` — `date := time.Now().UTC().Format(\"2006-01-02\")`, written into `.TH MCPX 1 %q ...` at `:337` | **VERIFIED** |\n| `postInstall` runs the generator at build time | `package.nix` `postInstall`: `$out/bin/mcpx man > $out/share/man/man1/mcpx.1` | **VERIFIED** |\n| Nothing asserts the man page or the completions | `rg -n 'ManPage\\|CmdMan\\|CmdCompletion\\|--version\\|a\\.Version' --glob '*_test.go'` in `pkgs/mcpx` → **zero matches** | **VERIFIED** |\n| The version is hard-coded in three places | `package.nix:19` `version = \"0.1.0\"`; `package.nix:61` `\"-X main.version=0.1.0\"`; `cmd/mcpx/main.go:18` `var version = \"0.1.0\"` (its own comment at `:17` says it \"is overridden at build time with -ldflags\"). `rg '0\\.1\\.0'` finds two further echoes that are not build inputs: `plugin/opencode/skills/mcpx-daemon/SKILL.md:35` (documentation example) and `plugin/opencode/mcpx/daemon.test.ts:132` (test fixture) | **VERIFIED — exactly three build-relevant sites, plus two documentation/test echoes** |\n| The test binary is built without those ldflags | `internal/testsupport/build.go:63` — `exec.Command(\"go\", \"build\", \"-o\", mcpxBin, \"./cmd/mcpx\")`, no `-ldflags` | **VERIFIED** |\n| No `CGO_ENABLED` is set | `rg -n 'CGO\\|env =' package.nix` → no matches; `buildGoModule` therefore inherits the nixpkgs default | **VERIFIED** (the static-linking consequences are #136's; **and the premise there was wrong — `CGO_ENABLED=0` yields a fully static linux binary, verified in #182, so #136 is a policy decision. This issue only records that `package.nix` sets no `CGO_ENABLED`.**) |\n\n## Current state (with file refs)\n\n### 1. The man page is not reproducible\n\n```go\n// internal/cli/manual.go:333-337\nfunc ManPage(version string) string {\n\tvar b strings.Builder\n\tdate := time.Now().UTC().Format(\"2006-01-02\")\n\n\tfmt.Fprintf(&b, \".TH MCPX 1 %q %q \\\"mcpx manual\\\"\\n\", date, \"mcpx \"+version)\n```\n\n`package.nix` runs `mcpx man` inside `postInstall`, so `$out/share/man/man1/mcpx.1` embeds the UTC date of the build. Everything else in the derivation is deterministic: Go builds reproducibly, `ldflags = [ \"-s\" \"-w\" ... ]` strips, and the vendor tree is a fixed-output derivation. `time.Now()` is the only wall-clock input.\n\nConsequences, in increasing order of how much they will matter later:\n\n- `nix build .#mcpx --rebuild` diffs across a UTC midnight boundary. Nothing runs that today, so nobody has seen it.\n- A content-addressed or signed release artefact (#158) is not byte-stable, so \"the tarball I built matches the tarball CI published\" cannot be asserted.\n- `man mcpx` shows the build date where a reader expects the documentation date, which is the wrong fact: a binary substituted from a cache shows the cache's build day.\n\nThe convention for exactly this is `SOURCE_DATE_EPOCH`, which nixpkgs already exports in every build (it is set to `1` in the stdenv unless overridden) and which every reproducible-build toolchain honours.\n\n### 2. Neither generated artefact is asserted\n\n```nix\n# package.nix postInstall\n$out/bin/mcpx man > $out/share/man/man1/mcpx.1\n\ninstallShellCompletion --cmd mcpx \\\n --bash \u003c($out/bin/mcpx completion bash) \\\n --zsh \u003c($out/bin/mcpx completion zsh) \\\n --fish \u003c($out/bin/mcpx completion fish)\n```\n\n`mcpx man` and `mcpx completion \u003cshell>` are **executed** at build time and their output is **never inspected**, by the build or by any test. The build fails only if the process exits non-zero. A `ManPage` that returned the empty string, or a `completion zsh` that emitted a syntactically invalid `#compdef` block, would produce a green `nix build` and a broken installed package. `rg` over every `_test.go` in the tree returns no reference to `ManPage`, `CmdMan` or `CmdCompletion`.\n\nThis is worse than it looks because both generators read `Commands()`, which is itself incomplete — seven dispatched commands are missing from it (#159 item 1; re-measured in the sibling review issue). So the man page and the completions are known to be wrong, and there is no mechanism by which anyone would find out.\n\n### 3. The version has three sources and no arbiter\n\n| Site | Value | Who reads it |\n| --- | --- | --- |\n| `package.nix:19` | `version = \"0.1.0\"` | the derivation name, `nix` metadata, any release artefact named from it |\n| `package.nix:61` | `\"-X main.version=0.1.0\"` | the installed binary's `--version`, `/v1/health`, the OpenAPI `info.version`, the man page's `.TH` title |\n| `cmd/mcpx/main.go:18` | `var version = \"0.1.0\"` | any binary built without ldflags — including **every end-to-end test**, via `internal/testsupport/build.go:63` |\n\nThey agree today only because nobody has changed one. The first bump breaks the property silently in two directions: the derivation name and the binary's self-report can diverge, and the e2e suite keeps exercising a binary that reports the pre-bump version while the packaged one reports the new one. `internal/api/openapi.go` and `internal/cli/openapi.go` both take `version` as a parameter, so a wrong value propagates into the published specification too.\n\n## Approaches\n\n### 1. Reproducible man page — no real choice\n\nHonour `SOURCE_DATE_EPOCH`: parse it when set, fall back to `time.Now()` when it is not, so an interactive `mcpx man` still shows today. Five lines in `internal/cli/manual.go`. The only sub-decision is what to show when the variable is absent from a *release* build, and the answer is that a release build always has it.\n\n### 2. Asserting the generated artefacts\n\n- **A — least recommended: assert in `postInstall`.** Add `grep -q` checks to the nix expression (`grep -q '^\\.TH MCPX' mcpx.1`, non-empty completions). It works, and it puts test logic in the one place that only runs under `nix build`, is invisible to `go test`, cannot be run locally without a full derivation rebuild, and is written in bash inside a Nix string. Every future assertion accretes there.\n- **B — middle: a Go golden test.** `internal/cli/manual_test.go` compares `ManPage(\"test\")` against a checked-in golden file. Catches regressions in content, and catches *nothing* about the completions actually being valid shell, because a golden file of a zsh script only proves it did not change.\n- **C — recommended: a Go presence test plus a shell-parser smoke test, and keep `nix build` dumb.** In Go: every entry in `Commands()` appears in `ManPage`, every entry appears in each of the three completion scripts, and the `.TH` line carries the version it was given. In CI (this belongs to #135's job graph, not to `postInstall`): pipe each completion script through `bash -n`, `zsh -n` and `fish --no-execute`, which is the only check that distinguishes \"non-empty\" from \"valid\". Once #159's `Commands()` gap is closed, the same presence test is what stops it reopening. Recommended because it moves the assertion to where it can be run in a second by anyone, and because the shell-parse check is the one that finds the failure mode that actually ships.\n\n### 3. Single-sourcing the version\n\n- **A — least recommended: a `//go:generate` step or a `version.txt` read by both.** A file both Nix and Go read is genuinely single-sourced, but it adds a build input that has to be kept in the `cleanSourceWith` filter, and it does not solve the test-binary problem: `go build` without ldflags still falls back.\n- **B — middle: drop the fallback and make an un-stamped binary say so.** `var version = \"dev\"` in `cmd/mcpx/main.go` (which is already the convention used at `internal/pool/pool.go:39`, `var Version = \"dev\"`). Then a binary built without ldflags reports `dev` and can never be confused with a release. Cheap, honest, and leaves `package.nix`'s two copies still hand-synchronised.\n- **C — recommended: B, plus derive the ldflag from the `version` attribute, plus a test.** `ldflags = [ \"-s\" \"-w\" \"-X main.version=${version}\" ]` removes one of the two Nix copies outright (`finalAttrs.version` or a `let`-bound name). `var version = \"dev\"` removes the third. That leaves exactly one literal, which #158 then replaces with the git tag. Add one e2e assertion that `mcpx --version` matches the derivation's version when run from `result/bin/mcpx` — which is the \"handful of assertions against `result/bin/mcpx`\" that **#134** identifies as the cheapest win in its area (formerly #161, closed as a duplicate), so the two should land together.\n\n## Open questions\n\n- Should `postInstall` keep generating the man page from the binary at all, or should the release pipeline (#158) generate and commit it so that the tarball, the nix package and the distro packages all ship the same bytes? Generating from the binary is the right call for correctness and the wrong call for a distro packager who does not want to execute a freshly built cross-compiled binary. This is a real fork and #158 should decide it, not this issue.\n- Does `SOURCE_DATE_EPOCH` belong in `ManPage`'s signature (explicit, testable) or read from the environment inside it (fewer call sites to change)? Prefer the parameter, but it touches `CmdMan`.\n- Is `lib.platforms.unix` plus an unasserted man page enough for a distro package's lintian/rpmlint pass, or does that need a `.TH` date in a specific format? Unknown; matters only once #158 picks a distro channel.\n\n## Ease · Impact · Related\n\n**Ease: S** (the man-page date and the version fan-out are a handful of lines each; the presence test is the bulk, and it is one file) · **Impact: med** (nothing is broken for a user today; everything here is a prerequisite that gets more expensive the longer #158 waits on it)\n\nRelated: **#158** — this is largely a prerequisite for it: a release pipeline needs a reproducible derivation, one version source and generated artefacts it can trust. **#134** owns the container image and the \"run assertions against `result/bin/mcpx`\" step that item 3C plugs into (formerly #161, closed as a duplicate). #182 added a `Containerfile`; nothing in CI builds or tests it yet, so that step is still owed. **#159** item 5 records the man-page date as a documentation problem; this issue adds the nix-reproducibility consequence and the fix shape. **#159** item 16 and **#158** both record the three version sites; this issue adds the test-binary divergence via `internal/testsupport/build.go:63`. **#136** owns the platform matrix and the static-binary question, which is why `CGO_ENABLED` is only recorded here and not decided. **#135** owns the CI job graph the shell-parse check belongs in, and the rest of the caching design (its `cache-dependency-path` line landed in #182). **#144**/**#145** own generating a reference from `Commands()`, which shares the presence test. **#49** — the same \"built but never exercised\" gap for every other flake package.\n\nSecurity/auth deferred; see tracker.\n\n\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-28T22:19:30Z","url":"https://github.com/developing-today/code/issues/1895"}
| 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:98ea3a14-5990-2ce7-f7fa-76dd0d699581 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C3B4:6AD3D:300483:3F1223:6B0616A6 |
| html-safe-nonce | bb4754ff667a459908b33e496d722845f976283adb7fd4f89723d8a6a1a73b8b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDM0I0OjZBRDNEOjMwMDQ4MzozRjEyMjM6NkIwNjE2QTYiLCJ2aXNpdG9yX2lkIjoiMzM2NTY2NTQwMDA1MzcwMDI2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 36bf0e281bbd968b87dc72fa27d0536e1bfe11ad717a00aa23435aa974478306 |
| hovercard-subject-tag | issue:6088542716 |
| 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/1895/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a93a7c5d7de298aa3e62b19a60270b7127399332af8ab3a861fd8ff151b4f593/developing-today/code/issues/1895 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a93a7c5d7de298aa3e62b19a60270b7127399332af8ab3a861fd8ff151b4f593/developing-today/code/issues/1895 |
| og:image:alt | Relocated from dezren39/darwin-nix#178 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