Skip to content

fix(codex): restore Superpowers after compaction - #2035

Draft
arittr wants to merge 3 commits into
codex/sdd-review-loop-fixfrom
codex-spinout-fixes
Draft

fix(codex): restore Superpowers after compaction#2035
arittr wants to merge 3 commits into
codex/sdd-review-loop-fixfrom
codex-spinout-fixes

Conversation

@arittr

@arittr arittr commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Who is submitting this PR? (required)

Field Value
Your model + version Branch authoring: Anthropic Claude Fable 5 (claude-fable-5). Stack preparation/submission: OpenAI gpt-5.6-sol at max effort.
Harness + version Branch authoring: Claude Code 2.1.216–2.1.218. Stack preparation/submission: Codex Desktop 0.146.0-alpha.3.1.
All plugins installed Claude Code authoring environment: cloud-build, decision-log, elements-of-style, episodic-memory, greenfield, iterative-development, linear, primeradiant-ops, superpowers-chrome, superpowers (local dev), unifi-network. Codex submission environment: documents, pdf, spreadsheets, presentations, template-creator, sites, browser, computer-use, visualize, primeradiant-ops, linear, slack, github, codex-security, superpowers (local dev), cloud-build.
Human partner who reviewed this diff Drew Ritter — reviewed and approved the complete combined diff on 2026-07-24, then explicitly directed this exact split. This PR is the upper hook/package subset of that reviewed diff.

The commits identify Claude Fable 5 as co-author. Codex performed the current-dev rebase, 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 SessionStart with source: "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 SessionStart hook 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?

  • Skill prose and boundary hints only. Rejected as the sole mechanism because compaction removes the global bootstrap and platform instructions from active context. The hints remain a fallback at scripted boundaries but cannot restore the whole instruction set.
  • A user-level ~/.codex/hooks.json entry. 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.
  • Restore an unconditional startup hook. Rejected because modern Codex discovers skills natively at startup; duplicating the bootstrap there recreates the redundancy that caused the previous hook to be removed.
  • Inject on every SessionStart source. Rejected because the measured gap is post-compaction. The manifest and script both gate on compact, while startup and malformed payloads are silent no-ops.
  • Create a standalone plugin. Rejected because this repairs lifecycle behavior for an already-supported core harness rather than adding a project-specific workflow or dependency.

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.

Environment tested

Harness Harness version Model Model version/ID
Codex App manual compact/resume probes Codex 0.145.0 family GPT-5.6 Sol parent with explicit Terra child routing gpt-5.6-sol; gpt-5.6-terra
Codex hook discovery/compact probes Codex app-server 0.146.0-alpha.3 n/a hook lifecycle and injected-context inspection
Fresh upper-layer deterministic checks macOS, bash/zsh n/a hook, manifest, package, shell-lint, and cross-harness SessionStart tests

New 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"
Not applicable: this PR does not add a new harness and intentionally leaves Codex's native clean-session startup path unchanged.

Evaluation

  • Initial prompt: Drew reported that long Codex SDD runs drifted after compaction and could continue for 8+ hours without finishing, even when the same work completed in 1–2 hours in Claude Code.
  • Eval sessions after the change: two manual Codex App validation runs plus focused sentinel/app-server hook probes. The broader SDD RED/GREEN campaign is documented in the lower PR, fix(codex): bound SDD dispatch and final review #2036.
  • Before/after: before the hook, compaction replaced the active instructions with a summary and the next dispatch could omit the required routing tuple. After installation and trust, startup emitted nothing while post-compaction SessionStart injected 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:

git diff --check codex/sdd-review-loop-fix...codex-spinout-fixes
bash tests/claude-code/test-sdd-workspace.sh
bash tests/hooks/test-session-start-codex.sh
bash tests/codex/test-marketplace-manifest.sh
bash tests/codex/test-package-codex-plugin.sh
bash tests/shell-lint/test-lint-shell.sh
bash tests/hooks/test-session-start.sh

All six test commands and the diff check passed on the upper branch.

Rigor

  • If this is a skills change: I used superpowers:writing-skills and completed adversarial pressure testing (results in fix(codex): bound SDD dispatch and final review #2036 and hook probes above)
  • This change was tested adversarially, not just on the happy path
  • I did not modify carefully-tuned content (Red Flags table, rationalizations, "human partner" language) without extensive evals showing the change is an improvement

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

  • A human has reviewed the COMPLETE proposed diff before submission

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.

arittr and others added 3 commits July 24, 2026 12:31
…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>
@arittr
arittr changed the base branch from dev to codex/sdd-review-loop-fix July 24, 2026 21:23
@arittr arittr changed the title fix(codex): keep SDD runs bounded across compaction fix(codex): restore Superpowers after compaction Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant