Skip to content

feat(fleet): start a relay session on a Windows lane in the target's plugin profile - #16631

Merged
kyle-sexton merged 5 commits into
mainfrom
feat/16605-windows-relay-profile
Nov 16, 2026
Merged

kyle-sexton merged 5 commits into
mainfrom
feat/16605-windows-relay-profile

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Closes #16605

Summary

A session the fleet relay starts on a Windows lane (R1, R3, R6) can now start in the target's plugin profile. #16601 covered WSL lanes and left Windows lanes out because profiles.mjs launch prints a POSIX env -u … claude line.

Fix

plugins/fleet/skills/reach/reference/relay.md, "Start in the target's plugin profile", new subsection "On a Windows lane (R1, R3, R6)". One PowerShell script goes on stdin, as a quoted heredoc, to powershell.exe -NoProfile -Command - from <win-dir>. Only PowerShell parses it. The prompt stays out of it: a first call writes it to a file, which the script feeds to claude.exe (see Review round 2). The script follows the machine-health wrapper's pattern (plugins/machine-health/skills/setup/templates/monthly-run.ps1, #16590):

  1. Finds profiles.mjs through claude.exe plugin list --json, taking the enabled plugin-profiles@ entry's installPath.
  2. Runs node …/scripts/profiles.mjs launch <profile> --folder $PWD.Path --unattended --json --with <settings file>.
  3. Walks argv: each name after -u is removed with Remove-Item Env: (no env), and the words after claude go to claude.exe with the verb's arguments.

The relay's own settings go to --with as a file. Windows PowerShell 5.1 strips the inner double quotes from a JSON argument to a native program: on R1, '{"crossSessionInbound":"accept"}' reached node as {crossSessionInbound:accept}. The section points at about_PowerShell_exe: -Command, read live this session, which says stdin input "is parsed and executed one statement at a time". A new eval case, reach-start-in-profile-windows, covers the Windows profile path.

