Skip to content

Trust and integrity consistency: install --frozen and audit --ci agree on executable approvals - #4272

Merged
Daniel Meppiel (danielmeppiel) merged 10 commits into
mainfrom
danielmeppiel-s14-frozen-approval-parity
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 10 commits into
mainfrom
danielmeppiel-s14-frozen-approval-parity

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

Trust and integrity consistency: apm install --frozen and apm audit --ci reach the same verdict on hook approval pins, and the lockfile's hook records follow the current approvals. Everything goes through the executables-trust owner.

  • security/trust.py (owner): hook admission compares a package's hook files to their pins. recorded_hook_pin_mismatches lists the lockfile-recorded hook files that their pin no longer admits.
  • install/exec_gate.py: locked_hook_pin_mismatches is the single route from the lockfile to the owner.
  • install --frozen: InstallService.enforce_frozen_hook_pins runs in the integrate phase before anything is deployed. When it refuses, the project and lockfile stay unchanged.
  • audit --ci: the new hook-approval-pins check uses the same route.
  • apm install retires hooks whose pin no longer matches, together with their merged config entries.
  • Closed-world guard install-deployment-hook-pin-frozen-audit-parity: only the frozen and audit paths call the shared route, and only exec_gate calls the owner. A mutation case with the same id covers it.
  • Docs: reference/baseline-checks.md, reference/cli/install.md and reference/cli/approve.md, plus the apm-guide governance.md.

Issue and approved scope

Issue: Fixes #4188

Human scope-approval comment: #4188 (comment)

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)

New tests:

  • tests/integration/test_hook_approval_pin_parity_lifecycle.py::test_frozen_and_audit_refuse_alike_when_a_hook_pin_does_not_match[claude|copilot]: drives the installed CLI with HOME isolated. It runs a paired install --frozen / audit --ci probe on the same state and asserts the snapshot is unchanged when the command refuses.
  • tests/integration/test_hook_approval_pin_parity_lifecycle.py::test_install_retires_a_hook_whose_pin_no_longer_matches[claude|copilot]
  • tests/spec_conformance/test_hook_pin_parity_reqs.py::test_frozen_install_and_audit_agree_on_a_hook_approval_pin (req-sc-011)
  • tests/unit/security/test_trust_admission.py (3 cases)
  • MutationCase install-deployment-hook-pin-frozen-audit-parity 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 src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py passed
uv run --frozen --extra dev ruff format --check (same paths) 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 passed
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.spec_conformance.gen_statement regenerated and committed
APM_BINARY_PATH=.venv/bin/apm uv run --frozen --extra dev pytest -n 2 tests/integration/test_hook_approval_pin_parity_lifecycle.py tests/spec_conformance tests/unit/security tests/unit/policy tests/unit/scripts/test_architecture_runner.py tests/unit/test_audit_policy_command.py tests/unit/install/test_architecture_invariants.py tests/quality/test_lifecycle_bug_ledger.py plus the global audit rule matrix and 30 approval/executables/frozen/native-plugin/trust lifecycle modules under tests/integration/ passed (2907 passed, 59 skipped, 27 xfailed)
Mutation case install-deployment-hook-pin-frozen-audit-parity and architecture runner passed
PR CI on head 3fc616e (CI, Merge Gate, Spec conformance, Lifecycle Smoke shards, GATE Cell Coverage, Architecture Ratchets, Windows Compatibility Gate, CodeQL) passed

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: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended (req-sc-011).
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Installed-CLI lifecycle test: install --frozen and audit --ci reach the
same verdict when a hook approval pin does not match the package content,
and a plain install retires the hook from every config and the lockfile.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The trust owner now answers whether a locked hook file is still admitted by
its pinned approval. apm install --frozen asks it before anything deploys,
and apm audit --ci asks it as the hook-approval-pins check, so both reach
one verdict with one remediation.

A package none of whose hook files matches its pin is no longer
admissible, so apm install retires its hooks from every config and from
the lockfile, as for a revoked approval.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Closed-world architecture rule install-deployment-hook-pin-frozen-audit-parity:
install --frozen and audit --ci verify locked hook approval pins through
install/exec_gate.py and the security/trust.py owner, and no other module
calls that route. One mutation case drops the frozen verification.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
)

Adds the req-sc-011 conformance test, the hook-approval-pins baseline
check reference, the frozen-mode note, the bug-ledger row and the
changelog entry.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
#4188)

audit --ci resolves the executables trust context for the hook-approval-pins
check only when a locked package deploys hook files, so projects without
hooks keep their policy discovery unchanged. Baseline check counts include
the new check.

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

Unresolved trust-check defects allow frozen installs to retire deployed hooks despite changed pins or removed grants, while CI audit can mutate personal approval state and let user grants affect its verdict.

5 open issues
What changed in this PR

