oficina / equipo Public

Abilities: phase 2 end to end

Versions in between, as deployed: Equipo at step 2 with a Base from
before the board keeps every ability on as legacy, renewed through its
operations route across 30 minutes, and PUT host succeeds. With web off,
web_lookup isn't offered and its refusal names who can turn it on, with
no machinery words (thintest.MachineryWords). Staging acceptance 4: a
member who disconnects in Base and keeps using their own Equipo access
has the copy revoked on the next fetch, and nothing switched runs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 7e6e97902c907f5e81b39807d6549e26402b6c62 parent 12e49fa
2 files changed, +140 −0
  • internal/thintest/abilities_e2e_test.go +117 −0
  • internal/thintest/machinery_words.go +23 −0
diff --git a/internal/thintest/abilities_e2e_test.go b/internal/thintest/abilities_e2e_test.go
new file mode 100644
index 00000000..591cc2cc
--- /dev/null
+++ b/internal/thintest/abilities_e2e_test.go
@@ -0,0 +1,117 @@
+package thintest
+
+import (
+ "context"
+ "encoding/json"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/equipo/assist"
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// webStub is a web provider with web_lookup, so the switch in front of it
+// can be seen before lookups are built.
+type webStub struct{}
+
+func (webStub) Name() string { return "web" }
+func (webStub) List(context.Context, string) ([]assist.Operation, error) {
+ return []assist.Operation{{Name: "web_lookup", App: "Web", ReadOnly: true, Description: "Look something up on the public web for the person.", Input: json.RawMessage(`{"type":"object","properties":{},"additionalProperties":false}`)}}, nil
+}
+func (webStub) Invoke(context.Context, string, string, json.RawMessage, string) (json.RawMessage, error) {
+ return json.RawMessage(`{"shown":true}`), nil
+}
+
+// endTurn ends the rig's Assistant turn with a reply.
+func (o *opsRig) endTurn() {
+ o.t.Helper()
+ if err := o.runner.Send(o.ctx, "end-"+o.turn, wire.FrameReply, wire.Reply{TurnID: o.turn, Attempt: 1, Text: "Done."}); err != nil {
+ o.t.Fatal(err)
+ }
+ o.until("turn "+o.turn+" replied", func() bool {
+ return o.rows("SELECT count(*) FROM chat_turns WHERE id = ? AND state = ?", o.turn, wire.TurnReplied) == 1
+ })
+}
+
+// moveClock sets the instance's clock d ahead of now.
+func (o *opsRig) moveClock(d time.Duration) {
+ o.t.Helper()
+ at := time.Now().UTC().Add(d)
+ o.inst.Store.Chat().SetClock(func() time.Time { return at })
+ o.t.Cleanup(func() { o.inst.Store.Chat().SetClock(func() time.Time { return time.Now().UTC() }) })
+}
+
+// Equipo at step 2 with a Base from before the board (step 0 or 1): PUT
+// host succeeds, every key is on as legacy, renewed through the Base's
+// operations route across 30 minutes, and the Assistant does what it did.
+func TestOldBaseKeepsTodaysBehaviour(t *testing.T) {
+ base := StartFakeBase(t)
+ base.SetLegacy(true)
+ r := newRigWith(t, func(i *Instance) { i.AssistantHosts = []string{base.Origin} })
+ o := &opsRig{toolRig: &toolRig{rig: r, runner: r.dialAt(wire.ProtocolAssistant)}, base: base, a: r.client.Assistant(), protocol: wire.ProtocolAssistant}
+ if out := o.connect(base.Token); out.Revision != 1 {
+ t.Fatalf("PUT host: %+v", out)
+ }
+ for i := 1; i <= 3; i++ {
+ o.moveClock(time.Duration(i) * 11 * time.Minute)
+ o.begin("What are my apps?")
+ if res := o.use("u"+itoa(i), "base_apps", map[string]any{}); res.IsError {
+ t.Fatalf("after %d minutes: %+v", i*11, res)
+ }
+ o.endTurn()
+ }
+ got, err := o.inst.Store.Chat().OwnAbilities(o.ctx, Owner)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, k := range wire.Abilities {
+ if !got.Abilities[k] {
+ t.Errorf("%s off for an old Base's member", k)
+ }
+ }
+}
+
+// With web off, the Assistant is told in one line who can turn it on,
+// with no machinery in what it is told; the lookup isn't offered.
+func TestWebOffReplyNamesOwner(t *testing.T) {
+ o := newOpsRig(t, webStub{})
+ o.connect(o.base.Token)
+ o.setBoard(wire.AbilityWeb)
+ o.begin("What's the weather in Dublin?")
+ if res := o.tool("l1", wire.ToolLook, map[string]any{"query": "weather"}); strings.Contains(res.Text, "web_lookup") {
+ t.Errorf("look offers web_lookup with web off: %s", res.Text)
+ }
+ res := o.use("u1", "web_lookup", map[string]any{})
+ if !res.IsError || res.Code != wire.CodeAbilityOff || !strings.Contains(res.Text, "Paul can turn it on") || !strings.Contains(res.Text, "Look things up on the web") {
+ t.Fatalf("web_lookup with web off: %+v", res)
+ }
+ if bad := MachineryIn(res.Text); bad != "" {
+ t.Errorf("the refusal names %q: %s", bad, res.Text)
+ }
+}
+
+// Staging acceptance 4, headless: the member disconnects Ask in Base,
+// which forgets their host token, and uses the Assistant with their own
+// Equipo bearer: nothing switched runs.
+func TestStagingAcceptance4Headless(t *testing.T) {
+ o := newOpsRig(t, webStub{})
+ o.connect(o.base.Token)
+ o.begin("What's the weather?")
+ if res := o.use("u1", "web_lookup", map[string]any{}); res.IsError {
+ t.Fatalf("before: %+v", res)
+ }
+ o.endTurn()
+ o.base.Forget(o.base.Token)
+ o.moveClock(2 * time.Minute)
+ o.begin("What's the weather now?")
+ if res := o.use("u2", "web_lookup", map[string]any{}); !res.IsError || res.Code == "used" {
+ t.Errorf("after disconnecting in Base: %+v", res)
+ }
+ if res := o.use("u3", "base_apps", map[string]any{}); !res.IsError {
+ t.Errorf("Base's reads with a forgotten token: %+v", res)
+ }
+ if n := o.rows("SELECT count(*) FROM chat_assistant_abilities WHERE person = ? AND revoked_at IS NOT NULL", Owner); n != 1 {
+ t.Errorf("the copy wasn't revoked: %d", n)
+ }
+}
diff --git a/internal/thintest/machinery_words.go b/internal/thintest/machinery_words.go
new file mode 100644
index 00000000..39868c00
--- /dev/null
+++ b/internal/thintest/machinery_words.go
@@ -0,0 +1,23 @@
+package thintest
+
+import (
+ "regexp"
+ "strings"
+)
+
+// MachineryWords are the words for Equipo's machinery that nothing Base
+// shows a person may carry (spec 2026-11-26-assistant-abilities, the
+// jobs plan's machinery_words): Base and its Assistant name outcomes,
+// never how they are made.
+var MachineryWords = []string{"Equipo", "team", "Coordinator", "runner", "task", "branch", "merge", "check", "repository", "Amadan"}
+
+// MachineryIn is the first machinery word text carries as a word of its
+// own (any case), "" for none.
+func MachineryIn(text string) string {
+ for _, w := range MachineryWords {
+ if regexp.MustCompile(`(?i)\b` + regexp.QuoteMeta(strings.ToLower(w)) + `s?\b`).MatchString(text) {
+ return w
+ }
+ }
+ return ""
+}