oficina / equipo Public

chat: taste questions wait on an open ask; events carry them right

Task 10 review, fix round 1.

1. House rule (houseRule 2026-12-01.2): when status says asked open for
   the person and project, the coordinator does not start Design or ask
   again and waits for the answer; that branch comes before "otherwise
   start at once". TestHouseRuleAsksTaste asserts the branch and its
   order.
2. Card events: proposeSpecialist records the Add card's ask before
   cardEvent, so the event that brings the card carries its questions;
   answerSpecialist settles (Add) or drops (Not now) the ask before
   saveCard, so the answered card's event no longer offers them.
   answerTaste already settled before its saveCard. New
   TestTasteCardEvents reads the stored event payloads (chat_events) for
   the Add card (raise, Add, Not now) and the taste card (raise, Skip).
3. chat-stream.js: a refresh's snapshot of a card's fields now replaces
   the last one, and an empty snapshot deletes it. The bug was not only
   in the keyed path: any card field (a keyless textarea too) emptied
   after one refresh came back on the next. Fixed for both, one line.
   New browser test TestBrowserTasteCardDrafts: tick a feel and type in
   a keyless field, refresh, both kept; untick and clear, refresh,
   neither comes back.

TDD: TestBrowserTasteCardDrafts failed before the JS fix ("after
unticking and clearing: true false plain draft"); TestTasteCardEvents
and the new TestHouseRuleAsksTaste assertions were written with the
fixes and checked by reverting each (below). Pass: whole chat package;
thin 'Design|Ask|Taste|MCP|Converse|Opening|House|Voice|Jobs|Bridge|
Proposal|Specialist|Coordinator' (one run failed with its output lost,
three reruns pass); equipo 'Taste|Card|Copy|Chat|Direction'; browser
TestBrowserTasteCardDrafts, DirectionDrafts, TasteDrafts, NeedsDrafts.
vet and gofmt clean.

Mutations (each alone, restored):
F1 open-ask wait clause removed: TestHouseRuleAsksTaste caught
F1b house rule version back to 2026-12-01.1: TestHouseRuleAsksTaste caught
F2a Add card event before its ask: TestTasteCardEvents caught
F2b answered event before the ask settles or drops: TestTasteCardEvents
    caught
F3 stale draft kept (no delete): TestBrowserTasteCardDrafts caught
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev d0d0dc7bba0b63e30ad6994e335a12e50e486a81 parent afd8c33
6 files changed, +204 −14
  • internal/equipo/chat/specialists.go +13 −10
  • internal/equipo/chat/taste_ask_test.go +60 −0
  • internal/equipo/static/chat-stream.js +3 −1
  • internal/equipo/taste_card_browser_test.go +119 −0
  • internal/runner/thin/claude.go +2 −2
  • internal/runner/thin/taste_ask_test.go +7 −1
diff --git a/internal/equipo/chat/specialists.go b/internal/equipo/chat/specialists.go
index 5600e0e6..ac2f6783 100644
--- a/internal/equipo/chat/specialists.go
+++ b/internal/equipo/chat/specialists.go
@@ -276,21 +276,22 @@ func (t *txn) proposeSpecialist(r turnRecord, p specialist.Proposal, project pro
if err := t.db.Create(&c).Error; err != nil {
return wire.ToolResult{}, err
}
- if err := t.cardEvent(c); err != nil {
- return wire.ToolResult{}, err
- }
+ text := toolSpecialistAsked
if project.ID != "" {
- text := toolSpecialistAskedProject
+ text = toolSpecialistAskedProject
if feels != nil && p.Profile == specialist.ProfileDesign {
+ // The ask first: the card's event carries its questions.
extra, err := t.askOnAdd(c, project.ID, feels)
if err != nil {
return wire.ToolResult{}, err
}
text += extra
}
- return wire.ToolResult{Code: "proposed", Text: text}, nil
}
- return wire.ToolResult{Code: "proposed", Text: toolSpecialistAsked}, nil
+ if err := t.cardEvent(c); err != nil {
+ return wire.ToolResult{}, err
+ }
+ return wire.ToolResult{Code: "proposed", Text: text}, nil
}
// answerSpecialist is the answer on a specialist card: open and at its
@@ -371,10 +372,8 @@ func (t *txn) answerSpecialist(person string, c cardRecord, in wire.AnswerCard)
if err := t.specialistAudit(sp, action, person); err != nil {
return wire.Card{}, wire.Card{}, err
}
- c.State, c.Choice = wire.CardAnswered, in.Choice
- if err := t.saveCard(&c); err != nil {
- return wire.Card{}, wire.Card{}, err
- }
+ // The ask settles before the card is saved, so the answered card's
+ // event no longer carries its questions.
if ask.CardID != "" && sp.State == wire.SpecialistActive {
if err := t.settleAsk(ask, in.Taste); err != nil {
return wire.Card{}, wire.Card{}, err
@@ -384,6 +383,10 @@ func (t *txn) answerSpecialist(person string, c cardRecord, in wire.AnswerCard)
return wire.Card{}, wire.Card{}, err
}
}
+ c.State, c.Choice = wire.CardAnswered, in.Choice
+ if err := t.saveCard(&c); err != nil {
+ return wire.Card{}, wire.Card{}, err
+ }
if sp.State == wire.SpecialistActive {
if err := t.queueSpecialistAdded(c, sp, person); err != nil {
return wire.Card{}, wire.Card{}, err
diff --git a/internal/equipo/chat/taste_ask_test.go b/internal/equipo/chat/taste_ask_test.go
index 24b48d0e..af3a1f54 100644
--- a/internal/equipo/chat/taste_ask_test.go
+++ b/internal/equipo/chat/taste_ask_test.go
@@ -472,6 +472,66 @@ func (r *hkRig) proposeFeels(l Lease, project, scope string, feels []string) (sp
return r.proposal(specialist.ProfileDesign, scope), res
}
+// cardEvents are the card events the person's stream carried for card,
+// oldest first, as the stream sent them.
+func (r *hkRig) cardEvents(card string) []wire.Card {
+ r.t.Helper()
+ var rows []eventRecord
+ r.must(r.s.db.G.Where("type = ?", wire.EventCard).Order("id").Find(&rows).Error)
+ var out []wire.Card
+ for _, row := range rows {
+ var e wire.Event
+ r.must(json.Unmarshal([]byte(row.Body), &e))
+ if e.ID != card {
+ continue
+ }
+ var c wire.Card
+ r.must(json.Unmarshal(e.Data, &c))
+ out = append(out, c)
+ }
+ return out
+}
+
+// TestTasteCardEvents (review fix 2): the event that brings a card that
+// asks the questions carries them, and the event of its answer does not,
+// for the Add card and the taste card alike.
+func TestTasteCardEvents(t *testing.T) {
+ r, l, _ := grantRig(t)
+ sp, _ := r.proposeFeels(l, "Patrix", "p_patrix", tasteFeels)
+ events := r.cardEvents(sp.CardID)
+ if len(events) != 1 || events[0].Taste == nil || !reflect.DeepEqual(events[0].Taste.Feels, tasteFeels) {
+ t.Fatalf("the Add card's event: %+v", events)
+ }
+ if _, _, err := r.s.Answer(r.ctx, paul, sp.CardID, wire.AnswerCard{Choice: wire.ChoiceAdd, Revision: 1, Taste: &wire.TasteAnswer{Feels: []string{"Calm"}}}); err != nil {
+ t.Fatal(err)
+ }
+ events = r.cardEvents(sp.CardID)
+ if last := events[len(events)-1]; len(events) < 2 || last.State != wire.CardAnswered || last.Taste != nil {
+ t.Fatalf("the Add's event: %+v", last)
+ }
+ // Not now: its event offers no questions either.
+ r2, l2, _ := grantRig(t)
+ sp2, _ := r2.proposeFeels(l2, "Patrix", "p_patrix", tasteFeels)
+ r2.must(r2.answer(paul, sp2, wire.ChoiceNotNow, 1))
+ if events := r2.cardEvents(sp2.CardID); events[len(events)-1].Taste != nil {
+ t.Fatalf("Not now's event: %+v", events[len(events)-1])
+ }
+ // The taste card.
+ r3, l3, _ := tasteAskRig(t)
+ _, c := r3.askTaste(l3, "Calmer.")
+ events = r3.cardEvents(c.ID)
+ if len(events) != 1 || events[0].Taste == nil || !reflect.DeepEqual(events[0].Taste.Feels, tasteFeels) || events[0].Name != "Patrix" {
+ t.Fatalf("the taste card's event: %+v", events)
+ }
+ if _, err := r3.answerTaste(c, wire.ChoiceSkip, nil); err != nil {
+ t.Fatal(err)
+ }
+ events = r3.cardEvents(c.ID)
+ if last := events[len(events)-1]; last.State != wire.CardAnswered || last.Taste != nil {
+ t.Fatalf("the answer's event: %+v", last)
+ }
+}
+
// TestAddCardWithAnswers: Add with two feels and a box writes three notes
// in its transaction, records the ask answered, and queues the
// continuation with its usual binding: another project, a second task
diff --git a/internal/equipo/static/chat-stream.js b/internal/equipo/static/chat-stream.js
index 5c857890..9140a3d5 100644
--- a/internal/equipo/static/chat-stream.js
+++ b/internal/equipo/static/chat-stream.js
@@ -852,7 +852,9 @@
var report = card.querySelector("[data-report-thread]"); if (report) reportOpen.set(card.dataset.card, report.open);
var inputs = {};
card.querySelectorAll("textarea, input:not([type=hidden])").forEach(function (el) { if (el.type === "checkbox") { if (el.checked) inputs[draftKey(el) + "\n" + el.value] = "on"; return; } if (el.value) inputs[draftKey(el)] = el.value; });
- if (Object.keys(inputs).length) cardDrafts.set(card.dataset.card, inputs);
+ // This snapshot replaces the last: a field the person emptied, or
+ // a feel they unticked, since an earlier refresh stays so.
+ if (Object.keys(inputs).length) cardDrafts.set(card.dataset.card, inputs); else cardDrafts.delete(card.dataset.card);
});
next.querySelectorAll("[data-card]").forEach(function (card) {
var old = cardBusy.get(card.dataset.card); if (old) { card.replaceWith(old); return; }
diff --git a/internal/equipo/taste_card_browser_test.go b/internal/equipo/taste_card_browser_test.go
new file mode 100644
index 00000000..7123aac9
--- /dev/null
+++ b/internal/equipo/taste_card_browser_test.go
@@ -0,0 +1,119 @@
+//go:build browser
+
+package equipo
+
+import (
+ "bytes"
+ "context"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "sync/atomic"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/wire"
+ "amadan.net/rastrillo/rastrillo/harness"
+ "github.com/chromedp/chromedp"
+)
+
+// TestBrowserTasteCardDrafts (Task 10 review, fix round 1): a
+// conversation refresh keeps the feels the person ticked on the taste
+// card, and what they typed in another card's field; once they untick
+// the feel and clear the field, the next refresh keeps that too, never
+// bringing back the choice they removed.
+func TestBrowserTasteCardDrafts(t *testing.T) {
+ var card bytes.Buffer
+ c := wire.Card{ID: "c1", Kind: wire.CardDesignTaste, State: wire.CardOpen, Revision: 1, Question: copyText("chat.card.taste_title"), Taste: &wire.CardTaste{Feels: []string{"Calm", "Bold"}}}
+ if err := pages["chat"].ExecuteTemplate(&card, "chat-card", cardView(c, nil, nil)); err != nil {
+ t.Fatal(err)
+ }
+ var cursor atomic.Int64
+ cursor.Store(1)
+ page := func() string {
+ return fmt.Sprintf(`<!doctype html><html lang="en"><head><meta charset="utf-8"><link rel="stylesheet" href="%s"><link rel="stylesheet" href="%s"><link rel="stylesheet" href="%s">`+
+ `<script>window.errors = []; addEventListener("error", e => errors.push(String(e.message)));</script><script defer src="%s"></script><script defer src="%s"></script></head><body>`+
+ `<div equipo-conversation data-chat-stream data-cursor="%d" data-card-busy="Busy"><div equipo-scroll><ol equipo-feed>%s<li data-card="c2"><form action="/elsewhere"><textarea name="note"></textarea></form></li></ol></div><form id="composer"><div id="chat-composer"></div><textarea name="text"></textarea></form></div></body></html>`,
+ assets.Path("static/tokens.css"), assets.Path("static/theme.css"), assets.Path("static/equipo.css"), assets.Path("static/stardust.js"), assets.Path("static/chat-stream.js"), cursor.Load(), card.String())
+ }
+ trigger := make(chan struct{}, 1)
+ mux := http.NewServeMux()
+ mux.Handle("GET /static/", assets.Handler())
+ mux.HandleFunc("GET /conversation", func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "text/html; charset=utf-8")
+ fmt.Fprint(w, page())
+ })
+ mux.HandleFunc("GET /api/v1/events", func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "text/event-stream")
+ w.WriteHeader(http.StatusOK)
+ w.(http.Flusher).Flush()
+ for {
+ select {
+ case <-trigger:
+ fmt.Fprintf(w, "event: card\ndata: {\"cursor\":%d,\"data\":{}}\n\n", cursor.Add(1))
+ w.(http.Flusher).Flush()
+ case <-r.Context().Done():
+ return
+ }
+ }
+ })
+ server := httptest.NewServer(mux) // 127.0.0.1
+ defer server.Close()
+
+ opts := append(chromedp.DefaultExecAllocatorOptions[:], chromedp.ExecPath(harness.ChromePath(t)), chromedp.NoSandbox, chromedp.UserDataDir(t.TempDir()))
+ alloc, stop := chromedp.NewExecAllocator(context.Background(), opts...)
+ defer stop()
+ ctx, cancel := chromedp.NewContext(alloc)
+ defer cancel()
+ ctx, timeout := context.WithTimeout(ctx, 60*time.Second)
+ defer timeout()
+ run := func(a chromedp.Action[chromedp.Void]) {
+ t.Helper()
+ if _, err := chromedp.Run(ctx, a); err != nil {
+ t.Fatal(err)
+ }
+ }
+ eval := func(js string) string {
+ t.Helper()
+ out, err := chromedp.Run(ctx, chromedp.Evaluate[string](js, chromedp.EvalAwaitPromise))
+ if err != nil {
+ t.Fatal(err)
+ }
+ return out
+ }
+ refresh := func() {
+ t.Helper()
+ eval(`(document.querySelector('[data-card="c1"]').dataset.old = "1", document.querySelector('[data-card="c2"]').dataset.old = "1", "")`)
+ trigger <- struct{}{}
+ if got := eval(`new Promise(r => { const t0 = Date.now(); (function wait() { const c = document.querySelector('[data-card="c1"]'), d = document.querySelector('[data-card="c2"]'); if (c && !c.dataset.old && d && !d.dataset.old) return r("ok"); if (Date.now() - t0 > 5000) return r("no refresh"); setTimeout(wait, 50); })(); })`); got != "ok" {
+ t.Fatal(got)
+ }
+ }
+ feel := func(label string) string {
+ return `document.querySelector('[data-card="c1"] form[data-draft-key="taste"] input[name=feel][value="` + label + `"]')`
+ }
+ state := func() string {
+ return eval(`[` + feel("Calm") + `.checked, ` + feel("Bold") + `.checked, document.querySelector('[data-card="c2"] textarea').value].join(" ")`)
+ }
+ run(chromedp.Navigate(server.URL + "/conversation"))
+ if got := eval(`new Promise(r => setTimeout(() => r(document.querySelector("[data-roster-enhanced]") ? errors.join(";") : "not enhanced " + errors.join(";")), 300))`); got != "" {
+ t.Fatalf("chat-stream.js did not start: %s", got)
+ }
+ // Check, and type in another card's keyless field: a refresh keeps both.
+ eval(`(` + feel("Calm") + `.click(), document.querySelector('[data-card="c2"] textarea').focus(), "")`)
+ run(chromedp.KeyEvent("plain draft"))
+ eval(`(document.activeElement.blur(), "")`)
+ refresh()
+ if got := state(); got != "true false plain draft" {
+ t.Fatalf("after the first refresh: %q", got)
+ }
+ // Uncheck, and clear the field: the next refresh brings neither back.
+ eval(`(` + feel("Calm") + `.click(), document.querySelector('[data-card="c2"] textarea').value = "", "")`)
+ refresh()
+ if got := state(); got != "false false " {
+ t.Fatalf("after unticking and clearing: %q", got)
+ }
+ if got := eval(`errors.join(";")`); got != "" {
+ t.Errorf("script errors: %s", got)
+ }
+}
diff --git a/internal/runner/thin/claude.go b/internal/runner/thin/claude.go
index b8b7e552..d41ac43f 100644
--- a/internal/runner/thin/claude.go
+++ b/internal/runner/thin/claude.go
@@ -712,7 +712,7 @@ func (c *claudeCoordinator) idleExit() {
// houseRule versions the opening's rule. Changing the rule's text changes
// it, so sessions started under an older rule are not resumed.
-const houseRule = "2026-12-01.1"
+const houseRule = "2026-12-01.2"
// sessionAccount records the account and the lane's rule a session runs
// on.
@@ -866,7 +866,7 @@ func opening(person string, catalog []wire.RepoInfo) string {
b.WriteString(accessPrompt + "Use the named project or the clear continuation. If placement is ambiguous, ask_person with structured placement choices, best guess first. Always confirm a new repository unless the person directly requested one in the main composer this turn. Hand-offs, nudges, quotes and ordinary card answers cannot grant creation. One turn permits one creation; placement-card labels name the repository and come from the server. Wait for the answer before recording or starting work. Learn from project corrections in your notebook. Call status to see reachable repositories and create_in namespaces.\n")
b.WriteString("For settled placement, call add_project for existing work or create_project for explicitly requested or confirmed new work. Choose the related namespace, otherwise home from status. Change home only when asked. Never fall back silently to a different project after a refusal.\n")
b.WriteString("Once placement is settled for a bug or change, call record_task before investigating, with the repository it belongs to, a short title and their words as the brief. Then investigate with search_code and read_file, attach what you found with add_finding (a one-sentence headline for the person, plain words and no file paths, and the full finding with its file and line), and call start_task with a brief for Engineering. Engineering changes the code on the task's own branch and pushes it to Amadan; the change is then checked and reviewed, and Equipo's merge rules decide whether it merges on its own or asks the person with a card that gives Equipo's call. You cannot make it merge: when you have a concrete reason a change needs the person's look, call hold_merge with that reason. When the person says how a project should merge (\"always ask me about Suite\", \"main is not a release for Woodstar\"), call set_merge_policy with their words; a stricter rule applies at once and a looser one waits for their tap. Never offer to merge or open a pull request, and never ask the person to merge. The one exception: when a merge failed and the task waits at Ready to merge, offer_retry puts a card in front of the person to try it again, and only their tap merges. Use ask_person only for a question only the person can answer. Mockups, prototypes, design options and spikes are explorations: record them with kind explore; they end at a preview and the person's choice of direction, never a merge. A website meant to go live is a change, not an exploration: ask Engineering for plain HTML and CSS files with no build step, kept in one folder that release/preview.json names. Once it is merged its person is asked whether to publish it. To publish a merged website when asked (also one merged before and never offered), call publish_site with its task: a card names where it goes, and only the person's tap publishes; with no confirmed place it asks where first. places and site_status say where sites go and what Equipo recorded; never look for a site anywhere else, and never say it is live until the task shows its address.\n")
- b.WriteString("Visual design, layout, themes and mockups go to Design: status lists the team's active specialists, and start_task with \"specialist\": its id hands the task to the one for the task's project (or the team's). With no Design specialist active for it, call propose_specialist with profile design-v1 (project: the task's project) and say in one line why; only an owner's tap adds it, and Equipo then carries on with the request. Before starting Design on a project, call status: when it shows no taste for the person there (taste notes 0, asked none) and the request names no style, mood or reference, ask first, once (on the Add card, with propose_specialist's feels, when Design is new for it; else with ask_design_taste), and start Design when they answer; otherwise start at once. After they tap Skip, start Design and say in one line that Design will use its own judgement.\n")
+ b.WriteString("Visual design, layout, themes and mockups go to Design: status lists the team's active specialists, and start_task with \"specialist\": its id hands the task to the one for the task's project (or the team's). With no Design specialist active for it, call propose_specialist with profile design-v1 (project: the task's project) and say in one line why; only an owner's tap adds it, and Equipo then carries on with the request. Before starting Design on a project, call status. When its taste for the person there says asked open, the questions are still on their screen: do not start Design and do not ask again; wait for their answer, which comes back as their next message. When it shows no taste (taste notes 0, asked none) and the request names no style, mood or reference, ask first, once (on the Add card, with propose_specialist's feels, when Design is new for it; else with ask_design_taste), and start Design when they answer; otherwise start at once. After they tap Skip, start Design and say in one line that Design will use its own judgement.\n")
b.WriteString("Never file the same problem twice. If record_task returns similar open tasks and one of them is what the person is reporting, call add_report on it with their words and tell them in one line it is already logged and where it stands, naming it as a markdown link; record a separate task only when it is clearly a different problem.\n")
b.WriteString("Speak at the outcome level: what you understood, what is happening, what you need from the person. For example: \"Got it, I've logged [Swipe back doesn't work](/tasks/tk...) and Engineering is on it.\" No file paths, line numbers or code mechanics in your replies; the diagnosis goes on the task with add_finding. Always name a task as a markdown link with its title and the link from record_task, start_task or read_task, never as \"the task card\".\n")
b.WriteString("Anything the person may need to paste (commands, prompts, config, codes) goes in a fenced code block, one block per thing to paste, with its kind after the opening fence (bash for a command, prompt for a prompt, text for plain text): the chat shows each block with a Copy button.\n")
diff --git a/internal/runner/thin/taste_ask_test.go b/internal/runner/thin/taste_ask_test.go
index f75b6afd..5b0b9086 100644
--- a/internal/runner/thin/taste_ask_test.go
+++ b/internal/runner/thin/taste_ask_test.go
@@ -131,7 +131,13 @@ func TestHouseRuleAsksTaste(t *testing.T) {
t.Fatalf("the opening lacks %q", want)
}
}
- if houseRule == "2026-11-29.1" {
+ // Review fix 1: an open ask (asked open) is waited for, never "start
+ // at once"; that branch comes before the start.
+ wait := strings.Index(o, "asked open, the questions are still on their screen: do not start Design and do not ask again; wait for their answer")
+ if wait < 0 || wait > strings.Index(o, "otherwise start at once") {
+ t.Fatalf("the opening does not wait on an open ask first:\n%s", o)
+ }
+ if houseRule == "2026-11-29.1" || houseRule == "2026-12-01.1" {
t.Fatal("the opening's rule changed without a new house rule")
}
}