Skip to content

test(lifecycle): M-GATE approve under an org deny exits 1 naming the org layer; strict Known #4923 - #4924

Merged
Daniel Meppiel (danielmeppiel) merged 11 commits into
mainfrom
ql/w2b-4919-gate-approve-org-deny
Nov 23, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 11 commits into
mainfrom
ql/w2b-4919-gate-approve-org-deny

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

The nightly GATE state machine (#4919, run 45113537038 at main b8a12c2) falsified set_policy(org-deny) -> declare(hook) -> update -> decide(hook, approve): approve exited 1 where the model expected 0.

Classification:

  • Stale model (exit code). Deny wins. reference/cli/approve.md, "Approving a denied package": when a named package is still blocked by a deny in another layer, approve exits 1 and names that layer and how to lift it. The CLI does exactly that ("... is still denied (org-deny); ... the org policy denies it; ask its owner to change apm-policy.yml"). GateMachine.decide now expects exit 1 and the named org layer for an installed package an org deny still blocks. The org deny is never weakened, and the regression test checks that the hook stays undeployed.
  • Product bug (I7), filed as [BUG] apm approve writes the grant to apm.yml and then exits 1 when an org deny still blocks the package #4923. The same refused approve records the grant in apm.yml before exiting 1, so a failed command changes durable state. It is a strict known cell in KNOWN_CELLS (gate-cell-approve-org-deny, law I7, applying only to a new grant). The mandatory spine now revokes and re-approves the hook under the org deny, so the cell fails every run until [BUG] apm approve writes the grant to apm.yml and then exits 1 when an org deny still blocks the package #4923 is fixed.

Regression test: test_m_gate.py::test_approve_under_an_org_deny_refuses_and_names_the_org_layer replays the falsifier.

Issue and approved scope

Issue: Refs #4919, Refs #4923

Human scope-approval comment: QL owns the lifecycle machines (#4919 lane, assigned by the Quality & Lifecycle VP).

Does not close #4919 (the next green scheduled GATE run closes it) or #4923 (needs the product fix).

Type of change

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Scratch dispatch of the GATE nightly on this head (binary driver, 25 fresh examples per scope; sequences, mandatory spine and the regression test): run 45116537410, 5 passed. Locally only ruff and the guarded generator, witnesses and known_cell_issues (host rule 17(g)).

Changelog

  • One fragment per section, changelog.d/<pr>.<section>.md, holding
    one line: user-visible effect first, 25 words or fewer, ending with
    (#PR); breaking changes only under upgrade notes; no Highlights; no
    new lines under ## [Unreleased]. See changelog.d/README.md and
    .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.
  • 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.

…nd name the org layer (#4919)

The nightly falsifier set_policy(org-deny), declare(hook), update, decide(hook, approve) expected approve to exit 0 because the hook package was installed. The documented contract is deny wins (reference/cli/approve.md, 'Approving a denied package'): when a named package is still blocked by a deny in another layer, approve exits 1 and names that layer and how to lift it. commands/approve.py records the grant, prints '<pkg> is still denied (...); the approval has no effect until that deny is lifted: the org policy denies it ...', and exits 1. The model now expects exit 1 with the org layer named for an org-denied installed package; the org deny itself is untouched. Regression test: test_approve_under_an_org_deny_refuses_and_names_the_org_layer replays the falsifier and checks the hook stays undeployed.

Refs #4919

Co-authored-by: Copilot App <[email protected]>
… 1: strict Known #4923

The narrowed nightly run 45115510222 showed the second half of the #4919 falsifier. With the exit code expectation fixed, a new approval under the org deny records the grant in apm.yml and then exits 1, a failed command that changed durable state (I7). Filed as #4923. GATE KNOWN_CELLS holds it strict (project scope, applies only to a new grant). The spine now revokes and re-approves the hook under the org deny so the cell fails every run.

Refs #4919

Co-authored-by: Copilot App <[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.

🟢 Approval recommended

No active review issues are recorded for the test-only lifecycle update, while the separate durable-state bug is tracked as a strict known failure.

No open issues 🎉

What changed in this PR

This PR corrects the GATE lifecycle model for approvals blocked by an organization deny, addressing the stale expectation behind #4919 while tracking the separate durable-state bug in #4923. It changes test infrastructure only, not CLI behavior.

Changes:

  • Expect exit 1 and an organization-layer explanation when approving an installed, org-denied package.
  • Add a regression replay and mandatory revoke/re-approve sequence, checking that the hook remains undeployed.
  • Register #4923 as a strict known failure for a refused approval that writes a new grant.
File Description
tests/​quality/​known_cell_issue_states.json Records #4923 as open for known-failure validation.
tests/​lifecycle/​machines/​test_m_gate.py Adds the regression replay and mandatory org-denied approval sequence.
tests/​lifecycle/​machines/​_gate_kit.py Corrects approval expectations and registers the strict known failure.

Review effort: Balanced

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.

🟢 Approval recommended

No active review issues are reported, and the separate manifest-write bug is explicitly tracked as a strict known failure.

No open issues 🎉

Review effort: Balanced

@danielmeppiel Daniel Meppiel (danielmeppiel) added the full-integration Run the full integration suite (ci-integration.yml) on this PR before merge label Nov 23, 2026
The refusal cell now runs approve directly and asserts the exit code,
the org-layer message, and that the hook file is not deployed.

Co-authored-by: Copilot App <[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

The repeated-approve test bypasses the snapshot and cross-cutting checks, allowing unintended durable-state changes to pass despite the expected refusal.

1 open issue

Review effort: Balanced

Comment thread tests/lifecycle/machines/test_m_gate.py Resolved
The repeat is not a new grant, so the snapshot, I7 and write-set oracles
guard it; the manifest must stay byte-identical.

Co-authored-by: Copilot App <[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.

🔵 Needs a closer look

Human assessment is needed because the org-denied lifecycle checks can accept unrelated manifest changes without verifying that the targeted grant was recorded.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

# Conflicts:
#	tests/quality/known_cell_issue_states.json

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 #4923 exception can accept unrelated manifest corruption during an org-denied approval because it ignores before/after snapshots instead of limiting changes to the verified grant and required approval metadata.

1 open issue

Review effort: Balanced

Comment thread tests/lifecycle/machines/_gate_kit.py Resolved
The exception now requires the grant for the approved package and an
otherwise identical manifest; any unrelated manifest change stays fatal.

Co-authored-by: Copilot App <[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

The known-cell matcher incorrectly rejects a named-approval transition that removes the package’s matching deny, causing an unexpected I7 failure and requiring a narrowly scoped matcher fix with regression coverage.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread tests/lifecycle/machines/_gate_kit.py Resolved
# Conflicts:
#	tests/quality/known_cell_issue_states.json

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 Known comparison still rejects reachable approval transitions that remove a matching project deny, causing unexcused I7 failures for the existing write-before-refusal bug and requiring a narrow fix with regression coverage.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread changelog.d/4908.fixed.md Resolved
…s own deny

Approve removes the same-store deny for the package before it saves the
grant; the matcher now undoes exactly that, and a replay pins the
deny -> org-deny -> approve sequence. Drops five v0.38.1 changelog
fragments a main merge restored.

Co-authored-by: Copilot App <[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.

🟢 Approval recommended

No active review issues remain for the organization-policy blocked-approval lifecycle changes.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

# Conflicts:
#	tests/quality/known_cell_issue_states.json

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.

🟢 Approval recommended

No active review issues are reported, and the remaining manifest-write bug is tracked separately as known issue #4923.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 3bbfb6c into main Nov 23, 2026
64 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the ql/w2b-4919-gate-approve-org-deny branch November 23, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-integration Run the full integration suite (ci-integration.yml) on this PR before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ci] Nightly GATE state machine is failing

2 participants