oficina / alta Public

homecompat: pin Home with existing-team adoption

Pin Home, home/roster and home/handoff at 16da7ba. The mirror in
homeop/protocol.go needed no change beyond Task 1's existing_team.
The harness now admits the canonical route under the reserved label, as
Home's directoryRouteAllowed does. TestHomeAcceptsAltaSignedExistingTeamPlan
checks an Alta-signed plan verifies on both roles, the plan store keeps
existing_team, and an ordinary create-team under oficina is refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 51d614723deac754bca8fdbf19d3ec0af93bf830 parent 2c6c839
4 files changed, +105 −6
  • homecompat/adopt_test.go +84 −0
  • homecompat/compat_test.go +12 −3
  • homecompat/go.mod +3 −3
  • homecompat/go.sum +6 −0
diff --git a/homecompat/adopt_test.go b/homecompat/adopt_test.go
new file mode 100644
index 0000000..bb811c0
--- /dev/null
+++ b/homecompat/adopt_test.go
@@ -0,0 +1,84 @@
+package altacompat
+
+// Existing-team adoption at Home's real operator code: the plan Alta signs
+// for the six production apps, and the reserved label that keeps every
+// other plan out of it (internal/operator existing.go, plan.go).
+
+import (
+ "context"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/alta/homeop"
+ "amadan.net/oficina/alta/provision"
+ "amadan.net/oficina/home/internal/operator"
+)
+
+// adoptionPlan is the plan Alta signs for role: create-team under the
+// reserved label, bound to the proposed team SQID. Home's credential role
+// carries the owner; its directory role the label and name.
+func (r *rig) adoptionPlan(t *testing.T, role, existing string) []byte {
+ t.Helper()
+ p, err := r.client.NewPlan(role, homeop.Token(), homeop.KindCreateTeam, apps, r.home.now)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if role == homeop.Directory {
+ p.Label, p.DisplayName = "oficina", "Oficina"
+ } else {
+ p.Owner = owner
+ }
+ p.ExistingTeam = existing
+ raw, err := homeop.SignPlan(r.client.Key, p)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return raw
+}
+
+func TestHomeAcceptsAltaSignedExistingTeamPlan(t *testing.T) {
+ r := newRig(t)
+ ctx := context.Background()
+ run, err := r.engine.StartInitialize(ctx, provision.InitializeAttestation)
+ if err != nil {
+ t.Fatal(err)
+ }
+ r.home.confirm(t, "directory", "")
+ if got := r.drive(t, run); got.State != "done" {
+ t.Fatalf("initialize: %s %s", got.State, got.Code)
+ }
+ r.home.now = r.home.now.Add(homeop.WindowLifetime * time.Second)
+
+ sqid, err := operator.TeamSQID(1)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // An ordinary create-team under the reserved label is refused on the
+ // directory role: nothing but an adoption may name "oficina".
+ if o := r.client.SubmitPlan(ctx, homeop.Directory, r.adoptionPlan(t, homeop.Directory, "")); o != homeop.Refused {
+ t.Fatalf("ordinary create-team under oficina: %v", o)
+ }
+ if _, err := r.home.dirPlans.Pending(ctx, r.home.now); err == nil {
+ t.Fatal("a refused plan is pending")
+ }
+
+ // The adoption plan verifies on both roles.
+ for _, role := range []string{homeop.Directory, homeop.Credential} {
+ if o := r.client.SubmitPlan(ctx, role, r.adoptionPlan(t, role, sqid)); o != homeop.OK {
+ t.Fatalf("%s refused the adoption plan: %v", role, o)
+ }
+ }
+ // Home's own copy of each pending plan keeps existing_team.
+ views := map[string]operator.PlanView{}
+ for _, role := range []string{homeop.Directory, homeop.Credential} {
+ v := r.home.confirm(t, role, owner)
+ if v.ExistingTeam != sqid || v.Kind != homeop.KindCreateTeam {
+ t.Fatalf("%s plan view: %+v", role, v)
+ }
+ views[role] = v
+ }
+ if v := views[homeop.Directory]; v.Label != "oficina" || v.DisplayName != "Oficina" || len(v.Apps) != len(apps) {
+ t.Fatalf("directory plan view: %+v", v)
+ }
+}
diff --git a/homecompat/compat_test.go b/homecompat/compat_test.go
index 125e11b..2e200d3 100644
--- a/homecompat/compat_test.go
+++ b/homecompat/compat_test.go
@@ -113,7 +113,14 @@ func newHome(t *testing.T, alta *family.Keypair, prefilter string, installation,
if err != nil {
t.Fatal(err)
}
- route := func(r directorydata.Route) bool { return r.Origin == "https://"+r.Label+"."+r.App+".oficina.works" }
+ // internal/home directory_runtime.go directoryRouteAllowed: the reserved
+ // label admits only the canonical binding; every other label its own host.
+ route := func(r directorydata.Route) bool {
+ if r.Label == "oficina" {
+ return directorydata.CanonicalBinding(r.Label, r.App, r.ConsumerID, r.Origin)
+ }
+ return r.Origin == "https://"+r.Label+"."+r.App+".oficina.works"
+ }
h.directory, err = operator.NewDirectory(de, ov, prov, []roster.Key{{ID: "page1", Public: base64.RawURLEncoding.EncodeToString(page.SignPub())}}, directorydata.Config{Apps: apps, ValidateRoute: route})
if err != nil {
t.Fatal(err)
@@ -274,6 +281,7 @@ type rig struct {
con *fakeconsole.Console
engine *provision.Engine
store *provision.Store
+ client *homeop.Client
}
func newRig(t *testing.T) *rig {
@@ -310,13 +318,14 @@ func newRig(t *testing.T) *rig {
"credential": {Name: "credential", Origin: credOrigin, URL: cred.URL, Installation: inst, Registry: reg, Device: dev},
"directory": {Name: "directory", Origin: dirOrigin, URL: dir.URL, Installation: inst, Registry: reg, Device: dev},
}
- e := provision.New(provision.Config{Store: store, Home: &homeop.Client{Key: alta, Prefilter: pre, Roles: roles, Now: clock},
+ client := &homeop.Client{Key: alta, Prefilter: pre, Roles: roles, Now: clock}
+ e := provision.New(provision.Config{Store: store, Home: client,
Console: &console.Client{Base: con.URL(), Account: account, Tokens: tokens, Guard: provision.Guard{Store: store, Account: account}},
Public: &http.Client{Transport: con.Transport()},
HomeCfg: provision.HomeConfig{Issuer: credOrigin, Directory: dirOrigin, KeysBase64: "eyJrMSI6IkJBPT0ifQ==", Provisioner: h.provPub},
Account: account, Now: clock, Logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
Debug: func(err error) { t.Logf("transient: %v", err) }})
- return &rig{home: h, con: con, engine: e, store: store}
+ return &rig{home: h, con: con, engine: e, store: store, client: client}
}
func (r *rig) drive(t *testing.T, run int64) provision.Run {
diff --git a/homecompat/go.mod b/homecompat/go.mod
index ebea1d4..0078288 100644
--- a/homecompat/go.mod
+++ b/homecompat/go.mod
@@ -11,9 +11,9 @@ toolchain go1.26.5
require (
amadan.net/oficina/alta v0.0.0
- amadan.net/oficina/home v0.1.1-0.20261028105932-0cee9bad1c40
- amadan.net/oficina/home/handoff v0.0.0-20261028092646-82d938882ed3
- amadan.net/oficina/home/roster v0.0.0-20261028092646-82d938882ed3
+ amadan.net/oficina/home v0.1.1-0.20261116154649-16da7bad9395
+ amadan.net/oficina/home/handoff v0.0.0-20261116154649-16da7bad9395
+ amadan.net/oficina/home/roster v0.0.0-20261116154649-16da7bad9395
amadan.net/rastrillo/rastrillo v0.29.1-0.20261028004840-5bb38c0ab31b
)
diff --git a/homecompat/go.sum b/homecompat/go.sum
index d447c2e..d828330 100644
--- a/homecompat/go.sum
+++ b/homecompat/go.sum
@@ -2,10 +2,16 @@ amadan.net/carlos/platform.git/launchctx v0.0.0-20260911135504-fb577f96f7d1 h1:R
amadan.net/carlos/platform.git/launchctx v0.0.0-20260911135504-fb577f96f7d1/go.mod h1:6fBmMWgtESLFXZURzu/HyRXM0vyLuo4+XGGdKuZ+wao=
amadan.net/oficina/home v0.1.1-0.20261028105932-0cee9bad1c40 h1:2knYtzHnkG/gojSJAN4Z5JlfLht0MZ3taVeIQ3b5wVA=
amadan.net/oficina/home v0.1.1-0.20261028105932-0cee9bad1c40/go.mod h1:mt2ZytPZvpN0yYfrQLsoZ3y5ij+CkjOwb74M4M6JI3w=
+amadan.net/oficina/home v0.1.1-0.20261116154649-16da7bad9395 h1:5QEhaQTkxryVZSQlLpRehhmxJcjbfs7OK1yA2jiUUC8=
+amadan.net/oficina/home v0.1.1-0.20261116154649-16da7bad9395/go.mod h1:YQrPsuTn0bga002nJQ9P+MN4Kjl6lZianRJINDJ8On4=
amadan.net/oficina/home/handoff v0.0.0-20261028092646-82d938882ed3 h1:KQ3zM7eJp/JRQuPI2090jVcV5fJSVmOvonVAfSWzwUY=
amadan.net/oficina/home/handoff v0.0.0-20261028092646-82d938882ed3/go.mod h1:YISpzFJ+iMgrM0rUL032OSzsAQbP4/nozvXLCCOcn1k=
+amadan.net/oficina/home/handoff v0.0.0-20261116154649-16da7bad9395 h1:r9TnQOObUFlvMqPn9e+fr8mwEU7ZS9RH26Fn6NSBUeE=
+amadan.net/oficina/home/handoff v0.0.0-20261116154649-16da7bad9395/go.mod h1:YISpzFJ+iMgrM0rUL032OSzsAQbP4/nozvXLCCOcn1k=
amadan.net/oficina/home/roster v0.0.0-20261028092646-82d938882ed3 h1:AjimnZNNK8kIlaba371a4TgO7Z04DgLLBhjv25k2fPo=
amadan.net/oficina/home/roster v0.0.0-20261028092646-82d938882ed3/go.mod h1:gqshuXyDtFZUCYbhuZyV3Epc51pUcsLbpqAqiA5UiXg=
+amadan.net/oficina/home/roster v0.0.0-20261116154649-16da7bad9395 h1:CtVcBJvcspQRHQ68XJI0xOJg/lh5tpZ3ixbNaBmEhHY=
+amadan.net/oficina/home/roster v0.0.0-20261116154649-16da7bad9395/go.mod h1:gqshuXyDtFZUCYbhuZyV3Epc51pUcsLbpqAqiA5UiXg=
amadan.net/rastrillo/rastrillo v0.29.1-0.20261028004840-5bb38c0ab31b h1:7rApPVcEQ4MReZ6Q1h6fydrxtQwjd6kk6MyzQfpHYjo=
amadan.net/rastrillo/rastrillo v0.29.1-0.20261028004840-5bb38c0ab31b/go.mod h1:jSSeydqEvlm/fU3hhWoXFnyEaDgroR8LPRZSo9ZhhIM=
amadan.net/rastrillo/rastrillo/money v0.1.0 h1:MxU4oqNrW8abxRTkgZBv24OYNpFnvonajNqeLIzmmaM=