Skip to content

fix(install): one locked-source verdict for audit --ci, install, --frozen and update - #4385

Merged
Daniel Meppiel (danielmeppiel) merged 13 commits into
mainfrom
danielmeppiel-cache-integrity-parity-4356
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 13 commits into
mainfrom
danielmeppiel-cache-integrity-parity-4356

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Trust and integrity consistency: apm audit --ci, apm install (including --frozen) and apm update read locked git sources through one cache, so they recompute content_hash over the same bytes and reach one verdict. A refused install leaves apm_modules byte for byte as it was, and a refused apm update reports the mismatch with an [x] line.

  • cache/git_cache.py attach_persistent_git_cache is the one place a downloader gets the persistent git cache. Install's resolve phase, apm outdated and the apm audit --ci replay (install/drift.py run_replay) all use it. When a package copy and its cached checkout both differ from the lock, audit now refuses with the shared entry/expected/observed line, as install --frozen does. With a clean cache, both pass.
  • install/transaction.py stage_existing_copy hands an existing apm_modules/<pkg> copy to the install transaction before a re-fetch replaces it (parallel pre-download, the sequential download and the integrate re-download). On refusal the transaction restores it, including .apm-pin. On success the transaction discards the saved copy. Only lock rows that record a content_hash are staged, since only those can be refused on a content-hash mismatch. Audit reads the shared cache read-only: it never creates, evicts or records cache entries.
  • commands/update.py routes DirectDependencyError and RequiredIntegrationError through InstallLogger.error, so the refusal carries [x]. Exit code and wording are unchanged.
  • Closed-world guard install-deployment-locked-source-cache, owned by package-content-hash:
    • each locked-source reader calls attach_persistent_git_cache;
    • each re-fetch site calls stage_existing_copy;
    • only the owner may set persistent_git_cache.
      A MutationCase with the same id removes the replay's cache wiring.
  • Lifecycle security table: removes the strict known cells for apm install leaves fetched bytes in apm_modules when it fails closed on a content hash mismatch #4353, audit --ci passes an edited cached package copy that install --frozen refuses #4356 and update exits 1 on a content hash mismatch without an error marker #4363, including those added by test(lifecycle): interim strict cells for integrity rows red on main (#4353, #4356, #4363) #4367, which this branch merges.
    • I|approval-pins|audit-ci|disk-or-cache now expects the shared content-hash line, the same line install --frozen expects for that cell.
    • The two uninstall-prune|disk-or-cache cells stay strict under a neutral pending marker. They cover uninstall retaining an edited target file, not a content-hash refusal.

Issue and approved scope

Issue: Fixes #4356
Issue: Fixes #4353
Issue: Fixes #4363

Human scope-approval comment: #4356 (comment), #4353 (comment), #4363 (comment)

Does this PR complete the issue, or what remains? It completes all three issues.

Type of change

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

Testing

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

New tests:

  • tests/integration/test_locked_source_cache_parity_lifecycle.py::test_audit_ci_and_frozen_refuse_alike_when_every_copy_differs: drives the installed CLI with HOME isolated. It runs a paired audit --ci / install --frozen probe plus plain install on one state, and checks the project, lockfile and apm_modules are byte-identical after each refusal.
  • tests/integration/test_locked_source_cache_parity_lifecycle.py::test_update_refusal_names_the_mismatch_as_an_error
  • tests/lifecycle/security/test_integrity.py::test_integrity_row: the git-content_hash and approval-pins cells for these issues now run as required cells.
  • tests/integration/test_trust_integrity_consistency_lifecycle.py::test_frozen_and_audit_refuse_alike_a_git_row_without_content_hash_under_require_hashes: drives the installed CLI. With security.integrity.require_hashes: true, a git row with no content_hash makes install --frozen and audit --ci both exit 1 and name the row; the project, lockfile and apm_modules are unchanged. The dependency-content-hashes audit check now names the rows in its message.
  • tests/integration/test_trust_integrity_consistency_lifecycle.py::test_frozen_and_audit_agree_on_a_git_row_without_content_hash_by_default: under the documented default, both readers accept such a row alike.
  • MutationCase install-deployment-locked-source-cache in tests/integration/test_architecture_owner_rule_mutations.py

Validation evidence (local, on the merge with current main):

