Skip to content

test(lifecycle): M-GATE matrix credits OP x PRIM x GATE cells (T-1 batch 1) - #4575

Closed
Daniel Meppiel (danielmeppiel) wants to merge 10 commits into
mainfrom
danielmeppiel-q-l-w2-gate-lock-drain
Closed

Daniel Meppiel (danielmeppiel) wants to merge 10 commits into
mainfrom
danielmeppiel-q-l-w2-gate-lock-drain

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

M-GATE credited no generated obligation: generator/witnesses.py read only M-SOURCE and M-SCOPE-LOCK, and the covering replay never produces GATE=none for executables (gate off), denied-dependency (org dependency deny), a skill beside a revoked executable (U2), or a GATE for install --mcp (U7). So those T1/T2 cells stayed baseline.

This PR adds a deterministic GATE matrix spine (tests/lifecycle/machines/_gate_matrix.py) on the shared lifecycle world. It walks six gate levels in turn:

  1. gate off (no executables block)
  2. allowed
  3. revoked after deploy
  4. denied before deploy
  5. unapproved
  6. org dependency deny (new world policy variant deny-all-deps)

The spine runs about 40 real CLI commands. Every step runs check_cross_cutting (I1-I9, with I4 against expected_deployed). Then oracles.check_obligation credits machine ids G1|<op>|<prim>|<gate>|<scope> with e2e-evidence:

  • install --mcp steps: the non-MCP surfaces are unchanged, and no other server is configured.
  • Refusals: durable state is unchanged.
  • U2 steps: the p-mixed skill is present.

witnesses.py translates the ids with GATE as an anchor: only implied ids that name GATE are credited, so a refusal under a dependency deny never discharges a success cell.

Supporting changes:

  • ModelState.exec_gate (default on): with the gate off, executables are allowed.
  • StepRunner is extracted from MachineBase, so a deterministic spine can reuse the step runner without being a Hypothesis machine.

Ruling applied (Q&L lead, 2026-11-21): apm prune under a dependency deny is non-reconciling for I4. prune removes only undeclared packages, and declared denied dependencies stay until the user removes them.

Obligation counts (tests/quality/lifecycle_obligations.json, regenerated after merging main):

before after
status baseline 1468 / required 1023 baseline 1331 / required 1160
T-1 baseline 254 133
T-7b baseline 63 47

Total moved: 137 (121 T-1 + 16 T-7b GATE=denied-dependency pairs). After review, the spine credits no bin or other-file cell and no MCP cell of install --mcp, the U7 oracle asserts that the requested server is declared, locked and configured (with a negative control), (no step observes a bin outcome at project scope, U-BIN). Each resolving step must now deploy exactly the model's observable set, and prune under a dependency deny must never widen. CI time of the matrix test: 47 s (Lifecycle Smoke shard, engine driver).

Issue and approved scope

Issue: Refs #4564 (0.38 lifecycle burn-down), Refs #4565 (epic)

Human scope-approval comment: #4564 (comment)

