ChainWeaver testing.instructions.md

Python testing rules for ChainWeaver using pytest, a framework for running tests. They define test layout, fixtures, assertions, and coverage for successful and failing cases.

In plain words
What is it for?
Use them when adding or editing ChainWeaver tests, fixtures, executor checks, exception-message checks, or shared test helpers.
Why use it?
They make tests consistent and ensure new features check both normal behavior and errors.

Instructions file for GitHub Copilot

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/dgenio/chainweaver/testing
Clone the repo
git clone --depth 1 https://github.com/dgenio/ChainWeaver

Made for: GitHub Copilot.

Per session 462 This file is loaded in full into every session.
When invoked 462 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00462 $0.00462
Opus 5 $0.00231 $0.00231
Sonnet 5 $0.00092 $0.00092
Haiku 4.5 $0.00046 $0.00046

Measured yesterday against content hash 5dcc854c11d5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

ChainWeaver testing.instructions.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/instructions/testing.instructions.md · 46 lines

What it actually says

Testing instructions — ChainWeaver

These instructions apply when editing test files. They are excluded from Copilot Code Review to avoid false-positive review comments on test patterns.

Framework

  • Use pytest exclusively (no unittest.TestCase)
  • Use plain assert statements (pytest rewrites them for clear diffs)

Structure

  • File naming: tests/test_<module>.py
  • Group related tests in classes: class TestSuccessfulExecution:
  • One logical assertion per test when practical

Fixtures

  • Use @pytest.fixture() with explicit parentheses
  • Fixtures return fully configured objects (tools, flows, executors)
  • Prefer fixture composition over deep setup logic
  • Scope fixtures appropriately (scope="function" is default and preferred)

Coverage patterns

  • Every new feature needs: happy path + at least one error/edge case
  • Test exception messages, not just exception types
  • For executor tests: verify both ExecutionResult.success and StepRecord contents

File boundary

  • tests/helpers.py — shared Pydantic schemas and tool functions
  • tests/conftest.py — pytest fixtures that compose objects from helpers.py
  • Do not merge these files; do not put schemas in conftest.py or fixtures in helpers.py

Anti-patterns in tests

  • Do NOT mock internal ChainWeaver classes unless testing integration boundaries
  • Do NOT sleep() to wait for background work to finish — poll an observable condition with a deadline, or wait on a threading.Event. Fixed-duration sleeps are allowed for event-loop yields, latency simulation, poll cadence, and duration measurement; they must be routed through helpers.scaled() where a duration is simulated and carry a # timing: <category> marker. scripts/check_test_sleeps.py enforces this (issue #341; see docs/agent-context/workflows.md § Testing conventions, which is canonical)
  • Do not use relative imports into chainweaver internals; import from the public chainweaver package API instead
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 46 lines · 462 tokens per session scan A 5dcc854c11d5

Subscribe to this mod's changes

ChainWeaver testing.instructions.md is an instructions file published in the GitHub repository dgenio/ChainWeaver (6 stars, last pushed 2d ago), licensed Apache-2.0. It adds 462 tokens to every session, about $0.0023 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.