Skip to content

feat(plugin-profiles): launch each session with its plugin profile - #16523

Merged
kyle-sexton merged 9 commits into
mainfrom
feat/launch-with-profile
Nov 16, 2026
Merged

kyle-sexton merged 9 commits into
mainfrom
feat/launch-with-profile

Conversation

@kyle-sexton

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

Copy link
Copy Markdown
Member

Closes #16512

Summary

Sessions that share one folder can now each run in their own plugin profile. Every launch site starts its session through one command, plugin-profiles launch, which writes the one-session settings file for the folder and profile and prints the claude --settings command. A phase change is a relaunch. The in-session /plugin-profile switch stays for folders with one session.

Fix

One source of truth: profiles.mjs launch [<name>] [--folder <dir>] [--with <settings>] [--unattended] [--json]

  • Writes one session file per folder and profile (D19), rewritten on every launch, and changes no settings file. apply --for session uses the same per-folder file.
  • With no name it takes the session's own profile (PLUGIN_PROFILES_SESSION), else the folder's recorded one (D20). With neither, the command carries no profile.
  • The printed command always starts env -u PLUGIN_PROFILES_SESSION -u PLUGIN_PROFILES_SESSION_FILE claude, so a launcher never passes on an inherited marker (D21). That clear lives in this one place; the lanes launcher's no-profile prefix is the same words.
  • Each session file sets PLUGIN_PROFILES_SESSION_FILE to its own path, so status names the file a session was started with, merged or not. status reads it only when the marker is set.
  • launch works from any surface: the session it starts is a CLI session.
  • apply still requires --for.
  • --with takes a launcher's own settings (a JSON object or a file) and writes one file holding both, keyed by folder, profile and a hash of the merged content. claude keeps only the last --settings (probe 2 below), so two flags cannot work.
  • Cleanup: a session file no launch has written for 30 days is removed by the next launch.
  • --unattended stops (exit 1, nothing written) when the profile switches on a plugin missing a required prerequisite (D23). An attended launch prints it and goes ahead.
  • status prints "Start another session here in this profile with: ..." (the launch command). This was defect 1: the handoff reference asked for a restore entry that status did not print.

Launch sites

  • session-flow continue-in-background: claude --bg takes its words from launch when the profile skill is available; --cloud cannot carry a settings file, and the launch report says so.
  • session-flow handoff: the claude --resume line carries --settings "<file>" (save_point.py new --settings-file). On a phase change, --start-command adds a line above the copy line telling the user to exit and start the next session with the next profile's command. The copy line itself is unchanged, because /session-flow:find-handoff and the hop-chain harness key on it.
  • harness-ops lanes: a per-lane profile field. The launcher finds the enabled plugin-profiles through claude plugin list --json, runs launch --unattended --json with the lane's settings as --with, and starts the lane with its argv. A refused profile skips that lane with an error; other lanes launch. On restart, the refusal is checked before the running lane is stopped, for the folder the relaunch uses (a local-background lane's linked worktree); a cloud lane, which carries no profile, skips that check. With plugin-profiles absent, the lane launches as today with a warning. Every lane launch clears an inherited marker. A cloud lane warns that the profile is not applied. restart-consumer.sh relaunches through the launcher, so it gets the same handling.
  • work-items work-loop: the launching session takes its words from launch --unattended.
  • Each site falls back to today's behavior when plugin-profiles is not enabled.

Sites left alone

  • fleet reach and its relay: its local hops (R1 WSL to Windows, R4 Windows to WSL) cross the WSL boundary, and only variables in WSLENV cross it (here WT_SESSION:WT_PROFILE_ID:), so no marker leaks there. Starting a remote session in the remote's profile needs the remote's profiles.mjs path, which the skill has no source for today; the natural source is the per-lane paths FLEET.md already renders from dotfiles, which is outside this repository.
  • machine-health setup: the scheduled run's claude argv is built in templates/monthly-run.ps1 (lines 43 and 59) under Windows Task Scheduler, whose /tr is capped at 262 characters, and the launch argv starts with env, which Windows lacks. It needs its own small design (an argv file the wrapper reads), not a skill-text change.

Not covered: a cloud lane whose cloud launch is refused falls back to a local launch, and that launch can still hit the missing-prerequisite stop after restart has already stopped the running lane.

Defects

  • Defect 2: worktree creation copies .claude/settings.local.json with its profile entries, but the record is keyed by the file's real path. When a linked worktree's file has no record, plugin-profiles now finds the main worktree from the files git writes (no git process), and adopts a copy of its record when the file still holds every entry that record wrote (entries a deferred switch has not yet written are skipped, as status skips them).
  • D22: /plugin-profile's confirmation names the other live sessions in the folder, read from claude agents --json (lib/sessions.mjs), and still applies on Apply.

Verification

