Skip to content

fix(frozen): frozen and audit fail on a stale exec_status (#4053) - #4065

Merged
Daniel Meppiel (danielmeppiel) merged 505 commits into
mainfrom
danielmeppiel-frozen-stale-exec-status-4053
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 505 commits into
mainfrom
danielmeppiel-frozen-stale-exec-status-4053

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

TL;DR. When apm deny or an org policy tightening changes the executables gate's decision for a locked package after the last plain install, apm install --frozen and apm audit --ci both exited 0 with a stale exec_status. On merged-config targets (Claude settings.json) no recorded file goes missing, so the #4054 presence check cannot see it. Both commands now exit 1, naming the package with its recorded and current status and the repair. Both route through the existing staleness owner in install/exec_gate.py, the one apm update already uses.

Important

Stacked on #4054 (base danielmeppiel-frozen-retired-hook-4043). CI does not run on a non-main base, so the evidence below is the local CI mirror.

Problem.

  • lock_exec_decisions_stale (used by apm update) knew a recorded decision was stale but only returned a bool, and neither frozen nor audit asked it.
  • Frozen post-deploy verification checked claims, presence and hashes, and audit checked presence and drift. On Claude the retired hook leaves settings.json present with no drift, so both passed.

Approach.

Decision Choice
Owner install/exec_gate.py: new stale_exec_decisions() returns (StaleExecDecision[], indeterminate); lock_exec_decisions_stale is now a thin bool over it (first_only=True), so apm update keeps its exact answers
Policy wiring apm update's policy-outcome handling moves into the owner as exec_policy_from_discovery() / discovered_exec_policy(deploy_root). Frozen reuses it; audit wraps its single per-run discovery with it
Frozen InstallService._enforce_frozen_no_rewrite: claims -> missing files (#4043) -> stale exec_status -> hashes
Audit new baseline check exec-status-current (after deployed-files-present), fed the audit run's single policy fetch
Indeterminate a policy resolution failure (POLICY_RESOLUTION_FAILURE_OUTCOMES, e.g. cache_miss_fetch_fail) raises ExecPolicyUnavailable, so the answer is indeterminate and is reported as "not verified" rather than failed. The same applies to an unreadable package. apm update still treats indeterminate as stale
--no-policy audit: exec-status-current is not evaluated (reported "not verified") when --no-policy is given without --policy, because the gate's decision depends on org policy that audit was told not to read. frozen: evaluated with no org policy, matching the gate this same --no-policy install just ran, so it judges what was actually deployed
Message <package>: recorded deployed, now denied plus run 'apm install' without --frozen ... then commit apm.lock.yaml

Deny still wins (retirement proceeds as today) and frozen never writes apm.lock.yaml (req-lk-006).

Implementation

File Change
install/exec_gate.py StaleExecDecision, discovered_exec_policy, stale_exec_decisions; lock_exec_decisions_stale delegates
commands/update.py uses discovered_exec_policy (logic unchanged)
install/service.py _frozen_stale_exec_decisions(); shared _FROZEN_LOCK_REPAIR_TIP
policy/ci_checks.py, commands/audit.py _check_exec_status_current; run_baseline_checks(policy_provider=...)
scripts/architecture_linter/checks/install_frozen_and_audit.py the frozen guard requires frozen and audit to call stale_exec_decisions and audit's provider to use exec_policy_from_discovery, and rejects recorded_exec_status_is_stale( / current_exec_decision( / exec_trust_context_for_project( in either
scripts/architecture_linter/checks/install_lsp_plugin.py registered trust-owner caller renamed to stale_exec_decisions
tests new test_frozen_stale_exec_status_lifecycle.py (incl. --no-policy and no-cache-unreachable cases); req-lk-006 conformance case; 4 mutation cases; baseline check counts 9->10 / 10->11
docs (last commit) install reference (frozen mode), baseline-checks reference (exec-status-current), deny retirement note

Trade-offs

  • One more baseline check. apm audit --ci reports 11 checks instead of 10; three tests that pinned the count were updated.
  • Review fold (b270da7c, MEDIUM). Audit used to take replay_policy, which returns None both under --no-policy and when discovery fails without a cache. That decided as if no org policy existed, so after an org deny_all audit failed with a repair that never converges, and a tightened but unreachable policy passed silently. Audit now skips the check under --no-policy and reports a resolution failure as indeterminate. I chose skip over a partial local-only judgment because org policy is not tighten-only (recommend is default-allow), so a local-only decision can be wrong in either direction.
  • Indeterminate is not a failure for frozen/audit, so an unreachable org policy cannot turn a green CI red through this check. A stale decision under an unknown policy is still caught by apm update and the next plain install.
  • Out of scope per the record: personal apm deny --user layers in audit, apm update reconciliation, exec_status vocabulary, spec amendments.

Benefits

  1. install --frozen, audit --ci and apm update share one staleness test (stale_exec_decisions).
  2. A Claude hook gated after the last install no longer leaves a lock that frozen and audit accept.
  3. Bypassing or re-deriving the decision, or dropping the policy-unavailable path, fails the architecture linter (4 mutation cases).

Validation

New lifecycle test on main 67936cd (CLI version line 0.36.1 (67936cd7d)): both revocations fail at the frozen step, and the controls pass:

E       AssertionError: ('install', '--frozen')     # deny: exit 0
E       AssertionError: ('install', '--frozen')     # org-tightening: exit 0
2 failed, 2 passed

The two review cases (--no-policy; discovery failing with no cache) fail on 0e9f6c43d with exec-status-current ... recorded denied, now deployed, and pass here.

On this branch (head 2514e1d89):

Command Result
APM_BINARY_PATH=.venv/bin/apm pytest tests/integration/test_frozen_stale_exec_status_lifecycle.py tests/integration/test_executables_deny_retires_hooks_lifecycle.py 21 passed (incl. the #4043 missing-file control and both review cases)
targeted set (above + native-plugin audit, undeclared retention, deployed hash, package MCP gate, tests/unit/policy, tests/unit/commands, test_frozen.py, test_replay_exec_allow_map.py, test_audit_policy_command.py, test_lockfile_reqs.py) 3013 passed, 1 skipped, 1 xfailed
pytest tests/integration/test_architecture_owner_rule_mutations.py -k frozen_and_audit_share 8 passed
broad pytest tests/unit tests/spec_conformance tests/integration -k "frozen or audit or deny or executables or gate or update or approve or policy or exec" 7048 passed. Remaining failures also fail on the #4054 base or come from this host (git commit signing, root user); two test_executables.py cases are order-flaky and pass in isolation
ruff check + format, pylint R0801, lint-auth-signals.sh, lint-architecture-boundaries.sh clean
orphan_check, gen_statement (committed), Mode B vs main and vs stack base OK
Scenario evidence
Scenario Test Principle
Claude, command-only hook, apm deny / org deny_all: frozen exits 1 naming the package, recorded and current status and the repair; hook gone from settings.json; lock bytes unchanged; audit exits 1 test_stale_exec_status_fails_frozen_and_audit_until_install[deny|org-tightening] fail closed; one answer
Plain install then records denied; frozen and audit both exit 0 same test lock matches deployment
Unchanged decision keeps frozen and audit at 0 (claude, copilot) test_unchanged_exec_decision_keeps_frozen_and_audit_green no false positives
Org deny_all recorded, then audit --ci --no-policy --no-drift: not evaluated, exit 0 test_no_policy_audit_does_not_judge_org_derived_decisions no false repair loop
Org deny_all recorded, cache removed, policy source unreachable: not stale test_unreachable_policy_without_cache_is_not_a_stale_decision indeterminate, not decided as "no policy"
#4043 missing-file case reports as before test_frozen_fails_when_a_gated_hook_retires_but_the_lock_still_claims_it ordering preserved
Frozen never rewrites the lock to hide a stale decision test_frozen_fails_rather_than_keep_a_stale_executables_decision (req-lk-006) never write lock

How to test

  • APM_BINARY_PATH=$PWD/.venv/bin/apm uv run --extra dev pytest tests/integration/test_frozen_stale_exec_status_lifecycle.py
  • In install/service.py replace stale_exec_decisions( with any local helper; bash scripts/lint-architecture-boundaries.sh fails.

Pre-merge

Issue and approved scope

Issue: Fixes #4053

Human scope-approval comment: #4053 (comment)

Does this PR complete the issue, or what remains? Completes it.

Type of change

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

Testing

  • Tested locally
  • All existing tests pass (host-environment and pre-existing failures noted above)
  • Added tests for new functionality (if applicable)

Changelog

  • One line under ## [Unreleased] -> ### Fixed.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit: @pytest.mark.req("req-lk-006") test added under tests/spec_conformance/.
  • CONFORMANCE.{md,json} regenerated and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Co-authored-by: Copilot [email protected]

@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the danielmeppiel-frozen-stale-exec-status-4053 branch 3 times, most recently from 0e9f6c4 to 2514e1d Compare November 20, 2026 04:23
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
@danielmeppiel Daniel Meppiel (danielmeppiel) changed the title [0.38] fix(frozen): frozen and audit fail on a stale exec_status (#4053) fix(frozen): frozen and audit fail on a stale exec_status (#4053) Nov 20, 2026
@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the danielmeppiel-frozen-retired-hook-4043 branch from e96841b to d6f545f Compare November 20, 2026 08:03
@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the danielmeppiel-frozen-stale-exec-status-4053 branch from 2514e1d to 2c8bae2 Compare November 20, 2026 08:04
@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the danielmeppiel-frozen-retired-hook-4043 branch from d6f545f to 51e6e34 Compare November 20, 2026 08:15
@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the danielmeppiel-frozen-stale-exec-status-4053 branch from 2c8bae2 to dc561d1 Compare November 20, 2026 08:15
@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the danielmeppiel-frozen-retired-hook-4043 branch from 51e6e34 to fa87f1b Compare November 20, 2026 08:24
@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the danielmeppiel-frozen-stale-exec-status-4053 branch from dc561d1 to 264e7a6 Compare November 20, 2026 08:25
@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the danielmeppiel-frozen-retired-hook-4043 branch 3 times, most recently from a9679af to 4c0cf56 Compare November 20, 2026 11:01
@danielmeppiel
Daniel Meppiel (danielmeppiel) marked this pull request as ready for review November 20, 2026 11:46
# Conflicts:
#	.apm/architecture/owners/transport-auth-platform.json
#	docs/src/content/docs/enterprise/registry-proxy.md
#	docs/src/content/docs/reference/environment-variables.md
#	tests/unit/test_artifactory_support.py
Package validation now counts dependencies.lsp like apm and mcp when it
accepts an apm.yml without .apm/ as a dependency-only package. Uninstalling
another package no longer fails its survivor preflight on an LSP-only
package (gated and approved, ungated, or denied), and an LSP-only package
installs from git as it does from a local path.

Fixes #4161
Fixes #4214
Fixes #4215
Fixes #4257

Co-authored-by: Copilot App <[email protected]>
Main replaced security.executables.project_manifest_path with the scope
owner's scope_manifest_path (1cfd9ac).

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

H2 moved code the generator rules cite, so their line citations follow it.
A reinstall adopts rendered commands, so the J01/J02/J03 transcripts say
adopted and no longer repeat the dropped-key warnings; the strict cells H2
fixes go (#4182 frozen step, #4197), and the step-2 unpinned notice is
tracked under #4183.

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

# Conflicts:
#	tests/lifecycle/generator/rules.py
#	tests/quality/lifecycle_obligations.json
The frozen replay now asserts the printed recovery for kept files: move
them aside, then 'apm install' (or --force). Steward audit.

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

# Conflicts:
#	tests/fixtures/lifecycle_bug_ledger.json
#	tests/lifecycle/generator/rules.py
#	tests/quality/lifecycle_obligations.json
Co-authored-by: Copilot App <[email protected]>

# Conflicts:
#	tests/fixtures/lifecycle_bug_ledger.json
#	tests/lifecycle/generator/rules.py
#	tests/quality/lifecycle_obligations.json
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…loyment evidence (#4360)

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

# Conflicts:
#	tests/quality/lifecycle_obligations.json
…plugin files before writing

Co-authored-by: Copilot App <[email protected]>
…kup line and frozen trust notice print once (#4242, #4244, #4256)

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

# Conflicts:
#	tests/conftest.py
#	tests/fixtures/lifecycle_bug_ledger.json
#	tests/utils/lifecycle_evidence.py
…er match without a local receipt; cleanup retains files the install kept

Co-authored-by: Copilot App <[email protected]>
…ns; name every credential tried

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

# Conflicts:
#	tests/lifecycle/generator/rules.py
#	tests/quality/lifecycle_obligations.json
…cripts notice once per command

Co-authored-by: Copilot App <[email protected]>
#4258 makes kept a required keyword (explicit kept=() at non-install callers); #4394's frozen_withdrawal caller predates that and relied on the old default.

Co-authored-by: Copilot App <[email protected]>
python -m tests.lifecycle.witnesses --write (collection only): 8 journey cells move from known-failing to required now that their fixes are in.

Co-authored-by: Copilot App <[email protected]>
python -m tests.lifecycle.witnesses --write (collection only): journey cells whose fixes are in move from known-failing to required.

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

# Conflicts:
#	tests/quality/generated_obligations.json
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
At user scope the install gate discovers org policy from APM_HOME, never
from the HOME repository's remote (#4087). The frozen stale-decision check
and the retired-hook naming discovered from the deploy root (HOME), so a
HOME remote's org-deny made --frozen refuse a hook the gate still deployed
(GATE user spine). Both now discover from manifest_root, as the gate does.
E01 step 4's check count follows exec-status-current.

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

#4065 pinned the exact ordered baseline; #4493 adds native-mcp-ownership after config-consistency. Interaction fix, no check dropped.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 9574d3e into main Nov 21, 2026
3 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-frozen-stale-exec-status-4053 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.

Claude target: exec_status in the lockfile is not updated after a deny

2 participants