Improve CI checks and contributor guidance#1336
Conversation
The `test.backend.yml` and `test.frontend.yml` workflows used the same concurrency group (`head_ref || run_id`), so a push that touched both `ui/**` and non-`ui/**` paths would race the two workflows against the same group, and `cancel-in-progress: true` killed the one that started second. Observed on PR #1306 head `0d05fb47`: Backend Tests succeeded, Frontend Tests got cancelled three seconds after starting. The FE run was re-run manually and passed. Namespace the group by `${{ github.workflow }}` so each workflow has its own group. Cancel-on-new-push within the same workflow stays as before. Co-Authored-By: Claude <noreply@anthropic.com>
…reference files Slim CLAUDE.md (.agents/AGENTS.md) from 899 to ~600 lines and add the guidance that two years of PR review history shows is missing: - Definition-of-done checklists (endpoint/queryset, model change, pre-review) mapping 1:1 to the most frequent review findings: missing permission checks and default filters, 500s from unvalidated params, PII in serializers, N+1-blind single-row test fixtures, WIP debris, stale PR descriptions. - Domain invariants section: one feature extractor per clustering query, timezone.now() rule, ML-backend schema boundary, raise-don't-return, no assert in prod code, migration-in-same-PR rule. - Automated review bots section: verify bot findings against actual lint configs, push back with evidence, 150-file CodeRabbit limit. - Split bulk reference out of the always-loaded file: - DB schema table + query guide + QuerySet catalog -> docs/claude/reference/query-patterns.md - Worktree-vs-main-stack testing -> docs/claude/reference/worktree-testing.md - Chaos testing section -> pointer to existing docs/claude/debugging/chaos-scenarios.md - New docs/claude/reference/canonical-patterns.md: reuse-before-reinventing table with file:line refs (SingleParamSerializer, ProjectMixin, permissions, stats pattern, fixtures). - New ui/CLAUDE.md: frontend conventions (i18n via language.ts, no any in data-services models, mutation button states, naming, which lint rules are actually configured). - New docs/claude/INDEX.md: searchable index of all agent docs. Co-Authored-By: Claude <noreply@anthropic.com>
✅ Deploy Preview for antenna-preview canceled.
|
✅ Deploy Preview for antenna-ssec canceled.
|
|
Warning Review limit reached
More reviews will be available in 7 minutes and 31 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Job.job_type_key builds its choices from VALID_JOB_TYPES, so registry changes (post_processing and data_export job types added since the last migration) alter the field definition. The migration is state-only — no database schema change — but Django requires it, and the new makemigrations --check CI step fails without it. Documented the gotcha in the agent instructions. Co-Authored-By: Claude <noreply@anthropic.com>
0fcc968 to
bf85ca5
Compare
There was a problem hiding this comment.
Pull request overview
This PR improves CI reliability and contributor/agent guidance by (1) isolating workflow concurrency to avoid cross-workflow cancellations, (2) enforcing a “missing migrations” gate in backend CI, and (3) restructuring/adding agent reference docs (plus a frontend-specific conventions doc) to prevent common review-time issues.
Changes:
- Namespaced GitHub Actions
concurrency.groupper workflow for backend/frontend test workflows. - Added a backend CI step to fail if Django detects missing migrations, plus a state-only migration fixing
Job.job_type_keychoices. - Added/reorganized agent documentation (index + reference docs) and introduced
ui/CLAUDE.mdfor frontend conventions.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/test.backend.yml |
Namespaced concurrency group; added migration-check gate step. |
.github/workflows/test.frontend.yml |
Namespaced concurrency group to avoid cross-workflow cancellation. |
ami/jobs/migrations/0023_alter_job_job_type_key.py |
State-only migration to align job_type_key choices with VALID_JOB_TYPES. |
.agents/AGENTS.md |
Added domain invariants + checklists; moved bulky reference material into docs and linked to it. |
docs/claude/INDEX.md |
Added an index for agent-oriented docs (reference/runbooks/plans). |
docs/claude/reference/canonical-patterns.md |
Canonical “reuse” table pointing to existing helpers/patterns. |
docs/claude/reference/query-patterns.md |
Extracted DB/query reference and QuerySet method catalog into a load-on-demand doc. |
docs/claude/reference/worktree-testing.md |
Extracted worktree testing procedures into a dedicated doc. |
ui/CLAUDE.md |
Added frontend conventions (i18n, types, async/mutations, lint/format reality). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- ui/CLAUDE.md: React Query is pinned to v4, so mutation in-flight state is isLoading, not the v5 isPending. - docs/claude/INDEX.md: fix stray space in the title heading. - docs/claude/reference/worktree-testing.md: use repo-relative paths instead of developer-specific absolute paths in the override example. - docs/claude/reference/canonical-patterns.md: correct the url_boolean_param usage reference to ami/jobs/views.py:165. - .github/workflows/test.backend.yml: add --noinput to makemigrations --check so a model change needing a default fails deterministically instead of blocking on a prompt. Co-Authored-By: Claude <noreply@anthropic.com>
…ructions Adds a "Writing Comments, Docstrings, and PR Text" section: keep the load-bearing fact and cut unverified mechanism, label hunches as hunches, keep comments short and link to the PR/issue for depth, and distinguish measured from inferred in PR descriptions. A confident but wrong comment is read as fact and built on, so confidence should match evidence. Co-Authored-By: Claude <noreply@anthropic.com>
Match the repo-root convention (CLAUDE.md -> .agents/AGENTS.md): the frontend conventions file is now ui/AGENTS.md, with ui/CLAUDE.md a symlink to it. Other agent tools read AGENTS.md; Claude Code auto-loads the nested CLAUDE.md symlink when editing under ui/. Updated references in the instructions and index. Co-Authored-By: Claude <noreply@anthropic.com>
After merging main, VALID_JOB_TYPES includes regroup_events (added with the configurable session-gap work). Regenerated 0023 so the job_type_key field choices in the migration match the current registry; makemigrations --check passes against the merged tree. Co-Authored-By: Claude <noreply@anthropic.com>
Summary
This bundles several CI and contributor-guidance improvements that all aim at the same thing: catching problems automatically or at authoring time, instead of in review.
Two are small CI fixes. First, the
concurrencygroups in the backend and frontend test workflows are now namespaced per workflow, so a new push cancels only the same workflow's in-progress run rather than cancelling an unrelated one that happens to share the branch. Second, CI now fails when a model change is missing its migration, a class of mistake that is easy to miss in review.The larger part restructures the agent/contributor instructions (
.agents/AGENTS.md, symlinked asCLAUDE.md) so they actively prevent the issues that recur in this repo's PR review history. The guidance comes from reviewing roughly fifty merged PRs over the last two years and grouping the recurring feedback — from human reviewers and the review bots — into categories, then writing checklists and rules targeted at the most frequent ones: new code paths missing a permission check or the default occurrence filters (bugs invisible in the diff), unbounded/Python-side query work that doesn't scale, params returning a 500 instead of a 400, PII through nested serializers, single-row test fixtures that can't catch N+1s, and forgotten migrations.No application behavior changes except the two CI steps and the one migration the migration-gate required.
List of Changes
concurrencygroup bygithub.workflowintest.backend.ymlandtest.frontend.ymlmakemigrations --check --dry-runstep totest.backend.ymlJob.job_type_keyrequireschoicesare built fromVALID_JOB_TYPES, so the registered job types and the field definition must stay in sync;makemigrations --checkrequires this migration to be presentAGENTS.mdfor endpoint/queryset changes, model changes, and a pre-review pass (permission-matrix tests, default filters, param validation → 400, no PII in serializers,assertNumQuerieswith multi-row fixtures, self-review for debris)timezone.now()vsdatetime.now(), the ML-backend schema boundary, raise-don't-return, noassertin prod, migration-in-same-PRdocs/claude/reference/query-patterns.md; worktree-vs-main-stack testing todocs/claude/reference/worktree-testing.md; chaos-testing to a pointer to the existing runbookdocs/claude/reference/canonical-patterns.md— reuse table with file:line refs (SingleParamSerializer, ProjectMixin, permission classes, stats pattern, fixtures)ui/AGENTS.md(symlinked asui/CLAUDE.md, matching the repo-root convention): strings through the translation layer, noanyin data-services models, disable mutation buttons in-flight, naming, and which lint rules are actually configured (there is no Stylelint config, so bot Stylelint findings should be ignored)docs/claude/INDEX.mdindexing all reference docs, runbooks, and plansAGENTS.md: keep the load-bearing fact and cut unverified mechanism, label hunches ("best-guess", "not measured"), keep comments short and link to the PR/issue for depth, and distinguish measured from inferred in PR descriptionsDetailed Description
The agent-doc guidance is evidence-based: each checklist item and invariant corresponds to a category of feedback that recurred across multiple PRs and reviewers. The intent is to shift that feedback to authoring time or CI, and to make the always-loaded instruction file smaller and more rule-focused by moving bulk reference material into load-on-demand docs.
A separate higher-level "why Antenna exists / design grounding" section was drafted but is being held back for team review, since it's more strategic than mechanical.
How to Test the Changes
python manage.py makemigrations --check --dry-runexits 0 on this branch. Verified locally against the CI compose file.Checklist
🤖 Generated with Claude Code