Equipo and Base for own teams: seeded recipes, probe-gated activation, Paul's execution pair
Team bundle slices 1, 2 and 3b (design/team-bundle spec rev 3 + plan rev 2, Fable APPROVED, Paul's rulings 2026-11-30): - registry: Equipo and Base are Seeded and OwnOnly, no longer adoption-only; step 0 refuses them under outside (app-own-only), refuses Base until the team has every other app (base-needs-team-apps) or for a label over 19 characters (label-too-long-for-base) - recipes: owners written (the wait rule keeps the address until both are written); EQUIPO_ASSISTANT_HOSTS and BASE_EQUIPO_ORIGIN point at the label's own hosts; BASE_OFICINA_APPS is every other app; no Store, no agent keys - steps: seeded apps verify through a seeded /api/team (consumer and owner checked; probe-mode-mismatch, roster-owner-pending) and activate; audit records them live - OperatorKeys takes the run's inputs: own Equipo's EXECUTION_ENABLED=1 and a marker inside its own instance directory, admitted whole and exact; console guard refuses Alta writing either - form leaves own-only apps unchecked; team page offers them only to all-own teams, never on the adoption label - fake console answers the seeded probe; homecompat proves Home's real operator activates seeded apps
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
18 files changed,
+561
−59
AGENTS.md+2 −2README.md+46 −1console/client.go+2 −1console/fakeconsole/fakeconsole.go+29 −3homecompat/compat_test.go+40 −0internal/web/app.go+10 −1internal/web/templates/team_new.html+1 −1internal/web/words.go+6 −2provision/apps.go+115 −12provision/apps_test.go+7 −2provision/base_test.go+11 −10provision/engine.go+11 −4provision/equipo_test.go+9 −8provision/guard_test.go+2 −1provision/profile_test.go+10 −3provision/review_test.go+4 −2provision/seeded_test.go+238 −0provision/steps.go+18 −6
CI passed — run details
CI log
=== vet === go vet ./... === fmt === === test === CGO_ENABLED=0 go test ./... ok amadan.net/oficina/alta/adopt 23.894s ok amadan.net/oficina/alta/carlosop 0.054s ? amadan.net/oficina/alta/carlosop/fakecarlos [no test files] ok amadan.net/oficina/alta/cmd/alta 0.167s ok amadan.net/oficina/alta/cmd/alta-adopt 37.234s ok amadan.net/oficina/alta/console 0.003s ? amadan.net/oficina/alta/console/fakeconsole [no test files] ok amadan.net/oficina/alta/homeop 0.004s ok amadan.net/oficina/alta/homeop/fakehome 0.049s ok amadan.net/oficina/alta/internal/web 0.123s ok amadan.net/oficina/alta/provision 14.177s === compat === cd homecompat && go vet ./... && CGO_ENABLED=0 go test ./... ok amadan.net/oficina/home/altacompat 0.895s
diff --git a/AGENTS.md b/AGENTS.md| index 9d58561..8670e86 100644 |
| --- a/AGENTS.md |
| +++ b/AGENTS.md |
| @@ -59,8 +59,8 @@ A [rastrillo](https://amadan.net/rastrillo/rastrillo) app, on the current |
| - **No address at rest once it is no longer needed.** The owner's address |
| lives sealed in `owner_inputs`, the credential plan and the owner-seed |
| request until the seed has committed and every recipe that writes it (a |
| - stopgap allowlist; none since every app has roster mode) is written, |
| - then all three are deleted (`secure_delete`). |
| + stopgap allowlist, or a seeded app's owner: `EQUIPO_OWNERS`, |
| + `BASE_OWNER`) is written, then all three are deleted (`secure_delete`). |
| - **Logs carry step keys and fixed codes only**: never a label, an address, |
| a key or a platform value. |
| - Screens work without JavaScript; the only script is estilo's `busy.js`. |
diff --git a/README.md b/README.md| index ac0c16e..132f782 100644 |
| --- a/README.md |
| +++ b/README.md |
| @@ -46,7 +46,8 @@ form, recorded on the run and shown with its plan on Alta's run page |
| refuses to boot with `MEMORIA_AI=on` and no key, and Alta never holds |
| the TensorX key); Paul sets `MEMORIA_TENSORX_KEY` (secret) and |
| `MEMORIA_AI=on` in the environment afterwards, and the audit admits the |
| - two together and refuses either alone. |
| + two together and refuses either alone. Own teams may also take |
| + **Equipo and Base** (below). |
| - **samples**, a separate box: `DOCS_SAMPLE_DOCUMENTS=1`, for a sample |
| team only. |
| @@ -85,6 +86,50 @@ Labels: Alta's pattern, never `--` (`xn--` punycode), and never a reserved |
| name (`ReservedLabels`: `oficina`, every app's name, and the suite's and |
| platform's own names). |
| +### Equipo and Base (own teams only; team-bundle spec, 2026-11-30) |
| + |
| +Design: `docs/superpowers/specs/2026-11-29-team-bundle-design.md` and its |
| +plan, on branch `design/team-bundle`. |
| + |
| +- **Seeded, not roster.** Neither app has Home roster mode. Their owner |
| + comes from `EQUIPO_OWNERS` and `BASE_OWNER`, so their recipes write the |
| + owner's address, and Alta keeps it (sealed) until both environments |
| + are written. Each serves a seeded `GET /api/team`. Step 11 activates |
| + it only when the probe names this consumer and reports an owner |
| + (`roster-owner-pending` parks until then). |
| +- **Removing someone at Home removes them from neither.** That is |
| + accepted for own teams (Paul, 2026-11-30). Remove them in Equipo and |
| + Base too. |
| +- **Own profile only.** Step 0 refuses either under `outside` |
| + (`app-own-only`). The team page offers them only to a team whose apps |
| + are all own, and never on the adoption label. |
| +- **Base comes last.** Step 0 refuses Base (`base-needs-team-apps`) |
| + until the team has, or the run includes, every other app, Equipo |
| + included. Its tile list (`BASE_OFICINA_APPS`, every other app) and |
| + `BASE_EQUIPO_ORIGIN` then never depend on the run. A label over 19 |
| + characters cannot take Base (`label-too-long-for-base`). Base has no |
| + Store: no `BASE_PLATFORM_*`, `BASE_APPS_DOMAIN` or |
| + `BASE_ASSERTION_KEY`. |
| +- **No agent keys** (`<P>_AGENT_*`) on fresh instances, as for the six. |
| + Agent access for fresh teams is a follow-up. |
| +- **Execution is Paul's post-run pair**, like Memoria's AI. Set both: |
| + - `EQUIPO_EXECUTION_ENABLED=1`; |
| + - `EQUIPO_EXECUTION_MARKER_PATH=/data/instances/<label>-equipo.<account>.oncarlos.com/execution/witness`, |
| + the instance's own CARLOS directory. |
| + |
| + The audit admits the exact pair together, and refuses half of it or a |
| + path naming another instance. Alta's console guard refuses writing |
| + either. App `equipo` is already under `--swap hold`, which is |
| + app-wide. |
| +- **Closing a team** with these apps (spec §5.1 rule 4): |
| + - `retire-apps` leaves the environment and the parked replica; |
| + - before `carlos env release`, unset each Equipo and Base secret and |
| + key (`carlos secrets unset`, `carlos env unset`); |
| + - revoke the team's GitHub connections at GitHub; |
| + - revoke Memoria's TensorX key at TensorX. |
| + |
| +### Retiring |
| + |
| Retiring apps (`retire-apps`) disables the directory consumer, retires the |
| credential consumer, detaches the hostname and deletes the instance. The |
| parked database replica, the owned environment, and the team's label stay; |
diff --git a/console/client.go b/console/client.go| index c7fdea9..a5325a0 100644 |
| --- a/console/client.go |
| +++ b/console/client.go |
| @@ -76,7 +76,8 @@ func PlatformManaged(key string) bool { return managedKey.MatchString(key) } |
| // TensorX key, Paul 2026-11-12): Alta never holds or writes them, so a set |
| // of either is refused before it is sent. Unsetting (a fork's blanked |
| // MEMORIA_AI) stays allowed. |
| -var operatorOnly = map[string]bool{"MEMORIA_AI": true, "MEMORIA_TENSORX_KEY": true} |
| +// Equipo's execution pair is the same (team-bundle spec slice 3b). |
| +var operatorOnly = map[string]bool{"MEMORIA_AI": true, "MEMORIA_TENSORX_KEY": true, "EQUIPO_EXECUTION_ENABLED": true, "EQUIPO_EXECUTION_MARKER_PATH": true} |
| // OperatorOnly reports whether key is Paul's alone to set. |
| func OperatorOnly(key string) bool { return operatorOnly[key] } |
diff --git a/console/fakeconsole/fakeconsole.go b/console/fakeconsole/fakeconsole.go| index e4d9ff7..081afee 100644 |
| --- a/console/fakeconsole/fakeconsole.go |
| +++ b/console/fakeconsole/fakeconsole.go |
| @@ -92,6 +92,13 @@ type Console struct { |
| // NoTeamProbe: the roster-mode app serves no /api/team (Docs' main |
| // today). |
| NoTeamProbe bool |
| + // SeededRoster is a seeded app's (Equipo, Base) roster word on its |
| + // /api/team: "" answers "ok", once its owner exists. |
| + SeededRoster string |
| + // ProbeConsumer overrides the consumer an app's /api/team names. |
| + ProbeConsumer map[string]string |
| + // ProbeMode overrides an app's probe mode: "roster" or "seeded". |
| + ProbeMode map[string]string |
| // Requests is every request's method, door and app, for assertions. |
| Requests []string |
| @@ -606,16 +613,35 @@ func (c *Console) Transport() http.RoundTripper { |
| rec.WriteString(i.serving) |
| } |
| case r.URL.Path == "/api/team" && !c.NoTeamProbe: |
| - // Every app has roster mode, and the probe. |
| + // The six have roster mode; Equipo and Base answer seeded |
| + // (their owners come from the environment). |
| p := strings.ToUpper(i.app) |
| b := c.envs[i.app][i.env] |
| - _, token := b.vars[p+"_TEAM_ROSTER_TOKEN"] |
| consumer := b.vars[p+"_HOME_CONSUMER_ID"].Value |
| + if v, ok := c.ProbeConsumer[i.app]; ok { |
| + consumer = v |
| + } |
| + mode := "roster" |
| + if i.app == "equipo" || i.app == "base" { |
| + mode = "seeded" |
| + } |
| + if v, ok := c.ProbeMode[i.app]; ok { |
| + mode = v |
| + } |
| + rec.Header().Set("Content-Type", "application/json") |
| + if mode == "seeded" { |
| + roster := c.SeededRoster |
| + if roster == "" { |
| + roster = "ok" |
| + } |
| + _ = json.NewEncoder(rec).Encode(map[string]any{"team_mode": false, "seeded": true, "consumer": consumer, "roster": roster}) |
| + break |
| + } |
| + _, token := b.vars[p+"_TEAM_ROSTER_TOKEN"] |
| roster := c.Roster |
| if !token { |
| roster = "unknown" |
| } |
| - rec.Header().Set("Content-Type", "application/json") |
| _ = json.NewEncoder(rec).Encode(map[string]any{"team_mode": token, "consumer": consumer, "roster": roster}) |
| default: |
| rec.WriteHeader(404) |
diff --git a/homecompat/compat_test.go b/homecompat/compat_test.go| index 6494280..21d2ec9 100644 |
| --- a/homecompat/compat_test.go |
| +++ b/homecompat/compat_test.go |
| @@ -493,3 +493,43 @@ func TestHomeRefusesWhatAltaMustNotDo(t *testing.T) { |
| t.Fatal("Home accepted a plan for an owner who never signed in") |
| } |
| } |
| + |
| +// TestSeededAppsAgainstHomesRealOperator: an own team with Equipo and Base |
| +// (oficina/alta design/team-bundle) reaches live at Home's real directory. |
| +// The seeded apps carry no roster record; Home's activation takes Alta's |
| +// evidence for them as it does for a roster app (spec §1.2). |
| +func TestSeededAppsAgainstHomesRealOperator(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) |
| + |
| + bundle := append(append([]string{}, apps...), "equipo", "base") |
| + run, err = r.engine.CreateTeam(ctx, provision.NewTeam{Label: "campbells", Name: "Campbells", Owner: owner, Apps: bundle, Options: provision.RunOptions{Profile: provision.ProfileOwn}}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + r.home.confirm(t, "directory", "") |
| + r.home.confirm(t, "credential", owner) |
| + if got := r.drive(t, run); got.State != "done" { |
| + steps, _ := r.store.Steps(ctx, "campbells") |
| + t.Fatalf("create-team: %s %s %+v", got.State, got.Code, steps) |
| + } |
| + for _, id := range []string{"campbells-equipo", "campbells-base"} { |
| + var state string |
| + if err := r.home.dirDB.QueryRow("SELECT state FROM team_instances WHERE consumer_id=?", id).Scan(&state); err != nil || state != "live" { |
| + t.Fatalf("%s at the directory: %q %v", id, state, err) |
| + } |
| + } |
| + var live int |
| + if err := r.home.dirDB.QueryRow("SELECT count(*) FROM team_instances WHERE state='live'").Scan(&live); err != nil || live != len(bundle) { |
| + t.Fatalf("live at the directory: %d %v", live, err) |
| + } |
| +} |
diff --git a/internal/web/app.go b/internal/web/app.go| index 0ac82a5..21306c3 100644 |
| --- a/internal/web/app.go |
| +++ b/internal/web/app.go |
| @@ -458,10 +458,19 @@ func (a *App) team(w http.ResponseWriter, r *http.Request) { |
| } |
| ctx := r.Context() |
| var apps, addable []string |
| + // An own-only app (Equipo, Base) is offered only to a team whose |
| + // written apps are all under profile own, and never on the adoption |
| + // label (team-bundle spec §5.1 rule 3). Step 0 refuses it anyway. |
| + own := t.Label != provision.AdoptionLabel |
| + for s := range t.Apps { |
| + if opt, written, _ := a.cfg.Store.WrittenOptions(ctx, t.Label, s); written && opt.Profile != provision.ProfileOwn { |
| + own = false |
| + } |
| + } |
| for _, s := range provision.Slugs() { |
| if _, in := t.Apps[s]; in { |
| apps = append(apps, s) |
| - } else if spec, _ := provision.AppBySlug(s); !spec.AdoptionOnly { |
| + } else if spec, _ := provision.AppBySlug(s); !spec.AdoptionOnly && (!spec.OwnOnly || own) { |
| addable = append(addable, s) |
| } |
| } |
diff --git a/internal/web/templates/team_new.html b/internal/web/templates/team_new.html| index 5fd7308..c7aea22 100644 |
| --- a/internal/web/templates/team_new.html |
| +++ b/internal/web/templates/team_new.html |
| @@ -6,7 +6,7 @@ |
| {{template "field" dict "ID" "owner" "Name" "owner" "Label" "Owner email" "Type" "email" "Value" (index .Data.Form "owner") "Required" true "Autocomplete" "off" "Help" "They must already have signed in at oficina.works once."}} |
| <fieldset class="alta-apps"> |
| <legend>Apps</legend> |
| - {{range .Data.Apps}}<label><input type="checkbox" name="app" value="{{.Slug}}"{{if or (index $.Data.Checked .Slug) (not $.Data.Checked)}} checked{{end}}> {{.Name}}</label>{{end}} |
| + {{range .Data.Apps}}<label><input type="checkbox" name="app" value="{{.Slug}}"{{if or (index $.Data.Checked .Slug) (and (not $.Data.Checked) (not .OwnOnly))}} checked{{end}}> {{.Name}}{{if .OwnOnly}} <small class="alta-quiet">(own teams only)</small>{{end}}</label>{{end}} |
| </fieldset> |
| {{template "run-options" .Data.Options}} |
| <label class="alta-check"><input type="checkbox" name="forked" value="1"{{if .Data.Forked}} checked{{end}}> Moving a stopgap: use the environments you forked to <span class="alta-label"><label>-team</span></label> |
diff --git a/internal/web/words.go b/internal/web/words.go| index 9b33cf8..7e17b91 100644 |
| --- a/internal/web/words.go |
| +++ b/internal/web/words.go |
| @@ -60,8 +60,12 @@ var words = map[string]string{ |
| "label-shape": "A label is 3–32 lower-case letters, digits and hyphens, starting with a letter and ending with a letter or digit", |
| "label-double-hyphen": "A label never has two hyphens together (that is how punycode names begin)", |
| "profile-unknown": "Choose a profile: own or outside", |
| - "operator-keys-invalid": "Memoria's AI pair is not as memoria reads it: MEMORIA_AI must be the variable on, and MEMORIA_TENSORX_KEY a secret", |
| - "audit-operator-partial": "Memoria's AI is half set: MEMORIA_AI=on and MEMORIA_TENSORX_KEY go together", |
| + "operator-keys-invalid": "A post-run pair is not as the app reads it: for Memoria, MEMORIA_AI is the variable on and MEMORIA_TENSORX_KEY a secret; for Equipo, EQUIPO_EXECUTION_ENABLED is 1 and EQUIPO_EXECUTION_MARKER_PATH names this instance's own directory, exactly as the team page shows", |
| + "audit-operator-partial": "A post-run pair is half set: MEMORIA_AI and MEMORIA_TENSORX_KEY go together, and so do EQUIPO_EXECUTION_ENABLED and EQUIPO_EXECUTION_MARKER_PATH", |
| + "app-own-only": "Equipo and Base are for your own teams only: choose the own profile, or leave them out", |
| + "label-too-long-for-base": "Base needs a label of 19 characters or fewer", |
| + "base-needs-team-apps": "Base comes last: the team needs every other app, Equipo included, before Base is added", |
| + "probe-mode-mismatch": "The app's /api/team answers in a mode this recipe was not written for", |
| "name-shape": "Give the team a name", |
| "owner-shape": "That is not a plain email address", |
| "no-apps": "Choose at least one app", |
diff --git a/provision/apps.go b/provision/apps.go| index 166bb39..5d9bc5d 100644 |
| --- a/provision/apps.go |
| +++ b/provision/apps.go |
| @@ -61,11 +61,22 @@ const PublicDomain = "oficina.works" |
| // whether it needs the platform relay. |
| type App struct { |
| // AdoptionOnly admits an existing canonical instance, without offering an |
| - // unimplemented recipe for fresh team instances. |
| + // unimplemented recipe for fresh team instances. No app is adoption-only |
| + // since Equipo and Base gained recipes (team-bundle spec, slices 1–2); |
| + // the flag stays for the next app that is. |
| AdoptionOnly bool |
| - Slug string |
| - Name string |
| - Prefix string |
| + // Seeded is an app with no Home roster mode whose owners are seeded |
| + // from its environment (EQUIPO_OWNERS, BASE_OWNER). It reaches |
| + // steps 11–12 through its seeded /api/team probe instead of a roster |
| + // (team-bundle spec §1.2), and its recipe writes the owner's address. |
| + Seeded bool |
| + // OwnOnly is an app offered only under profile own (team-bundle spec |
| + // §5.1 rule 3): its roster diverges from Home's, which is acceptable |
| + // only for Paul's own teams until it has roster mode. |
| + OwnOnly bool |
| + Slug string |
| + Name string |
| + Prefix string |
| // Roster is true for an app with team (roster) mode on main. Only |
| // those reach steps 11–12; the rest stop at 10 with their directory |
| // row pending (§6). |
| @@ -104,8 +115,8 @@ var Apps = []App{ |
| {Slug: "calendar", Name: "Calendar", Prefix: "CALENDAR", Roster: true, MailPrefixes: []string{"CALENDAR_SMTP", "CARLOS_SMTP"}, SubmitPrefix: "CARLOS_SMTP", Dashboard: true}, |
| {Slug: "calls", Name: "Calls", Prefix: "CALLS", Roster: true, MailPrefixes: []string{"CALLS_SMTP", "CARLOS_SMTP"}, SubmitPrefix: "CARLOS_SMTP", Relay: true}, |
| {Slug: "memoria", Name: "Memoria", Prefix: "MEMORIA", Roster: true, MailPrefixes: []string{"CARLOS_SMTP"}, SubmitPrefix: "CARLOS_SMTP"}, |
| - {Slug: "equipo", Name: "Equipo", Prefix: "EQUIPO", AdoptionOnly: true, MailPrefixes: []string{"CARLOS_SMTP"}, SubmitPrefix: "CARLOS_SMTP"}, |
| - {Slug: "base", Name: "Base", Prefix: "BASE", AdoptionOnly: true, MailPrefixes: []string{"CARLOS_SMTP"}, SubmitPrefix: "CARLOS_SMTP"}, |
| + {Slug: "equipo", Name: "Equipo", Prefix: "EQUIPO", Seeded: true, OwnOnly: true, MailPrefixes: []string{"CARLOS_SMTP"}, SubmitPrefix: "CARLOS_SMTP"}, |
| + {Slug: "base", Name: "Base", Prefix: "BASE", Seeded: true, OwnOnly: true, MailPrefixes: []string{"CARLOS_SMTP"}, SubmitPrefix: "CARLOS_SMTP"}, |
| } |
| // ProvisioningApps are the apps with supported fresh-instance recipes. |
| @@ -255,7 +266,10 @@ func (o RunOptions) Normal() (RunOptions, bool) { |
| // Inputs is what a recipe is built from. |
| type Inputs struct { |
| - Label string |
| + Label string |
| + // Account is the CARLOS account's sqid, for a value that names an |
| + // instance's platform host (Equipo's execution marker, OperatorKeys). |
| + Account string |
| Owner string // empty once deleted (§4) |
| TeamSQID string |
| Record []byte // step 5's signed record (Docs) |
| @@ -353,10 +367,77 @@ func Recipe(app App, in Inputs) []Key { |
| Key{Name: "MEMORIA_TEAM", Class: Set, Value: in.Label}, |
| ) |
| keys = append(keys, teamKeys(p, in)...) |
| + case "equipo": |
| + // Seeded (team-bundle spec §1.2): no roster mode, so the owner is |
| + // written and Alta's wait rule keeps the address until this |
| + // environment is written. Execution is not written here: it is |
| + // Paul's post-run pair (OperatorKeys). The assistant host is the |
| + // label's own Base, written whether or not Base exists yet: |
| + // Equipo admits only that origin, so naming one not yet created is |
| + // harmless, and the value never depends on the run (plan rev 2). |
| + // No EQUIPO_AGENT_*: agent access for fresh teams is a follow-up. |
| + keys = append(keys, |
| + ownerKey("EQUIPO_OWNERS", in), |
| + Key{Name: "EQUIPO_ASSISTANT_HOSTS", Class: Set, Value: PublicOrigin(in.Label, "base")}, |
| + ) |
| + case "base": |
| + // Seeded, no Store (team-bundle spec §2.2): no BASE_PLATFORM_*, |
| + // BASE_APPS_DOMAIN or BASE_ASSERTION_KEY, so installs are off. |
| + // Base comes last (step 0, BaseRefusal): the team has every other |
| + // app, so the tile list is fixed and Ask always has its Equipo. |
| + keys = append(keys, |
| + ownerKey("BASE_OWNER", in), |
| + Key{Name: "BASE_NAME", Class: Set, Value: in.Label}, |
| + Key{Name: "BASE_SLUG", Class: Set, Value: in.Label}, |
| + Key{Name: "BASE_OFICINA_APPS", Class: Set, Value: BaseOficinaApps(in.Label)}, |
| + Key{Name: "BASE_EQUIPO_ORIGIN", Class: Set, Value: PublicOrigin(in.Label, "equipo")}, |
| + ) |
| } |
| return keys |
| } |
| +// BaseOficinaApps is BASE_OFICINA_APPS for label: every other registry app |
| +// as id=origin, in registry order (Base internal/config/oficina.go). Base |
| +// is not in its own list: an unknown id refuses Base's boot. |
| +func BaseOficinaApps(label string) string { |
| + var parts []string |
| + for _, a := range Apps { |
| + if a.Slug != "base" { |
| + parts = append(parts, a.Slug+"="+PublicOrigin(label, a.Slug)) |
| + } |
| + } |
| + return strings.Join(parts, ",") |
| +} |
| + |
| +// BaseSlugMax is Base's longest BASE_SLUG (Base internal/config maxSlug). |
| +const BaseSlugMax = 19 |
| + |
| +// AppsRefusal is step 0's rule for the apps a run names, beside what the |
| +// team already has (active), under the run's profile: "" to proceed. |
| +func AppsRefusal(label string, apps []string, active map[string]bool, p Profile) string { |
| + has := func(slug string) bool { return active[slug] || slices.Contains(apps, slug) } |
| + for _, slug := range apps { |
| + app, ok := AppBySlug(slug) |
| + switch { |
| + case !ok, app.AdoptionOnly: |
| + return "unknown-app" |
| + case app.OwnOnly && p != ProfileOwn: |
| + return "app-own-only" |
| + } |
| + } |
| + if slices.Contains(apps, "base") { |
| + if len(label) > BaseSlugMax { |
| + return "label-too-long-for-base" |
| + } |
| + for _, a := range Apps { |
| + if a.Slug != "base" && !has(a.Slug) { |
| + return "base-needs-team-apps" |
| + } |
| + } |
| + } |
| + return "" |
| +} |
| + |
| func qualityReports(own bool) string { |
| if own { |
| return "on" |
| @@ -373,11 +454,26 @@ type OperatorKey struct { |
| Value string |
| } |
| -// OperatorKeys is app's post-run group under profile p: Memoria's AI on |
| -// an own team (MEMORIA_AI=on and the TensorX key, both or neither; |
| -// memoria refuses to boot with one alone). Outside teams have none. |
| -func OperatorKeys(app App, p Profile) []OperatorKey { |
| - if p != ProfileOwn || app.Slug != "memoria" { |
| +// OperatorKeys is app's post-run group under in's profile. On an own |
| +// team: Memoria's AI (MEMORIA_AI=on and the TensorX key, both or |
| +// neither; memoria refuses to boot with one alone), and Equipo's |
| +// execution (team-bundle spec slice 3b: EQUIPO_EXECUTION_ENABLED=1 and |
| +// the marker inside the instance's own CARLOS directory, whose name is |
| +// its platform host; a path naming any other directory fails Equipo's |
| +// boot, and the exact value is what the audit admits). Outside teams |
| +// have none. |
| +func OperatorKeys(app App, in Inputs) []OperatorKey { |
| + if in.Profile != ProfileOwn { |
| + return nil |
| + } |
| + switch app.Slug { |
| + case "equipo": |
| + return []OperatorKey{ |
| + {Name: "EQUIPO_EXECUTION_ENABLED", Value: "1"}, |
| + {Name: "EQUIPO_EXECUTION_MARKER_PATH", Value: ExecutionMarkerPath(in.Label, in.Account)}, |
| + } |
| + case "memoria": |
| + default: |
| return nil |
| } |
| return []OperatorKey{ |
| @@ -386,6 +482,13 @@ func OperatorKeys(app App, p Profile) []OperatorKey { |
| } |
| } |
| +// ExecutionMarkerPath is a team Equipo's EQUIPO_EXECUTION_MARKER_PATH: |
| +// under the instance's own /data/instances/<platform host>, apart from its |
| +// database, as the canonical instance's is. |
| +func ExecutionMarkerPath(label, account string) string { |
| + return "/data/instances/" + RouteHost(label, "equipo", account) + "/execution/witness" |
| +} |
| + |
| // profileWrites is every env key some run's choice writes into app's |
| // environment for label beyond the outside recipe, with the exact value |
| // it writes: a later run may take back out a key that is still exactly |
diff --git a/provision/apps_test.go b/provision/apps_test.go| index 1e79b1f..fbdc9ca 100644 |
| --- a/provision/apps_test.go |
| +++ b/provision/apps_test.go |
| @@ -54,8 +54,8 @@ func TestRosterRecipes(t *testing.T) { |
| } |
| } |
| for _, a := range ProvisioningApps() { |
| - if !a.Roster { |
| - t.Fatalf("%s roster mode %v", a.Slug, a.Roster) |
| + if a.Roster == a.Seeded { |
| + t.Fatalf("%s: roster %v, seeded %v: an app is exactly one", a.Slug, a.Roster, a.Seeded) |
| } |
| } |
| } |
| @@ -92,6 +92,11 @@ func TestCanonicalHelpersForOficina(t *testing.T) { |
| func TestTeamKeyNamesMatchesRecipe(t *testing.T) { |
| in := Inputs{Label: "lagged", TeamSQID: "Uk", Record: []byte("{}"), Home: HomeConfig{Directory: "https://oficina.works", Provisioner: "AQ"}} |
| for _, app := range ProvisioningApps() { |
| + if app.Seeded { |
| + // A seeded app has no roster, so no <P>_TEAM_ keys (and the |
| + // recipe tests pin that none is written). |
| + continue |
| + } |
| want := TeamKeyNames(app) |
| if len(want) != 5 { |
| t.Fatalf("%s: %v", app.Slug, want) |
diff --git a/provision/base_test.go b/provision/base_test.go| index 88dbde4..74c5118 100644 |
| --- a/provision/base_test.go |
| +++ b/provision/base_test.go |
| @@ -13,13 +13,11 @@ import ( |
| // label was already reserved. |
| func TestBaseAdoptionRegistry(t *testing.T) { |
| app, ok := AppBySlug("base") |
| - if !ok || app.Prefix != "BASE" || app.Name != "Base" || !app.AdoptionOnly || app.Roster { |
| + if !ok || app.Prefix != "BASE" || app.Name != "Base" { |
| t.Fatalf("Base registry: %+v %v", app, ok) |
| } |
| - for _, a := range ProvisioningApps() { |
| - if a.Slug == "base" { |
| - t.Fatal("Base advertised for fresh provisioning") |
| - } |
| + if app.AdoptionOnly || !app.Seeded || !app.OwnOnly || app.Roster { |
| + t.Fatalf("Base is seeded and own-only (team-bundle spec): %+v", app) |
| } |
| if !ReservedLabels["base"] { |
| t.Fatal("Base label is not reserved") |
| @@ -79,15 +77,18 @@ func TestBaseJoinsExistingAdoption(t *testing.T) { |
| } |
| } |
| -func TestBaseCannotProvisionFreshInstances(t *testing.T) { |
| +// A fresh Base is offered only under profile own (team-bundle spec §5.1 |
| +// rule 3), never under outside, and never by an ordinary run under the |
| +// adoption label. |
| +func TestBaseFreshInstancesAreOwnOnly(t *testing.T) { |
| h := newHarness(t) |
| h.initialized() |
| e := h.engine(nil) |
| - _, err := e.CreateTeam(h.ctx(), NewTeam{Label: "new-team", Name: "New", Owner: ownerCanary, Apps: []string{"docs", "base"}}) |
| - failCode(t, err, "unknown-app") |
| + _, err := e.CreateTeam(h.ctx(), NewTeam{Label: "new-team", Name: "New", Owner: ownerCanary, Apps: []string{"docs", "sheets", "slides", "calendar", "calls", "memoria", "equipo", "base"}}) |
| + failCode(t, err, "app-own-only") |
| if err := h.store.CreateTeam(h.ctx(), "existing", "Existing", "existing", false, ownerCanary, []string{"docs"}); err != nil { |
| t.Fatal(err) |
| } |
| - _, err = e.AddApps(h.ctx(), "existing", []string{"base"}, RunOptions{}) |
| - failCode(t, err, "unknown-app") |
| + _, err = e.AddApps(h.ctx(), "existing", []string{"base"}, RunOptions{Profile: ProfileOutside}) |
| + failCode(t, err, "app-own-only") |
| } |
diff --git a/provision/engine.go b/provision/engine.go| index 58ab709..d2b3a51 100644 |
| --- a/provision/engine.go |
| +++ b/provision/engine.go |
| @@ -161,14 +161,14 @@ func validEnvironment(s string) bool { |
| // CreateTeam runs step 0 for a new team and, if it passes, records the |
| // label (for good) and submits the plans. |
| func (e *Engine) CreateTeam(ctx context.Context, in NewTeam) (int64, error) { |
| - for _, slug := range in.Apps { |
| - if app, ok := AppBySlug(slug); ok && app.AdoptionOnly { |
| - return 0, fail("unknown-app") |
| + opt, okOpt := in.Options.Normal() |
| + if okOpt { |
| + if r := AppsRefusal(in.Label, in.Apps, nil, opt.Profile); r != "" { |
| + return 0, fail(r) |
| } |
| } |
| in.Apps = SortApps(in.Apps) |
| env := EnvironmentName(in.Label, in.Forked) |
| - opt, okOpt := in.Options.Normal() |
| switch { |
| case LabelRefusal(in.Label) != "": |
| return 0, fail(LabelRefusal(in.Label)) |
| @@ -239,6 +239,13 @@ func (e *Engine) AddApps(ctx context.Context, label string, apps []string, opt R |
| if !ok { |
| return 0, fail("profile-unknown") |
| } |
| + active := map[string]bool{} |
| + for a, st := range t.Apps { |
| + active[a] = st == "active" |
| + } |
| + if r := AppsRefusal(label, apps, active, opt.Profile); r != "" { |
| + return 0, fail(r) |
| + } |
| // An environment already written keeps its choice: step 7 is done and |
| // never rewrites it, so a run under another choice would finish while |
| // changing nothing. Refused, naming the app. |
diff --git a/provision/equipo_test.go b/provision/equipo_test.go| index fa5bec9..b22c167 100644 |
| --- a/provision/equipo_test.go |
| +++ b/provision/equipo_test.go |
| @@ -13,10 +13,8 @@ func TestEquipoAdoptionRegistry(t *testing.T) { |
| if !ok || app.Prefix != "EQUIPO" || app.Name != "Equipo" { |
| t.Fatalf("Equipo registry: %+v %v", app, ok) |
| } |
| - for _, a := range ProvisioningApps() { |
| - if a.Slug == "equipo" { |
| - t.Fatal("Equipo advertised for fresh provisioning") |
| - } |
| + if app.AdoptionOnly || !app.Seeded || !app.OwnOnly || app.Roster { |
| + t.Fatalf("Equipo is seeded and own-only (team-bundle spec): %+v", app) |
| } |
| if !ReservedLabels["equipo"] { |
| t.Fatal("Equipo label is not reserved") |
| @@ -76,15 +74,18 @@ func TestEquipoJoinsExistingAdoption(t *testing.T) { |
| } |
| } |
| -func TestEquipoCannotProvisionFreshInstances(t *testing.T) { |
| +// A fresh Equipo is offered only under profile own (team-bundle spec §5.1 |
| +// rule 3), never under outside, and never by an ordinary run under the |
| +// adoption label. |
| +func TestEquipoFreshInstancesAreOwnOnly(t *testing.T) { |
| h := newHarness(t) |
| h.initialized() |
| e := h.engine(nil) |
| _, err := e.CreateTeam(h.ctx(), NewTeam{Label: "new-team", Name: "New", Owner: ownerCanary, Apps: []string{"docs", "equipo"}}) |
| - failCode(t, err, "unknown-app") |
| + failCode(t, err, "app-own-only") |
| if err := h.store.CreateTeam(h.ctx(), "existing", "Existing", "existing", false, ownerCanary, []string{"docs"}); err != nil { |
| t.Fatal(err) |
| } |
| - _, err = e.AddApps(h.ctx(), "existing", []string{"equipo"}, RunOptions{}) |
| - failCode(t, err, "unknown-app") |
| + _, err = e.AddApps(h.ctx(), "existing", []string{"equipo"}, RunOptions{Profile: ProfileOutside}) |
| + failCode(t, err, "app-own-only") |
| } |
diff --git a/provision/guard_test.go b/provision/guard_test.go| index b42a1ec..8d30f3d 100644 |
| --- a/provision/guard_test.go |
| +++ b/provision/guard_test.go |
| @@ -118,7 +118,8 @@ func TestGuardRefusesPlatformManagedKeys(t *testing.T) { |
| } |
| // Memoria's AI pair is Paul's alone: never set, in any kind; a |
| // fork's blanked MEMORIA_AI may still be unset. |
| - for _, k := range []string{"MEMORIA_AI", "MEMORIA_TENSORX_KEY"} { |
| + // So is Equipo's execution pair (team-bundle slice 3b). |
| + for _, k := range []string{"MEMORIA_AI", "MEMORIA_TENSORX_KEY", "EQUIPO_EXECUTION_ENABLED", "EQUIPO_EXECUTION_MARKER_PATH"} { |
| for _, v := range []console.SetVar{{Kind: "env", Value: "on"}, {Kind: "secret", Envelope: "x"}} { |
| _, err := e.cfg.Console.PutConfig(h.ctx(), "sheets", "alpha", map[string]console.SetVar{k: v}, nil, "") |
| refusedLocally(t, h, "set "+k, err) |
diff --git a/provision/profile_test.go b/provision/profile_test.go| index 5740794..7c61df4 100644 |
| --- a/provision/profile_test.go |
| +++ b/provision/profile_test.go |
| @@ -80,6 +80,11 @@ const outsideGolden = "3836921a89ecd9942eead9b48db0609ed5509586348231bb1c3608112 |
| func recipesDigest(in Inputs) string { |
| var all [][]Key |
| for _, a := range ProvisioningApps() { |
| + if a.OwnOnly { |
| + // Never written under outside (step 0 refuses it), so not |
| + // part of today's outside recipes. |
| + continue |
| + } |
| all = append(all, Recipe(a, in)) |
| } |
| b, _ := json.Marshal(all) |
| @@ -170,15 +175,17 @@ func TestNoProfileWritesMemoriaAI(t *testing.T) { |
| } |
| } |
| } |
| - if len(OperatorKeys(app, ProfileOutside)) != 0 { |
| + outside, own := goldenInputs, goldenInputs |
| + outside.Profile, own.Profile = ProfileOutside, ProfileOwn |
| + if len(OperatorKeys(app, outside)) != 0 { |
| t.Fatal("an outside team admits Memoria AI") |
| } |
| - got := OperatorKeys(app, ProfileOwn) |
| + got := OperatorKeys(app, own) |
| if len(got) != 2 || got[0] != (OperatorKey{Name: "MEMORIA_AI", Value: "on"}) || got[1] != (OperatorKey{Name: "MEMORIA_TENSORX_KEY", Secret: true}) { |
| t.Fatalf("own memoria operator keys %v", got) |
| } |
| for _, a := range ProvisioningApps() { |
| - if a.Slug != "memoria" && len(OperatorKeys(a, ProfileOwn)) != 0 { |
| + if a.Slug != "memoria" && a.Slug != "equipo" && len(OperatorKeys(a, own)) != 0 { |
| t.Fatalf("%s has operator keys", a.Slug) |
| } |
| } |
diff --git a/provision/review_test.go b/provision/review_test.go| index 6d4728e..dbbf945 100644 |
| --- a/provision/review_test.go |
| +++ b/provision/review_test.go |
| @@ -245,8 +245,10 @@ func TestOwnerForgottenOnceSeeded(t *testing.T) { |
| h := newHarness(t) |
| h.initialized() |
| for _, a := range Apps { |
| - if NeedsOwner(a) { |
| - t.Fatalf("%s still writes the owner's address", a.Slug) |
| + // Only the seeded apps (Equipo, Base) write it, and this run has |
| + // neither (TestSeededAppsKeepTheOwnerUntilWritten). |
| + if NeedsOwner(a) != a.Seeded { |
| + t.Fatalf("%s writes the owner's address: %v", a.Slug, NeedsOwner(a)) |
| } |
| } |
| e := h.engine(nil) |
diff --git a/provision/seeded_test.go b/provision/seeded_test.go| new file mode 100644 |
| index 0000000..b84f2f5 |
| --- /dev/null |
| +++ b/provision/seeded_test.go |
| @@ -0,0 +1,238 @@ |
| +package provision |
| + |
| +import ( |
| + "strings" |
| + "testing" |
| +) |
| + |
| +// The team bundle's seeded apps (oficina/alta design/team-bundle, plan |
| +// slices 1, 2 and 3b): Equipo and Base, own teams only. |
| + |
| +var bundleApps = []string{"docs", "sheets", "slides", "calendar", "calls", "memoria", "equipo", "base"} |
| + |
| +func keyMapOf(keys []Key) map[string]Key { |
| + m := map[string]Key{} |
| + for _, k := range keys { |
| + m[k.Name] = k |
| + } |
| + return m |
| +} |
| + |
| +func TestSeededRecipes(t *testing.T) { |
| + in := goldenInputs |
| + in.Label, in.Owner, in.Profile = "campbells", ownerCanary, ProfileOwn |
| + eq, _ := AppBySlug("equipo") |
| + base, _ := AppBySlug("base") |
| + |
| + e := keyMapOf(Recipe(eq, in)) |
| + want := map[string]string{ |
| + "EQUIPO_ORIGIN": "https://campbells.equipo.oficina.works", |
| + "EQUIPO_HOME_CONSUMER_ID": "campbells-equipo", |
| + "EQUIPO_OWNERS": ownerCanary, |
| + "EQUIPO_ASSISTANT_HOSTS": "https://campbells.base.oficina.works", |
| + } |
| + for name, v := range want { |
| + if e[name].Value != v || e[name].Class != Set { |
| + t.Errorf("equipo %s = %+v, want %q", name, e[name], v) |
| + } |
| + } |
| + if !e["EQUIPO_OWNERS"].OwnerAddress { |
| + t.Error("EQUIPO_OWNERS is not marked as the owner's address") |
| + } |
| + for _, name := range []string{"EQUIPO_INSTANCE_KEY", "EQUIPO_HOME_DEK_BASE64"} { |
| + if e[name].Class != Generated || !e[name].Secret { |
| + t.Errorf("equipo %s = %+v", name, e[name]) |
| + } |
| + } |
| + |
| + b := keyMapOf(Recipe(base, in)) |
| + want = map[string]string{ |
| + "BASE_ORIGIN": "https://campbells.base.oficina.works", |
| + "BASE_HOME_CONSUMER_ID": "campbells-base", |
| + "BASE_OWNER": ownerCanary, |
| + "BASE_NAME": "campbells", |
| + "BASE_SLUG": "campbells", |
| + "BASE_EQUIPO_ORIGIN": "https://campbells.equipo.oficina.works", |
| + "BASE_OFICINA_APPS": "docs=https://campbells.docs.oficina.works,sheets=https://campbells.sheets.oficina.works," + |
| + "slides=https://campbells.slides.oficina.works,calendar=https://campbells.calendar.oficina.works," + |
| + "calls=https://campbells.calls.oficina.works,memoria=https://campbells.memoria.oficina.works," + |
| + "equipo=https://campbells.equipo.oficina.works", |
| + } |
| + for name, v := range want { |
| + if b[name].Value != v || b[name].Class != Set { |
| + t.Errorf("base %s = %+v, want %q", name, b[name], v) |
| + } |
| + } |
| + |
| + for _, keys := range []map[string]Key{e, b} { |
| + for name := range keys { |
| + // No roster, no Store, no agent access, no execution: those |
| + // are absent (the plan), never written empty. |
| + for _, banned := range []string{"_TEAM_", "_PLATFORM_", "_APPS_DOMAIN", "_ASSERTION_KEY", "_AGENT_", "_EXECUTION_", "TENSORX", "HOUSE"} { |
| + if strings.Contains(name, banned) { |
| + t.Errorf("recipe writes %s", name) |
| + } |
| + } |
| + } |
| + } |
| + if !NeedsOwner(eq) || !NeedsOwner(base) { |
| + t.Error("a seeded recipe must write the owner, so the wait rule holds") |
| + } |
| +} |
| + |
| +func TestAppsRefusal(t *testing.T) { |
| + six := []string{"docs", "sheets", "slides", "calendar", "calls", "memoria"} |
| + activeSix := map[string]bool{} |
| + for _, a := range six { |
| + activeSix[a] = true |
| + } |
| + for _, tc := range []struct { |
| + name string |
| + label string |
| + apps []string |
| + active map[string]bool |
| + p Profile |
| + want string |
| + }{ |
| + {"six outside", "acme", six, nil, ProfileOutside, ""}, |
| + {"equipo outside", "acme", []string{"docs", "equipo"}, nil, ProfileOutside, "app-own-only"}, |
| + {"base outside", "acme", bundleApps, nil, ProfileOutside, "app-own-only"}, |
| + {"equipo own", "acme", []string{"docs", "equipo"}, nil, ProfileOwn, ""}, |
| + {"all own", "campbells", bundleApps, nil, ProfileOwn, ""}, |
| + {"base without equipo", "campbells", append(append([]string{}, six...), "base"), nil, ProfileOwn, "base-needs-team-apps"}, |
| + {"base alone, team has the rest", "campbells", []string{"base"}, map[string]bool{"docs": true, "sheets": true, "slides": true, "calendar": true, "calls": true, "memoria": true, "equipo": true}, ProfileOwn, ""}, |
| + {"base alone, team lacks calls", "campbells", []string{"base", "equipo"}, map[string]bool{"docs": true, "sheets": true, "slides": true, "calendar": true, "memoria": true}, ProfileOwn, "base-needs-team-apps"}, |
| + {"base label too long", "a-label-of-twenty-ch", bundleApps, nil, ProfileOwn, "label-too-long-for-base"}, |
| + {"equipo long label", "a-label-of-twenty-ch", []string{"equipo"}, activeSix, ProfileOwn, ""}, |
| + } { |
| + if got := AppsRefusal(tc.label, tc.apps, tc.active, tc.p); got != tc.want { |
| + t.Errorf("%s: %q, want %q", tc.name, got, tc.want) |
| + } |
| + } |
| +} |
| + |
| +func TestExecutionPair(t *testing.T) { |
| + eq, _ := AppBySlug("equipo") |
| + in := goldenInputs |
| + in.Label, in.Account, in.Profile = "campbells", "bds", ProfileOwn |
| + got := OperatorKeys(eq, in) |
| + want := []OperatorKey{ |
| + {Name: "EQUIPO_EXECUTION_ENABLED", Value: "1"}, |
| + {Name: "EQUIPO_EXECUTION_MARKER_PATH", Value: "/data/instances/campbells-equipo.bds.oncarlos.com/execution/witness"}, |
| + } |
| + if len(got) != 2 || got[0] != want[0] || got[1] != want[1] { |
| + t.Fatalf("own equipo operator keys %v", got) |
| + } |
| + in.Profile = ProfileOutside |
| + if len(OperatorKeys(eq, in)) != 0 { |
| + t.Fatal("an outside team admits Equipo execution") |
| + } |
| + in.Profile = ProfileOwn |
| + env := func(vals map[string]string) func(string) (string, string, bool) { |
| + return func(name string) (string, string, bool) { |
| + v, ok := vals[name] |
| + return "env", v, ok |
| + } |
| + } |
| + for _, tc := range []struct { |
| + name string |
| + vals map[string]string |
| + want OperatorState |
| + }{ |
| + {"none", map[string]string{}, OperatorNone}, |
| + {"half", map[string]string{"EQUIPO_EXECUTION_ENABLED": "1"}, OperatorPartial}, |
| + {"whole", map[string]string{"EQUIPO_EXECUTION_ENABLED": "1", "EQUIPO_EXECUTION_MARKER_PATH": want[1].Value}, OperatorWhole}, |
| + {"another instance's directory", map[string]string{"EQUIPO_EXECUTION_ENABLED": "1", "EQUIPO_EXECUTION_MARKER_PATH": "/data/instances/equipo.bds.oncarlos.com/execution/witness"}, OperatorInvalid}, |
| + {"enabled 0", map[string]string{"EQUIPO_EXECUTION_ENABLED": "0", "EQUIPO_EXECUTION_MARKER_PATH": want[1].Value}, OperatorInvalid}, |
| + } { |
| + if got := operatorState(OperatorKeys(eq, in), env(tc.vals)); got != tc.want { |
| + t.Errorf("%s: %v, want %v", tc.name, got, tc.want) |
| + } |
| + } |
| +} |
| + |
| +func (h *harness) createOwnBundle(e *Engine, label string) int64 { |
| + h.t.Helper() |
| + run, err := e.CreateTeam(h.ctx(), NewTeam{Label: label, Name: "Campbells", Owner: ownerCanary, Apps: bundleApps, Options: RunOptions{Profile: ProfileOwn}}) |
| + if err != nil { |
| + h.t.Fatal(err) |
| + } |
| + h.confirm("create-team") |
| + return run |
| +} |
| + |
| +// An own team with every app, Equipo and Base included, goes live end to |
| +// end: the seeded apps through their probe, each audited, and the owner's |
| +// address forgotten once the last recipe holding it is written. |
| +func TestOwnTeamWithEquipoAndBaseGoesLive(t *testing.T) { |
| + h := newHarness(t) |
| + h.initialized() |
| + e := h.engine(nil) |
| + run := h.createOwnBundle(e, "campbells") |
| + if r := h.drive(e, run, 80); r.State != "done" { |
| + for _, a := range bundleApps { |
| + for _, s := range AppSteps(mustApp(t, a)) { |
| + if st, _, _ := h.store.Step(h.ctx(), "campbells", a, s); st.State != "done" { |
| + t.Logf("%s %s: %s %s", a, s, st.State, st.Code) |
| + break |
| + } |
| + } |
| + } |
| + t.Fatalf("run %s %s", r.State, r.Code) |
| + } |
| + for _, a := range []string{"equipo", "base"} { |
| + if got := h.home.InstanceState(ConsumerID("campbells", a)); got != "live" { |
| + t.Errorf("%s directory row %q", a, got) |
| + } |
| + st, _, _ := h.store.Step(h.ctx(), "campbells", a, StepAudit) |
| + if st.State != "done" || st.Data["directory_pending"] != false { |
| + t.Errorf("%s audit %+v", a, st) |
| + } |
| + } |
| + if _, held, _ := h.store.Owner(h.ctx(), "campbells"); held { |
| + t.Error("the owner's address is still held after every recipe holding it is written") |
| + } |
| +} |
| + |
| +func mustApp(t *testing.T, slug string) App { |
| + t.Helper() |
| + a, ok := AppBySlug(slug) |
| + if !ok { |
| + t.Fatal(slug) |
| + } |
| + return a |
| +} |
| + |
| +// A seeded app's probe gates activation: an owner not yet seeded parks |
| +// and resumes; a probe naming another consumer parks; a roster app that |
| +// answers seeded is not the build its recipe was written for. |
| +func TestSeededProbeParks(t *testing.T) { |
| + for _, tc := range []struct { |
| + name string |
| + set func(h *harness) |
| + app string |
| + code string |
| + }{ |
| + {"owner pending", func(h *harness) { h.con.SeededRoster = "owner-pending" }, "equipo", "roster-owner-pending"}, |
| + {"wrong consumer", func(h *harness) { h.con.ProbeConsumer = map[string]string{"base": "campbells-equipo"} }, "base", "not-team-mode"}, |
| + {"roster app answers seeded", func(h *harness) { h.con.ProbeMode = map[string]string{"docs": "seeded"} }, "docs", "probe-mode-mismatch"}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + h := newHarness(t) |
| + h.initialized() |
| + tc.set(h) |
| + e := h.engine(nil) |
| + run := h.createOwnBundle(e, "campbells") |
| + if r := h.drive(e, run, 60); r.State == "done" { |
| + t.Fatal("run finished past a bad probe") |
| + } |
| + st, _, _ := h.store.Step(h.ctx(), "campbells", tc.app, StepVerify) |
| + if st.State != "parked" || st.Code != tc.code { |
| + t.Fatalf("%s verify %s %s, want parked %s", tc.app, st.State, st.Code, tc.code) |
| + } |
| + if h.home.InstanceState(ConsumerID("campbells", tc.app)) == "live" { |
| + t.Fatal("activated past a bad probe") |
| + } |
| + }) |
| + } |
| +} |
diff --git a/provision/steps.go b/provision/steps.go| index 8e61a48..0277ff2 100644 |
| --- a/provision/steps.go |
| +++ b/provision/steps.go |
| @@ -40,7 +40,7 @@ const ( |
| // AppSteps is the pipeline for app, in order. |
| func AppSteps(app App) []string { |
| s := []string{StepConsumer, StepRegister, StepEnv, StepInstance, StepDomain, StepServing} |
| - if app.Roster { |
| + if app.Roster || app.Seeded { |
| s = append(s, StepVerify, StepActivate) |
| } |
| return append(s, StepAudit) |
| @@ -413,7 +413,7 @@ func (e *Engine) stepRegister(ctx context.Context, p *pass, app App) error { |
| // ---- step 7: environment ---- |
| func (e *Engine) inputs(ctx context.Context, p *pass, app App) (Inputs, error) { |
| - in := Inputs{Label: p.run.Label, TeamSQID: p.team.TeamSQID, Home: e.cfg.HomeCfg, CallsZone: e.cfg.CallsZone, RunOptions: p.run.Options} |
| + in := Inputs{Label: p.run.Label, Account: e.cfg.Account, TeamSQID: p.team.TeamSQID, Home: e.cfg.HomeCfg, CallsZone: e.cfg.CallsZone, RunOptions: p.run.Options} |
| if owner, ok, err := e.cfg.Store.Owner(ctx, p.run.Label); err != nil { |
| return in, err |
| } else if ok { |
| @@ -447,7 +447,7 @@ func (e *Engine) stepEnv(ctx context.Context, p *pass, app App) error { |
| // Paul's own post-run keys (an own team's Memoria AI), once he has |
| // set the whole group: Alta neither writes nor removes them. Part of |
| // one (a fork's blanked MEMORIA_AI) is any other key. |
| - operator := OperatorKeys(app, in.Profile) |
| + operator := OperatorKeys(app, in) |
| switch operatorState(operator, lookup(present)) { |
| case OperatorWhole: |
| for _, k := range operator { |
| @@ -728,8 +728,12 @@ func (e *Engine) stepServing(ctx context.Context, p *pass, app App) error { |
| // ---- steps 11 and 12: verify and activate (roster-mode apps) ---- |
| // TeamProbe is GET /api/team's readiness answer (team-members.md §7). |
| +// |
| +// A seeded app (Equipo, Base) answers team_mode false and seeded true, |
| +// with roster "ok" once an owner exists and "owner-pending" before. |
| type TeamProbe struct { |
| TeamMode bool `json:"team_mode"` |
| + Seeded bool `json:"seeded"` |
| Consumer string `json:"consumer"` |
| Roster string `json:"roster"` |
| } |
| @@ -794,7 +798,15 @@ func (e *Engine) stepVerify(ctx context.Context, p *pass, app App) error { |
| if status != http.StatusOK || json.Unmarshal(body, &probe) != nil { |
| return park("roster-unreadable") |
| } |
| - if !probe.TeamMode || probe.Consumer != ConsumerID(p.run.Label, app.Slug) { |
| + if probe.TeamMode == app.Seeded || probe.Seeded != app.Seeded { |
| + // A roster app answering seeded, or a seeded app claiming roster |
| + // mode, is not the build this recipe was written for. |
| + if probe.TeamMode || probe.Seeded { |
| + return park("probe-mode-mismatch") |
| + } |
| + return park("not-team-mode") |
| + } |
| + if probe.Consumer != ConsumerID(p.run.Label, app.Slug) { |
| return park("not-team-mode") |
| } |
| if probe.Roster != "ok" { |
| @@ -917,7 +929,7 @@ func (e *Engine) AuditEnvironment(ctx context.Context, label string, app App) er |
| } |
| // Paul's post-run group (an own team's Memoria AI) is admitted |
| // whole or not at all, never one key of it. |
| - operator := OperatorKeys(app, in.Profile) |
| + operator := OperatorKeys(app, in) |
| admitted := map[string]bool{} |
| switch operatorState(operator, lookup(present)) { |
| case OperatorPartial: |
| @@ -993,7 +1005,7 @@ func (e *Engine) stepAudit(ctx context.Context, p *pass, app App) error { |
| if err := e.AuditEnvironment(ctx, p.run.Label, app); err != nil { |
| return err |
| } |
| - pending := !app.Roster |
| + pending := !app.Roster && !app.Seeded |
| return e.record(ctx, p, app.Slug, StepAudit, map[string]any{"directory_pending": pending}) |
| } |