Skip to content

test: land-direct and ubicloud recovery tests pass in one bun process (GST-1613) - #4068

Merged
capy-ai[bot] merged 1 commit into
mainfrom
capy/gst-1613-land-recovery-isolation
Nov 6, 2026
Merged

capy-ai[bot] merged 1 commit into
mainfrom
capy/gst-1613-land-recovery-isolation

Conversation

@garrytan

@garrytan garrytan commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 4068,
  "head": "abc28bd19c537e0250293953f6ea16d11fea766e",
  "version": "1.96.0.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 1607,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 42215899235,
      "attempt": 1,
      "tree": "ada77cdce1e4fbd70d5d8d9e278421b4b4a70ec1"
    }
  ],
  "session_kind": "unattended",
  "head_tree": "ada77cdce1e4fbd70d5d8d9e278421b4b4a70ec1",
  "product_patch_id": "none",
  "gstack_version": "1.96.0.0",
  "review_depth": {
    "depth": "light",
    "class": "tests",
    "runtime_lines": 0,
    "rules": "70895942bb8a8ee2",
    "base": "937b360fedcd8f2c3f2483090e93628767ca99e2",
    "registry": "937b360fedcd8f2c3f2483090e93628767ca99e2",
    "gate_scan": {
      "tagged": 0,
      "head": "abc28bd19c537e0250293953f6ea16d11fea766e"
    },
    "reasons": [
      "runtime=0"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "warn @ada77cdce1e4 (7 checks, current for abc28bd19c53)",
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/, README.md, CLAUDE.md, AGENTS.md, CONTRIBUTING.md (141 docs searched; 3 read)"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 3,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "ledgers_read": 1
  }
}

What changed

runMergedChecks moves from the bun test runner into a child Bun, so its prctl flags no longer turn the runner into a non-reaping subreaper

runMergedChecks moves from the bun test runner into a child Bun, so its prctl flags no longer turn the runner into a non-reaping subreaper.

Before/after as text: runMergedChecks moves from the bun test runner into a child Bun, so its prctl flags no longer turn the runner into a non-reaping subreaper
--- Before · before.txt · captured output
+++ After · after.txt · captured output
+// test/ship-queue-land-direct.test.ts on this branch (abc28bd)
+import type { MergedRun } from '../lib/land-merged-checks';
+function runMergedChecks(root, base, pin, checks, ms?): MergedRun {
+  // same call, made in a child Bun (spawnSync(process.execPath, [...bunIsolationArgs(), '-e', ...]))
+  // so the prctl flags die with the child and the runner keeps reaping orphans
+}
+// fakeVm() now throws a named error if the runner is already a subreaper;
+// recovery's afterAll fails on any zombie child left behind
-// test/ship-queue-land-direct.test.ts at main (937b360)
-import { runMergedChecks } from '../lib/land-merged-checks';
-// the case calls it in the bun test runner itself, so closeLandProc() runs
-//   prctl(PR_SET_DUMPABLE, 0) and prctl(PR_SET_CHILD_SUBREAPER, 1) on the runner;
-// later orphans in the same process stay zombies, and
-// test/ubicloud-runner-recovery.test.ts's run cases hang at 90 s (Free Tests, shard 10)
 

Why

A free-suite shard that packed test/ship-queue-land-direct.test.ts and test/ubicloud-runner-recovery.test.ts into one bun process hung every recovery run case at the 90 s timeout. The cause is lib/land-merged-checks.ts closeLandProc(), which calls prctl(PR_SET_CHILD_SUBREAPER, 1) and PR_SET_DUMPABLE 0 on its caller and never undoes them; the land-direct case 'runMergedChecks: HEAD is the merged commit…' reached it in-process, so the bun test runner itself became a subreaper that adopted later orphans and never reaped them. The fake VM's detached phases then stayed zombies that tail --pid and kill -0 count as alive. That case now calls runMergedChecks in a child Bun, so the flags die with the child and the two files pass together again, which unblocks #4063.

Blast radius

Only test code changes, in the land-direct test file, the shared fake VM helper, recovery's teardown and a new regression file. lib/land-merged-checks.ts and its production callers in lib/ship-queue-land-direct.ts (lines 93 and 212) are untouched, and those run inside the short-lived gstack-ship-queue land process, which exits after landing (file:line read). The new fakeVm() guard returns false off Linux, so macOS and Windows callers behave as before (file:line read; the Free Tests run at this head passed).

