Skip to content

Fix schema-clean JSON hook installs#50

Merged
KristjanPikhof merged 25 commits into
mainfrom
fix/schema-clean-json-hooks
Jun 20, 2026
Merged

Fix schema-clean JSON hook installs#50
KristjanPikhof merged 25 commits into
mainfrom
fix/schema-clean-json-hooks

Conversation

@KristjanPikhof

Copy link
Copy Markdown
Owner

Bug Description

JSON hook installs needed to be schema-clean while still being detectable and diagnosable by ACD.

Expected:

  • Codex, Claude Code, and Cursor JSON hook templates do not emit legacy _acd_managed.
  • ACD detects schema-clean JSON installs from hook command signatures.
  • acd doctor reports missing active hooks as drift.
  • Uninstall docs identify every ACD lifecycle hook, including stop/flush/touch entries.

Actual:

  • Legacy JSON marker guidance no longer matched Codex 0.141+ schema behavior.
  • Schema-clean JSON detection needed command-signature support.
  • A SessionStart-only Codex/Claude install could be treated as healthy.
  • Uninstall docs could miss stop/flush/touch hooks because those commands do not carry --harness.

Root Cause

JSON install detection was tied to the legacy top-level _acd_managed marker. After removing that marker, ACD needed format-aware command-signature detection and drift checks that count missing active JSON hook events, not just stale commands that still exist.

Type of Change

  • Bug fix

Fix Description

  • Remove _acd_managed from JSON hook templates.
  • Detect JSON installs from ACD hook command signatures while preserving legacy marker fallback.
  • Warn through acd doctor for legacy JSON markers and missing Codex/Claude active hooks.
  • Update Codex/Cursor/Claude docs and uninstall instructions for schema-clean installs.
  • Add regression coverage for JSON detection, doctor drift, setup output, and uninstall docs.

How to Verify

  1. acd setup codex --raw emits JSON with only hooks at the top level.
  2. acd doctor --json reports drift for schema-clean Codex/Claude installs missing PreToolUse and PostToolUse.
  3. Uninstall docs include lifecycle-only commands such as acd touch, acd flush --logical, and acd stop.

Testing

  • git diff --check 30c4c38455d81c71e7a3c2a3a9a86f659bb19f43...HEAD
  • cleanenv make lint
  • cleanenv make test

Impact Assessment

  • Severity: Medium
  • Users affected: Users installing or diagnosing JSON harness hooks for Codex, Claude Code, or Cursor
  • Duration: Relevant for Codex 0.141+ schema validation and this branch's schema-clean hook migration

Regression Risk

  • JSON harness install detection
  • acd doctor drift reporting
  • Setup/uninstall docs for Codex, Claude Code, and Cursor

Checklist

  • Root cause identified and documented above
  • Fix addresses the root cause
  • Added tests to prevent regression
  • Existing tests pass locally
  • Tested the specific drift and docs coverage paths
  • No new warnings introduced by lint

Related Issues

None found in branch name or commit messages.

- Drop obsolete managed markers from all hook templates.
- Keep the snippets aligned with the current config shape.
- Avoid carrying metadata that no longer affects behavior.
- Generalize config detection from static markers to detectors
- Preserve legacy JSON _acd_managed detection for migration paths
- Support JSON command signature matching without relying on spacing
- Keep per-path install detection consistent across both callers.
- Replace marker-slice checks with the resolved detector field.
- Stop treating top-level `_acd_managed` as an install detector input.
- Report the legacy Codex marker in doctor output with migration
  guidance.
- Keep schema-breaking Codex configs visible without accepting them as
  installs.
- Expand detection tests to cover both signature-based and legacy JSON
  markers.
- Add a reusable helper for asserting top-level JSON shape in setup
  tests.
- Keep test fixtures aligned with the current hook schema while
  preserving legacy compatibility coverage.
- Ensure setup JSON no longer emits the legacy _acd_managed marker.
- Tighten canonical hook schema checks before unmarshaling the JSON
  block.
- Keep coverage aligned across Claude Code, Cursor, and Codex setup
  output.