Command Result
uv run --frozen --extra dev ruff check / ruff format --check on src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py passed
uv run --frozen --extra dev python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py passed (10.00/10)
bash scripts/lint-auth-signals.sh; bash scripts/lint-architecture-boundaries.sh passed
YAML I/O, file-length and relative_to guards from ci.yml passed
uv run --frozen --extra dev python scripts/check_complexity_ratchet.py --base-ref origin/main passed
uv run --frozen --extra dev python -m tests.lifecycle.witnesses up to date
TESTS_ROW

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md:
    user-visible effect first, 25 words or fewer, ending with (#PR);
    breaking changes only under upgrade notes; no Highlights; see
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour. The req-lk-015 refusal and diagnostic are unchanged; this aligns which local copy audit and install read.

apm-spec-waiver: aligns which local package copy install, --frozen, update and audit --ci read; req-lk-015 refusal and diagnostic unchanged

…' into danielmeppiel-cache-integrity-parity-4356
…pdate

The audit --ci replay reads locked git sources through the same persistent
cache as install, --frozen and update (attach_persistent_git_cache), so both
commands recompute content_hash over the same bytes and reach one verdict.
A re-fetch of an existing apm_modules copy is staged with the install
transaction, so a refused install leaves apm_modules as it was. update
reports a refusal through the [x] error line.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
… probes and ledger

Adds the install-deployment-locked-source-cache closed-world guard and its
mutation case, installed-CLI paired audit --ci / install --frozen probes and
an update refusal probe, ledger rows and a CHANGELOG line.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 20, 2026 15:43
Co-authored-by: copilot-swe-agent[bot] <[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

A critical staging-path collision causes installs with nested transitive dependencies to fail before the parent package downloads, requiring isolated backups and coverage for both staging orders and rollback.

1 open issue
What changed in this PR

This PR aligns locked-source integrity checks across audit, install, frozen install, and update, addressing #4356, #4353, and #4363.

Changes:

  • Centralizes persistent Git cache attachment for consistent source verification.
  • Stages existing package copies for rollback and adds an error marker to update refusals.
  • Adds lifecycle regressions and architecture guards, and promotes repaired integrity cases to required checks.
File Description
tests/​unit/​scripts/​test_architecture_runner.py Registers the new guard in the expected inventory.
tests/​quality/​generated_obligations.json Updates required integrity witnesses and known failures.
tests/​lifecycle/​security/​test_integrity.py Requires repaired integrity cases; retains uninstall exclusions.
tests/​integration/​test_locked_source_cache_parity_lifecycle.py Tests verdict parity, refusal preservation, and update diagnostics.
tests/​integration/​test_architecture_owner_rule_mutations.py Tests detection of missing replay cache wiring.
tests/​fixtures/​lifecycle_bug_ledger.json Records the three fixes and regression coverage.
src/​apm_cli/​install/​transaction.py Adds the existing-copy staging helper.
src/​apm_cli/​install/​sources.py Stages copies before sequential re-fetches.
src/​apm_cli/​install/​phases/​resolve.py Uses shared cache attachment.
src/​apm_cli/​install/​phases/​integrate.py Stages mismatching copies instead of deleting them.
src/​apm_cli/​install/​phases/​download.py Stages copies before parallel re-fetches.
src/​apm_cli/​install/​drift.py Attaches the shared cache to audit replay.
src/​apm_cli/​commands/​update.py Routes dependency and integration failures through error logging.
src/​apm_cli/​commands/​outdated.py Reuses shared cache attachment.
src/​apm_cli/​cache/​git_cache.py Defines the canonical cache-attachment helper.
scripts/​architecture_linter/​checks/​install_locked_source_cache.py Guards cache attachment and re-fetch staging routes.
scripts/​architecture_linter/​checks/​install_deployment_analyzers.py Registers the new architecture check.
CHANGELOG.md Documents verification parity and refusal preservation.
.apm/​architecture/​owners/​install-deployment.json Records shared cache and staging ownership.

Review effort: Balanced

Comment thread src/apm_cli/install/transaction.py Resolved
The audit --ci replay attaches the persistent git cache read-only: it
serves an existing checkout for the locked commit and never creates,
evicts or records cache entries; any miss falls back to a fresh clone.
Updates the integrate re-download unit test for the staged copy.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
A nested copy staged before its parent no longer occupies the parent's
backup path; both staging orders roll back byte for byte.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…--ci, install, --frozen and update

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

# Conflicts:
#	tests/fixtures/lifecycle_bug_ledger.json
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
… re-fetch

A content hash refusal can only reject a row that records content_hash, so
only those copies are staged with the install transaction; rows without one
re-fetch in place as before.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…--ci, install, --frozen and update

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…--ci, install, --frozen and update

Co-authored-by: Copilot App <[email protected]>
…names unhashed rows

Under require_hashes both readers refuse and name the row; by default both
accept it alike. The dependency-content-hashes audit check names the rows.

apm-spec-waiver: aligns which local package copy install, --frozen, update and audit --ci read; req-lk-015 refusal and diagnostic unchanged

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit c25b79d into main Nov 21, 2026
45 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-cache-integrity-parity-4356 branch November 21, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants