Skip to content

fix(install): frozen judges lock sync only from copies that match the lock - #4401

Merged
Daniel Meppiel (danielmeppiel) merged 22 commits into
mainfrom
danielmeppiel-frozen-verified-copy-4389
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 22 commits into
mainfrom
danielmeppiel-frozen-verified-copy-4389

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

Trust and integrity consistency: apm install --frozen checks lock sync against package copies that match the lock. On an edited apm_modules copy whose locked source is intact, it therefore reaches the same verdict as apm audit --ci.

Builds on #4385, whose commits this branch includes until #4385 lands.

  • integration/mcp_config_view.py: in the frozen preflight (allow_pending), a remote package copy that differs from its locked content_hash is deferred like a missing copy. The verdict comes from the shared source_helpers.locked_content_mismatch owner, through _copy_contradicts_lock. The strict post-restoration check (enforce_hydrated_mcp) then judges that package's declarations from the verified copy frozen restores.
  • Guards:
    • install-deployment-locked-source-cache now requires the view to route through that verdict.
    • install-deployment-locked-content-verdict admits the view as a verdict caller.
  • tests/integration/test_mcp_omission_lifecycle.py::test_skills_only_preserves_admitted_baseline_and_real_drift[False] is no longer a strict known cell. The [False] branch now runs a paired audit --ci / install --only apm --frozen probe on each edited-copy state (changed or removed MCP declaration, deleted synthesized manifest). It asserts:
    • both commands exit 0;
    • both print the shared entry/expected/observed line for an edited declaration;
    • the lockfile, .mcp.json and deployed files are byte-identical;
    • frozen restores the locked copy.
      The [True] root-declared branch still asserts reported drift.

Issue and approved scope

Issue: Fixes #4389

Human scope-approval comment: tracked by the 0.37 security stream lead (follow-up to #4356 on the steward-approved I3 re-anchor from #4271).

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

Type of change

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)
Command Result
uv run --frozen --extra dev ruff check / ruff format --check (CI paths) passed
uv run --frozen --extra dev python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 ... passed (10.00/10)
bash scripts/lint-auth-signals.sh; bash scripts/lint-architecture-boundaries.sh passed
uv run --frozen --extra dev python scripts/check_complexity_ratchet.py --base-ref origin/main passed
APM_BINARY_PATH=.venv/bin/apm uv run --frozen --extra dev pytest tests/integration/test_mcp_omission_lifecycle.py 6 passed

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 -- this PR does not change OpenAPM-observable behaviour.

apm-spec-waiver: frozen lock sync now reads only package copies that match the lock; req-lk-015 and req-lk-006 behavior is 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]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
… lock

The frozen preflight defers an apm_modules copy that differs from its
locked content_hash to the strict post-restoration check, so install
--frozen and audit --ci reach one verdict on an edited copy whose locked
source is intact. The MCP-omission lifecycle test now pairs audit --ci and
install --frozen on that state.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
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]>
…ozen-verified-copy-4389

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) changed the base branch from danielmeppiel-cache-integrity-parity-4356 to main November 20, 2026 16:56
@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 17:02

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 locked-source-cache mutation test uses an outdated fragment missing read_only=True, so its verbatim-match assertion fails before the guard can test the boundary.

1 open issue
What changed in this PR

This follow-up to #4385 addresses #4389 by making frozen installs judge lock sync from verified package copies, aligning their verdict with apm audit --ci when local copies have been edited.

Changes:

  • Defers frozen MCP preflight checks for mismatched copies until verified restoration.
  • Builds on shared Git-cache access and transactional preservation of copies during re-fetches.
  • Expands parity and rollback regression coverage, architecture guards, and issue tracking.
File Description
tests/​unit/​scripts/​test_architecture_runner.py Adds the shared-cache guard to the expected inventory.
tests/​unit/​install/​test_resolution_staging_relocate.py Covers nested staging and rollback in either order.
tests/​unit/​install/​test_integrate_orchestration.py Verifies rollback restores a mismatched package copy.
tests/​quality/​generated_obligations.json Refreshes lifecycle coverage and known-issue mappings.
tests/​lifecycle/​security/​test_integrity.py Makes resolved integrity scenarios required checks.
tests/​integration/​test_mcp_omission_lifecycle.py Checks audit/frozen parity, restoration, and unchanged deployed bytes.
tests/​integration/​test_locked_source_cache_parity_lifecycle.py Adds shared-cache refusal and state-preservation scenarios.
tests/​integration/​test_architecture_owner_rule_mutations.py Adds a shared-cache boundary mutation case.
tests/​fixtures/​lifecycle_bug_ledger.json Records fixes and their regression tests.
src/​apm_cli/​integration/​mcp_config_view.py Defers declarations from copies that contradict the lock.
src/​apm_cli/​install/​transaction.py Adds transactional preservation of existing copies.
src/​apm_cli/​install/​sources.py Stages existing copies before sequential re-fetches.
src/​apm_cli/​install/​resolution_staging.py Uses isolated backup slots for nested packages.
src/​apm_cli/​install/​phases/​resolve.py Uses the shared cache-attachment helper.
src/​apm_cli/​install/​phases/​integrate.py Stages mismatched copies instead of deleting them.
src/​apm_cli/​install/​phases/​download.py Stages copies before parallel re-fetches.
src/​apm_cli/​install/​drift.py Uses read-only shared-cache access during 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/​paths.py Allows cache-root lookup without directory creation.
src/​apm_cli/​cache/​git_cache.py Adds read-only lookups and centralized cache attachment.
scripts/​architecture_linter/​checks/​install_locked_source_cache.py Guards shared-cache, staging, and frozen-verdict routing.
scripts/​architecture_linter/​checks/​install_locked_content_verdict.py Permits the MCP view to call the shared verdict owner.
scripts/​architecture_linter/​checks/​install_deployment_analyzers.py Registers the shared-cache architecture guard.
CHANGELOG.md Documents frozen parity and stacked integrity fixes.
.apm/​architecture/​owners/​install-deployment.json Records cache and staging ownership and the new guard.

Review effort: Balanced

apm-spec-waiver: frozen lock sync now reads only package copies that match the lock; req-lk-015 and req-lk-006 behavior is unchanged

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…rity-4356' into danielmeppiel-frozen-verified-copy-4389
… 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]>
…rity-4356' into danielmeppiel-frozen-verified-copy-4389
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…pies that match the lock

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

# Conflicts:
#	tests/fixtures/lifecycle_bug_ledger.json
#	tests/quality/generated_obligations.json
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…pies that match the lock

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]>
…rity-4356' into danielmeppiel-frozen-verified-copy-4389
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 982f497 into main Nov 21, 2026
44 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-frozen-verified-copy-4389 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

Development

Successfully merging this pull request may close these issues.

install --frozen judges lock sync from an unverified cached copy

2 participants