Guide

The QA sync API

The contract between GAOS and the QA tools: the REST API GAOS serves so the QA tools can read a product's test catalog and report what they automated and ran, and the two endpoints GAOS calls on the QA tools when an operator presses a sync button. Built in v0.37.0 (D-072).

Placeholders

Every example uses <TOKEN> for a bearer token and <PRODUCT_ID> for a product id such as p-6. Ask the GAOS operator for both. A command line is visible to other users of the machine, so prefer curl -H @header-file with the Authorization line in a file only you can read.

Base URL and authentication

The base URL is https://gaos.example.org/api/v1. Every request carries Authorization: Bearer <TOKEN> and every body is a JSON object. A token looks like gaos_ followed by 64 hexadecimal characters. There are two scopes. The qa token reads a product's catalog, reports results and creates new cases. The admin token does all of that and also imports and seeds, and may force a stale result. A qa token reaches only the products the operator listed for it: any other product answers 404, never 403.

bash
curl -sS -H @header-file https://gaos.example.org/api/v1/products
# header-file holds one line:  Authorization: Bearer <TOKEN>

The API fails closed. When no token is configured every route answers 503; when two tokens are equal the API is disabled. A request that reaches GAOS through the operator's browser path (/app) answers 404. A token is never echoed in a response.

Limits, errors and status codes

A request carries at most 200 items and 1 MiB. Over either bound the answer is 413 and nothing is applied. Bodies are decoded strictly: an unknown field, a second JSON value after the first or a body that is not JSON is 400. Each token may have one write in flight; a second concurrent write answers 429 with Retry-After: 2, and reads are never blocked. A write that changes nothing answers 200 and counts the items unchanged. Every error has the same shape:

json
{"error":"not-found","reason":"no such product"}
StatusMeaning
200Done. Per-item refusals are in rejected, not in the status.
400Malformed JSON, an unknown field, a bad query, or a secret-shaped string in the body (secret-in-body, nothing written).
401No token, or a wrong one.
403A valid qa token on an admin route, or force without the admin token.
404No such route or product, or a product outside the qa token's scope.
409On the seed: product-exists-unseeded or replay.
413More than 200 items, or a body over 1 MiB.
422On the seed: not-ready, with the list of what is missing.
429Another write by this token is still running.
503api-disabled: no token is configured.

The calls GAOS serves

Seven routes: five the qa token may call (two reads, then creating cases and reporting results) and two only the admin token may call. Each example shows the request; the answer is described under it.

GET /products

Lists the products this token reaches, as {"products":[{"id","name","repo"}]}. A qa token sees only the products the operator scoped to it; if none, the list is empty.

bash
curl -sS -H @header-file https://gaos.example.org/api/v1/products

GET /products/{id}/qa/summary

Totals for the product, a roll-up per epic, the epics that are regressed (an epic with a failing case), the cases that need a decision (a script exists for a case GAOS has parked), the epics with no board card (noCard), the state of the last pull and push, and catHead, the product's catalog revision.

bash
curl -sS -H @header-file https://gaos.example.org/api/v1/products/<PRODUCT_ID>/qa/summary

GET /products/{id}/qa/cases

The catalog's cases, oldest change first. after is a revision (default 0), limit is 1 to 200 (default 100), and epic filters to one epic code of 2 to 8 capital letters. The answer is {"items":[…],"next":n|null,"catHead":n}. next is the last item's revision when the page was full and null when it was the last page, so a loop that passes after=next until next is null sees every case exactly once. A case that changes moves to the end of the feed. Each case carries the derived, output-only status: automated when it is planned and implemented, otherwise its decision.

bash
curl -sS -H @header-file \
  "https://gaos.example.org/api/v1/products/<PRODUCT_ID>/qa/cases?after=0&limit=100&epic=AUTH"
json
{"caseId":"TC-AUTH-001","epic":"AUTH","module":"A13","features":["A13.03"],
 "userStory":"US-AUTH-01","scenario":"Given…","polarity":"-","level":"GQL","pri":"P0",
 "decision":"planned","reason":"","status":"automated",
 "implemented":true,"spec":"tests/api/graphql/user/login.spec.ts",
 "result":"pass","runAt":1763000000,"runRef":"run-1","catRev":12}

POST /products/{id}/qa/cases

