Repository navigation
fix(audit): ignore hook sidecar object-key order - #3155
Daniel Meppiel (danielmeppiel) merged 11 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Nonstandard JSON constants remain accepted, and required architecture and bundled-guide updates are missing.
Review effort: Balanced
Findings: 2
Open (3)
What changed in this PR
Fixes false drift findings caused by JSON object-key ordering in hook ownership sidecars.
Changes:
- Canonicalizes sidecar JSON while preserving values and list order.
- Adds unit and end-to-end regression coverage.
- Updates audit documentation.
| File | Description |
|---|---|
src/apm_cli/integration/hook_ownership.py |
Adds sidecar canonicalization. |
src/apm_cli/install/drift.py |
Uses canonical comparison for sidecars. |
src/apm_cli/install/manifest_reconcile.py |
Updates reconciliation documentation. |
tests/unit/install/test_drift.py |
Covers sidecar comparison cases. |
tests/integration/test_hook_sidecar_drift_e2e.py |
Tests install and audit lifecycle. |
docs/src/content/docs/reference/cli/audit.md |
Documents JSON comparison behavior. |
docs/src/content/docs/reference/baseline-checks.md |
Updates drift-check semantics. |
docs/src/content/docs/enterprise/drift-detection.md |
Updates enterprise guidance. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Resume the retained ee08bb5 merge without discarding contributor work. Consolidate the duplicate Fixed heading identified by the documentation panel. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Preserve marketplace, unmatched-skill and SSH changes from main. Resolve only the overlapping release-note insertion, retaining both entries. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Address the retained architecture, performance and DevX panel nits: annotate the rejecting callback, reuse the linter scan inventory and keep the three public audit guides aligned with bundled constant-rejection guidance. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Preserve canonical user-scope cleanup and containment coverage while retaining the bounded sidecar comparison repair. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Preserve current docs and dashboard dependency updates before exact-head validation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Move the unchanged drift logger to its existing rendering module to retain the install-engine LOC budget without changing output or import contracts. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
APM review advisory:
|
b71cb47
into
microsoft:main


Description
A clean install can fail
apm audit --ciwhen a consumer already has Claude hook events: the live merge and the empty scratch replay write ownership sidecar keys in different orders. Compare registered hook sidecars as UTF-8 JSON, preserving every field and list order while ignoring object-key order and formatting. Invalid encoding, malformed JSON, duplicate keys and non-JSON constants (NaN,Infinity,-Infinity) still produce drift findings. The existing ownership guard protects this comparison and its drift call sites; bundled CLI guidance matches the public documentation.Shared native hook configurations continue to compare only APM-owned entries. Lockfile hashing and ownership decisions are unchanged.
Issue and approved scope
Fixes #3062.
Human scope approval: #3062 (comment)
This covers the approved false-positive repair and preserves meaningful drift detection.
Type of change
Testing
The hermetic install/install/audit regression fails against the original source and passes with this change. It checks stable repeated installation, preservation of user hooks and read-only audit. Unit cases cover key reordering, changed commands/value types, entry removal, added events, execution order, duplicate keys, malformed JSON and unsupported UTF-16/32 encodings.
uv run pytest tests/unit/install/test_drift.py tests/integration/test_drift_check.py tests/integration/test_hook_sidecar_drift_e2e.py tests/unit/integration/test_hook_integrator.py tests/unit/integration/test_hook_integrator_defect_regression.py tests/unit/install/test_drift_phase3.py tests/integration/test_drift_check_e2e.py -q: 364 passed. Four architecture mutation regressions also pass; they cover missing comparison authority, duplicate ownership, and bypassed drift call sites.The six CI test-quality/architecture-ratchet modules also pass locally: 91 passed. Full-source Ruff lint/format and pylint duplication checks, YAML I/O/file-length/portable-path guards, auth and architecture boundary checks, and
git diff --checkpass. The full functional suite and Windows runtime were not run locally; these are local checks, not a claim that GitHub CI has run.Spec conformance (OpenAPM v0.1)
No normative requirement changes: sidecars are outside the deployed-file hash maps governed by req-lk-012/017, and this change does not alter the ownership/reconciliation obligations in req-lk-021.