Repository navigation
fix(approve): refuse an org-denied approve before writing apm.yml (#4923) - #4928
Merged
Daniel Meppiel (danielmeppiel) merged 5 commits intoNov 23, 2026
Merged
Conversation
) apm approve recorded the grant (and cleared a same-store deny), saved the store, and only then exited 1 when an org or other-store deny still blocked the package. Decide that deny before any write, against the store as approve would save it, so a failed approve leaves apm.yml and the user store unchanged (I7). Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 23, 2026 05:38
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical refusal paths can migrate personal consent stores or persist bundle grants before rejecting an org-denied package, changing stored data despite reporting “Nothing written.”
2 open issues
What changed in this PR
This PR addresses #4923 by moving named-package deny checks before approval writes, aiming to preserve durable state when apm approve fails because another trust layer denies the package.
Changes:
- Adds a preflight check using the existing trust evaluation, accounting for same-store denies that approval would clear.
- Adds regression coverage for denied approvals and unchanged store bytes.
- Updates command documentation and records the fix in the changelog and lifecycle bug ledger.
| File | Description |
|---|---|
tests/unit/commands/test_approve_deny.py |
Adds refusal, mixed-package, and successful-approval cases. |
tests/integration/test_deny_remediation_lifecycle.py |
Checks store bytes remain unchanged after refusal. |
tests/fixtures/lifecycle_bug_ledger/bugs/4923.json |
Links the failed-command invariant to regression tests. |
src/apm_cli/commands/approve.py |
Moves named-package deny evaluation before recording and saving. |
packages/apm-guide/.apm/skills/apm-usage/commands.md |
Documents that still-denied approvals write nothing. |
docs/src/content/docs/reference/cli/approve.md |
Clarifies the no-write refusal behavior. |
changelog.d/4928.fixed.md |
Adds the user-facing fix entry. |
Review effort: Balanced
…ration Select named packages and refuse a still-denied one before the local-bundle approval path saves, so a mixed bundle-key/package approve writes nothing. Trust reads that run before the write no longer persist the legacy approvals.yml migration; a successful --user save retires that file. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
This was referenced Nov 23, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-jubilant-potato
branch
November 23, 2026 13:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
apm approve <pkg>under an orgexecutables.denyrecorded the grant inapm.yml(and cleared any same-store deny), saved the store, and only then reportedis still denied (org-deny)and exited 1. A failed command changed durable state (I7,transaction.failed_command_preserves_state).Fix at the approve owner (
commands/approve.py::_record_and_save): for named packages,_refuse_still_denieddecides the other-layer deny BEFORE any record or save. It reads the trust ladder through the existing_still_denied/package_type_verdictspath, with the written store's deny map replaced by the map approve would save (same-store denies it lifts removed), so the decision is not duplicated. A still-denied package prints the same error naming the layer and how to lift it, plusNothing written., and exits 1 with every store unchanged. If any named package is still denied, nothing is written for the others either. The preflight runs inapprove_cmdbefore the local-bundle approval path saves, so a mixed bundle-key/package approve also writes nothing. Trust reads before the write no longer persist the legacyapprovals.ymlmigration; a successful--usersave retires that file. The old post-save check is removed. Bulk--all/--recommendedare unchanged (they already skip denied packages before writing). A non-denied approve behaves as before.Docs:
reference/cli/approve.mdand the apm-usage guide now say a still-denied approve writes nothing.Lands after #4924 (strict Known cell
gate-cell-approve-org-deny). After #4924 merges, this branch is rebased, the Known marker is removed so the cell is required, and the snapshots are regenerated.Issue and approved scope
Issue: Fixes #4923
Human scope-approval comment: #4923 carries
status/accepted(milestone 0.38.0); assigned through the P2 Install & Harness lead.Completes the issue: the refusal now happens before any write (option 1 in the issue).
Type of change
Testing
Run locally (CI runs the full suite):
uv run --extra dev pytest tests/unit/commands/test_approve_deny.py -q-> 71 passed (new refusal cases, including mixed bundle+package and legacy approvals.yml, fail without the fix)APM_BINARY_PATH=$(uv run which apm) uv run --extra dev pytest tests/integration/test_deny_remediation_lifecycle.py -n 0 -q-> 3 passed (extended case fails without the fix)test_pinned_hook_policy_deny_lifecycle,test_user_scope_exec_trust_lifecycle,test_executables_gate_integration,test_approval_identity_lifecycle,test_lsp_denied_package_wording_lifecycle,test_frozen_deny_preflight_lifecycle,tests/lifecycle/machines/test_m_gate.py,test_remediation_gate9_call_sites-> 140 passed; after the review fold, the deny/user-scope/identity/local-bundle/gate neighbours -> 158 passeduv run --extra dev pytest tests/quality/test_lifecycle_bug_ledger.py -q-> 2 passedruff 0.15.12 check+format --checkon changed Python files -> cleanpython scripts/check_test_assertions.py-> ratchet cleanpython scripts/lint_architecture_boundaries.py --root .-> exit 0python -m tests.lifecycle.generator --check-> up to datepython scripts/check_complexity_ratchet.py --base-ref origin/main-> cleanpython -m tests.quality.taxonomy --changed-> cleanbash tests/spec_conformance/mode_b_detector.sh-> no critical-path diffInherited reds on main (not from this PR): Lint
deployment_ledger.pyline count (2101 > 2100); Windows #4876 failure.Changelog
changelog.d/<pr>.<section>.md, holdingone line: user-visible effect first, 25 words or fewer, ending with
(#PR); breaking changes only under upgrade notes; no Highlights; nonew lines under
## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.