Skip to content

test(lifecycle): family core -- model, driver, oracle receipts, obligation ratchet - #4142

Merged
Daniel Meppiel (danielmeppiel) merged 107 commits into
mainfrom
danielmeppiel-cautious-fortnight
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 107 commits into
mainfrom
danielmeppiel-cautious-fortnight

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

TL;DR. This PR adds the core of the lifecycle test family under tests/lifecycle/:

One example replay row drives the real CLI and earns receipts for I1-I9. The I2 law found a real defect on main, #4132, which the row records as a strict expected failure.

Problem (WHY). 17 lanes of the 0.37 lifecycle family need a shared model, driver, oracle and credit system. Until now, credit for a GATE cell came from a cell: event that is emitted before the step runs. A requested step therefore earned credit even if no oracle ever checked it.

Approach (WHAT).

Piece File
Pure model: declared forms, approvals, policy variant, targets, scope, lock, edited set, cache tests/lifecycle/model/state.py (ModelState)
Reference expectations and per-command exit contracts tests/lifecycle/model/expected.py (expected_deployed, expected_lock_rows, expected_exit, EXIT_CONTRACTS: audit 0-3, pack 0-5, others 0-2)
Driver: run(world, argv, scope=), APM_LIFECYCLE_DRIVER=engine|binary, user-scope flag per command tests/lifecycle/driver.py
Oracle (promoted, I1-I9); each check reports whether it applied; operation_for(args); check_output (I6, I8, I9) tests/lifecycle/oracles.py
Receipts: Receipt(node, params, pre_digest, argv, scope, post_digest, oracle_id, outcome, lane); emit raises ReceiptForgeryError for any caller other than the oracle module tests/lifecycle/receipts.py
Obligation catalog and witness ratchet plugin tests/lifecycle/obligations.py, tests/quality/promise_obligations.json
Snapshot helpers promoted from #4040 (LifecycleSurfaceRoots, capture_surfaces, restore_tree) tests/lifecycle/snapshot.py
Wiring: driver selection, T-0W world or fallback world, receipts plugin, global output oracle hook tests/lifecycle/conftest.py, tests/lifecycle/_fallback_world.py
Row runner and example row tests/lifecycle/rows.py (RowReplay), tests/lifecycle/replay/rows/core_gate_row.yaml

Implementation (HOW).

flowchart LR
  row[replay row / machine rule] --> drv[driver.run]
  drv --> cli[python -m apm_cli.cli]
  drv --> out[global output hook: I6 I8 I9]
  row --> orc[check_cross_cutting I1-I9]
  orc -->|law applied and passed| rc[receipts.emit]
  out --> rc
  rc --> mem[(in-process receipts)]
  rc --> jsonl[(session JSONL)]
  mem --> wit[witness check in lifecycle shard]
  jsonl --> q[test_promise_obligations.py]
  obl[promise_obligations.json] --> wit
  obl --> q
