Skip to content

ADR 0017 — CI results by webhook: GitHub and a generic signed shape ​

  • Status: accepted (2026-09-30). Built (2026-09-30): MVP slice 6 (the generic route, SurfaceRoutes::machine, the CI source in the gate), slice 7 (the AG-UI card), slice 8 (the web's card, 2026-09-30) and slice 9 (the GitHub adapter); see Built (slice 6), Built (slice 7) and Built (slice 9). The web draws the card as web/README.md says (mvp.md). Uses the inbox of ADR 0016; feeds the gate of ADR 0018. The wire contract is api/webhooks.md. Amended 2026-09-30 (review of slices 6, 7 and 9): "the first completed report decides" is gone, check_suite is not accepted, the idempotency keys come from the signed content and not from delivery ids, the AG-UI card id is unique per report, and a few limits were added. The text of the Decision and of the Built sections below is kept as it was written; the status note says what replaced what.

Context ​

MVP step 2 ends a job as "a pushed branch plus a CI result card". The agent pushes the branch (adam-coder emits a branch artifact); the CI result is somebody else's fact and reaches the orchestrator from outside. The owner decided on 2026-09-30 to accept both a GitHub adapter (HMAC on the raw body) and a generic signed shape, so that a CI that is not GitHub Actions can report without pretending to be GitHub.

ADR 0002 says quality is decided by an external judge and that a job is never "done" while its checks are red. CI is that judge; this ADR is how its verdict arrives.

Decision ​

A new crate, orch-surface-webhook, implements two inbound surfaces. ORCH_SURFACES gains two names, and the binary gains the Cargo feature surface-webhook, on by default:

Surface nameRouteAuthenticates with
webhook-githubPOST /webhooks/githubX-Hub-Signature-256, HMAC-SHA-256 of the raw body
webhook-genericPOST /webhooks/ciX-Vymalo-Signature-256, HMAC-SHA-256 of "<ts>.<body>"

Both are machine routes (ADR 0016, decision 5): mounted outside the identity layer, never reading X-Auth-Request-Email. Each does the same three things, in this order: check the HMAC on the raw body before any write; normalise the payload to a CiReport; hand it to App::receive, which stores an inbox row and answers 202.

GitHub &ZeroWidthSpace;

  • X-Hub-Signature-256 is checked on the raw body. Missing or bad: 401, and nothing is stored.
  • ping answers 204.
  • check_suite, check_run and workflow_run with action = completed become a CiReport { provider, repo_key, sha, branch, name, conclusion, url, summary }, where repo_key comes from repository.html_url, sha from head_sha, branch from head_branch, and name from app.slug (suite), the check name (run) or the workflow name (workflow run).
  • Any other event answers 202 and is not stored.
  • Idempotency key: github:<X-GitHub-Delivery>.

Generic &ZeroWidthSpace;

  • Headers: X-Vymalo-Delivery (a UUID, the idempotency key); X-Vymalo-Timestamp (Unix seconds, within plus or minus WEBHOOK_GENERIC_MAX_SKEW_SECS); X-Vymalo-Signature-256 (sha256= + hex HMAC(secret, "<ts>.<body>")).
  • Body: {version: 1, repository: <url>, sha: <40 hex>, branch?, name, conclusion, url?, summary?}.
  • The signed timestamp bounds replay; the delivery id makes a replay inside the window harmless.
  • The full contract, with a worked signature, is api/webhooks.md.

Common rules &ZeroWidthSpace;

  • Conclusions are a closed enum (ADR 0004). success, neutral and skipped pass; everything else fails.
  • Which reports count. When CiPolicy.required (a list of check names, from the target's gate.ci.required) is set, only reports with those names count and all of them must pass. Otherwise the first completed report decides. Every report gets a card in the chat, counted or not.
  • Matching is by watch, not by branch. A report is applied to the thread that holds Watch { ci:<repo-key>@<sha> }, set when the agent's branch artifact was applied. A report for an unknown key is parked, and applied when the watch appears.
  • Timeout. After ORCH_CI_TIMEOUT_SECS with the required reports missing, the thread goes to Blocked with interrupt reason ci_timeout. It does not spend an attempt; the user can answer, or cancel.
  • Secrets. WEBHOOK_GITHUB_SECRETS and WEBHOOK_GENERIC_SECRETS each hold at most two comma-separated secrets, so a secret can be rotated without a gap: a signature is good if either matches. A secret variable is required when its surface is mounted; otherwise the process exits 78 (ConfigError), as for an ORCH_SURFACES name without its feature.
  • Body limits. 5 MiB for GitHub, 256 KiB for generic; over the limit answers 413.

Configuration &ZeroWidthSpace;

VariableDefaultMeaning
ORCH_SURFACESaguiadd webhook-github and/or webhook-generic to mount them
WEBHOOK_GITHUB_SECRETSnoneone or two comma-separated secrets; required with webhook-github
WEBHOOK_GENERIC_SECRETSnoneone or two comma-separated secrets; required with webhook-generic
WEBHOOK_GENERIC_MAX_SKEW_SECS300accepted difference between X-Vymalo-Timestamp and the clock
ORCH_CI_TIMEOUT_SECS3600how long a job waits for CI before Blocked (ci_timeout); a target's gate.ci.timeoutSecs overrides it
INBOX_PARKED_TTL_SECS86400how long an unmatched report waits (ADR 0016)

One deployment-wide secret per surface, with rotation, is the default chosen; per-repository secrets are not part of this decision.

Diagrams &ZeroWidthSpace;

The path of a report, including one that beats its watch (parked, then re-armed):

mermaid
sequenceDiagram
  participant CI as CI system
  participant E as Edge (Caddy, oauth2-proxy)
  participant S as orch-surface-webhook
  participant DB as Postgres
  participant W as InboxWorker
  participant A as App and transition (pure)
  CI->>E: POST /webhooks/ci or /webhooks/github
  E->>S: passes /webhooks/*, strips X-Auth-Request-Email
  S->>S: HMAC over the raw body, before any write
  alt bad or missing signature
    S-->>CI: 401, nothing stored
  else valid
    S->>S: normalise to CiReport
    S->>DB: App::receive: INSERT inbox (source, idempotency_key), 202 also for a duplicate
    S-->>CI: 202
  end
  W->>DB: claim row (SKIP LOCKED), resolve correlation through watches
  alt a watch matches
    W->>A: apply(thread, CiReported, key inbox:id)
    A->>DB: ONE txn: state + job (CAS), ci_result and check_result events, row applied
  else no watch yet
    W->>DB: park the row
    Note over A,DB: later, the agent's branch artifact commits Watch{key}
    A->>DB: same txn as that commit: INSERT watches, re-arm parked rows with the key (pending)
    W->>DB: claim the re-armed row, apply as above
  end

The state of one inbox row:

mermaid
stateDiagram-v2
  [*] --> Pending: App receive stores the row
  Pending --> Inflight: claimed (SKIP LOCKED), lease
  Inflight --> Inflight: lease expired, another replica re-claims
  Inflight --> Applied: watch found, Input applied in the thread's commit
  Inflight --> Parked: no watch for the correlation key
  Parked --> Pending: a commit carrying Watch{key} re-arms it, same transaction
  Parked --> Expired: INBOX_PARKED_TTL_SECS elapsed
  Inflight --> Pending: transient error, backoff
  Inflight --> Dead: permanent error, attempts exhausted
  Applied --> [*]
  Expired --> [*]
  Dead --> [*]

Built (slice 6) &ZeroWidthSpace;

2026-09-30. The generic route, SurfaceRoutes::machine, the CI source of the gate and ORCH_CI_TIMEOUT_SECS are built and checked against the code (orchestrator/crates/surface-webhook, api, app, core; the binary). The GitHub route is slice 9 (below). Where the build differs from, or fixes, the text above:

  • The guard is the signature check. SurfaceRoutes::machine(routes, guard) mounts routes outside the identity layer and outside the request timeout, and takes the guard as a required argument, so a machine route cannot be added without one. The webhook's guard is a middleware that reads the body up to the route's limit, checks the headers, the timestamp and the HMAC, and only then hands the handler the verified bytes in a request extension; a handler that finds none refuses. The order is: the three headers (401), the timestamp is plain digits and within the skew (401), the body within 256 KiB (413), the HMAC (401). Nothing is written before the HMAC is good, and the handler cannot be reached without it.
  • The clock is the application's. The skew is judged against App's injected clock, so a test that holds the clock sees the same window the route does.
  • Delivery ids are UUIDs. X-Vymalo-Delivery must parse as a UUID (else 400, after the signature). It is stored in its hyphenated lower-case form, so the two spellings of one UUID are one delivery. The inbox source is generic.
  • The timestamp is [0-9]{1,12}. A sign, a blank or a fraction is a 401. This keeps the signed string "<ts>.<body>" unambiguous (a timestamp with a full stop could trade bytes with the body).
  • The conclusions of the generic body are the eight of api/webhooks.md. The core's enum also has startup_failure (GitHub's workflow_run can say it); slice 9 maps it, the generic body refuses it with a 400.
  • Only http and https links are kept, and a summary is cut to 16 KiB at a character boundary.
  • ORCH_CI_TIMEOUT_SECS is read (default 3600, at least 1) as the deployment's ci.timeout; an AGENTS_FILE entry's gate.ci.timeoutSecs overrides it for that agent. A gate that requires ci while no webhook surface is mounted on a control plane logs a warning at startup; its jobs end Blocked (ci_timeout), never Done.
  • Secrets are required by the role that serves the route. WEBHOOK_GENERIC_SECRETS unset while ORCH_SURFACES names webhook-generic is exit 78 for all and control-plane; a worker serves no routes and does not need it (a value that is set is validated in every role). More than two secrets is exit 78 too. The variable is redacted in --help and in Debug, and the value is never in a message or a log.
  • ping and the GitHub events are slice 9, below.
  • The gate honours ci. pending_reason(Ci) is None; the ci and ci: settings are accepted in a deployment or an AGENTS_FILE entry (never per thread); verifier is still refused until slice 10 (ADR 0018).
  • The core needed no change. ci_result cards, the CI source and the CI deadline to Blocked (no attempt spent) were built in slices 2 and 5; the slice's end-to-end tests (orch-e2e webhook.rs, both stores, a clock the test holds) drive them through the real route: a report that beats its watch is parked, matched and the job done; a red report reworks with the report in the findings, and a report about the old commit changes nothing; with no report the deadline blocks the thread; a refused delivery changes nothing.
  • Reproducing the vectors. The known-answer vectors are in api/webhooks.md and in the unit tests of signature.rs.

Built (slice 7) &ZeroWidthSpace;

2026-09-30. Every ci_result event is the AG-UI activity vymalo.ci (orch-agui-projection, api/agui.md); the TODO of slice 3 is gone.

  • The id is ci-<sha>-<name>, not per attempt. The text above leaves the id to the slice. A report is about a commit and a check, so its id depends on those and on nothing the projector has folded: the same log gives the same ids to every viewer and replay, a check that runs again on the same commit replaces its card (replace: true), and a report about the old commit (which the gate ignores) is a card of its own. (Superseded on 2026-09-30, see the status note: the id is now ci-<provider>-<sha>-<name>-<seq> and nothing is replaced.) A per-attempt id would have tied the card to the fold state, and a late report about attempt 1's commit would have landed on attempt 2's card.
  • The content is the report plus what a renderer would otherwise have to compute: passed (from the closed conclusion enum), shortSha. name, branch and summary are untrusted text; url is passed on only when it is http(s) (checked again in the projection: the log is data).
  • Golden ci (ci.events.json, ci.agui.json, run-ci, connect-ci, and the reference client's expectations): the fake agent's verify-ci, a red ci/build for the first commit, a green one for the second. The web's mock replays it (verify-ci), and the web renders the card (slice 8).

Built (slice 9) &ZeroWidthSpace;

2026-09-30. POST /webhooks/github (ORCH_SURFACES name webhook-github, secret WEBHOOK_GITHUB_SECRETS, same feature surface-webhook) is built; contract in api/webhooks.md.

  • ping answers 204, as this ADR says. (The slice's brief said 200; the ADR and the contract page say 204, the ADR wins, and GitHub accepts any 2xx.) ping is not parsed.
  • Order and codes. The guard checks the signature header (401), the size (413, 5 MiB) and the HMAC (401) before anything else; the handler then needs X-GitHub-Event (400 without) and answers: ping 204; the three events with action = completed are stored under github:<X-GitHub-Delivery> and 202 (a delivery id is required for those, 400 without); every other event or action is 202 and not stored, and not parsed, so GitHub neither retries nor flags them.
  • What summary, url and name are per event is fixed (table in api/webhooks.md): a check suite has a name (app.slug) but neither link nor summary; a check run has its html_url and output.summary; a workflow run has its html_url and a name that may be null (then workflow). startup_failure is kept as a conclusion of its own (it fails); anything else outside the closed list, and null, is failure.
  • The fixtures are synthetic, not recorded. No real delivery was available, so the payloads in crates/surface-webhook/testdata/github were written by hand after the documented schemas and say so (their README). What the docs do say was read on 2026-09-30 and is marked in the Verified section below; what they do not (the members of check_suite and check_run payloads) stays unverified until a real delivery replaces a fixture.
  • Dev stack. mock-ci (dev/mock-ci, alpine with git, curl and openssl, pinned by tag and digest) polls git ls-remote on git-server for agent/* and posts a signed check_suite through the edge (success, or failure when the commit message contains CI_FAIL; MOCK_CI_SHAPE=generic for the generic body); its delivery ids are derived from repository and commit, so a restart sends repeats, not new reports. The coder is gated on CI (gate: {require: [ci]}), and dev/coder-e2e.sh asserts the job's gate and the vymalo.ci card. Not run here: it needs Docker; the Coder E2E workflow is its first run.

Status note (2026-09-30): review fixes &ZeroWidthSpace;

A review of the three slices found that a red commit could pass, that a captured delivery could be replayed, and a few smaller faults. What changed, and which sentence above it replaces:

  • A gate that requires ci names its checks. Replaces "Otherwise the first completed report decides" (Common rules) and the "first report decides" path of the core. With no names, the first report for a commit decided, so a skipped report of another check, another workflow's, or a fork's, could pass a red commit. Now ci.required must name at least one check wherever the resolved policy requires ci: the deployment (ORCH_CI_REQUIRED) and every AGENTS_FILE entry are refused at startup (exit 78), a per-thread request that adds ci on a policy with none is a 400 or a tool error, and the core, should such a gate get through, lets nothing pass (the CI deadline blocks the job). Only a named check decides; every other report is a card. (ADR 0018.)
  • ci is honoured only where a report can arrive. A process that serves routes and mounts neither webhook-generic nor webhook-github refuses ci in every layer, per-thread requests included, with "no CI webhook surface is mounted (ORCH_SURFACES)". This replaces the startup warning of slice 6. A worker serves no routes and cannot tell.
  • check_suite is dropped from the GitHub adapter. A suite is named by its app (github-actions), so every check of that app would have the same name and none could be required by name. check_run (named by the check) and workflow_run (named by the workflow; a null or blank name is ignored: 202, not stored) remain. Replaces the GitHub list of the Decision and the "three events" of Built (slice 9).
  • A fork's run does not count. A workflow_run whose head_repository is not the repository (or is missing), and a check_run with a pull request whose head repository is not the repository, is acknowledged (202) and not stored. The fork chooses its own workflow names; its commit is not one the agent pushed.
  • Idempotency comes from what is signed. X-GitHub-Delivery and X-Vymalo-Delivery are not signed, so a captured request could be replayed under a new id and stored again. Replaces "Idempotency key: github:<X-GitHub-Delivery>" and "X-Vymalo-Delivery (a UUID, the idempotency key)". GitHub: check_run:<id>:<completed_at> and workflow_run:<id>:<run_attempt>. Generic: the SHA-256 of the signed string "<ts>.<body>", so the same timestamp and body are one delivery. The delivery-id headers are optional and only logged. An event whose signed completed_at (updated_at for a workflow run) is older than WEBHOOK_GITHUB_MAX_AGE_SECS (default 86400) is acknowledged and not stored, so a captured GitHub delivery is not replayable for ever (the generic route already had its skew window).
  • X-GitHub-Event is not signed. It only selects which parser reads the signed body, and the body must be what that parser demands (a check_run header over a workflow_run body is a 400). It cannot make a body mean something else.
  • Reading is bounded. The body buffer is not sized from Content-Length (a declared 5 MiB with no bytes held 5 MiB per connection); it grows with what arrives, up to the limit. Each webhook route gives up on a request after 10 seconds (408), inside the route's guard and not on SurfaceRoutes::machine as a whole (an MCP wait is long). The refusal log is one warn per route per 30 seconds, with the count of the ones held back, and debug for the rest.
  • The AG-UI card id is unique per report (see the note under Built (slice 7)).
  • Secrets are at least 32 bytes, trimmed, and a blank one is nothing. X-GitHub-Event, X-Vymalo-Delivery and X-GitHub-Delivery are never trusted for a decision.
  • Both sides of a match log the same key. When a job's push starts a CI watch, and when a report is received, the watch key (ci:<repository key>@<sha>) is logged at info with the repository key and the short sha, so a mismatch of spelling shows by eye.

Still open: what a real GitHub delivery carries (all fixtures are synthetic; every member read is unverified as listed in the Verified section), and per-repository secrets.

Security notes &ZeroWidthSpace;

  • Verify before any write. The HMAC is over the raw bytes as received, not a re-serialised body. A missing or wrong signature is 401 and touches no table.
  • Constant-time comparison through the HMAC library's verify function; never == on hex.
  • Replay. The generic shape signs a timestamp, rejects one outside the skew window, and is one delivery by its timestamp and body; GitHub's key comes from the signed body and an event older than the maximum age is not stored. A delivery-id header is never a key: it is not signed (status note above).
  • Untrusted text. summary and name come from the outside. They are shown in a card, and they flow into a rework prompt only as quoted, untrusted data (ADR 0018). A report can fail a check or pass it; it cannot start a job, approve a review or merge.
  • Edge. The edge must route /webhooks/* to the orchestrator without an identity header: the compose stand-in uses header_up -X-Auth-Request-Email. Production routing (oauth2-proxy skip_auth_routes) is unverified and checked in slice 6.
  • The GitHub relay. For a local stack, an opt-in relay (smee.io) is a third party that sees the payloads; it is off unless configured and is told to the owner (slice 13).
  • Secrets are SecretString, redacted in Debug, absent from logs.

Consequences &ZeroWidthSpace;

Easier

  • Any CI can report with a small signed POST; GitHub Actions needs only a webhook.
  • A duplicate delivery, an early report and a slow worker are all harmless.
  • The chat shows every report as a card, whether or not it decides the gate.

Harder

  • A report cannot be matched without the agent's branch artifact: a coder that pushes without emitting one leaves reports parked until they expire. The watch key is the commit, not the branch.
  • The orchestrator must be reachable from the CI system (a public route, or a relay). The webhook is inbound.
  • Two secret variables and two body schemas to keep in step with api/webhooks.md.
  • GitHub webhook payloads are assumed to match the REST schemas' field names. Slice 9 meant to settle it with recorded deliveries and could not (none was available): its fixtures are synthetic, and the question is still open (status note of 2026-09-30, Built (slice 9)).

Alternatives considered &ZeroWidthSpace;

  • Polling the checks API. Rejected: it needs an outbound GitHub credential per repository and a poll loop with backoff, ties the orchestrator to one provider, and is slower than a push.
  • Matching a report to a thread by branch name. Rejected: branches are reused and force-pushed; a report for an older commit of the same branch would be applied to a newer attempt. The commit SHA is the identity; a stale SHA is recorded and changes nothing.
  • Applying the report synchronously in the request. Rejected: GitHub's 10 s deadline, CAS conflicts, and no place for a report that arrives before its watch. See ADR 0016.
  • Only a GitHub adapter, or only the generic shape. Rejected by the owner's choice of both: GitHub is the common case and its signature is fixed; the generic shape covers everything else with a body we control.
  • One secret per repository. Not chosen; a deployment-wide secret with rotation is the default. Revisit if a deployment serves mutually distrusting repositories.

Hard to reverse &ZeroWidthSpace;

  • The route paths and the header names (/webhooks/github, /webhooks/ci, X-Vymalo-*): CI configurations elsewhere will hold them.
  • The generic body schema, version: 1, and the signed string "<ts>.<body>". A change is a version: 2 with its own route or negotiation, never an edit.
  • The idempotency key formats (github:<delivery>, the generic delivery UUID).
  • The conclusion enum.

Easy to reverse: limits, the skew window, the timeout and the TTL.

Verified &ZeroWidthSpace;

  • Verified 2026-09-30: X-Hub-Signature-256 is sha256= plus the hex HMAC-SHA-256 of the raw payload, compared in constant time. Source: https://docs.github.com/en/webhooks/using-webhooks/validating-webhook-deliveries.
  • Verified 2026-09-30: the headers X-GitHub-Event and X-GitHub-Delivery, the 25 MB payload cap and the event actions. Source: https://docs.github.com/en/webhooks/webhook-events-and-payloads. (The 25 MB cap is why the GitHub body limit here, 5 MiB, is a choice, not GitHub's.)
  • Verified 2026-09-30: the check run conclusion values are success, failure, neutral, cancelled, skipped, timed_out, action_required, stale (and null while running). Source: https://docs.github.com/en/rest/checks/runs.
  • Verified 2026-09-30 in the REST schemas (check suites, workflow runs): head_sha, head_branch, conclusion, repository.html_url. That the webhook payloads are identical to the REST ones is unverified, and still is after slice 9, whose fixtures are synthetic (status note of 2026-09-30). Whether workflow_run can carry a conclusion outside the list above (for example startup_failure) is unverified; startup_failure is mapped to its own failing conclusion, any other such value fails closed as failure.
  • Verified 2026-09-30 (adam-rs 882e239): adam-coder emits branch {repository, branch, base_branch, commit} and pull_request {…} artifacts, so the watch key can be built from it.
  • Verified 2026-09-30 (slice 9): GitHub's documented signature vector (secret It's a Secret to Everybody, payload Hello, World!, sha256=757107ea0eb2509fc211221cce984b8a37570b6d7586c22c46f4379c8b043e17), the REST fields of a workflow run (html_url, head_sha, head_branch and name nullable, conclusion nullable, no list of values, no startup_failure), and the ping payload (zen, hook_id, hook). Sources: the pages named in api/webhooks.md. Still unverified: the members of the check_suite and check_run webhook payloads beyond the REST schemas, and that GitHub sends startup_failure. The slice's fixtures are synthetic, not recorded deliveries.
  • Verified 2026-09-30 (slice 6), reading the source: verify_slice of digest's Mac checks the length and then compares with subtle's ct_eq. It is constant-time in the tag; the length of a tag is public. (Re-read for the versions the crate now uses, hmac 0.12.1 over digest 0.10.7, digest-0.10.7/src/mac.rs, verify_slice; the crate uses those, the versions the MCP tokens' sha2 0.10 shares, and no longer hmac 0.13.)
  • Verified 2026-09-30: oauth2-proxy has the option --skip-auth-route / skip_auth_routes ("bypass authentication for requests that match the method & path. Format: method=path_regex OR method!=path_regex. For all methods: path_regex OR !=path_regex"). https://oauth2-proxy.github.io/oauth2-proxy/configuration/overview. Unverified: that oauth2-proxy strips a client-supplied X-Auth-Request-Email on a skipped route. It does not matter to the webhooks, which never read it, and the compose edge deletes it (header_up -X-Auth-Request-Email).