WORKFLOW · quality-cd

Workflow: golden set with gated updates

A CI workflow that compares agent outputs against committed golden baselines and makes updating a golden an explicit, labelled, human-approved act rather than a silent regeneration.

✓ verified 2026-07-18 · stack: github-actions, github · source

A golden set is a regression suite where the expected output is a committed baseline: run the scenario, compare against the golden, fail on divergence. It catches the subtle degradations that assertion-style tests miss, and its one structural risk is equally subtle: whoever can regenerate the goldens can silently redefine “correct”. The workflow below runs the comparison on every PR and only permits golden updates behind an explicit label, so a baseline change is always a reviewed decision.

.github/workflows/golden-set.yml
name: golden-set
on:
pull_request:
permissions:
contents: read
jobs:
compare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
# Deterministic comparison against committed baselines. The runner
# writes current outputs to evals/golden/current/ and diffs them
# against evals/golden/expected/.
- run: node evals/golden/run.mjs
- name: Diff against the goldens
run: |
if ! diff -ru evals/golden/expected evals/golden/current > golden.diff; then
echo "Golden divergence found:" >&2
cat golden.diff >&2
exit 1
fi
# Changes to the baselines themselves are allowed only when a human has
# put the golden-update label on the PR: an unlabelled PR that touches
# expected/ fails here even if the comparison job is green.
guard-updates:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Require the golden-update label for baseline changes
env:
LABELS: ${{ join(github.event.pull_request.labels.*.name, ' ') }}
run: |
CHANGED=$(git diff --name-only "origin/${{ github.base_ref }}"...HEAD -- evals/golden/expected/)
if [ -n "${CHANGED}" ] && ! echo "${LABELS}" | grep -qw "golden-update"; then
echo "This PR changes golden baselines without the golden-update label:" >&2
echo "${CHANGED}" >&2
echo "Add the label (a human decision) or drop the baseline changes." >&2
exit 1
fi

The runner convention the workflow expects:

evals/golden/run.mjs
// Runs every scenario under evals/golden/scenarios/ and writes its output
// to evals/golden/current/<scenario>.txt. Deterministic by construction:
// no network, fixed seeds, stable ordering. Comparison is the workflow's
// job; this file only produces outputs.
import { readdirSync, mkdirSync, writeFileSync } from 'node:fs';
import { execFileSync } from 'node:child_process';
mkdirSync('evals/golden/current', { recursive: true });
for (const f of readdirSync('evals/golden/scenarios').sort()) {
const out = execFileSync('node', [`evals/golden/scenarios/${f}`], { encoding: 'utf8' });
writeFileSync(`evals/golden/current/${f.replace(/\.mjs$/, '.txt')}`, out);
}

What it does

  • Every PR replays the golden scenarios and diffs current output against the committed baselines; any divergence fails with the diff in the log, which is the review artifact.
  • Baseline updates are a separate, guarded path: a PR touching evals/golden/expected/ without the golden-update label fails regardless of content. Adding the label is the graduated approval: a human saying “this change in behaviour is intended”.
  • The structure is the regression-suite discipline in baseline form: the suite stays near-100% by design and a red run is a signal, not noise (demystifying evals).

Failure modes

  • Non-determinism turns goldens into flakes. Timestamps, ordering, and model calls in scenarios all poison baselines. Keep golden scenarios code-graded and deterministic; anything needing an LLM judge belongs in the judge suite, not here.
  • Exact-match is strict on purpose, and sometimes too strict. Where an output has legitimately volatile fields, normalise them in the runner (strip them before writing) rather than loosening the diff; a tolerance hidden in comparison logic is invisible to reviewers.
  • The label is only as strong as who can apply it. Restrict the golden-update label via repository permissions and CODEOWNERS on evals/golden/expected/; an agent that can label its own PR can approve its own baselines.
  • Golden rot. Baselines nobody has intentionally updated in months may be encoding obsolete behaviour. Review the set when the underlying feature changes, not only when the diff fails.

Verified against the regression-suite framing and code-grader preference at anthropic.com/engineering/demystifying-evals-for-ai-agents; the label-guard pattern against the GitHub Actions pull_request label context, 2026-07-18.