Skip to content

fix(mcpx): restore e2e/settings/cli to nix checkPhase (#2686) - #8003

Closed
dezren39 wants to merge 3 commits into
mainfrom
queue/8663-2686-mcpx-sandbox-restore
Closed

dezren39 wants to merge 3 commits into
mainfrom
queue/8663-2686-mcpx-sandbox-restore

Conversation

@dezren39

@dezren39 dezren39 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Restores #2686 sandbox checks.

e2e/cli: Linux child-subreaper TestMain + Wait4 reaper; harness mcpx invocations in own process group with group-kill on deadline. Bounds/reaps daemon trees under non-init supervisor.

settings: declares MCPX_ADAPTER_DECLARATION_SHA256, MCPX_PATHS_CONFIG (+ exec/consumer setters for EPHEMERAL, TRANSPORT_BEARER_TOKEN); exempts 3 proto per-minute rate limits (pin 210->213); regenerates docs/environment.md + docs/configuration.md.

Removes internal/e2e, internal/settings, internal/cli from checkExclude (conformance/defaults/examples remain). goTestCmd line untouched.

Verified: go test ./internal/settings (pass), ./internal/buildcheck (pass, 62 pkgs 3 excluded), e2e smoke (daemon cleanup, ls/call/exec), cli ensuredaemon/stopall, darwin cross-compile for touched pkgs.

Task 8663. Risk: nix build verification must run on laptop or CI, never sandbox.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

e2e/cli spawned subprocess trees with no reaping init in the nix
sandbox, piling zombies to the 30m timeout. Install a Linux
child-subreaper TestMain (e2e + cli) with a Wait4 reaper, and run each
harness mcpx invocation in its own process group with group-kill on
deadline.

settings source-scan guards caught real drift: declare
MCPX_ADAPTER_DECLARATION_SHA256, MCPX_PATHS_CONFIG, and the
exec/consumer setters for EPHEMERAL and TRANSPORT_BEARER_TOKEN;
exempt the three proto per-minute rate limits (daemon handler
coverage, no e2e probe yet, pin 210->213); regenerate docs.

Remove internal/e2e, internal/settings, internal/cli from
checkExclude; conformance/defaults/examples remain excluded.
The goTestCmd line is untouched.
@dezren39
dezren39 requested a review from a team as a code owner November 9, 2026 07:28
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9caf80a0-84fb-45d4-b177-7e21249fa52b
Commits

Reviewing files that changed from the base of the PR and between 67596fc and d49b7cc.

Files selected for processing: 5

  • pkgs/mcpx/internal/cli/sandbox_reap_linux_test.go
  • pkgs/mcpx/internal/e2e/e2e_test.go
  • pkgs/mcpx/internal/e2e/sandbox_reap_linux_test.go
  • pkgs/mcpx/internal/e2e/sandbox_reap_other_test.go
  • pkgs/mcpx/package.nix
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-09T07:28:17.966194Z
We couldn’t complete this review. Comment @codex review to try again.
da61ada PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@dezren39

Copy link
Copy Markdown
Member Author

Agent note — task 17254 claimed by lane any-d (PR shepherd pass)

  • state: claimed / verifying (nix build verification on the laptop, per the PR's own requirement)
  • task: 17254 (pr_shepherd, 90-day review open-PR pass), lane assignment: direct
  • PR: fix(mcpx): restore e2e/settings/cli to nix checkPhase (#2686) #8003 — fresh-verified OPEN at packet head da61ada, no labels (no held / user/owned / do-not-merge / do-not-auto-edit); issue mcpx: e2e and settings suites cannot run in the nix build sandbox (checkPhase exclusions) #2686 OPEN
  • not superseded: current main's pkgs/mcpx/package.nix still excludes internal/e2e, internal/settings and internal/cli from checkPhase — the restoration has not landed
  • review gate: zero inline Codex findings (the review run failed on Codex usage limits; status "failed", no findings posted); CodeRabbit rate-limited
  • CI state: the head's rollup never ran the mcpx nixbuild/test legs (basic tier only, partly cancelled) — the sandbox claim is unverified by CI, so this lane is running the nix build on the laptop as the PR body prescribes

@dezren39

Copy link
Copy Markdown
Member Author

Agent note — task 17254 parked: PR #8003 FAILS its sandbox verification at internal/cli (lane any-d)

  • state: parked — do NOT merge this PR as-is; it would break the mcpx nix build on main
  • Verification run by this lane (the check the PR body itself prescribes — laptop, not sandbox): nix build .#packages.x86_64-linux.mcpx --print-build-logs in a clean worktree at the PR head da61ada, started 2026-11-14T21:19Z. Full log: /tmp/queue-17254-nixbuild.log on the laptop (build left running past this note for the remaining packages' verdicts).
  • Result: checkPhase reached internal/cli and the package FAILED —
    • panic: test timed out after 30m0s
    • FAIL github.com/developing-today/code/pkgs/mcpx/internal/cli 1801.140s
    • the running test at the timeout: TestEverySettingFlagReachesTheResolvedValue (29m33s) — its detached daemon children (cli.test daemon --detached --idle-exit 4h, spawned per flag case) were still alive in the sandbox at 13+ minutes and the test never completed. This is the same hang class mcpx: e2e and settings suites cannot run in the nix build sandbox (checkPhase exclusions) #2686 documents for internal/cli in the sandbox; the PR's subreaper TestMain does not cure it.
  • Packages verified ok before the failure: adapter, api, artifacts, buildcheck, cache, catalog. internal/e2e and internal/settings verdicts were still pending when this note was written (the sequential -p 1 run had not reached them; they are in the log above as the build proceeds) — so this verdict condemns the cli third of the PR, and leaves the e2e/settings thirds unverified rather than failed.
  • The author's own verification list did not include a nix build (go test + smoke runs outside the sandbox), so this appears to be the first full sandbox run of the change.
  • Resume condition: the cli sandbox hang is fixed (the flag-matrix test's detached daemons must be reaped/stopped inside the sandbox, or the test restructured for the sandbox), then a fresh laptop nix build .#packages.x86_64-linux.mcpx passes checkPhase end-to-end (including e2e + settings), then this PR can be shepherded to merge.
  • Task 17254 parked 1h and returns to the pool with this evidence attached.

repo-worker-tmp-code-b added 2 commits November 16, 2026 05:42
# Conflicts:
#	pkgs/mcpx/docs/environment.md
#	pkgs/mcpx/internal/e2e/feature_coverage_test.go
#	pkgs/mcpx/internal/settings/effect.go
#	pkgs/mcpx/internal/settings/scriptenv.go
@dezren39

Copy link
Copy Markdown
Member Author

Shepherd progress (task 17254, lane code-c, 2026-11-16): branch brought current with main and the merge resolved; the PR is not landable yet — one real defect remains, proven below. Parking the shepherd task with this state rather than landing a red checkPhase.

Merge work done (pushed to this branch): merged origin/main; conflicts resolved in 4 files. Findings from the merge:

  • The settings-side substance is already on main in reworded form: EffectExemptionPin is 214 on main (the PR's +3 for the proto.* rate limits landed there as mcpx: internal/settings (scriptenv) and internal/conformance (TestAuthSplit, TestMatrix) failing on clean main #2716, plus a later +1 for script.language mcpx: Python as a first-class script language, 1:1 with TypeScript #1917); MCPX_ADAPTER_DECLARATION_SHA256 and MCPX_PATHS_CONFIG entries and the SetBy widenings are on main too. Those files took main's side. (The auto-merge also silently duplicated the three proto.* exemption map entries; the duplicates were dropped, keeping main's wording that matches pin 214.)
  • feature_coverage_test.go: the PR's TestMain is superseded — main's guardedMain (e2e_test.go) already writes the coverage ledger. Its one unique duty, installSandboxReaper(), was folded into guardedMain.
  • package.nix merged cleanly and the checkPhase re-inclusion survived: the exclusion list now names only internal/conformance and internal/defaults.

The remaining defect — the sandbox reaper steals tracked children. With the branch as pushed, go test ./internal/cli/ fails deterministically (2 tests, e.g. TestRunScriptFailureReturnsStatusJSON: "Run(--json exec, script exits 3) = 1, want 3"); pristine main passes the same package in the same environment. The cause is the PR's own internal/cli/sandbox_reap_linux_test.go TestMain: its goroutine loops on unix.Wait4(-1, …), which reaps every child of the test binary — including script children whose exit status the CLI itself is waiting to collect — so the status is lost and the run reports a generic 1. A blanket Wait4(-1) cannot distinguish the daemon orphans it exists to reap (Setsid+Release children reparented to the subreaper) from children the test binary's own code tracks. The e2e copy of the reaper (now called from guardedMain) has the same hazard shape.

Also recorded: go test ./internal/settings/ fails on pristine main in this (non-hermetic) environment too — the package asserts the exact process environment, which is the documented reason it was checkPhase-excluded; its sandbox behaviour can only be judged by the nix build itself.

What landing needs, in order: (1) a reaper that cannot steal tracked children (or a demonstration, from a real nix-sandbox run, that the theft does not occur there — it occurs deterministically under plain go test here); (2) nix build of pkgs/mcpx with the re-inclusion as the true gate for all three packages; (3) the e2e suite run. The two failing CI checks currently on this PR (fleet-search parity, scripts-test) are in unrelated areas and predate this merge work.

@dezren39

Copy link
Copy Markdown
Member Author

agent-note:v1
state: handover — diagnostic evidence (lane code-d; my claim on task 17254 lapsed during a laptop-agent outage and the task was re-claimed and parked by another lane at 2026-11-16T11:51:17Z, so I am recording what I found and stopping)
lane: code-d
task: 17254
pr: #8003

Fresh evidence from this shift (2026-11-16), for whoever shepherds this next:

  1. The full internal/cli package passes on the laptop outside the sandbox: go test ./internal/cli/ -count=1 — 171 tests, all pass, 42.8s total (slowest: TestEverySettingFlagReachesTheResolvedValue 24.5s).
  2. In the nix sandbox the same package burns its whole 30m budget (prior attempt at this head, and reproduced this shift: a full nix build .#packages.x86_64-linux.mcpx reached internal/cli and was still running ~25m later when the build was lost to a laptop-agent daemon restart — no verdict from that run).
  3. Root-cause evidence for the sandbox burn: during a cli-only sandbox build (temporary uncommitted checkPhase edit, since reverted), the running cli.test had spawned ~700 detached daemon processes (all comm cli.test, session leaders, ~2% CPU each) that accumulated continuously over the run — the tests auto-start daemons by re-execing the test binary (client.go Setsid + Release), the daemons stay alive, and on a 2-CPU builder several hundred Go-runtime daemons starve the test binary itself. The PR's subreaper TestMain reaps dead children; these daemons are alive, so nothing reaps or stops them. The prior lane's note ("TestEverySettingFlagReachesTheResolvedValue detached daemons") points at the same flood: that test invokes every command handler, and daemon-touching handlers each autostart a detached daemon.
  4. Fix direction (not attempted — no longer my claim): keep the flag-reach probe from autostarting real daemons (e.g. daemon.autostart off in the probe's config/env, since the probe only verifies flag → resolved-value plumbing), and/or bound daemon lifetime in the cli test environment so detached daemons exit promptly instead of accumulating for the whole package run. Verify with a full laptop nix build .#packages.x86_64-linux.mcpx passing checkPhase including internal/cli, internal/e2e, internal/settings.

@dezren39

Copy link
Copy Markdown
Member Author

agent-note:v1
state: parked — shepherd state + fix design (lane code-d, task 17254, 2026-11-16)

This PR is not landable yet; exactly one proven defect remains, and the fix is designed below. This lane is parking the shepherd task because the laptop execution surface failed again this shift (laptop-agent HTTP 502 / multi-minute stalls on trivial git ops — the second laptop-agent outage today; the first one at ~11:31Z lapsed this task's earlier claim).

State of the branch (head d49b7cc, per lane code-c's merge work recorded on this PR at 11:48Z):

  • Branch is current with main; the settings-side substance was already on main and took main's side in the merge; installSandboxReaper() was folded into main's guardedMain; the checkPhase re-inclusion survived (exclusions now only internal/conformance and internal/defaults).

The one remaining defect (proven by lane code-c): the sandbox reaper steals tracked children. Its Wait4(-1) reaps ANY dead child, including subprocesses the tests themselves are waiting on via exec.Cmd.Wait — those Waits then fail / lose exit codes. Deterministic failures: go test ./internal/cli/ — 2 tests, e.g. TestRunScriptFailureReturnsStatusJSON (script exits 3, Run returns 1). Corroborating evidence from this lane earlier today: the package passes clean on the laptop (171 tests, 42.8s), and in the sandbox the test binary spawns ~700 detached daemons (Setsid + Release in client.go) that are exactly the population the reaper exists for.

Fix design (ready to implement): make the reaper session-selective. The daemons it must reap are session leaders in their OWN session (client.go starts them with Setsid); tracked children (scripts and subprocesses tests Wait on) run in the test process's own session. So: poll /proc for zombie children of the test process (state Z, ppid == self), and Wait4(pid) ONLY those whose session id differs from the test process's session (field 6 of /proc//stat). Never call Wait4(-1). Linux-only test helper, consistent with the existing sandbox-only guard. Then verify in order: (1) laptop go test ./internal/cli/ -count=1 — the 2 named failures pass and the package stays green; (2) the nix gate nix build .#packages.x86_64-linux.mcpx — internal/cli completes inside its checkPhase budget; (3) merge on green, recording the SHA here. If the build still burns the cli budget after the theft fix, the remaining suspect is live-daemon CPU starvation (the ~700-daemon accumulation above) — capture the daemon count mid-build as the next evidence step rather than guessing.

@dezren39

Copy link
Copy Markdown
Member Author

Agent note — task 17254 in progress (lane code-a): reaper fix implemented, verification running

  • Implemented the session-selective reaper designed on this PR (comment 6917155851) in the worktree at head d49b7cc: pkgs/mcpx/internal/cli/sandbox_reap_linux_test.go and the identical reaper in pkgs/mcpx/internal/e2e/sandbox_reap_linux_test.go. The blanket Wait4(-1) loop is replaced by a /proc poll that Wait4s only zombie children of the test process whose session id differs from the test process's own session (adopted Setsid daemons), leaving tracked same-session children for their real exec.Cmd.Wait waiters.
  • Verified so far on the laptop: go vet ./internal/cli/ ./internal/e2e/ clean; TestRunScriptFailureReturnsStatusJSON (one of the two deterministic sandbox failures) PASSES.
  • Still running / owed: full go test ./internal/cli/ ./internal/e2e/ -count=1 (laptop job d3fea91200a5, detached — survives the tunnel), then the nix gate nix build .#packages.x86_64-linux.mcpx, then commit + push to this branch.
  • Infra: the laptop-agent tunnel dropped again mid-verification (HTTP 502 proxy closed during CONNECT, even for health) — the detached test job is unaffected; this lane will poll it when the tunnel recovers and finish the sequence. Changes are uncommitted in worktree /home/user/git/fleet/queue-17254-8003-mcpx-checkphase until the full test pass lands.

@dezren39

Copy link
Copy Markdown
Member Author

Agent note — task 17254 parked (lane code-a): reaper fix implemented; laptop tunnel outage blocks the remaining verification

  • Implemented this shift (uncommitted in laptop worktree /home/user/git/fleet/queue-17254-8003-mcpx-checkphase, branch queue/8663-2686-mcpx-sandbox-restore at PR head d49b7cc): session-selective reaper in pkgs/mcpx/internal/cli/sandbox_reap_linux_test.go + pkgs/mcpx/internal/e2e/sandbox_reap_linux_test.go — /proc poll, Wait4 only foreign-session zombie children, never Wait4(-1). Design: this PR's comment 6917155851; progress note: comment 6917991470.
  • Verified before the outage: go vet clean on both packages; TestRunScriptFailureReturnsStatusJSON PASS.
  • Blocker (checked repeatedly this shift, still true at park time): the laptop-agent tunnel has returned HTTP 502 (proxy closed during CONNECT) on every call — health, exec, and polls — since ~13:30Z (~28 minutes of retries). The full-package test run is a detached laptop job (d3fea91200a5) that survives the outage; its result is unread until the tunnel recovers. All remaining steps (read job result, nix build gate, commit, push, merge) execute on the laptop, so no fleet lane can finish them while the tunnel is down — this is the same outage that parked this task under lanes code-c/code-d earlier today.
  • Resume (next claimant, in order): (1) poll laptop job d3fea91200a5 — if it failed or is lost, re-run go test ./internal/cli/ ./internal/e2e/ -count=1 in pkgs/mcpx in the worktree above; (2) nix build .#packages.x86_64-linux.mcpx; (3) commit the two reaper files, push to this branch; (4) recheck PR state and merge on green, recording the SHA here; (5) complete task 17254.

@dezren39 dezren39 added queue/parked Queue task is parked (waiting on CI, time, or an event) status/parked Deliberately paused with a recorded resume condition work/assigned Queue worker lifecycle state labels Nov 16, 2026
@dezren39

Copy link
Copy Markdown
Member Author

Pickup (queue task 17254, lane any-d): shepherding this PR to a terminal outcome. Fresh evidence so far: the change is NOT on main (main still excludes internal/e2e, internal/settings, internal/cli from the mcpx nix checkPhase under #2686); the branch carries the restore plus two maintenance merges of main. Next: merge current main into the branch, run the affected packages, and run the nix checkPhase build as the decisive gate — merge on a pass, close with evidence if the restore no longer holds.

@dezren39 dezren39 added queue/claimed Queue worker lifecycle state status/in-progress Queue worker lifecycle state and removed status/parked Deliberately paused with a recorded resume condition queue/parked Queue task is parked (waiting on CI, time, or an event) labels Nov 16, 2026
@dezren39

Copy link
Copy Markdown
Member Author

Shepherd outcome (queue task 17254, lane any-d): closing with fresh evidence — the restore cannot land as constituted

Verified 2026-11-16 against current main (aa3472c), branch merged with main locally in a scratch worktree (clean merge; the remote branch was not modified):

1. The change is not on main. Main's pkgs/mcpx/package.nix still excludes internal/e2e, internal/settings, and internal/cli from the nix checkPhase under #2686, so the PR is not superseded — it is blocked on its own mechanism (below).

2. The cli/e2e leg's mechanism is racy by construction. The branch's TestMain (in internal/cli/sandbox_reap_linux_test.go, and the same pattern in internal/e2e/sandbox_reap_linux_test.go) installs a child subreaper and a background goroutine that reaps with unix.Wait4(-1, …) — it reaps any child of the test binary, including children the package's own code spawned and is itself waiting on. In-suite on the merged branch:

  • internal/cli: TestRunScriptFailureReturnsStatusText and TestRunScriptFailureReturnsStatusJSON fail — Run(--json exec, script exits 3) = 1, want 3: the reaper steals the script child's exit status before the runner's own wait collects it. The same tests pass individually and the full internal/cli suite is green on current main without this TestMain. TestAPythonScriptDeclaredWithARuntimeServesAndAnswers also failed in one full-suite run.
  • internal/e2e ships the identical Wait4(-1) reaper, so the same theft race applies to the mcpx processes e2e spawns and waits on (established by inspection of the identical mechanism; the e2e suite was not run to timeout for this determination).

An in-process Wait4(-1) reaper cannot coexist with code that waits on its own children; the fix is a different shape (a subreaper wrapper process around the test binary in the checkPhase, not a TestMain inside it) — a redesign, not a shepherd fix.

3. The settings leg is invalidated by main drift. internal/settings fails TestTheEnvironmentDocIsCurrent on current main itself (the environment doc has drifted since this branch regenerated it), so restoring settings into the checkPhase today would break the build regardless of this PR. That exclusion is still load-bearing until the doc is regenerated on main.

Closing this PR under the 90-day shepherd rule with the evidence above. The path forward is recorded on #2686: (a) regenerate the environment doc on main and only then restore internal/settings; (b) replace the in-process subreaper TestMain with a wrapper-init design for e2e/cli and re-prove the suites in the nix sandbox before restoring them. The branch is retained for whoever picks that up.

@dezren39 dezren39 removed the work/assigned Queue worker lifecycle state label Nov 16, 2026
dezren39 pushed a commit that referenced this pull request Nov 19, 2026
…aper (#2686)

internal/e2e burns its 30m checkPhase timeout because the build sandbox
has no init to reap the script subprocess trees it spawns; and
internal/settings, green on main since #10774's ScriptEnv Setter and
docs regeneration, no longer needs its exclusion. Both checkExclude
entries go.

In their place, the Linux checkPhase runs `go test` under `tini -s`:
a child subreaper outside the test binary that adopts and reaps
orphaned descendants without competing with Go's exec.Cmd.Wait for
children the tests themselves own — the failure mode that closed PR
#8003, whose in-binary TestMain reaper stole exit statuses the cli
suite waits on. tini joins nativeCheckInputs on Linux only; darwin
keeps the plain command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant