feat(verification): per-major-version badge data model (#3524 stage 1)#3568
Merged
feat(verification): per-major-version badge data model (#3524 stage 1)#3568
Conversation
Extends agent_verification_badges so an agent can hold parallel
(Spec)/(Live) badges across AdCP minor versions (3.0, 3.1, 4.0…).
The previous PK (agent_url, role) becomes
(agent_url, role, major_version).
Migration 457: adds major_version TEXT NOT NULL with a temporary default
of '3.0' so the backfill is safe, parses existing verified_protocol_version
('X.Y.Z' → 'X.Y'), rebuilds the PK, drops the default so future writes
must specify the version, and adds an index on (role, major_version,
status) for the per-version listings later stages will need.
DB layer: AgentVerificationBadge gains major_version. upsertBadge,
getActiveBadge, revokeBadge, degradeBadge all take a majorVersion
parameter. getBadgesForAgent / bulkGetActiveBadges /
getVerifiedAgentsByRole order by major_version DESC.
New getHighestVersionActiveBadge() powers the legacy /badge/{role}.svg
URL — embedded badges in the wild auto-upgrade to the most recent
version without changing the URL (Q3 of #3524's resolved-decisions
thread).
processAgentBadges() accepts an optional majorVersion (defaults to
DEFAULT_BADGE_MAJOR_VERSION = '3.0' for Stage 1 callers). Existing-badge
lookups and writes are now scoped to that single version — a failing
3.1 run never touches a 3.0 badge and vice versa. This is the
load-bearing isolation property: it's what lets old-version badges
persist while new versions are evaluated independently.
4 new tests cover the version-isolation invariant: only-touch-version,
upsertBadge receives the version, default fallback when callers don't
specify, and membership-lapse only affects the version under test.
No behavior change yet — heartbeat still passes the default. Stage 2
wires per-version fan-out, Stage 3 adds /badge/role/version.svg, Stage
4 splits panel rows by version, Stage 5 reshapes brand.json.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The values stored are MAJOR.MINOR strings ('3.0', '3.1'), not just the
SemVer major number. major_version was misleading. adcp_version
describes exactly what it tracks (the AdCP release this badge was
issued against) and pairs cleanly with verified_protocol_version
(full semver, e.g. '3.0.0', kept as informational metadata).
Mechanical rename across:
- migration 457 column, constraint, and index names
- AgentVerificationBadge type field
- upsertBadge / getActiveBadge / revokeBadge / degradeBadge parameters
- processAgentBadges parameter (adcpVersion) and log fields
- DEFAULT_BADGE_MAJOR_VERSION → DEFAULT_BADGE_ADCP_VERSION
- test mock fields and assertions
- changeset description
No behavior change. 89/89 tests pass, typecheck clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Security review:
- Numeric version sort: ORDER BY adcp_version DESC was a TEXT compare
('10.0' < '3.0'), so when AdCP hits double-digit major or minor
versions getHighestVersionActiveBadge would silently serve a stale
older badge. Switched all four sort sites to
split_part(adcp_version, '.', 1)::int DESC, split_part(...,'.',2)::int
DESC. CHECK constraint guarantees both segments parse.
- Membership lapse is per-agent, not per-version. Previously a 3.0
failing run with lapsed membership only revoked the 3.0 badge — the
3.1 badge (and any other version) kept signaling "AAO Verified" until
its own heartbeat landed 12-24h later. Now all versions revoke
immediately on lapse. Updated the test that codified the buggy
behavior to expect cross-version revocation.
Code review:
- brand.json + registry list enrichment dedupe: roles[] and
verified_roles[] silently grew duplicates the moment Stage 2 writes
parallel-version badges. Both sites now dedupe by role; modes_by_role
uses the highest-version badge per role (Q3 framing).
- Backfill regex guard: ^[1-9][0-9]*\.[0-9]+ rejects leading-zero
majors at the UPDATE so a hypothetical '0.x.y' row can't extract
'0.x' and fail the CHECK constraint at step 5.
- Migration header: documented the ACCESS EXCLUSIVE lock window for
next-reader context.
- Stale comment at the SVG handler: getActiveBadge → getHighestVersion-
ActiveBadge.
New test: partial overlap — agent has media-buy@3.0 and creative@3.1,
a 3.0 run for creative-ad-server issues creative@3.0 without touching
the existing creative@3.1.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5f0bbbe to
57b6f9d
Compare
This was referenced Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stage 1 of #3524 — extends `agent_verification_badges` so an agent can hold parallel `(Spec)` / `(Live)` badges across AdCP minor versions (3.0, 3.1, 4.0…). The previous PK `(agent_url, role)` becomes `(agent_url, role, major_version)`.
No behavior change yet — the heartbeat still passes the default `'3.0'` to `processAgentBadges`. Stage 2 wires per-version fan-out, Stage 3 adds `/badge/{role}/{version}.svg`, Stage 4 splits panel rows by version, Stage 5 reshapes brand.json. This PR is purely the data-model groundwork.
The six WG-decision questions on #3524 were resolved in this comment before any code landed.
What this PR ships
What this PR does NOT change
Test plan
Review focus
🤖 Generated with Claude Code