Create-only. Takes {"source","epics":[…],"cases":[…]} and answers {"created","unchanged","rejected":[{"caseId","reason"}],"epicsAdded","cardsAdded","cardsDeferred","catHead"}. A new caseId is created if it validates and has decision: "planned", an empty reason, no result, runAt or runRef, and an id whose middle part equals its epic (TC-AUTH-001 belongs to AUTH). It may carry implemented and spec. An existing case with identical planning fields is unchanged; with different ones it is refused exists-differs and is not changed. Nothing is ever deleted.

Refusal codeWhy
decision-not-allowedThe decision is not planned, or a reason is given: the QA side may not park or retire a case.
use-resultsresult, runAt or runRef is set; report runs on the results route.
bad-case-epicThe id's middle part is not the case's epic.
exists-differsThe case exists with different planning fields. GAOS owns them.
case-limitThe product already holds 5,000 cases.
epic-limitMore than 5 new epics in this request, or the product already has 100.
other bad-… codesA field outside its vocabulary or pattern, such as bad-case-id, bad-level, bad-spec or empty-scenario.

Epics and cards. A case whose epic GAOS does not know creates it; the epics array supplies code, title, service, source and module, and is read only for a code that does not exist yet. For each new epic GAOS adds one card to the product's board, titled Automate: <title>, and the card is always born BLOCKED: only an operator can release it, and nothing the QA tools send ever moves a task. With no workflow, or while the operator is replaying history, the epic is recorded and no card is made; cardsDeferred says no-workflow or replay. Every text field is screened for secrets and stripped of backticks, angle brackets and line breaks.

bash
curl -sS -X POST -H @header-file -H "Content-Type: application/json" \
  https://gaos.example.org/api/v1/products/<PRODUCT_ID>/qa/cases \
  -d '{"source":"qa-automation-tools",
       "epics":[{"code":"AUTH","title":"Authentication","service":"his-backend",
                 "source":"docs/test-catalog/his-backend/auth.md","module":"A13"}],
       "cases":[{"caseId":"TC-AUTH-001","epic":"AUTH","module":"A13","features":["A13.03"],
                 "userStory":"US-AUTH-01","scenario":"Given a user, when they sign in, then they see home",
                 "polarity":"+","level":"GQL","pri":"P0","decision":"planned","reason":"",
                 "implemented":true,"spec":"tests/api/graphql/user/login.spec.ts"}]}'

POST /products/{id}/qa/results

Reports what the QA tools automated and ran. Takes {"source","force"?,"items":[…]}; each item is {"caseId", "implemented"?, "spec"?, "result"?, "runAt"?, "runRef"?} and a field left out is left untouched. It answers {"applied","unchanged","rejected":[{"caseId","reason"}],"catHead"}. Valid items apply and invalid ones come back in rejected. implemented and spec describe the script, and the last write wins. result (pass, fail or skipped), runAt (unix seconds) and runRef are one run record and obey these rules.

ReasonWhen
run-incompleteThe item writes result or runRef without runAt. A run record always carries its time.
staleThe stored runAt is greater: the newest run wins. An equal runAt with equal fields is unchanged.
futurerunAt is more than 300 seconds ahead of GAOS's clock. A millisecond timestamp lands here.
unknown-caseThe case does not exist. Create it first.
bad-result, bad-spec, bad-run-refA value outside its vocabulary: spec is relative, with no leading slash and no ..; runRef is printable ASCII up to 120 bytes.

An item that names a planning field such as decision fails the whole request with 400. force: true skips the stale rule, to repair a bad timestamp already stored, and needs the admin token (403 otherwise).

bash
curl -sS -X POST -H @header-file -H "Content-Type: application/json" \
  https://gaos.example.org/api/v1/products/<PRODUCT_ID>/qa/results \
  -d '{"source":"qa-automation-tools",
       "items":[{"caseId":"TC-AUTH-001","implemented":true,
                 "spec":"tests/api/graphql/user/login.spec.ts",
                 "result":"pass","runAt":1763000000,"runRef":"run-1"}]}'

POST /products/{id}/qa/catalog (admin)

Imports epics and the planning half of cases, the only way to change a case that exists. Takes {"seed"?,"epics":[…],"cases":[…]} and answers {"created","updated","unchanged","rejected","catHead"}. It never writes the automation half of an existing case; with "seed": true a case that does not exist yet is created with the implemented and spec it carries.

