Skip to content

Make CLI terminal and child-process lifetimes explicit #269

Done

Description

@DocksDocks

Goal

Audit terminal lease, exclusive writes and child-process completion in the engine, including tidy and toolchain callers. Model confirmed phase-dependent data; keep orthogonal queues, terminal capabilities and platform policy separate.

Yolo: the user delegated every decision except the merge to the agent.

Mode: plan-and-implement

Research

Baseline: parent #267 assigns cli/src except plan/ (#270), engine-native/syncConcurrency.ts (#268), and derived payload bytes. git ls-files cli/src is the inventory. The command adapters, argv scanner, agent-doc checks, skill parsers and scorers, root services and entry points have linear flows, independent counters or already tagged results; no new machine there.

The remaining engine modules have explicit handoffs: tidy passes a TidyPlan with its resolved Docker endpoint to apply/report; sync passes resolved OmpWriteFolders through locks into deployment; kitLock owns SQLite connections. bun memoizes one promise of BunRuntimeState. engineCtx holds independent capabilities and run data. OS modules, version probes, caches, merge/deploy passes, atomic writes, option scanners and report formatting do not need another lifetime model. Quoting state in exec.windowsPathEntries is independent of the accumulated path text.

engine-native/logger.ts tracks the same lease through activeLease and released. Current identity gates the lease methods; stale update/release cannot erase a successor. Already-admitted actions must still run. The queue is per lease; exclusive writes use a logger-wide buffer. AsyncLocalStorage rejects nested actions while their owner remains active. Errors bypass buffered durable output. syncDispatch.runPipeline releases in finally. No production caller enters withExclusive; the installer pipes stderr. The logger tests exercise its contract. Preserve reentrant flushing and restoration on failure.

Handoff boundary: release does not cancel an admitted action or wait for it. A stale handle passes new actions through. Starting a successor before old actions drain can overlap the two queues and affect progress; this is existing library behavior, not a sequence the sync pipeline drives. Verify stale methods during a successor and completion of admitted work across release. Do not introduce cross-lease serialization, delay acquisition, or change flush/redraw timing in this behavior-preserving child.

exec.spawnProcess races the child close event with a deadline. Today a late close still performs cleanup and tries to resolve the already-settled promise. The winning event must own settlement and the loser's cancellation. Keep errors from the child and its pipes until close, partial streams on timeout, no timeout error field, and existing ordinary results with a numeric or null exit code. captureWithin, deps, tidy, ompChild and the Bun installer consume those results. Do not change host lookup, tree termination, pipes, deadlines, or the process-exit handler.

Decision: use the current lease identity as the only lease authority and buffered output as the exclusive-write state. A separate released flag can disagree with the current holder. Do not combine the independent admission queue, nesting context and redraw capability into a single global phase. Keep externally observable transitions covered by real writes to recording sinks. This local change is reversible without a caller migration.

Decision: use the one-shot close listener and deadline as mutually exclusive completion paths and narrow the result type using the existing timeout marker. An additional state flag would duplicate registrations; a new public discriminant would change returned objects. Guard against late events by retiring the competing callback before cleanup. No new dependency or wrapper remains. See Node close, async context and TypeScript narrowing.

docks-kit agent-docs verify-skill detect: verify skill: present. Verify flow V3 already drives public sync and toolchain checks in disposable fixture homes. Select those two rows and compare exit status and output to checked-in goldens. A live sync or real install would add unrelated side effects.

Tool versions: Bun 1.4.5, Node 26.13.0, git 2.53.0, gh 2.103.3, docks-kit 0.31.0 (local version output); Vitest 5.1.2, Oxlint 1.95.0 and Effect tsgo 0.74.1 (package.json).

Engineering standards

Both steps use code-clarity, type-safety-discipline, engine-native-context, host-platform-context and commit-discipline. Tests characterize existing behavior using test-coverage. No new public behavior or policy is intended.

Steps

# Id Task Files Depends Effect Status Done when
1 terminal Make lease authority and durable buffering explicit. Preserve queued and stale handles. cli/src/engine-native/logger.ts, cli/test/unit/logger.test.ts - local done Release cannot clear a later lease. Admitted actions finish; durable output flushes in order, including on rejection.
2 completion Give close and timeout exclusive ownership of completion and encode their result shapes. cli/src/engine-native/exec.ts, cli/test/unit/exec.test.ts - local done Only the winner settles and owns cleanup. Ordinary and timed-out results retain their public shape and exact output.

Acceptance

ID Command Expected
A1 git diff 701e104c29fb5e1a3c40fbc1d3867ea625ddf281 -- cli/src/engine-native/logger.ts cli/src/engine-native/exec.ts Inspect the resulting sources: lease identity replaces the release flag; buffering exists only during exclusive output; deadline and close disarm one another; a timeout cannot carry a numeric exit code or a process error. Fail the structural check if any condition is absent, even if the behavior checks pass.
A2 bun run test:unit cli/test/unit/logger.test.ts cli/test/unit/exec.test.ts cli/test/unit/syncLock.test.ts cli/test/unit/bun.test.ts cli/test/unit/deps.test.ts cli/test/unit/tidy.test.ts cli/test/unit/toolchain.test.ts All applicable tests pass, including ordered writes, stale lease operations, release with pending work, close with both output streams, error and timeout, and bounded process cleanup.
A3 GOLDEN_FILTER='^cli=public fixture=home-fresh cmd=sync --dry-run$' bun run golden:dryrun then GOLDEN_FILTER='^cli=public fixture=home-fresh cmd=toolchain check$' bun run golden:dryrun Each selected V3 public case matches checked-in output and exit status; neither updates goldens nor deploys.
A4 bun run check:types plus bun run lint and bun fmt --no-script --check on the changed TypeScript paths Types and Effect diagnostics, lint and formatting pass.
A5 Require the protected Full CI job from the authorized ready-for-review run on the reviewed head and current base. All required jobs pass, including the Linux full gate and portable jobs; GitHub accepts the reviewed candidate.
A6 Run the following Linux fixture command in Bash. The real public tidy command exits zero, keeps the dirty worktree, and reports the seeded cache. No apply, remote endpoint, or live home.

Reuse the archived #268 A3 fixture unchanged. Its code is reproduced below. createGitSandbox is the tracked fixture. Tool versions from #268 on this workstation: Bubblewrap 0.11.1, Bash 5.3.0, and coreutils 0.10.0.

bwrap --ro-bind / / --dev /dev --proc /proc --tmpfs /tmp --tmpfs /var/tmp --setenv TMPDIR /tmp -- \
bun -e 'import {createGitSandbox} from "./cli/test/lib/gitSandbox.ts"; import {mkdirSync,existsSync,symlinkSync} from "node:fs"; const s=createGitSandbox(); try { const cache=s.home+"/.cache/ms-playwright", bin=s.base+"/bin"; mkdirSync(cache,{recursive:true}); mkdirSync(bin); for(const name of ["bun","git","dirname","uname","du"]) { const path=Bun.which(name); if(!path) throw new Error("missing "+name); symlinkSync(path,bin+"/"+name); } const p=Bun.spawnSync(["./docks-kit","tidy","--repo",s.main,"--report"],{env:{PATH:bin,HOME:s.home,LC_ALL:"C",GIT_CONFIG_NOSYSTEM:"1",GIT_CONFIG_GLOBAL:s.base+"/gitconfig"},stdout:"pipe",stderr:"pipe"}); const out=p.stdout.toString(); if(p.exitCode!==0 || !out.includes("keep worktree "+s.worktrees.dirty+":") || !out.includes("  "+cache+"\n") || !existsSync(s.worktrees.dirty) || !existsSync(cache)) throw new Error("tidy fixture proof failed"); console.log("tidy kept the dirty worktree and measured the seeded cache"); } finally { s.dispose(); }'

The required full repository gate runs once on the exact reviewed candidate in CI. Run only focused local checks. Keep the separate full local bun run check checklist item unticked; a remote result cannot prove it ran locally.

Do not touch

Leave public CLI contracts, unrelated output policy, host-specific kill behavior, generated files, and other children's scope unchanged.

Open questions

Verification Results

