You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add attribution test writing guidelines to AGENTS.md
Document patterns and conventions for writing integration tests
that exercise the attribution system, including test harness setup,
daemon interaction, and assertion helpers.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: AGENTS.md
+78Lines changed: 78 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -149,3 +149,81 @@ Uses `insta` crate. Snapshots live in `tests/snapshots/` and `tests/repos/snapsh
149
149
-**SQLite WAL files**: Test DB paths are placed as siblings to the repo directory (not inside `.git/`) to prevent WAL/SHM files from interfering with git operations.
150
150
151
151
-**`smol` async runtime**: The project uses `smol` (not tokio) for async operations with `futures` combinators. The async surface area is small -- mostly HTTP operations and background flushes.
152
+
153
+
## Writing Attribution Tests
154
+
155
+
When writing tests that verify AI vs human attribution:
156
+
157
+
### Required: Use Line-Level Blame Verification
158
+
159
+
**NEVER** just check that an authorship note exists or that `attestations.is_empty()` is false. This only proves the system created a note -- it does NOT verify correct line-level attribution.
160
+
161
+
**ALWAYS** use `assert_lines_and_blame()` to verify attribution at specific lines:
### Required: Direct File Writes + Explicit Checkpoints
176
+
177
+
**Do NOT** use `set_contents()` for attribution tests. It creates an unrealistic two-phase write (stub content -> human checkpoint -> real content -> AI checkpoint) that can mask bugs in the checkpoint-to-commit pipeline.
178
+
179
+
**Instead**, write file contents directly and run explicit checkpoints:
180
+
181
+
```rust
182
+
letpath=repo.path().join("code.rs");
183
+
184
+
// 1. Write human content
185
+
fs::write(&path, "fn main() {\n // human code\n}\n").unwrap();
- Human whitespace changes **preserve** existing attribution
206
+
- AI whitespace changes **are attributed to AI**
207
+
208
+
Account for this in tests involving formatting or whitespace-only edits.
209
+
210
+
### Test Intermediate States
211
+
212
+
Always verify attribution at intermediate commits, not just the final state. Bugs like the intermediate commit corruption in rebase logic can only be caught by checking each step:
0 commit comments