Approvals

No approvals recorded for branch capy/gst-1613-land-recovery-isolation.

Summary

The land-direct merged-checks case ran runMergedChecks inside the bun test runner, and that call permanently turned the runner into a non-dumpable child subreaper. Any later test file in the same process that leaves detached children then leaks zombies. The case now runs the same call in a child Bun with bunIsolationArgs(), the fake VM fails at once with a named error if the runner is already a subreaper, recovery's afterAll fails on any zombie child, and a new regression runs both files in one process.

Test Coverage

Step 7 audit: not run (no runtime file changed; the diff is test code only).
Regression proof: test/land-direct-recovery-isolation.test.ts fails on the old fixture (3.6 s, lane run) and passes on this branch.
Tests ran: test 1607 (files, carried from the CI run at this exact tree)

Pre-Landing Review

Pre-Landing Review: 3 issues — 0 auto-fixed, 0 asked (0 fixed, 0 skipped), 0 deferred, 3 noted
REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=3 fixed=0 scope=frozen ledgers_read=1
Gate edits: none detected (9 listed, 2 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Outside review: openai/gpt-6.1-sol (reasoning medium, certified configuration): no actionable findings; it reran the focused regression and the spawn-timeout guard, 4 passed, 0 failed.

Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL lib/land-merged-checks.ts:72 completeness-gaps: closeLandProc() leaves its caller a non-dumpable child subreaper for the rest of the process. The production caller exits after landing, so nothing breaks today, but a future long-lived in-process caller would inherit the same unreaped-orphan behavior. Unchanged product code, outside this diff.
  • INFORMATIONAL test/helpers/process-reaping.ts:9 repo-conventions: isChildSubreaper() dlopens libc.so.6, so on a non-glibc Linux (musl) every fakeVm() call would throw. CI and the supported Linux targets are glibc, and lib/land-merged-checks.ts makes the same dlopen.
  • INFORMATIONAL test/ship-queue-land-direct.test.ts:118 timing-dependent-tests (medium confidence): the existing wall-clock bounds in the merged-checks case (under 10 s and under 3 s) now also include one child Bun start per call, about 0.2 to 0.5 s here. The headroom is large and the lane saw 53 pass.

Exploratory QA

Not applicable: the diff changes no product code (tests, test helpers and a changelog fragment only), so there is no product surface to probe. The behavior under change is the tests themselves: the lane ran land-direct (53 pass), recovery (29 pass) and the regression (1 pass, and it fails on the old fixture), and the outside reviewer reran the regression.

Design Review

No frontend files changed — design review skipped.

Eval Results

No prompt-related files changed — evals skipped.

Plan Completion

Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). Fix: add "Plan: " to the PR body, or run /autoplan.

TODOS

No TODO items completed in this PR.

Documentation

Status: current. The audit found nothing to edit.

Scope: base 937b360, head abc28bd on capy/gst-1613-land-recovery-isolation. The diff has 7 files: tests, helpers and a changelog.d fragment, with 0 staged, 0 unstaged and 0 untracked. The 141-doc inventory was searched for references to the changed test helpers and lib/land-merged-checks.ts.

Documentation health:

  • changelog.d/capy-gst-1613-land-recovery-isolation.md: current. Its claims match the diff.
  • docs/TESTING_INTERNALS.md: current. Its fake VM description is unchanged in substance.
  • CONTRIBUTING.md: current. Its test-of-test ratchet description still holds.

Coverage debt: none. The change adds no user-facing behavior.

Diagram drift: none found.

Test plan

  • Free Tests (workflow_dispatch on this branch, run 42215899235 attempt 1): green; CI_CARRY accepted at tree ada77cdce1e4
  • gstack-pregate --allow-repo-commands: warn (only a MEDIUM pii false positive on a CI run id in the changelog fragment); typecheck, module-size and conflict-marker guards pass; 29 of 29 selected test files reused from the CI run
  • Lane: bun run typecheck, bun run typecheck:test, land-direct 53 pass, recovery 29 pass, regression 1 pass, test-of-test / spawnsync-tripwire / module-size / bun-entry-isolation / test-free-shards / state-root ratchets 108 pass

🤖 Generated with Claude Code

…res a process (GST-1613)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@capy-ai
capy-ai Bot merged commit 63489d0 into main Nov 6, 2026
54 checks passed
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