Repository navigation
test(lifecycle): GATE state machine with cross-cutting oracle (#4031) - #4040
Merged
Daniel Meppiel (danielmeppiel) merged 16 commits intoNov 20, 2026
Merged
Conversation
#4029) Replace the wall-clock budget (elapsed < 1.0s) in the three parallel registry tests with an in-flight probe: each stubbed lookup holds until all three lookups are in flight together, and the test asserts max_in_flight == 3. The result no longer depends on runner speed, and a serialized executor (workers = 1) fails all three tests. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…ore ready) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The installer job evidence comes from main instead. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
This was referenced Nov 20, 2026
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-fictional-guacamole
branch
from
November 20, 2026 02:54
62a6186 to
d7ceb6c
Compare
This was referenced Nov 20, 2026
Merged
The generated lifecycle machine replayed the mandatory spine in an @initialize rule, so every Hypothesis example paid for the full spine. Replay it once per variant world inside the first generated model, then restore that post-spine world in place for each later example. Restoring in place keeps the deployment roots' inodes, which local receipts bind to. The new draws reach a no-op 'update' after a local edit; the model now keeps the edit unless the update changes the revision, matching the CLI. Local timing (2 CPUs), generated sequences: 310.5 s -> 121.1 s. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…snapshots (#4031) Add check_cross_cutting(before, after, result, model, op) with laws I1-I9 (lock/deployed agreement, idempotence, frozen/audit agreement, gate monotonicity, write set, ASCII and JSON output, failure atomicity, exit codes, duplicated output). Each law aliases the lifecycle-ledger properties it refines. A known failing cell is a strict expected failure: it must keep failing where the model says it does. LifecycleStateSnapshot can now capture approval stores, the policy cache, native plugin registries and per-adapter MCP config files. The in-place world restore moves to tests/utils/world_snapshot.py. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
#4031) M-GATE drives python -m apm_cli.cli through declare/undeclare of hook, LSP and native-plugin content, approve, deny, revoke, org policy tightening, install, install --frozen, update, uninstall, prune and audit --ci, at project scope and at user scope with APM_HOME outside HOME, checking the cross-cutting oracle after every step. Derandomized, step_count 8; 4 examples per scope in the lifecycle shards. Every step emits a cell: event; a session hook writes the visited set and tests/quality checks it covers tests/quality/gate_cell_obligations.json. A recorded mutant that skips the approval check must fail the machine. Cells failing on main are strict expected failures naming their tracking issues. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…4031) The nightly GATE run (25 examples per scope) moves out of the release pipeline into .github/workflows/gate-machine-nightly.yml, which opens or updates one tracking issue on failure and closes it on recovery. build-release.yml is unchanged from main. Nightly examples are no longer derandomized, so each night explores fresh sequences; PR runs stay derandomized. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Every known cell now names the violation message it owns; any other violation of the same law on that step still fails, including the reference law in the machine. I4 reports one violation per surface and checks mutating steps against a deployed ceiling recorded at each deny, revoke or tightening. Spine coverage is asserted on the machine's own visits. First-run creation of the user config and version-check cache is not a write-set violation. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Each lifecycle shard uploads its visited GATE cells; a GATE Cell Coverage job merges them and requires both scope spines to report and to cover the obligation list. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…coverage (#4031) Drop the deployed ceiling: I4 is checked relative to the model, so after each successful mutating step nothing may be deployed that current approvals and policy do not allow. A regression test narrows one surface after approving a hook and requires the hook to stay deployed. A project-scope step may now write only its receipts and bookkeeping under HOME. The lifecycle-smoke aggregate requires the GATE cell coverage job, whose checkout no longer persists credentials. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Admit only ~/.cache/apm and ~/.local/state/gh (plus their exact parent directory entries) besides receipts and local state, so a write such as ~/.local/bin/evil fails the write-set law. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
gate-cell-a (#4041) and gate-cell-f (#4048) now pass on main, so their strict expected failures are removed. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-fictional-guacamole
branch
from
November 20, 2026 07:36
877d70b to
4c6138e
Compare
This was referenced Nov 20, 2026
Co-authored-by: Copilot App <[email protected]>
…ELOG [Unreleased] resolved) Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
marked this pull request as ready for review
November 20, 2026 08:08
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 20, 2026 08:08
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Active gaps in the lifecycle oracle and test harness allow unexpected command failures, leftover declarations or LSP claims, and unauthorized artifact changes to pass undetected.
5 open issues
Restrict writes across all observed workspace roots · New Validate expected outcomes for nonzero install and update exits · New Require successful uninstall to remove the package declaration · New Reconcile LSP service claims with adapter configurations · New Compare durable artifact bytes when checking failed commands · New
What changed in this PR
Adds M-GATE to APM's lifecycle tests, exercising executable-trust transitions at project and user scope with shared invariants and tracked expected failures.
Changes:
- Adds generated GATE sequences, deterministic coverage obligations, and an approval-bypass mutation test.
- Reduces lifecycle replay overhead through in-place world restoration and replaces timing-based concurrency assertions.
- Adds cross-shard coverage enforcement, nightly exploration, and contributor documentation.
| File | Description |
|---|---|
tests/utils/world_snapshot.py |
Restores test worlds while preserving surviving directories. |
tests/utils/lifecycle_state.py |
Captures approval, policy, plugin and MCP surfaces. |
tests/utils/lifecycle_oracle.py |
Defines shared lifecycle laws and strict expected failures. |
tests/unit/integration/test_mcp_registry_parallel.py |
Verifies concurrency using overlapping calls instead of elapsed time. |
tests/quality/test_gate_cell_obligations.py |
Validates obligations and recorded cell coverage. |
tests/quality/test_ci_topology.py |
Requires GATE coverage in the lifecycle aggregate. |
tests/quality/gate_cell_obligations.json |
Records required GATE transition cells. |
tests/integration/test_generated_lifecycle_state_machine.py |
Reuses the mandatory spine and corrects no-op update modeling. |
tests/integration/test_generated_gate_state_machine.py |
Adds spines, generated sequences and oracle regression tests. |
tests/integration/conftest.py |
Writes per-process visited-cell artifacts. |
tests/integration/_gate_machine_kit.py |
Implements isolated GATE worlds, rules and reference checks. |
tests/fixtures/gate_mutants/skip_approval_check.py |
Provides an approval-bypass mutant. |
docs/src/content/docs/contributing/integration-testing.md |
Documents GATE coverage and lifecycle replay changes. |
CHANGELOG.md |
Records internal testing and concurrency-test changes. |
.gitignore |
Excludes generated cell-coverage artifacts. |
.github/workflows/gate-machine-nightly.yml |
Runs nightly exploration and maintains a failure-tracking issue. |
.github/workflows/ci.yml |
Uploads shard artifacts and enforces combined cell coverage. |
.github/ci-durations/linux-x86_64.json |
Adds GATE duration seeds and revises lifecycle estimates. |
Review effort: Balanced
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-fictional-guacamole
branch
November 20, 2026 08:18
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
…ess, flip #4040 gate-cell-e - Ledger row for #4045 (ownership.preserve_unowned, outcome.status_matches_state). - test_lsp_only_uninstall_clears_every_harness_it_wrote: install to copilot, claude and opencode, uninstall, and assert no harness config keeps the server, at project scope and at -g with APM_HOME outside HOME. - #4040 GATE machine: gate-cell-e (#4045) is no longer a known failure. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
This was referenced Nov 20, 2026
Merged
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
#4058 fixes #4042, so #4040's strict known failure for gate cell b would XPASS; remove it. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
…orks (#4042) #4040's spine reached update and deny with the plugin still pending because approve never took effect for a root-mcp.json Agent Plugin. With #4042 fixed the plugin is approved there, so the required update|plugin|pending and deny|plugin|pending cells went unvisited. Revoke and reinstall the plugin before update to keep them covered. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
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
TL;DR
Adds M-GATE, a Hypothesis sub-machine of the generated lifecycle model that drives
python -m apm_cli.clithrough every executable-trust transition, with a cross-cutting oracle (I1–I9 plus reference law R) checked after every step. First, the existing generated machine stops replaying its mandatory spine per example (310.5 s → 121.1 s locally). Cells the machine shows failing onmainare recorded as strict expected failures naming their tracking issues.Refs #4031 — completes the approved scope (spine fix, M-GATE, oracle, cell coverage, mutant, one internal CHANGELOG line).
Important
Merge order: merge this PR early in the 0.38 batch, before the fix PRs below. Every recorded failing cell is strict: once its fix lands, the machine fails with "strict expected failure … did not fail; remove its expectation", so each fix PR removes its matching
KnownCellwhen it rebases.Cell markers and their fix PRs
Rebased on 0.37.0: gate-cell-a (#4041) and gate-cell-f (#4048) were fixed by #4004 and are removed; both were verified to pass on
mainfirst.Problem (WHY)
@initialize, so every Hypothesis example paid for it (≈466 s on CI x86 for the three generated nodes).--frozen, update, uninstall, prune andaudit --ci, at both scopes.Approach (WHAT)
restore_tree), because local receipts bind to the deployment root's inode.check_cross_cutting(before, after, result, model, op)with laws I1–I9; each law aliases existing ledger properties (no new ledger rows).LifecycleStateSnapshotoptionally captures approval stores, the policy cache, native plugin registries and per-adapter MCP config files.stateful_step_count=8; 4 derandomized examples per scope on PR (lifecycle shards), 25 fresh examples per scope in.github/workflows/gate-machine-nightly.yml.cell:<OP>|<SRC>|<PRIM>|<GATE>|<SCOPE>; a session hook writes the visited set;tests/qualitychecks it covers the checked-in obligation list (107 cells); the GATE Cell Coverage job merges every shard's set and requires both scope spines.tests/fixtures/gate_mutants/skip_approval_check.py) that skips the approval check must fail the machine.Implementation (HOW)
tests/integration/test_generated_lifecycle_state_machine.py— removes@initialize;_SpineWorldreplays once and restores per example. The [BUG] Global install succeeds with empty skill directories when HOME/APM_HOME uses a symlink alias #2867 witnesstest_generated_lifecycle_mandatory_replayis unchanged. New draws exposed a model bug: a no-opupdateafter a local edit keeps the edit (the CLI is right), so the model now resetscleanonly when the revision changes.tests/utils/world_snapshot.py— in-place tree restore shared by both machines.tests/utils/lifecycle_oracle.py— the oracle. Expected cells are strict per step; message-matched cells (output noise) are strict per run.tests/utils/lifecycle_state.py—LifecycleSurfaceRoots+ four optional snapshot fields; existing callers are unaffected.tests/integration/_gate_machine_kit.py— world (hook, LSP and native-plugin packages), reference model, rules, known cells. Each known cell names the violation message it owns; anything else on that step still fails. I4 also checks a deployed ceiling recorded at each deny, revoke or tightening.tests/integration/test_generated_gate_state_machine.py— mandatory GATE spine per scope (asserts obligation coverage and that every scope cell still fails), generated sequences per scope, mutant kill.tests/quality/test_gate_cell_obligations.py,gate_cell_obligations.json— obligation schema, vocabulary, ≤10 rules, law aliases, visited coverage.gate-cell-coveragejob merges them and runs the coverage check. A new scheduled workflow,gate-machine-nightly.yml, runs 25 non-derandomized examples per scope and opens or updates one tracking issue on failure.build-release.ymlis unchanged. x86 duration seeds for the new nodes.Diagrams
Legend: one M-GATE step; the oracle and the reference law both consult the known-cell table, so an expected failure must fail and anything else must pass.
flowchart LR R["rule: decide / install / audit_ci ..."] --> C["emit cell event"] C --> B["observe before: snapshot + deployed surfaces"] B --> X["python -m apm_cli.cli"] X --> A["observe after"] A --> REF["reference law R"] A --> O["check_cross_cutting I1-I9"] K["KNOWN_CELLS strict"] --> REF K --> O O -->|"unexpected violation or expected pass"| F["fail run"] REF -->|"unexpected violation or expected pass"| FTrade-offs
lifecycle_merge_group; M-GATE must run on PR, so it lives in its ownlifecycle_smokemodule and reuses the shared helpers.audit --ciandprunehave no--globalform, so they are project-only rules (user spine substitutesinstall --frozen/update).scripts/check_lifecycle_evidence.pyrejects the currentapm_cli.entrypointlauncher onmaintoo (pre-existing, not CI-gated), so the [BUG] Global install succeeds with empty skill directories when HOME/APM_HOME uses a symlink alias #2867 witnesses were verified by running their tests directly.Benefits
Validation
Commands and results (local, 2 CPUs)
CI on the PR head: see the checks tab; the lifecycle shards run the GATE nodes and GATE Cell Coverage checks the merged visited set.
Before/after (same machine),
-k sequences_preserve:Scenario Evidence
test_generated_gate_state_machine.py::test_gate_mandatory_spine_covers_obligationstest_gate_generated_sequences_keep_cross_cutting_lawstest_gate_machine_kills_the_recorded_approval_mutanttest_generated_lifecycle_sequences_preserve_reference_modelHow to test
uv run --extra dev pytest -q tests/integration/test_generated_gate_state_machine.py→ 5 passed;build/gate-cells/visited-main.jsonis written.uv run --extra dev pytest -q tests/quality/test_gate_cell_obligations.py→ 6 passed.KnownCell→ the spine fails naming that cell's violation.Issue and approved scope
Issue: Refs #4031
Human scope-approval comment: #4031 (comment)
Does this PR complete the issue, or what remains? It delivers the approved scope; the product bugs it found are tracked separately (out of scope per the record).
Type of change
Testing
Changelog
## [Unreleased]inCHANGELOG.md(the record asks for one internal line).Spec conformance (OpenAPM v0.1)
Not applicable: no normative behaviour changes.
Co-authored-by: Copilot [email protected]