Skip to content

fix(platform): close remaining Vitest main failures - #6829

Merged
cv merged 4 commits into
mainfrom
codex/fix-wsl-gateway-uid-match
Jul 15, 2026
Merged

fix(platform): close remaining Vitest main failures#6829
cv merged 4 commits into
mainfrom
codex/fix-wsl-gateway-uid-match

Conversation

@cjagwani

@cjagwani cjagwani commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes the remaining failures exposed by the Platform Vitest main watch across WSL and macOS. The patch fixes the original WSL gateway-owner mismatch, supplies the missing macOS fd dependency, makes Shields timer takeover fail closed around PID reuse and late descendants, and makes the WSL root-only Hermes fixtures traversable by the intended peer without weakening their contents.

Related Issue

Follow-up to #6825; preserves the bare-gateway stop behavior from #4951.

Changes

  • Compare gateway process and identity-file owners by stable numeric UID instead of width-limited account names.
  • Install fd in the macOS platform lane and pin that dependency in the workflow contract.
  • Bound Shields process inspection, verify start identity immediately before signaling, stop the exact owner before enumerating descendants, and require a quiescent descendant pass.
  • Add deterministic PID-reuse, transient-inspection, stop-ordering, and non-quiescent-tree regressions.
  • Grant temporary execute-only traversal for the two WSL root peer fixtures, restore the shared temp-root mode, and return locked fixtures to mutable before cleanup.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: These are internal platform-CI and process-safety corrections; the documented tunnel and timer contracts do not change.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: Independent security review found no blockers. Exact process identity is the final pre-signal verification, zombies are treated as gone, replacement PIDs receive no stop or kill signal, and non-quiescent trees remain frozen and fail closed.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — npm run test:changed: 82 files and 735 tests passed; focused platform and Shields tests: 23 passed; CLI typecheck and build passed; integration fixtures: 9 passed with 2 root-only tests skipped locally; project membership and structural checks passed.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — authoritative branch Platform Vitest run is being dispatched on real macOS and WSL runners.
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Charan Jagwani cjagwani@nvidia.com

Summary by CodeRabbit

  • Bug Fixes
    • Improved shield recovery/takeover reliability with deadline-bounded process inspection, more deterministic hung-owner handling, and stronger “current vs gone” verification.
    • Prevented unsafe signaling during takeover by identity-based recovery-tree exclusion and tighter freeze/kill escalation logic.
    • Hardened Linux gateway shutdown by switching process authorization and PID discovery to numeric UID checks.
  • Tests
    • Added deadline behavior coverage and expanded shield takeover/recovery tests for hung and PID-reuse replacement scenarios.
    • Updated gateway stop-script and Hermes restart fixture tests, including stricter permission handling and cleanup.
  • Chores
    • Added fd to macOS CI dependency installation.

Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a8fc6cf6-a8a4-44ef-b4e3-9ec6b4a30946

📥 Commits

Reviewing files that changed from the base of the PR and between 032e0c4 and 3eb856d.

📒 Files selected for processing (1)
  • test/hermes-restart-config-seal-recovery.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/hermes-restart-config-seal-recovery.test.ts

📝 Walkthrough

Walkthrough

The PR adds deadline-bounded process inspection and identity-pinned shields takeover handling, switches gateway shutdown authorization from usernames to numeric UIDs, improves Hermes fixture permission cleanup, and adds fd to macOS CI dependencies and verification.

Changes

Shields takeover control flow

Layer / File(s) Summary
Deadline-bounded process inspection
src/lib/shields/timer-control.ts, src/lib/shields/timer-control.test.ts
Process inspection operations now share bounded deadlines; readProcessState and deadline helpers are exported and tested.
Exact shields-down takeover handling
src/lib/shields/index.ts
Forward-commit waiting and timed-out process-tree stopping now verify pinned identities and process states across bounded freeze and kill phases.
Takeover race and failure validation
src/lib/shields/flow.test.ts
Tests cover deterministic child readiness, takeover ordering, fail-closed stopping, lock retention, recovery PID reuse, and final-verification PID reuse.

Gateway UID authorization

Layer / File(s) Summary
UID-based gateway process selection
src/lib/tunnel/gateway-stop-script.ts
Identity-file validation and gateway PID discovery now use numeric UID ownership and UID-formatted ps output.
UID-based stop-script coverage
src/lib/tunnel/gateway-stop-script.test.ts, src/lib/tunnel/sandbox-gateway-stop.test.ts
Tests use numeric UID fixtures, race markers, mismatch cases, and UID-formatted ps assertions.

Hermes fixture permission cleanup

Layer / File(s) Summary
Peer traversal fixture lifecycle
test/helpers/hermes-restart-config-seal-fixture.ts, test/hermes-restart-config-seal-recovery.test.ts
Recovery tests temporarily enable peer traversal, handle permission-change failures, and restore parent directory permissions during teardown.

macOS dependency verification

