Keep the packages this node's compositions declare in the engine's own key, and answer them on the node seat (ADR 0565 clauses 6 and 15, issue 1953)
pacman still reads the controller's mirror because no engine wrote its key: the engine now keeps each handed composition's package resources and, after a pass that handed something new, writes mesh-host_packages.<node> only when the value differs, owed after the growing bound when refused. The manifest declares the state so the grants part creates it. The verb packages answers the key beside the mirror's key for the node and their difference, and with write writes the key again from what was composed. H8's integration test proves the write under the grant the grants part composes. Needs mesh-sdk feat/node-packages (0ef7c0c) for DeclaredPackagesOf and the engine's read of the mirror (go.mod pin left for the lead: the SDK commit is not pushed). Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
This commit is contained in:
@@ -90,6 +90,9 @@ type Env struct {
|
||||
// Data is this node's keys of the engine's state data (novox/hq ADR 0577 clause 1), where each placed module's data
|
||||
// items are kept after a pass that composed something new. Nil keeps none.
|
||||
Data DataStore
|
||||
// Packages is this node's key of the engine's state packages (novox/hq ADR 0565 §6), written after a pass that
|
||||
// handed something new when the packages its compositions declare differ. Nil keeps none.
|
||||
Packages PackagesStore
|
||||
}
|
||||
|
||||
// VaultSecretChanged is the vault's event that a secret changed: a name and its generation, never a value.
|
||||
@@ -161,6 +164,17 @@ type Composer struct {
|
||||
dataSaid string
|
||||
dataScope frombus.Scope
|
||||
dataKept map[string][]byte
|
||||
// pkgs is the package resources of each composition handed, by its composed key, and pkgsComposed whether this run
|
||||
// handed any (ADR 0565 §6); pkgsDue, pkgsTries and pkgsSaid are as the data items' are. Under mu. pkgsKept is what
|
||||
// the node's key of the state packages held when last read or written (pkgsRead), under pkgsWrite.
|
||||
pkgs map[string]delivery.Composed
|
||||
pkgsComposed bool
|
||||
pkgsDue bool
|
||||
pkgsTries int
|
||||
pkgsSaid string
|
||||
pkgsWrite sync.Mutex
|
||||
pkgsKept []byte
|
||||
pkgsRead bool
|
||||
}
|
||||
|
||||
// Pass is how one pass went, as the node-engine's verb compose answers it.
|
||||
@@ -241,7 +255,7 @@ func New(env Env) *Composer {
|
||||
return &Composer{env: env, wants: map[string]delivery.Want{}, placements: map[string]delivery.Placement{}, placementKeys: delivery.NewPlacementKeys(),
|
||||
records: map[string]delivery.NodeRecord{}, inOwn: map[string]bool{}, modules: map[string]delivery.Module{}, values: map[string]map[string]any{},
|
||||
manifests: map[string][]byte{}, archives: map[string][]byte{}, builds: map[string]delivery.BuilderBuild{}, handed: map[string]string{}, sealedOwn: map[string]ownSealed{},
|
||||
asked: make(chan chan Pass, 8)}
|
||||
pkgs: map[string]delivery.Composed{}, asked: make(chan chan Pass, 8)}
|
||||
}
|
||||
|
||||
// ComposeNow asks the composer for a pass now (the node-engine's verb compose, issue 774): the growing bound after a seat
|
||||
@@ -453,6 +467,7 @@ func (c *Composer) Watch(ctx context.Context, _ string) (<-chan agent.Update, er
|
||||
}
|
||||
}
|
||||
c.publishData(ctx)
|
||||
c.publishPackages(ctx)
|
||||
if c.owed.Load() {
|
||||
wait, _ := c.waitNow()
|
||||
c.env.Say(fmt.Sprintf("the node composes again in %s: a read on the bus did not answer", wait))
|
||||
@@ -903,6 +918,7 @@ func (c *Composer) compose(ctx context.Context) []agent.Update {
|
||||
}
|
||||
c.rev++
|
||||
c.handed[key] = dig
|
||||
c.pkgs[key] = packagesOf(comp)
|
||||
out = append(out, agent.Update{Key: key, Value: raw, Revision: c.rev})
|
||||
}
|
||||
for key := range c.handed {
|
||||
@@ -914,12 +930,16 @@ func (c *Composer) compose(ctx context.Context) []agent.Update {
|
||||
if !now[key] {
|
||||
c.rev++
|
||||
delete(c.handed, key)
|
||||
delete(c.pkgs, key)
|
||||
out = append(out, agent.Update{Key: key, Deleted: true, Revision: c.rev})
|
||||
}
|
||||
}
|
||||
pass.Handed = len(out)
|
||||
// The data items are kept again after a pass that handed something new, and after the run's first (ADR 0577 clause 1).
|
||||
c.dataDue = c.dataDue || len(out) > 0 || c.dataKept == nil
|
||||
// And the node's packages after the same passes (ADR 0565 §6): written only when they differ.
|
||||
c.pkgsDue = c.pkgsDue || len(out) > 0 || !c.pkgsComposed
|
||||
c.pkgsComposed = true
|
||||
return out
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user