Probes, Claude Code 2.1.325, interactive tmux sessions, 2026-11-16:

  1. Marker leak: from the Bash tool of a session started with claude --settings <file setting PLUGIN_PROFILES_SESSION>, a claude --bg child had no PLUGIN_PROFILES_SESSION in its process environment (/proc/<pid>/environ); in it, status reported no session profile and a --defer-off dry run was not refused. The background supervisor spawns the child. A direct child (claude started from that Bash tool) does inherit the whole environment. The clear stays at every site, per D21: a --bg launch that must first start the supervisor from a profiled shell was not probed.
  2. Two --settings flags: accepted without error; the last wins wholly. With a.json then b.json, only b's env values were set; in reverse order, only a's.

Observations, not acted on: a --bg child did not take the parent's --model (it ran the default model); a direct child took the parent's session name and bridge session id over its own --name.

Tests:

  • plugins/plugin-profiles/scripts/profiles.test.mjs: 80 pass (launch, merge, cleanup, unattended stop, status line and merged-file path, both variables cleared, any surface, apply needs --for, worktree record adoption, othersInFolder).
  • plugins/plugin-profiles/lib/sessions.test.sh: 2 pass.
  • claude plugin test plugins/plugin-profiles (mod): 17 pass, one new for D22.
  • plugins/session-flow/scripts/tests/test_save_point.py: 298 pass.
  • plugins/harness-ops/skills/lanes/scripts/lane-launcher.test.sh: PASS (with the restart preflight and cloud-lane restart cases); restart-consumer.test.sh: 213 cases, 0 failures.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo

kyle-sexton and others added 5 commits November 16, 2026 02:12
…a profile

launch writes the one-session file for a folder and profile and prints the
claude command that starts a session in it. It clears an inherited
PLUGIN_PROFILES_SESSION, merges a launcher's own settings through --with
(claude keeps only the last --settings), stops an unattended launch whose
profile misses a required prerequisite, and removes session files no launch
has written for 30 days. status prints the launch command for the profile
in force, which a handoff uses as its restore line.

Refs: #16512

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
… a worktree's copied record

The /plugin-profile confirmation names the other live sessions in the
folder, read from claude agents --json, and still applies on Apply.

A linked worktree whose .claude/settings.local.json was copied from the
main worktree now takes a copy of the main worktree's profile record when
the file still holds every entry the profile wrote, so status, the
session-start notice, clear and launch see the profile there.

Refs: #16512

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
When the profile skill is available, the session that launches the work
loop takes its start words from the plugin-profiles launch command and
launches nothing when that stops on a missing required prerequisite. The
skill cheat sheet lists the profile skill's launch action.

Refs: #16512

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
…ugin profile

continue-in-background takes its start words from the plugin-profiles
launch command when that plugin is enabled; a cloud launch says it starts
without the profile. The handoff resume line carries --settings for the
session's profile file, and a phase change adds a line above the
unchanged copy line telling the user to exit and start the next session
with the next profile's command. The restore entry is the launch line
status prints.

Refs: #16512

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
A lane's profile field starts it through the plugin-profiles launch
command, with the lane's settings merged into the profile's session file.
A refused profile skips that lane, and restart checks the refusal before
it stops the running lane. Without plugin-profiles the lane launches as
today with a warning. Every lane launch clears an inherited
PLUGIN_PROFILES_SESSION.

Also rewords two session-flow code spans that began with a space.

Refs: #16512

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 16, 2026 07:27
@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-16T07:31:34.720137Z 9bb1eaf 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: 9bb1eafc03

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

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 43824019905

Failed GitHub API calls

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

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 6f665ca45c96c3a09737dd00b10e41b2670c6f23: read 9 of 9 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #16523 at 6f665ca4 (incremental since 1ece0c96)

No security issues found. I read every hunk of all 9 files in scope in .claude-lane/incremental.diff. This lane already reviewed an earlier head, so this pass was blocking only: it reports CRITICAL and IMPORTANT findings and nothing lower.

critical-findings: 0

What changed and what I checked

  • launch --dry-run (plugins/plugin-profiles/scripts/profiles.mjs): the new flag skips two calls, replaceFile and sweepSessions, so a dry run writes no file. All the earlier checks still run, including the --unattended stop, and the new test confirms that stop still exits 1. Turning off writes widens nothing.
  • Empty PLUGIN_PROFILES_SESSION (sessionProfile helper): an empty value now counts as unset in apply --defer-off, ownProfile and statusOf. Before, an empty string was already falsy in the apply and ownProfile checks. In statusOf it now falls back to the folder profile. This crosses no trust boundary, because the variable is local session state.
  • findRecord (plugins/plugin-profiles/lib/record.mjs): a linked worktree that has no record now adopts the main worktree's record in memory only and does not save it. That means fewer writes, and the rules for when a record is adopted are unchanged.
  • Lane restart (plugins/harness-ops/skills/lanes/scripts/lane-launcher.sh): before stopping a running lane, _restart_one now runs the pre-flight launch with --dry-run. If plugin-profiles is missing, that check returns quietly and the real launch prints the warning. Every argument is still passed as an array element, and nothing new from outside reaches the shell. env -u PLUGIN_PROFILES_SESSION -u PLUGIN_PROFILES_SESSION_FILE still clears both inherited markers.
  • Handoff guidance (plugins/session-flow/reference/structure.md): the resume line now always uses this session's own launch file, and a phase change passes only --start-command. The existing test still refuses a start command that contains a backtick, and nothing in this change deletes or softens a guardrail.
  • Changelog fragments and tests: documentation and test changes only.

