Skip to content

feat(skills): add apm-lifecycle-tests authoring skill - #4127

Merged
Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-redesigned-doodle
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-redesigned-doodle

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

Adds the repo-local skill apm-lifecycle-tests: a shared authoring procedure for lifecycle tests (tests that drive the real apm CLI through command sequences and check durable state). It names the promise, picks the instrument, writes the failing-before test with snapshot and I1-I9 invariant oracles, and records the bug-ledger row. A one-paragraph pointer in tests.instructions.md routes authors to it.

Problem (WHY)

Approach (WHAT)

Piece Purpose
SKILL.md (251 lines, description 855 chars) Steps 0-9: locate family (branch on tests/lifecycle/conftest.py), name promise + cell factor tuple + owner, derive cells and search first, pick instrument (today vs target columns), write test, run red, fix at owner, run green, ledger row, execute printed hints. I1-I9 table, PR evidence-row output.
references/family.md TODAY harness map (every path verified with ls/grep) and the TARGET tests/lifecycle/ layout, marked in progress.
references/oracles.md How to check I1-I9 with today's helpers; strength ladder and floors; decisive-assertion rules; anti-oracles; negative control; receipts (target only). The "ApmLifecycle engine" content from the reviewer persona is ported into SKILL.md and this file.
references/migrate-and-merge.md Loaded only when moving, merging or retiring *_lifecycle*.py files.
assets/templates.md Runnable pytest skeleton on today's harness, replay row YAML (target), bug-ledger row JSON.
evals/ 3 content evals and 20 trigger evals (10/10; train 6+6, val 4+4), same convention as docs-sync/evals. Run and recorded in evals/README.md: trigger train 6/6 + 0/6, validation 4/4 + 0/4 (gate passes); C1 shows a clear with/without delta; C3 shows no over-trigger.

