Take a module, converge a node after a preview, and return it to adopted, from the command line and the API (hq ADR 0100)

This commit is contained in:
2026-09-22 17:27:35 +02:00
parent 28894fa5bd
commit 1ea84f8b8f
6 changed files with 683 additions and 39 deletions
+18 -11
View File
@@ -244,17 +244,7 @@ func (r Resolution) compose(with Rendering, owner map[string]string) ([]map[stri
// Once, from every module's listens -- not per module. A module receiving only its own ports
// would write a rule set that closed every other module on the machine. Each module's per-node
// exposure settings override its listens' source first (novox/hq ADR 0046).
exposure := map[string]map[int]string{}
for _, m := range r.Modules {
e, err := Exposure(m, with.Settings[m.Module])
if err != nil {
return nil, err
}
if e != nil {
exposure[m.Module] = e
}
}
rules, err := r.Filtering(with.Generators, with.Ports, exposure)
rules, err := r.Rules(with)
if err != nil {
return nil, err
}
@@ -627,6 +617,23 @@ func (r Resolution) guarded(out []map[string]any, owner map[string]string, with
return ports
}
// Rules is the rule set this node's filter is derived from: every module's listens, what was
// computed for this machine, and each module's per-node exposure. The same answer whether the node
// is adopted or converged — the one loads it as a filter, the other declares it as openings.
func (r Resolution) Rules(with Rendering) ([]Rule, error) {
exposure := map[string]map[int]string{}
for _, m := range r.Modules {
e, err := Exposure(m, with.Settings[m.Module])
if err != nil {
return nil, err
}
if e != nil {
exposure[m.Module] = e
}
}
return r.Filtering(with.Generators, with.Ports, exposure)
}
// Contribution is one module telling the answer to a requirement what it needs from it.
type Contribution struct {
// From is the module that said it, so the provider and a person reading the file can tell