Skip to content

fix: support host-confined Windows workers and private state ownership - #1257

Merged
willkill07 merged 2 commits into
NVIDIA:release/0.10from
bbednarski9:bbednarski/windows-worker-private-state-backport
Oct 7, 2026
Merged

willkill07 merged 2 commits into
NVIDIA:release/0.10from
bbednarski9:bbednarski/windows-worker-private-state-backport

Conversation

@bbednarski9

@bbednarski9 bbednarski9 commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

Windows hosts that prohibit Job Object breakaway currently reject daemon worker startup even when the worker could run safely inside the enclosing job. Separately, private files created by LocalSystem can inherit Administrators as their owner and fail Relay's subsequent process-user ownership checks.

Allow host-confined workers and explicitly assign private file ownership to the process user, while preserving job confinement and private access checks.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

  • Prefer worker breakaway when available; otherwise retain the worker in the enclosing Windows job and emit a categorical lifetime warning only after successful creation and confirmed child job membership. Preserve handle whitelisting and cleanup when job-membership verification fails.
  • Set the private Windows security descriptor owner to the process user's SID. Reuse the existing SID lookup for creation and ownership validation; retain the protected Owner Rights and SYSTEM DACL.
  • Update the restrictive-job regression to require successful worker startup and verify that the worker remains confined, a failed launch emits no lifetime warning, and a successful confined launch emits exactly one JSONL warning. Document that host shutdown can terminate a confined worker and require reactivation.

Validation:

  • The restrictive-job and private atomic-write regressions passed on Windows for the validated patch; the private-file test also passed under LocalSystem.
  • Fresh runtime probes remained ready for all 36 samples before and after a daemon restart; post-reboot client runs maintained worker readiness.
  • The prior canonical just test-rust run completed with 5,598 passes and one failure in the Pi workspace symlink fixture. This was not an entirely passing suite. macOS regression validation has not been run.
  • On current upstream main, the restrictive-job regression and private atomic-write regression each passed (one test each). Formatting and staged whitespace checks passed. Staged hygiene and copyright checks passed. The Clippy hook reported existing Windows findings in unchanged resource-metrics tests, generation handling, plugin lifecycle handling, and managed-daemon tests. Workspace cargo check, the documentation link check, and uv audit passed. The complete hook run was not green: cargo-deny is unavailable, and npm audit cannot parse a Pi workspace package.json symlink checked out as target text on Windows. No dependency or symlink changes are included in this PR.
  • Review follow-up: the strengthened Windows regression and operational logging contract test each passed. Formatting, copyright and workspace cargo check passed. The repeated hook run retains the above Clippy/tooling/Pi fixture gaps; the documentation linkcheck also encountered a remote connection reset (Windows error 10054) for an unchanged Apple documentation link in docs/daemon/macos.mdx, after the earlier linkcheck had passed.

Where should the reviewer start?

Start with spawn_with_handle_list in crates/cli/src/process/detached.rs and worker_starts_without_escaping_restrictive_external_parent_job in crates/cli/tests/coverage/daemon/mcp_tests.rs. Then review the explicit owner in with_private_windows_descriptor in crates/cli/src/filesystem/atomic.rs; the existing private atomic-write regression covers the write/rewrite ownership checks.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • Relates to: none

Summary by CodeRabbit

  • New Features

    • Windows workers can now start even when the host environment prevents them from running independently. In that case, they remain tied to the host’s lifetime and may stop when it closes.
    • The system reports when a worker’s lifetime is limited. Routes may need to be reactivated after the broker’s recovery period if workers stop.
  • Documentation

    • Updated Windows worker guidance to explain behavior when breakaway from the host job is unavailable.

Signed-off-by: Bryan Bednarski <[email protected]>
(cherry picked from commit 25973ea)
Signed-off-by: Bryan Bednarski <[email protected]>
Signed-off-by: Bryan Bednarski <[email protected]>
(cherry picked from commit dc46f53)
Signed-off-by: Bryan Bednarski <[email protected]>
@bbednarski9
bbednarski9 requested review from a team as code owners October 7, 2026 21:58
@github-actions github-actions Bot added size:S PR is small Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code labels Oct 7, 2026
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/NeMo-Relay/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: bb8f0f9a-1e8e-4576-b438-e4f498f456f0
📥 Commits

Reviewing files that changed from the base of the PR and between 57dc6bf and 5ebb26f.

📒 Files selected for processing (5)
  • crates/cli/src/filesystem/atomic.rs
  • crates/cli/src/process/detached.rs
  • crates/cli/tests/coverage/daemon/mcp_tests.rs
  • docs/daemon/reference.mdx
  • docs/reference/migration-guides.mdx

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (14)
  • GitHub Check: Rust / Package (windows-amd64)
  • GitHub Check: Rust / Package (windows-arm64)
  • GitHub Check: Rust / Package (linux-amd64)
  • GitHub Check: Rust / Package (macos-arm64)
  • GitHub Check: Rust / Package (linux-musl-amd64)
  • GitHub Check: Rust / Package (linux-arm64)
  • GitHub Check: Rust / Test (windows-amd64)
  • GitHub Check: Rust / Test (linux-amd64)
  • GitHub Check: Rust / Test (linux-arm64)
  • GitHub Check: Rust / Package (linux-musl-arm64)
  • GitHub Check: Rust / Test (windows-arm64)
  • GitHub Check: Rust / Test (macos-arm64)
  • GitHub Check: Check / Run
  • GitHub Check: Preview docs
🧰 Additional context used
📚 Code guidelines (4)
.agents/skills/contribute-docs/SKILL.md — configured
.agents/skills/review-doc-style/SKILL.md — configured
.agents/skills/prepare-code-freeze/SKILL.md — configured
.agents/skills/draft-release-notes/SKILL.md — configured
📓 Path-based instructions (6)
Review documentation for technical accuracy against the current API, command correctness, and consistency across language bindings.

⚙️ CodeRabbit configuration file

Files:

  • docs/daemon/reference.mdx
  • docs/reference/migration-guides.mdx
Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.

⚙️ CodeRabbit configuration file

Files:

  • crates/cli/tests/coverage/daemon/mcp_tests.rs
Source excerpt: In MDX files, top-of-file comments must use JSX comment delimiters: `{/*` to open and `*/}` to close.

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Files:

  • docs/daemon/reference.mdx
  • docs/reference/migration-guides.mdx
Source excerpt: Verify MDX files use JSX delimiters for top-of-file SPDX comments.

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)

Files:

  • docs/daemon/reference.mdx
  • docs/reference/migration-guides.mdx
Source excerpt: Search documentation source for references to the old version and update current-version install commands, package examples, and configuration examples to `` where appropriate: Review matches before changing th...

📄 CodeRabbit inference engine (.agents/skills/prepare-code-freeze/SKILL.md)

Files:

  • docs/daemon/reference.mdx
  • docs/reference/migration-guides.mdx
Source excerpt: Preserve MDX front matter and the JSX SPDX comment.

📄 CodeRabbit inference engine (.agents/skills/draft-release-notes/SKILL.md)

Files:

  • docs/daemon/reference.mdx
  • docs/reference/migration-guides.mdx
🔇 Additional comments (2)
crates/cli/src/filesystem/atomic.rs (1)

305-306: LGTM!

Also applies to: 310-330, 355-355, 371-384, 414-414

crates/cli/src/process/detached.rs (1)

201-201: LGTM!

Also applies to: 286-286, 312-312, 326-333, 414-414


Walkthrough

The Windows security descriptor now sets its owner to the current user. Windows worker launches proceed when a host Job Object prevents breakaway, and log a warning if the child remains in a job. Tests and documentation cover the updated behavior.

Changes

Windows file ownership

Layer / File(s) Summary
Current-user SID and security descriptor
crates/cli/src/filesystem/atomic.rs
A shared helper supplies the current-user SID for file-owner comparison and the private security descriptor’s owner. The descriptor retains its protected full-access entries for the current user and LocalSystem.

Windows worker breakaway

Layer / File(s) Summary
Launch with preferred breakaway
crates/cli/src/process/detached.rs
The launcher proceeds when breakaway is unavailable. If the child remains in a job, it logs a warning that identifies the restriction reason. A failed job-status query still triggers an error and cleanup.
Validate and document host-scoped workers
crates/cli/tests/coverage/daemon/mcp_tests.rs, docs/daemon/reference.mdx, docs/reference/migration-guides.mdx
Windows tests check host-scoped launches and lifetime-limited events. Documentation describes activation inside the host job and possible route reactivation after the host closes.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant WorkerLauncher as spawn_with_handle_list
  participant Windows as Windows process and job APIs
  participant RelayLogger as Relay logger
  WorkerLauncher->>Windows: Create child with preferred breakaway
  Windows-->>WorkerLauncher: Return child process
  WorkerLauncher->>Windows: Check child job membership
  Windows-->>WorkerLauncher: Child remains in a job
  WorkerLauncher->>RelayLogger: Log warning with job restriction reason
