Integrations
Agents, severity and review fixes
A product says which agents work on it. That switches its pull-request flows on, role by role. The reviewer's finding becomes a severity you can see and filter on the board, a medium or worse finding asks GitHub for changes, and a low one can be fixed by an agent with a draft pull request into the reviewed branch.
Where this comes from
Decision D-102, rule BR-61 in BRD §9.6, cases TC-800 … TC-818 in the QA test plan. The pull-request flows themselves are described in Pull-request agents, and the fix machinery in Defect auto-fix. The examples use an invented product, Route Planner.
What it gives you
| You want | Where | What happens |
|---|---|---|
| To see which agents serve a product | Back office → Agents, pick the product | The list narrows to that product's agents; each agent shows the products it is assigned to as chips. |
| To turn a pull-request flow on or off for one product | Agents → Edit assignments | A role with an assigned agent runs; a role without one plans no card on that product. |
| To find the reviews a person must read | Board → Severity → Medium or worse | The kanban and the table show only medium, high and critical reviews. |
| To have GAOS block a risky pull request | Configure the product (any save) | A medium or worse finding is posted as changes requested. |
| To have small findings fixed for you | Assign the fixer, turn auto-fix on, list the branches | A low finding becomes a draft pull request into the reviewed branch. |
| To have GAOS decide what a pull request needs automated | Assign Orion, the automation planner | An e2e card with no case asks the planner; its decision waits for you to release the card. |
| To find cards that did not come from GitHub | Board → Label → source:api or source:bundle | Cards an API client or a bundle's test planner created. |
Every i button on the Agents page, beside the board's Severity filter and on the Auto-fix page opens the matching section of this page.
Assignment
A product lists the agents assigned to it. One agent can be assigned to several products: Kite, the unit-test
builder, can serve Route Planner and three other products at once. The list is stored on the product record
(Product.assignedAgents, Product.assignedSet), so it survives a restart and needs no schema
change.
Three states of a product
| State | How you get there | Pull-request flows | Review event |
|---|---|---|---|
| Not configured | The default for every product, old and new | All run, as before this feature | Comment only |
| Configured | Save in Edit assignments, with at least one agent | Only the roles with an assigned agent | Medium or worse requests changes |
| Configured, empty | Save with no agent ticked | None; the page says so | Medium or worse requests changes |
Stop gating returns a product to “not configured” and forgets its list. Cards already on the board when a role is switched off are left alone and finish normally; only new cards are affected.
Which roles assignment switches
| Role | Agent | The card it switches |
|---|---|---|
pr-reviewer | Juno | The review card when a pull request opens |
qa | Ember, Flint | The e2e automation card on open and the e2e run card on a staging deploy; without one the staging callback answers 422 unassigned |
unit-test | Kite | The unit-test card when a pull request merges |
fixer | Mica | Review fixes only (below); the defect auto-fix of D-091 keeps its own switch |
automation-planner | Orion | The automation planner’s card, for an e2e automation card with no case or a test planner’s handoff; without one the e2e card keeps its old reason and says the planner was not started |
Assignment switches a role on for a product; it does not choose which agent runs a card. Each of these roles has one
agent except qa, and the QA tool, not an agent, runs the e2e work. Cards planned by an
external-tasks API client and the test planner's cards from a
bundle are never gated: they are explicit requests. They carry a
source label instead, so you can filter them.
Who may change it
Only an account listed in GAOS_AUTOFIX_ADMINS sees the editor and may post to
POST /agents/assign (fields product, agent repeated, action=save|reset).
Every change is a RecordUpdated event naming the account's alias, never its address; the first save of a
product says that gating and requested changes are now on.
Severity on the board
The reviewer ends its reply with a severity: none, low, medium,
high or critical. GAOS stores it as a label of the family severity:* on the card,
before anything is posted, so a review that was held for a secret or failed to post still shows what was found.
- Kanban: a chip with the level written in it, first among the card's labels;
nonehas no chip. Medium is amber, high red, critical a red block. - Table: a Severity column (sortable; worst first, a card without a severity last both ways) and a Labels column.
- Filter: the Every severity select offers the levels on the product's cards and Medium or worse. The address keeps it, for example
?severity=medium%2B.
An operator may correct a severity through the label route (for example to downgrade a false critical). That changes the record only: nothing is posted again and the card does not move.
Comment or request changes
| Severity | Not configured | Configured | Card afterwards |
|---|---|---|---|
| none, low | Comment | Comment | Done (a low may plan a review fix) |
| medium | Comment | Request changes | Done |
| high, critical | Comment | Request changes | Stays in Review, labelled pr-review:needs-manual |
GAOS never approves. It requests changes only when it knows the pull request's author and the account that posts
the review, and they differ; otherwise it comments. GAOS reviews a pull request once and never dismisses its own
review, so a request-changes body ends with: “GAOS reviews once. When these points are addressed, a
maintainer dismisses this review.” On a pull request whose author is an agent (ai-assisted, or
opened by GAOS) it only comments, and reviews again after each revision: see
the revision loop (D-112).
Whose name is on the review
The review posts under the account of GAOS_GITHUB_TOKEN_FILE. If that is a person's token, a request
for changes appears as that person's judgement, and where branch protection requires approvals it blocks the merge
until someone dismisses it. Use a bot account's token before configuring a product.
On GitLab “request changes” is an unresolved thread and the review is advisory (D-114): the reviewer, triager, test planner and e2e cards work there; the fixer, the automation planner and the unit-test watcher do not yet. See GitLab.
Low findings fixed by an agent
A low finding can become a review fix. GAOS records it as a defect of kind review, already
triaged easy, and the auto-fix pipeline does the rest: the fixer agent edits the code, and
GAOS opens a draft pull request into the reviewed pull request's own branch, on top
of the exact commit the reviewer read. On an agent’s pull request no draft is opened: the
revision loop pushes the change onto the pull request itself.
The fix follows the source's root branch. Route Planner's feature/route-limits was cut
from staging and targets staging; the fix lands in feature/route-limits and
reaches staging when that branch merges. GAOS never opens a review fix against staging,
main or any other shared branch.
When a review fix is planned
- The product is configured and Mica (fixer) is assigned to it.
- Auto-fix is on for the product.
- The head branch matches one of
reviewFixHeads— patterns with a literal first segment such asfeature/*;*,**and a bare branch name are refused. - The repository is one of the auto-fix
targetReposand not an automation repository. - The day's
reviewFixCap(default 3, at most 20, per product, UTC day) is not reached. - The head has not moved since the review, the file list is complete, and the pull request changes nothing under
.github/.
The review card's reason says what happened: review posted; review fix planned (<card>), or a
reason such as ; no fixer assigned, ; auto-fix off,
; branch not allowed for review fixes, ; review fix cap reached,
; head moved since review.
The settings
Two fields join the product's auto-fix settings (POST /products/{id}/autofix, admins only):
| Field | Meaning |
|---|---|
reviewFixHeads | One branch pattern per line, at most 8. Empty: review fixes are off. |
reviewFixCap | Review fixes planned per UTC day. 0 means the default 3; at most 20. Counted apart from the defect fix cap. |
The checks before anything is written
GAOS reads the pull request again before the agent runs, and once more before any branch exists. Any of these blocks the card with the reason shown and closes the review fix:
| Reason | Why |
|---|---|
review-pr-closed | The pull request closed or merged. |
review-base-changed | Its head is another branch now. |
review-base-moved | Its head is not the commit the reviewer read. |
review-fork | It comes from a fork (always refused). |
review-shared-branch | Its branch is the default branch, the auto-fix base, an allowed retarget base, or protected. |
review-branch-not-allowed | Its branch no longer matches reviewFixHeads. |
review-files-incomplete | GitHub's file list was cut short. |
review-workflows | It changes .github/. |
review-not-target | The repository is no longer a fix target. |
review-unassigned | The fixer was unassigned since. |
review-outside-paths | The agent edited a file the pull request does not change, or added a file outside their folders. |
The fixer sees the review findings and the pull request's code as untrusted data, fenced, after its
instructions. Every other auto-fix check still applies: the allowed and forbidden paths, the CI-secret check, the
egress screen. When the draft opens, GAOS posts one line on the reviewed pull request:
GAOS opened a draft fix: <url>.
What happens next
- The reviewed pull request merges before the fix starts: the fix card is canceled. GAOS checks the merge with GitHub first.
- The draft's base changes (GitHub retargets it when the reviewed branch is deleted): GAOS records it and closes the review fix; it closes nothing on GitHub. A person decides what to do with the draft.
- The draft is closed unmerged: the review fix closes; no second attempt is planned.
- GAOS's own review fix merging into the feature branch plans no unit-test card; the feature branch's own merge does.
- A review fix is never retargeted.
Where a card came from
Cards planned from a GitHub event or the staging callback carry no source label. The two kinds of card that assignment does not gate say where they came from, so you can filter them on the board's Label select:
| Label | The card |
|---|---|
source:api | Created by an external-tasks API client (a review, unit tests, an e2e automation or run it asked for). |
source:bundle | The test planner's card for a bundle of merged pull requests. |
The planner sets them; an operator cannot. An API request for a card GitHub already planned adopts that card and adds no label to it. There is no backfill: only cards planned from v0.64.0 on carry a source label.
The automation planner
Since v0.74.0 (D-111). The automation-planner role,
agent Orion, decides from a pull request’s own test scenarios what its tests need: a spec written
for a case, an existing spec updated, a new epic added to the test catalog, or nothing. It never starts a spec itself:
every outcome waits for a person to release the card
(BR-67).
When it starts
- An e2e automation card with no case (no
QA-case:line) is released. The planner card is planned and the e2e card waits BLOCKED with automation planner <id> is deciding the case. A release while the planner is still open waits again; after a planner that wrote no case, a release plans a new one, at most three times. - A test planner hands its bundle over when no epic fits: it ends DONE with handed to the automation planner <id>, and the task-tracker note is still written once.
It is refused, and the reason says so, when the role is not assigned on the product
(unassigned:automation-planner) or when
GAOS_PLANNER_DAILY planners (default 10, 0 switches the planner off) already started for the
product that UTC day (daily).
What it reads
- The pull requests, fenced as data: title, author, base branch, the template’s “what the developer tested” and “what QA should test” sections (capped and screened), at most 200 changed paths, and a test planner’s handoff note.
- The product’s epics, one line each, and at most 40 KiB of related cases from at most eight epics.
- The automation repository, and the catalog layout: one file per epic under
docs/test-catalog/<service>/[<area>/]<epic>.md. Product-specific conventions come from the product’s Blueprint policies; no knowledge source is read.
Its context is rebuilt by the poller after a restart before the card can run, as the test planner’s is.
What it may output
| Decision | What it carries | What happens |
|---|---|---|
automate | A known case and create or update (with a note); only for a pull request’s planner | The e2e card stays BLOCKED with qa-planned case:<code> mode:<mode> — move to Ready to start. Moving it to Ready sends the case to the QA tool. An update needs the QA tool’s update capability; without it the card says to update the spec by hand. |
catalog | A new epic: code, title, path under docs/test-catalog/, content | GAOS opens a draft pull request on gaos/catalog-<epic> in the automation repository, labelled gaos-catalog. A person reviews and merges it; when its cases sync, add QA-case: and move the e2e card to Ready. |
none | A summary | The e2e card stays BLOCKED with the automation planner found nothing to automate. |
Every plan carries a summary for the person. When the pull request names no test scenario and the context does not
settle it, the planner asks instead: the card waits in Needs you with three options. A plan that breaks a
rule, or a reply with no plan, fails the planner card, and the e2e card says so and waits. A catalog
plan, or a planner that could not plan, is sent as an automation:planned line, to the pull request’s
author for an e2e card, to the group for a bundle. A none or automate plan asks nothing of a
person and is never sent (D-123):
the decision is on the planner card and the e2e card.
The catalog pull request
GAOS writes only a new file, and refuses, naming the class, when the product has no automation repository
(catalog-no-repo), the repository is public (catalog-public), the file already exists
(catalog-file-exists), or a workflow with secrets would run on the branch (ci-secrets). Since v0.74.3 the commit carries
[skip ci], which GitHub honours for push and pull_request workflows, so only a
secret-using workflow on another trigger, such as pull_request_target, refuses the write. A refused write
ends the planner card FAILED, so Retry runs it again once the cause is fixed. An open catalog pull request for the same epic is reused. GAOS never merges it, never marks it ready
and never pushes to it again. It uses the write token, GAOS_GITHUB_WRITE_TOKEN_FILE, whose scope must cover
the automation repository with contents and pull-request write; a 403 or 404 is catalog-token-refused.
The model
The planner runs on claude-opus-5-5, a scoped exception to
BR-36 made at the operator’s request. Set
GAOS_MODEL_AUTOMATION_PLANNER to change it without a release; a malformed value is ignored. A vendor policy
that names a model wins, under Antigravity the product’s own model applies, and no other role changes.
Set it up for a product
- Sign in to the back office with an account listed in
GAOS_AUTOFIX_ADMINS. - Open Agents, choose the product in the filter, open Edit assignments.
- Tick Juno · PR Reviewer, Kite · Unit Test Builder and a QA agent (Ember or Flint), then Save. The notice under the filter now says which roles do not run.
- For review fixes: also tick Mica · Defect Fixer, and in the product's auto-fix settings
turn auto-fix on, list the target repositories, and set
reviewFixHeads(for examplefeature/*andbugfix/*). - For the automation planner: also tick Orion · Automation planner, and make sure the write token’s scope covers the product’s automation repository.
- Check the Board: the next opened pull request shows a review card, then a severity chip.
To undo it, open Edit assignments and press Stop gating.
The second release: e2e kinds, staging creates and merged specs
Built in v0.65.0, waiting on the QA tool
GAOS's half of parts 1–3 shipped in v0.65.0 (D-103,
design docs/designs/release-b-e2e-kinds-merge-unit-tests.md). The QA tool's half follows in its own
pull requests. Until the QA tool lists a capability, GAOS sends what it sends today, so nothing changes by itself.
Unit tests (part 4) get a design of their own.
The second release finishes the e2e automation builder. In short: when a repository is deployed to staging, GAOS runs its automation of the repository's kind and, if the product asks for it, has the QA tool create what is missing; a person approves each new spec; the QA tool may let it merge by itself once its checks pass; GAOS then runs it.
How it works: the data flow
Three systems take part: your CI (it deploys to staging), GAOS (it plans cards and asks), and the QA tool (it writes and runs the specs). GitHub merges; GAOS never does. Each flow below reads left to right; the numbered list says who calls whom.
A. A staging deploy runs the automation, and creates what is missing.
- The pipeline calls
POST /api/v1/products/{id}/stagingwith the repository and commit (HTTP Basic, one credential per product). - GAOS plans one run card, labelled with the repository's kind. If staging creates is on and this is a new commit, it also plans up to two create cards for planned cases with no automation yet.
- GAOS's QA runner asks the QA tool for a job per card (
POST /api/v1/gaos/automationwithkind, only when the QA tool lists that capability) and polls it. - A run ends the card Done (the results are on the QA side and in the catalog) or Failed with its reason.
B. A new spec: created, approved, merged, then run.
- The create card's job generates the spec and repairs it against staging. The card waits in Needs you.
- A person approves the spec. Only an approval given in the QA tool can lead to an auto-merge; an answer from the GAOS Inbox opens the pull request for a person to merge.
- The QA tool pushes the commit (GAOS records it as the approved commit) and opens the pull request. If
GAOS still allows it (
GET /api/v1/products/{id}/spec-auto-merge: the product's auto-merge switch on, the Working or Complete band) and every repository check passes, it turns on GitHub's auto-merge pinned to that commit. - GitHub merges when the required checks pass. Otherwise a person merges.
- GAOS's pull-request poller sees the merge. If the merged head is the approved commit and the QA catalog shows the case implemented, GAOS plans one run of that case. Any other head is noted on the Pull requests page and not run.
C. A pull request is opened, reviewed, and a low finding fixed.
- Brain Town forwards
pr.openedfor a repository the product lists. - GAOS plans a review card when a PR reviewer is assigned (see Assignment).
- The review is posted on GitHub; medium and worse request changes, and the card gets a
severity:*label. - A low finding on an allowed branch becomes a draft pull request into the reviewed pull request's own branch (Low findings fixed by an agent).
1. A kind per repository
| Kind | A staging run runs | The QA tool may create |
|---|---|---|
| none (not set) | every automated case, as today | nothing on staging |
be — backend only | API and GraphQL cases | API specs (tests/api/rest/) |
fullstack — frontend and backend | every case | browser specs (tests/web/); API specs too when the product has no be repository |
Open the Agents page, pick the product, and open E2E repository kinds (admins only, the same
accounts as auto-fix). Choose a kind for each repository and save. The staging run card of a repository with a kind
carries e2e-kind:be or e2e-kind:fullstack: shown and filterable like every label, never
settable by hand. Route Planner's acme/route-api is be; acme/route-web is
fullstack. Saving kinds never touches assignment.
2. On a staging deploy: create what is missing
Tick On a staging deploy, ask the QA tool to create missing automation in the same editor. It is off by default, because it lets the staging credential start generation jobs. Then:
- The devops pipeline calls the staging callback, as today. GAOS plans the run of the repository's kind.
- On a new commit only, GAOS reads the product's QA catalog for planned cases with no automation at the kind's
levels, and plans a create card for each: at most 2 per deploy (
GAOS_E2E_CREATE_MAX) and 4 open per product (GAOS_E2E_CREATE_OPEN). The answer carriescreates. - A case is never created twice. Each of these blocks it: an open card creating it; its spec pull request open (30 days); merged but not yet implemented in the catalog (14 days); closed, or its create card failed (7 days).
- The QA tool writes the spec and waits for a person to approve it in the QA tool. The card ends Done when the spec pull request is open, and its reason says how it will merge.
3. The approved spec merges by itself, then runs
Tick Let the QA tool auto-merge a spec a person approved (off by default; it applies only in the
Working or Complete readiness band). After a person approves a spec in the QA tool (an answer given in the
GAOS Inbox leaves the pull request for a person), the QA tool asks GAOS
(GET /api/v1/products/{id}/spec-auto-merge, QA token) and, when allowed, turns on GitHub's auto-merge
pinned to the exact commit that was approved. It does so only when the automation repository has a ruleset that
lets only the QA tool's account push qa-auto/* branches and a required check from a fixed source;
otherwise it leaves the pull request for a person. GAOS never merges and holds no merge token.
When the spec pull request merges, GAOS plans one run of that case if the merged head is the approved commit, a qa agent is assigned, and the QA catalog shows the case implemented. If the catalog has not caught up yet, the row on the Pull requests page says waiting for the catalog and the run is planned when the result arrives (within 14 days). A merge at another commit is noted on the row and in the activity feed, and its case is not run.
What GitHub must allow first
The QA tool turns auto-merge on only after it has read, through GitHub's API, a ruleset that restricts updates and
deletions of qa-auto/* branches and required checks bound to their source on the base branch. On a
private repository GitHub offers rulesets only on a paid plan (Team, or Pro for a personal account);
on the free plan the API answers "Upgrade to GitHub Pro or make this repository public" and every spec is
left for a person to merge. The QA tool's GitHub account must also be a bot account without admin or maintain rights
on the automation repository: an admin could bypass the rules, so the QA tool refuses one. Until both hold, keep the
auto-merge switch off: GAOS still runs each new case once a person merges its spec.
Spec auto-merge is off by default everywhere. The GAOS switch is off for every product until an admin ticks it, and the QA tool’s QA_SPEC_AUTO_MERGE is unset, which is off. Keep both off for a private automation repository on GitHub’s free plan: without rulesets nothing can be merged safely, so every spec waits for a person.
4. Unit tests: read from the repository’s own CI result
Built in v0.67.0 (D-105, BR-65; design docs/designs/release-b4-unit-tests.md). GAOS runs no test. The repository owner adds one GitHub Actions workflow (the template is below); GitHub runs it on every merge commit in a disposable VM, and GAOS reads the result of that one workflow. A failure becomes a defect that waits for an auto-fix admin before any agent works on it. The feature is off for every product until an auto-fix admin turns it on. Writing missing tests is a later design (docs/designs/release-b4b-unit-create.md).
Two result sources (v0.68.0, D-106). Each product chooses where its result comes from: GitHub Actions (the default: GAOS reads the workflow’s check, the flow below) or Jenkins (the organisation’s Jenkins runs the tests on its own agents and posts the result to GAOS, below). Either way GAOS executes nothing, the defect, the hold, the close on a pass and the notices are the same, and a merge with no result is never a pass. Under either source, tests that need a database or the network must skip under -short before the switch is turned on.
- Turn it on. On the Auto-fix page, open Unit tests (CI) for <product> (auto-fix admins only;
POST /products/{id}/autofix/unit), read its Before you switch this on checklist, and choose where results come from. It needs auto-fix on, a fixer and a triager assigned, a fix-target repository, GitHub and the Brain Town reader (and, for Jenkins, the product’s unit-results credential). You can name another workflow file or check name, extra bases beside the auto-fix base branch (or the default branch), and a daily cap of new unit defects (default 5). First merge the workflow and make sure its run on the base is green. - A merge plants a watch. A pull request of a fix-target repository merged into a unit base gives GAOS its merge commit. For that repository the old agent unit-test card is no longer planned; other repositories and products keep it, as Pull-request agents describes.
- GAOS reads the check. Every 2 minutes, at most 10 merges at a time: the
pushrun of the workflow on that commit and base, and the check run namedunit-testsof that run’s own check suite from thegithub-actionsapp. A check posted by anything else, and every commit status, is ignored. A failure counts only when the run carries the workflow’sunit-tests-totalnotice, so a job that never started (a billing or spending limit) files nothing. - A failure files a held defect. One open unit defect per repository and base (plus one for a failed build), naming at most ten failing tests; a new failing set updates it. Its triage card is born Blocked; only an auto-fix admin can release or cancel it (the cancel closes the defect), and nobody else can close it. The group gets one line.
- After release the usual auto-fix path runs: triage, then a draft fix pull request against the branch whose tests failed. The fix may not change the failing tests’ files, add tests beside them or add
TestMainorinit, and it is never retargeted. - A later green check closes it, or, while its card is still held, marks it (“checks passed at …”) so the admin can close it by cancelling the card.
| The check | What GAOS does |
|---|---|
| success | closes the open unit defects of that base (marks a held one) |
| failure, with the total notice | files or updates the unit defect (a build defect when no test was named) |
| failure, every test name withheld | files nothing; one line to the group |
| failure without the total notice | inconclusive: the workflow did not report (job not started?); a line at most once a day |
| no run 6 hours after the merge | no-ci: is the workflow installed? A line at most once a day |
| cancelled, skipped, timed out, unread, anything else | inconclusive: nothing is filed or closed; never read as a pass |
The workflow the repository owner adds
Merge it through an ordinary reviewed pull request as .github/workflows/unit-tests.yml; GAOS never writes workflow files. Set the repository’s default workflow permissions to read-only and let no other workflow grant checks: write. Verify each pinned action SHA before merging (gh api repos/actions/checkout/commits/<sha> --jq .sha, and the tag’s ref points to it). The go test step holds no secret; a private-module token is used only by go mod download. Tests that need a database or the network are skipped with -short.
name: unit-tests
on:
push:
branches: [develop, staging, main]
pull_request:
permissions:
contents: read
jobs:
unit-tests:
name: unit-tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version-file: go.mod
- name: modules
env:
MODULES_TOKEN: ${{ secrets.MODULES_TOKEN }} # only if private modules are needed
run: |
if [ -n "$MODULES_TOKEN" ]; then
git config --global url."https://x-access-token:${MODULES_TOKEN}@github.com/".insteadOf "https://github.com/"
fi
go mod download
git config --global --unset-all url."https://x-access-token:${MODULES_TOKEN}@github.com/".insteadOf || true
- name: go test
shell: bash
run: |
set +e +o pipefail
go test -short -json ./... > test.json
status=$?
mod=$(go list -m)
# leaf tests only: a parent fails when a subtest fails; keep the deepest names
fails=$(jq -r 'select(.Action=="fail" and .Test!=null) | "\(.Package) \(.Test)"' test.json | sort -u |
awk '{a[NR]=$0} END {for(i=1;i<=NR;i++){leaf=1; for(j=1;j<=NR;j++) if(j!=i && index(a[j], a[i]"/")==1) leaf=0; if(leaf) print a[i]}}')
n=$(printf '%s\n' "$fails" | grep -c . || true)
printf '%s\n' "$fails" | head -n 10 | while read -r pkg test; do
[ -z "$test" ] && continue
dir=${pkg#"$mod"}; dir=${dir#/}; [ -z "$dir" ] && dir=.
file=$(grep -l "func ${test%%/*}(" "$dir"/*_test.go 2>/dev/null | head -n 1 || true)
file=${file#./}
echo "::error file=${file},title=${test}::${pkg} ${test} failed"
done
echo "::notice title=unit-tests-total::${n}"
exit $status
Jenkins posts the result
With Results come from: Jenkins, GAOS reads no GitHub check. The organisation’s Jenkins builds each merge commit of a unit base, runs go test -short on its own agents and posts one result per build. The result finishes that merge’s watch exactly as a GitHub check would: a failure files or updates the held defect, a pass closes it (or marks a held one), and a merge with no result 6 hours after it was merged ends no-ci with a line to the group at most once a day (“no unit-test result from Jenkins on a merge; is the Jenkins stage installed?”). The events a posted result causes are attributed to jenkins:<product>.
The route and the credential. POST /api/v1/products/{id}/unit-results, HTTP Basic with the product’s unit-results credential: a line productId:user:password in the file named by GAOS_UNIT_RESULTS_BASIC_AUTH_FILE (mode 0600, a password of at least 32 characters, made with openssl rand -base64 32). It is checked by the staging callback’s gate but is never the staging credential: neither opens the other route. A credential of another product answers 404; five failures from one address in 5 minutes lock that address out of this route for 5 minutes. An empty file leaves the route off (503 jenkins-off). GAOS_JENKINS_ORIGIN (optional, e.g. https://jenkins.acme.example) is the only origin whose build links the Auto-fix page shows as links.
The body is strict JSON, at most 64 KiB, no unknown field:
{"repo":"acme/route-api","commit":"0123456789abcdef0123456789abcdef01234567","branch":"develop",
"result":"failed","total":2,
"failing":[{"test":"TestPlanRoute/empty_stops","file":"planner/route_test.go"},
{"test":"TestDistance","file":"geo/distance_test.go"}],
"summary":"","runUrl":"https://jenkins.acme.example/job/route-api/job/develop/42/"}
| Field | Rule |
|---|---|
repo | owner/repo, a fix-target repository of the product |
commit | the merge commit, 40 hex |
branch | the branch Jenkins built; it must be the merge’s base |
result | passed, failed (at least one test named) or build-failed (no test named; summary says why) |
total, failing | the failing leaf tests: the count (0 to 100000) and up to 50 named, {"test","file"}; GAOS keeps the first 10 it accepts, and drops a name that is not a Go test, a path that is unsafe, or anything over 512 bytes |
summary | build-failed only; cut to 2 KiB |
runUrl | optional; an https build link, otherwise stored empty (never refused) |
| GAOS answers | Meaning, and what the stage does |
|---|---|
202 {"accepted":true,"outcome":…} | the merge’s watch ended with that outcome; done |
200 {"duplicate":true} | the same result was already recorded (a replayed build); done |
409 no-watch, Retry-After: 60 | GAOS has not seen this merge yet; retry once a minute for 10 minutes |
409 already-finished | a different result was recorded first; it stands, and the group is told once |
409 branch-mismatch, unit-checks-off, not-jenkins | another branch, unit checks off, or the product reads GitHub Actions; not retried |
422 rejected, not-target | the body is wrong, or the repository is not a fix target; not retried |
401, 404 not-found | no or a wrong credential, or another product’s; never retried (each counts toward the lock) |
429 throttled, 502, 503, no answer | retry once a minute for 10 minutes |
A result that arrives within 24 hours after its merge ended no-ci (a long Jenkins queue) is still accepted. Verified on: none yet — the two templates below are checked by reading; the first real run is the check: merge a pull request with a deliberately failing test, see one held card and one group line, then revert it. On that first run, also check that the watch’s commit is the pull request’s merge commit, that the caller’s address GAOS recorded is Jenkins’ public address, that a branch build cannot bind the credential, that a Jenkins account that is not an administrator sees neither Configure nor Replay nor Build on the report job, nor the credential on its folder, and that the report job runs with the Groovy sandbox off and no per-signature approval was added.
The work is split in two, because in a multibranch pipeline every branch builds its own Jenkinsfile and whoever pushes a branch controls it:
- The test stage, in the repository’s Jenkinsfile. It runs on the unit bases only, holds no credential, downloads modules in one container and runs the tests in a second with
--network none, resolves each failing test to its file, and archives four small files. At the very end (post { always }, so it never gates a deploy) it triggers the report job and does not wait. - The report job, defined in Jenkins by an administrator, in no repository. It is the only holder of the credential, stored as Username with password in its folder only, on a
gaos-reportagent restricted to it. It reads the upstream build from the build cause (never a parameter), refuses any upstream that is not exactly<folder>/<repo>/(develop|staging|main), refuses a replayed build, posts the commit the upstream checkout recorded, refuses a symlinked or oversized artifact, and passes the password tocurlon its standard input. It runs with the Groovy sandbox off under a whole-script approval; never add per-signature approvals — they would open these calls to every pipeline on the instance.
Conditions the owner must meet (GAOS cannot check them)
The credential is bound only by the report job (folder-scoped), or, if there is no separate job, is branch-restricted to the unit bases — otherwise anyone who can push a branch the pipeline builds can read it. Run and Replay on the unit-base jobs are restricted to the people trusted to post results. Configure, Replay and Build on the report job, and every credential permission on its folder, are held only by Jenkins administrators. A holder of the credential can post any result for a pending merge of its product; the hold and the admin release bound what a forged failure can do.
// Jenkinsfile (multibranch) — Route Planner (p-9), repository acme/route-api. Verified on: none yet.
// The test stage holds no credential. The image tag matches the `go` line of go.mod.
pipeline {
agent none
options { copyArtifactPermission('gaos-unit-report') }
stages {
// … the organisation's existing stages …
stage('unit tests') {
when { beforeAgent true; anyOf { branch 'develop'; branch 'staging'; branch 'main' } }
agent { label 'docker' } // a node with Docker; both containers share its workspace
steps {
script {
env.UNIT_COMMIT = env.GIT_COMMIT // Groovy, before any test runs (a cross-check only)
def go = docker.image('golang:1.24-bookworm') // matches the go line of go.mod
def goEnv = "export HOME=$WORKSPACE/.home GOCACHE=$WORKSPACE/.cache/go-build GOMODCACHE=$WORKSPACE/.cache/go-mod;"
// Modules, with network. Private modules only: bind the module token here, then remove the rewrite.
go.inside { sh "${goEnv} go mod download" }
// Tests, with no network and no fetch: test code reaches no service.
go.inside('--network none') {
sh("${goEnv} export GOPROXY=off GOFLAGS=-mod=readonly;" + '''
set +e
mkdir -p unit
go test -short -json ./... > unit/test.json 2> unit/test.err
echo $? > unit/status.txt
mod=$(go list -m)
# leaf tests only: a parent fails when a subtest fails; keep the deepest names
sed -n 's/.*"Action":"fail","Package":"\\([^"]*\\)","Test":"\\([^"]*\\)".*/\\1 \\2/p' unit/test.json | sort -u |
awk '{a[NR]=$0} END {for(i=1;i<=NR;i++){leaf=1; for(j=1;j<=NR;j++) if(j!=i && index(a[j], a[i]"/")==1) leaf=0; if(leaf) print a[i]}}' > unit/fails.txt
grep -c . unit/fails.txt > unit/total.txt
: > unit/failing.tsv
head -n 50 unit/fails.txt | while read -r pkg test; do
dir=${pkg#"$mod"}; dir=${dir#/}; [ -z "$dir" ] && dir=.
case "$dir" in /*|*..*) continue;; esac
file=$(grep -l "func ${test%%/*}(" "$dir"/*_test.go 2>/dev/null | head -n 1); file=${file#./}
[ ${#test} -gt 512 ] || [ ${#file} -gt 512 ] && continue
printf '%s\t%s\n' "$test" "$file" >> unit/failing.tsv
done
{ cat unit/test.err; sed -n 's/.*"Action":"build-output".*"Output":"\\(.*\\)"}$/\\1/p' unit/test.json; } | head -c 1800 > unit/summary.txt
exit 0
''')
}
}
archiveArtifacts artifacts: 'unit/status.txt,unit/total.txt,unit/failing.tsv,unit/summary.txt',
followSymlinks: false // a symlink left by test code archives nothing
}
}
}
post {
always { // after every stage: never gates deploy
script {
if (env.UNIT_COMMIT) {
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
build job: 'gaos-unit-report', wait: false,
parameters: [string(name: 'COMMIT', value: env.UNIT_COMMIT)]
}
}
}
}
}
}
// Job "gaos-unit-report" — a Pipeline job an administrator defines in Jenkins, in the folder that holds
// the credential "gaos-p-9" (the product's unit-results credential). Not in any repository. Verified on: none yet.
pipeline {
agent none
parameters { string(name: 'COMMIT', defaultValue: '') }
options { timeout(time: 15, unit: 'MINUTES') }
stages {
stage('report to GAOS') {
steps {
script {
def up = currentBuild.getBuildCauses('org.jenkinsci.plugins.workflow.support.steps.build.BuildUpstreamCause')
if (up.size() != 1) { error('not triggered by a unit-base build') }
def job = up[0].upstreamProject, num = up[0].upstreamBuild.toString()
def branch = job.tokenize('/').last()
// The full path, not any folder ending in route-api.
if (!(job ==~ /^acme\/route-api\/(develop|staging|main)$/)) { error("not a unit-base job: ${job}") }
// The commit the upstream build recorded, and no Replay. this job runs with the
// Groovy sandbox OFF and an administrator approves the WHOLE script once. Never approve these calls
// one signature at a time: that would open them to every pipeline on the instance.
def run = Jenkins.get().getItemByFullName(job)?.getBuildByNumber(num as int)
if (run == null) { error('upstream build not found') }
if (run.getCause(org.jenkinsci.plugins.workflow.cps.replay.ReplayCause) != null) { error('a replayed build is not reported') }
// Exact repository match: normalise scheme, user, host case and a trailing .git; exactly one BuildData.
def norm = { String u -> u.replaceFirst(/^[a-z+]+:\/\//, '').replaceFirst(/^[^@\/]+@/, '').replaceFirst(/:/, '/').replaceFirst(/\.git$/, '').toLowerCase() }
def want = 'github.com/acme/route-api'
def hits = run.getActions(hudson.plugins.git.util.BuildData).findAll { d -> d.remoteUrls.any { u -> norm(u) == want } }
if (hits.size() != 1) { error("expected exactly one checkout of ${want}, found ${hits.size()}") }
def commit = hits[0].lastBuiltRevision?.sha1String
if (!(commit ==~ /[0-9a-f]{40}/)) { error('no recorded commit') }
if (params.COMMIT && params.COMMIT != commit) { error('the COMMIT parameter differs from the recorded commit') }
def runUrl = "${env.JENKINS_URL}${up[0].upstreamUrl}${num}/"
def answer = ''
for (int i = 0; i < 10; i++) {
node('gaos-report') { // label restricted to this job; has jq and curl
deleteDir()
catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
copyArtifacts projectName: job, selector: specific(num), filter: 'unit/*'
withEnv(["U_COMMIT=${commit}", "U_BRANCH=${branch}", "U_RUN=${runUrl}"]) {
sh '''#!/bin/bash
set -e
for f in unit/*; do # no symlink, nothing over 64 KiB
[ -L "$f" ] && { echo "refused: $f is a symlink"; exit 1; }
[ "$(stat -c %s "$f")" -le 65536 ] || { echo "refused: $f is over 64 KiB"; exit 1; }
done
status=$(cat unit/status.txt); n=$(cat unit/total.txt)
jq -R -s 'split("\\n") | map(select(length > 0) | split("\\t") | {test: .[0], file: (.[1] // "")})' \
unit/failing.tsv > failing.json
summary=''
if [ "$status" = 0 ]; then result=passed; n=0; echo '[]' > failing.json
elif [ "$(jq length failing.json)" -gt 0 ]; then result=failed
else result=build-failed; echo '[]' > failing.json; summary=$(cat unit/summary.txt)
fi
jq -n --arg repo acme/route-api --arg commit "$U_COMMIT" --arg branch "$U_BRANCH" \
--arg result "$result" --argjson total "$n" --slurpfile failing failing.json \
--arg summary "$summary" --arg runUrl "$U_RUN" \
'{repo: $repo, commit: $commit, branch: $branch, result: $result, total: $total,
failing: $failing[0], summary: $summary, runUrl: $runUrl}' > body.json
'''
}
withCredentials([usernamePassword(credentialsId: 'gaos-p-9',
usernameVariable: 'GAOS_USER', passwordVariable: 'GAOS_PASS')]) {
answer = sh(returnStdout: true, script: '''#!/bin/bash
cred=$(printf '%s:%s' "$GAOS_USER" "$GAOS_PASS" | sed 's/[\\\\"]/\\\\&/g')
code=$(printf 'user = "%s"\\n' "$cred" |
curl -sS -K - -o answer.json -w '%{http_code}' -H 'Content-Type: application/json' \
--data-binary @body.json 'https://gaos.acme.example/api/v1/products/p-9/unit-results' || true)
err=$(jq -r '.error // ""' answer.json 2>/dev/null || true)
echo "${code:-000} ${err}"
''').trim()
}
}
}
def code = answer.tokenize(' ')[0] ?: '000'
def err = answer.tokenize(' ').size() > 1 ? answer.tokenize(' ')[1] : ''
def again = (code == '409' && err == 'no-watch') || code in ['429', '000', '502', '503']
if (!again) { break }
sleep(time: 60, unit: 'SECONDS') // outside node: no executor is held
}
if (!(answer.startsWith('200') || answer.startsWith('202'))) { unstable("GAOS answered ${answer}") }
}
}
}
}
}
GAOS never writes the Jenkinsfile or the report job. Review of the merged pull request does not guard branch builds; the credential’s scope does.
A GitLab pipeline
With Results come from: GitLab pipeline (D-117), GAOS reads the job named as the check in the newest pipeline that ran the merge request’s last head commit, and on a failure the pipeline’s JUnit report. Every fix-target repository must be on GitLab. The details are on the GitLab page.
Tests that need a database or the network skip under -short
Both sources run go test -short. A unit base whose suite needs a live database, the network or another service is red on every clean merge, and every merge would file a defect. So before the switch is turned on, make each such test skip under -short:
func TestRouteStore(t *testing.T) {
if testing.Short() {
t.Skip("needs a database")
}
// …
}
A package whose TestMain opens the service checks testing.Short() after flag.Parse() and returns m.Run() without opening it. To find the tests to mark, run go test -short ./... once on a machine with no database and no network (for example in a container started with --network none after go mod download): every failure there is a test to mark or a real defect. A build tag (//go:build integration) is an equivalent way to keep such tests out; -short is the documented one because both templates pass it. The Auto-fix page shows the same rule in its Before you switch this on checklist.
Status
| Part | GAOS | QA tool |
|---|---|---|
| 1. Repository kinds | Built (v0.65.0) | Built: kind and GET /api/v1/gaos/capabilities |
| 2. Create on staging | Built (v0.65.0) | Nothing new needed |
| 3. Auto-merge, then run | Built (v0.65.0) | Built, off until QA_SPEC_AUTO_MERGE=on; needs the automation repository's rulesets (a paid GitHub plan for a private repository) and a bot account |
| 4. Unit tests (run) | Built (v0.67.0; Jenkins source v0.68.0), off by default | Nothing: GitHub Actions runs the repository’s own workflow, or the organisation’s Jenkins posts the result |
| 4b. Unit tests (write missing) | Draft design | Needs a separate GitHub identity and an approval in the QA tool |
When something is off
| You see | Why, and what to do |
|---|---|
| No review card for a new pull request | The product is configured and Juno is not assigned. Assign Juno, or press Stop gating. |
The staging callback answers 422 unassigned | No QA agent is assigned. Assign Ember or Flint. |
| A medium review was posted as a comment | The product is not configured, or the author is the review account, or a login could not be read (the reason says comment only). |
| A low review planned no fix | Read the review card's reason; it names the missing condition. |
A fix card is Blocked with review-… | The table above says which check refused it; nothing was written to GitHub. |