-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Why
GitHub Copilot supports path-scoped instruction files (.github/instructions/*.instructions.md) that activate only when Copilot is working on files matching a glob pattern. This allows more targeted guidance than the global copilot-instructions.md:
- Source code gets production-specific rules (Pydantic patterns, exception hierarchy, etc.)
- Test code gets testing-specific rules (fixture patterns, assertion style, etc.) — and can exclude Copilot Code Review from seeing test-framework boilerplate rules that would generate false-positive review comments.
Scope / Proposed changes
Create two files in .github/instructions/:
python-source.instructions.md— scoped tochainweaver/**/*.pytesting.instructions.md— scoped totests/**/*.py, withexcludeAgent: "code-review"
Proposed contents
File 1: .github/instructions/python-source.instructions.md
---
applyTo: "chainweaver/**/*.py"
---
# Python source instructions — ChainWeaver
These instructions apply when editing production source code in `chainweaver/`.
## Module conventions
- Every module starts with `from __future__ import annotations`
- Every module has a module-level docstring explaining its role
- All public classes and functions have Google-style docstrings
## Pydantic patterns
- Use `pydantic.BaseModel` for all data models (v2 API)
- Use `model_dump()` not `.dict()` (v2 migration)
- Use `model_validate()` not `.parse_obj()` (v2 migration)
- Field descriptions via `Field(description="...")` for schema clarity
## Exception patterns
- All custom exceptions inherit from `ChainWeaverError`
- Exception constructors accept context kwargs: `tool_name`, `step_index`, `detail`
- Import exceptions from `chainweaver.exceptions`, never define inline
## Export rules
- Any new public class/function MUST be added to `chainweaver/__init__.py` `__all__`
- If adding a new module, add its imports to `__init__.py`
## Executor invariant
- `executor.py` must remain deterministic: no LLM calls, no network I/O, no randomness
- The executor runs a compiled graph — it does not make decisionsFile 2: .github/instructions/testing.instructions.md
---
applyTo: "tests/**/*.py"
excludeAgent: "code-review"
---
# 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
## Anti-patterns in tests
- Do NOT mock internal ChainWeaver classes unless testing integration boundaries
- Do NOT use `time.sleep()` — tests must be deterministic and fast
- Do NOT import from `chainweaver` using relative pathsWhy excludeAgent: "code-review" on testing instructions?
When Copilot Code Review processes a PR that includes test files, it would receive testing-specific instructions like "use @pytest.fixture() with explicit parentheses" and may flag existing test code that doesn't follow these conventions — even if the PR didn't modify those tests. This creates noisy, false-positive review comments.
By setting excludeAgent: "code-review", these instructions guide code generation (Copilot Chat, Copilot Coding Agent) but are hidden from Code Review, reducing noise.
Labels to apply
documentationpriority:P2ai-friendlymilestone:v0.1.0
Depends on
- Add .github/copilot-instructions.md with coding conventions and validation commands #53 —
.github/copilot-instructions.mdshould exist first (scoped instructions complement, not replace, the global file)
Acceptance criteria
-
.github/instructions/python-source.instructions.mdexists withapplyTo: "chainweaver/**/*.py" -
.github/instructions/testing.instructions.mdexists withapplyTo: "tests/**/*.py"andexcludeAgent: "code-review" - Both files use valid YAML frontmatter syntax
- No content from global
copilot-instructions.mdis duplicated — these files add path-specific rules only - Pydantic v2 API patterns cited are correct (e.g.,
model_dump()not.dict()) - Exception hierarchy matches actual code in
chainweaver/exceptions.py
Avoid drift/duplication notes
- Global conventions (Ruff config, validation commands, PR rules) stay in
.github/copilot-instructions.md— NOT repeated here. - Architecture context stays in
AGENTS.md— NOT repeated here. - These files contain only path-specific rules that would be noise in the global file.
- If a scoped rule becomes universal, move it to
copilot-instructions.mdand remove from here.