Files
mesh-catalog/modules/mesh-config/cmd/mesh-config/takeover_test.go
T
jschoubben a30852939c mesh-config: remove the pull request path (issue 1982; ADR 0681 §1, §3, §5, §6)
The mesh knows no pull request (design 47 G, G-1 §38-39). Removed:
- the states `pulls` and `kept` and all code that reads or writes them (pulls.go, the held values a proposal holds, the
  listing of held values), SweepPulls, settlePull, HeardPull and the forge call;
- the consumes of git.pull-merged and git.pull-closed, the invoke of seat:git.pull;
- the config verb's `pull`, `head`, `declares` and `pulls` arguments and its actions `pull-declares` and `held`;
- the indexer's config candidates, which only that path used: the consume of mesh-delivery-indexer.views.config-candidates
  and the invoke of indexer_read_config_candidates (the indexer's state goes in the same group).
A stored proposal that names a pull request is judged not one this module makes, so nothing is set on it.

Builds: ADR 0681 §1 (no pulls or kept, no git events, no seat:git.pull, no `pull` argument, no pull-declares or held), §3, §5, §6;
lead answer A-490l (a stored proposal naming a pull request is refused on its approval).

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
2026-11-20 02:38:45 +01:00

75 lines
2.8 KiB
Go

package main
import (
"encoding/json"
"strings"
"testing"
catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
)
// The trunk's manifests aMesh declares.
const (
claudeDeclared = `{"module":"claude-code","settings":{
"managed":{"kind":"","default":{},"why":"","type":"object","description":"managed settings","trusted":true,"predefined":"agent-managed-settings"}}}`
oldDeclared = `{"module":"old","settings":{"workers":{"kind":"preference","default":4,"why":"two per core"}}}`
)
// anAgreeingMesh is aProposingMesh with the indexer's predefined list in place.
func anAgreeingMesh(t *testing.T) (*Config, *memStore, *standIn) {
t.Helper()
c, m, r := aProposingMesh(t)
indexerList(t, m, "aaaaaaaaaaaa", `{"agent-managed-settings":{"type":"object","description":"managed settings","trusted":true},
"font-size":{"type":"number","description":"text size, in points","minimum":6,"maximum":72}}`)
if _, err := c.Reconcile(); err != nil {
t.Fatal(err)
}
return c, m, r
}
// indexerList is the indexer's `predefined.list` at a commit.
func indexerList(t *testing.T, m *memStore, commit, list string) {
t.Helper()
raw, _ := json.Marshal(catalog.PredefinedByListValue{V: 1, Commit: commit, List: json.RawMessage(list)})
m.mirror(t, IndexerPredefinedRead, catalog.PredefinedByListKey(), string(raw))
}
// ADR 0590 (issue 1126): config reads its own sources always, with no take-over: declared is written once per
// manifest, and the list comes from the indexer. compare, take-over, hand-back and a pull request's config went (the
// mesh knows no pull request, design 47 G).
func TestConfigReadsItsOwnSourcesAlways(t *testing.T) {
c, m, _ := anAgreeingMesh(t)
steps := []struct {
name string
do func() (string, error)
want string // what the answer or the error says
}{
{"declared is written when it differs, and once", func() (string, error) {
_ = m.Delete(DeclaredState, "dunst")
first, err := c.Reconcile()
again, _ := c.Reconcile()
return strings.Join(first.Declared, ",") + "|" + strings.Join(again.Declared, ","), err
}, "dunst|"},
{"the list comes from the indexer", func() (string, error) {
indexerList(t, m, "cccccccccccc", `{"font-size":{"type":"number","description":"text size","minimum":6,"maximum":72},
"agent-managed-settings":{"type":"object","description":"managed settings","trusted":true},
"theme":{"type":"string","description":"the desktop's theme"}}`)
res, err := c.Reconcile()
return res.Published, err
}, "theme"},
}
for _, s := range steps {
got, err := s.do()
text := got
if err != nil {
text = err.Error()
}
if !strings.Contains(text, s.want) {
t.Errorf("%s: said %q, want %q", s.name, text, s.want)
}
}
if sw, _ := c.source(); sw.Source != SourceIndexer {
t.Errorf("the source is %q", sw.Source)
}
}