oficina / equipo Public

chat: taste notebook with add and forget on Design's page

Task 8 of the Design feedback 1 plan (spec 2 and 8.6).

- chat_taste_notes and chat_taste_books (revision, forget_revision),
  appended to migration 0125, schema.sql and chat Models. Notes are
  personal records: every read and write filters by the verified
  person; only an active member (roster read in the same transaction)
  reads or writes, else ErrForbidden.
- txn.writeTaste(person, project, source, body, question, task, card)
  for Task 7: words or choice, body trimmed, valid UTF-8, no NUL, 1 to
  300 characters, question at most 300, project "" or an existing one.
  Bumps revision; audits taste.write "<id> <source>".
- Store.Taste (wire.TasteNote, newest first, revision), TasteBook (page
  view with project names), AddTaste (taste.add), ForgetTaste (hard
  delete, bumps revision and forget revision, taste.forget "<id>
  <source>"; another persons note is ErrNotFound), ForgetAllTaste
  (taste.forget_all "<count>"). Audits never carry the text.
- Design's page (/team/{id}, active design-v1 only) leads with "Design
  knows N things about your taste" (singular, empty state), lists the
  viewer's notes (words, source, date, scope) with Forget, Forget
  everything behind a details confirm step, and an Add a note form
  (maxlength 300, scope This project or All projects; the project comes
  from the specialist, never the form). Routes POST
  /team/{id}/taste, /taste/forget, /taste/{note}/forget through
  chatActionTo (session person, same-origin protection).
- 17 copy keys team.taste.*, marked pending; equipo.css token rules.

TDD evidence
Command: go test ./internal/equipo/... -run
 TestTaste|TestForget|TestAddTaste|TestRemovedMemberTaste|TestWriteTaste
First run: build failed (undefined tasteBookRecord, TasteDesign,
AddTaste, Taste, ...); after the store, the page tests failed on the
missing section; now all pass.

Mutations (each broke, test failed, restored):
- read: drop person filter: caught by TestForgetDeletesAndAudits, TestTasteOnlyOwnerReads
- forget: drop person filter (lookup and delete): caught by TestForgetDeletesAndAudits
- forget all: drop person filter: caught by TestForgetDeletesAndAudits
- addTaste: no roster check: caught by TestRemovedMemberTasteUnused
- read: no roster check: caught by TestRemovedMemberTasteUnused
- tasteMember: inactive allowed: caught by TestRemovedMemberTasteUnused
- bound 300 -> 301: caught by TestAddTasteBounds, TestWriteTasteChoice
- bound counts bytes: caught by TestAddTasteBounds
- no NUL check: caught by TestAddTasteBounds
- no UTF-8 check: caught by TestAddTasteBounds
- empty allowed: caught by TestAddTasteBounds
- no trim: caught by TestAddTasteBounds
- project existence unchecked: caught by TestAddTasteBounds
- source unchecked: caught by TestWriteTasteChoice
- question unbounded: caught by TestWriteTasteChoice
- audit add carries the text: caught by TestAddTasteBounds
- audit forget dropped: caught by TestForgetDeletesAndAudits
- forget does not bump forget revision: caught by TestForgetDeletesAndAudits
- forget all: no bump: caught by TestForgetDeletesAndAudits
- write: no revision bump: caught by TestAddTasteBounds, TestWriteTasteChoice, TestForgetDeletesAndAudits
- page: revoked Design still takes notes: caught by TestTasteFormsRefused
- handler: project scope on a team-wide Design: caught by TestTasteFormsRefused
- handler: unknown scope means all: caught by TestTasteFormsRefused
- headline: no singular: caught by TestTastePageCount
- headline: no empty state: caught by TestTastePageCount, TestTasteOnlyOwnerSees
- template: no Forget everything confirm step: caught by TestTastePageCount
- template: project option offered on a team-wide Design: caught by TestTasteFormsRefused
- page: taste section on any specialist: caught by TestTasteFormsRefused
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev c6cc2a0ed6863c1c7516819439ce1fbb8346cb58 parent 802eed6
11 files changed, +978 −1
  • internal/equipo/app.go +3 −0
  • internal/equipo/chat/models.go +1 −1
  • internal/equipo/chat/taste.go +294 −0
  • internal/equipo/chat/taste_test.go +229 −0
  • internal/equipo/copy.go +20 −0
  • internal/equipo/migrations/0125_design_feedback.sql +10 −0
  • internal/equipo/migrations/schema.sql +10 −0
  • internal/equipo/static/equipo.css +9 −0
  • internal/equipo/team_panel.go +145 −0
  • internal/equipo/team_taste_test.go +247 −0
  • internal/equipo/templates/team.html +10 −0
diff --git a/internal/equipo/app.go b/internal/equipo/app.go
index 3910ebc3..2cd14acb 100644
--- a/internal/equipo/app.go
+++ b/internal/equipo/app.go
@@ -468,6 +468,9 @@ func RouterWithStore(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logg
r.Get("/work", a.index)
r.Get("/nav/rail", a.railFragment)
r.Get("/team/{specialist}", a.teamPage)
+ r.Post("/team/{specialist}/taste", a.addTaste)
+ r.Post("/team/{specialist}/taste/forget", a.forgetAllTaste)
+ r.Post("/team/{specialist}/taste/{note}/forget", a.forgetTaste)
for _, path := range []string{"/needs-you", "/journey", "/connections"} {
r.Get(path, a.taskList)
}
diff --git a/internal/equipo/chat/models.go b/internal/equipo/chat/models.go
index 5694bdd2..ecd224a0 100644
--- a/internal/equipo/chat/models.go
+++ b/internal/equipo/chat/models.go
@@ -11,7 +11,7 @@ import (
)
// Models are the tables this package owns, for the migration check.
-var Models = append([]any{&changeDiffRecord{}, &notificationReceipt{}, &projectNameRecord{}, &cardVisibility{}, &cardThreadRecord{}, &copyAttemptRecord{}, &copyReviewRecord{}, &copyFeedbackRecord{}, &turnRecord{}, &messageRecord{}, &eventRecord{}, &commandRecord{}, &inboxRecord{}, &runnerSessionRecord{}, &projectRecord{}, &cardRecord{}, &toolCallRecord{}, &settingRecord{}, &coordinatorRecord{}, &notebookRecord{}, &taskRecord{}, &stepRecord{}, &entryRecord{}, &attachmentRecord{}, &starRecord{}, &questionRecord{}, &connectionRecord{}, &usageRecord{}, &distinctRecord{}, &hkRecord{}, &hkFailureRecord{}, &hkSettingsRecord{}, &fileRecord{}, &fileDataRecord{}, &transferRecord{}, &mergePolicyRecord{}, &mergeAuditRecord{}, &specialistRecord{}, &grantRecord{}, &specialistAuditRecord{}, &researchSourceRecord{}, &researchAddressRecord{}, &researchPrefixRecord{}, &researchInventoryRecord{}, &instancePrefixRecord{}, &instanceAddressRecord{}, &instanceInventoryCardRecord{}, &webSearchUsageRecord{}, &lookupRecord{}, &researchRecord{}, &researchFetchRecord{}, &taskFileRecord{}, &taskFileDataRecord{}, &stepRenderRecord{}, &releaseRecord{}, &adviceRecord{}, &assistantHostRecord{}, &abilitiesRecord{}, &handoffRecord{}, &handoffTurnRecord{}, &handoffTaskRecord{}, &handoffActionRecord{}, &connectTurnRecord{}, &specialistTurnRecord{}, &carriedRecord{}, &zoneRecord{}, &placeRecord{}, &projectPlaceRecord{}}, push.Models...)
+var Models = append([]any{&changeDiffRecord{}, &notificationReceipt{}, &projectNameRecord{}, &cardVisibility{}, &cardThreadRecord{}, &copyAttemptRecord{}, &copyReviewRecord{}, &copyFeedbackRecord{}, &turnRecord{}, &messageRecord{}, &eventRecord{}, &commandRecord{}, &inboxRecord{}, &runnerSessionRecord{}, &projectRecord{}, &cardRecord{}, &toolCallRecord{}, &settingRecord{}, &coordinatorRecord{}, &notebookRecord{}, &taskRecord{}, &stepRecord{}, &entryRecord{}, &attachmentRecord{}, &starRecord{}, &questionRecord{}, &connectionRecord{}, &usageRecord{}, &distinctRecord{}, &hkRecord{}, &hkFailureRecord{}, &hkSettingsRecord{}, &fileRecord{}, &fileDataRecord{}, &transferRecord{}, &mergePolicyRecord{}, &mergeAuditRecord{}, &specialistRecord{}, &grantRecord{}, &specialistAuditRecord{}, &researchSourceRecord{}, &researchAddressRecord{}, &researchPrefixRecord{}, &researchInventoryRecord{}, &instancePrefixRecord{}, &instanceAddressRecord{}, &instanceInventoryCardRecord{}, &webSearchUsageRecord{}, &lookupRecord{}, &researchRecord{}, &researchFetchRecord{}, &taskFileRecord{}, &taskFileDataRecord{}, &stepRenderRecord{}, &releaseRecord{}, &adviceRecord{}, &assistantHostRecord{}, &abilitiesRecord{}, &handoffRecord{}, &handoffTurnRecord{}, &handoffTaskRecord{}, &handoffActionRecord{}, &connectTurnRecord{}, &specialistTurnRecord{}, &carriedRecord{}, &zoneRecord{}, &placeRecord{}, &projectPlaceRecord{}, &tasteNoteRecord{}, &tasteBookRecord{}}, push.Models...)
type turnRecord struct {
CreateRepo string
diff --git a/internal/equipo/chat/taste.go b/internal/equipo/chat/taste.go
new file mode 100644
index 00000000..9c2390b7
--- /dev/null
+++ b/internal/equipo/chat/taste.go
@@ -0,0 +1,294 @@
+package chat
+
+import (
+ "context"
+ "strconv"
+ "strings"
+ "time"
+ "unicode/utf8"
+
+ "amadan.net/oficina/equipo/internal/wire"
+ "gorm.io/gorm"
+)
+
+// The taste notebook (spec 2026-11-28-dynamic-specialists.md, sections 2
+// and 8.6): each person's notes on their taste, per discipline. Notes are
+// the person's own records, not shared team records: every read and
+// write names the verified person, only that person ever sees them, and
+// only an active member reads or writes them (the roster is checked in
+// the same transaction). Each write, add and forget bumps the notebook's
+// revision, a forget also its forget revision, and appends an audit row
+// with the note id and its source kind (or a count), never the text.
+
+// TasteDesign is the design notebook's discipline (Design and Design
+// review share it).
+const TasteDesign = "design"
+
+// tasteNoteRecord is one note: Person's, in Discipline, for ProjectID
+// ("" all of the person's projects). Source is wire.TasteSourceWords
+// (Body is the person's own text) or wire.TasteSourceChoice (Body the
+// label they chose, Question the words they chose it under, "" none).
+// TaskID and CardID are where a choice was made ("" none).
+type tasteNoteRecord struct {
+ ID string `gorm:"primaryKey"`
+ Person string `gorm:"index:chat_taste_note_person,priority:1"`
+ Discipline string `gorm:"index:chat_taste_note_person,priority:2"`
+ ProjectID string `gorm:"not null;default:''"`
+ Source string
+ Body string
+ Question string `gorm:"not null;default:''"`
+ TaskID string `gorm:"not null;default:''"`
+ CardID string `gorm:"not null;default:''"`
+ CreatedAt time.Time
+}
+
+func (tasteNoteRecord) TableName() string { return "chat_taste_notes" }
+
+// tasteBookRecord is a person's notebook in one discipline: Revision
+// moves on every write and forget, ForgetRevision on every forget.
+type tasteBookRecord struct {
+ Person string `gorm:"primaryKey"`
+ Discipline string `gorm:"primaryKey"`
+ Revision int64 `gorm:"not null;default:0"`
+ ForgetRevision int64 `gorm:"not null;default:0"`
+}
+
+func (tasteBookRecord) TableName() string { return "chat_taste_books" }
+
+// tasteText is s trimmed when it is valid UTF-8 without NUL and at most
+// wire.MaxTasteBox characters; ok is false otherwise.
+func tasteText(s string) (string, bool) {
+ s = strings.TrimSpace(s)
+ return s, utf8.ValidString(s) && !strings.ContainsRune(s, 0) && utf8.RuneCountInString(s) <= wire.MaxTasteBox
+}
+
+// tasteMember refuses a person who is not an active member now.
+func (t *txn) tasteMember(person string) error {
+ ok, err := t.activeMember(person)
+ if err != nil {
+ return err
+ }
+ if !ok {
+ return ErrForbidden
+ }
+ return nil
+}
+
+// addTaste checks and stores one design note of person's and bumps the
+// notebook's revision; it returns the note's id. The caller audits.
+func (t *txn) addTaste(person, project, source, body, question, task, card string) (string, error) {
+ if err := t.tasteMember(person); err != nil {
+ return "", err
+ }
+ if source != wire.TasteSourceWords && source != wire.TasteSourceChoice {
+ return "", ErrInvalid
+ }
+ body, ok := tasteText(body)
+ if !ok || body == "" {
+ return "", ErrInvalid
+ }
+ question, ok = tasteText(question)
+ if !ok {
+ return "", ErrInvalid
+ }
+ if project != "" {
+ var n int64
+ if err := t.db.Model(&projectRecord{}).Where("id = ?", project).Count(&n).Error; err != nil {
+ return "", err
+ }
+ if n == 0 {
+ return "", ErrInvalid
+ }
+ }
+ n := tasteNoteRecord{ID: newID("tn_"), Person: person, Discipline: TasteDesign, ProjectID: project, Source: source, Body: body, Question: question, TaskID: task, CardID: card, CreatedAt: t.now()}
+ if err := t.db.Create(&n).Error; err != nil {
+ return "", err
+ }
+ return n.ID, t.bumpTaste(person, false)
+}
+
+// bumpTaste moves the person's design notebook revision, and its forget
+// revision too for a forget.
+func (t *txn) bumpTaste(person string, forget bool) error {
+ f := 0
+ if forget {
+ f = 1
+ }
+ return t.db.Exec("INSERT INTO chat_taste_books(person, discipline, revision, forget_revision) VALUES (?, ?, 1, ?) ON CONFLICT(person, discipline) DO UPDATE SET revision = revision + 1, forget_revision = forget_revision + excluded.forget_revision", person, TasteDesign, f).Error
+}
+
+// writeTaste keeps one design note of person's from their own signal (a
+// card answer in their transaction): source wire.TasteSourceWords with
+// their text, or wire.TasteSourceChoice with the label they chose and
+// the question it answered. It bumps the revision and audits taste.write
+// with the note id and source only.
+func (t *txn) writeTaste(person, project, source, body, question, task, card string) error {
+ id, err := t.addTaste(person, project, source, body, question, task, card)
+ if err != nil {
+ return err
+ }
+ return t.audit(person, "taste.write", id+" "+source)
+}
+
+// TasteEntry is one of a person's design notes as their own page shows
+// it: ProjectName is the project's shown title ("" for a team-wide note,
+// or a project no longer found).
+type TasteEntry struct {
+ ID, Source, Body, Question, ProjectID, ProjectName string
+ CreatedAt time.Time
+}
+
+// TasteNotebook is a person's own design notes as their page shows
+// them: Notes newest first, Revision the notebook's (0 before any
+// write), and ProjectName the shown title of the project the page asked
+// about ("" none, or not found).
+type TasteNotebook struct {
+ Notes []TasteEntry
+ Revision int64
+ ProjectName string
+}
+
+// TasteBook reads the person's own design notebook, and the name of
+// project for the page's "This project". Only an active member reads.
+func (s *Store) TasteBook(ctx context.Context, person, project string) (TasteNotebook, error) {
+ var out TasteNotebook
+ err := s.read(ctx, func(tx *gorm.DB) error {
+ if err := s.authority.CurrentPerson(ctx, tx); err != nil {
+ return err
+ }
+ t := &txn{s: s, ctx: ctx, db: tx}
+ if err := t.tasteMember(person); err != nil {
+ return err
+ }
+ var rows []tasteNoteRecord
+ if err := tx.Where("person = ? AND discipline = ?", person, TasteDesign).Order("created_at DESC, rowid DESC").Find(&rows).Error; err != nil {
+ return err
+ }
+ names := map[string]string{"": ""}
+ name := func(id string) (string, error) {
+ if n, seen := names[id]; seen {
+ return n, nil
+ }
+ var ps []projectRecord
+ if err := tx.Where("id = ?", id).Limit(1).Find(&ps).Error; err != nil {
+ return "", err
+ }
+ names[id] = ""
+ if len(ps) == 1 {
+ names[id] = ps[0].shownTitle()
+ }
+ return names[id], nil
+ }
+ out.Notes = make([]TasteEntry, 0, len(rows))
+ for _, n := range rows {
+ pn, err := name(n.ProjectID)
+ if err != nil {
+ return err
+ }
+ out.Notes = append(out.Notes, TasteEntry{ID: n.ID, Source: n.Source, Body: n.Body, Question: n.Question, ProjectID: n.ProjectID, ProjectName: pn, CreatedAt: n.CreatedAt})
+ }
+ var err error
+ if out.ProjectName, err = name(project); err != nil {
+ return err
+ }
+ var books []tasteBookRecord
+ if err := tx.Where("person = ? AND discipline = ?", person, TasteDesign).Limit(1).Find(&books).Error; err != nil {
+ return err
+ }
+ if len(books) == 1 {
+ out.Revision = books[0].Revision
+ }
+ return nil
+ })
+ if err != nil {
+ return TasteNotebook{}, err
+ }
+ return out, nil
+}
+
+// Taste is the person's own design notes, newest first, as a Design
+// dispatch carries them, and the notebook's revision.
+func (s *Store) Taste(ctx context.Context, person string) ([]wire.TasteNote, int64, error) {
+ book, err := s.TasteBook(ctx, person, "")
+ if err != nil {
+ return nil, 0, err
+ }
+ out := make([]wire.TasteNote, 0, len(book.Notes))
+ for _, e := range book.Notes {
+ scope := wire.TasteScopeTeam
+ if e.ProjectID != "" {
+ scope = wire.TasteScopeProject
+ }
+ out = append(out, wire.TasteNote{ID: e.ID, Source: e.Source, Scope: scope, Body: e.Body, Question: e.Question, Date: e.CreatedAt.UTC().Format("2006-01-02")})
+ }
+ return out, book.Revision, nil
+}
+
+// AddTaste keeps a note the person typed on Design's page: their own
+// words, for project ("" all their projects). Audited as taste.add.
+func (s *Store) AddTaste(ctx context.Context, person, project, text string) error {
+ return s.tx(ctx, func(t *txn) error {
+ if err := s.authority.CurrentPerson(ctx, t.db); err != nil {
+ return err
+ }
+ id, err := t.addTaste(person, project, wire.TasteSourceWords, text, "", "", "")
+ if err != nil {
+ return err
+ }
+ return t.audit(person, "taste.add", id+" "+wire.TasteSourceWords)
+ })
+}
+
+// ForgetTaste deletes one of the person's own design notes: another
+// person's, or one already gone, is ErrNotFound.
+func (s *Store) ForgetTaste(ctx context.Context, person, id string) error {
+ return s.tx(ctx, func(t *txn) error {
+ if err := s.authority.CurrentPerson(ctx, t.db); err != nil {
+ return err
+ }
+ if err := t.tasteMember(person); err != nil {
+ return err
+ }
+ var rows []tasteNoteRecord
+ if err := t.db.Where("id = ? AND person = ? AND discipline = ?", id, person, TasteDesign).Limit(1).Find(&rows).Error; err != nil {
+ return err
+ }
+ if len(rows) == 0 {
+ return ErrNotFound
+ }
+ del := t.db.Where("id = ? AND person = ?", id, person).Delete(&tasteNoteRecord{})
+ if del.Error != nil {
+ return del.Error
+ }
+ if del.RowsAffected != 1 {
+ return ErrNotFound
+ }
+ if err := t.bumpTaste(person, true); err != nil {
+ return err
+ }
+ return t.audit(person, "taste.forget", id+" "+rows[0].Source)
+ })
+}
+
+// ForgetAllTaste deletes every one of the person's design notes (Forget
+// everything), audited as taste.forget_all with the count.
+func (s *Store) ForgetAllTaste(ctx context.Context, person string) error {
+ return s.tx(ctx, func(t *txn) error {
+ if err := s.authority.CurrentPerson(ctx, t.db); err != nil {
+ return err
+ }
+ if err := t.tasteMember(person); err != nil {
+ return err
+ }
+ del := t.db.Where("person = ? AND discipline = ?", person, TasteDesign).Delete(&tasteNoteRecord{})
+ if del.Error != nil {
+ return del.Error
+ }
+ if del.RowsAffected > 0 {
+ if err := t.bumpTaste(person, true); err != nil {
+ return err
+ }
+ }
+ return t.audit(person, "taste.forget_all", strconv.FormatInt(del.RowsAffected, 10))
+ })
+}
diff --git a/internal/equipo/chat/taste_test.go b/internal/equipo/chat/taste_test.go
new file mode 100644
index 00000000..5fbfae13
--- /dev/null
+++ b/internal/equipo/chat/taste_test.go
@@ -0,0 +1,229 @@
+package chat
+
+import (
+ "errors"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/wire"
+ "gorm.io/gorm"
+)
+
+// Design feedback 1, Task 8 (spec 2026-11-28-dynamic-specialists.md,
+// sections 2 and 8.6): each person's design notebook. Notes are the
+// person's own records, never a shared team record: every read and write
+// names the verified person, and only an active member writes or reads.
+// Each write, add and forget bumps the notebook's revision (a forget also
+// its forget revision) and appends an audit row with the note id and
+// source kind, never the text.
+
+type tasteAudit struct{ actor, kind, record string }
+
+// tasteRig is an hkRig with a project and its audit rows kept.
+func tasteRig(t *testing.T) (*hkRig, *[]tasteAudit) {
+ r := newHKRig(t)
+ r.exec("INSERT INTO chat_projects(id, repo, state, title, title_set) VALUES ('p_site', 'oficina/site', 'active', 'Site', 1)")
+ var audits []tasteAudit
+ r.s.authority.Audit = func(_ *gorm.DB, actor, kind, record string) error {
+ audits = append(audits, tasteAudit{actor, kind, record})
+ return nil
+ }
+ return r, &audits
+}
+
+// book is the person's design notebook revisions (-1, -1: no row).
+func (r *hkRig) book(person string) (rev, forget int64) {
+ r.t.Helper()
+ var b tasteBookRecord
+ err := r.s.db.G.Where("person = ? AND discipline = ?", person, TasteDesign).First(&b).Error
+ if errors.Is(err, gorm.ErrRecordNotFound) {
+ return -1, -1
+ }
+ r.must(err)
+ return b.Revision, b.ForgetRevision
+}
+
+func (r *hkRig) tasteRows(person string) []tasteNoteRecord {
+ r.t.Helper()
+ var rows []tasteNoteRecord
+ r.must(r.s.db.G.Where("person = ?", person).Order("created_at, rowid").Find(&rows).Error)
+ return rows
+}
+
+// TestAddTasteBounds: a words note is the person's text, trimmed, valid
+// UTF-8 with no NUL, 1 to 300 characters; a project note names a project
+// that exists. Anything else is ErrInvalid and writes nothing.
+func TestAddTasteBounds(t *testing.T) {
+ r, audits := tasteRig(t)
+ for name, text := range map[string]string{
+ "301": strings.Repeat("a", 301),
+ "301 é": strings.Repeat("é", 301),
+ "empty": "",
+ "spaces": " \n\t ",
+ "nul": "warm\x00paper",
+ "invalid": "warm \xff paper",
+ } {
+ if err := r.s.AddTaste(r.ctx, hkOwner, "", text); !errors.Is(err, ErrInvalid) {
+ t.Fatalf("%s: %v", name, err)
+ }
+ }
+ if err := r.s.AddTaste(r.ctx, hkOwner, "p_nowhere", "Quiet."); !errors.Is(err, ErrInvalid) {
+ t.Fatalf("unknown project: %v", err)
+ }
+ if n := len(r.tasteRows(hkOwner)); n != 0 || len(*audits) != 0 {
+ t.Fatalf("refusals wrote %d notes, %d audits", n, len(*audits))
+ }
+ if rev, _ := r.book(hkOwner); rev != -1 {
+ t.Fatalf("refusals moved the revision to %d", rev)
+ }
+
+ r.must(r.s.AddTaste(r.ctx, hkOwner, "", strings.Repeat("é", 300)))
+ r.must(r.s.AddTaste(r.ctx, hkOwner, "p_site", " No gradients, ever. "))
+ rows := r.tasteRows(hkOwner)
+ if len(rows) != 2 || rows[1].Body != "No gradients, ever." || rows[1].ProjectID != "p_site" || rows[1].Source != wire.TasteSourceWords || rows[1].Discipline != TasteDesign || rows[0].ProjectID != "" {
+ t.Fatalf("rows %+v", rows)
+ }
+ if rev, forget := r.book(hkOwner); rev != 2 || forget != 0 {
+ t.Fatalf("revision %d, forget %d after two adds", rev, forget)
+ }
+ notes, rev, err := r.s.Taste(r.ctx, hkOwner)
+ r.must(err)
+ if rev != 2 || len(notes) != 2 || notes[0].Body != "No gradients, ever." || notes[0].Scope != wire.TasteScopeProject || notes[1].Scope != wire.TasteScopeTeam || notes[0].Source != wire.TasteSourceWords || notes[0].Date != r.now.Format("2006-01-02") {
+ t.Fatalf("notes %+v at %d", notes, rev)
+ }
+ for _, a := range *audits {
+ if a.kind != "taste.add" || a.actor != hkOwner || strings.Contains(a.record, "gradients") || strings.Contains(a.record, "é") {
+ t.Fatalf("audit %+v", a)
+ }
+ }
+}
+
+// TestWriteTasteChoice: writeTaste keeps a choice with the question it
+// answered, on its task and card, audited as taste.write with the note
+// id and source only.
+func TestWriteTasteChoice(t *testing.T) {
+ r, audits := tasteRig(t)
+ r.must(r.tx(func(t *txn) error {
+ return t.writeTaste(hkOwner, "p_site", wire.TasteSourceChoice, "Calm", "What feel are you after?", "tk_1", "c_1")
+ }))
+ rows := r.tasteRows(hkOwner)
+ if len(rows) != 1 || rows[0].Source != wire.TasteSourceChoice || rows[0].Body != "Calm" || rows[0].Question != "What feel are you after?" || rows[0].TaskID != "tk_1" || rows[0].CardID != "c_1" {
+ t.Fatalf("rows %+v", rows)
+ }
+ if len(*audits) != 1 || (*audits)[0] != (tasteAudit{hkOwner, "taste.write", rows[0].ID + " " + wire.TasteSourceChoice}) {
+ t.Fatalf("audits %+v", *audits)
+ }
+ for name, source := range map[string]string{"unknown source": "model", "no source": ""} {
+ if err := r.tx(func(t *txn) error { return t.writeTaste(hkOwner, "", source, "Calm", "", "", "") }); !errors.Is(err, ErrInvalid) {
+ t.Fatalf("%s: %v", name, err)
+ }
+ }
+ if err := r.tx(func(t *txn) error {
+ return t.writeTaste(hkOwner, "", wire.TasteSourceChoice, "Calm", strings.Repeat("q", 301), "", "")
+ }); !errors.Is(err, ErrInvalid) {
+ t.Fatalf("long question: %v", err)
+ }
+ if rev, _ := r.book(hkOwner); rev != 1 {
+ t.Fatalf("revision %d", rev)
+ }
+}
+
+// TestForgetDeletesAndAudits: Forget deletes the row, bumps both
+// revisions and audits the id and source, never the text; another
+// person's note is not found and stays. Forget everything deletes only
+// the person's design notes.
+func TestForgetDeletesAndAudits(t *testing.T) {
+ r, audits := tasteRig(t)
+ r.must(r.s.AddTaste(r.ctx, hkOwner, "", "Serif headings."))
+ r.must(r.s.AddTaste(r.ctx, hkOwner, "p_site", "Lots of white space."))
+ r.must(r.s.AddTaste(r.ctx, hkMember, "", "Dark mode first."))
+ mine := r.tasteRows(hkOwner)
+ theirs := r.tasteRows(hkMember)[0]
+ *audits = nil
+
+ if err := r.s.ForgetTaste(r.ctx, hkOwner, theirs.ID); !errors.Is(err, ErrNotFound) {
+ t.Fatalf("forgetting another's note: %v", err)
+ }
+ if len(r.tasteRows(hkMember)) != 1 || len(*audits) != 0 {
+ t.Fatal("another person's note was forgotten")
+ }
+ r.must(r.s.ForgetTaste(r.ctx, hkOwner, mine[0].ID))
+ if rows := r.tasteRows(hkOwner); len(rows) != 1 || rows[0].ID != mine[1].ID {
+ t.Fatalf("after forget %+v", rows)
+ }
+ if rev, forget := r.book(hkOwner); rev != 3 || forget != 1 {
+ t.Fatalf("revision %d, forget %d", rev, forget)
+ }
+ if len(*audits) != 1 || (*audits)[0] != (tasteAudit{hkOwner, "taste.forget", mine[0].ID + " " + wire.TasteSourceWords}) {
+ t.Fatalf("audits %+v", *audits)
+ }
+ if err := r.s.ForgetTaste(r.ctx, hkOwner, mine[0].ID); !errors.Is(err, ErrNotFound) {
+ t.Fatalf("second forget: %v", err)
+ }
+
+ r.must(r.s.AddTaste(r.ctx, hkOwner, "", "Round corners."))
+ *audits = nil
+ r.must(r.s.ForgetAllTaste(r.ctx, hkOwner))
+ if n := len(r.tasteRows(hkOwner)); n != 0 {
+ t.Fatalf("%d notes left", n)
+ }
+ if len(r.tasteRows(hkMember)) != 1 {
+ t.Fatal("Forget everything reached another person's notes")
+ }
+ if rev, forget := r.book(hkOwner); rev != 5 || forget != 2 {
+ t.Fatalf("revision %d, forget %d after Forget everything", rev, forget)
+ }
+ if len(*audits) != 1 || (*audits)[0] != (tasteAudit{hkOwner, "taste.forget_all", "2"}) {
+ t.Fatalf("audits %+v", *audits)
+ }
+ for _, a := range *audits {
+ if strings.Contains(a.record, "corners") || strings.Contains(a.record, "white") {
+ t.Fatalf("audit has the text: %+v", a)
+ }
+ }
+ if notes, rev, err := r.s.Taste(r.ctx, hkOwner); err != nil || len(notes) != 0 || rev != 5 {
+ t.Fatalf("after Forget everything: %+v at %d, %v", notes, rev, err)
+ }
+ if rev, _ := r.book(hkMember); rev != 1 {
+ t.Fatalf("another person's revision moved: %d", rev)
+ }
+}
+
+// TestTasteOnlyOwnerReads: Taste lists only the person's own notes.
+func TestTasteOnlyOwnerReads(t *testing.T) {
+ r, _ := tasteRig(t)
+ r.must(r.s.AddTaste(r.ctx, hkOwner, "", "Serif headings."))
+ notes, rev, err := r.s.Taste(r.ctx, hkMember)
+ if err != nil || len(notes) != 0 || rev != 0 {
+ t.Fatalf("member reads %+v at %d, %v", notes, rev, err)
+ }
+}
+
+// TestRemovedMemberTasteUnused: once a member is removed nothing reads
+// or writes their notebook, and their notes stay as they were.
+func TestRemovedMemberTasteUnused(t *testing.T) {
+ r, audits := tasteRig(t)
+ r.must(r.s.AddTaste(r.ctx, hkMember, "", "Dark mode first."))
+ id := r.tasteRows(hkMember)[0].ID
+ *audits = nil
+ r.exec("UPDATE members SET active = 0 WHERE address = ?", hkMember)
+ for name, err := range map[string]error{
+ "add": r.s.AddTaste(r.ctx, hkMember, "", "More."),
+ "forget": r.s.ForgetTaste(r.ctx, hkMember, id),
+ "forget all": r.s.ForgetAllTaste(r.ctx, hkMember),
+ "write": r.tx(func(t *txn) error { return t.writeTaste(hkMember, "", wire.TasteSourceWords, "More.", "", "", "") }),
+ } {
+ if !errors.Is(err, ErrForbidden) {
+ t.Fatalf("%s for a removed member: %v", name, err)
+ }
+ }
+ if _, _, err := r.s.Taste(r.ctx, hkMember); !errors.Is(err, ErrForbidden) {
+ t.Fatalf("read for a removed member: %v", err)
+ }
+ if rows := r.tasteRows(hkMember); len(rows) != 1 || len(*audits) != 0 {
+ t.Fatalf("rows %+v, audits %+v", rows, *audits)
+ }
+ if _, _, err := r.s.Taste(r.ctx, "stranger@example.com"); !errors.Is(err, ErrForbidden) {
+ t.Fatalf("read for a non-member: %v", err)
+ }
+}
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index 606fd03d..116f5486 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -2549,6 +2549,26 @@ var pageCopy = map[string]string{
"team.recent": "Recent work", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11): team panel drawer
"team.recent_empty": "Nothing yet.", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11): team panel drawer
+ // Design feedback 1, task 8: what Design knows about the viewer's
+ // taste, on Design's page (spec 2026-11-28-dynamic-specialists.md, 8.6).
+ "team.taste.count": "Design knows %d things about your taste", // COPY REVIEW PENDING
+ "team.taste.count_one": "Design knows 1 thing about your taste", // COPY REVIEW PENDING
+ "team.taste.empty": "Design doesn't know your taste yet. Add a note, or answer its questions when it asks.", // COPY REVIEW PENDING
+ "team.taste.source_words": "Your words", // COPY REVIEW PENDING
+ "team.taste.source_choice": "Your choice", // COPY REVIEW PENDING
+ "team.taste.scope_all": "All projects", // COPY REVIEW PENDING
+ "team.taste.scope_this": "This project: %s", // COPY REVIEW PENDING
+ "team.taste.scope_project": "Project: %s", // COPY REVIEW PENDING
+ "team.taste.project_gone": "a project that is no longer here", // COPY REVIEW PENDING
+ "team.taste.forget": "Forget", // COPY REVIEW PENDING
+ "team.taste.forget_all": "Forget everything", // COPY REVIEW PENDING
+ "team.taste.forget_all_confirm": "Design forgets every note here. Work that has already started keeps what it was given.", // COPY REVIEW PENDING
+ "team.taste.forget_all_yes": "Yes, forget everything", // COPY REVIEW PENDING
+ "team.taste.add": "Add a note", // COPY REVIEW PENDING
+ "team.taste.add_placeholder": "What should Design know about your taste?", // COPY REVIEW PENDING
+ "team.taste.scope_label": "For", // COPY REVIEW PENDING
+ "team.taste.add_send": "Add note", // COPY REVIEW PENDING
+
// The paste box: every fenced block in a rendered message.
"chat.paste.copy": "Copy", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11): paste box button
"chat.paste.copied": "Copied", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11): paste box button after a copy, and announced
diff --git a/internal/equipo/migrations/0125_design_feedback.sql b/internal/equipo/migrations/0125_design_feedback.sql
index a8f41173..4a753e71 100644
--- a/internal/equipo/migrations/0125_design_feedback.sql
+++ b/internal/equipo/migrations/0125_design_feedback.sql
@@ -11,3 +11,13 @@ ALTER TABLE chat_steps ADD COLUMN pack_digest text NOT NULL DEFAULT "";
-- set on the step that starts the round and on each of its fix rounds;
-- "" none (every step from before this round).
ALTER TABLE chat_steps ADD COLUMN design_ask text NOT NULL DEFAULT "";
+-- The taste notebook (sections 2 and 8.6): each person's own notes on
+-- their taste, per discipline ("design"), for one project or all of
+-- theirs (project_id ""), each the person's words or a choice they made
+-- (with the question it answered); and each person's notebook revision,
+-- moved by every write and forget, and its forget revision, moved by
+-- every forget. Personal records, never shared team ones: only their
+-- person reads or writes them.
+CREATE TABLE chat_taste_notes (id text PRIMARY KEY, person text, discipline text, project_id text NOT NULL DEFAULT "", source text, body text, question text NOT NULL DEFAULT "", task_id text NOT NULL DEFAULT "", card_id text NOT NULL DEFAULT "", created_at datetime);
+CREATE INDEX chat_taste_note_person ON chat_taste_notes(person, discipline);
+CREATE TABLE chat_taste_books (person text, discipline text, revision integer NOT NULL DEFAULT 0, forget_revision integer NOT NULL DEFAULT 0, PRIMARY KEY (person, discipline));
diff --git a/internal/equipo/migrations/schema.sql b/internal/equipo/migrations/schema.sql
index 4dd1b59f..f5362e00 100644
--- a/internal/equipo/migrations/schema.sql
+++ b/internal/equipo/migrations/schema.sql
@@ -929,3 +929,13 @@ ALTER TABLE chat_steps ADD COLUMN pack_digest text NOT NULL DEFAULT "";
-- set on the step that starts the round and on each of its fix rounds;
-- "" none (every step from before this round).
ALTER TABLE chat_steps ADD COLUMN design_ask text NOT NULL DEFAULT "";
+-- The taste notebook (sections 2 and 8.6): each person's own notes on
+-- their taste, per discipline ("design"), for one project or all of
+-- theirs (project_id ""), each the person's words or a choice they made
+-- (with the question it answered); and each person's notebook revision,
+-- moved by every write and forget, and its forget revision, moved by
+-- every forget. Personal records, never shared team ones: only their
+-- person reads or writes them.
+CREATE TABLE chat_taste_notes (id text PRIMARY KEY, person text, discipline text, project_id text NOT NULL DEFAULT "", source text, body text, question text NOT NULL DEFAULT "", task_id text NOT NULL DEFAULT "", card_id text NOT NULL DEFAULT "", created_at datetime);
+CREATE INDEX chat_taste_note_person ON chat_taste_notes(person, discipline);
+CREATE TABLE chat_taste_books (person text, discipline text, revision integer NOT NULL DEFAULT 0, forget_revision integer NOT NULL DEFAULT 0, PRIMARY KEY (person, discipline));
diff --git a/internal/equipo/static/equipo.css b/internal/equipo/static/equipo.css
index e0d4271b..1bd9f4ed 100644
--- a/internal/equipo/static/equipo.css
+++ b/internal/equipo/static/equipo.css
@@ -1644,6 +1644,15 @@ dialog[equipo-drawer] [equipo-team-head] { position: sticky; inset-block-start:
[equipo-team-recent] p { font-size: var(--rst-fs-sm); color: var(--rst-text-muted); }
[equipo-team-recent] small { display: flex; flex-wrap: wrap; gap: 0 var(--rst-sp-2); font-size: var(--rst-fs-xs); color: var(--rst-text-faint); }
[equipo-team-recent] small > span + span::before { content: "\00B7"; margin-inline-end: var(--rst-sp-2); }
+[equipo-taste-notes] { list-style: none; margin: 0 0 var(--rst-sp-2); padding: 0; display: grid; }
+[equipo-taste-notes] li { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--rst-sp-3); padding-block: var(--rst-sp-2); border-block-end: 1px solid var(--rst-line); }
+[equipo-taste-notes] li > div { display: grid; gap: var(--rst-sp-1); min-inline-size: 0; }
+[equipo-taste-body] { font-size: var(--rst-fs-sm); color: var(--rst-text); overflow-wrap: anywhere; white-space: pre-line; }
+[equipo-taste-notes] small { display: flex; flex-wrap: wrap; gap: 0 var(--rst-sp-2); font-size: var(--rst-fs-xs); color: var(--rst-text-faint); }
+[equipo-taste-notes] small > span + span::before { content: "\00B7"; margin-inline-end: var(--rst-sp-2); }
+[equipo-team-taste] [equipo-mach-confirm] { margin-block-end: var(--rst-sp-2); }
+[equipo-taste-label] { font-size: var(--rst-fs-sm); font-weight: 600; color: var(--rst-text); }
+[equipo-taste-scope] { display: flex; align-items: center; gap: var(--rst-sp-2); margin-inline-end: auto; font-size: var(--rst-fs-sm); color: var(--rst-text-muted); }
/* The Settings pattern (Paul, 2026-11-11: "make sure all the settings
screens have proper UX and aren't just random forms"). One content
diff --git a/internal/equipo/team_panel.go b/internal/equipo/team_panel.go
index 96830177..78273152 100644
--- a/internal/equipo/team_panel.go
+++ b/internal/equipo/team_panel.go
@@ -3,13 +3,16 @@ package equipo
import (
"context"
"crypto/rand"
+ "fmt"
"net/http"
+ "net/url"
"slices"
"time"
"github.com/go-chi/chi/v5"
"amadan.net/oficina/equipo/internal/equipo/chat"
+ "amadan.net/oficina/equipo/internal/specialist"
"amadan.net/oficina/equipo/internal/wire"
)
@@ -44,6 +47,25 @@ type teamPanel struct {
ModelPending bool
Ask *teamAsk
Recent []teamRecent
+ // Taste is the viewer's own design notes, on a design-v1
+ // specialist's page only (nil elsewhere).
+ Taste *teamTaste
+}
+
+// teamTaste is what Design knows about the viewer's taste: Headline the
+// count in words, Notes the viewer's own notes, newest first, and Project
+// the specialist's project's name, the Add box's "This project" ("" for
+// a team-wide Design, which offers All projects only).
+type teamTaste struct {
+ Headline string
+ Notes []teamTasteNote
+ Project string
+}
+
+// teamTasteNote is one note as the page shows it: its words (Question
+// the question a choice answered), source, date and scope in words.
+type teamTasteNote struct {
+ ID, Body, Question, Source, Date, Scope string
}
// teamLine is one activity line: what it means, and the raw subject for
@@ -118,10 +140,133 @@ func (a *application) teamPage(w http.ResponseWriter, r *http.Request) {
a.failure(w, r, chatError(err))
return
}
+ sp, err := a.designSpecialist(ctx, address, s.specialist)
+ if err != nil {
+ a.failure(w, r, chatError(err))
+ return
+ }
+ if sp != nil {
+ if panel.Taste, err = a.teamTaste(ctx, address, *sp); err != nil {
+ a.failure(w, r, chatError(err))
+ return
+ }
+ }
data.Team, data.Title = panel, s.copyKey
render(w, "team", data)
}
+// designSpecialist is the active design-v1 specialist key names, as the
+// person's specialist list reads it; nil when key is any other.
+func (a *application) designSpecialist(ctx context.Context, person, key string) (*wire.Specialist, error) {
+ list, err := a.store.Chat().Specialists(ctx, person)
+ if err != nil {
+ return nil, err
+ }
+ for _, sp := range list.Items {
+ if sp.ID == key && sp.Profile == specialist.ProfileDesign && sp.State == wire.SpecialistActive {
+ return &sp, nil
+ }
+ }
+ return nil, nil
+}
+
+// teamTaste reads the viewer's own design notes for Design's page. A
+// read that fails fails the page: the count is never shown as zero.
+func (a *application) teamTaste(ctx context.Context, person string, sp wire.Specialist) (*teamTaste, error) {
+ book, err := a.store.Chat().TasteBook(ctx, person, sp.Project)
+ if err != nil {
+ return nil, err
+ }
+ notes := book.Notes
+ v := &teamTaste{Headline: fmt.Sprintf(copyText("team.taste.count"), len(notes))}
+ switch len(notes) {
+ case 0:
+ v.Headline = copyText("team.taste.empty")
+ case 1:
+ v.Headline = copyText("team.taste.count_one")
+ }
+ if sp.Project != "" {
+ v.Project = book.ProjectName
+ if v.Project == "" {
+ v.Project = copyText("team.taste.project_gone")
+ }
+ }
+ for _, n := range notes {
+ line := teamTasteNote{ID: n.ID, Body: n.Body, Question: n.Question, Date: n.CreatedAt.UTC().Format("2 Jan 2006"), Source: copyText("team.taste.source_words")}
+ if n.Source == wire.TasteSourceChoice {
+ line.Source = copyText("team.taste.source_choice")
+ }
+ name := n.ProjectName
+ if name == "" {
+ name = copyText("team.taste.project_gone")
+ }
+ switch {
+ case n.ProjectID == "":
+ line.Scope = copyText("team.taste.scope_all")
+ case n.ProjectID == sp.Project:
+ line.Scope = fmt.Sprintf(copyText("team.taste.scope_this"), name)
+ default:
+ line.Scope = fmt.Sprintf(copyText("team.taste.scope_project"), name)
+ }
+ v.Notes = append(v.Notes, line)
+ }
+ return v, nil
+}
+
+// tasteAction runs a taste write as the session's person from a
+// design-v1 specialist's page and returns to that page; any other
+// specialist is not found.
+func (a *application) tasteAction(w http.ResponseWriter, r *http.Request, act func(context.Context, string, wire.Specialist) error) {
+ key := chi.URLParam(r, "specialist")
+ a.chatActionTo(w, r, "/team/"+url.PathEscape(key), func(ctx context.Context, person string) error {
+ sp, err := a.designSpecialist(ctx, person, key)
+ if err != nil {
+ return err
+ }
+ if sp == nil {
+ return chat.ErrNotFound
+ }
+ return act(ctx, person, *sp)
+ })
+}
+
+// addTaste is POST /team/{specialist}/taste: a note in the person's own
+// words for the specialist's project (scope "project") or all their
+// projects (scope "all"). The project comes from the specialist, never
+// from the form.
+func (a *application) addTaste(w http.ResponseWriter, r *http.Request) {
+ a.tasteAction(w, r, func(ctx context.Context, person string, sp wire.Specialist) error {
+ project := ""
+ switch r.PostFormValue("scope") {
+ case "all":
+ case "project":
+ if sp.Project == "" {
+ return chat.ErrInvalid
+ }
+ project = sp.Project
+ default:
+ return chat.ErrInvalid
+ }
+ return a.store.Chat().AddTaste(ctx, person, project, r.PostFormValue("body"))
+ })
+}
+
+// forgetTaste is POST /team/{specialist}/taste/{note}/forget: one of the
+// person's own notes.
+func (a *application) forgetTaste(w http.ResponseWriter, r *http.Request) {
+ a.tasteAction(w, r, func(ctx context.Context, person string, _ wire.Specialist) error {
+ return a.store.Chat().ForgetTaste(ctx, person, chi.URLParam(r, "note"))
+ })
+}
+
+// forgetAllTaste is POST /team/{specialist}/taste/forget: Forget
+// everything, once the person confirmed it on the page.
+func (a *application) forgetAllTaste(w http.ResponseWriter, r *http.Request) {
+ a.tasteAction(w, r, func(ctx context.Context, person string, _ wire.Specialist) error {
+ return a.store.Chat().ForgetAllTaste(ctx, person)
+ })
+}
+
// teamPanel reads one specialist's drawer from the thin core.
func (a *application) teamPanel(ctx context.Context, person, key, icon, copyKey string) (teamPanel, error) {
c := a.store.Chat()
diff --git a/internal/equipo/team_taste_test.go b/internal/equipo/team_taste_test.go
new file mode 100644
index 00000000..8cfa2aa8
--- /dev/null
+++ b/internal/equipo/team_taste_test.go
@@ -0,0 +1,247 @@
+package equipo
+
+import (
+ "context"
+ "crypto/rand"
+ "html"
+ "io"
+ "net/http"
+ "net/http/httptest"
+ "net/url"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/rastrillo/rastrillo/sessions"
+)
+
+// Design feedback 1, Task 8 (spec 2026-11-28-dynamic-specialists.md,
+// section 8.6): Design's page (/team/{specialist}, a design-v1
+// specialist) leads with what Design knows about the viewer's taste,
+// lists the viewer's own notes with Forget, offers Forget everything
+// behind a confirm step, and a box to add a note for the specialist's
+// project or all projects. Scriptless forms, same-origin posts, and only
+// the viewer's notes: another member's page shows none of them.
+
+const (
+ tasteOwner = "owner@example.com"
+ tasteMember = "member@example.com"
+ tasteOrigin = "https://equipo.example"
+ tasteSP = "sp_design"
+)
+
+type tasteSite struct {
+ t *testing.T
+ s *Store
+ h http.Handler
+}
+
+func newTasteSite(t *testing.T) *tasteSite {
+ t.Helper()
+ s, _, h := probeRouter(t, agentEnv(t), true)
+ if err := s.SetMember(context.Background(), Actor{Address: tasteOwner}, tasteMember, RoleMember, true, 0); err != nil {
+ t.Fatal(err)
+ }
+ x := &tasteSite{t, s, h}
+ x.exec("INSERT INTO chat_projects(id, repo, state, title, title_set) VALUES ('p_site', 'oficina/site', 'active', 'Site', 1)")
+ x.exec("INSERT INTO chat_specialists(id, profile, project_id, name, brief, state, revision, approver, created_at, updated_at) VALUES (?, 'design-v1', 'p_site', 'Design', 'b', 'active', 2, ?, ?, ?)", tasteSP, tasteOwner, time.Now().UTC(), time.Now().UTC())
+ return x
+}
+
+func (x *tasteSite) exec(q string, args ...any) {
+ x.t.Helper()
+ if _, err := x.s.db.Writer().Exec(q, args...); err != nil {
+ x.t.Fatal(err)
+ }
+}
+
+// cookie is a browser session for address.
+func (x *tasteSite) cookie(address string) *http.Cookie {
+ x.t.Helper()
+ token := rand.Text()
+ now := time.Now().UTC()
+ x.exec("INSERT INTO sessions(token_hash,subject,method,auth_time,created_at,expires_at) VALUES(?,?,?,?,?,?)", sessions.HashToken(token), address, "fixture", now.Format(time.RFC3339Nano), now.Format(time.RFC3339Nano), now.Add(time.Hour).Format(time.RFC3339Nano))
+ return &http.Cookie{Name: "__Host-rastrillo_session", Value: token}
+}
+
+func (x *tasteSite) get(c *http.Cookie, path string, want int) string {
+ x.t.Helper()
+ r := httptest.NewRequest("GET", tasteOrigin+path, nil)
+ r.AddCookie(c)
+ w := httptest.NewRecorder()
+ x.h.ServeHTTP(w, r)
+ body, _ := io.ReadAll(w.Body)
+ if w.Code != want {
+ x.t.Fatalf("GET %s: %d, want %d: %.400s", path, w.Code, want, body)
+ }
+ return string(body)
+}
+
+// post submits a page form as c from this origin (sameOrigin) or with
+// no browser evidence; it returns the status and redirect.
+func (x *tasteSite) post(c *http.Cookie, path string, form url.Values, sameOrigin bool) (int, string) {
+ x.t.Helper()
+ r := httptest.NewRequest("POST", tasteOrigin+path, strings.NewReader(form.Encode()))
+ r.AddCookie(c)
+ r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ if sameOrigin {
+ r.Header.Set("Origin", tasteOrigin)
+ r.Header.Set("Sec-Fetch-Site", "same-origin")
+ }
+ w := httptest.NewRecorder()
+ x.h.ServeHTTP(w, r)
+ return w.Code, w.Header().Get("Location")
+}
+
+func (x *tasteSite) add(c *http.Cookie, body, scope string) {
+ x.t.Helper()
+ if code, to := x.post(c, "/team/"+tasteSP+"/taste", url.Values{"body": {body}, "scope": {scope}}, true); code != http.StatusSeeOther || to != "/team/"+tasteSP {
+ x.t.Fatalf("add %q: %d %q", body, code, to)
+ }
+}
+
+func (x *tasteSite) noteIDs(person string) []string {
+ x.t.Helper()
+ rows, err := x.s.db.Writer().Query("SELECT id FROM chat_taste_notes WHERE person = ? ORDER BY created_at, rowid", person)
+ if err != nil {
+ x.t.Fatal(err)
+ }
+ defer rows.Close()
+ var ids []string
+ for rows.Next() {
+ var id string
+ if err := rows.Scan(&id); err != nil {
+ x.t.Fatal(err)
+ }
+ ids = append(ids, id)
+ }
+ return ids
+}
+
+// TestTastePageCount: the page leads with the count (singular for one,
+// an empty state for none), lists each note with its source, date and
+// scope, and its forms post to the taste routes.
+func TestTastePageCount(t *testing.T) {
+ x := newTasteSite(t)
+ owner := x.cookie(tasteOwner)
+ page := x.get(owner, "/team/"+tasteSP, 200)
+ mustContain(t, page, html.EscapeString(copyText("team.taste.empty")), `action="/team/`+tasteSP+`/taste"`, `name="body" required maxlength="300"`, `<option value="project">`+strings.ReplaceAll(copyText("team.taste.scope_this"), "%s", "Site")+`</option>`, `<option value="all">`+copyText("team.taste.scope_all")+`</option>`)
+ if strings.Contains(page, `/taste/forget"`) {
+ t.Fatal("Forget everything with no notes")
+ }
+
+ x.add(owner, "Serif headings, never Inter.", "all")
+ page = x.get(owner, "/team/"+tasteSP, 200)
+ mustContain(t, page, copyText("team.taste.count_one"))
+ x.add(owner, "Lots of white space.", "project")
+ x.add(owner, "Warm <paper> tones.", "project")
+ page = x.get(owner, "/team/"+tasteSP, 200)
+ ids := x.noteIDs(tasteOwner)
+ if len(ids) != 3 {
+ t.Fatalf("notes %v", ids)
+ }
+ mustContain(t, page, "Design knows 3 things about your taste", "Serif headings, never Inter.", "Warm &lt;paper&gt; tones.",
+ copyText("team.taste.source_words"), copyText("team.taste.scope_all"), strings.ReplaceAll(copyText("team.taste.scope_this"), "%s", "Site"),
+ time.Now().UTC().Format("2 Jan 2006"),
+ `action="/team/`+tasteSP+`/taste/`+ids[0]+`/forget"`, `action="/team/`+tasteSP+`/taste/forget"`, copyText("team.taste.forget_all"), "<details equipo-mach-confirm")
+ if strings.Contains(page, "Warm <paper>") {
+ t.Fatal("a note's text is not escaped")
+ }
+ if strings.Index(page, "Warm &lt;paper&gt;") > strings.Index(page, "Serif headings") {
+ t.Fatal("notes not newest first")
+ }
+
+ // Forget, then Forget everything.
+ if code, to := x.post(owner, "/team/"+tasteSP+"/taste/"+ids[0]+"/forget", nil, true); code != http.StatusSeeOther || to != "/team/"+tasteSP {
+ t.Fatalf("forget: %d %q", code, to)
+ }
+ page = x.get(owner, "/team/"+tasteSP, 200)
+ if strings.Contains(page, "Serif headings") {
+ t.Fatal("a forgotten note shown")
+ }
+ mustContain(t, page, "Design knows 2 things about your taste")
+ if code, _ := x.post(owner, "/team/"+tasteSP+"/taste/forget", nil, true); code != http.StatusSeeOther {
+ t.Fatalf("forget everything: %d", code)
+ }
+ if ids := x.noteIDs(tasteOwner); len(ids) != 0 {
+ t.Fatalf("left %v", ids)
+ }
+ mustContain(t, x.get(owner, "/team/"+tasteSP, 200), html.EscapeString(copyText("team.taste.empty")))
+}
+
+// TestTasteOnlyOwnerSees: another member's page for the same specialist
+// shows none of the owner's notes, and they cannot forget them.
+func TestTasteOnlyOwnerSees(t *testing.T) {
+ x := newTasteSite(t)
+ owner, member := x.cookie(tasteOwner), x.cookie(tasteMember)
+ x.add(owner, "Serif headings, never Inter.", "all")
+ x.add(owner, "Lots of white space.", "project")
+ page := x.get(member, "/team/"+tasteSP, 200)
+ mustContain(t, page, html.EscapeString(copyText("team.taste.empty")))
+ for _, not := range []string{"Serif headings", "white space", "Design knows 2"} {
+ if strings.Contains(page, not) {
+ t.Fatalf("member sees %q", not)
+ }
+ }
+ id := x.noteIDs(tasteOwner)[0]
+ if code, _ := x.post(member, "/team/"+tasteSP+"/taste/"+id+"/forget", nil, true); code != http.StatusNotFound {
+ t.Fatalf("member forgets the owner's note: %d", code)
+ }
+ if code, _ := x.post(member, "/team/"+tasteSP+"/taste/forget", nil, true); code != http.StatusSeeOther {
+ t.Fatalf("member's Forget everything: %d", code)
+ }
+ if n := len(x.noteIDs(tasteOwner)); n != 2 {
+ t.Fatalf("owner has %d notes after the member's forgets", n)
+ }
+ mustContain(t, x.get(owner, "/team/"+tasteSP, 200), "Design knows 2 things about your taste")
+}
+
+// TestTasteFormsRefused: a cross-site post, a note too long, an unknown
+// scope, and a specialist that is not Design change nothing.
+func TestTasteFormsRefused(t *testing.T) {
+ x := newTasteSite(t)
+ owner := x.cookie(tasteOwner)
+ if code, _ := x.post(owner, "/team/"+tasteSP+"/taste", url.Values{"body": {"Quiet."}, "scope": {"all"}}, false); code != http.StatusForbidden {
+ t.Fatalf("cross-site add: %d", code)
+ }
+ for name, form := range map[string]url.Values{
+ "301": {"body": {strings.Repeat("a", 301)}, "scope": {"all"}},
+ "empty": {"body": {" "}, "scope": {"all"}},
+ "scope": {"body": {"Quiet."}, "scope": {"p_site"}},
+ "noscope": {"body": {"Quiet."}},
+ } {
+ if code, _ := x.post(owner, "/team/"+tasteSP+"/taste", form, true); code != http.StatusUnprocessableEntity {
+ t.Fatalf("%s: %d", name, code)
+ }
+ }
+ if code, _ := x.post(owner, "/team/engineering/taste", url.Values{"body": {"Quiet."}, "scope": {"all"}}, true); code != http.StatusNotFound {
+ t.Fatalf("Engineering's taste: %d", code)
+ }
+ if strings.Contains(x.get(owner, "/team/engineering", 200), "/taste") {
+ t.Fatal("a taste section on Engineering's page")
+ }
+ x.exec("INSERT INTO chat_specialists(id, profile, project_id, name, brief, state, revision, approver, created_at, updated_at) VALUES ('sp_research', 'research-v1', '', 'Research', 'b', 'active', 2, ?, ?, ?)", tasteOwner, time.Now().UTC(), time.Now().UTC())
+ if code, _ := x.post(owner, "/team/sp_research/taste", url.Values{"body": {"Quiet."}, "scope": {"all"}}, true); code != http.StatusNotFound {
+ t.Fatalf("Research's taste: %d", code)
+ }
+ if strings.Contains(x.get(owner, "/team/sp_research", 200), "/taste") {
+ t.Fatal("a taste section on Research's page")
+ }
+ // A team-wide Design offers All projects only.
+ x.exec("UPDATE chat_specialists SET project_id = '' WHERE id = ?", tasteSP)
+ page := x.get(owner, "/team/"+tasteSP, 200)
+ if strings.Contains(page, `<option value="project">`) {
+ t.Fatal("a project scope for a team-wide Design")
+ }
+ if code, _ := x.post(owner, "/team/"+tasteSP+"/taste", url.Values{"body": {"Quiet."}, "scope": {"project"}}, true); code != http.StatusUnprocessableEntity {
+ t.Fatalf("project scope on a team-wide Design: %d", code)
+ }
+ if n := len(x.noteIDs(tasteOwner)); n != 0 {
+ t.Fatalf("refusals wrote %d notes", n)
+ }
+ // A revoked Design has no page and takes no notes.
+ x.exec("UPDATE chat_specialists SET state = 'revoked' WHERE id = ?", tasteSP)
+ if code, _ := x.post(owner, "/team/"+tasteSP+"/taste", url.Values{"body": {"Quiet."}, "scope": {"all"}}, true); code != http.StatusNotFound {
+ t.Fatalf("revoked Design: %d", code)
+ }
+}
diff --git a/internal/equipo/templates/team.html b/internal/equipo/templates/team.html
index f584fa43..3c39f31a 100644
--- a/internal/equipo/templates/team.html
+++ b/internal/equipo/templates/team.html
@@ -11,6 +11,16 @@
<p equipo-team-state>{{if .Task}}<span data-spec-star>{{template "mark" "s"}}</span>{{with .Step}}{{template "elapsed" .StartedAt}}{{end}}{{else}}{{copy "nav.idle"}}{{end}}</p>
<button type="button" equipo-team-close data-team-close hidden aria-label="{{copy "team.close"}}" title="{{copy "team.close"}}">{{icon "x"}}</button>
</header>
+{{with .Taste}}<section equipo-team-sec equipo-team-taste data-taste>
+<h2>{{.Headline}}</h2>
+{{with .Notes}}<ul equipo-taste-notes>{{range .}}<li data-taste-note="{{.ID}}"><div>{{with .Question}}<p equipo-team-quiet>{{.}}</p>{{end}}<p equipo-taste-body>{{.Body}}</p><small><span>{{.Source}}</span><span>{{.Date}}</span><span>{{.Scope}}</span></small></div><form method="post" action="/team/{{$.Key}}/taste/{{.ID}}/forget"><button rst-btn data-quiet type="submit" data-taste-forget>{{copy "team.taste.forget"}}</button></form></li>{{end}}</ul>
+<details equipo-mach-confirm data-taste-forget-all><summary rst-btn data-quiet>{{copy "team.taste.forget_all"}}</summary><div><p>{{copy "team.taste.forget_all_confirm"}}</p><form method="post" action="/team/{{$.Key}}/taste/forget"><button rst-btn type="submit" data-danger>{{copy "team.taste.forget_all_yes"}}</button></form></div></details>{{end}}
+<form equipo-team-ask-form method="post" action="/team/{{$.Key}}/taste" data-taste-add>
+<label equipo-taste-label for="taste-body">{{copy "team.taste.add"}}</label>
+<textarea rst-input id="taste-body" name="body" required maxlength="300" rows="2" placeholder="{{copy "team.taste.add_placeholder"}}"></textarea>
+<div equipo-team-ask-foot><label equipo-taste-scope>{{copy "team.taste.scope_label"}} <select rst-input name="scope">{{if .Project}}<option value="project">{{printf (copy "team.taste.scope_this") .Project}}</option>{{end}}<option value="all">{{copy "team.taste.scope_all"}}</option></select></label><button rst-btn="primary" type="submit">{{copy "team.taste.add_send"}}</button></div>
+</form>
+</section>{{end}}
{{with .Task}}<section equipo-team-sec equipo-team-now>
<h2>{{copy "team.working_on"}}</h2>
<a equipo-team-task href="/tasks/{{.ID}}">{{.Title}}</a>