Skip to content

feat(test): coverage gate + golden snapshots + handler/polish error paths (test-strategy pass 1)#23

Merged
silversurfer562 merged 3 commits into
mainfrom
test/coverage-and-gaps-pass-1
May 11, 2026
Merged

feat(test): coverage gate + golden snapshots + handler/polish error paths (test-strategy pass 1)#23
silversurfer562 merged 3 commits into
mainfrom
test/coverage-and-gaps-pass-1

Conversation

@silversurfer562
Copy link
Copy Markdown
Member

Summary

Pass 1 of the test-strategy spec — Layer 4 (attune-author, the AI-assisted authoring layer and reference for the attune family's LLM mocking pattern).

  • 26 new tests across 3 new files; total 788 passing + 32 skipped
  • Coverage: 87.03% → 87.15% (branch coverage; modest because baseline already strong)
  • Gate enforced at `fail_under = 85` (measure-then-lock at baseline-2pp)
  • Golden snapshots for generated concept/task/reference templates — schema drift caught at PR time, not weeks later via the weekly cross-repo workflow
  • CI workflow gains coverage step on the ubuntu × py3.11 cell only

What changed

Coverage gate

  • `pytest-cov` branch coverage + `fail_under = 85` in `pyproject.toml`.
  • `tests.yml` runs `--cov` only on `ubuntu-latest × python-3.11`; uploads `coverage.xml` as artifact.
  • Stretch target for pass 2: 92% (already close at 87%).

New test files

File Purpose Tests
`tests/test_generated_templates_golden.py` Golden snapshots for concept/task/reference output via syrupy. Helper strips timestamps + source_hash for stability. Snapshots in `tests/snapshots/`. 6
`tests/test_mcp_handlers_integration.py` Full request → orchestration → response lifecycle for `AttuneAuthorHandlers.{author_init, author_status, author_generate, author_lookup}`. Path validation, envelope shape, no real LLM calls. 12
`tests/test_parallel_polish_errors.py` Error injection in `_parallel_polish`: PolishError propagation, TimeoutError, all-workers-fail cascade. Pins use_rag + template_type pass-through. 8

Tests README — reference layer

attune-author is the reference for LLM mocking in the family. The new `tests/README.md` documents the three autouse fixtures (`_lenient_polish_by_default`, `_reset_rag_pipeline`, import-time `anthropic.Anthropic` patches) that the other layers' READMEs point at.

Dependencies

  • Added `syrupy>=4.0` to dev extras.

Test plan

  • `pytest --cov` locally — 788 passing + 32 skipped; 87.15% branch coverage
  • `ruff check` clean on new test files
  • Snapshot stability verified (rerun without `--snapshot-update` passes)
  • CI matrix passes on ubuntu/macos/windows × py3.10–3.13
  • Coverage artifact uploads correctly on the py3.11 cell

Out of scope (deferred to subsequent passes)

  • `mcp/server.py` (~67%) and `cli.py` (~80%) coverage — pass 2.
  • `rag-gate.yml` real-API spend audit — pass 2.
  • Slow / flaky test stabilization, CI duplication audit — pass 3.

🤖 Generated with Claude Code

silversurfer562 and others added 3 commits May 8, 2026 21:29
Moved from ~/attune/specs/regen-pipeline/. The spec primarily
targets attune-author (the `attune-author regenerate` CLI command
in src/attune_author/cli.py:507, plus maintenance.py and
maintenance_batch.py).

Phase 3 status bumped from "approved" to "complete" — the CLI
ships, the batch variant ships, CHANGELOG documents both.
A pointer to the implementation files is added under the
"Phase 3: Tasks" header.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…polish errors

Pass 1 of the test-strategy spec for the attune product family —
Layer 4 (attune-author, the AI-assisted authoring layer and reference
for the family's LLM mocking pattern).

Coverage gate:
- Added pytest-cov branch coverage + fail_under = 85 in pyproject.toml
  (measure-then-lock at baseline-2pp; current 87.15% with new tests).
- tests.yml: coverage runs on the ubuntu x py3.11 cell only;
  coverage.xml uploaded as an artifact.
- Stretch target for pass 2: 92% (already close at 87%).

New test files (26 new tests; total 788 passing + 32 skipped):
- tests/test_generated_templates_golden.py — syrupy snapshots of
  generated concept/task/reference output. Schema drift in Jinja2
  templates or in the frontmatter contract surfaces immediately
  rather than weeks later via the cross-repo workflow. Snapshots
  in tests/__snapshots__/. Helper strips volatile fields
  (timestamps + source_hash) before comparison so reruns are
  deterministic.
- tests/test_mcp_handlers_integration.py — exercises the
  AttuneAuthorHandlers methods through their full request →
  orchestration → response lifecycle. Path-validation contract,
  author_init bootstrap (empty / discovered / already-init paths),
  author_status, author_generate, author_lookup envelope shapes.
  No real LLM calls.
- tests/test_parallel_polish_errors.py — error injection in
  _parallel_polish: single-worker PolishError, TimeoutError, and
  all-workers-fail cascade. Confirms exceptions propagate via
  Future.result(); also pins use_rag and template_type pass-through
  semantics.

Test infra:
- New tests/README.md positions attune-author as the LLM-mocking
  reference (the autouse _lenient_polish_by_default + _reset_rag_pipeline
  conftest fixtures). Documents the snapshot policy and the live
  marker.
- Added syrupy to dev deps.

Spec: /Users/patrickroebuck/attune/specs/test-strategy/

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The new tests/test_mcp_handlers_integration.py added in this PR
uses `async def` test functions with @pytest.mark.asyncio
decorators, but pytest-asyncio was not in the [dev] extras. CI
across all 12 OS/Py combinations failed with:

  Failed: async def functions are not natively supported.

Fix: add `pytest-asyncio>=0.21,<2.0` to [dev] extras and set
`asyncio_mode = "auto"` in [tool.pytest.ini_options] to
auto-collect the marker.

Sibling attune-ai uses pytest-asyncio>=0.21,<2.0 and
asyncio_mode = "auto" — matching that pattern.
@silversurfer562 silversurfer562 merged commit 0144872 into main May 11, 2026
11 of 12 checks passed
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.

1 participant