Skip to content

fix(hooks): run the SessionStart hook on Windows Codex and read its context without PATH (#127) - #171

Merged
mergify[bot] merged 10 commits into
mainfrom
fix/127-windows-session-start
Oct 13, 2026
Merged

mergify[bot] merged 10 commits into
mainfrom
fix/127-windows-session-start

Conversation

@ericlitman

@ericlitman ericlitman commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

The pstack SessionStart hook runs on Windows Codex, and its context script no longer depends on PATH (#127, reported by Coldsun1). A startup-hook check joins the Mac live gate, and a Windows workflow proves the hook on GitHub's windows-latest runner without any login.

 plugins/pstack/hooks/
~  run-hook.cmd         # whole superpowers 7.0.0 wrapper (bb92a77) + the port's header; delayed expansion off
~  session-start        # Bash built-ins only; exits 1 when the context file is missing
~  hooks.json           # + commandWindows for Codex (C:\Windows\System32\cmd.exe /v:on); generic command unchanged; no resume
+  .gitattributes       # LF line endings, as upstream ships, so Git for Windows keeps the scripts runnable
 .claude/skills/verify-open-pstack/
+  features/hooks.md, features/recipes.ts   # hook:startup case for Claude Code and Codex
~  features/registry.json                   # maps the new workflow under project
~  features/recipes.ts                      # also drops the 5,000-byte Reflect report cap (#166, Eric)
+.github/workflows/windows-hooks.yml         # login-free hook checks in cmd, Windows PowerShell and pwsh on every PR

Evidence

  • Native records show the context (Mac, before and after the fix):
    • Claude Code: a SessionStart hook_response with exit 0, whose stdout is byte-identical to session-start-context.md.
    • Codex 0.160.0: a developer message in the rollout holding the same text. The JSON stream does not show it.
    • The new hook:startup assertion passes on real sessions from the fixed hook, and fails on a failed hook, empty stdout, a different event, text only in a model reply, or a Codex user message.
  • session-start without PATH: it prints the exact context under env -i with bash 3.2 and 5, from a path with spaces. A missing context file exits 1, and a missing script exits 127.
  • Windows hook checks: the wrapper job runs the commandWindows value through cmd, Windows PowerShell and pwsh, the way Codex calls each one. The plugin path contains a space, &, % and !, and the session directory contains a planted cmd.exe. Each shell is checked with an ordinary PATH, a System32-only PATH, a missing script and a missing context file, and session-start is also checked under Git's bash with an empty PATH. All 13 checks passed on a lab push of this head's files (run). They also passed in this PR's run on acf8292 (run).
  • Windows Codex session: dropped. Head 1 had an interactive Codex login job. Unfret showed that a real login on a runner that then runs pull request code with hook trust bypassed exposes the credential, and that manual dispatch could check out a fork ref. Removing the job removes those findings, the public raw-stream upload, and the label runs that replaced the wrapper result. The reporter can confirm the Codex desktop app on the exact head.
  • Reporter test on the real surface (Coldsun1, head fd580ad): the Windows Codex desktop app (0.162.0-alpha.17.2) and the CLI received no pstack context. The wrapper printed it when run directly, and cmd.exe /d /s /c ""%PLUGIN_ROOT%\hooks\run-hook.cmd" session-start" made a fresh CLI session receive it.
  • Why, from Codex's source: Codex runs a hook through the session's shell (codex-rs/core/src/session/mod.rs, build_hooks_config, then codex-rs/hooks/src/engine/command_runner.rs, build_command). On Windows that shell is usually PowerShell, which gets -NoProfile -Command <value>. Cmd gets /c "<value>", and so does %COMSPEC% when there is no session shell. The CI job up to head 4 emulated only the cmd case.
  • Lab comparison on windows-latest (run), six plugin paths in each shell:
    • The value in heads 1 to 3, "%PLUGIN_ROOT%\hooks\run-hook.cmd" session-start, fails 6/6 in Windows PowerShell and in pwsh with a parse error, "Unexpected token 'session-start'". This is what Coldsun1 saw on fd580ad. Main has no commandWindows at all (Windows Codex SessionStart hook exits 1; plugin command lacks a Windows override #127).
    • The reporter's value (head 4) fails in PowerShell when the plugin path contains a space or &. In cmd it runs the session directory's cmd.exe instead of the system one, which is Unfret's head-4 security finding.
    • This head's value, C:\Windows\System32\cmd.exe /d /v:on /s /c ""!PLUGIN_ROOT!\hooks\run-hook.cmd" session-start", passes 6/6 in all three shells once the wrapper turns delayed expansion off. Without that change, a path containing ! fails.
  • Mac live gate: passed on acf8292, run from the candidate with --feature claude:hook:startup --feature codex:hook:startup --self-test (evidence).

Merge Danger

Door: two-way

Blast Radius: hooks

Every Claude Code and Codex session runs this hook at startup. A changed hook definition changes its trust hash, so Codex users review and trust it again once. The workflow sits under .github/, so Mergify does not auto-queue it. I queue it by hand once its checks pass. The Windows command names C:\Windows\System32\cmd.exe, so a Windows installed elsewhere does not run the hook, as docs/reference.md states.

Acceptance criteria

  • "The wrapper checks pass on windows-latest." See Evidence.
  • "The labeled Codex run ..." Dropped with the login job (see Evidence and the updated Windows Codex SessionStart hook exits 1; plugin command lacks a Windows override #127).
  • "The Mac live gate passes the new startup-hook case in Claude Code and Codex, plus project-skill in both under --self-test, from the candidate head." See Evidence.
  • "Bun tests, strict typecheck, static invariants and plugin validation pass." See Gate results.

Gate results

My run on the tree committed as acf8292, every command with MASTRA_TELEMETRY_DISABLED=1:

Check Exit
bun install --frozen-lockfile (poteto-mode scripts) 0
bun run test 0 (321 pass, 0 fail)
bun run typecheck (strict) 0
Manifest JSON parse 0
bun install --frozen-lockfile --ignore-scripts (verifier) 0
PSTACK_STATIC_ONLY=1 bash tests/skill-collision-repro.sh (includes the verifier's tests and typecheck) 0
claude plugin validate plugins/pstack 0

Not verified

Unfret rebuttals

Unfret rebuttal for head fd580ad6ab8d2a67e4b18bd352bf3c08e6b1e4c7, finding v1:394463387aacbc4c54db5704a814fd11a27becc6bdc4039a3afb760fdeb373e9
Claim: the PATH fallback can run a repository-relative bash.exe through a relative PATH entry.
Disproof: not change-attributable, and this change narrows it. On main, plugins/pstack/hooks/run-hook.cmd:32-34 runs "where bash" and then a bare "bash", which cmd.exe resolves by searching the current directory before PATH, so a repository bash.exe was reachable with no special PATH at all. This head resolves bash only through '"%SystemRoot%\System32\where.exe" $PATH:bash', which drops the current-directory search, and skips extensionless matches and the WSL launchers. The remaining case needs a relative entry the user added to PATH.
Unfret rebuttal for head fd580ad6ab8d2a67e4b18bd352bf3c08e6b1e4c7, finding v1:b08d88f76dc23b41fc7a08a2ef69c3a406c1e77f81f980c0acae7056da71402e
Claim: Windows startup silently loses the context without Bash.
Disproof: not change-attributable. On main, plugins/pstack/hooks/run-hook.cmd:38-40 already does "exit /b 0" when no bash is found, with the comment "exit silently rather than error". This head keeps that upstream behavior and names it. docs/reference.md (Dependencies, "Bash on Windows") lists Bash as the Windows prerequisite and states that without it the hook exits 0 and skips the context. REVIEW.md puts a host missing a named prerequisite out of scope except for the promised behavior, and the hook keeps that promised behavior.
Unfret rebuttal for head fd580ad6ab8d2a67e4b18bd352bf3c08e6b1e4c7, finding v1:3ad586e3bafd9a274534e7417d121552eb9b7e42f530eb695c6a7279b2b2ce60
Claim: a Git install at a non-default root such as D:\Git is not found.
Disproof: not change-attributable, and this change widens discovery. On main, plugins/pstack/hooks/run-hook.cmd:22-36 checks only the two C:\Program Files locations and a bash on PATH. This head adds the per-user %LOCALAPPDATA%\Programs\Git location. docs/reference.md names the discovery locations, so a host with Bash outside them and not on PATH lacks the documented prerequisite.

Closes #127

🤖 Generated with Claude Code

ericlitman and others added 6 commits October 12, 2026 11:24
…t report (#166)

No outcome required the cap, and it does not establish that the transcript
was read. Eric decided to remove it on 2026-10-12.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in the Reflect verifier fixes (#152, #166) and registry U1 (#155) before
this branch opens, since all three edit features/recipes.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	.claude/skills/verify-open-pstack/features/recipes.ts
#127)

#127 adds a required context field to SessionRecord, and the writer test from
#155 builds a record without it, so the merge failed strict typecheck.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mergify

mergify Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Merge Protections

🔴 1 of 2 protections blocking · waiting on 🙋 you

Protection Waiting on
🔴 🚦 Auto-queue 🙋 you
🟢 Queue ready pull requests —

🔴 🚦 Auto-queue

Waiting for

  • -files~=^\.github/
This rule is failing.

When all merge protections are satisfied and these conditions match, this pull request will be queued automatically.

  • -files~=^\.github/
  • base = main

Show 1 satisfied protection

🟢 Queue ready pull requests

Automatically queue non-draft pull requests targeting main after verify, Unfret, and live-gate pass on the head and every review thread is resolved.

  • #review-threads-unresolved = 0
  • -draft
  • check-success=Unfret
  • check-success=live-gate
  • check-success=verify

@ericlitman

Copy link
Copy Markdown
Owner Author

Live evidence: Open Pstack

  • Candidate SHA: d89f4a50a836256f09faa556394abbbaba766e77
  • Base SHA: 4f2b9b09dc9ba4f8fe08812f70bf11ec0388b201
  • Result: PASSED — named features verified
  • Self-test: completed in both harnesses
  • Publisher revision: d89f4a50a836256f09faa556394abbbaba766e77
  • Evidence-set SHA-256: 98247054c623abf7ba2aa1b526cc24c0f4c43bfd3b9559efa68d4b22a5b0fb03
  • Installation (claude): CLI 2.1.294 (Claude Code), plugin 1.7.0, candidate d89f4a50a836256f09faa556394abbbaba766e77, tree 08c31074dd2b8349b2e94e73ef293ce64b3324d99f6e0d93a7b7744b2da05d48.
  • Installation (codex): CLI codex-cli 0.160.0, plugin 1.7.0, candidate d89f4a50a836256f09faa556394abbbaba766e77, tree 08c31074dd2b8349b2e94e73ef293ce64b3324d99f6e0d93a7b7744b2da05d48.
  • Observation (claude / hook:startup): surface claude -p stream-json with the candidate plugin-dir; action recipe hook:startup: startup; result passed: startup:exit-0 startup:hook-context-injected; 2 assertions machine-checked; transcript SHA-256 fd4455f2564c71b9c2bf18915601895c525230f0fc3748bfbefcb8ae26ccc0af; artifact-set SHA-256 f0742b82d4de17cdfb0f1c51eb2e6e3e19ab9b7b741f57b1f407c9439a0bc2d6.
  • Observation (claude / project-skill): surface claude -p stream-json with the candidate plugin-dir; action recipe project-skill: doctor; result passed: doctor:exit-0 doctor:skill-loaded doctor:doctor-ran doctor:doctor-canonical-pass; 4 assertions machine-checked; transcript SHA-256 5b2339484854352f363233148e5a3910f5fb446a0aa5623495941093abdaedde; artifact-set SHA-256 ec1a48484920c6d1b6262fc93ce663eecc8d97bd14c3931f1d585639608a10cd.
  • Observation (codex / hook:startup): surface codex exec --json with the run-owned candidate installation; action recipe hook:startup: startup; result passed: startup:exit-0 startup:hook-context-injected; 2 assertions machine-checked; transcript SHA-256 37b6c5b1af05298c7c7221aae441e51f1f676e70c09ac5db08d0aef2515282c2; artifact-set SHA-256 3d310e2ea9e6ddce6a22f932a31fed3d92af7def754e78840d43d213576acd5e.
  • Observation (codex / project-skill): surface codex exec --json with the run-owned candidate installation; action recipe project-skill: doctor; result passed: doctor:exit-0 doctor:skill-loaded doctor:doctor-ran doctor:doctor-canonical-pass; 4 assertions machine-checked; transcript SHA-256 5bc0ff5e0042b62f2143695531db754fd3ed926750e6256c9f93e0c5a7b63435; artifact-set SHA-256 4369dca01d8ac5b6f1037300cbcd60facde36a9184ddeaee1ef4e509ece64aab.
  • Policy: every new head requires a fresh run; this verifier does not change PR state, queue, or merge.

@greptile-apps

greptile-apps Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

This PR adds a Windows command for the SessionStart hook and removes external command lookups from its context script.

  • Windows Codex sessions now run pstack's startup context hook.
  • The verifier checks that startup context reaches Claude and Codex sessions.
  • Windows runs can check the hook and a real Codex session.
  • Reflect reports can now include more than 5,000 bytes.

ericlitman explicitly leaves Windows desktop-app confirmation pending and leaves resume out of scope by design.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[New session] --> B{Host}
  B -->|Windows Codex| C[commandWindows]
  B -->|Unix| D[Generic command]
  C --> E[run-hook.cmd selects Bash]
  D --> E
  E --> F[session-start reads context file]
  F --> G[Harness adds context]
  G --> H[Native session record]
  H --> I[hook:startup compares installed text]
  I --> J[Retain matched context]
Loading

Reviews (1) · Last reviewed commit: "test(verify): give the runner writer tes..." · Reviewed by Greptile

@unfret-eal

unfret-eal Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

✅ Accepted risk

Accepted by ericlitman: GH-127 (authority 48fa77b)

🔴 Critical · Reject repository-relative Bash executables

🟡 Medium · Missed Bash discovery still reports hook success

🟡 Medium · Non-default Git installations lose startup context

🟡 Medium · Hardcoded system directory breaks non-C Windows startups

Advisories (1)
  • 🔵 Low · Wrapper provenance incorrectly claims a verbatim copy · NOTICE.md:16
    The linked `bb92a77` source uses bare `setlocal`, whereas the delivered wrapper adds `DisableDelayedExpansion` and its explanatory comments. This row therefore presents a behavior-changing local patch as a verbatim import with only a header modification, making the recorded source provenance inaccurate. Also reported for this defect: - Wrapper provenance incorrectly claims a verbatim import (NOTICE.md:16): The pinned `bb92a77` wrapper uses plain `setlocal`, whereas the current wrapper uses `setlocal DisableDelayedExpansion` and adds two explanatory comments. This row therefore incorrectly states that only the adaptation header differs, presenting a behavioral port modification as verbatim upstream content. The observable impact is limited to inaccurate provenance documentation.
    Not blocking because: The modification description incorrectly calls the wrapper verbatim. Copyright, license and source attribution remain present, and the supplied evidence establishes no deployment or acceptance decision consuming this description.
Details

Run: GET /unfret/run/panel:acf82929fd88720feb8c766315fc2ec9c01f4ab3:WHSPphiA4RS:i95BKX6dj6g.

@unfret review · @unfret status · @unfret help

@unfret-eal unfret-eal 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.

🛑 5 blocking findings
🔴 Critical · Fresh Codex login exposes credentials to PR-controlled code
🔴 Critical · Keep raw Codex evidence private
🔴 Critical · Manual dispatch bypasses the same-repository login boundary
🔴 High · Reuse existing auth instead of creating another login
🔴 High · Label events replace the head's Windows check results with skipped runs
Check

Comment thread .github/workflows/windows-hooks.yml Resolved
Comment thread .github/workflows/windows-hooks.yml Resolved
Comment thread .github/workflows/windows-hooks.yml Resolved
Comment thread .github/workflows/windows-hooks.yml Resolved
Comment thread .github/workflows/windows-hooks.yml Resolved
… checks (#127)

Unfret on head d89f4a5: the job put a fresh Codex login on a runner that then
ran pull request code with hook trust bypassed; manual dispatch could check out
a fork ref; it uploaded the raw Codex stream publicly; and label runs replaced
the wrapper result with a skipped one. Removing the job removes all of them.
The wrapper job already proves the hook on Windows without a login.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ericlitman

Copy link
Copy Markdown
Owner Author

Live evidence: Open Pstack

  • Candidate SHA: 909b29749a99311ca4c2b2b855e1786d947686c1
  • Base SHA: 4f2b9b09dc9ba4f8fe08812f70bf11ec0388b201
  • Result: PASSED — named features verified
  • Self-test: completed in both harnesses
  • Publisher revision: 909b29749a99311ca4c2b2b855e1786d947686c1
  • Evidence-set SHA-256: c5b2fa7c752142fe80eba59dda6db5c98c3002f787f1c9cdd58b8616f4823ef3
  • Installation (claude): CLI 2.1.294 (Claude Code), plugin 1.7.0, candidate 909b29749a99311ca4c2b2b855e1786d947686c1, tree 08c31074dd2b8349b2e94e73ef293ce64b3324d99f6e0d93a7b7744b2da05d48.
  • Installation (codex): CLI codex-cli 0.160.0, plugin 1.7.0, candidate 909b29749a99311ca4c2b2b855e1786d947686c1, tree 08c31074dd2b8349b2e94e73ef293ce64b3324d99f6e0d93a7b7744b2da05d48.
  • Observation (claude / hook:startup): surface claude -p stream-json with the candidate plugin-dir; action recipe hook:startup: startup; result passed: startup:exit-0 startup:hook-context-injected; 2 assertions machine-checked; transcript SHA-256 014ba8270aedf5521476a697060c1a7ebd7878a77d6dd6184338f5bbcadde5fb; artifact-set SHA-256 f0742b82d4de17cdfb0f1c51eb2e6e3e19ab9b7b741f57b1f407c9439a0bc2d6.
  • Observation (claude / project-skill): surface claude -p stream-json with the candidate plugin-dir; action recipe project-skill: doctor; result passed: doctor:exit-0 doctor:skill-loaded doctor:doctor-ran doctor:doctor-canonical-pass; 4 assertions machine-checked; transcript SHA-256 a3168324b71209f9463f5e94553def6f3139b30608a3dbb56c962b4c58c33c00; artifact-set SHA-256 eec3931c621885dcfe7bb9d0ebb3328a7e02c336a7e28cff606363efc1a712ba.
  • Observation (codex / hook:startup): surface codex exec --json with the run-owned candidate installation; action recipe hook:startup: startup; result passed: startup:exit-0 startup:hook-context-injected; 2 assertions machine-checked; transcript SHA-256 b00d7e92f2ac9a6c2cc4b96986a116ccb0007907029dd6239c3ed3373dc8840f; artifact-set SHA-256 7e2b7ff98528144cccd188ece3970fea13d4a3671aceeb541ce3514d7494b911.
  • Observation (codex / project-skill): surface codex exec --json with the run-owned candidate installation; action recipe project-skill: doctor; result passed: doctor:exit-0 doctor:skill-loaded doctor:doctor-ran doctor:doctor-canonical-pass; 4 assertions machine-checked; transcript SHA-256 06d7bd894ade25ba8b59a71e9b99595edcad2a38d99e226c41819a4f9a8c7e2b; artifact-set SHA-256 703a118ea4b46b0ac4e621f86b9d66df53e43bcacdc27d799e409ea9d74fca8b.
  • Policy: every new head requires a fresh run; this verifier does not change PR state, queue, or merge.

@unfret-eal unfret-eal 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.

🛑 1 blocking finding
🟡 Medium · Windows hook silently succeeds without an undocumented Bash dependency
Check

Comment thread plugins/pstack/hooks/hooks.json Resolved
…nStart hook (#127)

Unfret on head 909b297: run-hook.cmd exits 0 without context when it finds no
Bash, which the superpowers wrapper does by design, but the docs never named
the dependency. Dependencies now say Windows needs Git for Windows' bash.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ericlitman

Copy link
Copy Markdown
Owner Author

Live evidence: Open Pstack

  • Candidate SHA: fd580ad6ab8d2a67e4b18bd352bf3c08e6b1e4c7
  • Base SHA: 4f2b9b09dc9ba4f8fe08812f70bf11ec0388b201
  • Result: PASSED — named features verified
  • Self-test: completed in both harnesses
  • Publisher revision: fd580ad6ab8d2a67e4b18bd352bf3c08e6b1e4c7
  • Evidence-set SHA-256: 72032c62cebc119605edfb53806f4802468808a6321afe9b902eed52592adad0
  • Installation (claude): CLI 2.1.294 (Claude Code), plugin 1.7.0, candidate fd580ad6ab8d2a67e4b18bd352bf3c08e6b1e4c7, tree 08c31074dd2b8349b2e94e73ef293ce64b3324d99f6e0d93a7b7744b2da05d48.
  • Installation (codex): CLI codex-cli 0.160.0, plugin 1.7.0, candidate fd580ad6ab8d2a67e4b18bd352bf3c08e6b1e4c7, tree 08c31074dd2b8349b2e94e73ef293ce64b3324d99f6e0d93a7b7744b2da05d48.
  • Observation (claude / hook:startup): surface claude -p stream-json with the candidate plugin-dir; action recipe hook:startup: startup; result passed: startup:exit-0 startup:hook-context-injected; 2 assertions machine-checked; transcript SHA-256 50cf793cf792345fa29b6c38eefb15e519ceab7d35c20c156f06b38648f14f21; artifact-set SHA-256 f0742b82d4de17cdfb0f1c51eb2e6e3e19ab9b7b741f57b1f407c9439a0bc2d6.
  • Observation (claude / project-skill): surface claude -p stream-json with the candidate plugin-dir; action recipe project-skill: doctor; result passed: doctor:exit-0 doctor:skill-loaded doctor:doctor-ran doctor:doctor-canonical-pass; 4 assertions machine-checked; transcript SHA-256 b265f7a01508291b891055e95260e4e97575d9326fe6955e5340dfa06e542866; artifact-set SHA-256 ed00436f34e7035d38c7fc78a9a3f43305947382b2caa9dc80e1e08197ac0506.
  • Observation (codex / hook:startup): surface codex exec --json with the run-owned candidate installation; action recipe hook:startup: startup; result passed: startup:exit-0 startup:hook-context-injected; 2 assertions machine-checked; transcript SHA-256 c4b536996019e1d3eae88436fad1834c349e61f419b5854eae4e663f2dab182d; artifact-set SHA-256 f0152290e8c14fe6b7afebfe6d6c3b9d53facba62ff3878eb245a9d781808617.
  • Observation (codex / project-skill): surface codex exec --json with the run-owned candidate installation; action recipe project-skill: doctor; result passed: doctor:exit-0 doctor:skill-loaded doctor:doctor-ran doctor:doctor-canonical-pass; 4 assertions machine-checked; transcript SHA-256 fcd75fa6fdd9c49c59b0ee89e8cc38707976f50f6f12d952ec8f1662fc01ac21; artifact-set SHA-256 73ac3a921d31d446e71f2997354831a0ff8956ecdbce769b45e92d7c6bb5448f.
  • Policy: every new head requires a fresh run; this verifier does not change PR state, queue, or merge.

@unfret-eal unfret-eal 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.

🛑 3 blocking findings
🔴 Critical · Reject repository-relative Bash executables
🟡 Medium · Windows startup skips Bash in non-default Git installations
🟡 Medium · Windows startup still silently loses context without Bash
Check

Comment thread plugins/pstack/hooks/hooks.json Resolved
Comment thread plugins/pstack/hooks/hooks.json Resolved
@ericlitman

Copy link
Copy Markdown
Owner Author

@unfret review

@unfret-eal unfret-eal 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.

🛑 3 blocking findings
🔴 Critical · Reject repository-relative Bash executables
🟡 Medium · Interpreter discovery failure is reported as success
🟡 Medium · Discover Bash in non-default Git installations
Check

@ericlitman

Copy link
Copy Markdown
Owner Author

Operator waiver: Eric accepted these risks on head fd580ad on 2026-10-12.

All three findings concern Bash discovery in hooks/run-hook.cmd, which this PR takes near-verbatim from superpowers 7.0.0 (bb92a77):

  • Interpreter discovery failure is reported as success.
  • Reject repository-relative Bash executables.
  • Discover Bash in non-default Git installations.

main's wrapper already had each behavior, and Claude Code on Windows already runs it today. This PR adds the Codex path and narrows the relative-path exposure, because it drops the current-directory search.

What Eric accepted: the common case works, which is Git for Windows in its standard location. The remaining cases are Git in a non-default folder that is on PATH only through cmd, MSYS2 with no Git, and a relative PATH entry. They behave as they already do for Claude Code.

Follow-up:

  • The relative-PATH weakness is reported privately to superpowers (GHSA-mh5q-xvp6-c488).
  • open-pstack takes superpowers' fixed wrapper when it ships, rather than forking the file.

@mergify

mergify Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@Coldsun1

Copy link
Copy Markdown

I tested PR head fd580ad6ab8d2a67e4b18bd352bf3c08e6b1e4c7 in Codex desktop 0.162.0-alpha.17.2 on Windows after approving its SessionStart hook. With the PR plugin installed as pstack 1.7.0 and my local workaround disabled, a fresh desktop chat did not receive the pstack developer instruction. Its saved session has no <EXTREMELY_IMPORTANT> injection; a fresh CLI session also received none.

Running the PR's run-hook.cmd session-start directly through cmd.exe printed the expected context and exited 0. In an isolated diagnostic copy, changing the commandWindows value to the following made a fresh CLI session receive “You have pstack” automatically:

"commandWindows": "cmd.exe /d /s /c \"\"%PLUGIN_ROOT%\\hooks\\run-hook.cmd\" session-start\""

That diagnostic run used a one-invocation hook trust bypass because the changed definition had a new hash. I did not run the modified copy in desktop. The result points to Codex needing explicit cmd.exe invocation in commandWindows; the wrapper itself works when launched that way. I restored my local 1.6.1 workaround and confirmed injection in a fresh desktop chat. I can retest an updated PR head.

…md.exe /s /c (#127)

Coldsun1 tested head fd580ad in the Windows Codex desktop app and CLI: neither
received the pstack context. The wrapper printed it when run through cmd.exe
directly, and this commandWindows value made a fresh CLI session receive it.
Our CI emulates Codex's default COMSPEC path, where both values pass, so it
did not catch the failure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ericlitman

Copy link
Copy Markdown
Owner Author

@Coldsun1 thank you, that was exactly the test this needed. Head f2ed4b21d9efec2029b51733dd5ed18a649da6a2 now uses your commandWindows value, cmd.exe /d /s /c ""%PLUGIN_ROOT%\hooks\run-hook.cmd" session-start". Could you retest it in the desktop app and the CLI, both with a fresh chat after re-approving the changed hook? Our CI only emulates Codex's default %COMSPEC% /C path, where both the old and the new values pass, so it could not reproduce what you saw. If you know whether your Codex has a shell configured for commands, for example PowerShell, that would help explain the difference.

@ericlitman

Copy link
Copy Markdown
Owner Author

Live evidence: Open Pstack

  • Candidate SHA: f2ed4b21d9efec2029b51733dd5ed18a649da6a2
  • Base SHA: 4f2b9b09dc9ba4f8fe08812f70bf11ec0388b201
  • Result: PASSED — named features verified
  • Self-test: completed in both harnesses
  • Publisher revision: f2ed4b21d9efec2029b51733dd5ed18a649da6a2
  • Evidence-set SHA-256: bef7afecaf4c04c112dc132349afbfe87679ba4b979b68c36ad40393d61b7aee
  • Installation (claude): CLI 2.1.294 (Claude Code), plugin 1.7.0, candidate f2ed4b21d9efec2029b51733dd5ed18a649da6a2, tree 9ff45bedf415e242f481f915cd3fd7bd20f368ec3a4d0bae0b034603f6bf0aca.
  • Installation (codex): CLI codex-cli 0.160.0, plugin 1.7.0, candidate f2ed4b21d9efec2029b51733dd5ed18a649da6a2, tree 9ff45bedf415e242f481f915cd3fd7bd20f368ec3a4d0bae0b034603f6bf0aca.
  • Observation (claude / hook:startup): surface claude -p stream-json with the candidate plugin-dir; action recipe hook:startup: startup; result passed: startup:exit-0 startup:hook-context-injected; 2 assertions machine-checked; transcript SHA-256 8884497227ecd82cb0aaccc8e18bc1deee1ff2b4807faa60f191378d7186f8c9; artifact-set SHA-256 f0742b82d4de17cdfb0f1c51eb2e6e3e19ab9b7b741f57b1f407c9439a0bc2d6.
  • Observation (claude / project-skill): surface claude -p stream-json with the candidate plugin-dir; action recipe project-skill: doctor; result passed: doctor:exit-0 doctor:skill-loaded doctor:doctor-ran doctor:doctor-canonical-pass; 4 assertions machine-checked; transcript SHA-256 989c48cbd08c733ab901550c41385227c58cbbdc4f42700133026d502a83347a; artifact-set SHA-256 d4bad4364bfd6ddf3521de3ebd85e03517dca07e10cae932e030bf90b9036a1d.
  • Observation (codex / hook:startup): surface codex exec --json with the run-owned candidate installation; action recipe hook:startup: startup; result passed: startup:exit-0 startup:hook-context-injected; 2 assertions machine-checked; transcript SHA-256 a5d26d13dbdf0965614eb7222b774182f9f51cd7f07438fb5a9dc1ee87c953aa; artifact-set SHA-256 11c7e59419f5aec8061c47be58cac2b4f7853edd99b5703fb8e64821feba62d6.
  • Observation (codex / project-skill): surface codex exec --json with the run-owned candidate installation; action recipe project-skill: doctor; result passed: doctor:exit-0 doctor:skill-loaded doctor:doctor-ran doctor:doctor-canonical-pass; 4 assertions machine-checked; transcript SHA-256 282f1d6fe4e4cf8003b602221892fde093a9e14d61f4e93324f3a7c8959de827; artifact-set SHA-256 bfee6de6f7ade88839b321039092cceb47d231fd3b1e5ae008330e555878b0e2.
  • Policy: every new head requires a fresh run; this verifier does not change PR state, queue, or merge.

@unfret-eal unfret-eal 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.

🛑 5 blocking findings
🔴 Critical · Reject repository-relative Bash executables
🔴 Critical · Repository cmd.exe executes at startup
🟡 Medium · Carried: failed Bash discovery still reports hook success
🟡 Medium · Non-default Git installations lose startup context
🟡 Medium · Expanded PLUGIN_ROOT is unquoted in the outer cmd parse
Check

Comment thread plugins/pstack/hooks/hooks.json Resolved
Comment thread plugins/pstack/hooks/hooks.json Resolved
…ell and cmd (#127)

Codex runs a hook through the session's shell, which is usually PowerShell on
Windows. Main's commandWindows value is a PowerShell parse error, which is why
the reporter got no context. Head 4's value worked in PowerShell only for paths
without a space or &, and in cmd it resolved cmd.exe from the session directory
first, so a repository's cmd.exe ran at startup.

The hook now starts C:\Windows\System32\cmd.exe by full path with delayed
expansion, so the plugin path is expanded after cmd has parsed the line. The
wrapper turns delayed expansion off again so a ! in a path stays literal. The
Windows job runs the hook through cmd, Windows PowerShell and pwsh, with a
space, &, % and ! in the plugin path and a planted cmd.exe in the session
directory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ericlitman

Copy link
Copy Markdown
Owner Author

Live evidence: Open Pstack

  • Candidate SHA: acf82929fd88720feb8c766315fc2ec9c01f4ab3
  • Base SHA: 4f2b9b09dc9ba4f8fe08812f70bf11ec0388b201
  • Result: PASSED — named features verified
  • Self-test: completed in both harnesses
  • Publisher revision: acf82929fd88720feb8c766315fc2ec9c01f4ab3
  • Evidence-set SHA-256: 474cd7bdf4063efd13bf2faf2c7a498e60383e78b9216ab30311addb84939026
  • Installation (claude): CLI 2.1.294 (Claude Code), plugin 1.7.0, candidate acf82929fd88720feb8c766315fc2ec9c01f4ab3, tree e5515517f578789fcd95fbf97ae4c6c720295a0765859ea11be575177c0cc0f0.
  • Installation (codex): CLI codex-cli 0.160.0, plugin 1.7.0, candidate acf82929fd88720feb8c766315fc2ec9c01f4ab3, tree e5515517f578789fcd95fbf97ae4c6c720295a0765859ea11be575177c0cc0f0.
  • Observation (claude / hook:startup): surface claude -p stream-json with the candidate plugin-dir; action recipe hook:startup: startup; result passed: startup:exit-0 startup:hook-context-injected; 2 assertions machine-checked; transcript SHA-256 a737dc343d10696cd854de7b9f13b5e69f2848f2ff635f96bf14232f5cffab69; artifact-set SHA-256 f0742b82d4de17cdfb0f1c51eb2e6e3e19ab9b7b741f57b1f407c9439a0bc2d6.
  • Observation (claude / project-skill): surface claude -p stream-json with the candidate plugin-dir; action recipe project-skill: doctor; result passed: doctor:exit-0 doctor:skill-loaded doctor:doctor-ran doctor:doctor-canonical-pass; 4 assertions machine-checked; transcript SHA-256 7ad9c65749868b384bb40be8c9c93de9e80793c0c822305961e7c39d228cec32; artifact-set SHA-256 f7d6364ffe536369270ee2097864e35e3d42e349b09060f83bc1e413e7d1f257.
  • Observation (codex / hook:startup): surface codex exec --json with the run-owned candidate installation; action recipe hook:startup: startup; result passed: startup:exit-0 startup:hook-context-injected; 2 assertions machine-checked; transcript SHA-256 62af7ae32ded70dd7e58d0fe48f7870255d8b564a6fab3d4e6a16d07702cf1a8; artifact-set SHA-256 9a1d374b362131b21a973ac3ca583298a19da9ea1f212ab5d7cf7ae8075d964b.
  • Observation (codex / project-skill): surface codex exec --json with the run-owned candidate installation; action recipe project-skill: doctor; result passed: doctor:exit-0 doctor:skill-loaded doctor:doctor-ran doctor:doctor-canonical-pass; 4 assertions machine-checked; transcript SHA-256 1cbca78a28c379e8f5bb6fc00231beb0067a375c2389f34d430a65ed05aa4996; artifact-set SHA-256 d6ad42b38ec3c5745696ada2de280fd02f215192f92f6e2f5c7437b4c11391a3.
  • Policy: every new head requires a fresh run; this verifier does not change PR state, queue, or merge.

@ericlitman

ericlitman commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner Author

@Coldsun1 head acf82929fd88720feb8c766315fc2ec9c01f4ab3 replaces the value from your diagnostic. Codex runs hooks through the session's shell, which is PowerShell on most Windows setups. The value in fd580ad, the head you tested, is a PowerShell parse error, which explains what you saw. Your value fixed that, but on GitHub's Windows runner it broke for plugin paths with a space or &. In cmd it also ran a cmd.exe from the session directory instead of the system one.

The new value is:

"commandWindows": "C:\\Windows\\System32\\cmd.exe /d /v:on /s /c \"\"!PLUGIN_ROOT!\\hooks\\run-hook.cmd\" session-start\""

It passes in cmd, Windows PowerShell and pwsh, including a plugin path with a space, &, % and !. If you can, please retest this head in the desktop app and the CLI, each with a fresh chat after re-approving the changed hook.

@Coldsun1

Copy link
Copy Markdown

I retested head acf82929fd88720feb8c766315fc2ec9c01f4ab3 on Windows with Codex desktop and codex-cli 0.162.0-alpha.17.2 after approving the changed SessionStart hook. A fresh desktop chat and a fresh codex exec --json session both received "You have pstack." I checked the saved session records. Each contains one hook-injected developer message whose text exactly matches hooks/session-start-context.md after newline normalization. I did not bypass hook trust.

My Codex config has no explicit shell setting. The CLI startup log says it attempted a PowerShell shell snapshot, so PowerShell appears to be the selected shell for that session. The prior head failed to inject the context on this machine; this head passes in both requested Codex environments.

@unfret-eal unfret-eal 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.

🛑 4 blocking findings
🔴 Critical · Reject repository-relative Bash executables
🟡 Medium · Missed Bash discovery still reports hook success
🟡 Medium · Non-default Git installations lose startup context
🟡 Medium · Hardcoded system directory breaks non-C Windows startups
Check

Comment thread plugins/pstack/hooks/hooks.json Resolved
@ericlitman

Copy link
Copy Markdown
Owner Author

Operator waiver on head acf8292, 2026-10-13.

Carried from heads fd580ad and f2ed4b2 (Eric accepted these on 2026-10-12). All three concern Bash discovery in hooks/run-hook.cmd, which this PR takes near-verbatim from superpowers 7.0.0 (bb92a77):

  • Missed Bash discovery still reports hook success.
  • Non-default Git installations lose startup context.
  • Reject repository-relative Bash executables.

main's wrapper already had each behavior. The relative-PATH weakness is reported privately to superpowers (GHSA-mh5q-xvp6-c488), and #173 tracks taking superpowers' fixed wrapper when it ships.

New on this head (I accepted it as operator, under Eric's instruction to manage this PR): hardcoded system directory breaks non-C Windows startups.

  • Codex runs a hook through the session's shell, usually PowerShell and sometimes cmd. Its hook schema has no field that picks the shell (codex-rs/config/src/hook_config.rs, HookHandlerConfig::Command).
  • Naming cmd by full path is what closes the planted-cmd.exe finding. PowerShell does not expand %SystemRoot%, and cmd does not expand $env:SystemRoot, so only a literal path works in both shells.
  • What is accepted: on a Windows installed outside C:\Windows, the hook fails with a visible error and the session starts without the pstack context. On main, PowerShell sessions already get no context. docs/reference.md states the limit.

@ericlitman

Copy link
Copy Markdown
Owner Author

@Mergifyio queue

@mergify

mergify Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-13 04:49 UTC · Rule: default · triggered by @ericlitman with the @mergifyio queue command
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-10-13 04:49 UTC · at 779774898cabbe269574008b88d8aa7484c4670d · merge

This pull request spent 13 seconds in the queue, including 1 second running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Oct 13, 2026
@mergify
mergify Bot merged commit 7797748 into main Oct 13, 2026
6 checks passed
@mergify mergify Bot removed the queued label Oct 13, 2026
@ericlitman

Copy link
Copy Markdown
Owner Author

@Coldsun1 thank you for the careful retest, and for confirming PowerShell as the session shell. That matches what the lab on GitHub's Windows runner showed. The fix is merged and will ship in the next release (#174).

danpal35 pushed a commit to danpal35/open-pstack that referenced this pull request Oct 13, 2026
…sionStart fix (ericlitman#174)

Bumps the manifests, marketplace entry and version lines to 1.8.0, adds the
1.8.0 CHANGES.md section (registry U1 to U3 and ericlitman#127), and corrects the
NOTICE.md row for run-hook.cmd, which PR ericlitman#171 changed beyond its header.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows Codex SessionStart hook exits 1; plugin command lacks a Windows override

2 participants