Repository navigation
Description
Found while sealing git (#642). git.Resource can be read from a document form it can never be written to.
The asymmetry
UnmarshalJSON and UnmarshalYAML decode {uri, ref, head} and carefully carry ref and HEAD across the rebuild:
ref, head := aux.Ref, aux.HEAD
built, err := discoverResource(r.RuntimeEnvironment(), aux.URI)
built.ref, built.head = ref, headUnmarshalText's doc comment states the intended split outright: "Scalar form: only identity (URI) round-trips. Ref, HEAD, and Remotes remain at zero values; richer round trip uses [Resource.UnmarshalJSON] or [Resource.UnmarshalYAML]."
That richer round trip does not exist. git has no MarshalJSON and no MarshalYAML, so the promoted op.ResourceBase marshalers write the URI alone. Nothing in the tree ever produces the ref/head keys the decoders read.
The contract nobody honors
op.ResourceBase.MarshalJSON's own doc comment anticipates this: "additional fields (cached metadata, domain-specific state) override [ResourceBase.MarshalJSON] with their own representation."
Zero resources override it — verified across all nine providers. Every resource marshals as a bare URI string. So the base documents an extension contract that no implementation uses, and git is the one whose decoder was written as though it did.
Why it is more than adding two methods
git returns receipts (Provider.Clone → NewReceipt(destination)), and a receipt's result is marshaled through the resource. Today that is a URI string, and resolveRecordedResource depends on exactly that:
uri, isString := result.(string)
if !isString {
return nil, false
}Give git an object-form marshaler and its receipts stop satisfying that assertion. The miss is silent — retypeStampedResult swallows it with a bare return, and a resumed run keeps a decoded map instead of a resource. That is the same failure mode #641 fixed on the id side, arriving on the shape side.
So the work is:
MarshalJSON/MarshalYAMLongit's resource, emitting the{uri, ref, head}shape its decoders already accept, withomitemptyso a resource carrying neither stays{"uri": "..."}.resolveRecordedResourceaccepts the object form as well as the bare string, keyed onuri.- A round-trip pin: a
gitresource withrefandheadset survives marshal → unmarshal with both intact. Nothing tests that today, which is why the gap survived.
The wider question this raises
git is the only provider whose decoder assumes a richer form, but it may not be the only one that wants one. pkg and mem carry domain state too. Worth deciding whether the base's documented override contract is real — and if not, deleting the sentence rather than leaving an invitation nobody accepts.
Not folded into #642 (USER, 2026-08-24): that phase seals git and appnet and preserves the existing behavior exactly. This changes a document format and belongs on its own.
Activity
A value in an any slot carries its type, a resource slot records the …
David-Noble-at-work commentedon Nov 9, 2026
star github triage sweep added this issue to Triage: devlore, for the rule it breaks:
no-evidence: no Evidence of completion section