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

StepWhat happensWho
1The QA tool reports a defect of a case: a pinned expected failure, an unexpected failure, or a pinned failure that now passes.QA tool
2GAOS records it (DefectReported) and plans a triage card labelled defect:triage.GAOS
3The Defect Triager reads the product's defect-triage policy, the facts and the source files GAOS found, and answers easy, medium or complex.Agent
4GAOS re-checks the verdict, records it (DefectTriaged) and plans a fix card born with its label defect:easy, defect:medium or defect:complex.GAOS
5Easy, 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
6The Defect Fixer answers with edits and tests, never whole files.Agent
7GAOS 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
8GAOS sends one WhatsApp line with the link; the fix card ends DONE.GAOS
9GAOS 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.

1 · QA toolreports the defect
→
2 · GAOStriage card
→
3 · Triagereasy, medium or complex
→
4 · Fixeredits and a test
→
5 · GAOSchecks, branch, draft PR
→
6 · GitHubdraft pull request
  1. The QA tool calls POST /api/v1/products/{id}/qa/defects (the route).
  2. GAOS records the defect and plans a triage card, with the source files it found as data.
  3. The Defect Triager answers through ai-manager; GAOS re-checks the verdict and plans the fix card.
  4. 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.
  5. 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.
  6. 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.

1 · GitHubdraft, ready, merged or closed
→
2 · GAOS pollerreads the state
→
3 · GAOSmoves the record, maybe the defect
→
4 · Auto-fix viewshows it
  1. A person reviews on GitHub; GAOS never marks a pull request ready and never merges.
  2. The poller reads each open fix pull request (FixPRStateChanged on a change).
  3. 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).
  4. The view refreshes every 30 seconds.

C. A retarget opens a new draft and closes the one it replaced.

1 · AdminRetarget to another base
→
2 · GAOSnext-generation fix card
→
3 · Fixerredoes the fix on the new base
→
4 · GAOSnew draft, linked both ways
→
5 · GitHubold draft closed, branch kept
  1. An auto-fix admin presses Retarget in the Pull requests drawer (Change the base branch).
  2. GAOS raises the defect’s generation and plans a fix card against the chosen base; it writes nothing to GitHub yet.
  3. The Defect Fixer gets the new base’s source and the previous fix as untrusted data.
  4. GAOS opens a new draft on gaos/fix-…-<gen> and records it, so the defect now waits on it.
  5. 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.

1 · Auto-fix viewDuplicates panel
→
2 · AdminClose on GitHub, confirmed
→
3 · GAOSchecks, reads GitHub
→
4 · GitHubpull request closed
→
5 · GAOSrecords it; defect unchanged
  1. 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).
  2. The button posts POST /products/{id}/prs/{fixPRID}/close.
  3. 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.
  4. GAOS closes the pull request with the write token; the branch is kept. A GitHub failure answers 502 and changes nothing.
  5. The store checks the finding again under its lock and records the close (FixPRStateChanged, rule autofix-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:

VerdictMeaning
EasyA 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).
MediumA 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.
ComplexAuthentication, 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

SettingMeaning
GAOS_AUTOFIX_ADMINSA 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_FILEA 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_CLASSICSet 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.

FieldMeaningDefault
enabledThe standing consent for automatic dispatch. Refused (422) unless the paths, the test globs, ciConfirmed and the write token are in place.off
fixCap, triageCapAutomatic dispatches per product per UTC day.3 (at most 10), 10 (at most 50)
allowedGlobsThe only paths an easy fix may edit.required
forbiddenGlobsExtra paths never touched, on top of the built-in list (generated code, migrations, SQL, dependency files, CI, Dockerfiles, authentication, billing, secrets).optional
testGlobsWhat counts as a test file; each must contain a test marker and may not be * or **.required
prTemplateThe pull-request body with the slots {{defect}}, {{title}}, {{summary}}, {{before}}, {{after}}, {{files}} and {{limits}}; it must hold {{before}} and {{after}}.a neutral default
ciConfirmedThe 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
reviseCapRevision rounds per agent pull request (the revision loop, D-112), 0–10. 0 is off.0
baseBranchThe branch the fix branches from and the pull request targets.the repository's default branch
automationDirsOne 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)
ciConfirmedGitLabNeeded 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}]}
FieldRule
caseIdA case of the product's catalog.
kindxfail, fail or xpass.
defectIdDEF- and 1 to 6 digits; required for xfail and xpass.
automationType, backend, levelbe or e2e; graphql, rest or empty; API, GQL, WEB or E2E.
targetReposowner/repo, at most 8. GAOS keeps only repositories the product owns.
operationsAt most 5 names, used only as search terms; they never widen what a fix may touch.
spec, title, excerptA valid spec path; at most 200 characters; at most 4 KiB.
RequestAt 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

CapValue
Files in a fix3, at least one of them a test
Changed lines (added plus removed)40 outside tests, 120 in tests
Automatic dispatchesThe 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.
Branchgaos/fix-<slug>, never moved or overwritten
Pull requestDraft 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.

PartWhat it shows
TilesOpen 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.
FiltersProduct and difficulty, above the sections, for all of them (product, difficulty).
SectionsFix 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 requestsThe 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 waitingThe 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 productEach product’s switch, today’s dispatches against its caps, and why it is off or not ready.
The drawerOne 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 byWhen
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 closedA 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):

RuleCloseKeep
SupersededAn open pull request a retarget replacedThe one that replaced it, while it is open or merged
Same defectEvery other open pull request of one defectThe 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

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)

When something fails

What happensResult
Over 50 new keys in a dayThe item is rejected defect-limit.
The triager's reply is unreadableThe triage card fails; the defect stays open.
GitHub search failsThe triage card is blocked autofix-search-failed; an empty search is not an error.
No repository the product ownsThe fix card is born blocked autofix-no-repo.
Medium, complex or regressionThe fix card is born blocked autofix-not-easy.
The fixer's reply is unreadableBlocked autofix-unreadable.
A cap is exceededBlocked autofix-limits; nothing is written to GitHub.
A file changed since the packetBlocked autofix-base-moved.
The private source trips the detectorsBlocked autofix-egress.
CI runs secrets on the branchBlocked 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 oursBlocked autofix-branch-exists; it is never used or deleted.
GitHub refuses a draftBlocked autofix-draft-unsupported; there is no non-draft fallback.
The pull request is closed unmergedA 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 writeThe fix card fails github-token; a branch this run created is deleted.
GitHub refuses to close a replaced pull requestIt 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 failsThe button answers with the reason (GitHub refused or cannot be reached, no longer a duplicate, not an admin); nothing changes.
GAOS restarts mid-wayThe stored reply is resumed; no second agent turn and no second pull request.
WhatsApp is downThe pull request stays; one failed ContactNotified is recorded.
The switch is off, a cap is spent or a turn is liveThe card stays READY and the view says why.