Repository navigation
refactor(file): the resource is a sealed interface named Resource - #624
Merged
Merged
Conversation
This was referenced Aug 23, 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.
Phase 1 of any-entry-claims.md. Closes #617. Feature: #616.
The file provider's resource is now a sealed interface named
Resource.file.Entry(interface)file.Resourcefile.Resource(exported base struct)file.resource(unexported)sealedEntry()sealedResource()EntryKind/EntryKindEntryResourceKind/ResourceKindAnykind="entry"kind="any"file.Any— the unasserted claimTwo changes in one, because they are one thought.
The unasserted claim.
file.Anyasserts existence and nothing else — what a kind-indifferentoperation needs, since a move moves whatever is there and the author should not have to name a kind the
operation does not care about. Its predicate is lstat plus "any taxonomy kind admits": a dangling
symbolic link counts (the link is the entry, and a following stat would wrongly call it absent), and a
FIFO does not (no variant could resolve to it).
Digest/Etagdelegate to the observed kind, so anunasserted claim does not silently lose drift detection while it is unresolved.
The naming. Every other resource-bearing provider names its type
Resource; file named itsinterface
Entry, which made it the one provider a newcomer has to learn an exception for. It is nowResource— an interface rather than a struct, because file has a kind axis — and the base beneath itis the unexported
resource, unnameable and un-hand-buildable outside the package. That also makes filethe template for #625, where the other nine providers adopt the same sealed shape for correctness
reasons.
The generator needed no prompting throughout: a resource type is identified by an exported
func(*op.RuntimeEnvironment, any) (*T, error)constructor, soany.gen.gowas emitted automatically —and the base stays unannounced precisely because it has no such constructor, which is what makes hiding
it possible at all.
The finding — this was expected to be behavior-neutral and was not. Unexporting the base silently
removed every promoted field from the Starlark surface;
TestLintCopyrightcaught it with"Regular" object has no attribute "source_path". The bridge'scollectFieldInfoskipped allunexported fields, anonymous ones included, so an unexported embed took its whole field set out of the
attribute surface.
Fixed at the bridge rather than by re-exporting the base, because the bridge was the thing that was
wrong: the attribute surface should mirror Go's promotion rules, under which
outer.Fieldresolvesthrough an unexported embed. Verified empirically before writing the fix — reflection's read-only flag,
which blocks reads through an unexported NAMED field, is deliberately not set for an anonymous one, so
the promoted value is readable (
CanInterface() == true). Pinned ingo_receiver_test.go.Three consumers outside the package follow the rename (
archive, its test,starcode), and two namedreturns stopped shadowing the new lowercase type. File moves went through
git mv, so history follows.Gate:
make test103 ok / 0 fail;make vetclean under darwin, windows, and linux;gofmt -lclean.