None of the changed files matches a trusted-path glob, a plugin manifest or a trust control. Nothing here can create a real charge.

@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 9bb1eafc032a8bfdcdce4a3795ec3cba3dc32ee3; 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 6f665ca45c96c3a09737dd00b10e41b2670c6f23: read 9 of 9 changed file(s); 0 finding(s), 0 as inline comments.

Incremental code review: PR #16523, changes since 1ece0c96

No blocking findings. This lane had already reviewed earlier heads (blocking only: yes), so this pass looked for blocking findings only and dropped advisory ones.

I read every hunk of all 9 files in .claude-lane/incremental.diff. What changed and what I checked:

  • lib/record.mjs findRecord: a linked worktree's adopted record now stays in memory and is not written to disk. Every caller still works with this:
    • apply saves it at profiles.mjs:320.
    • The rollback at :324 saves the adopted copy back, which matches the old write-on-read result.
    • clear deletes the record at :574 with removeFile, which uses rmSync({force:true}), so a missing file is fine.
    • status, ownProfile and :613 only read it.
  • launch --dry-run:
    • The only writes in launch, replaceFile and sweepSessions, are now skipped under the flag.
    • prepare never reads dryRun, so passing ...opts through to it changes nothing.
    • The --unattended refusal still runs before the skip.
    • The new test checks both cases.
  • sessionProfile: every read of PLUGIN_PROFILES_SESSION outside the tests now goes through this helper (apply --defer-off, ownProfile, statusOf). The plugin has no other reader.
  • lane-launcher.sh check mode:
    • The restart check now passes --dry-run, so restart no longer writes a session file that the real launch then rewrites.
    • When plugin-profiles is absent, check mode stays quiet, so restart warns once. The new test asserts the argv order and the single warning.
  • session-flow structure.md and the new test_save_point.py test: on a phase change, the resume line keeps this session's own file, and only the next phase's command goes to --start-command. The test asserts the reopen line does not carry the next profile's file.

Settled and prior findings: both prior inline findings (the restart check's target and folder, and the status comment spacing) were fixed at fbf8bac9 and settled by the owner. This push does not reopen either.

Manifests and hold: this push changes no plugin.json or marketplace.json, and no hold applies. The two changelog fragments only add text; the existing bump: minor and bump: patch still cover it.

Verification: I ran nothing. Everything above comes from reading the diff and the code at head.

Verifier dropped 0 of 0 candidates.

kyle-sexton and others added 4 commits November 16, 2026 02:44
- apply without --for is a usage error again; it had defaulted to the
  folder, which changes every session sharing it.
- Each session file sets PLUGIN_PROFILES_SESSION_FILE to its own path, so
  status names the file a merged launch started the session with.
- launch no longer checks the calling surface: the session it starts is a
  CLI session, so a launch from VS Code or Desktop works.
- The lanes restart check skips cloud lanes, which carry no profile, and
  resolves a local-background lane's profile for its linked worktree.
- The handoff skill is back under its line cap: the plugin profile steps
  live in the structure doc it already walks.
- The status line in the usage header has its column spacing back.

Refs: #16512

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
…unch

The launch command and the lanes launcher's own prefix now clear
PLUGIN_PROFILES_SESSION_FILE along with PLUGIN_PROFILES_SESSION, so a
session launched with no profile from a profiled shell does not keep the
parent's file path. status already reads the file variable only when the
marker is set. USAGE is back on its own line.

Refs: #16512

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
Puts `let target` in statusOf back on its own line, restores the space in
`const USAGE =`, and names both variables the launch command clears in
the usage header.

Refs: #16512

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
- A phase-change handoff reopens the producing session with its own
  profile file; only the next session's start command carries the next
  profile.
- An adopted worktree record stays in memory, so status, a dry run and
  launch's default write no record file.
- An empty PLUGIN_PROFILES_SESSION counts as unset everywhere it is read,
  so status falls back to the folder profile.
- launch takes --dry-run, which checks and writes no file; the lanes
  restart check uses it, so it writes no extra session file and the
  missing-plugin warning prints once.

Refs: #16512

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit 28ae193 Nov 16, 2026
51 checks passed
@kyle-sexton
kyle-sexton deleted the feat/launch-with-profile branch November 16, 2026 08:21
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 6, survived 1, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 86%; mutation score 86%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/harness-ops/skills/lanes/scripts/lane-launcher.sh 1 1 0 0 0 0
plugins/plugin-profiles/lib/record.mjs 1 0 0 0 0 0
plugins/plugin-profiles/lib/sessions.mjs 1 0 0 0 0 0
plugins/plugin-profiles/scripts/profiles.mjs 2 0 0 0 0 0
plugins/session-flow/scripts/save_point.py 1 0 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/harness-ops/skills/lanes/scripts/lane-launcher.sh:1245 ROR productive input-gap

The run's summary has the full report.

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.

Launch each session with its plugin profile

1 participant