Skip to content

fix(install): report a cache content-hash mismatch once per package - #4357

Merged
Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
danielmeppiel-t1-hash-notice-once
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
danielmeppiel-t1-hash-notice-once

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Fixes #4351

What

When a cached package's bytes contradict the locked content_hash, both the download phase (install/phases/download.py, _report_cache_mismatch) and the integrate phase (install/phases/integrate.py) printed Content hash mismatch for <pkg>: expected ..., got .... Re-downloading from the locked source.

The download phase is now the single owner. It records the package in InstallContext.cache_mismatch_reported, and integrate prints the notice only for packages download did not report. Integrate still removes the tampered copy and re-downloads as before; only the duplicate notice is gone.

Validation

  • pytest tests/integration/test_virtual_skill_audit_e2e.py (targeted e2e; result below).
  • ruff check and format: clean.

…4351)

The download phase reports the mismatch and records the package; the integrate
phase now reports it only for packages the download phase did not, so
'Content hash mismatch ... Re-downloading from the locked source.' prints once.

Fixes #4351

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

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

Download marks a mismatch as reported without a logger or diagnostic collector, causing integration to suppress its fallback and lose the diagnostic entirely.

1 open issue
What changed in this PR

Addresses #4351 by tracking cache content-hash mismatch notices across install phases to avoid duplicate reporting while preserving cache removal and re-download behavior.

Changes:

  • Add per-install tracking of packages whose mismatch was reported.
  • Record notices during download and suppress matching notices during integration.
File Description
src/​apm_cli/​install/​phases/​integrate.py Suppress notices already reported during download.
src/​apm_cli/​install/​phases/​download.py Record packages when reporting cache mismatches.
src/​apm_cli/​install/​context.py Add shared mismatch-reporting state.

Review effort: Balanced

Comment thread src/apm_cli/install/phases/download.py Resolved
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 46f89c1 into main Nov 20, 2026
31 of 35 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-t1-hash-notice-once branch November 20, 2026 15:20
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Validation update: pytest tests/integration/test_virtual_skill_audit_e2e.py (APM_E2E_TESTS=1, installed CLI from this branch) -> 11 passed, including test_tampered_cache_with_unreachable_source_fails_frozen_and_audit_alike.

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.

apm install prints the 'Content hash mismatch ... Re-downloading' notice twice for one package

2 participants