diff --git a/automation/README.md b/automation/README.md index 2a7b047..70c69c1 100644 --- a/automation/README.md +++ b/automation/README.md @@ -60,6 +60,11 @@ requires an interactive ESLint migration (a follow-up). Integration tests are type-checked here but executed against the `pelagia_test` DB by the autofix / locally (not in this shared CI, to avoid prod-mirror schema drift). +The **issue watcher pre-applies gate 1 (test-presence) locally** before opening a PR: +if Claude's fix changes code under `App/app|lib|components|hooks` but adds no test, the +watcher does **not** open a PR — it marks the issue `claude-failed` and comments — so it +never raises a PR that this CI would immediately reject. Re-queue (`claude-queue`) to retry. + A [`PULL_REQUEST_TEMPLATE.md`](../.forgejo/PULL_REQUEST_TEMPLATE.md) carries the checklist. ## Components diff --git a/automation/claude-issue-watcher.sh b/automation/claude-issue-watcher.sh index 676f97a..ed1a3f7 100644 --- a/automation/claude-issue-watcher.sh +++ b/automation/claude-issue-watcher.sh @@ -339,6 +339,22 @@ while [ "$f" -lt "$n_fix" ]; do commits=$(git -C "$WORKDIR" rev-list "origin/$BASE_BRANCH..HEAD" --count) if [ "$commits" -gt 0 ]; then + # Test-presence gate -- mirror .forgejo/workflows/pr-checks.yml so the watcher + # never opens a PR the CI will immediately reject. "Code" = app source under + # App/(app|lib|components|hooks); tests, prisma, config, docs are exempt. + changed=$(git -C "$WORKDIR" diff --name-only "origin/$BASE_BRANCH...HEAD") + code_changed=$(printf '%s\n' "$changed" | grep -E '^App/(app|lib|components|hooks)/' | grep -vE '(\.test\.|\.spec\.|/tests/)' || true) + test_changed=$(printf '%s\n' "$changed" | grep -E '(\.test\.|\.spec\.|/tests/)' || true) + if [ -n "$code_changed" ] && [ -z "$test_changed" ]; then + log "Test-presence gate FAILED for #$num: code changed with no test; not opening a PR" + set_labels "$num" "claude-working" "claude-failed" + add_comment "$num" "$BOT_MARKER +[Claude] Implemented a change but added **no test**, so no PR was opened. The contribution policy (\`pr-checks.yml\`) requires a test for any change under \`App/app|lib|components|hooks\`, and would reject this. Re-add \`claude-queue\` to retry, or pick it up interactively. + +Code files that needed an accompanying test: +$code_changed" + continue + fi log "Claude made $commits commit(s); pushing $branch" if ! git -C "$WORKDIR" push -f -u origin "$branch" -q 2>>"$LOG_FILE"; then log "push failed for #$num"; set_labels "$num" "claude-working" "claude-failed"; continue