Implementation (HOW)

  • .apm/skills/apm-lifecycle-tests/** is the source; .agents/skills/apm-lifecycle-tests/** is the deployed copy produced by uv run apm install (identical; diff -r clean).
  • The pytest skeleton lives in a fenced block in assets/templates.md, so pytest never collects it from the skill tree. It was validated by extracting it into tests/integration/, running it green against the in-tree CLI, running ruff on it, running a negative control (deleting the user file makes it fail), then removing the copies.
  • Target-family names (driver, replay rows, RowReplay, model, oracles, receipts, obligations, P-INV/P-LAW ids) appear only inside "when tests/lifecycle/ is present" branches; machines, scenarios, security tables and journeys are marked planned.
  • apm.lock.yaml: only additive rows for the new skill plus the updated hash of .github/instructions/tests.instructions.md. The lockfile header stays at the committed generator version (the in-tree install offered a one-time format upgrade; that is left for a separate change).
  • Template examples were checked against --help: the replay row uses apm approve <pkg> / apm deny <pkg> and apm install without --yes, which match the current CLI.

Trade-offs

  • Skeleton inside markdown instead of a .py file: avoids an extra collected test and lint surface inside the skill tree, at the cost of not being collected by CI. Mitigated by the extract-and-run validation above.
  • SKILL.md is 251 lines (target was ~200): the instrument and invariant tables stay inline because every lifecycle task uses them; everything conditional is in references/.
  • The TARGET layout is documented now but marked in progress; the TODAY branch stays authoritative until tests/lifecycle/ exists, so the skill is usable immediately.
  • No contributor docs page change: the approved scope covers the skill and the instructions pointer only.

Benefits

  1. One authoring procedure for every lifecycle test, loaded by pointer from tests.instructions.md.
  2. Every decisive assertion is a state fact (snapshot, bytes, exit code, egress log), not a stdout substring.
  3. Failing-before evidence and a ledger row are required steps, so fixes leave a regression node id in tests/fixtures/lifecycle_bug_ledger.json.
  4. Works on today's harness and switches to tests/lifecycle/ automatically when it lands.

Issue and approved scope

Issue: Fixes #4077

Human scope-approval comment: #4077 (comment)

This PR completes the issue: skill + deployed copy, references, templates, evals, and the pointer in both tests.instructions.md copies. Out of scope (per the record): src/, new tests/lifecycle/ infrastructure, the test-coverage-expert persona (#4078), moving or deleting tests.

Type of change

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

Testing

  • Tested locally
  • All existing tests pass (related subset run locally; full suite in CI)
  • Added tests for new functionality (n/a: no code change; the template was run instead)
Validation commands and results
Check Command Result
Template runs green extract the python block of assets/templates.md to tests/integration/test_zz_template_probe_lifecycle.py; APM_BINARY_PATH="$(uv run which apm)" uv run --extra dev pytest <it> -n 0 -q 1 passed in 2.44s (copy removed)
Template negative control same, with the user file deleted after uninstall 1 failed (FileNotFoundError on the sibling file)
Cited paths and symbols script over every skill file: each tests/, src/, .apm/, .github/ path exists; 30+ symbols (_new_scenario, PolicyScopeWorld, requests_to, apm_engine_command, _EXPECTED_RULE_ID_TEXT, MutationCase, ...) found by grep; markers found in pyproject.toml 47 paths checked; only the eval's hypothetical file and the TARGET-only quality gate are absent, both intended
CLI commands in templates apm approve/deny/install/update/pack --help replay row uses existing flags only; apm pack exit codes 3/4/5 confirmed
Template lint uv run --extra dev ruff check <copy> && uv run --extra dev ruff format --check <copy> All checks passed! / 1 file already formatted
Deploy parity uv run apm install then diff -r .apm/skills/apm-lifecycle-tests .agents/skills/apm-lifecycle-tests no differences
Managed-tree audit (CI step) uv run --frozen apm audit --ci All 11 check(s) passed (drift: no drift detected)
Instructions parity cmp .apm/instructions/tests.instructions.md .github/instructions/tests.instructions.md identical
Skill limits SKILL.md line count; frontmatter description length; name regex 251 lines; 855 chars; apm-lifecycle-tests valid and equals dir name
ASCII isascii() over every new file and the added instruction lines all ASCII (the instructions file already contained non-ASCII on main; added lines are ASCII)
Eval data json.load on both eval files parse OK; trigger 10/10 (train 6+6, val 4+4); content 3
Related tests uv run --extra dev pytest tests/quality tests/unit/test_project_licensing.py tests/unit/scripts/test_architecture_registry_conflicts.py -q 242 passed, 1 failed; the failure was a temp-repo git commit blocked by this host's injected signing config. Rerun with the host GIT_CONFIG_* variables unset: 2 passed
Python lint chain n/a no .py files changed

Scenario evidence

Scenario Evidence Principle
A contributor writes a lifecycle test on today's harness and gets a state-checking test Template run above: install, I1/I2 checks, user-owned sibling skill preserved across apm uninstall, audit --ci passes DevX
The deployed skill matches its source and the managed tree stays clean diff -r clean; apm audit --ci 11/11 Governed by policy

How to test

  • uv run apm install && diff -r .apm/skills/apm-lifecycle-tests .agents/skills/apm-lifecycle-tests
  • uv run --frozen apm audit --ci passes.
  • Copy the python block from assets/templates.md to tests/integration/test_tmp_lifecycle.py, run APM_BINARY_PATH="$(uv run which apm)" uv run --extra dev pytest tests/integration/test_tmp_lifecycle.py -n 0 -q, then delete the copy.
  • Ask an agent to "add an e2e test that uninstall keeps a user file next to a deployed skill" and check that it follows Steps 0-9 and returns the report block.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md.
  • N/A -- internal-only change (maintainer skill and test instructions).

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Co-authored-by: Copilot [email protected]

Add the repo-local apm-lifecycle-tests skill under .apm/skills and its
deployed copy under .agents/skills. The skill guides authors from a
named promise to an installed-CLI test with before/after snapshots,
the I1-I9 cross-cutting oracles, a failing-before run and a bug-ledger
row. References cover today's harness map and the target
tests/lifecycle layout, oracle checks, and migrate/merge rules.
Templates: a pytest skeleton for today's harness (validated green
against the in-tree CLI), a replay row and a ledger row. Evals: 3
content and 20 trigger cases.

Point tests.instructions.md (both byte-identical copies) at the skill.
The lockfile diff only adds the new deployment rows and the updated
instruction hash.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…raft (#4077)

Fold the approved base draft into the skill while keeping the Step 0-9
structure and every verified path:

- SKILL.md: promise, cell factor tuple and owner in Step 1; search-first
  and extend-over-add in Step 2; instrument table split into today and
  target columns so machine and catalog names only apply when
  tests/lifecycle exists; PR evidence row output.
- references: family.md TODAY table re-verified (kits, proxies,
  fixtures, markers); oracles.md strength ladder, anti-oracles,
  negative control; migrate-and-merge.md equal-copy checklist.
- assets/templates.md replaces the three template files: runnable
  pytest skeleton (green against the in-tree CLI, negative control
  fails), replay row with CLI-verified commands, ledger row.
- evals: approved content and trigger evals.

Co-authored-by: copilot-swe-agent[bot] <[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 review identified an incorrect locator-resolution recipe for user-scope and native deployments and an overly broad state-preservation rule that rejects supported partial failures.

1 open issue
What changed in this PR

Adds the repo-local apm-lifecycle-tests authoring skill for #4077, giving contributors a shared procedure for testing real CLI command sequences and durable state. It covers the current integration harness and documents the planned lifecycle test family without adding runtime infrastructure.

Changes:

  • Defines promise-based test authoring, state assertions, failing-before evidence, and regression-ledger recording.
  • Adds harness references, migration guidance, templates, and trigger/content evaluations.
  • Deploys the skill, adds test-instruction pointers, and records deployment hashes.
File Description
apm.lock.yaml Records skill deployments and updated instruction hashes.
.github/​instructions/​tests.instructions.md Adds the deployed authoring-skill pointer.
.apm/​skills/​apm-lifecycle-tests/​SKILL.md Defines the lifecycle test authoring procedure.
.apm/​skills/​apm-lifecycle-tests/​references/​oracles.md Describes state assertions and evidence requirements.
.apm/​skills/​apm-lifecycle-tests/​references/​migrate-and-merge.md Defines migration and consolidation safeguards.
.apm/​skills/​apm-lifecycle-tests/​references/​family.md Maps current helpers and the planned test layout.
.apm/​skills/​apm-lifecycle-tests/​evals/​trigger-evals.json Adds 20 skill-selection evaluation cases.
.apm/​skills/​apm-lifecycle-tests/​evals/​README.md Documents evaluation scoring and ship gates.
.apm/​skills/​apm-lifecycle-tests/​evals/​content-evals.json Adds three authoring and scope-evaluation scenarios.
.apm/​skills/​apm-lifecycle-tests/​assets/​templates/​test_lifecycle_promise.py.txt Provides a non-collected pytest starter.
.apm/​skills/​apm-lifecycle-tests/​assets/​templates/​replay-row.yaml Provides a planned-family replay template.
.apm/​skills/​apm-lifecycle-tests/​assets/​templates/​ledger-row.json Provides a regression-ledger entry template.
.apm/​instructions/​tests.instructions.md Adds the source authoring-skill pointer.
.agents/​skills/​apm-lifecycle-tests/​SKILL.md Deploys the authoring procedure.
.agents/​skills/​apm-lifecycle-tests/​references/​oracles.md Deploys assertion and evidence guidance.
.agents/​skills/​apm-lifecycle-tests/​references/​migrate-and-merge.md Deploys migration safeguards.
.agents/​skills/​apm-lifecycle-tests/​references/​family.md Deploys the harness and family map.
.agents/​skills/​apm-lifecycle-tests/​evals/​trigger-evals.json Deploys skill-selection evaluation cases.
.agents/​skills/​apm-lifecycle-tests/​evals/​README.md Deploys evaluation instructions.
.agents/​skills/​apm-lifecycle-tests/​evals/​content-evals.json Deploys content-evaluation scenarios.
.agents/​skills/​apm-lifecycle-tests/​assets/​templates/​test_lifecycle_promise.py.txt Deploys the pytest starter.
.agents/​skills/​apm-lifecycle-tests/​assets/​templates/​replay-row.yaml Deploys the replay template.
.agents/​skills/​apm-lifecycle-tests/​assets/​templates/​ledger-row.json Deploys the ledger-entry template.

Review effort: Balanced

…arget branch (#4077)

- evals/README.md: trigger evals run blind (train 6/6 and 0/6,
  validation 4/4 and 0/4; gate passes) and content evals C1 and C3
  with and without the skill, scored per item with a delta verdict.
- Target-family branch (only when tests/lifecycle is present): commands
  go through driver.run; replay rows live in
  tests/lifecycle/replay/rows and are run by rows.py (RowReplay); promise
  ids resolve as P-INV-I1..I9 and P-LAW-<ledger property id> until a
  catalog exists; the row template matches the row schema (run/exit and
  pair steps); the oracle note states the current family's oracle
  strength; model, oracles, receipts and obligations modules are named.
  Machines, scenarios, security tables and journeys are marked planned.
  The today-harness branch is unchanged.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 185c2cd into main Nov 20, 2026
29 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-redesigned-doodle branch November 20, 2026 08:40
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.

[FEATURE] Lifecycle test authoring skill (apm-lifecycle-tests)

2 participants