Repository navigation
test(quality): per-test AST duplicate gate, taxonomy placement and promise-link ratchets - #4146
Merged
Daniel Meppiel (danielmeppiel) merged 17 commits intoNov 20, 2026
Merged
Conversation
…omise-link ratchets Part of #4028. 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]>
…new debt 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]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 20, 2026 08:39
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The duplicate and taxonomy gates still permit allowance growth and miss process-spawning imports, leaving enforcement gaps that need fixes and regression coverage.
4 open issues
What changed in this PR
This PR strengthens APM's test-quality gates as part of #4028, detecting per-test duplication and preventing new classification, placement, and promise-link debt without rewriting existing tests.
Changes:
- Replaces whole-file duplicate detection with normalized AST body hashes and cross-file
Class::namechecks. - Adds taxonomy and promise-link checks, with informational handling of stale or moved allowances.
- Updates regression coverage, contributor guidance, and marker registration.
| File | Description |
|---|---|
tests/unit/scripts/test_check_exact_test_duplicates.py |
Tests duplicate detection and baseline lifecycle behavior. |
tests/quality/test_test_taxonomy.py |
Adds taxonomy and promise-link checks with seeded controls. |
tests/quality/test_quality_baselines.py |
Adapts baseline contracts to the new duplicate format. |
tests/quality/taxonomy_inventory_plugin.py |
Collects promise IDs and detects process-spawning calls. |
tests/quality/promise-catalog.json |
Seeds recognized specification and architecture-owner promises. |
scripts/test_body_hash.py |
Provides shared per-test AST hashing. |
scripts/check_exact_test_duplicates.py |
Implements per-test duplicate checks and baseline rekeying. |
pyproject.toml |
Registers the promise marker. |
docs/src/content/docs/contributing/integration-testing.md |
Explains the new test-corpus checks. |
CHANGELOG.md |
Records the internal test-quality changes. |
.github/instructions/tests.instructions.md |
Updates contributor instructions for the checks. |
.apm/instructions/tests.instructions.md |
Mirrors the test-corpus guidance in APM instructions. |
Review effort: Balanced
Adds P-INV-I1..I9 and P-LAW-<id> for every lifecycle law, renames owner:<id> to P-OWN-<id>, rejects unknown prefixes and undeclared families, and fails when a lifecycle law has no P-LAW id. Pre-seeds an in-flight allowance for #4143. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
5 of 10 tasks
Co-authored-by: Copilot App <[email protected]>
Merged
6 of 14 tasks
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
- duplicate gate: only absent baselined tests can be a move source - spawn detection: aliases resolve per lexical scope; asyncio.subprocess create_subprocess_exec/_shell count as spawning - taxonomy allowances: shrink-only against the PR base revision (scripts/check_taxonomy_allowances.py, wired into the Lint job), with validated move re-keys as the only accepted additions - baseline modules that landed on main Part of #4028 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…d on main The module reached main after the promise-link allowances were seeded, so tm006 flags it as a new promise-less module. Record it as an existing module. Co-authored-by: Copilot App <[email protected]>
6 of 10 tasks
Resolve the self-deployed tests instruction hash in apm.lock.yaml to the merged file content. Co-authored-by: Copilot App <[email protected]>
Modules and one same-body pair landed on main after the ratchet baselines were seeded. Record them as existing debt so the ratchets fail only on new growth; their owners add promise and taxonomy markers in follow-ups. Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-refactored-garbanzo
branch
November 20, 2026 13:09
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
…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]>
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. The test-duplicate gate hashed whole files, so it found 0 of the corpus's same-body tests. It now hashes each test's normalized AST body (
ast-body-v1) and also flags aClass::namereused across files. The taxonomy contract gains three no-growth ratchets: unclassified modules, misplaced modules, and new modules without apytest.mark.promiselink. All ratchets record today's debt, fail only on new debt with a[x] <file>: ... Fix: ...line, and report stale or moved entries as[i]without failing. No existing test is deleted, moved or rewritten.Measured on main (
1b96706):ast-body-v1same-body groupsClass::namecollisionspytestmark)unitmodules undertests/integrationtests/unitmodules that spawn processesWhat changed
scripts/test_body_hash.py(new)ast-body-v1hashing.TestFunctionkeeps the function and class AST nodes, so the follow-up equal-copy report can add the stricter decorator, fixture and class-context checks.scripts/check_exact_test_duplicates.pyClass::namereuses. A test outside the baseline that becomes a duplicate fails. A lockstep edit of a baselined pair does not fail. A baselined test moved to another file under the same name is re-keyed.--update-baselineonly prunes or re-keys.tests/quality/exact_test_duplicates.jsonalgorithm_docdocuments the algorithm and its limitation: the hash ignores decorators, parametrize values, fixtures, class context and module bindings.tests/quality/taxonomy_inventory_plugin.pysubprocess,os.exec*/spawn*/system,asynciosubprocess,pexpect).tests/quality/test_test_taxonomy.pytm006and catalog rulestm011, plus negative controlstm007-tm010andtm012(unknown prefix, undeclared family, missingP-LAW). They collect a seeded tmp tree with one violation per ratchet, a moved module, a removed entry and a compliant module.tests/quality/test_taxonomy_baseline.json(new)unclassified_modules,misplaced_modules,promise_exempt_modules(every module present today).tests/quality/promise-catalog.json(new)familieslist declares the id families, and an id with an unknown prefix or an undeclared family fails. 307 ids: 148 specreq-*(as inCONFORMANCE.json), 139P-OWN-<owner id>,P-INV-I1..I9, and 11P-LAW-<id>. Drift testtm011keepsP-LAWids equal to the lifecycle ledger'sproperty_catalog.pyproject.tomlpromisemarker.tests/quality/test_quality_baselines.py,tests/unit/scripts/test_check_exact_test_duplicates.pyClass::namereuse, third copy, lockstep edit, move re-key, stale info/prune, malformed baselines.integration-testing.md,tests.instructions.mdx2)Touched architecture owner:
behavioral-test-taxonomy-classification(.apm/architecture/owners/core-runtime.json). Thegetattr(module, "pytestmark"mutation anchor in the plugin is still unique.Trade-offs
--update-baselinefor duplicates; by hand for taxonomy).promise_exempt_modules.In-flight allowances (prune after these land)
These modules or tests are added or changed by open 0.37 PRs. They are pre-seeded so those PRs need no change. Before their PRs land, the entries are reported as stale, never as failures.
Allowances by PR
tests/integration/test_file_primitive_receipt_lifecycle.pytests/spec_conformance/test_cowork_deployed_hash_reqs.pytests/integration/test_file_primitive_receipt_lifecycle.pytests/spec_conformance/test_cowork_deployed_hash_reqs.pytests/spec_conformance/test_exec_decision_reqs.pytests/unit/install/test_exec_decision_equivalence.pytests/spec_conformance/test_exec_decision_reqs.pytests/unit/install/test_exec_decision_equivalence.pytests/integration/test_cleanup_deployment_evidence_lifecycle.pytests/spec_conformance/test_deletion_evidence_reqs.pytests/integration/test_cleanup_deployment_evidence_lifecycle.pytests/spec_conformance/test_deletion_evidence_reqs.pytests/integration/test_architecture_owner_rule_mutations.py::test_deploy_path_allow_map_comes_from_the_trust_ownertests/integration/test_architecture_owner_rule_mutations.py::test_trust_owner_reads_the_scope_manifest_closed_worldtests/integration/test_pinned_hook_policy_deny_lifecycle.pytests/integration/test_pinned_hook_policy_deny_lifecycle.pytests/integration/test_uninstall_lsp_without_mcp_lifecycle.pytests/unit/install/test_partial_subtree_reconciliation.pytests/integration/test_bin_canvas_deny_diagnostics_lifecycle.pytests/integration/test_bin_canvas_deny_diagnostics_lifecycle.pytests/integration/test_frozen_stale_exec_status_lifecycle.pytests/integration/test_frozen_stale_exec_status_lifecycle.pytests/integration/test_uninstall_lsp_recorded_targets_lifecycle.pytests/integration/test_remediation_advice_lifecycle.pytests/integration/test_policy_install_enforcement_lifecycle.pytests/unit/core/test_token_manager_purpose_env_var.pytests/unit/core/test_token_manager_purpose_env_var.pytests/integration/test_install_commit_order_lifecycle.pytests/integration/test_install_commit_order_lifecycle.pytests/integration/test_command_output_owner_e2e.pytests/lifecycle/test_core_example.pytests/quality/test_promise_obligations.pytests/lifecycle/test_core_example.pytests/quality/test_promise_obligations.pyIssue and approved scope
Issue: Refs #4028 (Part of #4028; follow-up C-1b adds the equal-copy report, AQ003/AQ004 and the e2e-drive ratchet).
Human scope-approval comment: #4028 (comment) (plus the amendment recorded on the issue).
Remaining after this PR: the C-1b items above.
Type of change
Testing
Validation evidence (merged with current main)
tests/unit/scripts/test_architecture_registry_conflicts.pyfails locally only because commit signing is enforced in this environment. It is unrelated, and it also fails on main here.How to test
uv run --frozen python scripts/check_exact_test_duplicates.pyshould be clean.[x] <file>: test <name> duplicates the body ... Fix: ....tests/unit/test_tmp.pywithout apytestmark, then runuv run --extra dev pytest -q tests/quality/test_test_taxonomy.py -k tm006. It fails, naming the file as unclassified and promise-less.Changelog
## [Unreleased]inCHANGELOG.md(internal, per the approved scope).Spec conformance (OpenAPM v0.1)
Temporary in-flight allowances (approved; shrink after #4142 lands)
These modules and one duplicate pair landed on main after the baselines were seeded. They are recorded as existing debt and are removed as their owners add markers or differentiate the tests.
tests/integration/test_config_credential_rendering_lifecycle.py-- new test module carries no pytest.mark.promisetests/integration/test_policy_outcome_routing_lifecycle.py-- new test module carries no pytest.mark.promisetests/integration/test_registry_archive_limits_lifecycle.py-- new test module carries no pytest.mark.promisetests/integration/test_registry_archive_limits_lifecycle.py-- unclassified test moduletests/quality/test_journey_index.py-- new test module carries no pytest.mark.promisetests/quality/test_journey_index.py-- unclassified test moduletests/spec_conformance/test_ext_behavior_reqs.py-- new test module carries no pytest.mark.promisetests/spec_conformance/test_ext_behavior_reqs.py-- unclassified test moduletests/spec_conformance/test_lockfile_behavior_reqs.py-- new test module carries no pytest.mark.promisetests/spec_conformance/test_lockfile_behavior_reqs.py-- unclassified test moduletests/spec_conformance/test_lockfile_cli_behavior_reqs.py-- new test module carries no pytest.mark.promisetests/spec_conformance/test_manifest_behavior_reqs.py-- new test module carries no pytest.mark.promisetests/spec_conformance/test_manifest_behavior_reqs.py-- unclassified test moduletests/spec_conformance/test_manifest_cli_behavior_reqs.py-- new test module carries no pytest.mark.promisetests/spec_conformance/test_policy_behavior_reqs.py-- new test module carries no pytest.mark.promisetests/spec_conformance/test_policy_behavior_reqs.py-- unclassified test moduletests/spec_conformance/test_resolve_behavior_reqs.py-- new test module carries no pytest.mark.promisetests/spec_conformance/test_resolve_behavior_reqs.py-- unclassified test moduletests/spec_conformance/test_security_behavior_reqs.py-- new test module carries no pytest.mark.promisetests/spec_conformance/test_security_behavior_reqs.py-- unclassified test moduletests/spec_conformance/test_targets_behavior_reqs.py-- new test module carries no pytest.mark.promisetests/spec_conformance/test_targets_behavior_reqs.py-- unclassified test moduletests/unit/utils/test_credential_rendering.py-- new test module carries no pytest.mark.promisetests/unit/utils/test_credential_rendering.py-- unclassified test moduletests/integration/test_git_lock_content_hash_lifecycle.py-- new test module carries no pytest.mark.promisetests/unit/utils/test_credential_rendering.py-- same-body pair:test_query_credentials_in_config_values_are_masked/test_userinfo_inside_equals_form_args_is_removed