Skip to content

test(lifecycle): harness conformance contract and ratchet in the promise engine - #5775

Merged
Daniel Meppiel (danielmeppiel) merged 2 commits into
mainfrom
danielmeppiel-harness-conformance
Dec 2, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 2 commits into
mainfrom
danielmeppiel-harness-conformance

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

This PR adds the harness conformance contract as registry-driven data inside the existing lifecycle promise engine (obligation_space.py, ReceiptWitnessPlugin, generated obligations). It adds no parallel framework. The contract states the promises every harness target owes. Whether a promise applies to a target is a pure function of registry data, so adding or removing a target in KNOWN_TARGETS adds or removes its cells through data alone.

Milestone 0.40.0. This is a precursor to the Pi target (#5771): Pi lands its column at zero baseline on top of this PR.

  • tests/lifecycle/harness_contract.py
    • Defines 39 promises, for example HC-DEPLOY-01.skills, HC-MCP-01 and HC-DOCTOR-01.
    • applies(promise, profile, scope) returns APPLIES, NOT_APPLICABLE (naming the field it read) or UNKNOWN.
    • Each predicate declares the registry fields it reads.
    • Project and user scope are evaluated separately.
    • A promise is live, pending-witness or retired.
  • obligation_space.harness_obligations()
    • Generates one <promise>|<target>|<scope> obligation for each APPLIES cell of a live promise.
    • Those obligations feed the generated space, and obligations.load_generated() reads their required witnesses.
  • tests/quality/harness_conformance.json
  • tests/lifecycle/scenarios/test_harness_conformance.py
    • The first witness: HC-DEPLOY-01.skills at project scope, parametrized only from applicable().
    • It installs a skill per target through the real CLI and checks the deployed path and the lock row.
  • tests/quality/test_harness_conformance.py checks that:
    • every profile field is read by a predicate, or classified as display or identity, or listed as pending a predicate (that list may only shrink);
    • contract code contains no harness-name literal;
    • an UNKNOWN verdict or a missing predicate fails;
    • an exemption is allowed only as a feature gap: the promise has an open feature issue and every applicable cell is baseline;
    • the baseline only shrinks;
    • no committed artifact carries cells of a pending-witness promise;
    • two mutation proofs hold, (a) and (b) below.
  • CI: the new quality module joins the architecture-contract lists in ci.yml and merge-train.yml.
  • Catalog: promise P-COMPAT-harness-conformance is added.

Issue and approved scope

Issue: Refs #3616

Human scope-approval comment: routed through the PGM Pi lead under the 2026-12-02 harness decision; a scope comment on #3616 is pending with the lead.

Does this PR complete the issue, or what remains? It does not complete #3616. What remains:

Type of change

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

Testing

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

Commands run locally, sequentially, with no xdist:

  • pytest tests/lifecycle/scenarios/test_harness_conformance.py tests/quality/test_generated_obligations.py: 40 passed. Receipts were enforced by ReceiptWitnessPlugin.
  • pytest tests/quality/test_harness_conformance.py "tests/quality/test_ci_topology.py::test_test_architecture_ratchets_are_required_in_every_context": 19 passed, 1 skipped. The skip is the shrink-only check, which needs a committed ratchet on main.
  • An earlier batch of test_ci_topology.py, test_quality_baselines.py, test_promise_obligations.py, test_test_taxonomy.py and test_known_cells_cite_open_issues.py returned 874 passed and 5 failed.
    • I fixed the cause of all five: a raw strict xfail, which is now removed, and the new module missing from the CI lists, which are now updated.
    • I re-ran test_known_cells_cite_open_issues.py and both topology checks afterwards, and they pass.
    • I did not re-run the full batch after the fixes.
  • Negative control: with the check_obligation call removed, the [claude] witness fails with "is the witness of 1 required obligation(s) that no oracle receipt covered".
  • Mutation (a): test_deleting_a_witness_turns_its_cell_red passes. Removing the witness function makes its required cell report as unwitnessed.
  • Mutation (b): test_a_target_added_without_cells_fails_the_ratchet passes. A cloned KNOWN_TARGETS entry with no ratchet rows is refused.
  • Lint: the ruff check and ruff format --check CI mirror at 0.15.12, pylint R0801, lint-auth-signals.sh, check_complexity_ratchet.py --base-ref origin/main, check_test_assertions.py, check_exact_test_duplicates.py and python -m tests.quality.taxonomy --changed are all clean.

Changelog

  • One fragment per section, changelog.d/<pr>.<section>.md, holding
    one line: user-visible effect first, 25 words or fewer, ending with
    (#PR); breaking changes only under upgrade notes; no Highlights; no
    new lines under ## [Unreleased]. See changelog.d/README.md and
    .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.

Agent assessment

  • Change confidence: medium-high. The change is test-only and additive to the existing promise engine. I ran the witness module, the new quality module and the engine's own tests, but not the full suite. The main risk is CI topology or lane checks that I didn't run locally.

…ise engine

Add the harness conformance contract (#3616) as registry-driven data inside
the existing promise engine, with no parallel framework:

- tests/lifecycle/harness_contract.py: the promises every harness target is
  measured against, each with a predicate that declares the registry fields
  it reads; applies(promise, profile, scope) returns APPLIES,
  NOT_APPLICABLE (naming the field) or UNKNOWN; project and user scope are
  evaluated separately; promise status is live, pending-witness or retired.
- obligation_space.harness_obligations(): one "<promise>|<target>|<scope>"
  obligation per APPLIES cell of a live promise, fed into the generated space;
  obligations.load_generated() reads their required witnesses.
- tests/quality/harness_conformance.json: shrink-only ratchet generated at
  base 62329d6 (15 required, 675 baseline). Required cells name lifecycle
  witnesses whose OBLIGATION receipts ReceiptWitnessPlugin enforces; unit and
  static witnesses do not count. HC-DOCTOR-01 is a feature gap owned by #3297.
- tests/lifecycle/scenarios/test_harness_conformance.py: the first witness,
  HC-DEPLOY-01.skills at project scope, parametrized only from applicable().
- tests/quality/test_harness_conformance.py: field-coverage guard (fields are
  irrelevant only for display or identity), harness-literal guard over the
  contract code, UNKNOWN or missing predicate fails, exemption rule (feature
  gap allowed, single-harness gap refused), baseline only shrinks, no
  committed artifact carries cells of a pending-witness promise, and two
  mutation proofs: deleting a witness turns its cell red, and a target added
  to KNOWN_TARGETS without cells fails.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ot base_sha

The shrink-only check now resolves its comparison base from the branch the
change applies to, never from the ratchet's own editable base_sha:

- In CI it fetches the pull request base branch tip explicitly
  (GITHUB_BASE_REF), or the first parent of HEAD for merge queue and push
  commits; an unreachable base fails instead of skipping.
- Outside CI it uses the merge base with origin/main.
- The only skip is a base commit without the ratchet file (the change that
  adds it) or a local clone without origin/main.
- New cells: growth stays refused when base_sha is re-pointed, and an
  unreachable base raises under CI.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@danielmeppiel
Daniel Meppiel (danielmeppiel) marked this pull request as ready for review December 2, 2026 14:20
Copilot AI balanced review requested due to automatic review settings December 2, 2026 14:20

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

Witness validation ignores parameter suffixes, allowing nonexistent pytest cases to satisfy required cells without receipt enforcement.

6 open issues
What changed in this PR

Adds registry-driven harness conformance checks to the existing lifecycle promise engine, supporting #3616 and preparing for the Pi target.

Changes:

  • Defines harness promises and generates target/scope obligations.
  • Adds a shrink-only baseline and receipt-backed skill deployment witnesses.
  • Integrates conformance checks into CI and merge-train gates.
File Description
tests/​quality/​test_harness_conformance.py Adds contract validation and mutation checks.
tests/​quality/​promise-catalog.json Registers the conformance promise.
tests/​quality/​harness_conformance.json Records required witnesses and baseline gaps.
tests/​lifecycle/​scenarios/​test_harness_conformance.py Adds parametrized skill deployment witnesses.
tests/​lifecycle/​obligations.py Loads required harness witnesses.
tests/​lifecycle/​obligation_space.py Includes generated harness obligations.
tests/​lifecycle/​harness_ratchet.py Implements ratchet validation and regeneration.
tests/​lifecycle/​harness_contract.py Defines promises and registry-based applicability.
.github/​workflows/​merge-train.yml Runs conformance checks on merge trains.
.github/​workflows/​ci.yml Runs conformance checks in CI.

Review effort: Balanced

names: dict[str, frozenset[str]] = {}
for key, node in sorted(ratchet.required.items()):
path, _, test = node.partition("::")
function = test.split("[", 1)[0]
def packs(profile: Any, scope: str) -> Result:
if scope != PROJECT:
return _na("pack is project-scope")
return _OK if profile.pack_prefixes else _na("pack_prefixes is empty")

@predicate(REGISTRY_NATIVE_PLUGIN_HARNESS)
def native_plugin_harness(profile: Any, scope: str) -> Result:
return _OK if _native_plugin_harness(profile) else _na("not a native plugin harness")
Comment on lines +77 to +78
elif not harness_contract.exemption_allowed(promise_id, ratchet.baseline, cells):
problems.append(f"{promise_id}: exempt only when every applicable cell is baseline")
Comment on lines +150 to +154
# A merge queue or push commit: its first parent is the base.
head = _git(root, "rev-parse", "HEAD").stdout.strip()
step = _git(root, "fetch", "--no-tags", "--depth=2", "origin", head) if head else None
resolved = (
_git(root, "rev-parse", "--verify", "HEAD^1") if step and step.returncode == 0 else step

def test_predicate_pending_fields_only_shrink() -> None:
# Pinned: a field leaves this set when a predicate reads it; none may join.
assert set(contract.PREDICATE_PENDING_FIELDS) <= {
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Dec 2, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 37fdcb3 into main Dec 2, 2026
57 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-harness-conformance branch December 2, 2026 19:28
Daniel Meppiel (danielmeppiel) added a commit to mohitmishra786/apm that referenced this pull request Dec 2, 2026
…soft#4593)

Gemini now carries the agents primitive, so the harness conformance
contract (microsoft#5775) generates HC-DEPLOY-01.agents cells for it at project
and user scope. Add the lifecycle witness that installs a local agent
package per required cell, checks the native path, frontmatter and lock
row, and emits the OBLIGATION receipt; list both cells as required in
the ratchet.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Dec 2, 2026
Restacked as one commit onto main 4e733b0 (#5775, #5778, #5743 and #5784
landed). This is the net Pi delta of danielmeppiel-pi-target at 0871e7d7 over
the stack it carried, applied with no conflicts:

- the pi target (registry profile, catalog capability, .pi detection, skills
  in .agents/skills, commands in .pi/prompts, PI_CODING_AGENT_DIR user root,
  read verbatim), trust hint, init picker from the registry, unsupported
  primitive warning once, governance_dirs for unmanaged_files;
- project cleanup removes only roots that do not signal their target, and only
  roots that do are created before a write (materializes_root); an auto_create
  target's merged hook config is created with its root;
- the trust hint also fires for project-only .apm content;
- harness conformance: Pi cells all required (zero baseline), HC-PLUGIN-01
  .dryrun promoted (26 rows formerly #5781) with an exact-line oracle;
  main's required cells kept (the carried ratchet had them in baseline),
  known_failing merged into the promise engine, PI_CODING_AGENT_DIR scrubbed
  in tests/conftest.py, Pi journey variants, Pi receipts;
- real-harness Pi 1.6.0 lane with the cross-spawn and minimatch overrides.

apm-spec-waiver: adds the pi target as registry data on the shared target layer; no change to an OpenAPM v0.1 requirement
apm-spec-waiver: policy default scan dirs now come from registry data; the existing list is byte-identical and pi adds .pi

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Dec 2, 2026
Restacked as one commit onto main 4e733b0 (#5775, #5778, #5743 and #5784
landed). This is the net Pi delta of danielmeppiel-pi-target at 0871e7d7 over
the stack it carried, applied with no conflicts:

- the pi target (registry profile, catalog capability, .pi detection, skills
  in .agents/skills, commands in .pi/prompts, PI_CODING_AGENT_DIR user root,
  read verbatim), trust hint, init picker from the registry, unsupported
  primitive warning once, governance_dirs for unmanaged_files;
- project cleanup removes only roots that do not signal their target, and only
  roots that do are created before a write (materializes_root); an auto_create
  target's merged hook config is created with its root;
- the trust hint also fires for project-only .apm content;
- harness conformance: Pi cells all required (zero baseline), HC-PLUGIN-01
  .dryrun promoted (26 rows formerly #5781) with an exact-line oracle;
  main's required cells kept (the carried ratchet had them in baseline),
  known_failing merged into the promise engine, PI_CODING_AGENT_DIR scrubbed
  in tests/conftest.py, Pi journey variants, Pi receipts;
- real-harness Pi 1.6.0 lane with the cross-spawn and minimatch overrides.

apm-spec-waiver: adds the pi target as registry data on the shared target layer; no change to an OpenAPM v0.1 requirement
apm-spec-waiver: policy default scan dirs now come from registry data; the existing list is byte-identical and pi adds .pi

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Dec 3, 2026
Restacked as one commit onto main 4e733b0 (#5775, #5778, #5743 and #5784
landed). This is the net Pi delta of danielmeppiel-pi-target at 0871e7d7 over
the stack it carried, applied with no conflicts:

- the pi target (registry profile, catalog capability, .pi detection, skills
  in .agents/skills, commands in .pi/prompts, PI_CODING_AGENT_DIR user root,
  read verbatim), trust hint, init picker from the registry, unsupported
  primitive warning once, governance_dirs for unmanaged_files;
- project cleanup removes only roots that do not signal their target, and only
  roots that do are created before a write (materializes_root); an auto_create
  target's merged hook config is created with its root;
- the trust hint also fires for project-only .apm content;
- harness conformance: Pi cells all required (zero baseline), HC-PLUGIN-01
  .dryrun promoted (26 rows formerly #5781) with an exact-line oracle;
  main's required cells kept (the carried ratchet had them in baseline),
  known_failing merged into the promise engine, PI_CODING_AGENT_DIR scrubbed
  in tests/conftest.py, Pi journey variants, Pi receipts;
- real-harness Pi 1.6.0 lane with the cross-spawn and minimatch overrides.

apm-spec-waiver: adds the pi target as registry data on the shared target layer; no change to an OpenAPM v0.1 requirement
apm-spec-waiver: policy default scan dirs now come from registry data; the existing list is byte-identical and pi adds .pi

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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