Skip to content

fix(audit): one message for a changed package copy across owners - #4485

Closed
Daniel Meppiel (danielmeppiel) wants to merge 3 commits into
mainfrom
danielmeppiel-h-a2-audit-drift-message
Closed

Daniel Meppiel (danielmeppiel) wants to merge 3 commits into
mainfrom
danielmeppiel-h-a2-audit-drift-message

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

apm audit --ci names a changed package copy with one message, whichever owner detects it:

  • the audit materialization check (install/audit_replay.py),
  • native Agent Plugin admission (install/native_plugin_admission.py),
  • the Codex native registrar (codex_plugins/registrar.py).

All three now build the message through core/cache_drift.py: <subject>: package cache differs from its locked content; <remedy>. Each owner keeps its existing remedy. What counts as drift is unchanged.

Follow-up to #4470 (#4449): the codex lifecycle test now pins the single message for every drift case (hashed file, unhashed cache file, mode change), replacing the two per-source needles.

Issue and approved scope

Fixes #4480 -- scope record: #4480 (comment)

Completes the issue.

Type of change

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

Testing

  • Tested locally (host overloaded; per the PM, train CI validates this change)
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Updated assertions:

  • tests/integration/test_codex_native_plugin_lifecycle.py (_audit_cache): one message for every case, and the old replay wording is absent.
  • tests/integration/test_native_plugin_cache_audit.py::test_native_cache_tamper_fails_installed_audit
  • tests/unit/test_codex_native_registrar.py::test_source_identity_refusal_precedes_native_access[same-pin]

Ruff and the complexity ratchet are clean.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- diagnostic wording only.

apm-spec-waiver: diagnostic wording unified across audit owners; no normative behaviour change

apm audit --ci named a changed package copy differently depending on the
owner that found it. The audit materialization check, native Agent Plugin
admission and the Codex native registrar now print one message from
core/cache_drift.py: 'package cache differs from its locked content',
followed by each owner's existing remedy. Tests pin the single message for
every drift case; ledger row and CHANGELOG line.

apm-spec-waiver: diagnostic wording unified across audit owners; no normative behaviour change

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
Copilot AI balanced review requested due to automatic review settings November 20, 2026 19:37

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 canonical drift owner lacks an owner-registry entry and a static delegation guard with a hermetic regression test, leaving producers’ use of the shared vocabulary unenforced.

1 open issue
What changed in this PR

This PR unifies package-cache drift wording across APM’s audit materialization check, native Agent Plugin admission, and Codex native registrar. It preserves existing integrity checks and owner-specific recovery advice.

Changes:

  • Adds a shared diagnostic formatter and routes all three reporting paths through it.
  • Updates lifecycle and registrar assertions to expect the common wording.
  • Records the fix in the lifecycle bug ledger and changelog.
File Description
tests/​unit/​test_codex_native_registrar.py Updates the expected same-pin drift diagnostic.
tests/​integration/​test_native_plugin_cache_audit.py Checks shared wording while retaining remedy assertions.
tests/​integration/​test_codex_native_plugin_lifecycle.py Checks consistent wording across cache mutations and rejects old replay wording.
tests/​fixtures/​lifecycle_bug_ledger.json Links issue #4480 to regression coverage.
src/​apm_cli/​install/​native_plugin_admission.py Uses the shared formatter for native plugin cache drift.
src/​apm_cli/​install/​audit_replay.py Uses the shared formatter for stale user-scope package copies.
src/​apm_cli/​core/​cache_drift.py Defines the common drift phrase and formatter.
src/​apm_cli/​codex_plugins/​registrar.py Uses the shared formatter for Codex source-identity drift.
CHANGELOG.md Documents the unified audit diagnostic.

Review effort: Balanced

Comment on lines +14 to +16
def package_cache_drift(subject: str, remedy: str) -> str:
"""Return the drift message for *subject*, followed by its *remedy*."""
return f"{subject}: {PACKAGE_CACHE_DRIFT}; {remedy}"
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
… across owners

Co-authored-by: Copilot App <[email protected]>

# Conflicts:
#	tests/fixtures/lifecycle_bug_ledger.json
#	tests/integration/test_codex_native_plugin_lifecycle.py
)

The one package cache drift message module needs a canonical owner;
it joins the ci-audit-scratch-materialization decision with audit_replay.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Closing as superseded: this change shipped in v0.37.0 through the release train (#4424). Its core source and test files are byte-identical on main, and the linked issues are closed as completed in 0.37.0. The only remaining differences are in shared files that every train PR touches (CHANGELOG, bug ledger, owner registry). Nothing is left to land. -- regent, 0.37 milestone close-out

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.

Audit names package cache drift with two different messages

2 participants