Skip to content

fix(plugin-diagnostics): read the session's --settings file as a settings layer - #16686

Merged
kyle-sexton merged 2 commits into
mainfrom
fix/16673-session-settings-layer
Nov 17, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
fix/16673-session-settings-layer

Conversation

@kyle-sexton

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

Copy link
Copy Markdown
Member

Closes #16673

Summary

A session started with a --settings file that turns a plugin off still got that plugin's SessionStart prerequisite notices, because the shared reader never read that layer. Every plugin-profiles session starts that way. The reader now reads the file a variable it defines names, and plugin-profiles sets that variable in the session file it writes (owner decision on #16673, option (a), "Go with recommendations.", relayed by the hub "Plugin Presets").

Fix

  • lib/enabled-plugin-roots.mjs (synced into plugin-diagnostics and harness-ops): rootsFromSettings(config, project, managed, env) reads the file SESSION_SETTINGS_FILE names after <project>/.claude/settings.local.json and before the managed files. With the variable unset, or naming a file that is missing or not JSON, it adds nothing. The header comment documents the variable; that is its one home.
  • plugins/plugin-diagnostics/hooks/prerequisites-fleet.mjs passes its env to the reader.
  • plugins/harness-ops/skills/prerequisites/scripts/check-prerequisites.mjs: with the variable set it takes the settings route, because claude plugin list --json does not see the session's --settings file. That route now reads the managed settings files too, which win. session-telemetry-state.mjs passes env and its header now says a --settings session is seen.
  • plugins/plugin-profiles/scripts/profiles.mjs: both one-session writers (apply --for session and launch) set SESSION_SETTINGS_FILE to the file's own path, and launch's argv clears an inherited one (env -u SESSION_SETTINGS_FILE). A child started with no profile from a profiled shell would otherwise read the parent's file.
  • plugins/harness-ops/skills/lanes/scripts/lane-launcher.sh: its no-profile launch lines clear the variable too, matching the two plugin-profiles variables they already clear.

The variable is named for what it holds: the settings file the session was started with. It carries no plugin-profiles name, so the hook units read nothing another plugin owns (D35). Basis: the owner's rule "a hook unit never depends on a skill, an agent or a file of another plugin", and the naming rule that no status, severity or implementation word goes in a published name.

PLUGIN_PROFILES_SESSION_FILE now carries the same path as the new variable. It stays because status, lane-launcher, the fleet relay and machine-health use it as part of the launch contract, and removing it is not needed for this fix. Basis: git grep PLUGIN_PROFILES_SESSION_FILE (lane-launcher.sh, profiles.mjs, fleet eval samples, machine-health tests).

Verification

Done-when, item by item:

  • A session whose --settings file turns a plugin off gets no prerequisite probe for it, shown by a test and by a live session.
    • Test: prerequisites-fleet.test.mjs, "a plugin the session's settings file turns off is not probed, and an unreadable session file adds nothing". User settings turn alpha on and the session file turns it off; alpha gets no notice and beta still does.
    • Live (Claude Code 2.1.326, no model turn): claude -p -n probe-16673-session-layer --setting-sources "" --settings <throwaway file> --model claude-nonexistent-probe-0 "reply ok". The throwaway file turns go-format@melodic-software off, sets SESSION_SETTINGS_FILE to its own path, and has a SessionStart command hook that runs this branch's reader. The hook wrote {"var":"<the file>","goFormat":false,"instructionPlacement":true}. The same script run outside the session, with the variable unset, wrote goFormat:true. The run exited 1 on the unknown model, as expected.
  • The three readers of rootsFromSettings agree on which plugins are enabled for that session. All three pass the session's env to the same function. check-prerequisites.test.sh covers the one reader with a second route: "session: a plugin the session file turns off is not read" (a stub listing enables the plugin and the session file wins) "session: a missing session file adds nothing", and "session: a managed file that turns the plugin off wins over the session file". On that route the table reads the managed settings files, as the hook and the session-telemetry reader do.

Suites run on this branch:

  • node --test on profiles.test.mjs, prerequisites-fleet.test.mjs and session-telemetry-state.test.mjs: 99 pass, 0 fail.
  • check-prerequisites.test.sh: 51 cases, 0 failed, run with and without an inherited SESSION_SETTINGS_FILE (the suite now unsets it).
  • lane-launcher.test.sh: 575 cases pass.
  • prerequisites-fleet.test.sh: 13 pass.
  • scripts/sync-shared-copies.sh --check (and --check-bump origin/main on the first head): pass.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_015XWwmd6tBpn6BvQsRn9MyP

…ings layer

The shared reader (lib/enabled-plugin-roots.mjs) reads the file that
SESSION_SETTINGS_FILE names after the project-local settings and before
managed ones, so a plugin a session's --settings file turns off is not
probed for prerequisites. Unset, or naming a missing or unreadable file,
it adds nothing. The reader defines and documents the variable.

plugin-profiles sets it in every one-session file it writes and clears an
inherited one on launch; lane launches clear it too. The prerequisites
table takes the settings route when it is set, since claude plugin list
does not see the file, so the three readers agree.

Closes #16673

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

Copy link
Copy Markdown
Member Author

Ownership: this pull request belongs to the control-hub session "Plugin Presets", which watches and merges it. The build session that opened it answers findings only as Plugin Presets relays them.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 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-17T02:07:11.778428Z 5f7ef9b 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: 5f7ef9bb48

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

Failed GitHub API calls

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

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 7be201f107f4b6121ec447541ab19cd855497221: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

