A trusted setting is proposed through the settings verb and set only on the operator's warrant (hq ADR 0277)
mesh/delivery superseded: a newer head of the same pull request
mesh/merge-gate pass: builds build-agent, mesh-controller → ace, g14, novox, shanks; no bus step; every machine composes with the change as it did without …
mesh/repo-check pass: its merge-check.sh passed

Issue 339 made every trusted setting the controller's terminal's alone, so an agent could only hand the
operator a line to type at the control node. Now anyone the bus admits may PROPOSE a layer: settings
propose keeps the proposal in the controller's own asks (the asked bucket, which the controller alone
writes), judged as settings set judges, and asks the operator on the operator channel at the level
approve with every key, its exact new value (in its shape where a path or an address may not leave the
mesh), the was of a changed key, the removed keys and the layer's fingerprint. The serving controller
sets the layer on the warrant alone: once, for the ask it holds, only when the record's values still
digest to what the option bound and the layer is still the one shown, with the terminal's judgement and
history, and keeps who approved it beside the layer, which settings says back (migration 0090). Decline,
expiry, a cancel, a replacement or the router's refusal discard it; nothing is asked when no router, no
grant or no channel can carry it. settings proposals lists them. The push afterwards is a separate act.
This commit is contained in:
jochen
2026-10-10 14:34:01 +02:00
parent b9ceeace41
commit e2a51f05bb
10 changed files with 1711 additions and 43 deletions
+51 -7
View File
@@ -799,7 +799,35 @@ func profileFrom(raw []byte) ([]Capability, error) {
// this is a statement of the whole layer, so removing a key is done by leaving it out, which is
// the only way removing one could work at all.
func (i *Inventory) SetSettings(ctx context.Context, nodeName, module string, values map[string]any) error {
return i.setSettings(ctx, nodeName, module, values, true)
return i.setSettings(ctx, nodeName, module, values, true, "")
}
// SetSettingsBy is SetSettings with who set the layer kept beside it (novox/hq ADR 0277): "approved by the
// operator via telegram …" for a layer set on a warrant, the caller at the controller's terminal otherwise.
// `settings` says it back, so a layer the operator approved on their phone is told from one typed.
func (i *Inventory) SetSettingsBy(ctx context.Context, nodeName, module string, values map[string]any, setBy string) error {
return i.setSettings(ctx, nodeName, module, values, true, setBy)
}
// JudgeSettings judges a layer as SetSettings would, and keeps nothing: what a proposal is held to before the
// operator is asked (novox/hq ADR 0277), so an ask is never raised for a layer the mesh would refuse.
func (i *Inventory) JudgeSettings(ctx context.Context, nodeName, module string, values map[string]any) error {
if err := i.judgeSettings(ctx, nodeName, module, values); err != nil {
return err
}
raw, err := json.Marshal(values)
if err != nil {
return err
}
given, err := givenIn(module, raw)
if err != nil {
return err
}
if nodeName == "" && len(given) > 0 {
return fmt.Errorf("%s: %s is given per node — a port is a fact about one machine; "+
"set it with --node", module, catalogue.PortsSetting)
}
return nil
}
// KeepSettings records a layer the mesh already holds, as it holds it, without judging it alone: for a
@@ -807,10 +835,10 @@ func (i *Inventory) SetSettings(ctx context.Context, nodeName, module string, va
// mesh-wide layer that needs a machine's own value to compose would be refused before that machine's
// layer is there — though the mesh keeps both and composes. Composition still judges every layer.
func (i *Inventory) KeepSettings(ctx context.Context, nodeName, module string, values map[string]any) error {
return i.setSettings(ctx, nodeName, module, values, false)
return i.setSettings(ctx, nodeName, module, values, false, "")
}
func (i *Inventory) setSettings(ctx context.Context, nodeName, module string, values map[string]any, judge bool) error {
func (i *Inventory) setSettings(ctx context.Context, nodeName, module string, values map[string]any, judge bool, setBy string) error {
raw, err := json.Marshal(values)
if err != nil {
return err
@@ -848,9 +876,9 @@ func (i *Inventory) setSettings(ctx context.Context, nodeName, module string, va
return err
}
if _, err := tx.Exec(ctx,
`insert into settings (node, module, values) values (null, $1, $2)
`insert into settings (node, module, values, set_by) values (null, $1, $2, $3)
on conflict (module) where node is null
do update set values = excluded.values, set_at = now()`, module, raw); err != nil {
do update set values = excluded.values, set_at = now(), set_by = excluded.set_by`, module, raw, nullable(setBy)); err != nil {
return wrapModule(err, module)
}
return tx.Commit(ctx)
@@ -878,9 +906,9 @@ func (i *Inventory) setSettings(ctx context.Context, nodeName, module string, va
return err
}
_, err = tx.Exec(ctx,
`insert into settings (node, module, values) values ($1, $2, $3)
`insert into settings (node, module, values, set_by) values ($1, $2, $3, $4)
on conflict (node, module) where node is not null
do update set values = excluded.values, set_at = now()`, node.ID, module, raw)
do update set values = excluded.values, set_at = now(), set_by = excluded.set_by`, node.ID, module, raw, nullable(setBy))
if err != nil {
return wrapModule(err, module)
}
@@ -1069,6 +1097,11 @@ func wrapModule(err error, module string) error {
// ClearSettings removes a layer.
func (i *Inventory) ClearSettings(ctx context.Context, nodeName, module string) error {
return i.ClearSettingsBy(ctx, nodeName, module, "")
}
// ClearSettingsBy removes a layer, and keeps who cleared it with the history copy (novox/hq ADR 0277).
func (i *Inventory) ClearSettingsBy(ctx context.Context, nodeName, module, clearedBy string) error {
nodeID, err := i.layerNode(ctx, nodeName)
if err != nil {
return err
@@ -1082,6 +1115,17 @@ func (i *Inventory) ClearSettings(ctx context.Context, nodeName, module string)
if _, err := tx.Exec(ctx, keepReplacedSQL, module, nodeID, "clear"); err != nil {
return err
}
if clearedBy != "" {
// The history copy says who cleared it, beside who had set it.
if _, err := tx.Exec(ctx,
`update settings_history set set_by = coalesce(set_by, '') || ' — cleared ' || $3
where module = $1 and node is not distinct from $2::uuid
and replaced_at = (select max(replaced_at) from settings_history
where module = $1 and node is not distinct from $2::uuid)`,
module, nodeID, clearedBy); err != nil {
return err
}
}
if _, err := tx.Exec(ctx,
`delete from settings where module = $1 and node is not distinct from $2::uuid`, module, nodeID); err != nil {
return err