Skip to content

drop the feed aliases; fail on any alias or forwarder; add the gitlab golden - #249

Merged
adssib merged 4 commits into
mainfrom
pl-no-aliases
Nov 21, 2026
Merged

adssib merged 4 commits into
mainfrom
pl-no-aliases

Conversation

@adssib

@adssib adssib commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

What this changes

No forwarders, enforced. A follow-up to #247.

  1. import core/extract directly; drop the feed aliases: deleted kinds/notices/feed/extract.go, which kept feed.Entry, feed.Section, feed.Parse, feed.Text, feed.Lines, feed.SplitBy, feed.Date and feed.Codes as aliases of core/extract. Every caller now imports core/extract: the feed kind itself (Reader takes an extract.Entry), providers/{cloudflare,github,google} and their tests, and cmd/new-plugin's notices/feed scaffold. The feed parser's tests moved with the parser, to core/extract/feed_test.go (ParseFeed). Also deleted openStore in kinds/openapi/openapi_test.go, a leftover wrapper that only called kittest.NewMem().
  2. fail on a package-level alias or forwarder: providers/all/aliases_test.go walks every .go file in the module (tests included, testdata/ skipped) and fails on a package-level type alias (type X = …), a var/const that is only another package's symbol (var X = otherpkg.Y), or a func whose body only calls another package's func with its own parameters. A genuine one passes if its doc comment says why with alias-ok: <reason>; none needs it today. A second test checks each shape is caught and the marker lets one through. AGENTS.md's layout rule says so.
  3. add the gitlab rest-api golden: providers/gitlab had a pair test but no golden file. The existing test over the saved, trimmed v18.11.0-ee → v19.0.0-ee spec excerpts now also writes testdata/golden/gitlab-rest-api.json (the 4 Bitbucket import events), with source_url set to the URL GitLab publishes the spec at (as Appwrite's golden does), not the local test server.

The sweep found no other alias, re-export or forwarder (the new test is the sweep: it passes on every file).

Checklist

  • Metadata complete in the registration. Not applicable: no registration changed.
  • Every commit is signed off (git commit -s, DCO)
  • Golden test over a real saved copy of the source: new for gitlab/rest-api; every other golden is byte-identical (git diff origin/main -- '*golden*' shows only the new file)
  • providers/gitlab/testdata/README.md already lists both saved specs (unchanged)
  • One pinned drop test: GitLab's exists (APIEntitiesBadge response-side retyping); unchanged
  • Provider pages: no change needed
  • Provider-specific code only in providers/<provider>/; a kind imports no provider
  • Fetches only through env.Get / core/kit/
  • make check passes locally (go1.27.1)
  • Nothing private

Notes for the reviewer

  • Import paths change (feed.Entry & co. are gone; use extract.Entry & co. from core/extract), so this needs a release after merge. The aliases were added in v0.7.0's layout and nothing outside this module uses them, so a patch release (v0.7.1) is enough; releases are cut by a maintainer.
  • The forwarder check is an AST check, not a type check: it catches the shapes above by syntax (a bare pkg.Name value; a call to pkg.Func(a, b) passing exactly the params). Something cleverer (a wrapper that reorders args) gets past it; review still applies.
  • The GitLab golden's source_url is GitLab's API raw-file URL for the tag (what the adapter fetches in production).

🤖 Generated with Claude Code

adssib and others added 3 commits November 21, 2026 13:43
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: adssib <75389300+adssib@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: adssib <75389300+adssib@users.noreply.github.com>
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 50s —— View job


✅ Ready to merge: the aliases are removed cleanly, the new forwarder check passes on every file, the GitLab golden matches its existing pair test, and everything I ran passes.

Rules

Rule Status Evidence
Metadata in the registration (Rule 1) ✅ n/a No provider.go changed. No hand-kept plugin list came back.
Provider page ✅ n/a No source was added or changed, so no section needs to change.
Golden test and source quote ✅ New providers/gitlab/testdata/golden/gitlab-rest-api.json (4 events) comes from the saved v18.11.0-ee / v19.0.0-ee excerpts that testdata/README.md already lists. No other golden changed. Each event has a source_url, a source_pointer and a source_excerpt.
Drop test ✅ unchanged GitLab's APIEntitiesBadge test is still there.
Kinds and providers kept apart ✅ kinds/notices/feed imports only core/. Cloudflare, GitHub and Google import only core/extract, core/event and kinds/notices/feed.
Fetch only through env ✅ No new net/http. The httptest in rest_api_test.go was already there.
Nothing private (Rule 2) ✅ No secrets or internal names in the code, tests, commits or PR body. The only URL added is GitLab's public spec URL. All 3 commits are signed off.

Bugs

None found. Things I checked:

  • Golden source_url rewrite (rest_api_test.go:115-122): the assertions above it already require every event's SourceURL to be oldURL or newURL, so the map lookup can't silently return "". event.Fingerprint(api, version, changeType, subject, detail) doesn't use the URL, so swapping the URL leaves the fingerprints valid. This follows the same approach as Appwrite's golden.
  • Leftover references: nothing in the repo, including docs, still mentions feed.Entry, feed.Text, feed.Lines, feed.SplitBy, feed.Date, feed.Codes, feed.Parse or feed.Section. The cmd/new-plugin notices/feed scaffold now imports core/extract, and the cmd/new-plugin tests pass with it.
  • TestForwardersCatchesEachShape: it covers type aliases (including type B = int), var/const re-exports and a pure forwarding func. It also checks that the marker, a call with an expression argument and a call to a local func are let through.

Verified

  • go build ./...: OK, no output
  • go vet ./...: OK, no output
  • gofmt -l .: printed nothing
  • go test -race ./...: all packages ok, including providers/all (the new alias test), providers/gitlab (the new golden), core/extract (the moved feed tests) and cmd/new-plugin
  • python3 scripts/leak_guard.py --all: no banned terms (8 hashed terms checked)
  • Searched the repo for the removed feed.* names: no matches

Non-blocking

  • providers/all/aliases_test.go:73 (inline comment): the package name is taken from the last part of the import path, so gopkg.in/yaml.v3 is read as yaml.v3 and a /v2 path as v2. A forwarder to one of those would get past the check. This only causes misses, never false failures, and no such import exists today.
  • rest_api_test.go:115: the variable real shadows Go's built-in real. It's harmless; published would read a little clearer.
  • rest_api_test.go:594: the rewrapped doc comment has one much longer line than the rest. It's only cosmetic.
  • As the PR body says, removing the feed.* names changes import paths, so the next release should mention it. Releases are cut by a maintainer.

Comment thread providers/all/aliases_test.go Outdated
imported := map[string]bool{}
for _, imp := range f.Imports {
path := strings.Trim(imp.Path.Value, `"`)
name := path[strings.LastIndex(path, "/")+1:]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this takes the last path element as the package name, so gopkg.in/yaml.v3 becomes yaml.v3 and a .../v2 module path becomes v2. A forwarder to one of those (var X = yaml.Marshal) would get past the check. It only causes misses, never false failures, and no such import exists today. If you want it tighter, strip a trailing .vN and skip a final /vN element when deriving the name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: adssib <75389300+adssib@users.noreply.github.com>
@adssib
adssib merged commit 6c8a600 into main Nov 21, 2026
4 checks passed
@adssib
adssib deleted the pl-no-aliases branch November 21, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant