package host import ( "context" "testing" "github.com/carlosframework/platform/internal/registry" "github.com/carlosframework/platform/internal/release" ) // These are the protected attribution/readiness fields consumed by the // production adoption pass. E3 settings and E4 consent join this matrix when // their owning track lands; this test claims no whole-registry conversion. func testPlan14RootProtectedDispatch(t *testing.T) { cases := map[string]func(*registry.Route){ "canonical": func(*registry.Route) {}, "account": func(r *registry.Route) { r.Account = "bap" }, "app": func(r *registry.Route) { r.App = "other" }, "unit": func(r *registry.Route) { r.Unit = "other.service" }, "socket": func(r *registry.Route) { r.Socket = "/run/other.sock" }, "addr": func(r *registry.Route) { r.Addr = "127.0.0.1:1" }, "addrs": func(r *registry.Route) { r.Addrs = "127.0.0.1:1" }, "health": func(r *registry.Route) { r.Health = "null" }, "kind": func(r *registry.Route) { r.Kind = "static" }, "backing": func(r *registry.Route) { r.Backing = "exec" }, "channel": func(r *registry.Route) { r.Channel = "forged" }, "removed": nil, } for name, mutate := range cases { t.Run(name, func(t *testing.T) { e, rt, u, c, pub := plan14AdoptionFixture(t) h := seedHostRootHistory(t, rt) if mutate == nil { if err := e.root.reg.Delete(rt.Host); err != nil { t.Fatal(err) } } else { mutate(&rt) if err := e.root.reg.Upsert(rt); err != nil { t.Fatal(err) } } forward := rootRestartRouteWith(e.root.reg, u, u.opt, func(string) string { return "5s" }, e.root.obs.recordSettled(e.bake), c) err := release.Pass(context.Background(), e.root.reg, e.store, pub, u.opt, forward, release.BakeDir(e.bake), release.WithRootHistory(boundRootHistory(h, c.resolve, e.root.obs)), release.WithRollbackRestart(rollbackUnitRestart(e.root.reg, u, u.opt, func(string) string { return "5s" }, c))) if name == "canonical" { if err != nil || len(u.effects) != 1 { t.Fatal("canonical dispatch", err, u.effects) } } else if len(u.effects) != 0 { t.Fatal("registry mutation dispatched", name, err, u.effects) } }) } t.Run("observation-and-settle", TestPlan14ProofObservationRejectsForgedRegistry) t.Run("held-publication", TestPlan14HeldRevalidatesCanonicalBindingUnderGuard) }