bash
curl -sS -X POST -H @header-file -H "Content-Type: application/json" \
  https://gaos.example.org/api/v1/products/<PRODUCT_ID>/qa/catalog \
  -d '{"cases":[ /* planning fields, as in the case above */ ]}'

POST /seed/product (admin)

Creates or adopts a product from a seed document: the BRD, stories, Blueprint policies, epics and a workflow. It is idempotent, screens every text field for secrets, refuses a product below the readiness floor (422 not-ready) or a same-named product it did not make (409 product-exists-unseeded), and never clears the design gate. The operator normally runs it from a script on the GAOS host.

bash
curl -sS -X POST -H @header-file -H "Content-Type: application/json" \
  https://gaos.example.org/api/v1/seed/product -d @product.json

The inbox: asking the operator, and answering

A client can put a question in the operator's Needs you inbox, read the decision back, and — since v0.43.0 — answer the question itself, for example from a button on the QA tool's history page (D-083, BR-57). Every answer records where it came from, whoever gave it. A client reads and answers only the items it asked; any other item is 404.

Clients and their source

A client is a token with a name, a kind and an origin. The qa token is the client qa-tools, kind qa-tool, origin GAOS_QA_ORIGIN (or the host of GAOS_QA_URL when that is a name rather than an IP). The admin token asks as the QA tool and may read any item, but never answers. Further clients are lines of the file GAOS_API_CLIENTS_FILE; such a client reaches the routes of its capabilities on its own products: the three inbox routes with inbox (the default), and the external tasks API with tasks (v0.61.0). The source of an answer is built by GAOS from the token, never from the body:

Answered bykindclientoriginactor
The operator, in GAOSgaosback-officethe deployment's labeloperator (the account is kept in GAOS)
The QA toolqa-toolqa-toolsGAOS_QA_ORIGINthe actor.username it sent
A client from the clients fileits kindits nameits originthe actor.username it sent

The origin is the client's registered host, not the address a call came from. The actor is a handle the client reports and GAOS does not verify; it is stored for as long as the event, so send a handle, not an email. It may not be operator or a back-office account.

POST /products/{id}/inbox

Asks the operator. Body: {"externalId","question","context"?,"options"?,"expiresInHours"?,"title"?} — the id is 1 to 80 of A-Z a-z 0-9 . _ : - and starts with a letter or digit; the question is at most 500 characters, the context 4000, the title 120; 2 or 3 options (label up to 60, description up to 200), or none for Approve / Reject / Needs changes; 1 to 720 hours, 168 by default. A new item answers 201, the same id again answers 200 with the item as it is now and writes nothing, and an id another client already uses answers 409 id-taken — choose another; it is never transient. Each client may hold 200 open items per product.

bash
curl -sS -X POST -H @header-file -H "Content-Type: application/json" \
  https://gaos.example.org/api/v1/products/<PRODUCT_ID>/inbox \
  -d '{"externalId":"run-42:case-7","question":"Quarantine these 3 specs?","title":"Quarantine"}'

GET /products/{id}/inbox/{externalId}

Reads the item. status is open, answered or expired; choice 4 means the answerer's own words, with no optionLabel. source is always present: null while open, after an expiry, and for an answer given before v0.43.0.

json
{"externalId":"run-42:case-7","status":"answered","choice":1,"optionLabel":"Approve",
 "askedAt":1763000000,"answeredAt":1763000900,"expiresAt":1763604800,
 "source":{"kind":"qa-tool","client":"qa-tools","origin":"qa.example.org","actor":"ardi"}}

POST /products/{id}/inbox/{externalId}/answer

Answers an item the caller asked. Body: {"choice","text"?,"actor":{"username","display"?}}. choice is 1 to the number of options offered, or 4 with text as the answer; with 1 to 3, text is an optional note. text is at most 4000 characters, actor.username 1 to 64 of A-Z a-z 0-9 . _ @ + -, actor.display at most 64 characters and not stored. Every string is screened for secrets, before and after it is cleaned. The first answer wins, from wherever it came.

bash
curl -sS -X POST -H @header-file -H "Content-Type: application/json" \
  https://gaos.example.org/api/v1/products/<PRODUCT_ID>/inbox/run-42:case-7/answer \
  -d '{"choice":1,"actor":{"username":"ardi"}}'