This PR addresses #4188 by routing frozen-install and CI-audit hook approval checks through the shared executable-trust owner. It also updates normal install to retire hooks when none of their pinned approvals match.

Changes:

  • Adds shared hook-pin verification for install --frozen and audit --ci.
  • Adds lifecycle, unit, conformance, and architecture-guard coverage.
  • Updates approval documentation, baseline checks, and release notes.
File Description
tests/​unit/​test_audit_policy_command.py Updates the expected baseline-check count.
tests/​unit/​security/​test_trust_admission.py Tests hook admission and recorded-pin mismatches.
tests/​unit/​scripts/​test_architecture_runner.py Registers the new guard in the expected inventory.
tests/​unit/​policy/​test_ci_checks.py Updates the expected CI-check count.
tests/​spec_conformance/​test_hook_pin_parity_reqs.py Adds paired frozen/audit verdict checks.
tests/​integration/​test_hook_approval_pin_parity_lifecycle.py Covers refusal, retirement, and reapproval through the CLI.
tests/​integration/​test_architecture_owner_rule_mutations.py Adds a frozen-check bypass mutation.
tests/​fixtures/​lifecycle_bug_ledger.json Records #4188 and its regression coverage.
src/​apm_cli/​security/​trust.py Adds shared mismatch decisions and content-aware hook admission.
src/​apm_cli/​policy/​ci_checks.py Adds the hook-approval-pins baseline check.
src/​apm_cli/​install/​service.py Adds frozen hook-pin enforcement.
src/​apm_cli/​install/​phases/​integrate.py Invokes enforcement before hook deployment or retirement.
src/​apm_cli/​install/​exec_gate.py Adapts locked dependencies to shared pin verification.
src/​apm_cli/​install/​deployment_plan.py Reports parked hooks when none are admitted.
scripts/​architecture_linter/​checks/​install_portable_trust.py Adds a shared-routing architecture guard.
packages/​apm-guide/​.apm/​skills/​apm-usage/​governance.md Documents the new baseline check.
docs/​src/​content/​docs/​reference/​cli/​install.md Explains frozen hook-pin verification.
docs/​src/​content/​docs/​reference/​cli/​approve.md Documents retirement and frozen/audit refusal.
docs/​src/​content/​docs/​reference/​baseline-checks.md Describes hook-pin failures and remediation.
CONFORMANCE.md Updates the requirement’s test count.
CONFORMANCE.json Registers the new conformance test.
CHANGELOG.md Adds the user-facing fix summary.
.apm/​architecture/​owners/​install-deployment.json Records the shared verification route and guard.

Review effort: Balanced

Comment on lines +1209 to +1225
from ..constants import APM_MODULES_DIR
from ..install.errors import PolicyViolationError
from ..install.exec_gate import locked_hook_pin_mismatches
from ..security.executables import resolve_project_exec_allow_map

modules_root = (
prepared_replay.modules_root
if prepared_replay is not None
else project_root / APM_MODULES_DIR
)

def trust_ctx() -> Any:
# Resolved only when a locked package deploys hook files.
allow = resolve_project_exec_allow_map(
deployment_root, manifest, user_scope=user_scope, no_policy=no_policy
)
return getattr(allow, "trust_context", None)
Comment on lines +833 to +837
recorded_deployed = (
recorded_status in (None, TRUST_DEPLOYED) or EXEC_TYPE_HOOKS in recorded_allowed
)
root = install_path.resolve()
hook_files = HookIntegrator().find_hook_files(root) if recorded_deployed else []
Comment on lines +842 to +843
if ctx is None or not ctx.gate_enabled or not has_item_pins(ctx, package_keys, EXEC_TYPE_HOOKS):
return []
_EXEC_GATE: ("def locked_hook_pin_mismatches(", "recorded_hook_pin_mismatches("),
_SERVICE: ("mismatches = locked_hook_pin_mismatches(lockfile, modules_dir, trust_ctx)",),
"src/apm_cli/install/phases/integrate.py": ("InstallService.enforce_frozen_hook_pins(",),
_CI_CHECKS: ("mismatches = locked_hook_pin_mismatches(", "_check_hook_approval_pins("),
Comment on lines +734 to +738
recorded_hook_pin_mismatches(
_ctx,
tuple(_candidate_keys(pkg_key)),
install_path,
package=_strip_version(pkg_key),
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 6cac590 into main Nov 20, 2026
42 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-s14-frozen-approval-parity branch November 20, 2026 13:07
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…n_retirement

#4272 grew install/service.py, so the frozen presence step moves out of the
owner into install/frozen_retirement.enforce_frozen_presence; the owner
keeps one call. The closed-world guard fragments and mutation cases follow
the move, with a new case for the owner skipping the presence step.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
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.

Trust and integrity consistency: install --frozen and audit --ci agree on executable approvals

2 participants