H-3: the node-engine says composed, running and capabilities-changed on the seat's subjects
Builds: design 47 G §260, §227, §226, §177, §309, §404 Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
@@ -137,6 +137,7 @@ func (c *Composer) writeComposed(ctx context.Context, at *published) (wrote, del
|
||||
}
|
||||
c.pubKept[key] = ComposedEntry{Value: values[key], Revision: rev}
|
||||
wrote++
|
||||
c.saidComposed(key, values[key])
|
||||
}
|
||||
for _, key := range c.pastKeeping() {
|
||||
if err := c.env.ComposedState.Delete(ctx, key); err != nil {
|
||||
@@ -319,3 +320,24 @@ func ranOf(running []engcomp.Composed) map[string]string {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// saidComposed says the event composed for a key just written that holds a module's composition at a fingerprint and was
|
||||
// not refused: the node's own composition and a refusal say nothing.
|
||||
func (c *Composer) saidComposed(key string, value []byte) {
|
||||
if c.env.SayComposed == nil {
|
||||
return
|
||||
}
|
||||
_, module, fp, isNode, err := engcomp.ParseKey(key)
|
||||
if err != nil || isNode {
|
||||
return
|
||||
}
|
||||
comp, err := engcomp.Decode(value)
|
||||
if err != nil || comp.Refused != "" {
|
||||
return
|
||||
}
|
||||
digest, err := engcomp.DigestOf(comp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
c.env.SayComposed(module, fp, digest)
|
||||
}
|
||||
|
||||
@@ -84,6 +84,14 @@ func TestTheNodePublishesItsCompositions(t *testing.T) {
|
||||
state := &fakeComposed{kv: map[string]ComposedEntry{}}
|
||||
env := b.env()
|
||||
env.ComposedState = state
|
||||
// Design 47, *What each step says*: each module composition written says composed, with its fingerprint and digest.
|
||||
var saidMu sync.Mutex
|
||||
var saidComposed []string
|
||||
env.SayComposed = func(module, fingerprint, digest string) {
|
||||
saidMu.Lock()
|
||||
defer saidMu.Unlock()
|
||||
saidComposed = append(saidComposed, module+" "+fingerprint+" "+digest)
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
c := New(env)
|
||||
@@ -136,6 +144,14 @@ func TestTheNodePublishesItsCompositions(t *testing.T) {
|
||||
t.Errorf("the published composition of lemurs: %+v, %v", comp, err)
|
||||
}
|
||||
}
|
||||
if comp, err := engcomp.Decode(state.kv[lemursKey].Value); err == nil {
|
||||
dig, _ := engcomp.DigestOf(comp)
|
||||
saidMu.Lock()
|
||||
if len(saidComposed) != 1 || saidComposed[0] != "lemurs "+fp+" "+dig || dig == "" {
|
||||
t.Errorf("composed said %v, want once for lemurs at %s with its digest %q (the node's own says none)", saidComposed, fp, dig)
|
||||
}
|
||||
saidMu.Unlock()
|
||||
}
|
||||
// A pass that changes nothing writes nothing.
|
||||
setFor(t, &askedWithin, 0)
|
||||
if _, err := c.ComposeNow(ctx); err != nil {
|
||||
|
||||
@@ -118,11 +118,26 @@ type Env struct {
|
||||
// SeatList is the node's reader of the seat list (novox/hq ADR 0636 §1): until the list was read, the composer hands
|
||||
// nothing new of a module whose seats are not all bootstrapped, and keeps what runs of it. Nil gates nothing.
|
||||
SeatList SeatGate
|
||||
// SayComposed says the seat's event composed for a composition of a module written into the composition state at a
|
||||
// fingerprint (design 47, *What each step says*): the module, the fingerprint and the digest of the composition. Nil says
|
||||
// nothing.
|
||||
SayComposed func(module, fingerprint, digest string)
|
||||
// SeatListChanged says the reader's held set changed: the node composes again, so what waited for the list is
|
||||
// handed at the read and not on a timer. Nil hears nothing.
|
||||
SeatListChanged <-chan struct{}
|
||||
}
|
||||
|
||||
// ManifestOf is the digest of the manifest of the build a module runs at fp, from the composer's picture of the catalog half;
|
||||
// "" when the picture holds no such build (the event running names it, so one not known is not said).
|
||||
func (c *Composer) ManifestOf(module, fp string) string {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
if m, ok := c.modules[module]; ok && m.Fp2 == fp {
|
||||
return m.Manifest
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// SeatGate is what the composer asks of the reader of the seat list: whether it may compose a module that claims,
|
||||
// invokes or provides these seats (seatlist.Reader.MayAct).
|
||||
type SeatGate interface {
|
||||
|
||||
Reference in New Issue
Block a user