Skip to content

feat(machine-health): start the monthly run in a plugin profile - #16590

Merged
kyle-sexton merged 3 commits into
mainfrom
feat/16542-machine-health-profile
Nov 16, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
feat/16542-machine-health-profile

Conversation

@kyle-sexton

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

Copy link
Copy Markdown
Member

Closes #16542

Summary

The machine-health monthly Task Scheduler run can now start in a plugin profile. #16523 wired the other launch sites to profiles.mjs launch and left this one out: its /tr value is capped in length, and the argv launch prints starts with env, which Windows lacks.

Fix

  • plugins/machine-health/skills/setup/templates/monthly-run.ps1: one optional parameter, -PluginProfile <name> (validated to ^[A-Za-z0-9][A-Za-z0-9._-]*$, so it cannot add words to /tr). With it, each run:

    1. finds the enabled plugin-profiles install through claude plugin list --json (the lane launcher's lookup);
    2. runs node <install>/scripts/profiles.mjs launch <name> --folder <StateBase> --unattended --json;
    3. reads the result's enabledPlugins (each plugin as the session will start with it, which the profile wins) and does not start the run unless a machine-health or machine-health@* entry is true: "profile '' leaves machine-health off, so the run would not reach /machine-health:audit and did not start; name a profile that includes machine-health". A result without enabledPlugins (a plugin-profiles older than fix(harness-ops): refuse a lane that arms the stop gate under a profile without autonomy #16586) is refused with "update plugin-profiles";
    4. reads the argv: removes each variable its leading env -u NAME words name from the run's ProcessStartInfo.Environment, checks the next word is claude, and passes the remaining words (--settings <session file>) before the audit's arguments, after any leading -ClaudeCommand words;
    5. logs what the profile added and cleared to the stderr log.

    It never runs env, on any platform. When plugin-profiles is not installed and enabled, or the launch refuses (exit non-zero, for example a missing required prerequisite under --unattended), the run does not start: the reason goes to the stderr log and the status file records a not-ok run with no exit code. Without -PluginProfile nothing above runs.

  • plugins/machine-health/skills/setup/SKILL.md, Task Scheduler fallback: step 1 asks whether the run should start in a profile (default none) and says the profile must include machine-health; step 2 ends the /tr value with -PluginProfile <profile> when one is named; step 3's run-now command takes the same parameter.

  • Install-MonthlyRun.ps1 is unchanged: no launch.json.

  • .changes/machine-health/: a minor fragment.

Shape, and its Basis. The issue proposed Install-MonthlyRun -Argv writing <StateBase>/scheduler/launch.json for the wrapper to read. Launching at each run instead has fewer parts (no new file, no installer change) and avoids two failures that shape would have:

  • profiles.mjs launch "removes session files no launch has written for 30 days" (plugins/plugin-profiles/scripts/profiles.mjs, launch's description), so a session file written once at install could be gone before a monthly run. Each run's launch rewrites it.
  • The argv names the plugin's install path, which a plugin update changes; a stored argv would go stale, while the per-run lookup reads the current one.

The /tr value grows only by -PluginProfile <name>, about 20 characters, against the cap the issue cites (I did not re-measure the cap; schtasks itself refuses an over-long /tr). The env problem goes away because the wrapper starts claude through ProcessStartInfo already (monthly-run.ps1, the $psi block) and removes the variables from its environment itself.

Done-when, item by item:

  1. A scheduled run can be set up to start in a named profile on Windows: setup's Task Scheduler steps take the profile and put -PluginProfile <profile> in /tr; the wrapper applies it at each run. Delivered.
  2. The wrapper's profile path is not Windows-only and runs on Linux or macOS, shown by a test there, with no scheduler route added: the same code path runs on every platform (no env, no platform branch); the new monthly-run wrapper in a plugin profile Pester block passes on Linux (output under Verification); no cron or other route is added. Delivered, with one note: CI's machine-health Pester lane runs on Windows only (.github/workflows/pr-test-platforms.yml, "Run machine-health Pester suites"), so the Linux run is the local one below.
  3. With no profile named it runs as it does today: no plugin lookup, no launch, the same audit arguments, the inherited environment untouched (test 2). Delivered.
  4. The marker variables are cleared on Windows without env: the stub's argv starts env -u PLUGIN_PROFILES_SESSION -u PLUGIN_PROFILES_SESSION_FILE claude, the wrapper runs from a shell where both are set, and the child sees neither (test 1); the wrapper never executes env. Delivered; CI runs it on Windows.
  5. Tests cover both paths: the profile path (test 1, and the two refusals) and the no-profile path (test 2, plus every existing case, which runs without a profile). Delivered.

Verification

  • Invoke-Pester plugins/machine-health/skills/audit/tests/windows/scheduler/monthly-run.Tests.ps1 on Linux (pwsh 7.6.10, Pester 6.2.0): the seven new cases pass:

    • starts the run with the profile launch arguments before the audit arguments, with both markers cleared and no env (machine-health on in the result);
    • runs as before with no profile named: no profile launch, the audit arguments alone, the environment untouched;
    • does not start the run when plugin-profiles is not installed and enabled;
    • does not start the run when the profile launch refuses, and logs its reason;
    • does not start the run when the profile leaves machine-health off, and names the fix;
    • does not start the run when the launch result reports no enabledPlugins, and says to update plugin-profiles;
    • rejects a profile name that is not a plain word.

    Of the existing 17 cases, 16 pass; passes every argument intact through a .cmd claude, which cmd.exe re-parses fails on Linux, and fails the same way on unchanged main there, since it needs cmd.exe. CI runs this suite on Windows.

  • The branch merges origin/main (with fix(harness-ops): refuse a lane that arms the stop gate under a profile without autonomy #16586, which added enabledPlugins to launch --json). Against the merged tree, the real node plugins/plugin-profiles/scripts/profiles.mjs launch harness-upkeep --folder <empty temp dir> --unattended --json --dry-run prints an enabledPlugins object holding "machine-health@melodic-software": true; the same call for build reports it false, which the wrapper now refuses.

  • No Pester case runs the wrapper against the real profiles.mjs: its launch reads the installed plugins through claude plugin list --json and this machine's settings layers, so on a CI runner with no claude or plugins installed the result would describe the host, not the code. The stub stands in for that result, and the real call above checks its shape.

  • Pre-push check-affected passes.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_015XWwmbLtFcfditeagftLrv

The Task Scheduler wrapper takes -PluginProfile <name>. At each run it
asks the enabled plugin-profiles install for profiles.mjs launch, clears
the variables the argv's env -u words name from the run's environment,
and passes the argv's remaining claude arguments before the audit's.
That works the same on every platform, so Windows needs no env. A
missing plugin-profiles or a refused launch starts no run and logs why.
Without the parameter the run is unchanged.

Launching at each run, rather than storing the argv at install time,
keeps the session file inside the 30-day sweep and the install path
current after a plugin update, and adds only the profile name to /tr.

Closes #16542

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

Copy link
Copy Markdown
Member Author

Owner: the control-hub session "Plugin Presets" watches and merges this pull request; it waits on CI Status and the review lanes on head 5203bd6. Review findings go to it, and the build session (plugin-profiles-build-5) fixes them.

@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-16T18:21:19.943887Z 5203bd6 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: 5203bd6a48

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

A profile wins on enabledPlugins, so one that leaves machine-health out
starts a session that cannot run /machine-health:audit. The wrapper now
reads enabledPlugins from the launch result and does not start the run
unless a machine-health entry is on, naming the profile and the fix; a
result without enabledPlugins is refused with "update plugin-profiles".
The setup skill's profile question says the profile must include
machine-health.

Refs: #16542

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015XWwmbLtFcfditeagftLrv
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review needs no new review of 2dbf4450b7629cdcbbad9af722e603113945a62e: no file of this pull request changed since the review of e1f9dee.

Security review (incremental, since 5203bd6): no security issues found

I read every hunk of the four files in the incremental scope: the changelog fragment, monthly-run.Tests.ps1, setup/SKILL.md and templates/monthly-run.ps1. None of them matches a trusted path. No plugin manifest, trust control or merge hold changed.

What changed. In plugins/machine-health/skills/setup/templates/monthly-run.ps1, the wrapper now parses the whole profiles.mjs launch result instead of only its argv. It refuses to start the run in two cases:

  • the result has no enabledPlugins dictionary;
  • no machine-health or machine-health@* key in that dictionary is exactly $true.

Both checks run before argv is read, so the existing checks on argv and the cmd.exe metacharacter refusal still apply unchanged. The new code only adds ways for the run to stop. It skips no check that existed before.

Inputs. enabledPlugins comes from the owner's own installed plugin-profiles, run on the owner's machine. Nothing from a pull request, issue or comment author, or from any other outside source, reaches it. The values from the result are only compared with -ceq and -clike, and the error messages contain only the profile name, which is already checked against ^[A-Za-z0-9][A-Za-z0-9._-]*$. Nothing from the result is run or interpolated into a command.

SKILL.md. The change adds the requirement that the profile must include machine-health. It removes or softens no instruction.

Tests and changelog. The stub gains an MH_PROFILES_MH switch, which is saved and restored like the other variables, plus two refusal cases. These files have no security surface.

Earlier reviews. The settled thread on monthly-run.ps1 line 100 is the owner's accepted fix that this push implements, and nothing here reopens it. This lane's one prior post was a summary with no findings, so there is nothing to restate. This review was blocking only: an earlier head was already reviewed, so it reports only CRITICAL and IMPORTANT findings. There were none of any severity.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

claude-review needs no new review of 2dbf4450b7629cdcbbad9af722e603113945a62e: no file of this pull request changed since the review of e1f9dee.

Code review (incremental, 5203bd6 → e1f9dee, blocking only)

This lane already reviewed an earlier head, so this pass reports blocking findings only. I read all four files in the incremental diff in full: the changelog fragment, monthly-run.Tests.ps1, the setup SKILL.md step and templates/monthly-run.ps1.

What changed since the last review. When a profile is named, the wrapper now reads enabledPlugins from the profiles.mjs launch result and refuses to start the run in two cases:

  • the result has no enabledPlugins map, so it asks the user to update plugin-profiles;
  • no machine-health or machine-health@* entry is true.

This is the fix the owner described in the settled thread on line 100. I did not raise that thread's point again.

Blocking finding (one inline comment). The plugin-profiles in this tree never prints enabledPlugins from launch. The result object at profiles.mjs#L424 has only profile, folder, file, prerequisitesMissing, argv and command, and it is printed as-is at #L452. Unless #16586 is already on main, every profiled run refuses with "update plugin-profiles", and the latest plugin-profiles cannot meet that request. The new tests do not catch this because their stub prints an enabledPlugins field that the real script lacks. If that holds, Done-when item 1 of #16542 ("A machine-health scheduled run can be set up to start in a named profile on Windows") is not met when this PR merges alone.

Other checks (no finding).

  • When the output is empty or does not parse, $result is null. Indexing it then throws inside the existing try, so the run still records not-ok.
  • $result is assigned again later at monthly-run.ps1#L202, which is harmless.
  • The SKILL.md wording and the changelog fragment match the new behaviour. The minor bump still fits.
  • The diff changes no plugin manifest.
  • No spend beyond the normal scheduled run.

I ran no tests. The PR's Linux Pester results are as the author reports them and I did not verify them.

Verifier dropped 0 of 1 candidates.

@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: 1 inline finding(s) on e1f9deeec8c433aad2c5808082cc7c467f2e94d1; the summary is in this lane's pull request comment.

claude-lane: claude-review

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit 10df8b2 Nov 16, 2026
64 checks passed
@kyle-sexton
kyle-sexton deleted the feat/16542-machine-health-profile branch November 16, 2026 18:55
@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 the machine-health scheduled run in a plugin profile

1 participant