Repository navigation
docs(plan): sealed resources split in two parts; the fragment names the interface - #648
Merged
Merged
Conversation
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.
Rewrites the #625 plan after investigating phase 1. One fact the original asserted is false, and the
investigation turned up a silent failure the change would have converted from latent to live.
The enabling fact was false
The plan claimed — and #625 repeated as "verified 2026-08-23" — that
pkg/op/provider/<p>/gen/*.gen.godeclares the provider's own package, so generated announcements could name unexported types.
go listsays otherwise:
Two import paths, the same package name, different packages. The gen file imports the provider as
providerand can name only its exported identifiers.Ruling 4 — the URI fragment names the interface
Holding to the original ruling that the fragment names the struct would have required an exported
ResourceType() reflect.Typeseam per provider — andreflect.Newon that seam forges a resource,reopening the door the feature exists to close. Giving the fragment to the interface dissolves it: ruling
3 already hands the interface the name the struct gives up, so
typeIDOfis byte-identical and thegenerated files do not change at all.
The receipt-retyping failure this surfaced
Ruling 4 covers the URI. It does not cover the receipt's product-type id — and that turned out to be
a latent fragility rather than a clean invariant.
ReceiptBase.CommitrecordscanonicalIDOf(result), the produced value's dynamic type.ProductTypeByIDresolves it against an index built from every action method's declared resulttype. The two need not agree, and today they agree only by coincidence:
file.Move,Remove,RemoveAll, andBackupalready return theResourceinterface, so they record a concrete id such as*…/file.Regular— which resolves only becausefile.Copyindependently declares*Regularandcontributes the key.
Sealing removes the coincidence. The dynamic type becomes
*…/file.regular, an unexported struct nomethod declares, so the lookup misses — and the miss is silent, because
retypeStampedResult(
pkg/op/recovery_stack.go:647) isif !ok { return }. A resumed run leaves the result as its rawdecoded value, the bare URI string, instead of a resource. No error, no log.
So the change converts a latent fragility into a live silent failure across every provider. Phase 1 fixes
both sides to record the announced identity, and the plan pins it with a resume that asserts the
retyped result — asserting that resume merely succeeds proves nothing against a bare
return.The delta is narrow:
ResultTypeisomitemptyandcanonicalIDOfreturns""for nil, so a methodwith no result omits the field.
file.WalkTreereturnsany, and a reducer returning an int recordsintbefore and after. Only receipts whose result is a provider resource move, and they move by exactlyone character —
result_typeloses the leading*that a pointer return produced.The acceptance criterion is narrowed accordingly: the
resourcessection and URIs stay byte-identical;resource-bearing receipt ids change deliberately and are pinned to their new value.
What the receiver machinery needs
The original plan said "filter on
PkgPath()". That was wrong-headed — enumeration is not the problem.NewMethodcannot consume an interface method at all:reflectgives an interface method a nilFuncand aTypewith no receiver, sodo.Type.In(0)returns the first parameter forEqual(other any)and panics for a no-arg method likeEtag().The change is to split the one field doing two jobs:
receiverTypestores the concrete type (methodenumeration, dispatch, and the
byTypekey, which must matchreflect.TypeOf(value)) plus a storedtype-id string computed once from the interface (the two
typeIDOf(ProviderType()) == typeIDcomparisons that match against an id lifted from a URI). Those consumers sit on adjacent lines and want
opposite things. With the concrete type restored, the promotion and unexported-method problems evaporate
on their own, and
UnpackerByTypeIDstarts working again forfunction,json,mem, andyaml.Dividend: the type id becomes a declared identity instead of one re-derived at each site. Today any Go
rename silently invalidates every saved document.
Ruling 5 — two parts, so the goal is actually reached
Part 1 seals the eight single-resource providers; part 2 converts
file's four variants. The originalwould have left
filea permanent exception in a new direction. It is not merely aesthetic:file'svariants carry zero exported fields, so the forging path fills nothing yet still mints an identity-less
*Regular.Ruling 6 —
kind() <Interface>discriminates the variantsRegularandDirectoryhave identical exported method sets, so as bare interfaces they would bestructurally interchangeable —
r.(Directory)would succeed for a regular file and every kind-honestyguarantee from #616 would evaporate without a single test failing.
kind() Regularandkind() Directoryare different signatures, and a type may declare only one method named
kind, so exclusivity isstructural rather than conventional.
Recorded as open for phase 5: the
Anystruct cannot be namedany— that shadows the predeclaredidentifier for the whole package.
The correctness case is now concrete
The plan previously argued from a struct literal someone might write. No such literal exists outside its
own package anywhere in the tree — checked across all eight. The plan now names the live path:
tryHydrateStruct(pkg/op/convert.go:441) reflectively mints a resource from a dict, producing a valuewith an empty URI that reaches
sm.Disable(name.Name)against the host. Phase 1 pins it red before theseal and green after, so the claim is demonstrated rather than argued.
Housekeeping
Unpackerimplementers share one silentfailure mode and are proved together;
pkgstands alone on consumer surface.file, not nine.ConvertFromreturns the same identity-less value in-package, andneeds its own issue.
Refs #625.