Skip to content

test(hooks): align cursor smoke expectations with native flat handlers - #3198

Open
Mohammed Alkindi (MohammedAlkindi) wants to merge 2 commits into
microsoft:mainfrom
MohammedAlkindi:fix/cursor-flat-hooks-smoke
Open

Mohammed Alkindi (MohammedAlkindi) wants to merge 2 commits into
microsoft:mainfrom
MohammedAlkindi:fix/cursor-flat-hooks-smoke

Conversation

@MohammedAlkindi

Copy link
Copy Markdown
Contributor

Description

Daily smoke has failed since #3149 moved Cursor to preToolUse with flat handlers. Two cursor tests still expected the old shape. The drift test now reads preToolUse and seeds a flat user hook. The audit test expects a nested Cursor group reported incomplete (native hook event requires flat handlers). Tests only.

280b8a7b: 2 failed, 9 passed (both [cursor])
331086c7: both [cursor] cases pass

Issue and approved scope

Issue: #3166

Human scope-approval comment: none; #3166 is the bot-filed smoke tracker.

Does this PR complete the issue, or what remains? Should clear the smoke.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Spec conformance (OpenAPM v0.1)

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via uv run --extra dev python -m tests.spec_conformance.gen_statement and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

microsoft#3149 renders Cursor hooks under camelCase native events with flat
handlers, but two integration tests still expected the old shape and
have kept the scheduled smoke red since:

- the root source drift test read the ownership sidecar under
  PreToolUse instead of preToolUse, and seeded a nested user hook that
  Cursor's strict validator now rejects on reinstall;
- the audit contract test expected a nested group in .cursor/hooks.json
  to be silently not-applicable, while audit now reports it as
  incomplete coverage because Cursor does not load nested handlers.

Refs microsoft#3166

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The updated tests can miss user-hook mutation and still use a non-native Cursor event in the audit fixture.

2 open findings
What changed in this PR

Updates Cursor integration tests to match native camel-case events and flat handlers.

Changes:

  • Uses preToolUse and flat user hooks for Cursor drift tests.
  • Updates audit expectations for nested Cursor handlers.
File Description
tests/​integration/​test_hook_root_source_drift_e2e.py Aligns Cursor drift fixtures with flat handlers.
tests/​integration/​test_audit_primitive_contract.py Expects nested Cursor handlers to be incomplete.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +709 to +712
if target == "cursor" and nested:
# Cursor loads only flat handlers, so a nested group is reported, not read.
assert [(entry.pointer, entry.diagnostic) for entry in result.incomplete] == [
("/hooks/PreToolUse/0", "native hook event requires flat handlers")
and isinstance(e["hooks"][0], dict)
and e["hooks"][0].get("command") == "echo user-owned"
]
user_owned = [e for e in entries if _is_user_owned(e)]

Copilot AI commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

One or more custom setup steps configured for this repository failed during this Copilot code review run:

Sync dependencies with uv

Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review.

Note

You can configure setup steps for Copilot code review separately from Copilot cloud agent with a copilot-code-review.yml file. Read the docs for details.

This branch has not been deployed

No deployments
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