Done-when, item by item:

  • The relay section covers a Windows lane: finds profiles.mjs on the target, runs launch … --unattended --json, clears the variables argv names without env, and starts claude.exe with the remaining arguments.
  • With no profile named (the section's shared paragraph), or no enabled plugin-profiles (or no node) on the target, a Windows start behaves as today and prints that the profile was not applied.
  • An unattended start whose profile needs a missing required tool starts nothing: the script prints "not started", exits 1, and the reason launch printed is reported.
  • Tried on a real Windows lane in parts; the section says it is untested on a live hop. The Verified-behavior row records what ran.
  • Eval cases cover the Windows profile path: reach-start-in-profile-windows.

Not delivered

  • No relay turn has been started in a profile on a real Windows lane. plugin-profiles is not installed on the laptop's Windows lane, and a -p start needs a sign-in. The section and the Verified-behavior row say the route is untested on a live hop.
  • R3 and R6, through another machine's sshd, were not run. Whether node resolves in that session's Windows environment is not checked; with no node, the script starts without the profile and says so.

Review round 2

  • Prompt handling. The prompt no longer goes into the script text.
    • A first call writes it to <win-dir>/relay-prompt-<name>.txt, quoted as the WSL rows quote a prompt.
    • The script starts claude.exe through Start-Process, with each argument quoted by Q (the Microsoft C runtime's argument rules, which the section points at). A -p prompt arrives on stdin through -RedirectStandardInput; a --bg prompt arrives as one Q-quoted argument, since claude.exe --help (2.1.325) shows no stdin or file prompt for a background start.
    • The file is removed after the start.
    • This closes three routes: a curly quote ending a PowerShell string, a prompt line PS ending the heredoc, and a blank line ending the -Command - input.
    • The security lane's curly-quote claim was confirmed on R1: inside PowerShell 5.1, Invoke-Expression "'a’ + ’b'" returned ab.
  • R1 form. The section now shows R1's two lines (a local printf … > and cd <win-dir> && …powershell.exe -NoProfile -Command - <<'PS') in place of "drop the ssh part".
  • Evals. Four graders were added, each with pass and fail samples:
    • says-profile-not-applied
    • launch-refusal-stops
    • prompt-from-file
    • no-prompt-in-script (fails a literal prompt piped to $claude)

Verification

Live on R1 (melo-lap-001's Windows lane; Windows PowerShell 5.1; Claude Code 2.1.325; no agent started):

  • -Command - ran the heredoc script.
  • claude.exe plugin list --json parsed 186 plugins, none of them plugin-profiles@, so the not-installed branch started claude.exe --settings <file> --version.
  • A --dry-run launch through Windows node, of this branch's profiles.mjs on the \\wsl.localhost path, exited 0. Walking its argv left claude --settings C:\…\sessions\…json, and Remove-Item Env: cleared PLUGIN_PROFILES_SESSION.
  • Forward-slash paths resolved both claude.exe and profiles.mjs.
  • Review round 1, Codex P1 on the plugin-list filter. This was confirmed on R1 (Windows PowerShell 5.1.26100) with a two-entry JSON array whose second entry is plugin-profiles@x, enabled:
    • Piped as ConvertFrom-Json | Where-Object, the filter matched nothing.
    • With the conversion parenthesized, (… | ConvertFrom-Json) | Where-Object, it matched the plugin-profiles@x entry.
    • The script now uses the parenthesized form. The new eval grader array-enumerated-before-filter fails the old form.
  • Review round 2, on R1, with a 60-byte prompt file holding ', ’, ", " --version ", a blank line and a line PS (SHA-256 cc82aea7…):
    • With node standing in for claude.exe, Start-Process -RedirectStandardInput delivered stdin with the same SHA-256 and length.
    • The --bg form's last argument, quoted by Q, had the same SHA-256, and " --version " stayed inside it.
    • --settings 'C:\a b\f.json' arrived as two arguments.
    • The exact documented script (with --version in place of -p -n <name>) printed the not-applied line, started claude.exe from the file (exit 0) and removed the file.
    • No agent started; the probe files were removed.
  • Review round 1, Codex P1 on restated behavior: the two upstream-behavior explanations are now section-anchored pointers (about_Parsing: Passing arguments that contain quote characters and about_PowerShell_exe: -Command), each with when to fetch it. scripts/check-as-of-recheck.sh --check exits 0.

Offline checks:

  • validate-cases.py plugins/fleet/evals: exit 0, no FAIL. Every grader in the new case accepts its pass samples and rejects its fail samples.
  • The pre-push hooks passed. The first push was refused by the check-affected hook's portability check for a \b in \.local\bin\; the paths now use forward slashes.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_015XWwmchG8Tg8XKYxMrgKKq

kyle-sexton and others added 2 commits November 16, 2026 15:09
…plugin profile

One PowerShell script on stdin to powershell.exe -Command - finds
profiles.mjs through claude.exe plugin list --json, runs launch
--unattended --json, removes each variable argv names after -u, and starts
claude.exe with the rest of argv. The relay's own settings go to --with as a
file, since Windows PowerShell 5.1 strips the quotes from a JSON argument.

Closes #16605

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmchG8Tg8XKYxMrgKKq
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 16, 2026 20:11
@kyle-sexton

Copy link
Copy Markdown
Member Author

Owner: the session plugin-profiles-build-6, working for the control-hub session "Plugin Presets". Ready steps: branch current with main (head ffb28e3); code and security review left to their CI lanes (both healthy); tests run locally (eval-suite validator exit 0, pre-push check-affected passed, the Windows script's parts run on a real Windows lane as the body records). Review findings go through Plugin Presets.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T20:14:07.367507Z ffb28e3 Draft marked ready
ℹ️ 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ffb28e3dbc

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions github-actions 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.

claude-security-review: 2 inline finding(s) on 0237d8398ed6cf53ae0d8e71e844cd92014645ce; the summary is in this lane's pull request comment.

claude-lane: claude-security-review

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 81dec1cbc45c8e55d9f2041b2e08ccd0e1d15fd1: read 13 of 13 changed file(s); 0 finding(s), 0 as inline comments.

Security review (incremental): PR #16631, 0237d839..81dec1cb

I read every hunk of the 13 files in the incremental scope: relay.md and 12 eval files for reach-start-in-profile-windows. None of them is a trusted path. The change touches no workflow, action, token request, trusted-actor list, merge hold, kill switch or plugin manifest. This lane already reviewed an earlier head (blocking only: yes), so this review reports only CRITICAL and IMPORTANT findings.

I found no CRITICAL or IMPORTANT security issues in this push.

Earlier findings, now fixed. The owner resolved both of this lane's earlier threads, and the lines under them are unchanged since resolution. I still read the new code and checked that both injection routes are gone:

  • Prompt in the script text (relay.md L251–269). The prompt no longer goes into the PowerShell heredoc. A first call writes it to <win-dir>/relay-prompt-<name>.txt. Over R3, printf runs locally and its output is piped to cat over ssh, so the prompt never appears on the remote command line. The -p form gives it to claude.exe on stdin via Start-Process -RedirectStandardInput. That rules out three earlier risks:

    • a curly quote ending a string;
    • a line PS closing the heredoc;
    • a blank line ending the -Command - input.
  • Argument splitting. Each argument now goes through Q (L254), which follows the Microsoft C runtime rules:

    • backslash runs before a " are doubled, and the " becomes \";
    • trailing backslashes are doubled;
    • the result is wrapped in "…".

    Start-Process -ArgumentList passes the joined string to claude.exe as its command line. A " in the prompt can therefore no longer split it into extra claude.exe flags in the --bg form (L293–295).

Considered and dropped (below the blocking bar). In the --bg form the prompt is one Q-quoted argument with no -- before it. A prompt whose whole text is an option, such as --dangerously-skip-permissions, could still be read as a flag. Two things keep this low. The operator's own session writes the prompt, and this push gives no pull-request, issue or comment author a way to reach it. And only a prompt made of a single option word works this way, which ordinary prose isn't. That makes it a SUGGESTION at most, so this blocking-only review does not post it.

Instruction surface. The diff removes the rule "the prompt rides inside it as a single-quoted PowerShell string (each ' doubled)". The prompt-from-file mechanism replaces it and enforces the same protection more strongly, so this is not a finding. I judged the removed rule by what happens without it; I did not consult the instruction-exception register.

Eval files. The four new regex graders and the refreshed pass/fail samples are test data with no execution surface.

Spend (not a finding, no hold). The four added regex graders run inside the existing eval case's runs, which are paid from prepaid API credits. They add no new runs.

critical-findings: 0

@github-actions github-actions 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.

claude-review: 2 inline finding(s) on 0237d8398ed6cf53ae0d8e71e844cd92014645ce; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 81dec1cbc45c8e55d9f2041b2e08ccd0e1d15fd1: read 13 of 13 changed file(s); 0 finding(s), 0 as inline comments.

Code review: incremental pass on #16631 (closes #16605), blocking findings only

This lane already reviewed an earlier head (0237d83), so this pass reports blocking findings only and leaves out advisory ones. I read all 13 files in .claude-lane/incremental.diff, covering every hunk.

Result: no blocking findings.

What changed since 0237d83

  • No prompt in the script. The Windows-lane script in relay.md no longer puts the prompt into its own text.
    • A first call writes the prompt to <win-dir>/relay-prompt-<name>.txt.
    • claude.exe then starts through Start-Process -RedirectStandardInput $p -NoNewWindow -Wait -PassThru, every argument quoted by Q.
    • The script removes the prompt file on both the "not started" path and the normal path.
  • Q quoting. Q doubles each run of backslashes before a " and escapes the ", and it doubles trailing backslashes. Reading the code, that matches the Microsoft C runtime rules.
  • Argument list. The comma operator binds tighter than +, so @($a) + '-p', '-n', '<name>' concatenates the two arrays as intended.
  • Not-applied branch. It now falls through to the same Start-Process line with $a = @('--settings', $s).
  • Refused launch. The $ok -and $LASTEXITCODE guard still stops the script and exits 1.
  • R1. It now shows the two local calls in full with the command unquoted, which resolves the earlier R1-wording finding.
  • New graders. says-profile-not-applied, launch-refusal-stops, prompt-from-file and no-prompt-in-script each have a pass sample and a fail sample. I checked each regex against its samples by reading them; I did not run any:
    • each pass sample matches its grader;
    • each fail sample has the guarded behavior removed and does not match.

Earlier findings

  • All three of this lane's earlier findings were fixed in this push, and the owner resolved them; their lines have not changed since:
    • the R1 wording;
    • the missing graders for two of the closing issue's criteria;
    • the --bg prompt passed as a native argument.
  • The two settled threads from the earlier round stay settled.

Closing issue #16605

  • Its criteria are still met.
  • The two criteria that had no grader before ("says the profile was not applied" and "a refused launch starts nothing") now have one each.
  • The Verified-behavior row's new SHA-256 and Start-Process measurements are the author's claim; I did not run them.

Inputs

  • I found no embedded instructions in the PR context, settled-threads or prior-findings files.

I reviewed without subagents, so no verifier ran. Verifier dropped 0 of 0 candidates.

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-refine/fix-docs
Model rung 0
Leg handoff
Run job success
Activity step success
Commits pushed none (read lane)
Run 43953358685

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit ed58af7 Nov 16, 2026
89 of 90 checks passed
@kyle-sexton
kyle-sexton deleted the feat/16605-windows-relay-profile branch November 16, 2026 21:12
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Start a fleet relay session on a Windows lane in a plugin profile

1 participant