Skip to content

fix(hooks): copilot self heal dual hooks (drop camelCase entry) - #3449

Merged
aeppling merged 5 commits into
developfrom
feat/copilot-hook-self-heal
Aug 6, 2026
Merged

aeppling merged 5 commits into
developfrom
feat/copilot-hook-self-heal

Conversation

@aeppling

@aeppling aeppling commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Self-heal stale Copilot hook configs left by pre-fix(hooks): stop Copilot from silently deciding permission on unconfigured commands #3212 rtk init --copilot: on a legacy camelCase preToolUse invocation, remove rtk's own duplicate camelCase entry from rtk-rewrite.json (project + global) so upgrades need no manual re-init
  • Surgical and fail-safe: only the exact stock rtk entry is removed, user hooks/keys/order preserved, PascalCase entry required before touching anything; any other shape, IO failure, or malformed file is a silent no-op
  • Atomic write (temp + rename), no effect on healthy installs; code path only reachable via the stale registration itself

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • tests/copilot_selfheal_test.rs: 13 real-binary e2e tests (sandboxed HOME/COPILOT_HOME); heal correctness, 10-case refusal matrix, response byte-identical pre/post heal, concurrency, unwritable dir, exit 0 + silent stderr everywhere
  • Manual testing: stale/healthy/JetBrains payloads piped to rtk hook copilot, configs and responses inspected

Legacy camelCase invocation rewrites the old stock config to the single-schema form, so upgrades need no manual rtk init --copilot.
Match the exact stock camelCase entry instead of the whole file, so extended configs (extra hooks/keys) heal too; anything non-stock stays untouched.
Real-binary tests: heal correctness, refusal matrix, response integrity, concurrency, unwritable dir.
@aeppling
aeppling marked this pull request as ready for review August 5, 2026 15:09

@KuSh KuSh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a nitpick and a question (non blocking)

Comment thread src/hooks/hook_cmd.rs
// Exact camelCase entry written by pre-b754b85 `rtk init --copilot`; that
// stale registration is the only thing routing invocations into the
// CopilotCli arm above. Only this entry is removed — user additions stay.
fn legacy_camelcase_entry() -> Value {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: use OnceLock for lazy init

Comment thread src/hooks/hook_cmd.rs Resolved
@aeppling aeppling mentioned this pull request Aug 6, 2026
@aeppling
aeppling merged commit 9936b2b into develop Aug 6, 2026
16 checks passed
@aeppling
aeppling deleted the feat/copilot-hook-self-heal branch November 18, 2026 17:23
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.

2 participants