Candidate 92d4e95360e139fc80ea9108cba5a859ebb980e1, base 701e104c29fb5e1a3c40fbc1d3867ea625ddf281.

  • A1: the current lease identity gates update/release/redraw. The optional write buffer replaces the exclusive flag. Close cancels the deadline; timeout unregisters close before cleanup. The timeout variant admits neither a numeric exit code nor a process error.
  • A2: seven files, 138 tests passed on Linux. Both new terminal scenarios passed, as did child close and timeout.
  • A3: each selected public CLI golden passed (one sync case, one toolchain case). Both used the current TypeScript entry.
  • A4: bun run check:types, targeted Oxlint and Bun formatting passed on all four changed files. The full local gate did not run.
  • A6: the sandboxed public CLI printed tidy kept the dirty worktree and measured the seeded cache. The fixture was disposed.
  • A5 follows publication of the reviewed head.

After review, 197e2e8d516a05331da6e9a4b5c433ac7d51bfb2 preserves A1 and releases processed write batches during long reentrant flushes. A2: 139 of 139 passed. A3: both public goldens passed. A4: types, Oxlint and format passed. A6: the public tidy proof passed. The tests include sink failure recovery, a real missing executable, strict result shapes and both partial streams.

Candidate 458a7cf1940fa5ed307f0b558999b71e7004908f: A1 unchanged. A2 passed all 139 tests, including a synchronized real-child test for partial output. A3 passed both public goldens. A4 passed types, lint and formatting. A6 passed the isolated tidy proof.

Candidate 0a2b8b1e16eeb0e24bbbe9df86d03a306996bfe4: A1 unchanged. A2 passed all 138 tests in seven files. One synchronized tree test replaces two timing-sensitive process tests; it checks both partial streams and descendant termination. A3 passed both public goldens. A4 passed types, lint and formatting. A6 passed the public tidy proof.

Candidate ecb5047670a4ad95a01c0193df03d44e873c8226: A1 unchanged. A2 passed all 138 tests after the fixture cleanup repair. A3 passed both public goldens. A4 passed types, lint and formatting. A6 passed the public tidy proof.

A5, first request: run 46544646567 failed the skill source-range guard on Linux, macOS and Windows. The logger ended on line 192, but the project skill cited line 196. Commit d168ea0a1d6dbb254dac355aafbd69d206c7928d corrects the two affected source extents. The guard and all 138 behavior tests passed on that head. A1 stayed unchanged. A3, A4 and A6 passed again. A5 needs a fresh request.

A5, second request: Linux and Windows passed on d168ea0. GitHub cancelled the macOS job before any step ran. Its annotation reported no available hosted runner. The required gate failed closed. Requested a new first-attempt run on the same head; no code changed.

A5 passed on d168ea0a1d6dbb254dac355aafbd69d206c7928d. All 10 jobs passed in run 46547968375, including Linux, macOS, Windows and the required Full CI job. The run tested merge 4cad8e6c0d069516f8664dcf1e870ec9dd604570 against main at 701e104c29fb5e1a3c40fbc1d3867ea625ddf281. GitHub reported CLEAN for PR #275.