claude-security-review, incremental review of 5f7ef9bb..7be201f1. I read both files on the incremental list in full. Because this lane already reviewed an earlier head, this pass reports only CRITICAL and IMPORTANT findings.

I found no security issues in this change.

What I checked:

  • check-prerequisites.mjs, settings route. It now passes the managed settings files to rootsFromSettings, using managedSettingsFiles() from plugins/harness-ops/lib/plugin-options.mjs.
    • That function builds its paths only from a fixed per-platform directory (MANAGED_DIRS[platform]) and the .json files in its managed-settings.d drop-in folder (plugin-options.mjs#L41-L55).
    • No value an attacker controls picks those paths. The try/catch around the call returns an empty list on error, the same behaviour the route had before this change.
    • The effect is narrowing: a managed true or false now wins over the session file and the user layers, so this reader agrees with the other two.
    • ctx.managed is a test hook that only callers inside the process can set. The command line can't reach it.
  • check-prerequisites.test.sh. It now clears SESSION_SETTINGS_FILE in the scrub at line 4 and adds a test case where managed settings turn a plugin off and the session file turns it on. These are local test changes with no security surface.
  • Earlier threads. Both owner-settled threads (managed scope on the settings route, and the suite inheriting SESSION_SETTINGS_FILE) are fixed by this change. Neither is raised again.
  • Out of scope here. No trusted path, trust control, merge hold, kill switch, token request, workflow, plugin manifest or standing instruction is touched.
  • Embedded text. The settled-threads and prior-findings files hold no instructions aimed at this lane.

Spend: none. The change adds no lane runs and no model use.

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 5f7ef9bb48afff342aa07e84453e33a04d5f92f3; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 7be201f107f4b6121ec447541ab19cd855497221: read 2 of 2 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #16686, incremental (5f7ef9b → 7be201f)

This pass covered only what changed since the last review, and only blocking findings, because this lane already reviewed an earlier head. I read the whole incremental change in both files listed for this pass:

  • plugins/harness-ops/skills/prerequisites/scripts/check-prerequisites.mjs
  • plugins/harness-ops/skills/prerequisites/scripts/check-prerequisites.test.sh

No blocking findings.

Both earlier findings are fixed

  • Managed settings are read again on the settings route. The settings route now passes ctx.managed ?? managedFiles() to rootsFromSettings. managedFiles() wraps managedSettingsFiles() from lib/plugin-options.mjs in a try/catch. That matches what prerequisites-fleet.mjs and session-telemetry-state.mjs do, and rootsFromSettings applies managed files last, so a managed true or false wins.
    • A new test sets the plugin off in a managed file and on in the session file, and checks the plugin is not listed. Without the managed file the plugin would be listed as missing, so the test can tell the two cases apart.
    • The header comment is updated to match.
  • The suite no longer inherits the variable. check-prerequisites.test.sh now unsets SESSION_SETTINGS_FILE at line 4.

Both threads are also resolved by the owner. Their lines are unchanged since resolution, so I did not raise them again.

Closing issue #16673

  • "A session whose --settings file turns a plugin off gets no prerequisite probe for it, shown by a test and by a live session": met, as in the last review. The live-session evidence comes from the author and I did not verify it.
  • "The three readers of rootsFromSettings agree on which plugins are enabled for that session": now met. All three readers pass managed files, and the new case tests the managed-over-session order.

Other checks

  • Manifests: this push changes no plugin.json or marketplace.json.
  • Embedded text: none in the PR context, settled threads or prior findings.
  • Spend: this change adds no spend.
  • Tests: I had no shell and ran nothing. The suite results in the PR body ("51 of 51" both with and without the inherited variable) are the author's claim and unverified.

Verifier dropped 0 of 0 candidates.

… route

With SESSION_SETTINGS_FILE set, check-prerequisites skips claude plugin
list and reads settings files, but passed no managed files, so a plugin a
managed policy forces on or off read wrongly and the table disagreed with
the SessionStart hook and the session-telemetry reader. The settings route
now reads the managed files, which win.

The test suite unsets an inherited SESSION_SETTINGS_FILE, so running it
from a plugin-profiles session no longer sends its listing cases down the
settings route.

Refs #16673

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmd6tBpn6BvQsRn9MyP
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 4fc2ba5 Nov 17, 2026
75 checks passed
@kyle-sexton
kyle-sexton deleted the fix/16673-session-settings-layer branch November 17, 2026 02:36
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 4, survived 2, timeout 0, no coverage 0, invalid 0, not run 1.
Covered-code score 67%; mutation score 67%.

File Killed Survived Timeout No coverage Invalid Not run
lib/enabled-plugin-roots.mjs 0 1 0 0 0 0
plugins/harness-ops/scripts/session-telemetry-state.mjs 0 1 0 0 0 0
plugins/harness-ops/skills/lanes/scripts/lane-launcher.sh 1 0 0 0 0 0
plugins/harness-ops/skills/prerequisites/scripts/check-prerequisites.mjs 1 0 0 0 0 0
plugins/plugin-diagnostics/hooks/prerequisites-fleet.mjs 1 0 0 0 0 0
plugins/plugin-diagnostics/lib/enabled-plugin-roots.mjs 1 0 0 0 0 0
plugins/plugin-profiles/scripts/profiles.mjs 0 0 0 0 0 1

Surviving mutants

Location Operator Disposition Cause
lib/enabled-plugin-roots.mjs:65 SBR unclassified none
plugins/harness-ops/scripts/session-telemetry-state.mjs:51 other unclassified none

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.

Prerequisite probe treats plugins a session's --settings file turns off as enabled

1 participant