oficina / equipo Public

equipo: owner setting to run a project's checks in a hosted VM

chat_projects gains hosted_checks, hosted_checks_owner and
hosted_checks_revision (0125, additive, off for every project).
SetHostedChecks is owner only, roster and session read inside the
write transaction, at the revision the owner saw, audited in the same
transaction (project.hosted_checks). hostedChecks counts it only while
the project is active and its setter is still an owner; lookup errors
deny. The Settings section, its page and its save exist only with
EQUIPO_HOSTED_RUNNERS=1, for owners. Four copy keys, pending. Budget
records raised for internal/equipo and internal/equipo/chat.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 4946959eb291a0d52c888fe26863b2b5586371fa parent cbf27a2
18 files changed, +603 −39
  • .rastrillo/budgets.txt +2 −2
  • docs/superpowers/plans/2026-11-30-hosted-slice-2-copy.json +28 −0
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +4 −0
  • docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md +24 −0
  • internal/equipo/app.go +4 −1
  • internal/equipo/chat/hosted_setting.go +99 −0
  • internal/equipo/chat/hosted_setting_test.go +159 −0
  • internal/equipo/chat/projects.go +6 −2
  • internal/equipo/config.go +5 −0
  • internal/equipo/copy.go +29 −25
  • internal/equipo/hosted_settings.go +46 −0
  • internal/equipo/hosted_settings_test.go +135 −0
  • internal/equipo/migrations/0125_hosted_checks_setting.sql +7 −0
  • internal/equipo/migrations/schema.sql +8 −0
  • internal/equipo/render.go +1 −1
  • internal/equipo/settings_hub.go +33 −7
  • internal/equipo/templates/hosted_settings.html +11 −0
  • internal/equipo/templates/settings_hub.html +2 −1
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 5de6f2ce..832c42ac 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -14,7 +14,7 @@ perf GET /* skip Unknown private paths render 404; this fallback contains no scr
time internal/equipo/team 60s Plan 3 loaded CI measured 45.985s; niced serial reruns measured 18.079s and 22.031s. Keep migration, recovery, accounting and concurrency assertions; 60s leaves 30 percent headroom above loaded CI.
time internal/equipotest 300s Final fix package rerun measured 187.035s (review 172.4s); 300s gives 60 percent headroom for HTTP, sandbox, authority and final regression coverage.
-size internal/equipo 24741 - Preview, retry, merges, kept work, check-db, notifications, places, GitHub routes, installer, abilities, lookups, Mac waits, slice F codes, D1, probe details, Design's copy, /api/team; measured 24735. Hosted slice 2 Task 15 review 1: work.reason.pack_incomplete (pending); 24736. Task 17: work.reason.deps_conflict, deps_new_module, deps_missing, deps_too_large and token_renewal_failed (pending); 24741.
+size internal/equipo 24825 - Preview, retry, merges, kept work, check-db, notifications, places, GitHub routes, installer, abilities, lookups, Mac waits, slice F codes, D1, probe details, Design's copy, /api/team; measured 24735. Hosted slice 2 Task 15 review 1: work.reason.pack_incomplete (pending); 24736. Task 17: work.reason.deps_conflict, deps_new_module, deps_missing, deps_too_large and token_renewal_failed (pending); 24741. Task 18: the owner setting "Run checks in a hosted VM" (config flag, routes, section, handler, four pending keys); 24825.
size internal/wire 9884 - Protocols 31 to 35 (facts, diffs, evidence, CI units, files, places), abilities, 36 lookups, 37 Mac Engineering, 38 Design, unproven and probe detail codes, 39 hosted runners (hosted.go: placement, hosted_pack and deps transfer limits, enrolment types); measured 9848. Task 15 opened TransferHeader.Valid to hosted_pack (inbound, base then candidate) and added ReasonPackIncomplete; 9860. Its review round 1 registered it in StepReasons; 9862. Task 17: the hosted worker's reasons (deps_conflict, deps_new_module, deps_missing, deps_too_large, token_renewal_failed) registered in StepReasons, and TransferHeader.Valid opened to deps with the hosted_pack rules (the worker accepts the bundle; Task 23 sends it); 9884.
size internal/equipotest - 12693 GitHub connect value search, lifecycle and sweep-log contracts; Task 21 migration fixtures, Rastrillo asset contract, renderer archive link; measured 0/12693 source/test lines.
time internal/runner/checks 90s CI worker measured 44.553s (44.6s rounded);
@@ -59,7 +59,7 @@ perf GET /api/v1/assistant/snapshot skip Assistant person API: bearer-only JSON
perf GET /api/v1/assistant/messages skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen.
perf GET /api/v1/assistant/events skip Assistant event stream (Server-Sent Events), bearer-only and long-lived; not a screen.
perf GET /api/v1/assistant/abilities skip Assistant person API: bearer-only JSON for Base's Settings line, not a browser screen.
-size internal/equipo/chat 45105 18911 File facts/diffs, previews, merges, unfinished work, CI, receipts, Assistant files, places, abilities, lookups, go-aheads, Mac work, D1, Design specialists, grants, captures; 45093/18782. Hosted slice 2 Task 15: openHostedPack (the instance's send_pack for a hosted pack) and its test; 45105/18883. Its review round 1 added the report-ingestion test for pack_incomplete; 45105/18911.
+size internal/equipo/chat 45208 19070 File facts/diffs, previews, merges, unfinished work, CI, receipts, Assistant files, places, abilities, lookups, go-aheads, Mac work, D1, Design specialists, grants, captures; 45093/18782. Hosted slice 2 Task 15: openHostedPack (the instance's send_pack for a hosted pack) and its test; 45105/18883. Its review round 1 added the report-ingestion test for pack_incomplete; 45105/18911. Task 18: hosted_setting.go (SetHostedChecks, hostedChecks, HostedSettings; owner only, roster in the transaction, audited) and its tests; 45208/19070.
perf GET /api/v1/questions/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads questions on /tasks/{id}.
perf GET /api/v1/steps/{id}/log skip Thin v1 person API: bearer-only JSON for devices; the browser shows the log tail on /tasks/{id}.
perf GET /api/v1/connections/preference skip Connections slice 1 person API: bearer-only JSON for devices; the browser shows the preference on /conversation/connections.
diff --git a/docs/superpowers/plans/2026-11-30-hosted-slice-2-copy.json b/docs/superpowers/plans/2026-11-30-hosted-slice-2-copy.json
index e21c5399..74a58cc0 100644
--- a/docs/superpowers/plans/2026-11-30-hosted-slice-2-copy.json
+++ b/docs/superpowers/plans/2026-11-30-hosted-slice-2-copy.json
@@ -40,5 +40,33 @@
"draft": "the hosted machine could not renew its sign-in before the checks finished",
"paul_sees": true,
"reviewed": ""
+ },
+ {
+ "key": "hosted.title",
+ "where": "Settings, owners only with EQUIPO_HOSTED_RUNNERS=1: the hosted checks section's menu entry and heading (Task 18)",
+ "draft": "Hosted checks",
+ "paul_sees": true,
+ "reviewed": ""
+ },
+ {
+ "key": "hosted.lede",
+ "where": "Settings, hosted checks section: the line under the heading (Task 18)",
+ "draft": "Choose which projects run their checks on machines Equipo hosts. Only owners can change this.",
+ "paul_sees": true,
+ "reviewed": ""
+ },
+ {
+ "key": "hosted.checks",
+ "where": "Settings, hosted checks section: the switch for one project, off by default (Task 18)",
+ "draft": "Run checks in a hosted VM",
+ "paul_sees": true,
+ "reviewed": ""
+ },
+ {
+ "key": "hosted.checks_help",
+ "where": "Settings, hosted checks section: the description under the switch (Task 18)",
+ "draft": "Each checks run happens on a new machine that Equipo starts for it and stops afterwards. Your own runner must still be online to send it the change.",
+ "paul_sees": true,
+ "reviewed": ""
}
]
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index 92bfa905..28f4823d 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -7225,6 +7225,10 @@ records remain unchanged.
| `work.reason.deps_missing` | a dependency the checks need did not reach the hosted machine | Copy specialist | COPY REVIEW PENDING |
| `work.reason.deps_too_large` | the dependencies were too large to send to the hosted machine | Copy specialist | COPY REVIEW PENDING |
| `work.reason.token_renewal_failed` | the hosted machine could not renew its sign-in before the checks finished | Copy specialist | COPY REVIEW PENDING |
+| `hosted.title` | Hosted checks | Copy specialist | COPY REVIEW PENDING |
+| `hosted.lede` | Choose which projects run their checks on machines Equipo hosts. Only owners can change this. | Copy specialist | COPY REVIEW PENDING |
+| `hosted.checks` | Run checks in a hosted VM | Copy specialist | COPY REVIEW PENDING |
+| `hosted.checks_help` | Each checks run happens on a new machine that Equipo starts for it and stops afterwards. Your own runner must still be online to send it the change. | Copy specialist | COPY REVIEW PENDING |
## Task 21
diff --git a/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md b/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md
index d658e6b2..71cc34c8 100644
--- a/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md
+++ b/docs/superpowers/plans/HOSTED-SLICE2-PROGRESS.md
@@ -1371,3 +1371,27 @@ Mutations (scripted, one at a time, restored from a copy and `cmp`-checked):
- **221** the same two removals. `CGO_ENABLED=0 go test ./internal/runner/linuxworker -run TestHostedCancelChangedGate -count=1`: exit 1, `worker_test.go:1020: cancelled report {... State:done Reason:checks_unavailable ...}`. Restored (`cp`, `cmp` identical).
Each guard alone is redundant end to end: a real checkout fails on a cancelled context, and that failure is now kept as a cancel. So removing the first guard alone left the primary and hosted tests passing; they fail only with both removed (220, 221). checkrun's own test (219, 222) catches each guard separately.
+
+## Task 18
+
+The owner setting "Run checks in a hosted VM": migration `0125_hosted_checks_setting.sql` (`chat_projects.hosted_checks`, `hosted_checks_owner`, `hosted_checks_revision`, additive, off for every existing row; `schema.sql` appended), `internal/equipo/chat/hosted_setting.go` (`SetHostedChecks`, `txn.hostedChecks`, and `HostedSettings`, the owners' list the page reads), `internal/equipo/hosted_settings.go` (routes, handler), `templates/hosted_settings.html`, the Settings section in `settings_hub.go` / `settings_hub.html` / `render.go`, and `Config.HostedRunners` (`EQUIPO_HOSTED_RUNNERS` exactly `1`) carried into `application.hostedRunners` in `app.go`.
+
+Rules: a write needs a current session and a current owner, read inside the write transaction, at the revision the owner saw (`ErrCardConflict` otherwise), on an active project; it is audited in the same transaction (`project.hosted_checks`, `<project>/revision:<n>/enabled:<bool>`), and a failed audit rolls it back. `hostedChecks` counts the setting only while the project is active and the owner who last changed it is still an owner; a roster lookup error denies. Without the flag the section is not in the menu and neither `GET /conversation/settings/hosted` nor `POST /settings/hosted` is registered; with it, owners alone see and use it (the page and the save both check again).
+
+Copy: `hosted.title`, `hosted.lede`, `hosted.checks`, `hosted.checks_help` in `internal/equipo/copy.go`, marked with `python3 scripts/copy-status.py pending` (stdin `{"candidate": <worktree>, "keys": ["hosted.title", "hosted.lede", "hosted.checks", "hosted.checks_help"]}`; inventory rows COPY REVIEW PENDING), listed in `2026-11-30-hosted-slice-2-copy.json`. Not accepted. No empty-state line: the brief names four keys, so a team with no projects sees the heading and lede only.
+
+Red: `CGO_ENABLED=0 go test ./internal/equipo/... -run 'TestHostedSetting' -count=1`: build failed in both packages (`t.hostedChecks undefined`, `r.s.SetHostedChecks undefined`, `r.s.HostedSettings undefined`; `a.hostedRoutes undefined`, `cfg.HostedRunners undefined`, `off.settingsShown undefined`, `chat.HostedSetting undefined`). The mutations below are the assertion-level evidence.
+
+Tests: chat `TestHostedSettingOwnerOnly`, `TestHostedSettingRemovedOwnerRefused` (removed, demoted, roster error, revoked session), `TestHostedSettingRevisionConflict` (and an archived project), `TestHostedSettingAudited` (exact audit lines, audit failure rolls back); equipo `TestHostedSettingHiddenWithoutFlag` (config values, routes by `chi.Walk`, menu, page guard), `TestHostedSettingPage` (renders the four keys and one switch per project with its revision), `TestHostedSettingMigrationOff` (0125 follows 0124; an existing project stays off).
+
+Green: `CGO_ENABLED=0 go test ./internal/equipo/... -run 'TestHostedSetting' -count=1`: ok (7 tests ran). Also ok: `./internal/equipo -run 'Copy|Settings|Migration|Autonomy|StepReasons|Config|Switch'`, `./internal/equipo/chat -run 'Autonomy|CopyDelegation|Project'`, `./internal/thintest -run 'Settings|Rail|Copy'`. `make migration-check budget build vet`: exit 0 after raising the records (internal/equipo 24825; chat 45208/19070, with reasons). gofmt and `git diff --check`: clean. `python3 scripts/copy-status.py verify` (stdin `{"candidate": <worktree>}`): `{"valid": false}`, by design: these four keys and the earlier tasks' keys are pending.
+
+Mutations (each an exact-string replace from a script under `$TMPDIR`, one at a time, the named test run, the file restored from a copy and checked with `filecmp`):
+- **224** skip the roster check on write. In `internal/equipo/chat/hosted_setting.go` `SetHostedChecks`, the `if err := t.isOwner(person); err != nil { return err }` block deleted. `CGO_ENABLED=0 go test ./internal/equipo/chat -run TestHostedSettingOwnerOnly -count=1`: exit 1, `hosted_setting_test.go:34: member turned it on: <nil>`. Restored (identical).
+- **225** skip the roster check on read (the setter's role not rechecked). In `hostedChecksOf`, the `t.isOwner(p.HostedChecksOwner)` block became `_ = errors.Is`. `... -run TestHostedSettingRemovedOwnerRefused`: exit 1, `hosted_setting_test.go:74: a removed owner's setting still counts: true <nil>`. Restored (identical).
+- **226** skip the roster check on the owners' list. In `HostedSettings`, the `t.isOwner(person)` block deleted. `... -run TestHostedSettingOwnerOnly`: exit 1, `hosted_setting_test.go:40: member listed the settings: <nil>`. Restored (identical).
+- **227** no revision conflict. `if p.HostedChecksRevision != revision {` became `if false && p.HostedChecksRevision != revision {`. `... -run TestHostedSettingRevisionConflict`: exit 1, `hosted_setting_test.go:111: stale write: <nil>`. Restored (identical).
+- **228** no audit. `s.authority.Audit(t.db, person, "project.hosted_checks",` became `func(string, string, string) error { return nil }(person, "project.hosted_checks",`. `... -run TestHostedSettingAudited`: exit 1, `hosted_setting_test.go:145: audit:` (no lines). Restored (identical). (A first attempt at this mutation did not compile and is not counted.)
+- **229** routes without the flag. In `internal/equipo/hosted_settings.go`, the `if !a.hostedRunners { return }` guard deleted. `CGO_ENABLED=0 go test ./internal/equipo -run TestHostedSettingHiddenWithoutFlag -count=1`: exit 1, `hosted_settings_test.go:57: routes without the flag: [GET /conversation/settings/hosted POST /settings/hosted]`. Restored (identical).
+- **230** menu entry without the flag. In `settings_hub.go`, `return a.hostedSection(owner) == nil` became `return owner`. Same command: exit 1, `hosted_settings_test.go:61: listed without the flag (owner true)`. Restored (identical).
+- **231** any value turns the flag on. In `config.go`, `getenv("EQUIPO_HOSTED_RUNNERS") == "1"` became `!= ""`. Same command: exit 1, `hosted_settings_test.go:43: EQUIPO_HOSTED_RUNNERS="0" read as true`. Restored (identical).
diff --git a/internal/equipo/app.go b/internal/equipo/app.go
index 3910ebc3..71fa18ac 100644
--- a/internal/equipo/app.go
+++ b/internal/equipo/app.go
@@ -42,6 +42,8 @@ type application struct {
home *oficinaid.HTTP
installAssets *release.InstallAssets
executionEnabled bool
+ // hostedRunners is Config.HostedRunners (hosted_settings.go).
+ hostedRunners bool
chi.Router
live *live.Hub
origin string
@@ -273,7 +275,7 @@ func RouterWithStore(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logg
if err != nil {
return nil, err
}
- a := &application{installAssets: release.NewInstallAssets(cfg.RunnerReleaseDir, rastrillo.BuildVersion, release.BuildManifest()), executionEnabled: cfg.ExecutionEnabled, Router: chi.NewRouter(), auth: authentication, store: store, logger: logger, nonces: pow.SQLNonces(d.Writer()), origin: cfg.Origin, push: cfg.Push}
+ a := &application{installAssets: release.NewInstallAssets(cfg.RunnerReleaseDir, rastrillo.BuildVersion, release.BuildManifest()), executionEnabled: cfg.ExecutionEnabled, hostedRunners: cfg.HostedRunners, Router: chi.NewRouter(), auth: authentication, store: store, logger: logger, nonces: pow.SQLNonces(d.Writer()), origin: cfg.Origin, push: cfg.Push}
if cfg.Home != nil {
storeID, e := oficinaid.New(d.Writer(), cfg.Origin, cfg.Home)
if e != nil {
@@ -431,6 +433,7 @@ func RouterWithStore(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logg
r.Post("/settings/copy/wording", a.editCopyWording)
r.Post("/settings/autonomy", a.saveAutonomySetting)
r.Get("/conversation/settings/autonomy", a.settingsSectionHandler("autonomy"))
+ a.hostedRoutes(r)
r.Post("/settings/copy", a.saveCopySetting)
r.Post("/settings/copy/import", a.importCopyReview)
r.Get("/conversation/settings/copy", a.settingsSectionHandler("copy"))
diff --git a/internal/equipo/chat/hosted_setting.go b/internal/equipo/chat/hosted_setting.go
new file mode 100644
index 00000000..0702718e
--- /dev/null
+++ b/internal/equipo/chat/hosted_setting.go
@@ -0,0 +1,99 @@
+package chat
+
+import (
+ "context"
+ "errors"
+ "fmt"
+
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// HostedSetting is one project's "Run checks in a hosted VM" on the
+// owners' Settings page.
+type HostedSetting struct {
+ Project, Title string
+ On bool
+ Revision int64
+}
+
+// hostedChecks reads the project's setting in the action's transaction.
+// It counts only while the project is active and the owner who turned it
+// on is still a current owner; a lookup error denies.
+func (t *txn) hostedChecks(project string) (bool, error) {
+ var p projectRecord
+ if err := t.db.Where("id = ?", project).First(&p).Error; err != nil {
+ return false, err
+ }
+ return t.hostedChecksOf(p)
+}
+
+func (t *txn) hostedChecksOf(p projectRecord) (bool, error) {
+ if !p.HostedChecks || p.HostedChecksOwner == "" || p.State != wire.ProjectActive {
+ return false, nil
+ }
+ if err := t.isOwner(p.HostedChecksOwner); err != nil {
+ if errors.Is(err, ErrForbidden) {
+ return false, nil
+ }
+ return false, err
+ }
+ return true, nil
+}
+
+// HostedSettings lists the active projects' settings for a current owner.
+func (s *Store) HostedSettings(ctx context.Context, person string) ([]HostedSetting, error) {
+ var out []HostedSetting
+ err := s.tx(ctx, func(t *txn) error {
+ if err := s.authority.CurrentPerson(ctx, t.db); err != nil {
+ return err
+ }
+ if err := t.isOwner(person); err != nil {
+ return err
+ }
+ var rows []projectRecord
+ if err := t.db.Where("state = ?", wire.ProjectActive).Order("repo").Find(&rows).Error; err != nil {
+ return err
+ }
+ for _, p := range rows {
+ on, err := t.hostedChecksOf(p)
+ if err != nil {
+ return err
+ }
+ out = append(out, HostedSetting{Project: p.ID, Title: p.shownTitle(), On: on, Revision: p.HostedChecksRevision})
+ }
+ return nil
+ })
+ return out, err
+}
+
+// SetHostedChecks is called with the verified session's address, never a
+// submitted actor. Only a current owner may change it, at the revision
+// they saw, and the change is audited in the same transaction.
+func (s *Store) SetHostedChecks(ctx context.Context, person, project string, enabled bool, revision int64) error {
+ return s.tx(ctx, func(t *txn) error {
+ if err := s.authority.CurrentPerson(ctx, t.db); err != nil {
+ return err
+ }
+ if err := t.isOwner(person); err != nil {
+ return err
+ }
+ var p projectRecord
+ if err := t.db.Where("id = ? AND state = ?", project, wire.ProjectActive).First(&p).Error; err != nil {
+ return err
+ }
+ if p.HostedChecksRevision != revision {
+ return ErrCardConflict
+ }
+ p.HostedChecks, p.HostedChecksOwner = enabled, person
+ p.HostedChecksRevision++
+ p.Revision++
+ p.UpdatedAt = t.now()
+ if err := t.db.Model(&projectRecord{}).Where("id = ?", p.ID).Select("hosted_checks", "hosted_checks_owner", "hosted_checks_revision", "revision", "updated_at").Updates(&p).Error; err != nil {
+ return err
+ }
+ if err := s.authority.Audit(t.db, person, "project.hosted_checks", fmt.Sprintf("%s/revision:%d/enabled:%t", p.ID, p.HostedChecksRevision, enabled)); err != nil {
+ return err
+ }
+ return t.projectEvent(p)
+ })
+}
diff --git a/internal/equipo/chat/hosted_setting_test.go b/internal/equipo/chat/hosted_setting_test.go
new file mode 100644
index 00000000..cccee37a
--- /dev/null
+++ b/internal/equipo/chat/hosted_setting_test.go
@@ -0,0 +1,159 @@
+package chat
+
+import (
+ "context"
+ "errors"
+ "strings"
+ "testing"
+
+ "gorm.io/gorm"
+)
+
+// hostedRead is the project's setting as an action reads it, in its own
+// transaction.
+func (r *hkRig) hostedRead(project string) (bool, error) {
+ var on bool
+ err := r.tx(func(t *txn) error {
+ var err error
+ on, err = t.hostedChecks(project)
+ return err
+ })
+ return on, err
+}
+
+// TestHostedSettingOwnerOnly: the setting is off by default, a member can
+// neither change it nor list it, and an owner can do both.
+func TestHostedSettingOwnerOnly(t *testing.T) {
+ r, _ := rosterRig(t)
+ r.task("tkhosted", "Hosted", hkOwner)
+ r.exec("UPDATE members SET role='member' WHERE address=?", hkMember)
+ if on, err := r.hostedRead("p1"); on || err != nil {
+ t.Fatalf("on by default: %t %v", on, err)
+ }
+ if err := r.s.SetHostedChecks(r.ctx, hkMember, "p1", true, 0); !errors.Is(err, ErrForbidden) {
+ t.Fatalf("member turned it on: %v", err)
+ }
+ if on, _ := r.hostedRead("p1"); on {
+ t.Fatal("a member's write took effect")
+ }
+ if _, err := r.s.HostedSettings(r.ctx, hkMember); !errors.Is(err, ErrForbidden) {
+ t.Fatalf("member listed the settings: %v", err)
+ }
+ r.must(r.s.SetHostedChecks(r.ctx, hkOwner, "p1", true, 0))
+ if on, err := r.hostedRead("p1"); !on || err != nil {
+ t.Fatalf("owner's setting not on: %t %v", on, err)
+ }
+ list, err := r.s.HostedSettings(r.ctx, hkOwner)
+ if err != nil || len(list) != 1 || list[0].Project != "p1" || !list[0].On || list[0].Revision != 1 || list[0].Title == "" {
+ t.Fatalf("owner's list: %+v %v", list, err)
+ }
+ r.must(r.s.SetHostedChecks(r.ctx, hkOwner, "p1", false, 1))
+ if on, _ := r.hostedRead("p1"); on {
+ t.Fatal("turned off, still on")
+ }
+ if on, err := r.hostedRead("missing"); on || err == nil {
+ t.Fatalf("unknown project: %t %v", on, err)
+ }
+}
+
+// TestHostedSettingRemovedOwnerRefused: the roster is read inside the
+// transaction. A removed or demoted owner cannot write, the setting they
+// turned on stops counting, and a roster or session error denies.
+func TestHostedSettingRemovedOwnerRefused(t *testing.T) {
+ r, fail := rosterRig(t)
+ r.task("tkhosted", "Hosted", hkOwner)
+ r.must(r.s.SetHostedChecks(r.ctx, hkOwner, "p1", true, 0))
+ r.exec("UPDATE members SET active=0 WHERE address=?", hkOwner)
+ if err := r.s.SetHostedChecks(r.ctx, hkOwner, "p1", false, 1); !errors.Is(err, ErrForbidden) {
+ t.Fatalf("removed owner wrote: %v", err)
+ }
+ if _, err := r.s.HostedSettings(r.ctx, hkOwner); !errors.Is(err, ErrForbidden) {
+ t.Fatalf("removed owner listed: %v", err)
+ }
+ if on, err := r.hostedRead("p1"); on || err != nil {
+ t.Fatalf("a removed owner's setting still counts: %t %v", on, err)
+ }
+ r.exec("UPDATE members SET active=1, role='member' WHERE address=?", hkOwner)
+ if on, _ := r.hostedRead("p1"); on {
+ t.Fatal("a demoted owner's setting still counts")
+ }
+ if r.s.SetHostedChecks(r.ctx, hkOwner, "p1", true, 1) == nil {
+ t.Fatal("demoted owner wrote")
+ }
+ r.exec("UPDATE members SET role='owner' WHERE address=?", hkOwner)
+ if on, _ := r.hostedRead("p1"); !on {
+ t.Fatal("restored owner's setting lost")
+ }
+ *fail = true
+ if on, err := r.hostedRead("p1"); on || err == nil {
+ t.Fatalf("roster error read as a setting: %t %v", on, err)
+ }
+ if r.s.SetHostedChecks(r.ctx, hkOwner, "p1", false, 1) == nil {
+ t.Fatal("roster error allowed a write")
+ }
+ *fail = false
+ r.s.authority.CurrentPerson = func(context.Context, *gorm.DB) error { return ErrForbidden }
+ if r.s.SetHostedChecks(r.ctx, hkOwner, "p1", false, 1) == nil {
+ t.Fatal("revoked session wrote")
+ }
+ if _, err := r.s.HostedSettings(r.ctx, hkOwner); err == nil {
+ t.Fatal("revoked session listed")
+ }
+}
+
+// TestHostedSettingRevisionConflict: a write names the revision it saw; a
+// stale one changes nothing, and an inactive project refuses.
+func TestHostedSettingRevisionConflict(t *testing.T) {
+ r, _ := rosterRig(t)
+ r.task("tkhosted", "Hosted", hkOwner)
+ r.must(r.s.SetHostedChecks(r.ctx, hkOwner, "p1", true, 0))
+ if err := r.s.SetHostedChecks(r.ctx, hkOwner, "p1", false, 0); !errors.Is(err, ErrCardConflict) {
+ t.Fatalf("stale write: %v", err)
+ }
+ if on, _ := r.hostedRead("p1"); !on {
+ t.Fatal("stale write took effect")
+ }
+ r.must(r.s.SetHostedChecks(r.ctx, hkOwner, "p1", false, 1))
+ r.must(r.s.SetHostedChecks(r.ctx, hkOwner, "p1", true, 2))
+ r.exec("UPDATE chat_projects SET state='archived' WHERE id='p1'")
+ if on, _ := r.hostedRead("p1"); on {
+ t.Fatal("inactive project kept the setting")
+ }
+ if r.s.SetHostedChecks(r.ctx, hkOwner, "p1", false, 3) == nil {
+ t.Fatal("inactive project accepted a write")
+ }
+}
+
+// TestHostedSettingAudited: each change is audited in its transaction,
+// with who, which project, the revision and the value; an audit failure
+// rolls the change back.
+func TestHostedSettingAudited(t *testing.T) {
+ r, _ := rosterRig(t)
+ r.task("tkhosted", "Hosted", hkOwner)
+ var got []string
+ r.s.authority.Audit = func(tx *gorm.DB, actor, kind, detail string) error {
+ if tx == nil {
+ t.Fatal("audit outside the transaction")
+ }
+ got = append(got, actor+" "+kind+" "+detail)
+ return nil
+ }
+ r.must(r.s.SetHostedChecks(r.ctx, hkOwner, "p1", true, 0))
+ r.must(r.s.SetHostedChecks(r.ctx, hkOwner, "p1", false, 1))
+ want := []string{hkOwner + " project.hosted_checks p1/revision:1/enabled:true", hkOwner + " project.hosted_checks p1/revision:2/enabled:false"}
+ if strings.Join(got, "\n") != strings.Join(want, "\n") {
+ t.Fatalf("audit:\n%s\nwant:\n%s", strings.Join(got, "\n"), strings.Join(want, "\n"))
+ }
+ r.s.authority.Audit = func(*gorm.DB, string, string, string) error { return errors.New("audit unavailable") }
+ if r.s.SetHostedChecks(r.ctx, hkOwner, "p1", true, 2) == nil {
+ t.Fatal("audit failure accepted")
+ }
+ if on, _ := r.hostedRead("p1"); on {
+ t.Fatal("unaudited change committed")
+ }
+ var rev int64
+ r.must(r.s.db.G.Raw("SELECT hosted_checks_revision FROM chat_projects WHERE id='p1'").Scan(&rev).Error)
+ if rev != 2 {
+ t.Fatalf("unaudited change moved the revision to %d", rev)
+ }
+}
diff --git a/internal/equipo/chat/projects.go b/internal/equipo/chat/projects.go
index af06d070..66349dc5 100644
--- a/internal/equipo/chat/projects.go
+++ b/internal/equipo/chat/projects.go
@@ -35,8 +35,12 @@ type projectRecord struct {
AutonomyRevision int64
CopyOwner string
CopyRevision int64
- ID string `gorm:"primaryKey"`
- Repo string `gorm:"uniqueIndex:chat_project_repo"`
+ // HostedChecks is "Run checks in a hosted VM" (hosted_setting.go).
+ HostedChecks bool
+ HostedChecksOwner string
+ HostedChecksRevision int64
+ ID string `gorm:"primaryKey"`
+ Repo string `gorm:"uniqueIndex:chat_project_repo"`
// Title is the product's name, from the catalog when it was added.
Title string
State string
diff --git a/internal/equipo/config.go b/internal/equipo/config.go
index 461223eb..6464adbd 100644
--- a/internal/equipo/config.go
+++ b/internal/equipo/config.go
@@ -77,6 +77,10 @@ type Config struct {
// work on a Mac worker. Unset, it waits as before, so a release can
// deploy inert.
MacEngineering bool
+ // HostedRunners (EQUIPO_HOSTED_RUNNERS=1, hosted runners slice 2)
+ // shows owners the "Run checks in a hosted VM" setting. Unset, the
+ // instance does nothing hosted.
+ HostedRunners bool
}
func LoadConfig(getenv func(string) string) (Config, error) {
@@ -84,6 +88,7 @@ func LoadConfig(getenv func(string) string) (Config, error) {
GitHubEnabled: getenv("EQUIPO_GITHUB") == "1",
ExecutionEnabled: getenv("EQUIPO_EXECUTION_ENABLED") == "1",
MacEngineering: getenv("EQUIPO_MAC_ENGINEERING") == "1",
+ HostedRunners: getenv("EQUIPO_HOSTED_RUNNERS") == "1",
ExecutionMarkerPath: getenv("EQUIPO_EXECUTION_MARKER_PATH"),
Origin: strings.TrimSpace(getenv("EQUIPO_ORIGIN")),
InstanceKey: strings.TrimSpace(getenv("EQUIPO_INSTANCE_KEY")),
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index 5fbbddb0..f3a6fe76 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -156,31 +156,35 @@ var pageCopy = map[string]string{
"agent.equipo_task_get": "Read one task and its current details.", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-20)
"agent.equipo_needs_you": "Read this person's recent unfinished tasks with a decision.", // COPY ACCEPTED BY DELEGATION (Luna, 2026-11-20)
- "work.reason.preview_headers": "the preview host needs an update before it can apply the required security headers", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "autonomy.auto_merge_sensitive": "Auto-merge sensitive changes", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "autonomy.auto_merge_sensitive_help": "Allow changes to sensitive files to merge when trusted checks pass.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "work.reason.preview_header_missing": "The preview host did not serve the safety header.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "preview.unsafe_question": "Open this preview without the safety header?", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "preview.unsafe_help": "The secret scan passed. This preview could still send browser data to other sites.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "preview.unsafe_open": "Open without the safety header", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "preview.wrapper_title": "Preview", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "autonomy.title": "What Equipo can do on its own", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "autonomy.lede": "Choose what Equipo may do for each project. Only owners can change these settings.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "autonomy.auto_merge_ci": "Auto-merge even when CI files change", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "autonomy.auto_merge_ci_help": "Allow automatic merges when check files change or Review receives a shortened diff, if checks from the base version pass.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "autonomy.public_previews": "Publish previews publicly", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "autonomy.public_previews_help": "Allow temporary preview links that anyone on the internet can open.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "autonomy.empty": "Add a project to choose what Equipo can do on its own.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "work.reason.base_checks_failed": "the base version's checks failed", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "chat.merge.not.base_failed": "the base version's checks failed", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "chat.merge.not.base_checks": "its checks were not run using the base version’s check files", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "chat.merge.not.gates": "it changes the files that run its checks", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "chat.merge.not.review_truncated": "Review received a shortened diff", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "work.reason.base_gate_unavailable": "the check files from the base version could not be loaded", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "work.reason.preview_secrets": "the preview was not published because its files may contain a secret", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "work.reason.preview_scanner": "the preview was not published because its secret scan could not be completed", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "work.reason.preview_public_disabled": "public previews are off for this project", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
- "work.reason.preview_host": "the preview host could not be verified", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "work.reason.preview_headers": "the preview host needs an update before it can apply the required security headers", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "autonomy.auto_merge_sensitive": "Auto-merge sensitive changes", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "autonomy.auto_merge_sensitive_help": "Allow changes to sensitive files to merge when trusted checks pass.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "work.reason.preview_header_missing": "The preview host did not serve the safety header.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "preview.unsafe_question": "Open this preview without the safety header?", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "preview.unsafe_help": "The secret scan passed. This preview could still send browser data to other sites.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "preview.unsafe_open": "Open without the safety header", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "preview.wrapper_title": "Preview", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "autonomy.title": "What Equipo can do on its own", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "autonomy.lede": "Choose what Equipo may do for each project. Only owners can change these settings.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "autonomy.auto_merge_ci": "Auto-merge even when CI files change", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "autonomy.auto_merge_ci_help": "Allow automatic merges when check files change or Review receives a shortened diff, if checks from the base version pass.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "autonomy.public_previews": "Publish previews publicly", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "autonomy.public_previews_help": "Allow temporary preview links that anyone on the internet can open.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "autonomy.empty": "Add a project to choose what Equipo can do on its own.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "hosted.title": "Hosted checks", // COPY REVIEW PENDING
+ "hosted.lede": "Choose which projects run their checks on machines Equipo hosts. Only owners can change this.", // COPY REVIEW PENDING
+ "hosted.checks": "Run checks in a hosted VM", // COPY REVIEW PENDING
+ "hosted.checks_help": "Each checks run happens on a new machine that Equipo starts for it and stops afterwards. Your own runner must still be online to send it the change.", // COPY REVIEW PENDING
+ "work.reason.base_checks_failed": "the base version's checks failed", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "chat.merge.not.base_failed": "the base version's checks failed", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "chat.merge.not.base_checks": "its checks were not run using the base version’s check files", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "chat.merge.not.gates": "it changes the files that run its checks", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "chat.merge.not.review_truncated": "Review received a shortened diff", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "work.reason.base_gate_unavailable": "the check files from the base version could not be loaded", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "work.reason.preview_secrets": "the preview was not published because its files may contain a secret", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "work.reason.preview_scanner": "the preview was not published because its secret scan could not be completed", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "work.reason.preview_public_disabled": "public previews are off for this project", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
+ "work.reason.preview_host": "the preview host could not be verified", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-19)
"access.not_owned": "Amadan can’t ask the owner of %s for access.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-17)
"access.already": "Equipo already has access.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-17)
diff --git a/internal/equipo/hosted_settings.go b/internal/equipo/hosted_settings.go
new file mode 100644
index 00000000..f23ceb0c
--- /dev/null
+++ b/internal/equipo/hosted_settings.go
@@ -0,0 +1,46 @@
+package equipo
+
+import (
+ "context"
+ "net/http"
+ "strconv"
+
+ "amadan.net/oficina/equipo/internal/equipo/chat"
+ "github.com/go-chi/chi/v5"
+)
+
+// hostedRoutes serves the "Run checks in a hosted VM" setting
+// (hosted runners slice 2) only when EQUIPO_HOSTED_RUNNERS=1. Without
+// it neither the page nor its save exists.
+func (a *application) hostedRoutes(r chi.Router) {
+ if !a.hostedRunners {
+ return
+ }
+ r.Get("/conversation/settings/hosted", a.settingsSectionHandler("hosted"))
+ r.Post("/settings/hosted", a.saveHostedSetting)
+}
+
+// hostedSection says whether the section may be served: the flag is on
+// and the person is an owner.
+func (a *application) hostedSection(owner bool) error {
+ if !a.hostedRunners {
+ return ErrNotFound
+ }
+ if !owner {
+ return ErrForbidden
+ }
+ return nil
+}
+
+func (a *application) saveHostedSetting(w http.ResponseWriter, r *http.Request) {
+ a.chatActionTo(w, r, "/conversation/settings/hosted", func(ctx context.Context, person string) error {
+ if a.hostedSection(true) != nil {
+ return chat.ErrForbidden
+ }
+ revision, err := strconv.ParseInt(r.FormValue("revision"), 10, 64)
+ if err != nil || revision < 0 {
+ return chat.ErrInvalid
+ }
+ return a.store.Chat().SetHostedChecks(ctx, person, r.FormValue("project"), r.FormValue("hosted_checks") == "on", revision)
+ })
+}
diff --git a/internal/equipo/hosted_settings_test.go b/internal/equipo/hosted_settings_test.go
new file mode 100644
index 00000000..16a0afad
--- /dev/null
+++ b/internal/equipo/hosted_settings_test.go
@@ -0,0 +1,135 @@
+package equipo
+
+import (
+ "bytes"
+ "context"
+ "net/http"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/equipo/chat"
+ "amadan.net/rastrillo/rastrillo/migrate"
+ "github.com/go-chi/chi/v5"
+)
+
+// hostedRoutesOf lists the hosted setting's routes a router serves.
+func hostedRoutesOf(t *testing.T, a *application) []string {
+ t.Helper()
+ r := chi.NewRouter()
+ a.hostedRoutes(r)
+ var out []string
+ if err := chi.Walk(r, func(method, route string, _ http.Handler, _ ...func(http.Handler) http.Handler) error {
+ if strings.Contains(route, "hosted") {
+ out = append(out, method+" "+route)
+ }
+ return nil
+ }); err != nil {
+ t.Fatal(err)
+ }
+ return out
+}
+
+// TestHostedSettingHiddenWithoutFlag: only EQUIPO_HOSTED_RUNNERS=1 shows
+// the section. Without it there is no menu entry, no page and no save
+// route, for owners too; with it, owners alone see the section.
+func TestHostedSettingHiddenWithoutFlag(t *testing.T) {
+ for _, value := range []string{"", "0", "true", "yes", " 1", "1"} {
+ env := map[string]string{"EQUIPO_ORIGIN": "https://equipo.bds.oncarlos.com", "EQUIPO_INSTANCE_KEY": "fixture", "CARLOS_MAIL": "submit", "EQUIPO_HOSTED_RUNNERS": value}
+ cfg, err := LoadConfig(func(k string) string { return env[k] })
+ if err != nil {
+ t.Fatal(err)
+ }
+ if cfg.HostedRunners != (value == "1") {
+ t.Fatalf("EQUIPO_HOSTED_RUNNERS=%q read as %t", value, cfg.HostedRunners)
+ }
+ }
+ var hosted settingsLink
+ for _, s := range settingsSections {
+ if s.Key == "hosted" {
+ hosted = s
+ }
+ }
+ if hosted.Href != "/conversation/settings/hosted" || hosted.CopyKey != "hosted.title" {
+ t.Fatalf("no hosted section: %+v", hosted)
+ }
+ off := &application{store: &Store{}}
+ if got := hostedRoutesOf(t, off); len(got) != 0 {
+ t.Fatalf("routes without the flag: %v", got)
+ }
+ for _, owner := range []bool{true, false} {
+ if off.settingsShown(hosted, owner) {
+ t.Fatalf("listed without the flag (owner %t)", owner)
+ }
+ }
+ if err := off.hostedSection(true); err == nil {
+ t.Fatal("page served without the flag")
+ }
+ on := &application{store: &Store{}, hostedRunners: true}
+ if got := strings.Join(hostedRoutesOf(t, on), ","); got != "GET /conversation/settings/hosted,POST /settings/hosted" {
+ t.Fatalf("routes with the flag: %s", got)
+ }
+ if !on.settingsShown(hosted, true) || on.settingsShown(hosted, false) {
+ t.Fatal("with the flag, the section is for owners only")
+ }
+ if on.hostedSection(false) == nil || on.hostedSection(true) != nil {
+ t.Fatal("with the flag, the page is for owners only")
+ }
+}
+
+// TestHostedSettingPage renders the section: its words and one switch per
+// project with its state and revision.
+func TestHostedSettingPage(t *testing.T) {
+ var data pageData
+ data.Settings.Section = "hosted"
+ data.Settings.Hosted = []chat.HostedSetting{{Project: "p1", Title: "Sample", On: true, Revision: 3}, {Project: "p2", Title: "Other", Revision: 0}}
+ var buf bytes.Buffer
+ if err := pages["settings_hub"].ExecuteTemplate(&buf, "hosted-settings", data); err != nil {
+ t.Fatal(err)
+ }
+ html := buf.String()
+ for _, key := range []string{"hosted.title", "hosted.lede", "hosted.checks", "hosted.checks_help"} {
+ if text := copyText(key); text == "" || text == key || !strings.Contains(html, text) {
+ t.Fatalf("%s missing from the page", key)
+ }
+ }
+ for _, want := range []string{`action="/settings/hosted"`, `name="project" value="p1"`, `name="revision" value="3"`, `name="hosted_checks" checked`, `name="project" value="p2"`, `name="revision" value="0"`} {
+ if !strings.Contains(html, want) {
+ t.Fatalf("missing %s in\n%s", want, html)
+ }
+ }
+ if strings.Count(html, " checked") != 1 {
+ t.Fatal("an off project shows on")
+ }
+}
+
+// TestHostedSettingMigrationOff: the migration follows 0124 and leaves
+// every existing project off, with no owner and revision 0.
+func TestHostedSettingMigrationOff(t *testing.T) {
+ all := Schema.All()
+ at := -1
+ for i, m := range all {
+ if m.ID == "equipo/0125_hosted_checks_setting" {
+ at = i
+ }
+ }
+ if at < 1 || all[at-1].ID != "equipo/0124_step_renders" {
+ t.Fatal("the hosted setting migration must follow 0124")
+ }
+ ctx := context.Background()
+ d, err := migrate.Replay(ctx, all[:at])
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer d.Close()
+ for _, q := range []string{"INSERT INTO chat_projects(id,repo,state) VALUES('old','amadan.net/oficina/old','active')", all[at].SQL} {
+ if _, err := d.ExecContext(ctx, q); err != nil {
+ t.Fatal(err)
+ }
+ }
+ var on bool
+ var owner string
+ var revision int
+ if err := d.QueryRowContext(ctx, "SELECT coalesce(hosted_checks,0),coalesce(hosted_checks_owner,''),coalesce(hosted_checks_revision,0) FROM chat_projects WHERE id='old'").Scan(&on, &owner, &revision); err != nil || on || owner != "" || revision != 0 {
+ t.Fatalf("migration turned hosted checks on: %t %q %d %v", on, owner, revision, err)
+ }
+}
diff --git a/internal/equipo/migrations/0125_hosted_checks_setting.sql b/internal/equipo/migrations/0125_hosted_checks_setting.sql
new file mode 100644
index 00000000..f887d2cd
--- /dev/null
+++ b/internal/equipo/migrations/0125_hosted_checks_setting.sql
@@ -0,0 +1,7 @@
+-- Hosted runners slice 2 (Task 18): the project setting "Run checks in a
+-- hosted VM", off by default. hosted_checks is the value, the owner who
+-- last changed it and the revision a write must name; it counts only
+-- while that owner is still an owner. No existing row changes.
+ALTER TABLE chat_projects ADD COLUMN hosted_checks numeric;
+ALTER TABLE chat_projects ADD COLUMN hosted_checks_owner text;
+ALTER TABLE chat_projects ADD COLUMN hosted_checks_revision integer;
diff --git a/internal/equipo/migrations/schema.sql b/internal/equipo/migrations/schema.sql
index b295b2da..429487fc 100644
--- a/internal/equipo/migrations/schema.sql
+++ b/internal/equipo/migrations/schema.sql
@@ -915,3 +915,11 @@ ALTER TABLE chat_steps ADD COLUMN design_options text NOT NULL DEFAULT "";
-- records as JSON (wire.RenderAudit), plain data. A team record, as its
-- step; no existing row changes.
CREATE TABLE chat_step_renders (step_id text, attempt integer, renders text NOT NULL DEFAULT "", updated_at datetime, PRIMARY KEY (step_id, attempt));
+
+-- Hosted runners slice 2 (Task 18): the project setting "Run checks in a
+-- hosted VM", off by default. hosted_checks is the value, the owner who
+-- last changed it and the revision a write must name; it counts only
+-- while that owner is still an owner. No existing row changes.
+ALTER TABLE chat_projects ADD COLUMN hosted_checks numeric;
+ALTER TABLE chat_projects ADD COLUMN hosted_checks_owner text;
+ALTER TABLE chat_projects ADD COLUMN hosted_checks_revision integer;
diff --git a/internal/equipo/render.go b/internal/equipo/render.go
index 0e96bc83..54d95487 100644
--- a/internal/equipo/render.go
+++ b/internal/equipo/render.go
@@ -60,7 +60,7 @@ func init() {
"roleKey": func(k Role) string { return "role." + string(k) },
}).ParseFS(ui.Templates(), "*.html"))
layout := template.Must(template.Must(base.Clone()).ParseFS(appFS, "templates/layout.html"))
- shell := template.Must(template.Must(layout.Clone()).ParseFS(appFS, "templates/chrome.html", "templates/forms.html", "templates/task_card.html", "templates/conversation_card.html", "templates/work_parts.html", "templates/housekeeping_settings.html", "templates/autonomy_settings.html", "templates/settings_nav.html", "templates/merge_policy.html", "templates/placement_chip.html", "templates/access_card.html"))
+ shell := template.Must(template.Must(layout.Clone()).ParseFS(appFS, "templates/chrome.html", "templates/forms.html", "templates/task_card.html", "templates/conversation_card.html", "templates/work_parts.html", "templates/housekeeping_settings.html", "templates/autonomy_settings.html", "templates/hosted_settings.html", "templates/settings_nav.html", "templates/merge_policy.html", "templates/placement_chip.html", "templates/access_card.html"))
for _, name := range []string{"github", "placement", "oficina_id", "id_public", "person_devices", "person_device", "teams", "onboarding", "invite", "playbooks", "playbook_form", "playbook_diff", "specialist_form", "template_library", "template_diff", "conversation", "chat", "jobs", "thread", "plan", "coordinator", "preferences", "index", "empty", "projects", "project", "project_form", "people", "settings", "specialist", "errors", "door", "form_error", "runners", "tasks", "task", "task_form", "question", "merge", "connections", "recovery", "recovery_form", "rendered_approval", "notebook", "housekeeping", "work_tasks", "work_task", "work_projects", "work_project", "models", "work_needs", "settings_hub", "team", "usage"} {
var page *template.Template
switch name {
diff --git a/internal/equipo/settings_hub.go b/internal/equipo/settings_hub.go
index b23105f2..e1a21bef 100644
--- a/internal/equipo/settings_hub.go
+++ b/internal/equipo/settings_hub.go
@@ -48,6 +48,7 @@ type settingsLink struct {
var settingsSections = []settingsLink{
{Key: "github", Href: "/conversation/settings/github", CopyKey: "github.title", Icon: "plug"},
{Key: "autonomy", Href: "/conversation/settings/autonomy", CopyKey: "autonomy.title", Icon: "list-checks"},
+ {Key: "hosted", Href: "/conversation/settings/hosted", CopyKey: "hosted.title", Icon: "monitor"},
{Key: "oficina-id", Href: "/conversation/settings/oficina-id", CopyKey: "id.title", Icon: "users"},
{Key: "thinking", Href: "/conversation/settings/thinking", CopyKey: "thinking.title", Icon: "type"},
{Key: "connections", Href: "/conversation/settings/connections", CopyKey: "settings.connections", Icon: "plug"},
@@ -64,6 +65,9 @@ var settingsSections = []settingsLink{
// section's own data.
type settingsHubView struct {
CopyProjects []wire.Project
+ // Hosted is "Run checks in a hosted VM" for each project (owners,
+ // EQUIPO_HOSTED_RUNNERS=1 only).
+ Hosted []chat.HostedSetting
// Places are the Places page's lines, state first (read-only).
Places []placeView
Section string
@@ -79,13 +83,7 @@ func (a *application) settingsPage(r *http.Request, section string, root bool) (
return data, err
}
for _, s := range settingsSections {
- if s.Key == "github" && (!data.Owner || a.store.forge == nil || !a.store.forge.Enabled) {
- continue
- }
- if s.Key == "autonomy" && !data.Owner {
- continue
- }
- if s.Key == "oficina-id" && a.home == nil {
+ if !a.settingsShown(s, data.Owner) {
continue
}
s.Current = s.Key == section
@@ -96,6 +94,21 @@ func (a *application) settingsPage(r *http.Request, section string, root bool) (
return data, nil
}
+// settingsShown says whether the Settings menu lists s for this person.
+func (a *application) settingsShown(s settingsLink, owner bool) bool {
+ switch s.Key {
+ case "github":
+ return owner && a.store.forge != nil && a.store.forge.Enabled
+ case "autonomy":
+ return owner
+ case "hosted":
+ return a.hostedSection(owner) == nil
+ case "oficina-id":
+ return a.home != nil
+ }
+ return true
+}
+
// settingsHub is GET /conversation/settings: the menu on a phone, the
// first section (Thinking words) beside it on a desktop.
func (a *application) settingsHub(w http.ResponseWriter, r *http.Request) {
@@ -123,6 +136,12 @@ func (a *application) settingsSection(w http.ResponseWriter, r *http.Request, se
a.failure(w, r, ErrForbidden)
return
}
+ if section == "hosted" {
+ if err := a.hostedSection(data.Owner); err != nil {
+ a.failure(w, r, err)
+ return
+ }
+ }
switch section {
case "copy", "autonomy":
projects, err := a.store.Chat().Projects(ctx, address)
@@ -131,6 +150,13 @@ func (a *application) settingsSection(w http.ResponseWriter, r *http.Request, se
return
}
data.Settings.CopyProjects = projects.Items
+ case "hosted":
+ hosted, err := a.store.Chat().HostedSettings(ctx, address)
+ if err != nil {
+ a.failure(w, r, chatError(err))
+ return
+ }
+ data.Settings.Hosted = hosted
case "thinking":
words, err := a.store.Chat().Thinking(ctx, address)
if err != nil {
diff --git a/internal/equipo/templates/hosted_settings.html b/internal/equipo/templates/hosted_settings.html
new file mode 100644
index 00000000..e427687f
--- /dev/null
+++ b/internal/equipo/templates/hosted_settings.html
@@ -0,0 +1,11 @@
+{{define "hosted-settings"}}
+{{template "settings-head" (dict "Title" "hosted.title" "Lede" "hosted.lede")}}
+{{range .Settings.Hosted}}<section equipo-sp-group><div equipo-sp-group-head><h2>{{.Title}}</h2></div>
+<form method="post" action="/settings/hosted">
+<input type="hidden" name="project" value="{{.Project}}"><input type="hidden" name="revision" value="{{.Revision}}">
+<div equipo-sp-card>
+<div equipo-sp-row><div equipo-sp-label><label equipo-sp-title for="hosted-checks-{{.Project}}">{{copy "hosted.checks"}}</label><p equipo-sp-desc id="hosted-checks-help-{{.Project}}">{{copy "hosted.checks_help"}}</p></div><span equipo-sp-control><label rst-switch><input id="hosted-checks-{{.Project}}" aria-describedby="hosted-checks-help-{{.Project}}" type="checkbox" name="hosted_checks"{{if .On}} checked{{end}}><span rst-switch-track aria-hidden="true"></span></label></span></div>
+</div>
+<div equipo-copy-actions><button rst-btn="primary" type="submit">{{copy "form.save"}}</button></div>
+</form></section>{{end}}
+{{end}}
diff --git a/internal/equipo/templates/settings_hub.html b/internal/equipo/templates/settings_hub.html
index c048c8bc..8b1b42ba 100644
--- a/internal/equipo/templates/settings_hub.html
+++ b/internal/equipo/templates/settings_hub.html
@@ -1,6 +1,6 @@
{{define "up"}}{{template "settings-up" .}}{{end}}
{{define "up-label"}}{{template "settings-up-label" .}}{{end}}
-{{define "title"}}{{if eq .Settings.Section "autonomy"}}{{copy "autonomy.title"}}{{else if eq .Settings.Section "copy"}}{{copy "copy.title"}}{{else}}{{if eq .Settings.Section "housekeeping"}}{{copy "settings.housekeeping"}}{{else if .Settings.Root}}{{copy "nav.settings"}}{{else}}{{copy "thinking.title"}}{{end}}{{end}}{{end}}
+{{define "title"}}{{if eq .Settings.Section "autonomy"}}{{copy "autonomy.title"}}{{else if eq .Settings.Section "hosted"}}{{copy "hosted.title"}}{{else if eq .Settings.Section "copy"}}{{copy "copy.title"}}{{else}}{{if eq .Settings.Section "housekeeping"}}{{copy "settings.housekeeping"}}{{else if .Settings.Root}}{{copy "nav.settings"}}{{else}}{{copy "thinking.title"}}{{end}}{{end}}{{end}}
{{define "content"}}
<div equipo-settings-layout data-section="{{.Settings.Section}}"{{if .Settings.Root}} data-root{{end}} data-settings-live>
<template equipo-saved-template><span equipo-saved-tick role="status">{{icon "check"}}<span>{{copy "settings.saved"}}</span></span></template>
@@ -9,6 +9,7 @@
{{if eq .Settings.Section "thinking"}}{{template "settings-head" (dict "Title" "thinking.title" "Lede" "thinking.lede")}}
{{template "thinking-form" (dict "Thinking" .Settings.Thinking "From" "settings")}}
{{else if eq .Settings.Section "autonomy"}}{{template "autonomy-settings" .}}
+{{else if eq .Settings.Section "hosted"}}{{template "hosted-settings" .}}
{{else if eq .Settings.Section "copy"}}{{template "settings-head" (dict "Title" "copy.title" "Lede" "copy.lede")}}
{{range .Settings.CopyProjects}}<section equipo-sp-group><div equipo-sp-group-head><h2>{{.Title}}</h2></div>
<form method="post" action="/settings/copy">