- Tighten setup tests to expect the canonical hook JSON shape
- Remove legacy top-level markers from the schema assertions
- Keep invalid-JSON checks aligned with the current templates
- Drop the redundant top-level marker assertion from the Claude Code
  stop-hook test.
- Update the Codex fixture to use the canonical hook JSON shape so the
  test covers real setup output.
- Use canonical snippets for setup fixtures instead of inline JSON.
- Treat schema-clean hooks.json separately from legacy _acd_managed
  cases.
- Add regression coverage for legacy Codex JSON marker handling.
- Reuse the canonical hooks.json snippet in repo-local and home-based
  tests
- Match doctor expectations to the newer hook-stdin-extract signature
- Fix a misleading JSON unmarshal failure message in the Codex marker
  test
- Refresh hook setup and doctor expectations for the new Cursor JSON
  shape
- Verify raw setup output stays valid JSON and doctor drift checks use
  the updated hook body/snippet format
- Clarify doctor diagnostics for alternate config-path installs
- Use consistent ACD wording in notes and duplicate-hook warnings
- Improve readability of hook conflict messages without changing logic
- Explain that raw setup now emits strict hooks.json with only hooks.
- Warn that old _acd_managed markers are legacy-only fallback data.
- Clarify uninstall and doctor guidance for mixed or duplicated
  installs.
- Remove obsolete `_acd_managed` references from hook install docs
- Clarify uninstall steps for older installs and merged custom hooks
- Keep the guidance aligned across Claude Code and Cursor templates
- Codex 0.141+ rejects unknown top-level hook fields.
- Keep the changelog aligned with the new JSON hook template behavior.
- Preserve legacy `_acd_managed` handling for migration and doctor flow.
- Limit legacy `_acd_managed` checks to the emitted JSON block.
- Avoid false positives from surrounding shell/setup output.
- Keep Claude Code, Cursor, and Codex assertions aligned.
- Keep the marker declarations aligned for readability
- No behavior changes; this is a formatting-only cleanup
- Keep doctor diagnostics aligned with alternate config locations.
- Preserve the legacy _acd_managed warning for repo-local Codex hooks.
- Extend coverage so the warning is verified from a repo-local install.
- Match only acd-managed hook objects by command/harness.
- Preserve merged custom hooks by removing empty event keys only.
- Update uninstall guidance for Claude Code, Codex, and Cursor.
- Simplifies the legacy _acd_managed guidance to favor schema-clean
  regeneration and manual preservation of custom hooks.
- Keeps doctor warnings and tests aligned with the revised remediation
  text.
- Updates the Codex template docs to match the new recommendation.
- Treat Claude Code and Codex JSON hooks like other active-hook
  harnesses
- Count missing PreToolUse/PostToolUse entries as drift for these
  configs
- Add regression coverage for JSON-backed harnesses missing active hooks
- Align uninstall instructions with the current hook command forms.
- Replace outdated harness-based matching with the commands now used.
- Keep removal guidance consistent across Claude Code, Codex, and
  Cursor.
- Extend setup test coverage for uninstall documentation
- Verify each harness uninstall snippet lists its lifecycle commands
- Catch regressions where docs drift from the supported command flow
- Reflects the new doctor behavior for Codex and Claude Code installs
  when required hooks are missing.
- Notes the uninstall documentation fix so JSON harness guidance covers
  all lifecycle hooks, including commands without `--harness`.
- Keeps the changelog aligned with the actual drift-detection and docs
  behavior changes in this branch.
- Retry fixture cleanup after macOS runner unlink races

- Use an explicit temp directory so teardown can wait for git I/O

- Keep bootstrap assertions focused on shadow behavior
@KristjanPikhof KristjanPikhof self-assigned this Jun 20, 2026
@KristjanPikhof KristjanPikhof marked this pull request as ready for review June 20, 2026 23:38
@KristjanPikhof KristjanPikhof merged commit 7ff8fca into main Jun 20, 2026
6 checks passed
@KristjanPikhof KristjanPikhof deleted the fix/schema-clean-json-hooks branch June 20, 2026 23:38
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