Skip to content

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

Closed

Description

@Coldsun1

Plan (maintainer, 2026-10-12)

Eric chose this plan on 2026-10-12. The original report follows below, unchanged.

Scope (revised after the 2026-10-12 design pass)

  • Wrapper. Take the whole superpowers 7.0.0 hooks/run-hook.cmd (bb92a77), keeping the port's adaptation header, and update its NOTICE.md row.
  • session-start. Read the adjacent context file with Bash built-ins, so a Git Bash without /usr/bin on PATH still prints the context. Exit nonzero when the file is missing.
  • hooks.json. Add the Codex commandWindows override that runs the wrapper through cmd.exe, and keep the generic command. resume is deferred (see the design-pass comment).
  • Verifier. A startup-hook case for Claude Code and for Codex in .claude/skills/verify-open-pstack/features/recipes.ts, asserting from the native record that the pstack context reached the session. Map the new workflow file in features/registry.json under project.
  • Windows CI job on GitHub's windows-latest runner:
    • On every PR, run the wrapper directly with no login: it exits 0 and prints the context, with an ordinary and a restricted PATH and a plugin path containing spaces, and it exits nonzero when the context file or the script is missing.
    • The interactive Codex login job is dropped (2026-10-12). Unfret showed that a real login on a runner that runs pull request code exposes the credential, so CI never holds a login.

Acceptance criteria

  • The wrapper checks pass on windows-latest.
  • The labeled Codex run on windows-latest shows the SessionStart context in a real session. Dropped with the login job. The reporter confirms the Codex desktop app on the exact head; that confirmation is evidence, not a merge gate.
  • 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.
  • Bun tests, strict typecheck, static invariants and plugin validation pass.

Constraints

  • The workflow change sits under .github/, so Eric queues the PR by hand.
  • The Windows run is evidence beside the Mac live-gate, which stays the merge gate. The verifier refuses non-Darwin hosts.
  • Not covered: the Codex desktop app on Windows. The reporter can confirm it on the exact head.

Original report

Environment

  • Windows Codex desktop app
  • pstack@open-pstack 1.5.0, enabled and hook trusted
  • Git for Windows installed at C:\Program Files\Git

Actual behavior

Starting a Codex chat shows one failed plugin SessionStart run: hook exited with code 1. The pstack context is absent from the chat. The user can run a locally patched hook directly and get the expected You have pstack. context. The stock 1.5.0 script fails when run directly with Git Bash on this machine.

Expected behavior

The automatic SessionStart run should exit 0 and add the pstack context to the new or resumed chat.

Reproduction

  1. Install and enable pstack 1.5.0 on Windows and trust its hook.
  2. Start a new Codex chat and inspect Hook stats. The plugin SessionStart run fails with exit code 1.
  3. Run the stock hooks/session-start with Git Bash. It reports dirname: command not found and cat: not found and exits 127. The stock run-hook.cmd session-start wrapper reports exit 0 despite those errors.
  4. Repair the script locally and call it directly. It prints the expected context, but a plugin cache refresh restores the stock files and the automatic failure returns.

Findings

  • hooks/hooks.json supplies only a generic command containing ${CLAUDE_PLUGIN_ROOT}. Codex supports a Windows-specific commandWindows field, but pstack does not set it. The missing override is a likely cause of the automatic launch failure; the desktop Hook stats do not expose stderr, so this particular cause is not yet directly confirmed from that run.
  • The matcher is startup|clear|compact, so it omits Codex's resume source.
  • Git Bash on this machine starts without /usr/bin on PATH. The session-start script then cannot find dirname or cat and exits 127.
  • run-hook.cmd uses %ERRORLEVEL% inside parenthesized blocks. cmd.exe expands that value before Bash runs, so the wrapper can report 0 even when the script fails. A missing script reproduced this false success.
  • The installed plugin cache was refreshed after a local patch. This restored the three stock files and made the failure recur.

Proposed fix

  • Add commandWindows that invokes the wrapper through cmd.exe and %PLUGIN_ROOT%.
  • Include resume in the matcher.
  • Make session-start read its adjacent context file using Bash built-ins, without depending on PATH.
  • Use delayed expansion for !ERRORLEVEL! in the Windows wrapper.

A local source patch is prepared in plugins/pstack/hooks/{hooks.json,session-start,run-hook.cmd}.

Verification performed

  • The configured Windows command exits 0 and prints the expected context.
  • A missing context file exits 1; a missing script exits 127.
  • In a fresh ephemeral Codex session using the patched local plugin and one-run hook-trust bypass, the agent confirmed that the You have pstack. developer context was present. This test did not use the desktop app's installed cache.

Changing the hook definition changes its trust hash, so users need to review and trust the updated hook before normal automatic runs resume.

Activity

  1. ericlitman commented on Oct 12, 2026

    @ericlitman
    Owner

    Thanks for the detailed report and the patch. Here's the plan:

    • Take superpowers' current run-hook.cmd, which already fixes the %ERRORLEVEL% expansion you found.
    • Add the Windows command for Codex and the resume matcher, and make session-start independent of PATH, along the lines you proposed.
    • Verify on a GitHub Actions Windows runner with a real Codex session.

    The plan is now at the top of this issue. When the PR is up, it would help a lot if you could install that exact head in the Codex desktop app on your machine and confirm the hook runs. CI covers the CLI, not the desktop app.

  2. ericlitman commented on Oct 12, 2026

    @ericlitman
    Owner

    Design pass (2026-10-12, Astra high, read-only at a41d063)

    Record: ~/projects/docs/projects/open-pstack/records/2026-10-12-batch-153/design-127.md (private docs repo).

    Accepted

    • Take the whole superpowers 7.0.0 run-hook.cmd (bb92a77), keeping the port's adaptation header and updating its NOTICE.md row. It already fixes exit propagation, adds per-user Git discovery and skips the WSL launchers, so delayed expansion is unnecessary.
    • session-start: use upstream's adjacent-file path and built-in read techniques, but keep pstack's nonzero exit when the context file is missing. Upstream prints error text and succeeds. Do not import its multi-platform JSON output.
    • hooks.json: add the Codex commandWindows override that runs the wrapper through cmd.exe, and keep the generic command. Claude Code does not document commandWindows. The PR shows that Claude still loads the hook.
    • A new workflow file throws Unmapped path in the verifier. Map it under project, which makes this PR a verifier change: the live run uses the candidate head as publisher revision with --self-test.
    • The verifier has no hook recipe, so the Mac live gate cannot test the changed session-start today. Add a startup-hook case for each harness. First establish that the native Claude stream and the Codex rollout show the injected context. If either does not, stop and report.
    • GitHub allows workflow_dispatch only for a workflow on the default branch, so a new workflow cannot prove itself before merge. The Windows Codex job also runs on pull_request when Eric adds a label, for same-repository PRs only, so fork code never runs beside his login. Manual dispatch stays for later runs. Upload only the intended evidence, never the Codex home.

    Rejected or deferred

    • resume in the matcher, deferred. Superpowers' matcher also leaves it out. Adding it changes Claude Code, which would re-inject the context on every resumed session. No resumed session has been shown missing the context. This also drops the resume recipes. Reopened if a resumed Codex session shows the context missing.
    • WarpBuild as a planned fallback. If upterm's relay is down, revisit then.
  3. ericlitman commented on Oct 12, 2026

    @ericlitman
    Owner

    This PR will also carry one line for #166: removing the unexplained 5,000-byte cap on the Claude Reflect report (f7c9c3a, Eric 2026-10-12). It edits the same verifier file, features/recipes.ts.

  4. added a commit that references this issue on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions