oficina / equipo Public

Abilities: Research for a person's job needs web

Research reads web pages for the person a job is for. With web off for
them, toolResearch is refused research_off ("Refused: the person this
work is for can't have web pages read. Carry on without Research."),
and authorizeResearch, which every Research lease call runs, refuses
ability_off: a step dispatched before the switch went off doesn't start,
and one running can't renew its lease. The step's Allow card is as it
was. Tasks no hand-off follows are outside the board.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 12e49faa88d5365e282abc070cab0e7ed1875cee parent 9aa5d34
3 files changed, +99 −0
  • internal/equipo/chat/research.go +31 −0
  • internal/equipo/chat/research_abilities_test.go +49 −0
  • internal/thintest/build_off_contract_test.go +19 −0
diff --git a/internal/equipo/chat/research.go b/internal/equipo/chat/research.go
index 77556872..e2730312 100644
--- a/internal/equipo/chat/research.go
+++ b/internal/equipo/chat/research.go
@@ -94,6 +94,14 @@ func (t *txn) toolResearch(l Lease, r turnRecord, v *wire.ToolCall) (wire.ToolRe
} else if err != nil {
return wire.ToolResult{}, err
}
+ // Research reads web pages for the person the job is for: they need
+ // web (spec 2026-11-26-assistant-abilities §6.2).
+ if ok, err := t.researchAllowed(k.ID); err != nil || !ok {
+ if err != nil {
+ return wire.ToolResult{}, err
+ }
+ return refused(wire.CodeResearchOff, toolResearchOff), nil
+ }
question, ok := cleanText(in.Question, wire.MaxResearchQuestion)
if !ok {
return refused("question", toolResearchQuestion), nil
@@ -724,6 +732,11 @@ func (t *txn) researchReport(l Lease, k *taskRecord, s *stepRecord, v *wire.Step
// the step ends cancelled (research_no_grant), which releases the
// Engineering it held.
func (t *txn) authorizeResearch(s *stepRecord) (string, error) {
+ // Every lease call: a Research step of a job whose person can't have
+ // web pages read doesn't start, and can't renew its lease (§6.2).
+ if ok, err := t.researchAllowed(s.TaskID); err != nil || !ok {
+ return wire.CodeAbilityOff, err
+ }
sp, g, err := t.researchGrant()
if err != nil && !errors.Is(err, ErrNoGrant) {
return "", err
@@ -834,3 +847,21 @@ func (t *txn) fenceResearch(l Lease) error {
}
return nil
}
+
+// toolResearchOff is the Coordinator's refusal for Research in a job
+// whose person can't have web pages read (model-facing, reviewed as code).
+const toolResearchOff = "Refused: the person this work is for can't have web pages read. Carry on without Research."
+
+// researchAllowed reports whether Research may read the web for a task:
+// true for a task no hand-off follows, else its person's web.
+func (t *txn) researchAllowed(taskID string) (bool, error) {
+ h, ok, err := t.handoffOf("", taskID)
+ if err != nil || !ok {
+ return err == nil, err
+ }
+ sw, err := t.switches(h.Person)
+ if err != nil {
+ return false, err
+ }
+ return sw.Can(wire.AbilityWeb), nil
+}
diff --git a/internal/equipo/chat/research_abilities_test.go b/internal/equipo/chat/research_abilities_test.go
new file mode 100644
index 00000000..b9b4c4d4
--- /dev/null
+++ b/internal/equipo/chat/research_abilities_test.go
@@ -0,0 +1,49 @@
+package chat
+
+import (
+ "context"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+// A Research step of a job dispatched before web went off isn't granted
+// its start or a renewal: authorizeResearch refuses ability_off on every
+// lease call. A task no hand-off follows is outside the board.
+func TestResearchLeaseNeedsWeb(t *testing.T) {
+ h, base := boardBase(t)
+ refresh(t, h)
+ for _, r := range []any{
+ &handoffRecord{ID: "h_r", Person: abPerson, State: handoffOpen, LedgerKey: "k-r", CreatedAt: h.now(), UpdatedAt: h.now()},
+ &handoffTaskRecord{HandoffID: "h_r", TaskID: "tk_job", Created: true},
+ } {
+ if err := h.s.db.G.Create(r).Error; err != nil {
+ t.Fatal(err)
+ }
+ }
+ authorize := func(task string) string {
+ var refused string
+ if err := h.s.tx(context.Background(), func(tx *txn) error {
+ allowed, err := tx.researchAllowed(task)
+ if err != nil || allowed {
+ return err
+ }
+ refused, err = tx.authorizeResearch(&stepRecord{ID: "s_r", TaskID: task})
+ return err
+ }); err != nil {
+ t.Fatal(err)
+ }
+ return refused
+ }
+ if got := authorize("tk_job"); got != "" {
+ t.Errorf("with web on: %q", got)
+ }
+ base.set(func(f *fakeBoardBase) { f.board.Abilities["web"], f.board.Revision = false, 2 })
+ refresh(t, h)
+ if got := authorize("tk_job"); got != wire.CodeAbilityOff {
+ t.Errorf("with web off: %q", got)
+ }
+ if got := authorize("tk_own"); got != "" {
+ t.Errorf("a task outside the board: %q", got)
+ }
+}
diff --git a/internal/thintest/build_off_contract_test.go b/internal/thintest/build_off_contract_test.go
index 703e5683..33e4f665 100644
--- a/internal/thintest/build_off_contract_test.go
+++ b/internal/thintest/build_off_contract_test.go
@@ -151,3 +151,22 @@ func TestProjectCreatedAfterSwitchOff(t *testing.T) {
refusedOff(t, "record_task", o.call("rt", wire.ToolRecordTask, map[string]any{"repo": "amadan.net/oficina/site", "title": "Site", "brief": "Build it."}))
})
}
+
+// Research for a job whose person can't have web pages read is refused
+// research_off, with the instance's text; with web on it isn't.
+func TestResearchNeedsWeb(t *testing.T) {
+ o := newTeamRigAt(t, wire.ProtocolCurrent)
+ o.ask("Make mockups for the barber shop.")
+ _, cmd := o.handoff("rw", "Make mockups for the barber shop.", "")
+ o.in(cmd.TurnID, func() {
+ id := o.shopTask("rw")
+ o.setBoard(wire.AbilityWeb)
+ if res := o.research("rw-r", id); !res.IsError || res.Code != wire.CodeResearchOff || res.Text != "Refused: the person this work is for can't have web pages read. Carry on without Research." {
+ t.Errorf("research with web off: %+v", res)
+ }
+ o.setBoard()
+ if res := o.research("rw-r2", id); res.Code == wire.CodeResearchOff {
+ t.Errorf("research with web on: %+v", res)
+ }
+ })
+}