Lesson 17.4 · 4 of 5 · 4 min read · Reviewed 24 Nov 2026
Keeping a golden set fresh
By the end, you can
- Keep a golden set fresh as the product changes.
- Retire and update stale cases.
Sources of staleness
- Policy or product change: labels are now wrong.
- New user behaviour: cases no longer match traffic (input drift, 67.4).
- Fixed failures: some cases always pass now and add little.
- New features: no cases at all.
Routines
| Trigger | Action |
|---|---|
| A user-reported failure | Add it as a case (redacted) |
| A policy or data change | Search for affected labels and update them |
| Monthly | Compare tag mix with live traffic; fill gaps |
| Quarterly | Review cases that always pass; keep a few, retire the rest |
Keep history
Record when a case was added, why, and when its label last changed. When a score moves, you can tell whether the system changed or the test did.
A frozen anchor
Keep a small frozen subset that you don’t edit, except to fix clear mistakes. It lets you compare a model or prompt from six months ago with today on the same ground. Report it separately from the living set.
Key points
- Test sets go stale: policies change, products change, users ask new things.
- Add new failures as cases, update labels when the source of truth changes, and retire cases that no longer apply.
- Keep a small frozen set too, so you can compare scores over long periods.
Refresh a golden set after a change
Apply the upkeep routines to a golden set: update labels hit by a policy change, retire stale cases, and leave the frozen anchor alone.
You will have: A refreshed golden set with a change log, printed as a summary of updated, retired and untouched cases.
Steps
- Read the golden set: each case has a label, the label's source, a frozen flag and how many runs in a row it has passed.
- Complete apply_policy_change so every living case whose label came from 'policy 4.2' swaps '30 days' for '60 days', resets its pass streak and records why in the log.
- Complete retire so living cases that passed more than 50 runs in a row are retired, keeping the two with the longest streaks as guards.
- Never edit frozen cases; print the log.
Done when
- All living cases sourced from policy 4.2 now say 60 days, each with a log entry.
- Frozen cases are unchanged and reported separately.
- The script prints 'updated: 3, retired: 2, frozen untouched: 2'.
Open in the Playground No API key needed.
Starter code (Python)
CASES = [
{"id": "g1", "label": "window is 30 days", "source": "policy 4.2", "frozen": False, "streak": 3},
{"id": "g2", "label": "window is 30 days for shoes", "source": "policy 4.2", "frozen": False, "streak": 80},
{"id": "g3", "label": "sale items: 14 days", "source": "policy 4.5", "frozen": False, "streak": 120},
{"id": "g4", "label": "window is 30 days", "source": "policy 4.2", "frozen": True, "streak": 200},
{"id": "g5", "label": "free return shipping in the UK", "source": "policy 6.1", "frozen": False, "streak": 70},
{"id": "g6", "label": "asks for order number", "source": "spec 2.3", "frozen": False, "streak": 95},
{"id": "g7", "label": "refuses other users' data", "source": "policy 9.0", "frozen": True, "streak": 300},
{"id": "g8", "label": "electronics: 30 days", "source": "policy 4.2", "frozen": False, "streak": 60},
{"id": "g9", "label": "gift cards: no returns", "source": "policy 4.7", "frozen": False, "streak": 55},
]
LOG = []
def apply_policy_change(cases, source, old, new, date):
# TODO: for living (not frozen) cases with this source and old in the label,
# replace old with new and append f"{date} {id}: label '{old}' -> '{new}' ({source} changed)" to LOG.
return 0
def retire(cases, min_streak=50, keep=2):
# TODO: among living cases with streak > min_streak, keep the `keep` longest streaks,
# mark the rest retired (case["retired"] = True) and log it. Return how many were retired.
return 0
updated = apply_policy_change(CASES, "policy 4.2", "30 days", "60 days", "2026-11-24")
retired = retire(CASES)
frozen = sum(1 for c in CASES if c["frozen"])
for line in LOG:
print(line)
print(f"updated: {updated}, retired: {retired}, frozen untouched: {frozen}")
Show a solution
CASES = [
{"id": "g1", "label": "window is 30 days", "source": "policy 4.2", "frozen": False, "streak": 3},
{"id": "g2", "label": "window is 30 days for shoes", "source": "policy 4.2", "frozen": False, "streak": 80},
{"id": "g3", "label": "sale items: 14 days", "source": "policy 4.5", "frozen": False, "streak": 120},
{"id": "g4", "label": "window is 30 days", "source": "policy 4.2", "frozen": True, "streak": 200},
{"id": "g5", "label": "free return shipping in the UK", "source": "policy 6.1", "frozen": False, "streak": 70},
{"id": "g6", "label": "asks for order number", "source": "spec 2.3", "frozen": False, "streak": 95},
{"id": "g7", "label": "refuses other users' data", "source": "policy 9.0", "frozen": True, "streak": 300},
{"id": "g8", "label": "electronics: 30 days", "source": "policy 4.2", "frozen": False, "streak": 60},
{"id": "g9", "label": "gift cards: no returns", "source": "policy 4.7", "frozen": False, "streak": 55},
]
LOG = []
def apply_policy_change(cases, source, old, new, date):
n = 0
for c in cases:
if not c["frozen"] and c["source"] == source and old in c["label"]:
c["label"] = c["label"].replace(old, new)
c["streak"] = 0
LOG.append(f"{date} {c['id']}: label '{old}' -> '{new}' ({source} changed)")
n += 1
return n
def retire(cases, min_streak=50, keep=2):
stale = [c for c in cases if not c["frozen"] and c["streak"] > min_streak]
stale.sort(key=lambda c: c["streak"], reverse=True)
for c in stale[keep:]:
c["retired"] = True
LOG.append(f"{c['id']}: retired after {c['streak']} passing runs")
return len(stale[keep:])
updated = apply_policy_change(CASES, "policy 4.2", "30 days", "60 days", "2026-11-24")
retired = retire(CASES)
frozen = sum(1 for c in CASES if c["frozen"])
for line in LOG:
print(line)
print(f"updated: {updated}, retired: {retired}, frozen untouched: {frozen}")