Fix requests
A maintainer can ask Code Hawk to fix a problem on a pull request by commenting on it. The bot answers with one draft pull request into the pull request's branch, or with the reason it made no change.
Commands
Section titled “Commands”The command is the first line of the comment, starting with the bot's mention:
@codehawk-app fixon a Code Hawk line finding, as a reply in its review thread. The finding is the one the thread belongs to.@codehawk-app fix finding <number>on the pull request conversation. The number is the finding's number in the current summary comment.@codehawk-app fix check <id>on the pull request conversation. The id is the GitHub Actions job id of a failed check, which is the number in the job's URL.
A first line that starts with the bot's mention and fix but does not match one of these forms is invalid syntax. A writer gets a reply with the usage line, and no fix is made. The same usage reply goes to a fix finding or fix check command sent as a review-thread reply, and to a bare fix on the pull request conversation. Text whose first line does not start with the bot's mention followed by fix is not a command. It gets no reply and makes no API call.
Who and what is accepted
Section titled “Who and what is accepted”The requester needs write, maintain or admin permission on the repository. The workflow asks GitHub for the permission, because a webhook's author association does not show a private organization member correctly. A pull request from a fork is refused before any finding, check or log evidence is read, because the fix would need secrets that a fork run cannot hold. Fix requests on pull requests opened by bots are also refused. On the pull request conversation the refusal is posted as a reply. A review-comment request on a fork pull request runs without OIDC or an App key, because GitHub withholds both from that event, so the refusal can only be written to the workflow log and no reply is posted. A draft pull request is accepted. A closed pull request is refused.
A finding is refused when it is outdated, or when its summary belongs to an older commit than the pull request head. A check is refused when it did not fail, is not a GitHub Actions job of this repository, ran on another commit, or its log names no repository file with a failure line. The log is cleaned of timestamps, colours and markers, and it reaches the model fenced as untrusted text.
What the fix looks like
Section titled “What the fix looks like”The fix uses the same stage as fix issues. The model answers with a unified diff that holds a test file one of the test_commands runs and a change outside the tests. The test must fail before the change and pass after it, and the commands that failed before and passed after are listed in the pull request. A problem gets one more model call, so there are two attempts. Model routes and caps come from the default-branch settings. Other fix rules come from the config at the pull request base commit, never from the head checkout.
The bot writes a new branch fix/pr-<number>-<kind>-<key>-<short head sha> and opens a draft pull request into the pull request's branch. The commit message includes Requested on #<number> and ends with a blank line followed by [skip ci]. The bot never merges, never updates or deletes a branch and never changes the pull request being reviewed. If the model cannot prove a fix, the requester gets a reply saying No code was changed. If the branch exists already, the reply names it and nothing is opened.
Jobs and permissions
Section titled “Jobs and permissions”Three jobs keep model-written code away from every write token:
resolvehas the workflow token withcontents: read,pull-requests: read,issues: read,checks: readandactions: read. It checks the request and reads default-branch settings through the API, then passes validated settings JSON to fix. It holds no checkout, inference JSON or credential slots.fixhascontents: read, a checkout of the pull request head with no persisted credentials, the inference JSON, the credential slots and the test image. It gets no GitHub token. Its timeout is 50 minutes, above the fix stage's own 40-minute cap, so a slow run still writes its result.publishhasid-token: writeand no repository permissions or checkout. It mints the App token (contents, pull requests and issues write), checks the request and the fix record again and then answers. It stops when the request comment was edited to another author or command or was deleted, the pull request moved on, the requester lost access or the record does not match the request. If the fix job failed or timed out before it wrote a result, so the record is missing or holds no result, the requester is told the fix job did not finish. Without OIDC or an App key the job writes the reason to the log and succeeds with no reply.
The request and the fix record pass between jobs as artifacts kept for one day.
Caller workflow
Section titled “Caller workflow”The caller runs on issue_comment and pull_request_review_comment. It passes required bot_login and test_image, plus the provider secrets used by the default-branch settings. The deprecated inference input and numbered slots remain optional for one release. Install the CodeHawk App for hosted tokens. Only comments that mention someone and come from a person start the resolve job. Each request comment gets its own concurrency group, so a second request never cancels a queued one. See pinning and development for how to pin the workflow.
name: Fix request
on: issue_comment: # zizmor: ignore[dangerous-triggers] comment jobs check write access and never check out pull request code types: [created] pull_request_review_comment: types: [created]
permissions: contents: read
jobs: fix: name: Code Hawk fix request if: >- (github.event_name == 'pull_request_review_comment' || github.event.issue.pull_request) && github.event.comment.user.type != 'Bot' permissions: contents: read pull-requests: read issues: read checks: read actions: read id-token: write uses: bts-io/codehawk/.github/workflows/fix-request.yml@<sha> # codehawk <version> with: bot_login: codehawk-app[bot] inference: ${{ vars.CODEHAWK_INFERENCE }} test_image: ghcr.io/example/test-image@sha256:<digest> secrets: # Forward the secret your settings file uses, for example: CODEHAWK_OPENAI_API_KEY: ${{ secrets.CODEHAWK_OPENAI_API_KEY }}Forward only the provider secret your .github/codehawk.json uses: CODEHAWK_OPENAI_API_KEY, CODEHAWK_ANTHROPIC_API_KEY, CODEHAWK_GOOGLE_API_KEY or CODEHAWK_GATEWAY_TOKEN.
GitHub runs pull_request_review_comment workflows from the pull request's own branch. A @codehawk-app fix reply in a review thread therefore only starts when that branch already contains this caller, for example a branch created after the caller was merged, or one updated from the default branch since. @codehawk-app fix finding <number> on the pull request conversation runs from the default branch and works on any open pull request.
The calling job grants id-token: write and the read permissions the resolve job uses, because a called workflow can only lower its caller's permissions.
The test_image must be pinned by @sha256: as described in fix issues.
For one release, @codereview-hawk also works and emits a deprecation warning. Use @codehawk-app for new commands.
For your own App, add app_id under with and forward CODEHAWK_PRIVATE_KEY under secrets. See the self-hosted App lines. The hosted App needs neither.
Commits end with [skip ci] so repository CI does not run model-written code with its secrets until a person pushes a commit to the branch.