Repository navigation
fix(approve): refuse a still-denied bundle approve before writing (#4933) - #4934
Merged
Daniel Meppiel (danielmeppiel) merged 4 commits intoNov 23, 2026
Merged
Conversation
) apm approve <bundle key> saved the grant, then exited 1 when an org or other-store deny still blocked the key. Decide that deny against the deny map approve would save, through the trust owner, before any write, so a failed bundle 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 06:34
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
marked this pull request as draft
November 23, 2026 06:36
Daniel Meppiel (danielmeppiel)
marked this pull request as ready for review
November 23, 2026 06:37
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The user approval path can delete approvals.yml and rewrite config.json before policy preflight rejects a bundle, changing durable state despite reporting “Nothing written.”
1 open issue
What changed in this PR
This PR addresses #4933, the local-bundle counterpart to #4923/#4928, by checking remaining trust-layer denies before saving bundle approvals.
Changes:
- Adds a pre-write deny check that refuses the entire bundle selection if any key remains denied.
- Adds state-preservation regression tests, successful-approval controls, and a lifecycle bug-ledger entry.
- Updates approval documentation and the changelog to describe the refusal behavior.
| File | Description |
|---|---|
tests/unit/commands/test_approve_deny.py |
Adds refusal snapshots and successful bundle-approval controls. |
tests/fixtures/lifecycle_bug_ledger/bugs/4933.json |
Records the failed-command state-preservation regression. |
src/apm_cli/commands/approve.py |
Moves remaining-deny checks before bundle approval writes. |
packages/apm-guide/.apm/skills/apm-usage/commands.md |
Documents refusal when another layer denies a bundle. |
docs/src/content/docs/reference/cli/approve.md |
Updates the local-bundle refusal contract. |
changelog.d/4934.fixed.md |
Adds the user-facing fix entry. |
Review effort: Balanced
…approve Matches the #4933 scope record: the refusal keeps the 'still denied by another trust layer' text and adds the layer and how to lift it. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…undle approve approve loads its store without persisting the legacy approvals.yml migration; a successful --user save retires that file. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
deleted the
fix-4933-bundle-approve-deny
branch
November 23, 2026 07:50
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 "<bundle key>"saved the bundle grant toapm.yml(or the--userstore), then exited 1 with<key> is still denied by another trust layerwhen an org deny or a deny in the other store still blocked the key. A failed command changed durable state (I7,transaction.failed_command_preserves_state). This is the bundle-path sibling of #4923 / #4928.Fix at the approve owner (
commands/approve.py::_approve_bundles):_bundles_still_denieddecides the deny BEFORE any write. It readspackage_type_verdicts(the trust owner) over the trust context, with the written store's deny map replaced by the one approve would save (same-store denies on the named keys are lifted). Neither the store load nor the preflight read persists a legacyapprovals.ymlmigration; a successful--usersave retires that file. A still-denied key keeps the[x] <key> is still denied by another trust layertext, now naming the layer and how to lift it (as a named package does), then printsNothing written., exits 1, and leaves every store unchanged. If any named key is still denied, no grant is written for the other keys either. A non-denied bundle approve behaves as before, includingCleared deny for <key>for a same-store deny.Docs: the
reference/cli/approve.md"Local bundles" section and the apm-usage guide list "another layer still denies the key" among the refusals that write nothing.Conflicts with #4928 in
approve.py,test_approve_deny.pyand the two doc files (different hunks). Whichever lands second rebases.Issue and approved scope
Issue: Fixes #4933
Human scope-approval comment: #4933 (comment)
Completes 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-> 70 passed (the refusal cases fail without the fix)APM_BINARY_PATH=$(uv run which apm) APM_E2E_TESTS=1 uv run --extra dev pytest tests/integration/test_install_local_bundle_e2e.py tests/integration/test_local_bundle_hooks_lifecycle.py tests/integration/test_local_bundle_mcp_lifecycle.py tests/integration/test_local_bundle_mcp_retire_lifecycle.py tests/integration/test_bundle_deny_retires_lsp_lifecycle.py tests/integration/test_executables_gate_integration.py tests/integration/test_local_bundle_canvas_gate_lifecycle.py tests/lifecycle/test_local_bundle_lost_lock_mcp.py -n 4-> 166 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-> clean; pylint R0801 -> 10.00python -m tests.quality.taxonomy --changed-> cleanbash tests/spec_conformance/mode_b_detector.sh-> no critical-path diffChangelog
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.