Repository navigation
Description
Part 1, phase 1 of sealed-provider-resources.md.
One framework change, then the whole shape proved on the cheapest provider.
The framework change
The receiver machinery is written for concrete types, and reflect treats an interface differently in three ways at once:
- The two
PointerTopromotions (pkg/op/helpers.go:258,pkg/op/receiver_type.go:357) yield a pointer to interface, whose method set is empty. Providers announcing method metadata fail loudly at init;file.Any, which announcesnil, fails silently with zero methods. NewMethodcannot consume an interface method at all (pkg/op/method.go:178).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().- Unexported methods become visible —
NumMethodcounts them only for interface types.
Point 2 is why "stop promoting interfaces" is not the fix. Split the one field doing two jobs:
- the concrete
*resourceserves method enumeration, promotion, dispatch, and thebyTypekey (receiver_registry.go:960), which must matchreflect.TypeOf(value); - a stored
typeID string, computed once from the interface at announce time, serves thetypeIDOf(ProviderType()) == typeIDcomparisons atreceiver_registry.go:486and:513, which match an id lifted from a URI.
Those consumers sit on adjacent lines and want opposite things. With the concrete type restored, points 1 and 3 evaporate and UnpackerByTypeID works again for function, json, mem, yaml.
The concrete type is unexported, so it cannot come from the gen file — it is registered from inside the provider package, where pkg/op/provider/file/planspace.go already sets the precedent by naming *resource. The generated announcements do not change at all.
The receipt retyping failure — fix it here
ReceiptBase.Commit records canonicalIDOf(result), the produced value's dynamic type (pkg/op/receipt.go:438). ProductTypeByID resolves it against an index built from every action method's declared result type (receiver_registry.go:542). The two need not agree, and today they agree only by coincidence:
file.Move, Remove, RemoveAll, and Backup already return the Resource interface, so they record a concrete dynamic id such as *…/file.Regular. That resolves because file.Copy independently declares *Regular and contributes the key; *Directory comes from Mkdir, *SymbolicLink from Link.
Sealing removes the coincidence. The dynamic type becomes *…/file.regular — an unexported struct no method declares — so the lookup misses. And the miss is silent, because retypeStampedResult (pkg/op/recovery_stack.go:647) reads:
productType, ok := ReceiverRegistry().ProductTypeByID(s.resultType)
if !ok {
return
}A resumed run leaves the result as its raw decoded value — the bare URI string — instead of a resource. No error, no log.
This is not a bug the change introduces; it is a latent fragility the change converts into a live silent failure across every provider. Fix by recording the announced identity on both sides. Pin it with a resume that asserts the retyped result — asserting that resume merely succeeds proves nothing, since the failure path is a bare return.
The template: service
Zero files outside its own package name the type (confirmed 2026-08-24). Sealed Resource interface, unexported resource struct, constructors unchanged in signature. Resource.Name is a field read 20x in pkg/op/provider/service/provider.go, so the interface gains Name() string. All in-package.
Acceptance
- The
resourcessection and URIs are byte-identical for the same intent. result_typeloses its leading*for resource-bearing receipts and is pinned to the new value. Receipts with no result, or a non-resource result (file.WalkTreereturnsany), are untouched.- The judgment scenario lands here, red first: a dict supplied where a resource slot is expected mints an identity-less resource today via
tryHydrateStruct(pkg/op/convert.go:441); it must fail conversion after. Red before the seal, green after — otherwise the correctness claim is argued rather than demonstrated.
Activity
David-Noble-at-work commentedon Aug 24, 2026
Related: #649 — every provider's
ConvertFrommints an identity-less resource. The seal does not remove those methods (they are in-package), but this phase changes their reachability: after sealing,Convertstep 7'sreflect.New(target)probe yields a pointer-to-interface with an empty method set, soTargetConverterno longer applies to resource slots. Worth confirming that as an observed effect while doing this phase, since it is half the argument in #649.