From f0cc3003580f80b2d517f5c90d6212da3c983740 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 7 May 2026 08:41:53 +0200 Subject: [PATCH] fix(opencode): make Phase 6 file gate see untracked files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `git diff --name-only` only shows tracked files with unstaged modifications. It does not show untracked files — which is precisely the state of any new test file @test creates, since @test's sandbox denies `git add`. The pre/post snapshots therefore both missed new files entirely and `comm -23 post pre` returned nothing, letting the gate cheerfully conclude nothing changed even when @test had just created tests/foo.rs (or, worse, src/lib.rs). Switch both snapshots to `git status --porcelain | sed 's/^...//' | sort -u`, which captures modified, staged, and untracked files in a single pass. Inline rationale notes the untracked blind spot so the orchestrator does not fall back to git diff. --- config/opencode/commands/workflow.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/config/opencode/commands/workflow.md b/config/opencode/commands/workflow.md index af99cbe..1e2a8eb 100644 --- a/config/opencode/commands/workflow.md +++ b/config/opencode/commands/workflow.md @@ -229,14 +229,15 @@ For each task from Phase 5, dispatch `@test` with: `@test` writes failing tests and verifies RED with structured failure codes. **Post-step file gate (MANDATORY):** -Before dispatching `@test`, snapshot the current changed files: +Before dispatching `@test`, snapshot every modified, staged, *and untracked* file. `git diff --name-only` alone misses untracked files, which is precisely the state of any new test file `@test` creates (it cannot `git add`). Use `git status --porcelain` so the gate sees them: ```bash -git diff --name-only > /tmp/pre_test_baseline.txt +git status --porcelain | sed 's/^...//' | sort -u > /tmp/pre_test_baseline.txt ``` -After `@test` completes, validate only NEW changes: +After `@test` completes, list NEW changes (in the post-snapshot but not the pre-snapshot): ```bash -git diff --name-only | comm -23 - /tmp/pre_test_baseline.txt > /tmp/test_new_files.txt +git status --porcelain | sed 's/^...//' | sort -u | comm -23 - /tmp/pre_test_baseline.txt > /tmp/test_new_files.txt ``` +Each line in `/tmp/test_new_files.txt` is a file path that did not exist (or was unmodified) before `@test` ran. The gate validates each one against the patterns below. All new files must match the project's test patterns: - Python: `**/test_*.py`, `**/*_test.py`, `**/conftest.py` (new only), `**/test_data/**`, `**/test_fixtures/**` - Rust: `tests/**/*.rs`, `**/tests/**/*.rs` (workspace-style `/tests/...`), `**/test_data/**`, `**/test_fixtures/**`