Skip to content

docs(cli): docs/TESTING.md holds the test conventions, ADR 0005 records that tests double only process edges, and AGENTS.md and the contributor docs point to them #1308

Closed

Description

@dan-petty

Problem

The owner settled the test design on 2026-10-07 (#1307). Its vocabulary is drafted in docs/TESTING.md and its decision in docs/adr/0005-tests-double-only-process-edges.md, both untracked on release/v0.2.28. The rules agents and contributors read today are scattered copies, and several contradict the decisions:

  • AGENTS.md states test rules in six places:
    • the tuple-assert mandate [code: AGENTS.md:15-16]. Its premise is false: ruff C901 does not count asserts, and a function of 15 linear asserts scores 1 [measured: ruff check --select C901, 2026-10-07];
    • "tests ... with structural tuple equality assertions" [code: AGENTS.md:103];
    • one test file per submodule (tests/test_<submodule>.py or tests/<submodule>/test_<feature>.py), with the work-named tests/test_consolidation_dry_run_decorator.py given as a canonical file [code: AGENTS.md:158-161];
    • isolation "using mocks (unittest.mock, pytest-mock)" [code: AGENTS.md:434];
    • provider protocols under providers/ with mock implementations [code: AGENTS.md:444], although the legacy ai/providers/{anthropic,openai,ollama,copilot}.py layer has no production caller;
    • test helpers in src/devops_cli that declare __test__ = False [code: AGENTS.md:446], although fakes are not to ship in the wheel.
  • Other copies:
    • docs/SDLC.md "Test Architecture & Standards", with pytest-mock isolation and __test__ = False [code: docs/SDLC.md:103-107];
    • CONTRIBUTING.md's tests/test_<feature>.py [code: CONTRIBUTING.md:45-49];
    • docs/ROUTINE_TASKS.md's "Create or update tests/test_<feature>.py ... and mocks" [code: docs/ROUTINE_TASKS.md:114];
    • .devops/review.md's tuple-comparison exemption [code: .devops/review.md:91-92];
    • docs/SELF_IMPROVEMENT.md's headroom step that turns linear asserts into tuples, and its flat canonical test files [code: docs/SELF_IMPROVEMENT.md:211-214, :577];
    • the shipped knowledge base's "All test modules must be named tests/test_<feature>.py" [code: src/devops_cli/ai/knowledge_base/it_domains/tools/ruff_mypy_pytest.md:90].
  • The AGENTS.md generator carries none of these rules. generate_agents_md [code: ai/instruction_generator.py:163] has no tuple mandate and no test-layout rule at 5c45b1e. Its only test guidance is the build-command block and the test-first remediation steps.

Acceptance criteria

docs/TESTING.md

  • It keeps the drafted vocabulary and adds a Conventions section, written in those terms, that states every decision of 2026-10-07 recorded in test(cli): tests double only process edges and mirror the source tree #1307 as a rule. Its headings:
    • Doubles: the faked and real edges, one seam per edge, fakes in tests/support/fakes/<edge>.py, a contract suite for every fake, stdlib patching as a fallback for stdlib edges only, and no patching of devops-cli and no imports of its private names.
    • Layout: the mirror at full depth with a conftest.py per package; one file per behaviour, named after it (tests/roadmap/test_descoping.py); tests/invariants/ as the only place for test files outside the mirror, one file per subject (test_source_tree.py, test_agents_md.py, …); and tests/support/ for fakes, builders and shared fixtures.
    • Names and assertions: behaviour in CONTEXT.md glossary terms (test_stalled_item_is_treated_as_not_started); whole-value comparisons, with tuple equality only to pick fields out of objects with noisy fields.
    • CLI tests (the cli fixture; parsing, wiring, output and exit code only; domain rules tested once, through the domain package) and Config (the config fixture; no patching of load_settings, CONFIG_PATH or get_settings).
    • Test data: builders named after glossary terms, in tests/support/builders.py; syrupy snapshots only where the whole text is the contract, updated with --snapshot-file-lock and the reason (syrupy issue 1237: an update under xdist loses data).
    • Property tests, Clock (time-machine and the libraries' own sleep and clock parameters, no freezegun) and Coverage (unreachable lines are deleted; the 90% gate stays).
    • Floor and ratchets, and Until the migration ends: which mechanisms exist yet. A new test follows the conventions wherever they exist, and the ratchets stop it from adding internal patches or private imports.

ADR

Pointers

Key questions

Strategic alignment

Activity

  1. added
    type/docs
    scope/cli
    priority/p2-medium
    scope/docs
    on Oct 7, 2026
  2. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Linked: #841, which cuts AGENTS.md to a budget with a mapping table; the test rules this item moves count toward it. Found by the 2026-10-08 backlog review.

  3. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Priority: P2-Medium. Scattered and contradictory test rules mislead agents and contributors but do not block a release or break functionality.
    • Value: Medium. Consistent, single-source test conventions reduce agent errors and contributor confusion across the project.
    • Effort: Medium. Requires writing a new Conventions section in docs/TESTING.md and editing at least seven existing files to remove or redirect contradictory rules.
  4. added
    priority/p0-critical
    and removed
    priority/p2-medium
    on Oct 18, 2026
  5. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Closed as a duplicate of #851: The candidate overlaps significantly with issue #851 which also addresses the tuple-assert mandate in test conventions, making it a duplicate.

    If it is not a duplicate, reopen it: intake then places it without the duplicate check.

  6. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Reopened: this is not a duplicate of #851. Intake closed it on 2026-10-18 with the reason "overlaps significantly with issue #851 which also addresses the tuple-assert mandate in test conventions". #851 retires one convention (the tuple-assert mandate) and adds detectors. This item writes docs/TESTING.md, records ADR 0005 (tests double only process edges), and points AGENTS.md and the contributor docs at them.
    It is P0 under the owner's blocker rule: #983's last pull request waits on it, with #1312. A read-only --plan an hour earlier placed it normally, so the duplicate verdict is the model's call, not a settled finding. That intake can close a person-planned item as a duplicate is drafted as an intake defect.

  7. added this to the v0.2.37 milestone on Oct 19, 2026
  8. added
    status/in-progress
    on Oct 19, 2026
  9. added a commit that references this issue on Oct 19, 2026
    5ab8a1e
  10. dan-petty commented on Oct 19, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1694, merged into release/v0.2.37 as 5ab8a1e.

    docs/TESTING.md becomes the one place for the test conventions. ADR 0007 records that tests double only process edges. AGENTS.md and the contributor docs link TESTING.md instead of restating test rules.

    docs/TESTING.md.

    • Vocabulary: a glossary of the testing terms, each with the words to avoid.
    • The owner's conventions of 2026-10-07:
      • tests double only process edges, each through one seam and one shared fake with a contract suite;
      • no test starts a real gh;
      • tests find the repository root and their data through tests.support.paths;
      • tests/ is to mirror src/devops_cli;
      • a test is named after its behaviour and compares whole values;
      • no test asserts on elapsed wall-clock time.
    • What later items deliver is marked (target). "Until the migration ends" says what exists today and what a new test does meanwhile.
    • Which tests a narrowed run selects describes feat(test): devops test and devops ci test choose tests through one selector, and a change that reaches every test runs the suite #1693's selector as merged: name at any depth and import, the coverage index in place of name matching for the modules it holds, the full-run triggers, and what the commit hook passes.

    ADR 0007. It takes the number 0007 because 0005 and 0006 were taken after the 2026-10-07 draft.

    Pointers.

    • Linked documents: AGENTS.md, CONTRIBUTING.md, RELEASE_CYCLE.md, docs/SDLC.md, docs/ROUTINE_TASKS.md, docs/SELF_IMPROVEMENT.md, .devops/review.md and three knowledge base articles now link TESTING.md.
    • AGENTS.md drops the tuple-assert mandate, the one-test-fil…

    16 file(s) changed.

    How it was verified

    Check runs at 16bbbac:

    • Prune PR DevContainer Images: pass
    • Audit Defect PR Hardening: skipping
    • Analyze (python): pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping
    • zizmor: pass
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Fail-to-Pass Check: pass
    • Changed-Test Independence: pass
    • Rule Pack Tests: pass
    • Fail-to-Pass Self-Check: pass
    • Tests & Coverage: pass
    • Analyze (actions): pass
    • Static Analysis: pass

    Acceptance Criteria of docs/agent/tasks/task-1308-test-conventions.md:

    • docs/TESTING.md keeps the drafted vocabulary and states every decision of 2026-10-07 as a convention, marks what later items deliver as (target), and marks none of tests/support/, the shared paths or feat(test): devops test and devops ci test choose tests through one selector, and a change that reaches every test runs the suite #1693's selection rules, which exist.
    • ADR 0007 is committed under the next free number, and every relative link in TESTING.md, the ADR and the ten documents that point to TESTING.md resolves, its #fragment included (tests/test_agents_md_claims.py::test_every_relative_link_in_the_test_conventions_and_their_pointers_resolves, which fails at the base on AGENTS.md's link to the missing docs/TESTING.md).
    • AGENTS.md and the nine other documents each link docs/TESTING.md (test_every_document_that_stated_test_rules_links_testing_md), and a negative control pins the link check, a link to a heading with letters outside ASCII included (test_a_link_to_a_missing_file_or_heading_is_broken).
    • The claims tests/test_agents_md_claims.py already made hold on the new tree: the issue templates AGENTS.md names exist, the personas in docs/SELF_IMPROVEMENT.md are the Persona values, the instruction stubs match the generator, and AGENTS.md stays within its character budget.
    • AGENTS.md drops the tuple mandate, the submodule test-file rule and the mock-isolation rule with __test__ = False.
    • changelog.d/1308.md records the change; CHANGELOG.md and docs/ROADMAP.md are not edited.
  11. added a commit that references this issue on Oct 20, 2026
    954914e
  12. removed
    status/in-progress
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p0-criticalscope/cliscope/docstype/docs

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions