[SOURCE-324] Harden AI review workflow - #29
Conversation
🎉 All green!🧪 All tests passed 🔗 Commit SHA: d805a09 | Docs | Datadog PR Page | Give us feedback! |
chouetz
left a comment
There was a problem hiding this comment.
Thanks a lot for this contribution. I suppose we can test this branch directly on the repo as an e2e test (it's what I did to set-it up)
| echo "Diff: ${diff_lines} lines, ${diff_bytes} bytes" | ||
|
|
||
| - name: Verify pinned PR and fetch complete changed file list | ||
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 |
There was a problem hiding this comment.
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 |
| needs: [gate, prepare] | ||
| if: needs.gate.outputs.proceed == 'true' && needs.gate.outputs.provider == 'claude' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 |
There was a problem hiding this comment.
This sounds high. Do you think we should rather put 10 for instance? I suppose we set the same target for all providers.
| # Scrub the Anthropic API key from Claude's subprocess environment. | ||
| # Belt-and-suspenders alongside the allowed_non_write_users sentinel below. |
There was a problem hiding this comment.
Do you think this comment is really useless?
| --disallowedTools "Bash,Edit,Write,MultiEdit,NotebookEdit" | ||
| --setting-sources user | ||
| --max-turns 10 | ||
| --json-schema '${{ steps.claude_schema.outputs.json }}' |
There was a problem hiding this comment.
Nice! I was struggling to make it respect the output schema, didn't know this option.
| // toJSON emits a JavaScript string literal, so model-controlled | ||
| // characters cannot escape into this generated script. | ||
| const raw = ${{ toJSON(steps.claude.outputs.structured_output) }}; | ||
| if (!raw) { | ||
| fail('Claude did not produce structured output'); |
There was a problem hiding this comment.
I hope the claude action will really generate the structured output as required. It's not always the case today, so this would create instability in the execution.
| prompt-file: codex-prompt.md | ||
| output-schema-file: codex-output-schema.json | ||
| output-file: codex-output.json | ||
| codex-version: 0.144.5 |
There was a problem hiding this comment.
I suppose we need a renovate rule to bump this? If yes I'll create it.
| - name: Install pinned Gemini CLI | ||
| run: | | ||
| set -euo pipefail | ||
| gemini_tgz="$(npm pack --silent @google/gemini-cli@0.47.0)" |
There was a problem hiding this comment.
Same here we need a renovate rule I guess.
Summary
anthropics/claude-code-actionagent flow with read-only tools, project/local settings disabled, a 10-turn ceiling, and schema-backed output that is rejected rather than recovered from execution logsSecurity model
Model execution remains isolated from GitHub write permissions. Trusted code and schemas come from the exact reusable-workflow revision; review guides come from a gate-pinned default-branch commit; PR content and provider output are treated as untrusted data. The post job performs strict shape validation and a second secret/anomaly scan before calling GitHub.
review_event: COMMENT_ONLYremains the secure default.ALLis an explicit relaxation for same-repository PRs and is documented as such. Gemini still requires network access to reach its API, but exposes no model-callable network, shell, write, MCP, or extension tool.Reliability
Validation
npm test(101 passing, 99.39% statement coverage)actionlint 1.7.12(with the compatibility ignore for GitHub's documentedjob.workflow_repository/job.workflow_shacontexts)git diff --checkOperational notes
A live reusable-workflow run with real provider secrets was not performed. The pinned Claude action installs its fixed CLI version through Anthropic's mutable installer endpoint, so the action SHA does not pin the installer response. Datadog's internal guidance also requires coordinating direct-provider usage and costs because this path does not use centralized AI Gateway observability.
Ticket
SOURCE-324