Does this PR complete the issue, or what remains? Partial. T-1 batches 2 and 3 remain: user scope (T2), bundle-install, pack, and the marketplace proposals. T-3 (#4097) follows.

Type of change

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

Testing

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

Validation (engine driver, macOS, host-guarded):

  • pytest tests/lifecycle/machines/test_m_gate.py::test_gate_matrix_credits_op_prim_gate_cells -> 1 passed, every G1| id earned a receipt. The call took 135-157 s locally under load 33; CI timing is pending.
  • pytest tests/quality/test_promise_obligations.py tests/quality/test_generated_obligations.py tests/lifecycle/generator/test_generator_rules.py tests/quality/test_gate_cell_obligations.py -> 80 passed
  • pytest tests/lifecycle/world/test_world.py -k deny-all-deps and test_m_scope_lock.py -k sequences (checks the MachineBase refactor) -> passed
  • python -m tests.lifecycle.generator --check -> up to date
  • Lint contract: ruff 0.15.12 check and format, pylint R0801, lint-auth-signals, complexity ratchet (--base-ref origin/main) and tests.quality.taxonomy --changed -> all clean

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

A deterministic spine on the shared lifecycle world walks six gate levels
(gate off, allowed, revoked after deploy, denied before deploy, unapproved,
org dependency deny) and credits G1 machine ids through check_obligation
after I1-I9 on every step. witnesses.py translates them anchored on GATE.

Refs #4564
Refs #4565

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 gate matrix can issue unsupported receipts because it misses incomplete deployments, widening prune steps, unexpected MCP servers and instruction changes, while crediting bin outcomes it never observes.

5 open issues
What changed in this PR

Adds a deterministic M-GATE lifecycle matrix to advance the obligation coverage work in #4564. The changes are test-only and connect gate scenarios to generated coverage receipts.

Changes:

  • Exercises six gate states through real CLI sequences, including MCP-only installs and dependency-deny refusals.
  • Extracts a reusable step runner and extends the test model and world with gate-off and deny-all-dependencies states.
  • Regenerates the obligation catalog, moving 172 cells from baseline to required.
File Description
tests/​quality/​lifecycle_obligations.json Records new matrix witnesses and updated coverage counts.
tests/​lifecycle/​world/​test_world.py Adds expected results for the dependency-deny policy.
tests/​lifecycle/​world/​services.py Defines the matrix's dependency-deny policy.
tests/​lifecycle/​model/​state.py Models gate-off and dependency-deny states.
tests/​lifecycle/​model/​expected.py Allows expected executable deployment when the gate is off.
tests/​lifecycle/​machines/​test_m_gate.py Runs the project-scope matrix and checks receipt completeness.
tests/​lifecycle/​machines/​_kit.py Extracts StepRunner for deterministic and rule-based tests.
tests/​lifecycle/​machines/​_gate_matrix.py Implements gate transitions, CLI sequences, and receipt evidence.
tests/​lifecycle/​generator/​witnesses.py Maps matrix IDs to GATE-anchored obligations.

Review effort: Balanced

Credit no bin cell (no spine step observes a bin outcome), keep
.github/instructions unchanged under install --mcp, compare MCP servers
against a set read before the command, hold prune under a dependency deny
to never-widen, and require each resolving step to deploy exactly the
model's observable set.

Refs #4564

Co-authored-by: Copilot App <[email protected]>
#4006/#4019 shifted the update command options by 8 lines, so
test_every_rule_cites_code_that_still_says_it failed on the merge.

Refs #4564

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

Copy link
Copy Markdown
Collaborator Author

Superseded by the train #4598, test(lifecycle): corpus train 1 (T-1 batch 1 + T-2 drain 1). The train merges this branch with --no-ff (authorship preserved) together with the other ready corpus batch, and regenerates tests/quality/lifecycle_obligations.json once. This PR stays open and linked until the train lands.

Per review on the corpus train: drop other-file credits (no compile-staged
output is asserted for copilot) and MCP credits of install --mcp (the
requested registry server is never gated). The U7 oracle now asserts the
requested server is declared, locked and configured, that no other server
appears, and that only servers the gate no longer allows may go, with a
negative control for each defect.

Refs #4564

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

Copy link
Copy Markdown
Collaborator Author

Superseded by #4598 (corpus train 1, merged as bfff927), which landed this branch with --no-ff.

Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 21, 2026
U-BIN-OPS (definition rule, OP x PRIM x GATE only): bin/ deploys only for a
marketplace plugin at user scope (exec_gate.plugin_bin_deployable); audit,
prune, pack and marketplace have no user-scope form and a local bundle is
never a marketplace plugin, so a gate level of bin/ under them is vacuous
(the #4575 review: an absence U-BIN guarantees proves nothing about the
gate). It removes 9 baseline cells and 11 required T1 cells whose covering
receipts only proved bin/ absent (T-1 required -11 by design). An org-policy
level stays its own cell (U2 no-collapse); OP x SRC x PRIM and OP x PRIM
cells keep their absence witnesses. A tripwire binds the rule to the live
CLI (no --global on audit, prune, pack, marketplace), the U-BIN predicate
pin and the closed-world bin/ writer pin.

U-FIRST-PARTY-MCP now also maps OP=mcp-install x PRIM=mcp at the executable
gate levels: install --mcp declares the server in the root apm.yml, so it
is first-party and never gated.

Refs #4095 #4565

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 21, 2026
U-BIN-OPS (definition rule, OP x PRIM x GATE only): bin/ deploys only for a
marketplace plugin at user scope (exec_gate.plugin_bin_deployable); audit,
prune, pack and marketplace have no user-scope form and a local bundle is
never a marketplace plugin, so a gate level of bin/ under them is vacuous
(the #4575 review: an absence U-BIN guarantees proves nothing about the
gate). It removes 9 baseline cells and 11 required T1 cells whose covering
receipts only proved bin/ absent (T-1 required -11 by design). An org-policy
level stays its own cell (U2 no-collapse); OP x SRC x PRIM and OP x PRIM
cells keep their absence witnesses. A tripwire binds the rule to the live
CLI (no --global on audit, prune, pack, marketplace), the U-BIN predicate
pin and the closed-world bin/ writer pin.

U-FIRST-PARTY-MCP now also maps OP=mcp-install x PRIM=mcp at the executable
gate levels: install --mcp declares the server in the root apm.yml, so it
is first-party and never gated.

Refs #4095 #4565

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 22, 2026
U-BIN-OPS (definition rule, OP x PRIM x GATE only): bin/ deploys only for a
marketplace plugin at user scope (exec_gate.plugin_bin_deployable); audit,
prune, pack and marketplace have no user-scope form and a local bundle is
never a marketplace plugin, so a gate level of bin/ under them is vacuous
(the #4575 review: an absence U-BIN guarantees proves nothing about the
gate). It removes 9 baseline cells and 11 required T1 cells whose covering
receipts only proved bin/ absent (T-1 required -11 by design). An org-policy
level stays its own cell (U2 no-collapse); OP x SRC x PRIM and OP x PRIM
cells keep their absence witnesses. A tripwire binds the rule to the live
CLI (no --global on audit, prune, pack, marketplace), the U-BIN predicate
pin and the closed-world bin/ writer pin.

U-FIRST-PARTY-MCP now also maps OP=mcp-install x PRIM=mcp at the executable
gate levels: install --mcp declares the server in the root apm.yml, so it
is first-party and never gated.

Refs #4095 #4565

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

2 participants