Skip to content

test: harden the receipt gate and the acceptance gate (#4586) - #4605

Merged
Daniel Meppiel (danielmeppiel) merged 11 commits into
mainfrom
danielmeppiel-w3-receipt-gate-4586
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 11 commits into
mainfrom
danielmeppiel-w3-receipt-gate-4586

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

Hardens the lifecycle receipt gate and the release-acceptance gate (issue #4586, epic #4565). Test and skill infrastructure only; no product change.

  1. Required receipts on the full run. The nightly lifecycle-full job (.github/workflows/lifecycle-journeys.yml) writes receipts to $RUNNER_TEMP/lifecycle-receipts. A follow-up step then runs test_merged_receipts_hold_the_ratchet with APM_LIFECYCLE_RECEIPTS_REQUIRED=1, so every required promise witness must have reported. All seven required witnesses live in tests/lifecycle outside journeys, so this is the full-set job. The workflow documents the subset jobs that do not set the variable: the PR lifecycle smoke shards, the journeys job and gate-machine-nightly.
  2. Base-ref status ratchet. scripts/check_obligation_status_ratchet.py --base-ref <sha> runs in the Lint job next to the complexity and taxonomy ratchets. It fails when an id that is required at the base in lifecycle_obligations.json or generated_obligations.json is baseline or absent at the head. known-failing still counts as tracked. The only way out is a rule that the same change adds and names: a new generator removed or mapped entry, a new security excluded entry, or a new entry in tests/quality/obligation_removals.json (id -> rule or ruling, with its issue) for ids no generator rule can express. A rule that is already present at the base does not excuse a new demotion.
  3. No vacuous e2e receipts. check_obligation refuses an e2e or e2e-evidence receipt with no assertion fact (Evidence.assertion_facts()). An assertion fact is a state fact, an output key line (match or forbid), an expected/observed pair, or a pinned exit code; the pinned exit is the CLI result's own expected/observed pair, which journey O8 receipts use. Evidence() alone is refused.
  4. No GO on a missing ledger. gate_row in the release-acceptance findings.py returns PENDING-VERIFICATION for an unbound ledger (sha null) as well as for a stale one. gate-row on a missing ledger file still exits 2, and now also prints the PENDING-VERIFICATION row. A walk with no findings binds the ledger with add --sha <sha>, so GO stays reachable; SKILL.md says so. The edits are made in .apm/skills/ (source) and redeployed to .agents/skills/ with apm install, which also updates the two content hashes in apm.lock.yaml.

Issue and approved scope

Issue: Refs #4586, Refs #4565

Human scope-approval comment: the amended apm-scope:v1 record on #4586 (Decision: approve, review contact Daniel Meppiel (@danielmeppiel); it supersedes the earlier record and adds item 4).

Does this PR complete the issue, or what remains? It covers items 1-4 of the amended record. One deviation in test placement: the fixture tests for the status ratchet live in tests/unit/scripts/test_check_obligation_status_ratchet.py, because test_ci_topology requires fixture-scope ratchet tests there. The other negative controls are in tests/quality.

Type of change

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

Testing

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

Fails before and passes after, or negative controls:

  • Item 1: test_required_receipts_fail_when_one_witness_did_not_report (all witnesses but one report, so the required mode fails and names the missing one) and test_the_full_lifecycle_run_requires_its_receipts (pins the workflow wiring; fails on main). Live proof, run locally: the seven required witnesses with APM_LIFECYCLE_RECEIPTS_DIR set gave 7 passed; test_merged_receipts_hold_the_ratchet with APM_LIFECYCLE_RECEIPTS_REQUIRED=1 then gave 1 passed.
  • Item 2: tests/unit/scripts/test_check_obligation_status_ratchet.py, 11 passed. A demotion or absence fails; known-failing and newly named removed, mapped and named-removal rules pass; a rule already at the base does not excuse a demotion; an unreadable base ref fails closed with exit 2. check_obligation_status_ratchet.py --base-ref origin/main is clean on this branch and on test(lifecycle): re-ground 21 stale known cells; sign and gate every known cell #4584.
  • Item 3: test_e2e_receipt_needs_an_assertion_fact fails on main and passes here.
  • Item 4: three new cases in tests/unit/test_release_acceptance_scripts.py (unbound ledger, missing ledger in the library and the CLI, add --sha binding a walk without findings) fail on main; 54 passed here, and the matching-sha GO case is unchanged.
  • pytest tests/quality/test_ci_topology.py tests/quality/test_promise_obligations.py tests/quality/test_generated_obligations.py tests/quality/test_test_taxonomy.py passed locally. Two collect-only subprocess tests timed out under host load and passed when re-run alone.
  • Lint contract: ruff 0.15.12 check and format are clean; pylint R0801 10.00/10; auth-signal lint clean; complexity ratchet clean; taxonomy --changed OK; taxonomy allowances did not grow.

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.

1. lifecycle-full writes receipts to one directory and then runs the
   merged-receipt ratchet with APM_LIFECYCLE_RECEIPTS_REQUIRED=1, so every
   required witness must report; subset jobs are documented as such.
2. scripts/check_obligation_status_ratchet.py (Lint job, vs the base SHA):
   an obligation required at the base must stay required or known-failing
   unless the change adds and names a removal or mapping rule
   (lifecycle removed/mapped, security excluded, obligation_removals.json).
3. An e2e receipt needs at least one assertion fact (state, output line,
   pinned exit or expected/observed); Evidence() is refused.
4. Release acceptance: an unbound or missing findings ledger yields
   PENDING-VERIFICATION, never GO; 'add --sha' binds a walk without
   findings.

Refs #4586, #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

Critical validation gaps allow assertion-free receipts, invalid obligation waivers, stale-SHA findings, and missing required witnesses to pass, while valid ASCII-output evidence is incorrectly rejected.

5 open issues
What changed in this PR

This PR strengthens lifecycle evidence and release-acceptance checks for #4586, supporting the broader test-corpus work in #4565. It changes test, CI, and skill infrastructure without changing product behavior.

Changes:

  • Adds required receipt checking to the nightly lifecycle run and rejects assertion-free e2e evidence.
  • Adds a base-ref ratchet to detect required obligations that become baseline or disappear without a new removal rule.
  • Makes missing or unbound acceptance ledgers pending and adds explicit SHA binding, documentation, and regression tests.
File Description
tests/​unit/​test_release_acceptance_scripts.py Tests missing ledgers and explicit SHA binding.
tests/​unit/​scripts/​test_check_obligation_status_ratchet.py Tests demotions, exceptions, and unreadable base refs.
tests/​quality/​test_promise_obligations.py Adds missing-witness and workflow-wiring checks.
tests/​quality/​test_generated_obligations.py Adds assertion-free receipt negative controls.
tests/​quality/​obligation_removals.json Introduces the named-removal registry.
tests/​lifecycle/​oracles.py Requires assertion facts for e2e receipts.
scripts/​check_obligation_status_ratchet.py Implements the base-ref obligation status check.
apm.lock.yaml Refreshes deployed skill content hashes.
.github/​workflows/​main-architecture-ratchets.yml Includes the new ratchet fixture tests.
.github/​workflows/​lifecycle-journeys.yml Persists and checks nightly lifecycle receipts.
.github/​workflows/​ci.yml Runs the status ratchet and its fixture tests.
.apm/​skills/​release-acceptance/​SKILL.md Documents SHA binding for finding-free walks.
.apm/​skills/​release-acceptance/​scripts/​findings.py Adds ledger binding and pending missing-ledger output.
.agents/​skills/​release-acceptance/​SKILL.md Updates the deployed acceptance instructions.
.agents/​skills/​release-acceptance/​scripts/​findings.py Synchronizes the deployed ledger implementation.

Review effort: Balanced

Comment thread tests/lifecycle/oracles.py Resolved
Comment thread tests/lifecycle/oracles.py Resolved
… CLI

- Journey O3 receipts assert ascii_output; it is an output fact, so the
  e2e assertion-fact rule accepts it (the smoke journeys were refused).
- The status ratchet tests are pure-function tests: marked unit (AQ003).
- The ledger gate tests drive findings.py and assert its printed row,
  keeping the assertion-quality baseline flat.

Refs #4586, #4565

Co-authored-by: Copilot App <[email protected]>
- findings.py add --sha refuses findings recorded for another SHA, so an
  old walk cannot bind a ledger to a new SHA and yield GO for it.
- Required receipts cover generated witnesses too, scoped per job by
  APM_LIFECYCLE_RECEIPTS_SCOPE: lifecycle-full requires tests/lifecycle
  outside journeys; the journeys job requires the journey family on Linux.
- A removal waiver must be a non-empty string; null, false, 0, {} and ''
  name no rule.
- State facts count only non-empty predicates: an empty path collection
  or an egress log without a host expectation checks nothing. Journey O12
  records its real fact (no refused host) as an expected/observed pair.

Refs #4586, #4565

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit fa7be34 into main Nov 21, 2026
70 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-w3-receipt-gate-4586 branch November 21, 2026 20:24
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