Integrations
Defect auto-fix
The QA tool pins a known defect as an expected failure, so a defect used to be invisible to GAOS and equally queued whether it was a one-line validation or a billing problem. Now the QA tool reports it, GAOS classifies it from the product's own policy, and a defect that is easy to fix ends as a draft pull request that a person reviews. It is narrow on purpose: a backend-only defect, three kinds of fix, a few files, an explicit switch per product, and daily caps (D-091).
What auto-fix does
| Step | What happens | Who |
|---|---|---|
| 1 | The QA tool reports a defect of a case: a pinned expected failure, an unexpected failure, or a pinned failure that now passes. | QA tool |
| 2 | GAOS records it (DefectReported) and plans a triage card labelled defect:triage. | GAOS |
| 3 | The Defect Triager reads the product's defect-triage policy, the facts and the source files GAOS found, and answers easy, medium or complex. | Agent |
| 4 | GAOS re-checks the verdict, records it (DefectTriaged) and plans a fix card born with its label defect:easy, defect:medium or defect:complex. | GAOS |
| 5 | Easy, backend-only, switch on, cap left: the fix card is dispatched with no operator move. Otherwise it waits in READY, or is born BLOCKED (a complex defect also sends a notice). | GAOS |
| 6 | The Defect Fixer answers with edits and tests, never whole files. | Agent |
| 7 | GAOS applies the edits, enforces the caps, creates a branch and a draft pull request through the GitHub API, labels it and posts the before and after as a comment. | GAOS |
| 8 | GAOS sends one WhatsApp line with the link; the fix card ends DONE. | GAOS |
| 9 | GAOS follows the pull request (draft, ready, merged, closed) and shows it in the Auto-fix view. | GAOS |
How it works: the data flow
Four systems take part: the QA tool (it reports defects), GAOS (it plans the cards, applies the fix and writes to GitHub), ai-manager (the Defect Triager and the Defect Fixer answer there) and GitHub (it holds the pull request). The agents never hold the write token: every GitHub write is GAOS's own. Each flow reads left to right; the numbered list says who calls whom.
A. A defect becomes a draft pull request.
- The QA tool calls
POST /api/v1/products/{id}/qa/defects(the route). - GAOS records the defect and plans a triage card, with the source files it found as data.
- The Defect Triager answers through ai-manager; GAOS re-checks the verdict and plans the fix card.
- An easy, backend-only fix on a product that is on, with cap left, is dispatched without an operator; the Defect Fixer answers with edits and tests, never whole files.
- GAOS stores the reply first (a restart never pays for a second turn), applies the edits against the base
branch, enforces the caps and the CI-secrets check, and writes the blobs, the tree, the commit
and the branch
gaos/fix-…with the write token. - GAOS opens the draft pull request, labels it, comments the before and after, records it
(
FixPROpened) and sends one WhatsApp line.
B. GAOS follows the pull request.
- A person reviews on GitHub; GAOS never marks a pull request ready and never merges.
- The poller reads each open fix pull request (
FixPRStateChangedon a change). - A merge moves the defect to fixed. A close of the pull request the defect waits on plans one person-only card
(
autofix-pr-closed). A close of a record the defect does not wait on — one a retarget replaced, or a duplicate — changes only that record (D-108). - The view refreshes every 30 seconds.
C. A retarget opens a new draft and closes the one it replaced.
- An auto-fix admin presses Retarget in the Pull requests drawer (Change the base branch).
- GAOS raises the defect’s generation and plans a fix card against the chosen base; it writes nothing to GitHub yet.
- The Defect Fixer gets the new base’s source and the previous fix as untrusted data.
- GAOS opens a new draft on
gaos/fix-…-<gen>and records it, so the defect now waits on it. - Only then does GAOS read the old pull request and, while it is still open, close it and comment “Superseded by … GAOS closed this pull request; its branch is kept.” If GitHub refuses, the old one stays open, the Auto-fix view lists it under Duplicates, and the next restart tries again.
D. An admin closes a duplicate from the Auto-fix view.
- The panel lists open fix pull requests to close: Superseded (a retarget replaced it) and Same defect (another open one fixes the same defect; the one the defect waits on is kept).
- The button posts
POST /products/{id}/prs/{fixPRID}/close. - GAOS refuses an account not on the auto-fix admin list (403), a replay view (409), a record that is no longer a
duplicate (409) and a branch that is not
gaos/fix-(422), all before calling GitHub. It then reads the pull request: one already closed or merged is recorded as it is, with no close. - GAOS closes the pull request with the write token; the branch is kept. A GitHub failure answers 502 and changes nothing.
- The store checks the finding again under its lock and records the close (
FixPRStateChanged, ruleautofix-dedup, with the account). The defect is never changed.
What easy means
The policy is a product's own, written in its Blueprint under the key defect-triage. The shape GAOS
ships is neutral:
| Verdict | Meaning |
|---|---|
| Easy | A fix a reviewer can judge from the diff alone, in one resolver or route, with a unit test: a missing or wrong validation (a date format, a length the contract does not enforce, an inverted check), a formatting problem in input parameters, or a minimum or maximum check (a negative or zero amount accepted). |
| Medium | A business rule or a state guard inside one service that needs a person's judgement: a duplicate accepted, a status that should block an action, a missing nil guard. |
| Complex | Authentication, authorisation or anonymous access; billing, price or stock; a schema or migration; more than one service or repository; anything whose expected behaviour is a business decision. |
An easy fix never edits generated code, a schema, a migration, a dependency file, CI, authentication or anything that prices or stocks, never changes more than three files, and never lacks a unit test.
GAOS checks the verdict
An easy verdict is accepted only if its class is validation, format or min-value, the repository is one the
product owns, and every file is one GAOS put in the packet and the product's allowed paths admit. Otherwise it is
downgraded to medium and the reason is recorded. The deterministic gate is the path set, not the class. A
defect in acme-org/sample-service reported as DEF-101 that fails this check simply
waits for a person.
The settings
| Setting | Meaning |
|---|---|
GAOS_AUTOFIX_ADMINS | A file, mode 600, of the addresses that may change a product's auto-fix settings. No file, a world-readable file or an unlisted account: 403. |
GAOS_GITHUB_WRITE_TOKEN_FILE | A file, mode 600: the token GAOS writes with. A fine-grained token with Contents, Pull requests and Issues read and write on the application repositories only is recommended. It is separate from the review flow's token, which stays read and comment. Unset: auto-fix cannot be switched on. |
GAOS_AUTOFIX_ALLOW_CLASSIC | Set to 1 in the deploy shell to accept a classic token. Empty by default, which refuses one. The view and the configuration event show which kind is in use. |
In production the two files are deploy/stacks/prod.pr-github-write-token and
prod.pr-autofix-admins. They are gitignored and must exist before up; an empty one
leaves auto-fix off.
The per-product configuration
POST /products/{id}/autofix, back office, restricted to the admin list. Every change is an
AutoFixConfigured event with the actor's alias, the new values (never the template text) and the kind of
token.
| Field | Meaning | Default |
|---|---|---|
enabled | The standing consent for automatic dispatch. Refused (422) unless the paths, the test globs, ciConfirmed and the write token are in place. | off |
fixCap, triageCap | Automatic dispatches per product per UTC day. | 3 (at most 10), 10 (at most 50) |
allowedGlobs | The only paths an easy fix may edit. | required |
forbiddenGlobs | Extra paths never touched, on top of the built-in list (generated code, migrations, SQL, dependency files, CI, Dockerfiles, authentication, billing, secrets). | optional |
testGlobs | What counts as a test file; each must contain a test marker and may not be * or **. | required |
prTemplate | The pull-request body with the slots {{defect}}, {{title}}, {{summary}}, {{before}}, {{after}}, {{files}} and {{limits}}; it must hold {{before}} and {{after}}. | a neutral default |
ciConfirmed | The operator confirms that the repositories' CI runs no secrets on gaos/fix-* branches. GAOS also reads the workflows itself. A revision pushes to the pull request’s own branch instead, so GAOS checks that branch and the pull request’s base, and refuses the push if a secret-using workflow would run (D-112). | false |
reviseCap | Revision rounds per agent pull request (the revision loop, D-112), 0–10. 0 is off. | 0 |
baseBranch | The branch the fix branches from and the pull request targets. | the repository's default branch |
automationDirs | One line per automation repository that is also a fix target: <repository> <directory>, the directory 1 to 4 segments of [a-z0-9_-] (D-116). Fixes never write into it, and an allowed glob that could reach into it is refused. A merge request whose every changed path is inside it is a QA merge request and gets no review, e2e or unit card; the automation planner writes the catalog under <directory>/docs/test-catalog/. Recorded in the event as dirs=. | none (an automation repository is automation only) |
ciConfirmedGitLab | Needed when a target or automation repository is on the configured GitLab host (D-115). The operator confirms: every CI/CD variable that holds a secret is Protected; pipelines on unprotected branches (gaos/*, qa-auto/*) run only on ephemeral, container- or VM-isolated runners (no shell executor, no mounted Docker socket, no runner on the host that runs GAOS or holds its secrets); and their CI job token reads no more than a Developer. GAOS cannot read variables or runners on GitLab, so this statement stands where the workflow check stands on GitHub. Recorded in the event as ciGitLab=. | false |
A monorepo (application code and the automation suite in one repository) lists the repository in
both the target and the automation repositories and names the suite’s directory in automationDirs.
A merge request that is QA at open but gains application code before it merges is read again at merge: it gets the
unit watch and a review at merge that only comments (no review fix, no unresolved thread).
On GitLab (D-115) a fix needs the GitLab write token, GAOS_GITLAB_WRITE_TOKEN_FILE
(a project access token of its own, Developer, scope api, never the review token), and each target
repository is checked against its own forge. The commit and its branch are made in one Commits API call; a branch that
is already there is adopted only when its merge-base diff is exactly the fix and carries its trailer. GitLab CI
configuration is never written: .gitlab-ci.yml and .gitlab/** are built-in forbidden, and
the files the CI configuration includes are resolved before each write; an include GAOS cannot follow (another
project, a URL, a template, a component, a wildcard, a $ path) refuses the write. The merge request is a
draft that removes its branch when merged, and its text is neutralised (quick actions, mentions, closing keywords).
The QA tool's route
POST /api/v1/products/{id}/qa/defects
Authorization: Bearer <QA token>
{"source":"push","items":[{
"caseId":"TC-SAMPLE-008", "defectId":"DEF-101", "kind":"xfail",
"level":"GQL", "automationType":"be", "backend":"graphql",
"targetRepos":["acme-org/sample-service"], "operations":["editSampleRecord"],
"spec":"tests/api/graphql/sample-service/records/edit.spec.ts",
"title":"a negative quantity is accepted and stored",
"excerpt":"<failure output, at most 4 KiB>",
"runRef":"run-1", "runAt":1764060000}]}
| Field | Rule |
|---|---|
caseId | A case of the product's catalog. |
kind | xfail, fail or xpass. |
defectId | DEF- and 1 to 6 digits; required for xfail and xpass. |
automationType, backend, level | be or e2e; graphql, rest or empty; API, GQL, WEB or E2E. |
targetRepos | owner/repo, at most 8. GAOS keeps only repositories the product owns. |
operations | At most 5 names, used only as search terms; they never widen what a fix may touch. |
spec, title, excerpt | A valid spec path; at most 200 characters; at most 4 KiB. |
| Request | At most 256 KiB (413 too-large) and 50 items; an unknown field is 400; at most 50 new defect keys per product per UTC day. |
The answer is 200 {"applied":n,"unchanged":n,"rejected":[{caseId,reason}]}: a bad item is rejected
with a reason and the rest apply. A repeat updates the last-seen time and plans nothing; an xpass marks
the defect fixed and cancels its open cards; a fail after a fix is a regression, whose fix card is
born BLOCKED and is never fixed automatically. Everything in an item is untrusted: its text is stripped of backticks,
angle brackets and line breaks, screened for secrets, reaches an agent only as data and appears in no event, card
title or log line.
The caps
| Cap | Value |
|---|---|
| Files in a fix | 3, at least one of them a test |
| Changed lines (added plus removed) | 40 outside tests, 120 in tests |
| Automatic dispatches | The fix and triage caps above, per product per UTC day. They count dispatches, not pull requests, and are the only spend bound for these cards. |
| Branch | gaos/fix-<slug>, never moved or overwritten |
| Pull request | Draft only; never ready, approved or merged by GAOS |
A failing cap does not retry: the card is blocked with its reason and the verdict is kept.
The Auto-fix view
The back office's Auto-fix view (/app/autofix) shows every product's defects and fix pull requests. It
refreshes every 30 seconds, announces an unreachable GitHub, shows the kind of write token in use, and never shows a
token or a failure excerpt. Everything is in the address, so a link opens the same view.
| Part | What it shows |
|---|---|
| Tiles | Open drafts (one a retarget replaced is not counted, and the note says how many there are), ready for review, merged in seven days, defects awaiting triage, cards waiting for a person, and today’s automatic dispatches against the caps. |
| Filters | Product and difficulty, above the sections, for all of them (product, difficulty). |
| Sections | Fix pull requests (the default, and always when a drawer is open), Cards waiting and Auto-fix by product, one at a time, each with its count (section=waiting, section=products). |
| Fix pull requests | The state links (all, preparing, draft, ready, merged, closed), the Duplicates panel, and a table ten rows a page: state (and replaced), the defect and what triggered it, difficulty, product, the pull request, branch → base, card, age and whether WhatsApp was told. |
| Cards waiting | The defect cards that are not moving and why (a person is next, a switch is off, a cap is spent, a live turn), five a page (wpage). |
| Auto-fix by product | Each product’s switch, today’s dispatches against its caps, and why it is off or not ready. |
| The drawer | One pull request: what triggered it (linked to the earlier pull request when one caused it), branch and base, class, the before and after, the changed files with their line counts, the caps and the timeline (open). |
Changing a filter, a state, a section or a page keeps the sheet’s scroll position.
What triggered a pull request
| Triggered by | When |
|---|---|
Retarget of owner/repo#n (base …) | A retarget opened it; the drawer links to the one it replaced. |
Review finding on owner/repo#n (branch) | A low finding of GAOS’s pull-request review (Pull-request agents). |
| Unit tests failed on <base> after merge <sha> | A failing unit-test result after a merge (Unit tests (CI)). |
Second attempt after owner/repo#n was closed | A later generation of the same defect after an earlier pull request ended; linked. |
| QA report <case> (<kind>) | Any other defect the QA tool reported. |
Duplicates
Above the table, a Duplicates panel lists open fix pull requests that should be closed, each with the one to keep and the reason (D-108):
| Rule | Close | Keep |
|---|---|---|
| Superseded | An open pull request a retarget replaced | The one that replaced it, while it is open or merged |
| Same defect | Every other open pull request of one defect | The one the defect waits on, else the newest |
An auto-fix admin closes one with Close … on GitHub, after a confirmation; everyone else sees that an admin can close it. The steps are flow D above. A retarget closes the pull request it replaced by itself, so a superseded finding appears only when that close failed.
What GAOS never does
- Marks a pull request ready, approves it or merges it, or pushes to a default branch. It closes only its own
gaos/fix-drafts that a retarget replaced or an admin closed as a duplicate (D-108). - Lets the agent hold the write token or open the pull request.
- Fixes a medium, complex, regression or end-to-end defect automatically, or opens a pull request from a card that fails the record-based check, however it was dispatched or relabelled.
- Starts a fix under
GAOS_RUNNER=onwhen a product's switch is off: the scheduler never dispatches a defect card in any mode. - Runs the tests. The “after” in the pull request is the agent's report, and the body says so (OQ-39).
- Puts a defect's text in an event, a card title or the WhatsApp line.
Private source files GAOS fetches for the packet go to the model provider, as D-091 records; a secret detector hit refuses the dispatch.
Operating notes (learned on the first live run)
- Globs.
*matches one path segment and**any number of them.*.gomatches only a file in the repository's root; a fix underpkg/graph/…needspkg/graph/**/*.go. A verdict naming a file outsideallowedGlobsis downgraded to medium (autofix-files-outside-globs), so a too-narrow glob looks like a triager that never says easy. Test globs likewise:**/*_test.go. - The triager's source slice. Search hits come from the QA tool's operation names, the defect's own operation first. Up to twelve files are read and at most six kept (64 KiB): hand-written Go source before tests before everything else, a file that defines a function named for an operation before one that only mentions it, and a file that holds a secret-shaped string is left out. If the verdict says the implementing code is not in its packet, look at the operations the QA tool sent.
- CI. Forbid, in
forbiddenGlobs, the directories that trigger a workflow which uses a secret, and say so inciConfirmed. GAOS applies a workflow'spathsfilter to the files the fix changes; a workflow with no filter, a negated pattern or an unreadable file still blocks. - The pull-request body. The repository's own template is not fetched. Put it in
prTemplatewith the slots; GAOS keeps every section and fills the ones it knows. Without one the neutral English body is used. - One page for every pull request. The fix pull requests also appear on the Pull requests page, next to the ones GAOS reviews and the ones the QA tool opens.
- Refusals are logged. A ready card that is not dispatched is logged once per card and reason (
autofix: … is ready but not dispatched: …): a cap, a live turn on the product (one at a time), the egress pass, the Blueprint drift gate. - The pull request is a draft, always. The “after” in its body and comment is the agent's prediction. Read the added test: an agent may write a test that restates the condition instead of calling the code.
When something fails
| What happens | Result |
|---|---|
| Over 50 new keys in a day | The item is rejected defect-limit. |
| The triager's reply is unreadable | The triage card fails; the defect stays open. |
| GitHub search fails | The triage card is blocked autofix-search-failed; an empty search is not an error. |
| No repository the product owns | The fix card is born blocked autofix-no-repo. |
| Medium, complex or regression | The fix card is born blocked autofix-not-easy. |
| The fixer's reply is unreadable | Blocked autofix-unreadable. |
| A cap is exceeded | Blocked autofix-limits; nothing is written to GitHub. |
| A file changed since the packet | Blocked autofix-base-moved. |
| The private source trips the detectors | Blocked autofix-egress. |
| CI runs secrets on the branch | Blocked autofix-ci-secrets. A workflow with a paths or paths-ignore filter counts only when a changed file matches it (see the operating notes). |
| The branch exists and is not ours | Blocked autofix-branch-exists; it is never used or deleted. |
| GitHub refuses a draft | Blocked autofix-draft-unsupported; there is no non-draft fallback. |
| The pull request is closed unmerged | A new person-only card, blocked autofix-pr-closed. A pull request GAOS closed as replaced or duplicate, or any record the defect no longer waits on, plans nothing. |
| GitHub refuses a write | The fix card fails github-token; a branch this run created is deleted. |
| GitHub refuses to close a replaced pull request | It stays open with a comment that a person may close it; the view lists it as superseded, and the next restart tries again. |
| A duplicate close fails | The button answers with the reason (GitHub refused or cannot be reached, no longer a duplicate, not an admin); nothing changes. |
| GAOS restarts mid-way | The stored reply is resumed; no second agent turn and no second pull request. |
| WhatsApp is down | The pull request stays; one failed ContactNotified is recorded. |
| The switch is off, a cap is spent or a turn is live | The card stays READY and the view says why. |