Loading
  • Ratchet. The universe is the steward-approved APPLY table (91 invariant x operation pairs) plus the 107 GATE cells. 144 obligations are required, each with a witness test: the example row, or the GATE spine for [project] or [user]. The remaining 54 sit in the baseline, each naming its lane (T-1 Lifecycle test family: M-GATE machine in the family (T1 and T2 obligations) #4095, T-2 Lifecycle test family: M-SOURCE machine (T3 and T5 obligations) #4096, T-3 Lifecycle test family: M-SCOPE-LOCK machine (T4 obligations) #4097 or T-5 Lifecycle test family: covering replay generator and rows #4099). A global pytest_runtest_makereport hook fails a passing witness whose receipts do not cover its rows; this runs inside the existing lifecycle shards with one dict lookup per test. test_promise_obligations.py is in the ratchet job. It pins the universe, checks that every witness is a lifecycle_smoke test, and checks that every baseline lane is a real lane. On a merged receipts run it also fails when a baseline row is already covered, so that row must be promoted to required.

  • Credit rules. A law that does not apply, fails, or is owned by a strict expected failure earns nothing. A refusal receipt never covers a success obligation; I7 needs a refusal. I3 credit also counts the paired audit op.

  • Promotion. tests/utils/lifecycle_oracle.py and tests/utils/world_snapshot.py become re-export shims. lifecycle_state.py imports the surface code from tests/lifecycle/snapshot.py. The GATE kit passes its cells and scope into Operation, so the GATE spines earn receipts for all 107 cells.

  • Oracle changes. These are kept minimal, as the lead asked:

    • I1 accepts a hashless record that is a directory (a deployed skill);
    • I8 uses each command's documented exit contract;
    • I9 also flags Python tracebacks.

    I3 remediation, I7 announcements and I9 per-cause counting are unchanged (T-1).

  • CI. The lifecycle shard command gains tests/lifecycle, the ratchet job gains tests/quality/test_promise_obligations.py, and estimated durations are added for the two new nodes. There are no new jobs.

Trade-offs.

Issue and approved scope

Fixes #4093
Fixes #4094
Fixes #4095
Fixes #4098
Fixes #4113
Fixes #4133

Human scope-approval comments: #4093 #4093 (comment) ; the records on #4094, #4095, #4098, #4113 and #4133 (posted by Daniel Meppiel (@danielmeppiel)).

This PR is the T1 integrator of the 0.37 lifecycle family:

Pieces land here progressively; the PR stays a draft until all of them are in and green. It makes no claim on #4096, #4097 or #4099 (finished by T2). It found #4132, which is not owned here and is recorded as a strict expected failure.

Type of change

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

Testing

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

Promise ids discharged: P-INV-I1..P-INV-I9 (the row names all nine). Obligation cells: 144 required rows in tests/quality/promise_obligations.json.

  • 18 are witnessed by tests/lifecycle/test_core_example.py::test_core_gate_row_keeps_every_invariant.
  • 126 are witnessed by tests/integration/test_generated_gate_state_machine.py::test_gate_mandatory_spine_covers_obligations[project|user]. This includes all 107 GATE cells, now earned through receipts.

Red before (snapshot-backed oracle failures on the real CLI, engine driver):

Control Command Result
Recorded mutant (approval check skipped) RowReplay(core_gate_row, entry_point=skip_approval_check.py) after install: I4 ...: p-exec/hook/copilot still deployed but not allowed; kept as test_core_gate_row_kills_the_recorded_approval_mutant
Negative control: remove the I4 oracle call "I4" dropped from _CHECKS, then pytest tests/lifecycle/test_core_example.py::test_core_gate_row_keeps_every_invariant FAILED: ...is the witness of 1 required obligation(s) that no oracle receipt covered: P-INV-I4|op:install
Negative control per law (in-process) pytest tests/quality/test_promise_obligations.py -k removing_one_oracle_call removing each of I1-I9 uncovers exactly P-INV-<law>|op:install (9 cases)
Closed-world receipt guard and its mutation -k only_the_oracle / -k without_the_caller_guard the guard refuses a test-body receipt; with only the guard disabled, the forged I4 receipt earns credit
Real defect on main example row, step apm install --frozen I2: converged install-frozen rewrote files: ['project:.github'], tracked as #4132 (strict known_cells)

Green after:

Command Result
uv run --extra dev pytest -p no:cacheprovider -q -n 8 --dist loadgroup tests/lifecycle tests/integration/test_generated_gate_state_machine.py tests/integration/test_lifecycle_state_snapshot_contract.py tests/unit/scripts/test_lifecycle_evidence.py tests/quality/test_promise_obligations.py tests/quality/test_gate_cell_obligations.py tests/quality/test_lifecycle_bug_ledger.py 240 passed in 57s
APM_LIFECYCLE_RECEIPTS_REQUIRED=1 uv run --extra dev pytest -q tests/quality/test_promise_obligations.py (on the merged session receipts) 19 passed
uv run --extra dev pytest -q -n 4 tests/quality/ 232 passed (test_ci_topology.py included)
CI-mirror lint: ruff check, ruff format --check, complexity ratchet, pylint R0801, lint-auth-signals.sh (grep guards are src/-scoped; no src/ change) all clean

Runtime: the two new lifecycle nodes take about 6 s each locally and run in lifecycle shard 2. The quality test takes 0.5 s.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md:
    user-visible effect first, 25 words or fewer, ending with (#PR);
    breaking changes only under upgrade notes; no Highlights; see
    .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.

…obligation ratchet (#4093)

Create tests/lifecycle/: a pure reference model (model/state.py,
model/expected.py), a driver (engine|binary), the cross-cutting oracle
promoted from tests/utils/lifecycle_oracle.py with receipts written only
by the oracle, snapshot helpers, a fallback world until T-0W lands, and a
row runner with one example replay row. tests/quality/promise_obligations.json
splits the 91 invariant x operation pairs and 107 GATE cells into required
rows (witness tests must earn the receipt, checked in the lifecycle shards)
and a baseline owned by later lanes. Old oracle/snapshot paths keep shims.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…mands run outside the project (#4093)

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
#4113)

Adds check_cli_output (I6 ASCII + JSON mode, I8 exit contract, I9 no
traceback or duplicated diagnostics) to tests/utils/lifecycle_evidence.py
and routes ApmLifecycleRunner.run and run_sequence through it. Known
cells registry is empty pending suite discovery.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…4095)

Move tests/integration/_gate_machine_kit.py and
test_generated_gate_state_machine.py to tests/lifecycle/machines/_gate_kit.py
and test_m_gate.py. Commands now run through the lifecycle driver (engine on
PR, binary on the nightly); the GATE cell session hook moves to
tests/lifecycle/machines/conftest.py. Witness node ids, duration seeds,
taxonomy baseline, nightly workflow and docs follow the move.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Compare the apm Click tree with the reference CLI pages and the apm-usage
commands guide in both directions; fix five small docs gaps it found.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…4107-#4112)

oracles.check_obligation(cell_id, strength, before, after, result, evidence)
is the one entry point that credits a generated obligation. The oracle
checks the evidence itself (snapshot paths, unchanged bytes, egress log,
persisted-secret scan, exit, output, owner value) and writes the receipt
only when every fact holds; unit, e2e and e2e-evidence strengths set the
minimum evidence.

tests/lifecycle/obligation_space.py expands the reviewed model export
tests/quality/security_obligations.json (G 244, P 224, I 116, E 281, M 38,
C 22 = 925) and one row per journey step oracle of the journey index. The
P collapse after the routing owner lands is a recorded, disabled rule.
obligations.py loads the generated space with required witnesses, a derived
per-lane baseline and a separate known-failing list that earns no receipt.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…ll, #4154 XPASS

- test_policy_outcome_routing_lifecycle.py cites P-OWN-policy-outcome-routing (added to the catalog).
- test_credential_rendering.py: the two equal-body tests become one parametrized test with ids.
- Strict output cell for approve's org-policy warning printed twice (#4178).
- p-native-claude at user scope installs now (#4154); its strict xfail is retired.

Co-authored-by: Copilot App <[email protected]>
…4142 resolves

- Taxonomy baseline: drop the temporary allowances for the modules #4142 marks
  (spec behavior modules, journey index, registry archive, git lock content hash,
  policy outcome routing, credential rendering) and the deleted integration machines;
  test_m_gate.py now carries e2e and promise marks.
- Exact-duplicate baseline: drop the credential_rendering pair (now one parametrized test).
- #4270 landed (#4276): the Claude plugin bin/ user-scope world cells are required again.
- #4178 cell keys on the same approve warning printed twice, not on any warning.

Co-authored-by: Copilot App <[email protected]>
…lowance growth

- test_generated_obligations.py cites the executable trust owners its security
  tables cover; its promise_exempt entry is dropped.
- Main's new test_hook_approval_pin_parity_lifecycle.py cites
  P-OWN-executable-trust-fingerprint; test_hook_pin_parity_reqs.py is component
  and cites req-sc-011.

Co-authored-by: Copilot App <[email protected]>
…e global hook; cell for the empty org-policy notice per phase (#4113)

One product duplicate now has one owner: tests/lifecycle/oracles.py
_i9 excuses a duplicated line only when a strict I9 known output cell
owns it for the same command, and the global hook on that command still
fails the cell once the defect is fixed. Adds the #4241 cell for
'[!] Org policy at <x> is present but empty' printed by both phases.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…--recommended prints the warning once (#4113)

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…4113)

New neutral issues: #4330 (non-ASCII path echoed raw), #4331 (uninstall lines per
duplicate declaration), #4332 (adapter unreadable-config warning twice), #4333
(deny_all lifecycle notice repeats on update), #4334 (verbose diagnostics repeat),
#4336 (hook summary line twice). Existing: #4299 (parked MCP per phase), #4291 (pack
manifest notes twice). One #4178 cell (repeat-keyed); #4256 keyed on a repeated notice.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit d754d89 into main Nov 20, 2026
27 of 33 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-cautious-fortnight branch November 20, 2026 14:02
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
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
#4142 moved the GATE machine kit to tests/lifecycle/machines; cell g
(#4050, fixed here) is dropped there and the #4050 ledger row points at the
moved spine test.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
Take main as canonical for the quality modules and the taxonomy baseline; keep
both CHANGELOG lines.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
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

2 participants