StatusBodyWhen
200the GET body, with sourcethis call answered it — or it repeats this client's first answer exactly (same choice, text and username), and nothing is written
409already_answered, a reason naming the first answer, and the GET bodysomebody answered first: the operator, or this client with a different answer
410expired and the GET bodythe item passed its deadline
404not-foundno such item, a product outside the token's scope, or an item another client asked
422bad-choice or bad-texta choice that was not offered, 4 without words, or text over 4000 characters
400bad-actor, secret-in-body or bad-jsona missing or malformed username, one naming the operator, a secret, an unknown field
403forbiddenthe admin token: it is not a client; answer in the back office
429write-in-flightthis token's previous write is still running — for the qa token, that includes a results or cases push; retry after Retry-After

What the QA tool must do with the answer

Record an answer as given only on 200. On 409 or 410, adopt the item in the body — that is the decision of record. GAOS still sends every decision on the QA tool's own items to POST /api/v1/gaos/inbox-answer, including the QA tool's own answers, and it may arrive before the 200; it carries the same decision and no source, so take source from the 200 or from GET. A decision is the operator's only when source.kind is gaos. Any other client is not pushed to: it polls GET.

Adding a client

A client is a line of GAOS_API_CLIENTS_FILE and a token file, not code. The line format, every rule and refusal, and a step-by-step tutorial for a new client are in Webhooks and external clients; how the pieces fit is in How integration works.

Who owns which field

Every field of a case has one writer, so there is no silent loser (BR-51). Inside the automation half the newest run wins.

HalfFieldsWritten by
Planning (GAOS)caseId, epic, module, features, userStory, scenario, polarity, level, pri, decision, reasonThe admin catalog route and the seed. The qa token may set them once, when it creates a case that does not exist.
Automation (QA tools)implemented, spec, and the run record result, runAt, runRefThe results route, and GAOS's pull.

The vocabularies are closed: polarity + or -; level API, GQL, WEB, E2E or MOB (a mobile-app case: listed and counted, never planned for a staging create); pri P0 to P3; decision planned, blocked, manual-only or wont. A reason is required for anything but planned and has the form <category>:<detail>. A case with a script but a decision other than planned is needs decision: GAOS lists it and never flips it.

What GAOS calls on the QA tools

When an operator presses Pull or Push on a product's QA tab, GAOS calls the QA tools' API with its own bearer token. The buttons are disabled, with the reason shown, until the operator configures the QA tools' address and token. The QA tools serve both routes (D-077, which closed OQ-33). GAOS accepts only an https address (or a plain-http address on its private tunnel), never follows a redirect, and treats every answer as untrusted: a page naming another product, a planning field, an unknown field, a cursor over 128 printable ASCII bytes or more than 200 items fails the sync and keeps the stored cursor.

GET /api/v1/gaos/results

GAOS pages through automation facts: ?product=<PRODUCT_ID>&after=<cursor>&limit=200, where the cursor is the opaque next of the previous page. The QA tools answer:

json
{"product":"<PRODUCT_ID>",
 "items":[{"caseId":"TC-AUTH-001","implemented":true,"spec":"…","result":"pass","runAt":1763000000,"runRef":"run-1"}],
 "next":"<opaque>","more":true}

The product echoes the id asked for. Each item goes through the same rules as the results route above, so a stale run is counted and skipped. GAOS reads at most 20 pages per click. An item carries result, runAt and runRef only for a case that has a stored run (the QA tools ingest a Playwright report; runAt is the report's start time), and then always the first two together. A case removed from the automation repository arrives as implemented: false with no script.

POST /api/v1/gaos/catalog

GAOS sends the cases whose revision is above its push cursor, in batches of at most 200, and advances the cursor after each batch the QA tools accept. It stops at the first non-2xx answer.

json
{"product":{"id":"<PRODUCT_ID>","name":"…","repo":"…"},
 "cases":[ /* the case shape above, planning fields */ ],
 "catHead":12}

The QA tools answer {"accepted":n,"rejected":[{"caseId","reason"}]}. A rejected id is shown on the QA tab and is not sent again until its revision changes. Both directions end in the same two store operations, so the QA tools may use either direction or both.