Answer architecture round 1: one owner keeps a folder's loaded and unloaded names apart, each loaded category is checked against its index entry, addSource returns what it replaced, the manifest cache goes, ErrLoad exits 1, and the docs say what New and Fake now refuse

This commit is contained in:
2026-10-09 19:26:54 +02:00
committed by Lillem4n
parent 642fe3a506
commit c783d4af23
13 changed files with 319 additions and 200 deletions
+15 -1
View File
@@ -20,13 +20,27 @@ type node interface{ isNode() }
// folder is a namespace of named children, built from a directory of JSON files
// and subdirectories. It has no value of its own: descend into a named child by
// dot path; rendering one is an error (see Fake).
// A name stands in children or in unloaded, never both; put and putUnloaded keep it so.
type folder struct {
children map[string]node
unloaded map[string]indexed // the categories here an index names and no call has reached yet
unloaded map[string]*indexed // the categories here an index names and no call has reached yet
}
func (*folder) isNode() {}
func (g *folder) put(name string, n node) {
g.children[name] = n
delete(g.unloaded, name)
}
func (g *folder) putUnloaded(name string, x *indexed) {
delete(g.children, name)
if g.unloaded == nil {
g.unloaded = map[string]*indexed{}
}
g.unloaded[name] = x
}
// choice draws one of its items. cum holds cumulative weights for a weighted
// draw; when nil the choice is uniform and selection is O(1). shared is the set of
// relative dot paths every item carries, counting paths inside a repeated template.