Add agentic PR reviewer (gh-aw): requirement-fidelity + CARE SQL review - #148
Merged
Merged
Conversation
Agentic workflow that reviews every query PR through four lenses: JIRA requirement fidelity (branch name = ticket ID), CARE SQL correctness (defers to the ohcnetwork/skills care-sql-code-review skill), TEMPLATE.md conformance, and repo hygiene. - .github/workflows/analytics-review.md: gh-aw source. pull_request_target with base-only checkout (never PR head), JIRA secrets confined to the fetch pre-step, sqlglot lint pre-step, pinned skills checkout, safe-outputs as the only write channel. - .github/agents/analytics-review.agent.md: the four review lenses with proportionality guidance. - .github/scripts/lint_queries.py: deterministic sqlglot parse + template-structure lint of changed query docs (never fails the job). - .github/scripts/render_jira_ticket.py: ADF JSON -> markdown renderer. - .github/workflows/analytics-review.lock.yml + .github/aw/actions-lock.json: compiled with gh-aw v0.85.4, zero warnings. - README.md: PR Review Bot section; fix stale Accouting/ typo in the structure diagram (folder was consolidated in #144). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Adds a GitHub Agentic Workflows (gh-aw) reviewer that automatically reviews every query PR in this repo, modeled on the battle-tested reviewer in ohcnetwork/care_fe. It posts ≤8 prioritized inline comments plus one consolidated review, tracks its own findings across pushes (re-reviews only the delta, resolves fixed threads), and answers when humans reply or @-mention it.
The four lenses
ENG-\d+from the PR branch name, fetches the JIRA ticket (summary, description, comments) and renders it to markdown. The agent reconstructs what was asked — metric, grain, filters, facility scope — and verifies the SQL delivers exactly that. No ticket in the branch → one finding about the missing linkage, review continues.entered_in_errortraps, facility scoping, join fan-out, sargability, magic IDs. Uncertain schema claims are verified againstohcnetwork/caremodels via the API, not guessed. A deterministic sqlglot lint pre-step feeds parse/template errors in as input.{{variables}}actually in the SQL, Metabase optional-filter syntax kept commented per repo convention.Accouting→Accountingconsolidation from Move accounting docs from Care/Accouting into Care/Accounting #144), snake_case + deployment suffix (_ssmm/_pallium/_kc), one query per PR.Proportionality is explicit in the agent file: a fine PR gets a clean pass, no manufactured findings.
Security model
pull_request_targetwith base-only checkout — the workflow only ever checks out trustedmain; PR content is read via the API at head SHA and never placed on disk. This is the same mitigation care_fe uses.JIRA_*secrets appear only in the ticket-fetch pre-step's env, never in the agent's env. The agent job runs with read-only permissions; all writes go through gh-aw safe-outputs (capped: 8 inline comments, 1 review, 8 replies, 8 resolves).${{ }}-interpolated into scripts.Security review note (compiler-mandated)
gh aw compilegates on new secrets; these were reviewed and approved:JIRA_API_TOKEN,JIRA_BASE_URL,JIRA_EMAIL— read-only JIRA REST fetch of the ticket named by the branch, confined to one pre-step's env, registered with gh-aw's log-redaction step. Missing/wrong secrets degrade to aNO TICKET FOUNDmarker; the job never fails and the agent never sees the credentials.actions/checkoutbumped to v7.0.1 (pinned by full SHA in the lock file);ohcnetwork/skillschecked out at pinned SHA30f437fb55e9216a964476bfb7fcf46992051a2f.Admin prerequisites (before this works end-to-end)
Set three repo secrets (values not invented here — admin supplies them):
JIRA_BASE_URL— e.g. the org'shttps://<org>.atlassian.netJIRA_EMAIL— service account email for the API tokenJIRA_API_TOKEN— Atlassian API token for that accountPlus the org-level
COPILOT_GITHUB_TOKENengine credential — already in use by care_fe's reviewer, assumed available to this repo.Without the JIRA secrets the bot still reviews (lenses 2–4); lens 1 degrades to a "ticket context unavailable" note.
Verification done here
gh aw compile(v0.85.4): 0 errors, 0 warnings;.lock.yml+actions-lock.jsoncommitted.bed_occupancy_ssmm.md/labtest_revenue_ssmm.md, clean parse ongendersplit_pallium.md.ENG-909, embedded lowercaseeng-1234, no ticket, no PR context, no secrets, connection failure) write theNO TICKET FOUNDmarker and exit 0.No workflow runs were triggered. Post-merge dry-run plan:
workflow_dispatchwith thepr_numberinput against #146 and #147 to validate the full loop on live PRs before relying on the PR triggers.Post-v0 roadmap
care-schema.mdin sync withohcnetwork/caremigrations.