Ask the packet filter's holder allowed at every compose of the filter

The node-engine stays the one renderer of the filter file: at each compose of
a converged node's filter it asks the holder of node-packet-filter its verb
allowed within the setting compose-ask-bound (10 s) and renders the answer.
When allowed does not answer, or answers what is not its answer, no filter file
is composed: the one loaded is kept as it runs, the holder's module is not held
(an old holder must stay replaceable), and the part withheld is said once in
the journal until an answer comes between. The node hears allowances-changed
on its own node's subject and composes again. The manifest invokes
seat:node-packet-filter.allowed and consumes node-packet-filter.allowances-changed.

Builds: design 08 control-verbs §1, §3, §4, §5, §7, §8; ADR 0683; H-A-305, H-A-307 (1), (2), H-A-314 (3), (5), (7), H-A-315 (2), (6), H-A-321
This commit is contained in:
2026-11-21 22:32:36 +01:00
parent 2a29c458ce
commit dc3765bb7c
18 changed files with 486 additions and 30 deletions
+41 -9
View File
@@ -105,18 +105,40 @@ func (e *UnreadManifestError) Error() string { return e.said }
// Compose is Declaration with the owner of every resource said.
func Compose(r mcat.Resolution, with mcat.Rendering) (mcat.Composed, error) {
return ComposeHolding(r, with, Holding{})
return ComposeHoldingFiltered(r, with, Holding{}, Filter{})
}
// ComposeHolding is Compose for a node that holds modules this pass (Holding): a held module's share of a holder's words
// is what runs (design 47 H, H-A-335, H-A-337).
func ComposeHolding(r mcat.Resolution, with mcat.Rendering, h Holding) (mcat.Composed, error) {
return ComposeHoldingFiltered(r, with, h, Filter{})
}
// Filter is what a compose of the node's packet filter is given beside the derived ports (design 08 control-verbs §1, §4):
// the allowances the holder of node-packet-filter answered its verb allowed, or, when allowed did not answer, why
// (Withheld) and the filter file as it runs (Running, nil when none runs). A withheld allowed composes no filter file: the
// one loaded is kept, its content as it runs, and none is composed where none runs, never one read as "nothing opened"
// (H-A-307 (1)).
type Filter struct {
Allowing Allowing
Withheld string
Running *string
}
// ComposeFiltered is Compose with the filter's allowances, or the filter kept as it runs (Filter).
func ComposeFiltered(r mcat.Resolution, with mcat.Rendering, filter Filter) (mcat.Composed, error) {
return ComposeHoldingFiltered(r, with, Holding{}, filter)
}
// ComposeHoldingFiltered is Compose for a node that holds modules this pass (Holding) and composes its packet filter with
// the allowances or keeps it as it runs (Filter): ComposeHolding and ComposeFiltered at once.
func ComposeHoldingFiltered(r mcat.Resolution, with mcat.Rendering, h Holding, filter Filter) (mcat.Composed, error) {
owner := map[string]string{}
received := map[string]map[string][]mcat.Contribution{}
leftOut := map[string]string{}
var foreseen, unplaced, handedOnly []string
handed := &handedFiles{plans: map[string]mcat.Plan{}}
resources, err := resolutionCompose(r, with, h, owner, received, leftOut, &foreseen, &unplaced, &handedOnly, handed)
resources, err := resolutionCompose(r, with, h, filter, owner, received, leftOut, &foreseen, &unplaced, &handedOnly, handed)
if err != nil {
return mcat.Composed{}, err
}
@@ -143,7 +165,7 @@ func ComposeHolding(r mcat.Resolution, with mcat.Rendering, h Holding) (mcat.Com
// BusMembershipPath is where the host reads it — the same constant on both sides.
func BusMembershipID() string { return "bus-membership" }
func resolutionCompose(r mcat.Resolution, with mcat.Rendering, h Holding, owner map[string]string,
func resolutionCompose(r mcat.Resolution, with mcat.Rendering, h Holding, filter Filter, owner map[string]string,
received map[string]map[string][]mcat.Contribution, leftOut map[string]string,
foreseen, unplaced, handedOnly *[]string, handed *handedFiles) ([]map[string]any, error) {
// **A setting is judged where it is stored, and an impossible one costs a module, not a
@@ -284,8 +306,8 @@ func resolutionCompose(r mcat.Resolution, with mcat.Rendering, h Holding, owner
"`node show %s` says whether it has. Until then %s is not sent, and the machine "+
"keeps the filter it has", r.Node, r.Node, filters)
}
filtering := AsNftablesWithLocal(rules, with.Mesh, r.PublicDomain != "", with.Foundation,
with.OutwardLinks, with.TunnelInterface, with.LocalNetworks)
filtering := AsNftablesAllowing(rules, with.Mesh, r.PublicDomain != "", with.Foundation,
with.OutwardLinks, with.TunnelInterface, with.LocalNetworks, filter.Allowing)
// **A variable two modules set is refused whether or not anything places it** (novox/hq ADR
// 0203 §5): the account has one environment, and a machine whose holder arrives later should not
@@ -323,10 +345,20 @@ func resolutionCompose(r mcat.Resolution, with mcat.Rendering, h Holding, owner
// that does not, because what gets remembered is that it works.
var first []map[string]any
if f := m.Filtering; f != nil {
first = append(first, map[string]any{
"id": mcat.FilteringID(), "type": "file", "path": f.Into,
"content": filtering, "mode": "0600",
})
// **An unanswered allowed composes no filter file** (design 08 control-verbs §4): the one loaded is kept as it
// runs, and none is composed where none runs.
switch {
case filter.Withheld == "":
first = append(first, map[string]any{
"id": mcat.FilteringID(), "type": "file", "path": f.Into,
"content": filtering, "mode": "0600",
})
case filter.Running != nil:
first = append(first, map[string]any{
"id": mcat.FilteringID(), "type": "file", "path": f.Into,
"content": *filter.Running, "mode": "0600",
})
}
}
// The node's fail2ban jails, composed from every module it runs (novox/hq to-be 31), written
// where the intrusion-prevention holder owns them. Like the rule set above: gathered from all