fix(codex): restore Superpowers after compaction - #2035
Draft
arittr wants to merge 3 commits into
Draft
Conversation
…sionStart hook Codex 0.145 re-fires SessionStart with source:"compact" after every context compaction, and injects hook stdout into the live model context (both verified with sentinel probes on codex-cli 0.145.0). Compaction replaces the transcript with a summary that sheds the using-superpowers bootstrap and the active skill's instructions; in instrumented SDD runs the first post-compaction dispatch that lacked a freshly printed reminder reverted to harness defaults (fork_turns=all, inherited frontier model) and the drift then self-perpetuated. Claude Code never exhibits this because its SessionStart matcher (startup|clear|compact) re-injects the bootstrap at the same moment — this hook restores that parity on Codex. On source:"startup" the hook emits nothing: the native plugin path owns session-start injection, and duplicating it would recreate the redundancy that led to the original session-start-codex removal. Output is plain text (Codex consumes raw stdout, unlike the JSON envelopes hooks/session-start emits for other harnesses), and every failure path is fail-open: bad stdin, missing skill file, or any error yields empty output and exit 0 so a hook problem can never break a session. Ships with hooks-codex.json.example for the user-level ~/.codex/hooks.json merge and tests covering source filtering, whitespace-tolerant matching, decoy fields, and fail-open behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…d drift-cure footer README gains the hook install step for Codex users (hooks.json merge, one-time trust prompt, --dangerously-bypass-hook-trust for headless automation). codex-tools.md aligns its claims with the mechanism — the dispatch rules bind every spawn, the printed hints appear at scripted boundaries, and the hook covers post-compaction re-grounding — and adds a section telling controllers compaction sheds these instructions and to treat every printed hint as authoritative. The hints file gains a drift-cure footer both scripts print after the role line: in the instrumented run that broke post-compaction, reprinted hints alone did not heal the already-broken dispatch pattern across three subsequent boundaries — recovery text must name the drift and prescribe the re-read. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The compaction re-injection hook previously required users to hand-merge an example into user-level ~/.codex/hooks.json — which renders in the Codex hooks UI as an anonymous, unattributed "Hook 1" and puts the install burden on every user. Restore the plugin-provided delivery this repo used before "Remove Codex hooks" (640ce6c): the Codex manifest points hooks at hooks/hooks-codex.json, which runs session-start-codex via ${PLUGIN_ROOT}/hooks/run-hook.cmd with matcher "compact". Unlike the removed hook, this one never fires at session start — Codex surfaces skills natively there, which is why the old startup-injecting hook was removed. The matcher plus the script's own source gate restrict it to post-compaction re-starts. The explicit manifest pointer also keeps suppressing Codex's hooks/hooks.json auto-discovery fallback, which the previous empty-object declaration existed for (7d8d3d4). The Codex portal archive now ships hooks/hooks-codex.json, hooks/run-hook.cmd, and hooks/session-start-codex; other-harness hook files stay excluded. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Who is submitting this PR? (required)
claude-fable-5). Stack preparation/submission: OpenAIgpt-5.6-solat max effort.The commits identify Claude Fable 5 as co-author. Codex performed the current-
devrebase, deterministic verification, duplicate search, stack split, and PR update.This is PR 2 of 2 and depends on #2036.
What problem are you trying to solve?
Long Codex SDD sessions lost the Superpowers bootstrap and active skill instructions after context compaction. The first post-compaction dispatch then reverted to harness defaults, and once one child was spawned with inherited full-history frontier settings, that broken pattern became its own precedent for later dispatches.
Codex already discovers skills natively at normal startup, so restoring the old unconditional startup injector would duplicate instructions and recreate a previously removed behavior. The missing lifecycle point is specifically
SessionStartwithsource: "compact".This upper layer preserves the SDD routing and bounded-review policy introduced by #2036 across compaction. Without it, the lower PR's printed boundary hints remain a fallback, but the global bootstrap and platform instructions are still absent from the compacted context.
What does this PR change?
This PR adds a plugin-provided Codex
SessionStarthook that is silent at startup, re-injects the bootstrap and a focused re-read addendum after compaction, and fails open on malformed input or missing files. It wires that hook into the Codex manifest and portal package, documents its trust/install behavior, adds a drift-cure footer to SDD boundary hints, and tests the hook lifecycle, manifest, archive contents, and cross-harness non-regression behavior.Is this change appropriate for the core library?
Yes. Codex is an existing first-class Superpowers harness, and preserving active Superpowers instructions across the harness's compaction lifecycle is core integration infrastructure. The hook adds no third-party dependency, is limited to Codex's existing plugin path, and remains silent during normal startup so native skill discovery continues to own that path.
What alternatives did you consider?
~/.codex/hooks.jsonentry. Tested, but it is manual, anonymous in the hooks UI, and not delivered with the plugin. The plugin-provided hook has correct provenance and installation behavior.compact, while startup and malformed payloads are silent no-ops.Does this PR contain multiple unrelated changes?
No. The hook, manifest wiring, package inclusion, trust documentation, drift-cure footer, and tests are one delivery path for post-compaction instruction restoration. The separable SDD routing/review-loop changes are isolated in the lower PR, #2036.
Existing PRs
No duplicate PR was found for a Codex compaction-only bootstrap re-injection hook packaged with the plugin.
compact, but the old startup hook was later removed. This implementation restores only the needed compact behavior and emits nothing at startup.hooksobject to suppress fallback auto-discovery. This PR replaces it with an explicit Codex hook manifest, which still avoids accidentalhooks/hooks.jsondiscovery.Environment tested
gpt-5.6-sol;gpt-5.6-terraNew harness support (required if this PR adds a new harness)
Not applicable. Codex is already supported; this restores instructions at a missing lifecycle event in that existing harness.
Clean-session transcript for "Let's make a react todo list"
Evaluation
SessionStartinjected exactly one bootstrap/restoration record; a resumed live session retained correctly routed dispatches across two compactions.The hook was tested with startup, compact, whitespace-varied, empty, malformed, and decoy payloads. Packaging tests verify that the manifest points at the Codex hook and that the portal archive contains the config, script, and cross-platform runner while excluding other harness hooks.
No new behavioral eval was run merely to split the already-reviewed branch. Fresh split verification was deterministic:
All six test commands and the diff check passed on the upper branch.
Rigor
superpowers:writing-skillsand completed adversarial pressure testing (results in fix(codex): bound SDD dispatch and final review #2036 and hook probes above)The pressure cases included startup-versus-compact source discrimination, malformed and misleading input, missing-file fail-open behavior, post-compaction dispatch drift, and Claude Code/Cursor/Copilot hook-output regression coverage. The drift-cure footer reflects the observed failure mode where reprinted hints alone did not heal an already-broken dispatch pattern.
Human review
Drew reviewed the complete combined GitHub compare, explicitly approved submission on 2026-07-24, and then requested this exact two-PR split. This upper PR is an unchanged subset of that reviewed diff.