alta-adopt: rehearsal, crash-at-every-act, real-Home flow, runbook
The rehearsal runs the whole adoption against the fakes in Paul's order and again killed at every Home act and every CARLOS act (before and after the PUT, after the restart, mid-rollback), resuming from the journal. homecompat runs the Home half, with HomeQueries on Home's own tables, against Home's real operator code. README gains the runbook.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+1,488
−11
README.md+180 −0adopt/live_test.go+4 −2adopt/rehearsal_test.go+1,025 −0homecompat/adopt_flow_test.go+219 −0homecompat/compat_test.go+4 −3homecompat/go.mod+14 −0homecompat/go.sum+42 −6
diff --git a/README.md b/README.md| index f1e30b3..6232362 100644 |
| --- a/README.md |
| +++ b/README.md |
| @@ -207,10 +207,190 @@ recorded here instead (Fable's rulings on oficina/alta #1): |
| pair Paul sets by hand (see Profiles). |
| - **§11, Help**: the account menu has no Help items yet (no Colophon page). |
| +## Adopting the six existing apps (`alta-adopt`) |
| + |
| +`alta-adopt` is a second binary, run on Paul's machine and never deployed. |
| +It joins the six canonical apps (docs, sheets, slides, calendar, calls, |
| +memoria at `https://<app>.oficina.works`) to a Home directory team |
| +labelled `oficina`, named "Oficina", so oficina-connect can route an |
| +assistant's calls to them. On CARLOS it writes two keys per app, |
| +`<P>_AGENT_ISSUER = https://connect.oficina.works` and |
| +`<P>_AGENT_TEAM = <the team's SQID>`, and proves nothing else changed. It |
| +creates no instance and changes no Home key or `HOME_CONSUMERS`. |
| + |
| +The design is Home `implementation/existing-team-adoption.md`; the plan |
| +is `docs/superpowers/plans/2026-11-16-adoption-runner.md`. Every command |
| +is a dry run unless given `--apply`. Build it with `make adopt`. |
| + |
| +### Before the first run |
| + |
| +- **The config file** (`--config`, mode 0600, Paul's own) holds Alta's |
| + operator key, prefilter and pins, `ALTA_DEK`, the directory's |
| + provisioning key, the console and account, the state database's path, |
| + and `artifacts`. |
| +- **`home_issuer` must be `https://id.oficina.works`**, the runner's |
| + `adopt.HomeIssuerOrigin`. Any other value is refused when the config is |
| + loaded. The CARLOS preflight checks each app's `<P>_HOME_ISSUER` |
| + against the same constant (`home-issuer-mismatch`). |
| +- **`artifacts`** maps each app to the SHA-256 of the release name Paul |
| + reviewed, as 64 lowercase hex: the value `X-Carlos-Version` serves, for |
| + example `printf %s v1.4.0 | sha256sum`. Activation is refused for an |
| + app whose served release hashes to anything else. |
| +- **The CARLOS credential** is an Admin service token |
| + (`carlos services create --account oficina --role admin |
| + oficina-adoption`). It is passed on a file descriptor only |
| + (`--carlos-token-fd 3 3<token-file`), held in memory and zeroed on exit. |
| + It is never in the environment, the config or the state database. |
| +- **The state database** is the run's journal and Alta's operator stream. |
| + Back it up after each session. Never edit or delete it by hand, with one |
| + exception (Plan A failing before the seed, below). |
| +- Gated on CARLOS 522 Plan 1 (conditional writes and |
| + `restart/scope`) being on the production console, and, for the live |
| + checks, on oficina-connect being live with |
| + `HOME_AGENT_DIRECTORY_TOKEN_SHA256` set. |
| + |
| +### Phases |
| + |
| +Phases may fall in separate sessions on separate days. Home's plan windows |
| +last 15 minutes and are never extended, so each plan is its own short |
| +session. A witness has no age limit: it stays valid until the instance, |
| +the served version or the config it observed changes. |
| + |
| +| Phase | Command | What happens | |
| +|---|---|---| |
| +| 0a | `home-preflight --phase pre-initialize` | Both Home roles inspected, plus Paul's pasted table counts. | |
| +| 0b | `preflight` | Per app, read-only: the config's layers, any other instance that would inherit the keys (`inherits-<host>` stops the run), team-mode keys, identity, delivery. | |
| +| 1 | `initialize` | Directory `initialize`, after Paul types the §12 attestation. | |
| +| 2 | `home-preflight --phase pre-plan-a`, then `plan-a` | Owner-seed, seed-team, then provision and register (verify only) for all six. | |
| +| 3 | `configure --app <a>`, `witness --app <a>` | Per app: one conditional `PUT /config`, one restart of the canonical host only, the after snapshot, Paul's witnessed sign-in. | |
| +| 4 | `activate --apps calendar` | Plan B: calendar, the canary, is re-observed and activated. | |
| +| 5 | `live --event <id>` | Revocation and permission checks against connect, for calendar. | |
| +| 6 | `activate --apps docs,sheets,slides,calls,memoria` | Plan C. Refused unless every live check passed. | |
| + |
| +`initialize`, `plan-a` and `activate` open a plan. After Paul confirms it |
| +on Home, `advance --run <id> --apply` takes the run as far as it can go; |
| +run it again if it stops (`status` shows where every run is). |
| + |
| +### Paul's steps, in order |
| + |
| +1. **Home counts, before initialize.** Run |
| + `alta-adopt home-preflight --phase pre-initialize`. It prints eight |
| + read-only queries; run each with `carlos db query` against Home's |
| + directory and paste the counts. Rerun with `--apply` to record them. |
| +2. **CARLOS preflight.** Run `alta-adopt preflight`. Any code stops the |
| + run; `inherits-<host>` means another instance shares the layer the keys |
| + would go to. |
| +3. **Initialize.** Run `alta-adopt initialize --apply` and type the |
| + attestation. Confirm on |
| + [https://oficina.works/operator/confirm](https://oficina.works/operator/confirm) |
| + with a fresh passkey in the system browser, then |
| + `advance --run <id> --apply`. |
| +4. **Wait out the initialize window: 15 minutes from the confirmation.** |
| + The pre-plan-a preflight refuses (`plan-open`) while it is open. |
| +5. **Home counts, before Plan A.** Run |
| + `home-preflight --phase pre-plan-a --apply` with fresh counts. After |
| + initialize, `roster_generation` and `roster_operator_receipts` hold one |
| + row each; every other table is empty. |
| +6. **Plan A.** Run `plan-a --apply` and type the owner (Paul's own |
| + address). Confirm on |
| + [https://oficina.works/operator/confirm](https://oficina.works/operator/confirm), |
| + then on |
| + [https://id.oficina.works/operator/confirm](https://id.oficina.works/operator/confirm), |
| + retyping the owner. Both pages should show the SQID, the six canonical |
| + hosts, "Oficina" and the same 8-hex prefix. Then `advance`. |
| +7. **Configure.** For each app, `configure --app <a>` (dry run) and then |
| + with `--apply`: one config write and one restart, of that host only. |
| + `configure` waits until the app serves agent-access's challenge, then |
| + records the after snapshot. |
| +8. **Witness.** Sign in at `https://<app>.oficina.works` in the system |
| + browser, check it works as before, then run `witness --app <a> --apply` |
| + and type the sentence it prints. |
| +9. **Plan B.** Run `activate --apps calendar --apply`, confirm on both |
| + pages, then `advance`. |
| +10. **Test account.** Create a throwaway Oficina ID account. It must |
| + already belong to some team other than Oficina: connect refuses to |
| + authorize a person with no team (403 `access_denied`), and the |
| + browser sign-in then hangs until cancelled. Sign it in to calendar.oficina.works once. Pick one of |
| + Paul's own calendar events and note its id for `--event`. |
| +11. **Live checks.** Run `live --event <id> --apply` and follow its |
| + prompts: sign the test account in to connect; add it to the Oficina |
| + team on the Team page, and remove it again; witness both local |
| + sign-ins; connect Paul's own account. **Remove the member within 5 |
| + minutes of adding it:** the check replays the member's request after |
| + removal, and a token older than its 5-minute life proves nothing (the |
| + check is inconclusive and Plan C stays refused). The runner revokes |
| + every connection it makes, whatever happens. |
| +12. **Plan C.** Run `activate --apps docs,sheets,slides,calls,memoria |
| + --apply`, confirm on both pages, then `advance`. |
| +13. **Clean up.** `carlos services delete oficina-adoption`, back up the |
| + state database, and delete the test account if Paul wishes. |
| + |
| +### When a step stops |
| + |
| +- **Plan A fails before the team is seeded.** Home then holds no team, and |
| + the runner has no way to restart a failed Plan A. The ruled recovery |
| + (2026-11-16) is a fresh state database, with the old one kept aside. |
| + Nothing at Home needs undoing: an owner-seed receipt expires after |
| + 300 s and an unconfirmed plan after 15 minutes. As the runner stands, |
| + though, a fresh journal does not hold Alta's directory stream, so the |
| + pre-plan-a preflight refuses it (`directory-stream-foreign`), and |
| + `plan-a` needs that preflight. Stop and get the procedure reviewed |
| + before trying this. |
| +- **Plan A's window closes after the seed.** Run `plan-a --apply` again: |
| + it opens a continuation (`add-apps` for the seeded SQID) that provisions |
| + and registers only the apps still missing. Confirm it on both pages and |
| + `advance`. |
| +- **A plan lapses before confirmation.** `plan-a --apply` signs it again; |
| + for Plans B and C, run `activate` again. |
| +- **A process dies mid-configure** (closed laptop, lost network). Run the |
| + same `configure --app <a> --apply` again. It rereads the console and |
| + continues from the journal: a write that landed is found, never sent |
| + twice; the baseline is never retaken. A restart may be repeated. |
| +- **A stop** (`preserved-changed`, `agent-keys-conflict`, |
| + `agent-keys-foreign`) is final for that app until someone has looked at |
| + the console. The runner never unsets a value it did not write. |
| +- **A live check fails.** Plan C stays refused for good: a failure means |
| + revocation or membership is not enforced. Investigate before anything |
| + else. |
| +- **Activation parks with `observe-<codes>`.** The re-observation just |
| + before activation no longer matches the journal; the codes name what |
| + moved (`witness-superseded`, `config-<key>`, `identity-<field>`, |
| + `artifact-mismatch`, …). Nothing was activated. Find out what changed |
| + before going on. |
| + |
| +### Every production write, and its rollback |
| + |
| +| # | Write | Where | Rollback | |
| +|---|---|---|---| |
| +| 1 | `directory.initialize` | Home directory | **None**, by design. Gated on the Home preflight and the §12 attestation. | |
| +| 2 | Plan submissions for initialize, A, B and C, both roles | Home `operator_plans` | An unconfirmed plan expires after 15 minutes and is swept. | |
| +| 3 | `credential.owner-seed` | Home credential | None needed: the receipt expires after 300 s. | |
| +| 4 | `directory.seed-team` `oficina` / "Oficina", Paul as owner | Home directory | None (nothing is deleted). The team is inert without a live instance, and the label is reserved. | |
| +| 5 | `directory.provision-consumer` ×6 | Home directory | `alta-adopt disable --app <a> --apply`: a retire-apps plan, then `directory.disable-consumer`. | |
| +| 6 | `credential.register-consumer` ×6 (verify only, nothing inserted) | Home credential | None needed. | |
| +| 7 | Conditional `PUT /config` of `<P>_AGENT_ISSUER` and `<P>_AGENT_TEAM`, one per app | CARLOS `oficina`, the canonical host's layer | `rollback-config --app <a> --apply`: a journalled conditional unset that refuses foreign values, **then the scoped restart (dry run first)**. Complete only when the probe shows the old operations shape again. | |
| +| 8 | `POST …/restart/scope {"host"}` after its dry run, one per app | CARLOS, that host only | Restart again after the rollback. | |
| +| 9 | `directory.verify-consumer` per app | Home directory | Expires after 600 s. | |
| +| 10 | `directory.activate-consumer` per app | Home directory | Immediately: row 7's rollback, which stops delegated access at the app. Then `disable`. A revoke at connect also works. | |
| +| 11 | Test connections at connect, and the member's add and remove (Paul) | connect, Home directory | The runner always revokes its connections. Paul removes the member. | |
| + |
| +From row 4 onward, keep Home on an adoption-capable build: **never |
| +downgrade it, restore an older snapshot, or delete rows.** |
| + |
| +### Rehearsal |
| + |
| +`adopt/rehearsal_test.go` runs the whole adoption against the fakes, in |
| +the order above, then again killed at every Home act and at every CARLOS |
| +act (before and after the PUT, after the restart, mid-rollback), resuming |
| +each time from the journal. `homecompat/adopt_flow_test.go` runs the Home |
| +half, with the preflight's own queries, against Home's real operator |
| +code. |
| + |
| ## Developing |
| make ci # vet, gofmt, tests, and the Home compatibility module |
| make release # linux/arm64, stamped with git describe |
| + make adopt # the local adoption runner, releases/alta-adopt |
| Tests run the state machine against `homeop/fakehome` and |
| `console/fakeconsole` (including a crash after every act, a lost answer |
diff --git a/adopt/live_test.go b/adopt/live_test.go| index 7157af6..6ec453e 100644 |
| --- a/adopt/live_test.go |
| +++ b/adopt/live_test.go |
| @@ -55,6 +55,7 @@ type fakeConnect struct { |
| srv *httptest.Server |
| mu sync.Mutex |
| + team string // the adopted team's SQID: liveSQID unless set |
| members map[string]bool |
| logins []string // who signs in at each successive browser open |
| codes map[string]string |
| @@ -78,6 +79,7 @@ type fakeConnect struct { |
| func newFakeConnect(t *testing.T) *fakeConnect { |
| f := &fakeConnect{ |
| t: t, |
| + team: liveSQID, |
| members: map[string]bool{subjOwner: true}, |
| logins: []string{subjTest, subjTest, subjOwner}, |
| codes: map[string]string{}, |
| @@ -133,7 +135,7 @@ func (f *fakeConnect) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| } |
| teams := []string{"team-other"} |
| if f.members[subject] { |
| - teams = append(teams, liveSQID) |
| + teams = append(teams, f.team) |
| } |
| tok := "bearer-canary-" + randHex() |
| ft := &fakeToken{index: len(f.issued), subject: subject, teams: teams} |
| @@ -249,7 +251,7 @@ func (f *fakeConnect) verify(w http.ResponseWriter, r *http.Request) *fakeToken |
| func (f *fakeConnect) teamsOf(ft *fakeToken) []string { |
| out := []string{} |
| for _, team := range ft.teams { |
| - if team == liveSQID && !f.members[ft.subject] && !f.membershipNotEnforced { |
| + if team == f.team && !f.members[ft.subject] && !f.membershipNotEnforced { |
| continue |
| } |
| out = append(out, team) |
diff --git a/adopt/rehearsal_test.go b/adopt/rehearsal_test.go| new file mode 100644 |
| index 0000000..6e19600 |
| --- /dev/null |
| +++ b/adopt/rehearsal_test.go |
| @@ -0,0 +1,1025 @@ |
| +package adopt |
| + |
| +// The rehearsal: the whole adoption in the order Paul runs it, against |
| +// the in-memory Home, the fake console, the six apps' origins and a fake |
| +// connect. Home preflights, CARLOS preflight, initialize, Plan A, |
| +// configure and witness for each app, Plan B for the canary, the live |
| +// checks, Plan C. Then the same run killed at every act, Home's and |
| +// CARLOS's, and resumed by a fresh process. |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "database/sql" |
| + "encoding/json" |
| + "errors" |
| + "fmt" |
| + "io" |
| + "log/slog" |
| + "net" |
| + "net/http" |
| + "net/http/httptest" |
| + "net/http/httputil" |
| + "net/url" |
| + "path/filepath" |
| + "reflect" |
| + "slices" |
| + "strings" |
| + "sync" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/alta/carlosop" |
| + "amadan.net/oficina/alta/carlosop/fakecarlos" |
| + "amadan.net/oficina/alta/console" |
| + "amadan.net/oficina/alta/homeop" |
| + "amadan.net/oficina/alta/homeop/fakehome" |
| + "amadan.net/oficina/alta/provision" |
| + family "amadan.net/rastrillo/rastrillo/crypto" |
| +) |
| + |
| +const rehearsalOwner = "rehearsal-owner-canary@oficina.test" |
| + |
| +// crashPoint is where a CARLOS process dies: on its first request of that |
| +// kind for an app, once per app. Before: the request never reaches the |
| +// console. After: the console has acted, and the answer never arrives. |
| +type crashPoint string |
| + |
| +const ( |
| + noCrash crashPoint = "" |
| + beforePut crashPoint = "before-put" |
| + afterPut crashPoint = "after-put" |
| + afterRestart crashPoint = "after-restart" |
| +) |
| + |
| +// rehearsal is one adoption, start to finish. |
| +type rehearsal struct { |
| + t *testing.T |
| + |
| + mu sync.Mutex |
| + now time.Time |
| + |
| + home *fakehome.Home |
| + hc *homeop.Client |
| + carlos *fakecarlos.Fake |
| + h *http.Client // the apps' origins |
| + connect *fakeConnect |
| + |
| + path string // the state database |
| + ps *provision.Store |
| + js *Store |
| + cfg provision.Config |
| + actsMu sync.Mutex |
| + acts []string // every Home act, in order |
| + |
| + sites map[string]*appSite |
| + |
| + // CARLOS crashes: which apps have died at the point already, and what |
| + // the console saw. |
| + crashed map[string]bool |
| + puts map[string]int // PUT /config reaching the console, per app |
| + foreign []string // an unset of a value the runner did not write |
| + sealed map[string][]byte // each baseline's sealed bytes, as first seen |
| + before map[string]layerState |
| + release chan struct{} |
| + zombies sync.WaitGroup |
| + cancels []context.CancelFunc |
| + closers []func() |
| + sqid string |
| + planARun int64 |
| +} |
| + |
| +// layerState is an app's two stored layers: the canonical host's default |
| +// bundle and its neighbour's own environment. |
| +type layerState struct { |
| + def, env map[string]fakecarlos.Var |
| + defVer, envVer string |
| +} |
| + |
| +// appSite is one app's process: it serves agent-access's challenge only |
| +// once a restart has loaded both of its agent keys. |
| +type appSite struct { |
| + mu sync.Mutex |
| + seen int |
| + loaded bool |
| +} |
| + |
| +func neighbourHost(app string) string { return "staging." + app + ".example" } |
| +func neighbourEnv(app string) string { return "acme-" + app } |
| + |
| +func newRehearsal(t *testing.T) *rehearsal { |
| + t.Helper() |
| + r := &rehearsal{t: t, now: time.Unix(2_000_000_000, 0), sites: map[string]*appSite{}, |
| + crashed: map[string]bool{}, puts: map[string]int{}, sealed: map[string][]byte{}, before: map[string]layerState{}, |
| + release: make(chan struct{})} |
| + // First registered, so it runs last: a dead process is let go, waited |
| + // for, and only then are its console door and journal closed. |
| + t.Cleanup(func() { |
| + close(r.release) |
| + for _, c := range r.cancels { |
| + c() |
| + } |
| + r.zombies.Wait() |
| + for i := len(r.closers) - 1; i >= 0; i-- { |
| + r.closers[i]() |
| + } |
| + }) |
| + fastPolls(t, 5*time.Millisecond, 2*time.Second) |
| + |
| + key, err := family.Generate() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + pre := homeop.Token() |
| + const credOrigin, dirOrigin = HomeIssuerOrigin, "https://oficina.works" |
| + r.home = fakehome.New(key.SignPub(), pre, credOrigin, dirOrigin, r.clock) |
| + pins := r.home.SharePins() |
| + r.home.AddPerson(rehearsalOwner) |
| + for _, a := range provision.Slugs() { |
| + r.home.AddEnvConsumer(a, homeop.CanonicalOrigin(a)) |
| + } |
| + roles := map[string]homeop.Role{} |
| + for name, origin := range map[string]string{homeop.Credential: credOrigin, homeop.Directory: dirOrigin} { |
| + srv := httptest.NewServer(r.home.Handler(name)) |
| + t.Cleanup(srv.Close) |
| + roles[name] = homeop.Role{Name: name, Origin: origin, URL: srv.URL, Installation: pins.Installation, Registry: pins.Registry, Device: pins.Device} |
| + } |
| + r.hc = &homeop.Client{Key: key, Prefilter: pre, Roles: roles, Now: r.clock} |
| + |
| + r.carlos = fakecarlos.New(fixtureAccount) |
| + t.Cleanup(r.carlos.Close) |
| + r.carlos.BeforePut = func(app string) { |
| + r.mu.Lock() |
| + r.puts[app]++ |
| + r.mu.Unlock() |
| + } |
| + for _, a := range provision.Apps { |
| + p := a.Prefix |
| + r.carlos.SetVar(a.Slug, "", p+"_HOME_ISSUER", HomeIssuerOrigin) |
| + r.carlos.SetVar(a.Slug, "", p+"_HOME_CONSUMER_ID", provision.ConsumerID(provision.AdoptionLabel, a.Slug)) |
| + r.carlos.SetVar(a.Slug, "", p+"_ORIGIN", valueOrigin) |
| + r.carlos.SetSecret(a.Slug, "", p+"_INSTANCE_KEY") |
| + r.carlos.SetSecret(a.Slug, "", p+"_DB_KEY") |
| + r.carlos.AddInstance(carlosop.Instance{ |
| + Host: CanonicalHost(a), App: a.Slug, Slug: "s-" + a.Slug, Channel: "stable", Region: "eu", |
| + CreatedAt: time.Date(2026, 3, 1, 0, 0, 0, 0, time.UTC), RecordSeq: 4, |
| + ReplicaAssignment: json.RawMessage(`{"boxes":["b1"]}`), |
| + }) |
| + // A neighbour on its own owned environment: it shares no layer |
| + // with the canonical host, so it never sees the keys, and it is |
| + // never restarted. |
| + r.carlos.SetVar(a.Slug, neighbourEnv(a.Slug), p+"_HOME_ISSUER", HomeIssuerOrigin) |
| + r.carlos.SetSecret(a.Slug, neighbourEnv(a.Slug), p+"_INSTANCE_KEY") |
| + r.carlos.Own(a.Slug, neighbourEnv(a.Slug), "alta") |
| + r.carlos.AddInstance(carlosop.Instance{Host: neighbourHost(a.Slug), App: a.Slug, Slug: "s-n-" + a.Slug, Environment: neighbourEnv(a.Slug), |
| + Channel: "stable", Region: "eu", CreatedAt: time.Date(2026, 4, 1, 0, 0, 0, 0, time.UTC)}) |
| + r.sites[a.Slug] = &appSite{} |
| + r.before[a.Slug] = r.layers(a.Slug) |
| + } |
| + |
| + site := httptest.NewTLSServer(http.HandlerFunc(r.site)) |
| + t.Cleanup(site.Close) |
| + tr := site.Client().Transport.(*http.Transport).Clone() |
| + addr := site.Listener.Addr().String() |
| + tr.DialContext = func(ctx context.Context, network, _ string) (net.Conn, error) { |
| + var d net.Dialer |
| + return d.DialContext(ctx, network, addr) |
| + } |
| + tr.TLSClientConfig.ServerName = "example.com" |
| + r.h = &http.Client{Transport: tr, Timeout: 10 * time.Second} |
| + |
| + r.connect = newFakeConnect(t) |
| + oldT, oldNow := liveTransport, liveNow |
| + liveTransport = r.connect.srv.Client().Transport |
| + liveNow = time.Now |
| + t.Cleanup(func() { liveTransport, liveNow = oldT, oldNow }) |
| + |
| + r.path = filepath.Join(t.TempDir(), "alta.db") |
| + r.ps, r.js = r.journal() |
| + r.cfg = provision.Config{ |
| + Store: r.ps, Home: r.hc, |
| + Console: &console.Client{HTTP: &http.Client{Transport: offlineNet{}}, Base: "https://console.invalid", Account: fixtureAccount, Tokens: map[string]string{}}, |
| + Public: &http.Client{Transport: offlineNet{}}, |
| + HomeCfg: provision.HomeConfig{Issuer: credOrigin, Directory: dirOrigin, Provisioner: r.home.ProvisioningPublic()}, |
| + Account: fixtureAccount, Now: r.clock, Logger: slog.New(slog.NewTextHandler(io.Discard, nil)), |
| + AfterAct: func(key string) error { |
| + r.actsMu.Lock() |
| + r.acts = append(r.acts, key) |
| + r.actsMu.Unlock() |
| + return nil |
| + }, |
| + } |
| + return r |
| +} |
| + |
| +func (r *rehearsal) clock() time.Time { |
| + r.mu.Lock() |
| + defer r.mu.Unlock() |
| + return r.now |
| +} |
| + |
| +func (r *rehearsal) tick(d time.Duration) { |
| + r.mu.Lock() |
| + defer r.mu.Unlock() |
| + r.now = r.now.Add(d) |
| +} |
| + |
| +// journal opens the state database as a fresh process does. |
| +func (r *rehearsal) journal() (*provision.Store, *Store) { |
| + r.t.Helper() |
| + db, err := provision.OpenDB(r.path) |
| + if err != nil { |
| + r.t.Fatal(err) |
| + } |
| + r.closers = append(r.closers, func() { db.Close() }) |
| + ps, err := provision.NewStore(context.Background(), db, bytes.Repeat([]byte{4}, 32), r.clock, Schema) |
| + if err != nil { |
| + r.t.Fatal(err) |
| + } |
| + js, err := NewStore(ps) |
| + if err != nil { |
| + r.t.Fatal(err) |
| + } |
| + return ps, js |
| +} |
| + |
| +func (r *rehearsal) layers(app string) layerState { |
| + var s layerState |
| + s.def, s.defVer, _ = r.carlos.Layer(app, "") |
| + s.env, s.envVer, _ = r.carlos.Layer(app, neighbourEnv(app)) |
| + return s |
| +} |
| + |
| +func (r *rehearsal) site(w http.ResponseWriter, req *http.Request) { |
| + host, _, err := net.SplitHostPort(req.Host) |
| + if err != nil { |
| + host = req.Host |
| + } |
| + slug := strings.TrimSuffix(host, ".oficina.works") |
| + switch req.URL.Path { |
| + case "/api/version": |
| + w.Header().Set("X-Carlos-Version", valueVersion) |
| + _, _ = io.WriteString(w, valueVersion) |
| + case "/healthz": |
| + w.WriteHeader(http.StatusOK) |
| + case "/api/v1/operations": |
| + if !r.serving(slug) { |
| + http.NotFound(w, req) |
| + return |
| + } |
| + agent401(w) |
| + default: |
| + http.NotFound(w, req) |
| + } |
| +} |
| + |
| +func (r *rehearsal) serving(slug string) bool { |
| + s, ok := r.sites[slug] |
| + a, known := provision.AppBySlug(slug) |
| + if !ok || !known { |
| + return false |
| + } |
| + s.mu.Lock() |
| + defer s.mu.Unlock() |
| + if n := r.carlos.RestartCount(CanonicalHost(a)); n != s.seen { |
| + vars, _, _ := r.carlos.Layer(slug, "") |
| + keys := AgentKeys(a) |
| + _, i := vars[keys[0]] |
| + _, t := vars[keys[1]] |
| + s.seen, s.loaded = n, i && t |
| + } |
| + return s.loaded |
| +} |
| + |
| +// ---- Home's half ---- |
| + |
| +func (r *rehearsal) confirm(kind string) { |
| + r.t.Helper() |
| + if err := r.home.Confirm(homeop.Directory, ""); err != nil { |
| + r.t.Fatal(err) |
| + } |
| + if kind == homeop.KindInitialize { |
| + return |
| + } |
| + owner := "" |
| + if kind == homeop.KindCreateTeam { |
| + owner = rehearsalOwner |
| + } |
| + if err := r.home.Confirm(homeop.Credential, owner); err != nil { |
| + r.t.Fatal(err) |
| + } |
| +} |
| + |
| +// drive advances run until it is done or failed, each pass a fresh |
| +// engine, as alta-adopt advance is: a pass killed by AfterAct resumes in |
| +// the next. |
| +func (r *rehearsal) drive(run int64, obs provision.Observer) provision.Run { |
| + r.t.Helper() |
| + var out provision.Run |
| + for i := 0; i < 30; i++ { |
| + cfg := r.cfg |
| + if obs != nil { |
| + cfg.Observer = obs |
| + } |
| + if err := provision.New(cfg).Advance(context.Background(), run); err != nil { |
| + var fl *provision.Fail |
| + if errors.As(err, &fl) { |
| + r.t.Fatalf("run %d failed: %s", run, fl.Code) |
| + } |
| + } |
| + var err error |
| + if out, err = r.ps.Run(context.Background(), run); err != nil { |
| + r.t.Fatal(err) |
| + } |
| + if out.State == "done" || out.State == "failed" { |
| + return out |
| + } |
| + r.tick(5 * time.Second) |
| + } |
| + return out |
| +} |
| + |
| +func (r *rehearsal) engine(obs provision.Observer) *provision.Engine { |
| + cfg := r.cfg |
| + if obs != nil { |
| + cfg.Observer = obs |
| + } |
| + return provision.New(cfg) |
| +} |
| + |
| +// homePreflight is alta-adopt home-preflight --apply: Paul's pasted |
| +// counts, both roles inspected, recorded only when nothing is refused. |
| +func (r *rehearsal) homePreflight(phase string) { |
| + r.t.Helper() |
| + counts := map[string]int64{} |
| + for _, q := range HomeQueries() { |
| + counts[q[strings.LastIndex(q, " ")+1:]] = 0 |
| + } |
| + if phase == PhasePrePlanA { |
| + counts["roster_generation"], counts["roster_operator_receipts"] = 1, 1 |
| + } |
| + rec, codes, err := CheckHome(context.Background(), r.hc, r.ps, counts, phase) |
| + if err != nil || len(codes) > 0 { |
| + r.t.Fatalf("home preflight %s: %v %v", phase, codes, err) |
| + } |
| + if err := r.js.SaveHomePreflight(context.Background(), rec); err != nil { |
| + r.t.Fatal(err) |
| + } |
| +} |
| + |
| +func (r *rehearsal) initialize() { |
| + r.t.Helper() |
| + run, err := r.engine(nil).StartInitialize(context.Background(), provision.InitializeAttestation) |
| + if err != nil { |
| + r.t.Fatal(err) |
| + } |
| + r.confirm(homeop.KindInitialize) |
| + if got := r.drive(run, nil); got.State != "done" { |
| + r.t.Fatalf("initialize: %s %s", got.State, got.Code) |
| + } |
| +} |
| + |
| +func (r *rehearsal) planA() { |
| + r.t.Helper() |
| + run, err := r.engine(nil).StartAdoption(context.Background(), "Oficina", rehearsalOwner) |
| + if err != nil { |
| + r.t.Fatal(err) |
| + } |
| + r.planARun = run |
| + r.confirm(homeop.KindCreateTeam) |
| + if got := r.drive(run, nil); got.State != "done" || got.Code != "awaiting-configuration" { |
| + r.t.Fatalf("plan A: %s %s", got.State, got.Code) |
| + } |
| + team, err := r.ps.Team(context.Background(), provision.AdoptionLabel) |
| + if err != nil || team.TeamSQID == "" { |
| + r.t.Fatalf("no seeded team: %v", err) |
| + } |
| + r.sqid = team.TeamSQID |
| + r.connect.team = r.sqid |
| +} |
| + |
| +// observer is the activation gate as alta-adopt builds it, over a fresh |
| +// console client. |
| +func (r *rehearsal) observer() *Observer { |
| + c := carlosop.New(r.carlos.URL(), fixtureAccount, r.carlos.Token()) |
| + r.closers = append(r.closers, c.Close) |
| + artifacts := map[string]string{} |
| + for _, a := range provision.Slugs() { |
| + artifacts[a] = sha256Hex(valueVersion) |
| + } |
| + return &Observer{C: c, H: r.h, S: r.js, Artifacts: artifacts, Now: r.clock} |
| +} |
| + |
| +// activate is Plan B or C: alta-adopt activate --apply, the two |
| +// confirmations, then advance until done. |
| +func (r *rehearsal) activate(apps ...string) { |
| + r.t.Helper() |
| + // Each plan waits out the last one's window. |
| + r.tick(homeop.WindowLifetime * time.Second) |
| + obs := r.observer() |
| + run, err := r.engine(obs).ActivateAdopted(context.Background(), apps) |
| + if err != nil { |
| + r.t.Fatalf("activate %v: %v", apps, err) |
| + } |
| + r.confirm(homeop.KindAddApps) |
| + if got := r.drive(run, obs); got.State != "done" { |
| + r.t.Fatalf("activate %v: %s %s", apps, got.State, got.Code) |
| + } |
| +} |
| + |
| +// ---- CARLOS's half: each step is a process that may die ---- |
| + |
| +// proc is one alta-adopt process's console client, through a door that |
| +// kills the process at its crash point: the request is held for good |
| +// (before) or answered to no one (after), and the process never runs |
| +// another line. |
| +type proc struct { |
| + c *carlosop.Client |
| + dead chan struct{} |
| + once sync.Once |
| +} |
| + |
| +func (p *proc) die() { p.once.Do(func() { close(p.dead) }) } |
| + |
| +func (r *rehearsal) newProc(point crashPoint) *proc { |
| + p := &proc{dead: make(chan struct{})} |
| + target, err := url.Parse(r.carlos.URL()) |
| + if err != nil { |
| + r.t.Fatal(err) |
| + } |
| + rp := httputil.NewSingleHostReverseProxy(target) |
| + // A connection the console dropped is dropped here too: the runner |
| + // meets a lost answer, never a 502 of the door's making. |
| + rp.ErrorHandler = func(http.ResponseWriter, *http.Request, error) { panic(http.ErrAbortHandler) } |
| + hold := func() { |
| + <-r.release |
| + panic(http.ErrAbortHandler) |
| + } |
| + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { |
| + select { |
| + case <-p.dead: |
| + hold() |
| + default: |
| + } |
| + body, _ := io.ReadAll(req.Body) |
| + req.Body = io.NopCloser(bytes.NewReader(body)) |
| + app, kind := r.classify(req, body) |
| + hit := kind == "put" && (point == beforePut || point == afterPut) || kind == "restart" && point == afterRestart |
| + if hit && r.dies(app) { |
| + if point == beforePut { |
| + p.die() |
| + hold() |
| + } |
| + rp.ServeHTTP(httptest.NewRecorder(), req) |
| + p.die() |
| + hold() |
| + } |
| + rp.ServeHTTP(w, req) |
| + })) |
| + p.c = carlosop.New(srv.URL, fixtureAccount, r.carlos.Token()) |
| + r.closers = append(r.closers, srv.Close, p.c.Close) |
| + return p |
| +} |
| + |
| +// dies reports whether app has yet to die at the crash point, and marks |
| +// it dead. |
| +func (r *rehearsal) dies(app string) bool { |
| + r.mu.Lock() |
| + defer r.mu.Unlock() |
| + if r.crashed[app] { |
| + return false |
| + } |
| + r.crashed[app] = true |
| + return true |
| +} |
| + |
| +// classify names a console request's app and kind ("put", "restart" for |
| +// a scoped restart that is not a dry run, or ""), and checks every unset |
| +// against the stored values: the runner unsets only what it wrote. |
| +func (r *rehearsal) classify(req *http.Request, body []byte) (app, kind string) { |
| + parts := strings.Split(strings.TrimPrefix(req.URL.Path, "/api/cli/apps/"), "/") |
| + if len(parts) < 3 { |
| + return "", "" |
| + } |
| + app, door := parts[1], "/"+strings.Join(parts[2:], "/") |
| + switch { |
| + case req.Method == http.MethodPut && door == "/config": |
| + var w struct { |
| + Environment string `json:"environment"` |
| + Unset []string `json:"unset"` |
| + } |
| + _ = json.Unmarshal(body, &w) |
| + if a, ok := provision.AppBySlug(app); ok && len(w.Unset) > 0 { |
| + vars, _, _ := r.carlos.Layer(app, w.Environment) |
| + keys := AgentKeys(a) |
| + ours := map[string]string{keys[0]: Issuer, keys[1]: r.sqid} |
| + for _, k := range w.Unset { |
| + if v, ok := vars[k]; ok && (v.Kind != "env" || v.Value != ours[k]) { |
| + r.mu.Lock() |
| + r.foreign = append(r.foreign, app+":"+k) |
| + r.mu.Unlock() |
| + } |
| + } |
| + } |
| + return app, "put" |
| + case req.Method == http.MethodPost && door == "/restart/scope": |
| + var w struct { |
| + DryRun bool `json:"dry_run"` |
| + } |
| + if json.Unmarshal(body, &w) == nil && !w.DryRun { |
| + return app, "restart" |
| + } |
| + } |
| + return app, "" |
| +} |
| + |
| +// step runs fn as one alta-adopt process at a time, killed at point the |
| +// first time app reaches it, until a process finishes. A dead process is |
| +// left where it died; the next one opens the journal afresh. |
| +func (r *rehearsal) step(app string, point crashPoint, fn func(ctx context.Context, c *carlosop.Client, js *Store) error) (deaths int) { |
| + r.t.Helper() |
| + for { |
| + p := r.newProc(point) |
| + _, js := r.journal() |
| + ctx, cancel := context.WithCancel(context.Background()) |
| + r.cancels = append(r.cancels, cancel) |
| + done := make(chan error, 1) |
| + r.zombies.Add(1) |
| + go func() { |
| + defer r.zombies.Done() |
| + done <- fn(ctx, p.c, js) |
| + }() |
| + select { |
| + case err := <-done: |
| + if err != nil { |
| + r.t.Fatalf("%s: %v", app, err) |
| + } |
| + return deaths |
| + case <-p.dead: |
| + deaths++ |
| + if deaths > 1 { |
| + r.t.Fatalf("%s died twice", app) |
| + } |
| + r.sawBaseline(app) |
| + } |
| + } |
| +} |
| + |
| +// sawBaseline keeps app's sealed baseline bytes the first time they are |
| +// seen; checkBaselines fails if any has moved since. |
| +func (r *rehearsal) sawBaseline(app string) { |
| + r.t.Helper() |
| + var b []byte |
| + err := r.ps.DB().QueryRow("SELECT sealed FROM adopt_baselines WHERE app=?", app).Scan(&b) |
| + if errors.Is(err, sql.ErrNoRows) { |
| + return |
| + } |
| + if err != nil { |
| + r.t.Fatal(err) |
| + } |
| + if _, ok := r.sealed[app]; !ok { |
| + r.sealed[app] = b |
| + } |
| +} |
| + |
| +func (r *rehearsal) checkBaselines() { |
| + r.t.Helper() |
| + for app, want := range r.sealed { |
| + var got []byte |
| + if err := r.ps.DB().QueryRow("SELECT sealed FROM adopt_baselines WHERE app=?", app).Scan(&got); err != nil { |
| + r.t.Fatal(err) |
| + } |
| + if !bytes.Equal(got, want) { |
| + r.t.Fatalf("%s: the sealed baseline moved", app) |
| + } |
| + } |
| +} |
| + |
| +// configure is alta-adopt configure --app --apply: the write, then, unless |
| +// the after snapshot is already taken, the restart until delivered and |
| +// the after snapshot. |
| +func configureApp(ctx context.Context, c *carlosop.Client, h *http.Client, js *Store, a provision.App, sqid string) error { |
| + if _, err := WriteAgentKeys(ctx, c, h, js, a, sqid, true); err != nil { |
| + return err |
| + } |
| + if _, ok, err := js.After(ctx, a.Slug); err != nil || ok { |
| + return err |
| + } |
| + base, ok, err := js.Baseline(ctx, a.Slug) |
| + if err != nil || !ok { |
| + return fmt.Errorf("no baseline: %v", err) |
| + } |
| + if _, err := RestartAndWait(ctx, c, h, a, base.Identity, func(d Delivery) error { return Delivered(base.Delivery, d) }, true); err != nil { |
| + return err |
| + } |
| + _, err = CaptureAfter(ctx, c, h, js, a) |
| + return err |
| +} |
| + |
| +func (r *rehearsal) configure(a provision.App, point crashPoint) int { |
| + r.t.Helper() |
| + deaths := r.step(a.Slug, point, func(ctx context.Context, c *carlosop.Client, js *Store) error { |
| + return configureApp(ctx, c, r.h, js, a, r.sqid) |
| + }) |
| + r.sawBaseline(a.Slug) |
| + return deaths |
| +} |
| + |
| +func (r *rehearsal) witness(a provision.App) { |
| + r.t.Helper() |
| + r.step(a.Slug, noCrash, func(ctx context.Context, c *carlosop.Client, js *Store) error { |
| + return RecordWitness(ctx, js, c, r.h, a, WitnessSentence(a), true) |
| + }) |
| +} |
| + |
| +func (r *rehearsal) rollback(a provision.App, point crashPoint) int { |
| + r.t.Helper() |
| + return r.step(a.Slug, point, func(ctx context.Context, c *carlosop.Client, js *Store) error { |
| + return RollbackAgentKeys(ctx, c, r.h, js, a, true) |
| + }) |
| +} |
| + |
| +// carlosPreflight is alta-adopt preflight: every app clean. |
| +func (r *rehearsal) carlosPreflight() { |
| + r.t.Helper() |
| + c := carlosop.New(r.carlos.URL(), fixtureAccount, r.carlos.Token()) |
| + defer c.Close() |
| + for _, a := range provision.Apps { |
| + if _, codes, err := Preflight(context.Background(), c, r.h, a, nil); err != nil || len(codes) > 0 { |
| + r.t.Fatalf("preflight %s: %v %v", a.Slug, codes, err) |
| + } |
| + } |
| +} |
| + |
| +// live is alta-adopt live --apply, Paul at the prompts. |
| +func (r *rehearsal) live() { |
| + r.t.Helper() |
| + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) |
| + defer cancel() |
| + p := &fakePrompter{f: r.connect} |
| + if err := RunLive(ctx, io.Discard, r.connect.srv.URL, r.sqid, p, r.js, r.connect.open, liveEvent, true); err != nil { |
| + r.t.Fatalf("live: %v", err) |
| + } |
| + allRevoked(r.t, r.connect) |
| +} |
| + |
| +// ---- the run ---- |
| + |
| +// options bends one run: where a CARLOS process dies, and a hook on every |
| +// Home act. |
| +type options struct { |
| + configure crashPoint |
| + lose bool // the first answer to each app's PUT is lost |
| + afterAct func(string) error |
| +} |
| + |
| +// run is the whole adoption, in order, through Plan C. |
| +func (r *rehearsal) run(o options) { |
| + r.t.Helper() |
| + if o.afterAct != nil { |
| + record := r.cfg.AfterAct |
| + r.cfg.AfterAct = func(key string) error { |
| + if err := o.afterAct(key); err != nil { |
| + return err |
| + } |
| + return record(key) |
| + } |
| + } |
| + r.untilPlanA() |
| + for _, a := range provision.Apps { |
| + if o.lose { |
| + r.carlos.LoseNextAnswer() |
| + } |
| + if deaths := r.configure(a, o.configure); o.configure != noCrash && deaths != 1 { |
| + r.t.Fatalf("%s: died %d times at %s", a.Slug, deaths, o.configure) |
| + } |
| + } |
| + for _, a := range provision.Apps { |
| + r.witness(a) |
| + } |
| + r.activate(CanaryApp) |
| + r.live() |
| + var rest []string |
| + for _, s := range provision.Slugs() { |
| + if s != CanaryApp { |
| + rest = append(rest, s) |
| + } |
| + } |
| + r.activate(rest...) |
| +} |
| + |
| +// untilPlanA is the run through Plan A: both preflights, initialize, the |
| +// wait for its window to lapse, the second Home preflight, Plan A. |
| +func (r *rehearsal) untilPlanA() { |
| + r.t.Helper() |
| + r.homePreflight(PhasePreInitialize) |
| + r.carlosPreflight() |
| + r.initialize() |
| + // pre-plan-a refuses while the initialize window is open. |
| + r.tick(homeop.WindowLifetime * time.Second) |
| + r.homePreflight(PhasePrePlanA) |
| + r.planA() |
| +} |
| + |
| +// ---- what must hold at the end ---- |
| + |
| +// adopted fails unless the run ended as it must: six live routes, every |
| +// preserved digest equal along baseline, after and fresh, each layer |
| +// changed by the two keys alone, nothing else restarted, nothing |
| +// committed twice at Home. |
| +func (r *rehearsal) adopted() { |
| + r.t.Helper() |
| + t := r.t |
| + ctx := context.Background() |
| + for _, s := range provision.Slugs() { |
| + if st := r.home.InstanceState(s); st != "live" { |
| + t.Fatalf("%s is %q at Home, want live", s, st) |
| + } |
| + } |
| + reqs := r.home.Requests() |
| + onceEachRequest(t, reqs) |
| + for _, s := range provision.Slugs() { |
| + for _, action := range []string{homeop.DirectoryProvision, homeop.CredentialRegister, homeop.DirectoryVerify, homeop.DirectoryActivate} { |
| + if n := countRequests(reqs, action+":"+s); n != 1 { |
| + t.Fatalf("%s:%s committed %d times", action, s, n) |
| + } |
| + } |
| + } |
| + |
| + c := carlosop.New(r.carlos.URL(), fixtureAccount, r.carlos.Token()) |
| + defer c.Close() |
| + for _, a := range provision.Apps { |
| + keys := AgentKeys(a) |
| + base, ok, err := r.js.Baseline(ctx, a.Slug) |
| + if err != nil || !ok { |
| + t.Fatalf("%s: no baseline", a.Slug) |
| + } |
| + after, ok, err := r.js.After(ctx, a.Slug) |
| + if err != nil || !ok { |
| + t.Fatalf("%s: no after snapshot", a.Slug) |
| + } |
| + fresh, err := Observe(ctx, c, r.h, a) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if p := Preserved(base, after, keys); len(p) > 0 { |
| + t.Fatalf("%s: after not preserved: %v", a.Slug, p) |
| + } |
| + if p := Preserved(base, fresh, keys); len(p) > 0 { |
| + t.Fatalf("%s: drifted: %v", a.Slug, p) |
| + } |
| + for _, v := range base.Vars { |
| + if v.Key == keys[0] || v.Key == keys[1] { |
| + t.Fatalf("%s: the baseline held %s", a.Slug, v.Key) |
| + } |
| + for _, snap := range []Snapshot{after, fresh} { |
| + w := findVar(snap.Vars, v.Key) |
| + if w == nil || w.Digest != v.Digest || w.Kind != v.Kind || w.From != v.From { |
| + t.Fatalf("%s: %s not preserved", a.Slug, v.Key) |
| + } |
| + } |
| + } |
| + if len(after.Vars) != len(base.Vars)+2 || len(fresh.Vars) != len(base.Vars)+2 { |
| + t.Fatalf("%s: %d vars before, %d after, %d now", a.Slug, len(base.Vars), len(after.Vars), len(fresh.Vars)) |
| + } |
| + |
| + // Each stored layer differs by the two keys alone. |
| + was, now := r.before[a.Slug], r.layers(a.Slug) |
| + if len(now.def) != len(was.def)+2 { |
| + t.Fatalf("%s: default bundle %d keys, was %d", a.Slug, len(now.def), len(was.def)) |
| + } |
| + for k, v := range was.def { |
| + if now.def[k] != v { |
| + t.Fatalf("%s: %s changed", a.Slug, k) |
| + } |
| + } |
| + if now.def[keys[0]] != (fakecarlos.Var{Kind: "env", Value: Issuer}) || now.def[keys[1]] != (fakecarlos.Var{Kind: "env", Value: r.sqid}) { |
| + t.Fatalf("%s: the agent keys are not as written", a.Slug) |
| + } |
| + if now.envVer != was.envVer || !reflect.DeepEqual(now.env, was.env) { |
| + t.Fatalf("%s: the neighbour's environment changed", a.Slug) |
| + } |
| + |
| + if n := r.carlos.RestartCount(neighbourHost(a.Slug)); n != 0 { |
| + t.Fatalf("%s restarted %d times", neighbourHost(a.Slug), n) |
| + } |
| + if n := r.carlos.RestartCount(CanonicalHost(a)); n < 1 || n > 2 { |
| + t.Fatalf("%s restarted %d times", CanonicalHost(a), n) |
| + } |
| + } |
| + if n := r.carlos.AppWideRestarts(); n != 0 { |
| + t.Fatalf("app-wide restarts %d", n) |
| + } |
| + r.checkBaselines() |
| + r.noForeignUnset() |
| +} |
| + |
| +func (r *rehearsal) noForeignUnset() { |
| + r.t.Helper() |
| + r.mu.Lock() |
| + defer r.mu.Unlock() |
| + if len(r.foreign) > 0 { |
| + r.t.Fatalf("unset a value the runner did not write: %v", r.foreign) |
| + } |
| +} |
| + |
| +func (r *rehearsal) putsOf(app string) int { |
| + r.mu.Lock() |
| + defer r.mu.Unlock() |
| + return r.puts[app] |
| +} |
| + |
| +func onceEachRequest(t *testing.T, reqs []string) { |
| + t.Helper() |
| + seen := map[string]int{} |
| + for _, q := range reqs { |
| + if seen[q]++; seen[q] > 1 { |
| + t.Fatalf("%s committed twice: %v", q, reqs) |
| + } |
| + } |
| +} |
| + |
| +func countRequests(reqs []string, entry string) int { |
| + n := 0 |
| + for _, q := range reqs { |
| + if q == entry { |
| + n++ |
| + } |
| + } |
| + return n |
| +} |
| + |
| +// ---- the tests ---- |
| + |
| +func TestRehearsalFullRun(t *testing.T) { |
| + r := newRehearsal(t) |
| + r.run(options{}) |
| + r.adopted() |
| + for _, a := range provision.Apps { |
| + if n := r.putsOf(a.Slug); n != 1 { |
| + t.Fatalf("%s: %d PUTs, want one", a.Slug, n) |
| + } |
| + if n := r.carlos.RestartCount(CanonicalHost(a)); n != 1 { |
| + t.Fatalf("%s: %d restarts, want one", a.Slug, n) |
| + } |
| + } |
| + if !slices.Contains(r.home.Requests(), homeop.DirectoryActivate+":"+CanaryApp) { |
| + t.Fatal("the canary was not activated") |
| + } |
| +} |
| + |
| +// The same run, killed once at each act. Home's: after the act took effect |
| +// at Home and before Alta recorded it (AfterAct). CARLOS's: before the |
| +// PUT reaches the console, after it lands with its answer lost to a dead |
| +// process, after the restart, and mid-rollback. A fresh process resumes |
| +// from the journal each time. |
| +func TestRehearsalCrashAfterEveryAct(t *testing.T) { |
| + clean := newRehearsal(t) |
| + clean.run(options{}) |
| + acts := slices.Clone(clean.acts) |
| + want := clean.home.Requests() |
| + if len(acts) < 2+2*len(provision.Apps)+2*len(provision.Apps) { |
| + t.Fatalf("acts %v", acts) |
| + } |
| + |
| + for i, key := range acts { |
| + t.Run(fmt.Sprintf("home-%02d-%s", i, key), func(t *testing.T) { |
| + r := newRehearsal(t) |
| + n, crashed := 0, false |
| + r.run(options{afterAct: func(string) error { |
| + if n == i && !crashed { |
| + crashed = true |
| + return errors.New("kill -9") |
| + } |
| + n++ |
| + return nil |
| + }}) |
| + if !crashed { |
| + t.Fatalf("act %d never reached", i) |
| + } |
| + r.adopted() |
| + if got := r.home.Requests(); !reflect.DeepEqual(sortedCopy(got), sortedCopy(want)) { |
| + t.Fatalf("requests\n got %v\nwant %v", got, want) |
| + } |
| + for _, a := range provision.Apps { |
| + if n := r.putsOf(a.Slug); n != 1 { |
| + t.Fatalf("%s: %d PUTs", a.Slug, n) |
| + } |
| + } |
| + }) |
| + } |
| + |
| + for _, point := range []crashPoint{beforePut, afterPut, afterRestart} { |
| + t.Run("carlos-"+string(point), func(t *testing.T) { |
| + r := newRehearsal(t) |
| + r.run(options{configure: point}) |
| + r.adopted() |
| + for _, a := range provision.Apps { |
| + if n := r.putsOf(a.Slug); n < 1 || n > 2 { |
| + t.Fatalf("%s: %d PUTs", a.Slug, n) |
| + } |
| + } |
| + }) |
| + } |
| + |
| + t.Run("carlos-answer-lost", func(t *testing.T) { |
| + r := newRehearsal(t) |
| + r.run(options{lose: true}) |
| + r.adopted() |
| + for _, a := range provision.Apps { |
| + if n := r.putsOf(a.Slug); n != 1 { |
| + t.Fatalf("%s: %d PUTs, want exactly one", a.Slug, n) |
| + } |
| + } |
| + }) |
| + |
| + // Mid-rollback: every app configured and witnessed, then rolled back, |
| + // each killed once at the point. |
| + for _, point := range []crashPoint{beforePut, afterPut, afterRestart} { |
| + t.Run("rollback-"+string(point), func(t *testing.T) { |
| + r := newRehearsal(t) |
| + r.untilPlanA() |
| + for _, a := range provision.Apps { |
| + r.configure(a, noCrash) |
| + r.witness(a) |
| + } |
| + r.crashed = map[string]bool{} |
| + for _, a := range provision.Apps { |
| + if deaths := r.rollback(a, point); deaths != 1 { |
| + t.Fatalf("%s: died %d times", a.Slug, deaths) |
| + } |
| + } |
| + ctx := context.Background() |
| + for _, a := range provision.Apps { |
| + rec, ok, err := r.js.Rollback(ctx, a.Slug) |
| + if err != nil || !ok || rec.State != "restarted" { |
| + t.Fatalf("%s: rollback %q %v", a.Slug, rec.State, err) |
| + } |
| + if n := r.putsOf(a.Slug); n < 1 || n > 2 { |
| + t.Fatalf("%s: %d PUTs", a.Slug, n) |
| + } |
| + was, now := r.before[a.Slug], r.layers(a.Slug) |
| + if !reflect.DeepEqual(now.def, was.def) || !reflect.DeepEqual(now.env, was.env) || now.envVer != was.envVer { |
| + t.Fatalf("%s: the layers are not back to the baseline", a.Slug) |
| + } |
| + if r.carlos.RestartCount(neighbourHost(a.Slug)) != 0 { |
| + t.Fatalf("%s: the neighbour restarted", a.Slug) |
| + } |
| + if r.home.InstanceState(a.Slug) != "pending" { |
| + t.Fatalf("%s is %q at Home", a.Slug, r.home.InstanceState(a.Slug)) |
| + } |
| + } |
| + if r.carlos.AppWideRestarts() != 0 { |
| + t.Fatal("an app-wide restart") |
| + } |
| + r.checkBaselines() |
| + r.noForeignUnset() |
| + onceEachRequest(t, r.home.Requests()) |
| + }) |
| + } |
| + |
| + // A process killed before its unset, and another writer then puts its |
| + // own team in the key: the resume stops and unsets nothing. |
| + t.Run("rollback-foreign-after-crash", func(t *testing.T) { |
| + r := newRehearsal(t) |
| + r.untilPlanA() |
| + a, _ := provision.AppBySlug("docs") |
| + r.configure(a, noCrash) |
| + r.crashed = map[string]bool{} |
| + p := r.newProc(beforePut) |
| + _, js := r.journal() |
| + ctx, cancel := context.WithCancel(context.Background()) |
| + r.cancels = append(r.cancels, cancel) |
| + r.zombies.Add(1) |
| + go func() { |
| + defer r.zombies.Done() |
| + _ = RollbackAgentKeys(ctx, p.c, r.h, js, a, true) |
| + }() |
| + <-p.dead |
| + r.sawBaseline(a.Slug) |
| + keys := AgentKeys(a) |
| + r.carlos.SetVar("docs", "", keys[1], "tForeignTeam") |
| + p2 := r.newProc(noCrash) |
| + _, js2 := r.journal() |
| + err := RollbackAgentKeys(context.Background(), p2.c, r.h, js2, a, true) |
| + r.noForeignUnset() |
| + if !errors.Is(err, ErrStopForeign) { |
| + t.Fatalf("resume: %v, want ErrStopForeign", err) |
| + } |
| + vars, _, _ := r.carlos.Layer("docs", "") |
| + if vars[keys[1]].Value != "tForeignTeam" || vars[keys[0]].Value != Issuer { |
| + t.Fatal("the resume unset a value it did not write") |
| + } |
| + if n := r.putsOf("docs"); n != 1 { |
| + t.Fatalf("%d PUTs, want the write alone", n) |
| + } |
| + r.checkBaselines() |
| + r.noForeignUnset() |
| + }) |
| +} |
| + |
| +func sortedCopy(s []string) []string { |
| + c := slices.Clone(s) |
| + slices.Sort(c) |
| + return c |
| +} |
diff --git a/homecompat/adopt_flow_test.go b/homecompat/adopt_flow_test.go| new file mode 100644 |
| index 0000000..25da8dd |
| --- /dev/null |
| +++ b/homecompat/adopt_flow_test.go |
| @@ -0,0 +1,219 @@ |
| +package altacompat |
| + |
| +// The whole existing-team adoption at Home's real operator code, as |
| +// alta-adopt runs it: the Home preflight before initialize, initialize, |
| +// the preflight before Plan A once initialize's window has lapsed, Plan A, |
| +// Plan B for the canary, Plan C for the other five. The counts the |
| +// preflight takes are Home's own, from HomeQueries run on its tables. |
| + |
| +import ( |
| + "context" |
| + "crypto/sha256" |
| + "database/sql" |
| + "encoding/base64" |
| + "encoding/hex" |
| + "slices" |
| + "strings" |
| + "sync" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/alta/adopt" |
| + "amadan.net/oficina/alta/homeop" |
| + "amadan.net/oficina/alta/provision" |
| + "amadan.net/oficina/home/internal/operator" |
| +) |
| + |
| +// served is the release name each canonical app serves. |
| +const served = "v1.4.0" |
| + |
| +// observer stands in for the CARLOS half's activation gate: what it |
| +// answers is shaped as adopt.Observer answers it (the served version, |
| +// Alta's artifact digest of it, the binding over the team), so Home's real |
| +// activation checks meet the evidence they will meet in production. |
| +type observer struct { |
| + mu sync.Mutex |
| + calls []string |
| +} |
| + |
| +func (o *observer) Observe(_ context.Context, app, team string) (provision.Observation, error) { |
| + o.mu.Lock() |
| + o.calls = append(o.calls, app) |
| + o.mu.Unlock() |
| + sum := sha256.Sum256([]byte(served)) |
| + return provision.Observation{ |
| + AppVersion: served, |
| + ArtifactDigest: base64.RawURLEncoding.EncodeToString(sum[:]), |
| + EnvironmentBinding: adopt.EnvironmentBinding(adopt.BindingInput{ |
| + TeamSQID: team, Issuer: adopt.Issuer, ArtifactSHA256: hex.EncodeToString(sum[:]), Version: served, |
| + }), |
| + }, nil |
| +} |
| + |
| +// homeCounts runs HomeQueries on Home's own tables, as Paul's read-only |
| +// carlos db query does, and answers what he would paste. |
| +func homeCounts(t *testing.T, h *home) map[string]int64 { |
| + t.Helper() |
| + counts := map[string]int64{} |
| + for _, q := range adopt.HomeQueries() { |
| + var n int64 |
| + if err := h.dirDB.QueryRow(q).Scan(&n); err != nil { |
| + t.Fatalf("%s at Home's directory: %v", q, err) |
| + } |
| + counts[q[strings.LastIndex(q, " ")+1:]] = n |
| + } |
| + return counts |
| +} |
| + |
| +func homePreflight(t *testing.T, r *rig, phase string) { |
| + t.Helper() |
| + _, codes, err := adopt.CheckHome(context.Background(), r.client, r.store, homeCounts(t, r.home), phase) |
| + if err != nil || len(codes) > 0 { |
| + t.Fatalf("home preflight %s: %v %v", phase, codes, err) |
| + } |
| +} |
| + |
| +// manifestDigest is the credential role's union manifest: the env |
| +// manifest and the active consumers table, as register answers it. |
| +func manifestDigest(t *testing.T, r *rig, env map[string]string) string { |
| + t.Helper() |
| + table, err := operator.ActiveConsumers(context.Background(), r.home.credDB) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + union := map[string]string{"directory": dirOrigin, "alta": "https://alta-x.bds.oncarlos.com"} |
| + for id, o := range env { |
| + union[id] = o |
| + } |
| + for id, o := range table { |
| + union[id] = o |
| + } |
| + want, err := operator.ManifestDigest(union) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if got := homeop.ManifestDigest(union); got != want { |
| + t.Fatalf("manifest digest: Alta's is not Home's") |
| + } |
| + return want |
| +} |
| + |
| +func TestAdoptionFlowAgainstRealHome(t *testing.T) { |
| + ctx := context.Background() |
| + env := map[string]string{} |
| + for _, a := range apps { |
| + env[a] = homeop.CanonicalOrigin(a) |
| + } |
| + r := newRigWith(t, env, nil) |
| + obs := &observer{} |
| + cfg := r.cfg |
| + cfg.Observer = obs |
| + r.engine = provision.New(cfg) |
| + before := manifestDigest(t, r, env) |
| + window := func() { r.home.now = r.home.now.Add(homeop.WindowLifetime * time.Second) } |
| + |
| + homePreflight(t, r, adopt.PhasePreInitialize) |
| + 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) |
| + } |
| + // Before Plan A, initialize's window must have lapsed: the preflight |
| + // refuses an open plan. |
| + if _, codes, err := adopt.CheckHome(ctx, r.client, r.store, homeCounts(t, r.home), adopt.PhasePrePlanA); err != nil || !slices.Contains(codes, "plan-open") { |
| + t.Fatalf("pre-plan-a with initialize's window open: %v %v", codes, err) |
| + } |
| + window() |
| + homePreflight(t, r, adopt.PhasePrePlanA) |
| + |
| + run, err = r.engine.StartAdoption(ctx, "Oficina", owner) |
| + 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" || got.Code != "awaiting-configuration" { |
| + t.Fatalf("plan A: %s %s", got.State, got.Code) |
| + } |
| + team, err := r.store.Team(ctx, provision.AdoptionLabel) |
| + if err != nil || team.TeamSQID == "" { |
| + t.Fatalf("no seeded team: %v", err) |
| + } |
| + |
| + // Plans B and C: the canary first, then the other five. |
| + rest := []string{} |
| + for _, a := range provision.Slugs() { |
| + if a != adopt.CanaryApp { |
| + rest = append(rest, a) |
| + } |
| + } |
| + for _, plan := range [][]string{{adopt.CanaryApp}, rest} { |
| + window() |
| + run, err := r.engine.ActivateAdopted(ctx, plan) |
| + if err != nil { |
| + t.Fatalf("activate %v: %v", plan, err) |
| + } |
| + for _, role := range []string{"directory", "credential"} { |
| + if v := r.home.confirm(t, role, ""); v.Kind != homeop.KindAddApps || v.ExistingTeam != team.TeamSQID || len(v.Apps) != len(plan) { |
| + t.Fatalf("%s plan view: kind %s apps %v", role, v.Kind, v.Apps) |
| + } |
| + } |
| + if got := r.drive(t, run); got.State != "done" { |
| + t.Fatalf("activate %v: %s %s", plan, got.State, got.Code) |
| + } |
| + } |
| + if len(obs.calls) != len(apps) { |
| + t.Fatalf("observed %v", obs.calls) |
| + } |
| + |
| + count := func(db *sql.DB, q string, args ...any) int { |
| + t.Helper() |
| + var n int |
| + if err := db.QueryRow(q, args...).Scan(&n); err != nil { |
| + t.Fatal(err) |
| + } |
| + return n |
| + } |
| + if n := count(r.home.dirDB, "SELECT count(*) FROM teams WHERE label='oficina'"); n != 1 { |
| + t.Fatalf("teams %d", n) |
| + } |
| + // Every canonical binding is live, and there is no other. |
| + if n := count(r.home.dirDB, "SELECT count(*) FROM team_instances WHERE state='live' AND consumer_id=app AND origin='https://'||app||'.oficina.works'"); n != len(apps) { |
| + t.Fatalf("live canonical rows %d", n) |
| + } |
| + if n := count(r.home.dirDB, "SELECT count(*) FROM team_instances"); n != len(apps) { |
| + t.Fatalf("team_instances %d", n) |
| + } |
| + // Register verified the env manifest and inserted nothing. |
| + if n := count(r.home.credDB, "SELECT count(*) FROM consumers"); n != 0 { |
| + t.Fatalf("credential consumers %d", n) |
| + } |
| + if after := manifestDigest(t, r, env); after != before { |
| + t.Fatal("the manifest digest changed") |
| + } |
| + for _, a := range apps { |
| + data, ok, err := r.store.Done(ctx, provision.AdoptionLabel, a, provision.StepRegister) |
| + if err != nil || !ok || data["manifest_digest"] != before { |
| + t.Fatalf("%s: register's manifest digest is not the unchanged one", a) |
| + } |
| + } |
| + // Alta's streams are Home's. |
| + for _, role := range []string{"directory", "credential"} { |
| + seq, head, _, _ := r.store.Stream(ctx, role) |
| + db := r.home.dirDB |
| + if role == "credential" { |
| + db = r.home.credDB |
| + } |
| + var hs int64 |
| + var hh string |
| + if err := db.QueryRow("SELECT sequence,head FROM "+role+"_operator_state WHERE singleton=1").Scan(&hs, &hh); err != nil { |
| + t.Fatal(err) |
| + } |
| + if seq != hs || head != hh { |
| + t.Fatalf("%s stream: Alta %d, Home %d", role, seq, hs) |
| + } |
| + } |
| +} |
diff --git a/homecompat/compat_test.go b/homecompat/compat_test.go| index 173b221..1939646 100644 |
| --- a/homecompat/compat_test.go |
| +++ b/homecompat/compat_test.go |
| @@ -285,6 +285,7 @@ type rig struct { |
| home *home |
| con *fakeconsole.Console |
| engine *provision.Engine |
| + cfg provision.Config // engine's, for an engine with an Observer |
| store *provision.Store |
| client *homeop.Client |
| } |
| @@ -328,13 +329,13 @@ func newRigWith(t *testing.T, extraEnv map[string]string, afterAct func(string) |
| "directory": {Name: "directory", Origin: dirOrigin, URL: dir.URL, Installation: inst, Registry: reg, Device: dev}, |
| } |
| client := &homeop.Client{Key: alta, Prefilter: pre, Roles: roles, Now: clock} |
| - e := provision.New(provision.Config{Store: store, Home: client, |
| + cfg := 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)), AfterAct: afterAct, |
| - Debug: func(err error) { t.Logf("transient: %v", err) }}) |
| - return &rig{home: h, con: con, engine: e, store: store, client: client} |
| + Debug: func(err error) { t.Logf("transient: %v", err) }} |
| + return &rig{home: h, con: con, engine: provision.New(cfg), cfg: cfg, 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 0078288..46c425a 100644 |
| --- a/homecompat/go.mod |
| +++ b/homecompat/go.mod |
| @@ -19,17 +19,31 @@ require ( |
| require ( |
| amadan.net/carlos/platform.git/launchctx v0.0.0-20260911135504-fb577f96f7d1 // indirect |
| + amadan.net/oficina/agent-access.git v0.0.0-20261101215226-e4ea91480ce6 // indirect |
| + github.com/danieljoos/wincred v1.2.3 // indirect |
| github.com/dustin/go-humanize v1.0.1 // indirect |
| github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2 // indirect |
| + github.com/godbus/dbus/v5 v5.2.2 // indirect |
| + github.com/gofrs/flock v0.12.1 // indirect |
| + github.com/google/jsonschema-go v0.4.3 // indirect |
| github.com/google/uuid v1.6.0 // indirect |
| github.com/jinzhu/inflection v1.0.0 // indirect |
| github.com/jinzhu/now v1.1.5 // indirect |
| github.com/mattn/go-isatty v0.0.20 // indirect |
| + github.com/modelcontextprotocol/go-sdk v1.7.0 // indirect |
| github.com/ncruces/go-strftime v1.0.0 // indirect |
| github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect |
| + github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 // indirect |
| + github.com/segmentio/asm v1.1.3 // indirect |
| + github.com/segmentio/encoding v0.5.4 // indirect |
| github.com/sqids/sqids-go v0.4.1 // indirect |
| + github.com/yosida95/uritemplate/v3 v3.0.2 // indirect |
| + github.com/zalando/go-keyring v0.2.8 // indirect |
| + golang.org/x/oauth2 v0.35.0 // indirect |
| + golang.org/x/sync v0.22.0 // indirect |
| golang.org/x/sys v0.47.0 // indirect |
| golang.org/x/text v0.41.0 // indirect |
| + golang.org/x/time v0.15.0 // indirect |
| gorm.io/gorm v1.31.2 // indirect |
| gorm.io/plugin/dbresolver v1.6.2 // indirect |
| modernc.org/libc v1.74.1 // indirect |
diff --git a/homecompat/go.sum b/homecompat/go.sum| index d828330..68c47be 100644 |
| --- a/homecompat/go.sum |
| +++ b/homecompat/go.sum |
| @@ -1,27 +1,39 @@ |
| amadan.net/carlos/platform.git/launchctx v0.0.0-20260911135504-fb577f96f7d1 h1:RxwIRojWcVtwSdNAjtdz7y1bxHLh3GUgqT1TrXVKpyM= |
| 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/agent-access.git v0.0.0-20261101215226-e4ea91480ce6 h1:TsdiPHRgol+QhONgRWRlRc3dfn4ilnPJm5cmrWeXndA= |
| +amadan.net/oficina/agent-access.git v0.0.0-20261101215226-e4ea91480ce6/go.mod h1:IWNXkxXLhEbHocPN+qPD5z8ix4dT/wtHLR27Z5QPdRc= |
| 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= |
| amadan.net/rastrillo/rastrillo/money v0.1.0/go.mod h1:cmgkjBEIQh1pFSYvQk0UU6oPYS8kSDypdT9+t4Flx0U= |
| +github.com/danieljoos/wincred v1.2.3 h1:v7dZC2x32Ut3nEfRH+vhoZGvN72+dQ/snVXo/vMFLdQ= |
| +github.com/danieljoos/wincred v1.2.3/go.mod h1:6qqX0WNrS4RzPZ1tnroDzq9kY3fu1KwE7MRLQK4X0bs= |
| +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= |
| +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
| +github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= |
| +github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= |
| github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= |
| github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= |
| github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2 h1:iizUGZ9pEquQS5jTGkh4AqeeHCMbfbjeb0zMt0aEFzs= |
| github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2/go.mod h1:TiCD2a1pcmjd7YnhGH0f/zKNcCD06B029pHhzV23c2M= |
| github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= |
| github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= |
| +github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ= |
| +github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c= |
| +github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= |
| +github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0= |
| +github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY= |
| +github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= |
| +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= |
| +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= |
| +github.com/google/jsonschema-go v0.4.3 h1:/DBOLZTfDow7pe2GmaJNhltueGTtDKICi8V8p+DQPd0= |
| +github.com/google/jsonschema-go v0.4.3/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE= |
| github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs= |
| github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= |
| github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= |
| @@ -38,16 +50,36 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE |
| github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= |
| github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= |
| github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= |
| +github.com/modelcontextprotocol/go-sdk v1.7.0 h1:yqjY2dsbKAC0LSuWZVBMrHgiG8ukXv6NRo0JiALay44= |
| +github.com/modelcontextprotocol/go-sdk v1.7.0/go.mod h1:dL7u98E/zjJTGzEq+j30jQ8K2k1mb6LeAH4inEcSGts= |
| github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= |
| github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= |
| +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= |
| +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
| github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= |
| github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= |
| +github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 h1:1EYB5IzjZawrrnELUi78f9fPu57HuXjmddZPjrls/28= |
| +github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= |
| +github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc= |
| +github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg= |
| +github.com/segmentio/encoding v0.5.4 h1:OW1VRern8Nw6ITAtwSZ7Idrl3MXCFwXHPgqESYfvNt0= |
| +github.com/segmentio/encoding v0.5.4/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJnO1gPH1sKt0= |
| github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0= |
| github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M= |
| github.com/sqids/sqids-go v0.4.1 h1:eQKYzmAZbLlRwHeHYPF35QhgxwZHLnlmVj9AkIj/rrw= |
| github.com/sqids/sqids-go v0.4.1/go.mod h1:EMwHuPQgSNFS0A49jESTfIQS+066XQTVhukrzEPScl8= |
| +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= |
| +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= |
| +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= |
| +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= |
| +github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4= |
| +github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4= |
| +github.com/zalando/go-keyring v0.2.8 h1:6sD/Ucpl7jNq10rM2pgqTs0sZ9V3qMrqfIIy5YPccHs= |
| +github.com/zalando/go-keyring v0.2.8/go.mod h1:tsMo+VpRq5NGyKfxoBVjCuMrG47yj8cmakZDO5QGii0= |
| golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk= |
| golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40= |
| +golang.org/x/oauth2 v0.35.0 h1:Mv2mzuHuZuY2+bkyWXIHMfhNdJAdwW3FuWeCPYN5GVQ= |
| +golang.org/x/oauth2 v0.35.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= |
| golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= |
| golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= |
| golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
| @@ -55,8 +87,12 @@ golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= |
| golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= |
| golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8= |
| golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= |
| +golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= |
| +golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= |
| golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE= |
| golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk= |
| +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= |
| +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
| gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo= |
| gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM= |
| gorm.io/driver/sqlite v1.6.0 h1:WHRRrIiulaPiPFmDcod6prc4l2VGVWHz80KspNsxSfQ= |