Activity

  1. self-assigned this
    on Nov 30, 2026
  2. DocksDocks commented on Nov 30, 2026

    @DocksDocks
    OwnerAuthor

    Delegation grant: yolo: next up is a yolo issue for "scan this codebase for any implicit state machines and make it explicit"
    Parent event: 7294751276

  3. DocksDocks commented on Nov 30, 2026

    @DocksDocks
    OwnerAuthor

    Delegation grant: yolo: ok go ahead and do issue://269 with the yolo skill

  4. DocksDocks commented on Dec 1, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 1

    Plan-review: repair

    • goal_fit - Research lines 17 and 21, Steps terminal, Acceptance A1–A2 - cli/src/engine-native/logger.ts:122–170 queues work per lease but buffers writes per logger. If lease A admits work, releases, and lease B acquires before A's callback starts, A's callback erases B's progress. A and B can also overlap, so A's cleanup can flush or disable buffering while B still owns exclusive output. Replacing the release flag alone can pass A1 while preserving both failures - Define the handoff so admitted work drains without overlapping exclusive sections or erasing successor progress, and check that interleaving in A2 - class: lease handoff missing from the ownership model
    • research_gap - Research line 17, “inherited-stdio installers use exclusivity” - cli/src/engine-native/bun.ts:47–56 ignores stdin and stdout and pipes stderr. syncDispatch.ts:174–186 acquires and releases the lease, but no production call enters withExclusive. A Bun install therefore does not exercise the exclusive buffer as the audit claims - Record that exclusivity is currently exercised by logger tests, not by an installer, and base the retention decision on that boundary - class: claimed production caller does not exist
    • goal_fit - Goal, Steps completion, Acceptance A2–A3 - Public tidy --repo uses defaultTidyHost to resolve the repository through Git and the changed spawnProcess path (cli/src/commands/tidy.ts:126–141, cli/src/engine-native/tidy.ts:125–134,336–345). A2 calls runTidy directly with an injected host (cli/test/unit/tidy.test.ts:480–495), and A3 runs only sync and toolchain. Both rows can pass without driving the tidy command named in the Goal - Run public tidy --repo against an isolated fixture without --apply, and name the expected exit status and preview output - class: missing end-to-end check for an affected public command
    • goal_fit - Acceptance A2–A5 - AGENTS.md:69–73 requires the full local unit and golden gate once at the pre-commit or release boundary. A2–A4 run focused checks, while A5 runs only after a pull request is marked ready (.github/workflows/parity.yml:1–5,190–207). The plan can therefore reach its final commit without the required local gate - Record bun run check once at the pre-commit boundary and retain A5 as the separate landing gate - class: required local check deferred to post-commit CI
  5. DocksDocks commented on Dec 1, 2026

    @DocksDocks
    OwnerAuthor

    Plan review round 2, delta

    Plan-review: pass

    None.

    Previous findings:

    • Round-1 finding on Research lines 17 and 21, Steps terminal, Acceptance A1–A2: rejected - not repeated
    • Round-1 finding on Research line 17, “inherited-stdio installers use exclusivity”: resolved - Research now records that the installer pipes stderr and that logger tests exercise withExclusive.
    • Round-1 finding on Goal, Steps completion, Acceptance A2–A3: resolved - A6 runs public tidy --repo --report against an isolated Git fixture and checks the exit status, worktree retention, and seeded cache output.
    • Round-1 finding on Acceptance A2–A5: rejected - not repeated

    Manager response to round 1

    Repaired:

    • Round 1 terminal handoff: Research now distinguishes stale-handle methods from admitted work. A2 exercises both. Queues remain per lease.
    • Round 1 inherited-stdio claim: corrected Research. The Bun installer pipes stderr; logger tests are the callers of withExclusive.
    • Round 1 public tidy proof: A6 runs the isolated public command against the tracked Git fixture and checks output plus surviving paths.

    Redesigned: none.
    Rejected:

    • Round 1 terminal handoff, requested new global serialization policy: Make implicit state machines explicit across the codebase #267 requires preserved observable behavior. The old queue is per lease and admitting new work through a released handle has always bypassed it. Terminal handoff Research records this boundary instead of adding new scheduling behavior.
    • Round 1 full local suite: session verification rules require focused checks only when they cover the changed code and callers. A4 and A5 record what runs locally and remotely. The full local checklist item remains unticked, as in the archived Model the bounded worker pool’s failure drain #268.
  6. DocksDocks commented on Dec 1, 2026

    @DocksDocks
    OwnerAuthor

    Self-review

    Correctness

    No findings. Both callbacks disarm the competing completion path. Late events cannot change the timeout result. Sink writes appended during a flush retain call order.

    Spec and tests

    No findings. The focused tests cover stale lease methods, already-admitted work, reentrant buffering and partial output on timeout. The two public goldens and the tidy fixture passed.

    Text and safety

    No findings. The change retains process-group and Windows cleanup policy. It adds no new command or configuration value.

  7. DocksDocks commented on Dec 1, 2026

    @DocksDocks
    OwnerAuthor

    Code review round 1, lens correctness

    Code-review: pass

    Standards

    • [LOW] Performance - cli/src/engine-native/logger.ts:104-115 - Unreached: If a sink queues one new line for each line it writes, the flush retains every processed callback and its message until the chain ends. Peak memory grows with the total lines written even when only one line is pending. The previous batch drain released processed callbacks between batches. The fixture at cli/test/unit/logger.test.ts:209-223 queues one extra line, no production caller enters withExclusive, and the documented exclusive-use cases don't describe a reentrant sink. - Drain in batches while keeping buffering active so reentrant writes still follow pending writes. - class: retained drained queue entries

    Spec

    None.

    Code review round 1, lens spec-and-tests

    Code-review: pass

    Standards

    • [LOW] Bug - cli/test/unit/exec.test.ts:109-113, cli/test/unit/exec.test.ts:134-139 - Both result-shape assertions accept extra properties set to undefined because Vitest's toEqual ignores them. The timeout test would pass with an own error: undefined property, even though the plan requires that field to be absent. The close test likewise accepts timedOut: undefined. - Use toStrictEqual for both result objects. - class: non-strict result shape assertion
    • [LOW] Maintainability - cli/test/unit/exec.test.ts:121-139, cli/src/engine-native/exec.ts:139 - The timeout fixture writes only to stdout and leaves stderr disconnected. A regression that drops captured stderr from timed-out results would still pass the new assertion. - Pipe stderr in this case, write a known marker before the child stalls, and assert that the timeout result contains it. - class: unexercised timeout stream
    • [LOW] Maintainability - cli/test/unit/exec.test.ts:60-82, cli/test/unit/exec.test.ts:98-114, cli/src/engine-native/exec.ts:174-182 - The error fixtures return before a child exists; the bounded close fixture exits nonzero without emitting a process error. Dropping error from onClose would therefore escape these tests and could make tidy misclassify an executable that disappears before spawn. - Add a real asynchronous spawn failure and assert that the close result retains the process error without reporting a timeout. - class: untested asynchronous error propagation
    • [LOW] Maintainability - cli/test/unit/logger.test.ts:160-182, cli/test/unit/logger.test.ts:208-222, cli/src/engine-native/logger.ts:104-115 - The rejection fixture throws from the action, not from a sink, and the reentrant sink never throws. A flush that stops at the first sink exception would pass both tests while dropping subsequent durable writes. - Have the reentrant sink enqueue its final write and then throw; assert that the lease rejects with that error and still emits the remaining writes in order. - class: untested sink failure recovery

    Spec

    None.

    Code review round 1, lens text-and-safety

    Code-review: pass

    Standards

    • [LOW] Bug - cli/src/engine-native/logger.ts:14-15, cli/src/engine-native/logger.ts:125-144, cli/test/unit/logger.test.ts:185-204 - The withExclusive doc promises serialization without saying it is per lease. The handoff test shows admitted work surviving release and stale calls running directly. If the successor starts exclusive work before the old action finishes, the separate queues allow both actions to run at once (inference). - Document that serialization is per lease, release does not drain admitted work, and stale calls bypass the queue. Keep the handoff behavior unchanged. - class: overstated lease guarantee
    • [LOW] Maintainability - cli/src/engine-native/logger.ts:104-115, cli/src/engine-native/logger.ts:150-154 - flushDurable clears the array even though its only caller immediately drops it on both success and failure. The reset makes the buffer look reusable when the next exclusive section gets a fresh one. - Remove writes.length = 0; keep the iteration that visits writes appended by a sink and the finally that drops the buffer. - class: redundant state reset

    Spec

    None.

  8. DocksDocks commented on Dec 1, 2026

    @DocksDocks
    OwnerAuthor

    Code review round 2, delta

    Code-review: pass

    Previous findings

    • Round-1 finding on cli/src/engine-native/logger.ts:104-115: fixed - The batch drain removes processed callbacks from the live queue while reentrant writes go into the next batch (cli/src/engine-native/logger.ts:104-116).
    • Round-1 finding on cli/test/unit/exec.test.ts:109-113, cli/test/unit/exec.test.ts:134-139: fixed - Both result assertions use toStrictEqual (cli/test/unit/exec.test.ts:118-122,144-149).
    • Round-1 finding on cli/test/unit/exec.test.ts:121-139, cli/src/engine-native/exec.ts:139: fixed - The timeout fixture pipes stderr, writes a marker, and requires it in the result (cli/test/unit/exec.test.ts:130-149).
    • Round-1 finding on cli/test/unit/exec.test.ts:60-82, cli/test/unit/exec.test.ts:98-114, cli/src/engine-native/exec.ts:174-182: fixed - The missing executable reaches native spawn; the test requires ENOENT without a timeout marker (cli/test/unit/exec.test.ts:99-106).
    • Round-1 finding on cli/test/unit/logger.test.ts:160-182, cli/test/unit/logger.test.ts:208-222, cli/src/engine-native/logger.ts:104-115: fixed - The sink enqueues another write before throwing; the test checks the exact rejection and all three writes in order (cli/test/unit/logger.test.ts:207-229).
    • Round-1 finding on cli/src/engine-native/logger.ts:14-15, cli/src/engine-native/logger.ts:125-144, cli/test/unit/logger.test.ts:185-204: fixed - The docs limit serialization to one lease and explain that release neither drains admitted work nor queues new work (cli/src/engine-native/logger.ts:14-17).
    • Round-1 finding on cli/src/engine-native/logger.ts:104-115, cli/src/engine-native/logger.ts:150-154: fixed - Each splice removes a batch before it runs; there is no redundant final reset (cli/src/engine-native/logger.ts:104-116,150-155).

    Standards

    • [LOW] Bug - cli/test/unit/exec.test.ts:130-149, cli/src/engine-native/exec.ts:155-171,190-198 - If the parent reads the PID before the one-second deadline but has not yet read the separate stderr pipe, spawnProcess correctly returns an empty stderr and the new assertion fails. Inference: a loaded runner can hit that ordering; its frequency is unknown. - Make the partial-output assertion wait for both real stream reads before advancing a controlled deadline, and keep the real-clock child cleanup check separate. - class: unsynchronized subprocess output assertion

    Spec

    None.

    Manager response to round 1

    Repaired in 197e2e8:

    • Correctness, logger flush: drain in bounded-by-arrivals batches; no processed callbacks accumulate across batches.
    • Text, lease contract and reset: describe per-lease serialization, the released bypass and non-draining release. Batch removal eliminates the redundant array reset.
    • Spec, process tests: strict close and timeout objects, PID on stdout and a known stderr marker on timeout. A nonexistent absolute executable exercises asynchronous spawn error retention without a host preflight rejection.
    • Spec, reentrant output sink: the sink queues the final line and throws; the test requires rejection with the exact error and delivery of all remaining writes in order.

    Rejected: none.
    Redesigned: none.

  9. DocksDocks commented on Dec 1, 2026

    @DocksDocks
    OwnerAuthor

    Code review round 3, delta

    Code-review: pass

    Previous findings

    • Round-2 finding on cli/test/unit/exec.test.ts:130-149, cli/src/engine-native/exec.ts:155-171,190-198: open - The partial-output test now waits for both pipes before advancing the deadline (cli/test/unit/exec.test.ts:156-169). The process-tree test still has an instance of the same defect, repeated under Standards.

    Standards

    • [LOW] Bug - cli/test/unit/exec.test.ts:182-202, cli/src/engine-native/exec.ts:185-198 - If the child starts its grandchild but the parent has not read the PID before the one-second deadline, spawnProcess correctly returns empty stdout and the test fails at expect(grandchild).toBeGreaterThan(0) before checking cleanup. Inference: a loaded runner can hit this ordering; its frequency is unknown. - Wait for the real grandchild PID before advancing a controlled deadline, then check that the grandchild exits. Keep the separate real-clock captureWithin test. - class: unsynchronized subprocess output assertion
    • [LOW] Bug - cli/test/unit/exec.test.ts:156-163, vitest.config.ts:40, cli/test/lib/spawnTimeout.ts:47 - The new test shares one four-second watchdog between reading both pipes and observing the child's close. A correct run that takes more than four seconds across those phases fails even though it is within the suite's 15-second ceiling, or 45 seconds on Windows. Inference: runner contention can exhaust this budget; its frequency for this fixture is unknown. - Derive the real watchdog from the suite's platform-specific timeout, leaving time for cleanup and keeping the simulated process deadline unchanged. - class: premature fixture watchdog

    Spec

    None.

    Manager response to round 2

    Repaired:

    • Round 2, unsynchronized subprocess output assertion: 458a7cf observes the real ChildProcess, waits for data from both pipes, then advances the controlled deadline. It waits for the real close event; a separate real-clock test checks process-tree cleanup. The fixture restores timers and terminates its child on failure.

    Rejected: none.
    Redesigned: none.

  10. DocksDocks commented on Dec 1, 2026

    @DocksDocks
    OwnerAuthor

    Code review round 4, delta

    Code-review: pass

    Previous findings

    • Round-3 finding on cli/test/unit/exec.test.ts:182-202, cli/src/engine-native/exec.ts:185-198: fixed - The merged tree test waits for the complete PID and stderr lines before advancing the simulated deadline. The separate real-clock captureWithin test remains (cli/test/unit/exec.test.ts:170-177,198-204).
    • Round-3 finding on cli/test/unit/exec.test.ts:156-163, vitest.config.ts:40, cli/test/lib/spawnTimeout.ts:47: fixed - The watchdog uses the platform-specific suite ceiling minus one second, and the descendant poll uses the remaining budget (cli/test/unit/exec.test.ts:152-154,185-188).

    Standards

    • [LOW] Bug - cli/test/unit/exec.test.ts:141-154,170-175,189-194 - If stdout delivers the grandchild PID but stderr misses the watchdog, Promise.all rejects before the test saves the PID. Teardown kills only the direct child, leaving the grandchild to run until its own 30-second or 90-second timer expires. Inference: this can happen if the two pipe events are delivered on opposite sides of the watchdog deadline. - Save the validated PID as soon as the stdout line arrives, while still waiting for both lines before advancing the simulated deadline. - class: cleanup state lost on partial readiness
    • [LOW] Bug - cli/test/unit/exec.test.ts:21-32,185-201, cli/src/engine-native/exec.ts:183-186 - If the fixture fails before restoring real timers and the grandchild exits between the liveness check and process.kill, the signal can throw ESRCH. That skips timer restoration and can make the following real-clock captureWithin test hang. Inference: the cascade requires the grandchild to exit in that teardown window. - Restore real timers before signaling the grandchild, and tolerate only ESRCH from the cleanup signal. - class: throwing teardown skips clock restoration

    Spec

    None.

    Manager response to round 3

    Repaired:

    • Round 3 unsynchronized grandchild PID: 0a2b8b1 combines child and tree assertions into a single live fixture. It waits for complete stdout and stderr lines before advancing the only controlled process deadline.
    • Round 3 premature watchdog: the fixture uses the suite's platform-specific TEST_TIMEOUT_MS, reserving one second for cleanup; the termination wait uses its remaining budget.

    Redesigned:

    • Replace independent child and descendant readiness tests with a single protocol carrying the descendant PID and stderr marker. The old real-clock test guessed when the PID was ready. Synchronizing only the first fixture left the same race in the second. Sharing one fixture removes that duplicated synchronization. The separate captureWithin case still checks the real clock. The test is local and reversible; bounded fixture lifetimes protect failed cleanup.

    Rejected: none.

  11. DocksDocks commented on Dec 1, 2026

    @DocksDocks
    OwnerAuthor

    Code review round 5, delta

    Code-review: pass

    Previous findings

    • Round-4 finding on cli/test/unit/exec.test.ts:141-154,170-175,189-194: fixed - The stdout callback validates and saves the grandchild PID before the combined readiness wait can fail on stderr. The test still waits for both lines before advancing the deadline (cli/test/unit/exec.test.ts:179-188).
    • Round-4 finding on cli/test/unit/exec.test.ts:21-32,185-201, cli/src/engine-native/exec.ts:183-186: fixed - Teardown restores real timers before signaling the grandchild. The signal ignores only ESRCH, and the success path clears the saved PID after observing that the grandchild has stopped (cli/test/unit/exec.test.ts:36-42,196-207).

    Standards

    None.

    Spec

    None.

    Manager response to round 4

    Repaired:

    • Partial readiness: ecb5047 records the validated descendant PID directly in the stdout callback. A delayed or absent stderr line cannot discard that ownership.
    • Clock and signal cleanup: ecb5047 restores real timers before descendant cleanup, tolerates ESRCH only from the kill race and clears ownership on the success path.

    Rejected: none.
    Redesigned: none.

  12. DocksDocks commented on Dec 1, 2026

    @DocksDocks
    OwnerAuthor

    Code review round 6, delta

    Code-review: pass

    Previous findings

    None.

    Standards

    None.

    Spec

    None.

    Manager response to round 5

    Repaired: none (no open findings). The CI range guard required a separate two-line metadata repair.

    Rejected: none.

    Redesigned: none.

  13. DocksDocks commented on Dec 1, 2026

    @DocksDocks
    OwnerAuthor

    Archived with landing pull request #275

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions