A-376: the bus keeper makes the catalog half's own holder before the first views
Before the catalog half's first views are in (a read refused, or none-yet), the keeper reads the manifest on the trunk of the holder of the seat mesh-catalog from the seat's states modules and manifests (the holder from the seat that places modules) and makes its kept data as any module's, each entry said as ever; every other module waits as A-367 says. Builds: design 47 G A-376 (G-22-lead-answers-2.md) Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -332,8 +332,12 @@ type Keeper struct {
|
||||
// branch has no first view yet, when the keeper plans nothing. Seats are the seat list's definitions, each resolved
|
||||
// with the parts it includes (§537). Again asks every first view of the catalog half again, by hand.
|
||||
Catalog func() (CatalogView, error)
|
||||
Seats func() map[string]seatdef.Definition
|
||||
Again func() error
|
||||
// Holder reads the manifest on the trunk of the holder of the seat mesh-catalog, the catalog half's own source, as the
|
||||
// indexer's first views `modules` and `manifests` give it (design 47 G A-376): what the keeper makes before the
|
||||
// catalog half's first views are in. Nil where nothing reads it; an error while it cannot be read.
|
||||
Holder func() (Accepted, error)
|
||||
Seats func() map[string]seatdef.Definition
|
||||
Again func() error
|
||||
// Act records a hand act through the seat mesh-hand-acts; Warrant reads the router's record of an ask.
|
||||
Act func(what, why, cause string) error
|
||||
Warrant func(askID string) (*oc.Ask, *oc.Warrant, error)
|
||||
@@ -463,6 +467,7 @@ func (k *Keeper) PlanCatalog() error {
|
||||
view, err := k.Catalog()
|
||||
if err != nil {
|
||||
k.setStatus(func(s *Status) { s.FirstView.Asked, s.FirstView.Error = at, err.Error() })
|
||||
k.planHolder()
|
||||
return err
|
||||
}
|
||||
k.mu.Lock()
|
||||
@@ -474,6 +479,7 @@ func (k *Keeper) PlanCatalog() error {
|
||||
k.setStatus(func(s *Status) {
|
||||
s.FirstView.Asked, s.FirstView.Error = at, "the catalog half lists no module yet (none-yet): nothing is planned or orphaned until a revision lists one"
|
||||
})
|
||||
k.planHolder()
|
||||
return nil
|
||||
}
|
||||
k.viewed = true
|
||||
@@ -530,6 +536,21 @@ func (k *Keeper) PlanCatalog() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// planHolder makes the entries of the holder of the seat mesh-catalog before the catalog half's first views are in (design 47
|
||||
// G A-376, which completes A-367): the catalog half's own owner needs its kept data to answer them, so it is read from the
|
||||
// holder's manifest on the trunk and made as Heard makes any module's, each entry said as ever; every other module waits.
|
||||
func (k *Keeper) planHolder() {
|
||||
if k.Holder == nil || k.Viewed() {
|
||||
return
|
||||
}
|
||||
a, err := k.Holder()
|
||||
if err != nil {
|
||||
k.logf("the holder of the seat %s is not read yet, so its kept data is not made before the catalog half's first views: %v", FirstViewOwner, err)
|
||||
return
|
||||
}
|
||||
k.hear(a)
|
||||
}
|
||||
|
||||
// drifts says each drift once (design 47 G §532): kept in the module's key, said again only when the branch or the
|
||||
// settings planned change.
|
||||
func (k *Keeper) drifts(ds []Drift) {
|
||||
@@ -588,6 +609,11 @@ func (k *Keeper) Heard(a Accepted) {
|
||||
k.logf("the entry of %s is heard before the catalog half's first views: nothing is planned until they are in", a.Module)
|
||||
return
|
||||
}
|
||||
k.hear(a)
|
||||
}
|
||||
|
||||
// hear plans one module's entry (Heard, and planHolder before the first views).
|
||||
func (k *Keeper) hear(a Accepted) {
|
||||
held, _, found := k.asked(a.Module)
|
||||
if !found {
|
||||
held = Asked{V: 1, Module: a.Module}
|
||||
|
||||
@@ -575,6 +575,35 @@ func TestTheKeeperMakesWhatAVerdictAsksForAndSaysIt(t *testing.T) {
|
||||
t.Error("the first revision with entries is viewed and plans as before")
|
||||
}
|
||||
}},
|
||||
// A-376: before the first views are in (read refused, or none-yet) the holder of the seat mesh-catalog is made from its
|
||||
// trunk manifest, each entry said as ever; every other module waits.
|
||||
{"before the first views the catalog half's own holder is made and no other module", func(t *testing.T, k *Keeper, bus *fakeBus, out *said) {
|
||||
k.mu.Lock()
|
||||
k.viewed = false
|
||||
k.mu.Unlock()
|
||||
k.Heard(Accepted{Module: "other", Revision: 1, BusState: []catalogue.BusStateEntry{drafts}})
|
||||
k.Holder = func() (Accepted, error) {
|
||||
return Accepted{Module: "idx", BusState: []catalogue.BusStateEntry{drafts}}, nil
|
||||
}
|
||||
for _, view := range []func() (CatalogView, error){
|
||||
func() (CatalogView, error) { return CatalogView{}, errors.New("no first view yet") },
|
||||
func() (CatalogView, error) { return CatalogView{}, nil },
|
||||
} {
|
||||
k.Catalog = view
|
||||
k.PlanCatalog()
|
||||
if _, ok := k.planned("idx"); !ok || fmt.Sprint(out.events) != "[created idx drafts]" {
|
||||
t.Fatalf("planned idx %v, said %v: the holder's entry is made once", ok, out.events)
|
||||
}
|
||||
if _, ok := k.planned("other"); ok || k.Viewed() {
|
||||
t.Errorf("another module is planned or the keeper counts as viewed")
|
||||
}
|
||||
}
|
||||
k.Holder = func() (Accepted, error) { return Accepted{}, errors.New("not read") }
|
||||
k.PlanCatalog() // a holder not read plans nothing and says why in the status
|
||||
if fmt.Sprint(out.events) != "[created idx drafts]" {
|
||||
t.Errorf("said %v", out.events)
|
||||
}
|
||||
}},
|
||||
// §538: a module in no watched branch's newest revision has its plans key deleted, its entries then orphans.
|
||||
{"a module no watched branch lists loses its plan, its entries orphans", func(t *testing.T, k *Keeper, bus *fakeBus, out *said) {
|
||||
k.Catalog = func() (CatalogView, error) {
|
||||
|
||||
Reference in New Issue
Block a user