Loading

Merge Risk: ⚪ Minimal · up to 5ebb2

Windows workers now start inside a host job when breakaway is blocked, and private files are explicitly owned by the process user. No concrete merge-blocking risk was identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 3 files. (2 skipped: 2…
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.
Title check ✅ Passed The title follows Conventional Commits format, uses the allowed lowercase type "fix", states the main changes, remains under 72 characters, and has no trailing period.
Description check ✅ Passed The description includes the required Overview, Details, reviewer guidance, and Related Issues sections. It also documents implementation scope, validation results, known limitations, and test failure…
✨ Finishing Touches 💡 1
🧪 Generate unit tests (beta)
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@willkill07 willkill07 changed the title fix: backport Windows worker and private state fixes to 0.10 fix: support host-confined Windows workers and private state ownership Oct 7, 2026
@willkill07
willkill07 enabled auto-merge (squash) October 7, 2026 22:00
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

@willkill07 willkill07 added this to the 0.10 milestone Oct 7, 2026
@willkill07
willkill07 merged commit 2d1e4b1 into NVIDIA:release/0.10 Oct 7, 2026
102 of 114 checks passed
willkill07 added a commit that referenced this pull request Oct 7, 2026
#### Overview

Fix Windows Codex hooks failing to execute, which leaves sub-agent and
collaboration tool scopes missing from ATOF traces. Codex runs hooks
through its session shell, which defaults to PowerShell on Windows;
Relay currently generates cmd.exe syntax.

- [x] I confirm this contribution is my own work, or I have the right to
submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does
not duplicate existing work.

#### Details

- Generate Windows Codex hook commands as encoded PowerShell scripts
with literal argument quoting, including ASCII and smart apostrophes.
- Stop on invocation errors so a missing Relay executable fails instead
of reporting success.
- Preserve the Relay exit code through both PowerShell layers, including
code 2 used for hook denials.
- Exercise argument paths with spaces, Unicode, apostrophes and shell
characters, stdin forwarding, stdout/stderr, native exit codes and a
missing executable in PowerShell 5 and 7.
- Run PowerShell 7 regressions only when installed, and decode
PowerShell literals correctly in test assertions.
- Keep other agents' command rendering unchanged. No public API or
breaking changes.

Validation:

- `just test-rust` and `uv run pre-commit run` passed on this branch.
- Native Windows regressions passed on `x1carbon` in PowerShell 5 and 7
using cross-compiled Rust binaries and the repository's native hook
fixture.
- Real Codex 0.160.1 runs against a deterministic localhost Responses
provider spawned one and three sub-agents. ATOF contained all expected
sub-agent and collaboration tool scopes, child model calls had correct
parentage, and every scope closed.
- Windows end-to-end validation used PR #1256's inspected head plus the
original Codex hook fix. Follow-up review fixes were validated with
native Windows execution tests in PowerShell 5 and 7, including a run
with PowerShell 7 absent from PATH. The worker fix's release backport is
tracked separately in #1257 and is excluded from this PR.
- Python and Node binding suites were not run because their contracts
are unchanged.

#### Where should the reviewer start?

Start with `render_hook_command` in `crates/cli/src/hooks/encoding.rs`,
particularly literal PowerShell argument encoding and exit-code
propagation. Then review the Windows execution regressions in
`crates/cli/tests/coverage/agents/plugin_host_tests.rs`.

#### Related Issues: (use one of the action keywords Closes / Fixes /
Resolves / Relates to)

- Fixes
[RELAY-1000](https://linear.app/nvidia/issue/RELAY-1000/nemo-relay0100-rc3windowscodex-sub-agent-and-collaboration-tool-scopes).
- Relates to #1244, which addressed Windows hook trust; this fixes the
remaining hook command execution failure.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Improved Windows hook execution for Codex in PowerShell and PowerShell
7. Hook commands now handle paths containing spaces, special characters,
apostrophes, smart quotes, and Unicode while preserving input, output,
and exit codes.
  * Missing hook relays now report an error and return a failure code.
* Claude Code and pi continue using their existing hook command
behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Will Killian <[email protected]>

This branch was previously deployed

1 inactive deployment
fern — 5ebb26f1 Deployed Oct 7, 2026 by willkill07 via Clean up docs preview #5511
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code size:S PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants