Skip to content

fix(star): a sealed resource announces the methods it actually dispatches - #659

Merged
David-Noble-at-work merged 1 commit into
developfrom
generator-inspects-implementation
Aug 25, 2026
Merged

David-Noble-at-work merged 1 commit into
developfrom
generator-inspects-implementation

Conversation

@David-Noble-at-work

Copy link
Copy Markdown
Contributor

Phase 2 of #625. Closes #658.

Sealing a provider silently shrank its dispatchable surface. The generator derived a resource's method
metadata by inspecting the exported type; sealing moves the methods onto the unexported struct, where it
could not see them, so it emitted none:

-		map[string][]string{
-			"Equal":          {"other"},
-			"CanConvertFrom": {"source"},
-			"ConvertFrom":    {"value"},
-		},
+		nil,

Every stage downstream accepted that quietly — nil metadata is legal, parseParameters returns an empty
map, announcedMethods matches nothing. For service (#641) the three lost entries were framework-facing and
nothing noticed. The next provider with an author-facing resource method would have lost it just as quietly,
with a green suite.

Why this is a fix and not a check

No build error is possible. An interface omitting a method its implementation has is well-formed Go. The
interface guard proves the struct satisfies the interface; the converse — that the interface exposes
everything worth dispatching — is not expressible as a type constraint.

An assertion at announce time was considered and rejected: UnmarshalJSON, MarshalYAML and friends are
exported on the struct and legitimately do NOT belong on the interface, so "every exported method must be
declared" would fire falsely on every provider.

So the fix removes the failure instead of reporting it. The emitted metadata is plain strings and never
names a type — only the inspection target was the exported interface, and that was incidental. Inspecting the
implementation makes the metadata describe the struct dispatch actually reflects on, so the two cannot
disagree.

The detection needs no type query

Only an interface has zero receiver methods. So emptiness at the announced name is the signal, and the
implementation's name follows from ruling 3 — the interface takes the headline name, the struct its lowercase
form. A struct with no methods falls back to itself, which is correct either way.

Why before the provider sweep

Otherwise phases 3-6 each inherit the same silent risk and each need a manual "does this resource have
author-facing methods?" review — four chances to miss one, with no signal when you do. It also narrows phase 7
to asserting the shape rather than also policing dispatch.

Verification

service's three entries returned with no hand-editing of *.gen.go — the issue's exit criterion. No
other provider's announcement moved: the metadata shape of all twelve resource announcements is unchanged
(file/gen/any_kind.gen.go stays nil, the rest keep their 2 or 3 entries).

make test 103 ok · make vet darwin/linux/windows · test-scenario · complexity · shell-lint ·
gofmt -l — clean. A second consecutive build runs zero codegen invocations, so the generator change did
not disturb the staleness property.

Also carried: the phase-1 finding that prompted this, and the plan's phases renumbered 1..8 with this inserted
as phase 2.

@David-Noble-at-work David-Noble-at-work self-assigned this Aug 25, 2026
@David-Noble-at-work
David-Noble-at-work merged commit 3270065 into develop Aug 25, 2026
8 checks passed
@David-Noble-at-work
David-Noble-at-work deleted the generator-inspects-implementation branch August 25, 2026 03:17
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.

The generator must derive resource method metadata from the implementation, not the interface

1 participant