Layer / File(s) Summary
fd installation coverage
.github/workflows/platform-vitest-main.yaml, test/platform-vitest-main-workflow.test.ts
The macOS Homebrew setup installs fd, and the workflow test verifies it.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ShieldsFlow
  participant waitForShieldsDownForwardCommit
  participant timer-control
  participant stopTimedOutShieldsDownTree
  participant ProcessIdentity
  ShieldsFlow->>waitForShieldsDownForwardCommit: await forward commit
  waitForShieldsDownForwardCommit->>timer-control: read exact process status
  timer-control->>ProcessIdentity: inspect identity and state
  waitForShieldsDownForwardCommit->>stopTimedOutShieldsDownTree: stop pinned owner
  stopTimedOutShieldsDownTree->>ProcessIdentity: enumerate and signal descendants
  ProcessIdentity-->>stopTimedOutShieldsDownTree: verified stop or kill status
Loading

Suggested labels: platform: macos, bug-fix

Suggested reviewers: cv

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the PR’s goal of fixing the remaining Platform Vitest failures.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-wsl-gateway-uid-match

Comment @coderabbitai help to get the list of available commands.

@github-code-quality

github-code-quality Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage remains at 96%, unchanged from the main branch.

TypeScript / code-coverage/cli

The overall coverage in the codex/fix-wsl-gatewa... branch remains at 80%, unchanged from the main branch.

Show a code coverage summary of the most impacted files.
File main 627154d codex/fix-wsl-gatewa... 3eb856d +/-
src/lib/hermes-dashboard.ts 95% 63% -32%
src/lib/messagi...tatus-health.ts 100% 79% -21%
src/lib/onboard...licy-presets.ts 100% 81% -19%
src/lib/messagi...l-validation.ts 77% 70% -7%
src/lib/onboard...shboard-port.ts 94% 89% -5%
src/lib/adapters/http/probe.ts 97% 94% -3%
src/lib/shields/index.ts 62% 63% +1%
src/lib/shields...nsition-lock.ts 89% 91% +2%
src/lib/messagi.../persistence.ts 86% 89% +3%
src/lib/adapter...shell/client.ts 83% 88% +5%

Updated July 15, 2026 17:24 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Advisor assessment: Informational / medium confidence
Next action: Review the warnings below.
Findings: 0 blockers · 1 warning · 0 suggestions
Status: Canonical ledger: 0 blocker(s), 1 warning(s), 0 suggestion(s).

Model lanes

  • GPT-5.6 Terra (primary): Completed · medium confidence · 0 blockers · 1 warning · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 0 blockers · 2 warnings · 0 suggestions
  • Model comparison: normalized findings differ; normalized E2E selections differ; Nemotron reported the same number of blockers, 1 more warning, the same number of suggestions.

Nemotron output stays in workflow artifacts and does not change the assessment above.

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: credential-sanitization, security-posture

3 optional E2E recommendations
  • shields-config
  • hermes-shields-config
  • tunnel-lifecycle
1 warning · 0 suggestions

Warnings

Warnings do not block.

PRA-1 Warning — Pin the newly added Homebrew runtime dependency

  • Location: .github/workflows/platform-vitest-main.yaml:100
  • Category: security
  • Problem: The macOS trusted CI lane now installs `fd` through `brew install bash coreutils fd gawk ripgrep`, which resolves the newly added tool from mutable Homebrew formula state. This differs from the workflow's pinned actions/container and hash-locked Python dependencies.
  • Impact: A changed or compromised Homebrew formula can alter the executable used by the trusted macOS test lane, reducing reproducibility and expanding the workflow supply-chain trust input.
  • Recommendation: Install `fd` from a versioned, integrity-verified source consistent with this workflow's existing pinned dependency controls, or otherwise constrain and verify the resolved artifact.
  • Verification: Inspect the macOS dependency-install step and confirm whether the `fd` formula version/artifact is constrained or verified after resolution.
  • Test coverage: Extend the workflow contract test to assert the selected `fd` installation mechanism includes the repository's chosen version/integrity constraint.
  • Evidence: .github/workflows/platform-vitest-main.yaml:100 adds `fd` to an unversioned `brew install` invocation. The same workflow pins action commits, uses an Ubuntu image digest, runs npm with lockfiles, and installs Python requirements with `--require-hashes`.

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
@cjagwani cjagwani changed the title fix(tunnel): compare gateway owners by uid fix(platform): close remaining Vitest main failures Jul 14, 2026
@wscurran wscurran added area: ci CI workflows, checks, release automation, or GitHub Actions area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery bug-fix PR fixes a bug or regression integration: hermes Hermes integration behavior labels Jul 14, 2026
@cv
cv marked this pull request as ready for review July 15, 2026 16:02

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/shields/timer-control.ts (1)

173-181: 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

ps -o lstart= is not a safe exact-identity fallback on macOS. readProcessStartIdentity() falls back to ps -o lstart=, which only yields second-level timestamps there. A PID reused within the same second can produce the same identity and slip past the exact-process checks that guard the shields takeover/restore paths. Treat this fallback as unverifiable on macOS or replace it with a collision-resistant process-start identity.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/shields/timer-control.ts` around lines 173 - 181, The
readProcessStartIdentity fallback using ps -o lstart= is not sufficiently
precise on macOS and must not be used as an exact identity there. Replace it
with a collision-resistant process-start identity or return it as unverifiable
on macOS, while preserving exact-process checks on supported platforms; update
the related coverage in src/lib/shields/flow.test.ts lines 678-717 to assert the
revised macOS behavior.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/shields/index.ts`:
- Around line 331-338: Update excludeRecoveryProcessTree and its caller to match
excluded processes using both PID and startIdentity rather than PID alone;
ensure recoveryTree entries retain and compare that identity. Preserve
fail-closed behavior when identity data is missing or mismatched, preventing PID
reuse from bypassing recovery-child exclusion.

In `@src/lib/shields/timer-control.ts`:
- Around line 13-19: Replace wall-clock timing with performance.now() for
processInspectionDeadline and remainingProcessInspectionTimeout in
src/lib/shields/timer-control.ts, and use the same monotonic source for handoff
polling in src/lib/shields/index.ts lines 230-234 and all freeze/kill deadlines
and comparisons in lines 269-375. Preserve bounded, fail-closed timeout behavior
consistently across every affected site.

In `@test/helpers/hermes-restart-config-seal-fixture.ts`:
- Around line 98-103: Make allowRestartFixturePeerTraversal failure-atomic by
restoring the original parent directory mode if either permission update fails.
In test/hermes-restart-config-seal-recovery.test.ts lines 29-30 and 329-330,
invoke this helper within try/finally, conditionally execute the returned
teardown callback, and ensure cleanup remains registered even when setup throws.

---

Outside diff comments:
In `@src/lib/shields/timer-control.ts`:
- Around line 173-181: The readProcessStartIdentity fallback using ps -o lstart=
is not sufficiently precise on macOS and must not be used as an exact identity
there. Replace it with a collision-resistant process-start identity or return it
as unverifiable on macOS, while preserving exact-process checks on supported
platforms; update the related coverage in src/lib/shields/flow.test.ts lines
678-717 to assert the revised macOS behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6cd8d0a3-1be4-4a9c-8201-aaff98598b8c

📥 Commits

Reviewing files that changed from the base of the PR and between 4f64b0a and c31027e.

📒 Files selected for processing (10)
  • .github/workflows/platform-vitest-main.yaml
  • src/lib/shields/flow.test.ts
  • src/lib/shields/index.ts
  • src/lib/shields/timer-control.ts
  • src/lib/tunnel/gateway-stop-script.test.ts
  • src/lib/tunnel/gateway-stop-script.ts
  • src/lib/tunnel/sandbox-gateway-stop.test.ts
  • test/helpers/hermes-restart-config-seal-fixture.ts
  • test/hermes-restart-config-seal-recovery.test.ts
  • test/platform-vitest-main-workflow.test.ts

Comment thread src/lib/shields/index.ts
Comment thread src/lib/shields/timer-control.ts
Comment thread test/helpers/hermes-restart-config-seal-fixture.ts
Signed-off-by: Carlos Villela <cvillela@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/shields/timer-control.test.ts`:
- Line 13: Update the test title in the “remain bounded when the wall clock
moves backward” case to append the applicable owning issue or PR reference as
the final suffix, following the repository’s parenthesized format such as
“(`#6829`)”.

In `@test/hermes-restart-config-seal-recovery.test.ts`:
- Around line 33-36: Update the chmodSync spy setup in the test to remove the
chmodCalls counter and conditional branch. Use chained mockImplementationOnce
calls so the first invocation delegates to realChmodSync and only the second
invocation throws the fixture chmod failure, preserving the existing test
behavior without adding an if statement.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a2c2f251-8e93-4896-8576-6e916ae57cb3

📥 Commits

Reviewing files that changed from the base of the PR and between c31027e and 032e0c4.

📒 Files selected for processing (6)
  • src/lib/shields/flow.test.ts
  • src/lib/shields/index.ts
  • src/lib/shields/timer-control.test.ts
  • src/lib/shields/timer-control.ts
  • test/helpers/hermes-restart-config-seal-fixture.ts
  • test/hermes-restart-config-seal-recovery.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • test/helpers/hermes-restart-config-seal-fixture.ts
  • src/lib/shields/timer-control.ts
  • src/lib/shields/index.ts
  • src/lib/shields/flow.test.ts

vi.restoreAllMocks();
});

it("remain bounded when the wall clock moves backward", () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the issue reference to the test title.

Append the owning issue or PR reference as a final suffix, for example (#6829) if applicable, to satisfy the repository’s test-title guideline.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/shields/timer-control.test.ts` at line 13, Update the test title in
the “remain bounded when the wall clock moves backward” case to append the
applicable owning issue or PR reference as the final suffix, following the
repository’s parenthesized format such as “(`#6829`)”.

Source: Coding guidelines

Comment thread test/hermes-restart-config-seal-recovery.test.ts Outdated
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv merged commit febf08d into main Jul 15, 2026
88 of 89 checks passed
@cv
cv deleted the codex/fix-wsl-gateway-uid-match branch July 15, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci CI workflows, checks, release automation, or GitHub Actions area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery bug-fix PR fixes a bug or regression integration: hermes Hermes integration behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants