Skip to content

a shape guard for every kind, anchors for living pages - #256

Merged
adssib merged 3 commits into
mainfrom
sh-guards
Nov 21, 2026
Merged

adssib merged 3 commits into
mainfrom
sh-guards

Conversation

@adssib

@adssib adssib commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Stacked on #255 (the openai/models fix): review that one first; this PR's diff is against its branch.

Closes #252 · Closes #253 · Closes #254 · Part of #250

What this changes

A source that changes its layout now fails loudly with a typed error, plugin.ErrShapeChanged, in every kind, instead of reading as "nothing changed" or, worse, as removals. Nothing from a refused read is stored or turned into events.

The shape guard (core/plugin/shape.go). A source's plugin.Source gets a Shape (zero: the kind's defaults). RegisterProvider hands it to the plugin through plugin.Guarded.WithShape and refuses a plugin that doesn't implement it, so every kind runs the guard:

Kind Counted Default ratio
notices (deprecations and end-of-life tables) notices on the page 0.9 (notices.DefaultMinRatio, was the retirements-only ShapeGuard)
notices (feeds) entries in the feed 0.5 (feed.Feed.MinRatio: a feed's window can shrink)
openapi operations in the spec 0.5
changelog (file) release headings in the file 0.9
changelog (JSON) days in the file 0.9
catalog command files / upcoming entries 0.8 / 0.25
apisurface public names 0.5
migrationguide none: one guide per major (guarded by NothingToRead)

A read with fewer than the ratio of the read before fails (compared when the read before had at least plugin.MinItemsCompared = 10), and so does a read with none after one with any. A source can set its own MinRatio, with a comment saying why.

Nothing to read, release after release (#254). Shape.NothingToRead(read []bool) is for whoever runs a versioned source: the newest NothingToReadAfter (default 3) releases in a row with ErrNothingToRead, after one that had something, is ErrShapeChanged (wrapping it, not ErrNothingToRead). A source that has never had anything to read isn't flagged. The hosted ingestion service calls it per source; it's tested here with a moved changelog (release notes) and a migration guide that stops being found.

Anchors (#253). A living source declares one or two entries in provider.go, by hand, each with where it is and the date checked; a read without one fails. Declared and checked on the live pages today (2026-11-21):

Source Anchors
openai/models gpt-4-0613, gpt-3.5-turbo-0301
anthropic/models claude-3-opus-20240229, claude-2.1
google/gemini-models gemini-2.0-flash, embedding-001
google/vertex-model-retirements gemini-1.5-pro-002, text-bison
google/vertex-ai-models (feed) the feed's title
github/actions (feed) the feed's title, Use Case: actions - GitHub Changelog
cloudflare/api (feed) the feed's title, Changelog | API deprecations
salesforce/rest-api versions 20.0, 30.0 (the live page answers 403, so checked on the Wayback Machine's capture of 2026-11-20, which is what the plugin reads when blocked)

Feeds drop their oldest entries, so an entry can't be an anchor; the feed's own title says the URL still serves that feed. kit.Notices gains Has(entry) (retire: a model id; eol: a version or a row label; feed: the feed's title or an entry's title); extract.FeedTitle reads a feed's title.

A living page whose reader finds nothing to read is now ErrShapeChanged too (it was a plain error).

Tests

  • A guard test in every kind with a redesigned, shrunken or moved input: kinds/notices/shape_test.go (renamed column, no table, a feed's lower ratio, anchor gone, anchor checked on a first read), kinds/openapi/shape_test.go, kinds/changelog/shape_test.go (moved and reformatted changelog, JSON changelog, release notes run), kinds/catalog/shape_test.go, kinds/apisurface/shape_test.go, kinds/migrationguide/shape_test.go; core/plugin/shape_test.go and the registry's refusals (no guard, an undated anchor, three anchors, ratio above 1).
  • noticestest.Golden reads every saved page with the registered Shape, so each declared anchor must be on the saved copy too (it is, for all seven); Salesforce's golden test does the same.
  • openai: the renamed-column test now runs on today's page through the registered plugin, plus an anchor-gone case; github: another feed served at the URL fails on the title anchor.
  • Every golden is unchanged. make check passes (go1.27.1).

Checklist

  • Metadata complete in the registration: the only change is Shape on seven sources, and I read the words of each anchor's comment.
  • Every commit is signed off (git commit -s, DCO)
  • Golden test over a real saved copy of the source: Not applicable, no source added; every existing golden unchanged
  • testdata/README.md: Not applicable, no saved file added
  • One pinned drop test: Not applicable, no source added
  • Provider pages: the anchors are in each provider.go, next to the source, with where and when checked
  • Provider-specific code only in providers/<provider>/; a kind imports no provider
  • Fetches only through env.Get / core/kit/
  • make check passes locally (make plugins unchanged: Shape isn't in the list)
  • Nothing private

Notes for the reviewer (calls I made)

  • A plugin built by hand in a test isn't guarded (its *Shape is nil until WithShape). Golden tests read trimmed copies, far smaller than real releases (several trimmed spec and wheel pairs read as "most operations gone"), so turning the guard on for them would have meant rewriting goldens. Registered plugins, which is what the hosted ingestion service runs, are always guarded; each kind has its own guard test.
  • The ratio defaults are per kind (constants in each kind), overridable per source in provider.go. Below 10 items, only "none after some" is checked: a few legitimate removals are a large share of a small list.
  • Anchors are only for living sources; RegisterProvider refuses them on a versioned one.
  • docs/writing-a-plugin.md explains the guard, NothingToRead and anchors; AGENTS.md and docs/how-it-works.md name them.

Related PRs

🤖 Generated with Claude Code

A read that finds far fewer items than the read before, or none, or a
living page without one of its source's anchors, fails with
plugin.ErrShapeChanged: never stored, never read as removals.
Shape.NothingToRead turns a run of releases with nothing to read into
the same signal for whoever runs a versioned source. Anchors declared,
checked on the live pages, for OpenAI, Anthropic, Gemini, Vertex AI,
GitHub Actions, Cloudflare and Salesforce.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: adssib <75389300+adssib@users.noreply.github.com>
@claude

claude Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Claude finished @adssib's task in 1m 46s —— View job


✅ Ready to merge (after #255): the shape guard is sound, every kind implements it, the registry enforces it, all goldens are unchanged, and every check passes locally.

Rules

Rule Status Evidence
Metadata in the registration (Rule 1) ✅ The only registration change is Shape on 7 living sources, each with a comment that says where the anchor is and when it was checked. RegisterProvider now refuses an unguarded plugin, an undated anchor, more than 2 anchors, anchors on a versioned source and a ratio above 1 (core/plugin/provider.go:207, core/plugin/shape.go:352). No hand-kept list has come back.
Provider page ✅ (see non-blocking) No source added. The anchors are only in provider.go.
Golden test + quote ✅ No testdata/ or golden file is touched. noticestest.GoldenFile and Salesforce's golden test now read with the registered Shape, so every declared anchor is shown to be on the saved copy.
Drop test n/a No new source.
Fetch only via env ✅ No net/http, no filesystem. The new code reads only snapshot content already fetched through env.Get.
Kinds import no provider ✅ go test ./providers/all passes. The kind code is generic: per-kind ratios, Has per reader.
Precision over recall ✅ Every guard runs before any event is built (openapi.go:1555, changelog.go:323, json.go:205, commands.go:136, upcoming.go:142, apisurface.go:146, notices.go:113). A refused read returns no events and no snapshot.
contract/fixtures ✅ Untouched.
Nothing private (Rule 2) ✅ The diff, the commit message and the PR body have no credentials, internal names or session links. It says "patch-it's hosted ingestion service" as required. The commit is signed off.

Bugs

None found. What I traced:

  • Registry: check() refuses a plugin that isn't Guarded before the .(Guarded) assertion in RegisterProvider, so that assertion can't panic.
  • CheckCount: it is nil-safe, skips first reads (before <= 0), and still flags "none after some" below MinItemsCompared.
  • Old snapshots: in notices.guard, a last snapshot from an older layout that no longer parses gives before = -1, so no false shape error after openai/models: read the deprecations page's new layout #255.
  • Feeds: Findings now counts entries, not findings, so a feed whose entries aren't findings isn't seen as empty.
  • Upcoming changes: entries() flattens the by-date map, so the count is entries, not dates.
  • extract.FeedTitle: the xml:"title" field only matches a direct child of the root, so an RSS item's title isn't mistaken for the feed's.

Verified

  • go build ./...: no output (ok)
  • go vet ./...: no output (ok)
  • gofmt -l .: printed nothing
  • go test -race ./...: every package ok (exit 0), including providers/all, the 6 new kind shape tests and the providers' goldens with anchors
  • python3 scripts/leak_guard.py --all: no banned terms (8 hashed terms checked)
  • From the PR's file list: no testdata/, golden/ or contract/ file changed.
  • I didn't run make check with PATCH_IT, which needs a patch-it checkout. I also didn't check the anchors on the live pages, so I'm taking the "checked 2026-11-21" dates on trust.

Non-blocking (optional)

  1. A big drop that's real has only one fix. A pair where a changelog really is trimmed at a new major, or a spec really is split, fails on every run. The only fix is a permanently lower MinRatio on the source. A sentence in docs/writing-a-plugin.md on what a maintainer does then (lower the ratio with a comment, or a future one-shot accept) would help whoever handles the first source-health issue.
  2. changelog.Releases (kinds/changelog/parse.go:860) counts Markdown headings when there are any, and RST titles only when there are none. An RST changelog that gains one line like # 1 ... (for example in a code block) would suddenly count 1 and fail the guard. That fails loudly, so it isn't a precision issue, but counting the format that has more headings (max(md, rst)) would avoid it.
  3. Provider pages. AGENTS.md asks a changed source to update its section. The anchors only change when a read fails, not what is read, so a page update isn't strictly needed. A line in each living source's section ("Anchors: … checked 2026-11-21") would still keep the page and provider.go saying the same thing.
  4. Salesforce dates: the comment says the anchors were checked on the Wayback capture of 2026-11-20, while Checked is 2026-11-21. That's consistent if Checked means the day you looked, which is how Anchor.Checked is documented. Just confirming that's intended.

Nice work. The tests for redesigned, shrunken and moved inputs in each kind make the guard easy to trust.

adssib and others added 2 commits November 21, 2026 15:01
Signed-off-by: adssib <75389300+adssib@users.noreply.github.com>
…gs; when a drop is real

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: adssib <75389300+adssib@users.noreply.github.com>
Base automatically changed from sh-openai-models to main November 21, 2026 20:25
@adssib
adssib merged commit ce92db3 into main Nov 21, 2026
4 checks passed
@adssib
adssib deleted the sh-guards branch November 21, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant