instance: step activity, task source and duplicates, project facts
A running step's activity lines come only from its person's primary
runner for the current attempt; the newest five stay on the step and
every member gets each line. Tasks carry the creator's name, the
message they were noted from, a possible duplicate and the coordinator
looking or merging; POST /tasks/{id}/duplicate folds one into another.
Projects carry the index's description, stack, checks and repo heads,
and the people involved. Migration 0048.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 files changed,
+636
−11
internal/equipo/chat/http.go+15 −0internal/equipo/chat/inner.go+323 −0internal/equipo/chat/projects.go+5 −2internal/equipo/chat/runner.go+2 −0internal/equipo/chat/store.go+4 −0internal/equipo/chat/stream.go+1 −1internal/equipo/chat/tasks.go+21 −4internal/equipo/migrations/0048_thin_ux1.sql+2 −0internal/equipo/migrations/schema.sql+2 −2internal/thintest/client.go+15 −2internal/thintest/inner_contract_test.go+246 −0
diff --git a/internal/equipo/chat/http.go b/internal/equipo/chat/http.go| index 108d06f2..d649a2d2 100644 |
| --- a/internal/equipo/chat/http.go |
| +++ b/internal/equipo/chat/http.go |
| @@ -75,6 +75,7 @@ func (h *HTTP) Mount(r chi.Router) { |
| r.Get("/tasks/{id}", h.thinOr("GET /tasks/{id}", thinTask, h.bearer(h.task))) |
| r.Post("/tasks/{id}/cancel", h.thinOr("POST /tasks/{id}/cancel", thinTask, h.bearer(h.cancelTask))) |
| r.Post("/tasks/{id}/retry", h.bearer(h.retryTask)) |
| + r.Post("/tasks/{id}/duplicate", h.bearer(h.markDuplicate)) |
| r.Post("/tasks/{id}/thread", h.bearer(h.postThread)) |
| r.Get("/steps/{id}/log", h.bearer(h.stepLog)) |
| r.Post("/tasks/{id}/questions", h.bearer(h.ask)) |
| @@ -449,6 +450,20 @@ func (h *HTTP) retryTask(w http.ResponseWriter, r *http.Request, p personapi.Per |
| writeJSON(w, http.StatusAccepted, wire.TaskAccepted{Attempt: attempt}) |
| } |
| +func (h *HTTP) markDuplicate(w http.ResponseWriter, r *http.Request, p personapi.PersonPrincipal) { |
| + var in wire.MarkDuplicate |
| + if err := readJSON(r, &in); err != nil { |
| + h.fail(w, r, err) |
| + return |
| + } |
| + out, err := h.Store.MarkDuplicate(r.Context(), p.Address, chi.URLParam(r, "id"), in) |
| + if err != nil { |
| + h.fail(w, r, err) |
| + return |
| + } |
| + writeJSON(w, 200, out) |
| +} |
| + |
| func (h *HTTP) postThread(w http.ResponseWriter, r *http.Request, p personapi.PersonPrincipal) { |
| var in wire.PostThread |
| if err := readJSON(r, &in); err != nil { |
diff --git a/internal/equipo/chat/inner.go b/internal/equipo/chat/inner.go| new file mode 100644 |
| index 00000000..77876e0d |
| --- /dev/null |
| +++ b/internal/equipo/chat/inner.go |
| @@ -0,0 +1,323 @@ |
| +package chat |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "errors" |
| + "slices" |
| + "strings" |
| + "unicode" |
| + "unicode/utf8" |
| + |
| + "gorm.io/gorm" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// What the inner screens show beyond the task itself: a step's newest |
| +// activity lines, the task's people and source, a possible duplicate, |
| +// the coordinator at work on it, and what Equipo knows of a project. |
| + |
| +// DisplayName is a member's name until people have profiles: the |
| +// address's local part up to the first ".", "_", "-" or "+", capitalised; |
| +// initials is its first letter. |
| +func DisplayName(address string) (name, initials string) { |
| + local, _, _ := strings.Cut(address, "@") |
| + if i := strings.IndexAny(local, "._-+"); i > 0 { |
| + local = local[:i] |
| + } |
| + r, n := utf8.DecodeRuneInString(local) |
| + if n == 0 || r == utf8.RuneError { |
| + return address, "" |
| + } |
| + first := string(unicode.ToUpper(r)) |
| + return first + local[n:], first |
| +} |
| + |
| +func personRef(address string) wire.PersonRef { |
| + name, initials := DisplayName(address) |
| + return wire.PersonRef{Address: address, Name: name, Initials: initials} |
| +} |
| + |
| +func decodeActivity(raw string) []wire.ActivityLine { |
| + out := []wire.ActivityLine{} |
| + if raw != "" { |
| + _ = json.Unmarshal([]byte(raw), &out) |
| + } |
| + return out |
| +} |
| + |
| +var activityKinds = []string{wire.ActivityRead, wire.ActivitySearch, wire.ActivityEdit, wire.ActivityRun, wire.ActivityOther} |
| + |
| +// activitySubject is a line's subject made safe to show: one line, no |
| +// control characters, the workspace prefix gone, bounded. |
| +func activitySubject(s string) string { |
| + if !utf8.ValidString(s) { |
| + return "" |
| + } |
| + s, _, _ = strings.Cut(strings.TrimSpace(s), "\n") |
| + s = strings.TrimPrefix(strings.TrimSpace(s), "/workspace/") |
| + s = strings.Map(func(r rune) rune { |
| + if unicode.IsControl(r) { |
| + return -1 |
| + } |
| + return r |
| + }, s) |
| + if len(s) > wire.MaxActivitySubject { |
| + s = s[:wire.MaxActivitySubject] |
| + for !utf8.ValidString(s) { |
| + s = s[:len(s)-1] |
| + } |
| + } |
| + return strings.TrimSpace(s) |
| +} |
| + |
| +// stepActivity keeps a running step's newest activity line and tells |
| +// every member. Only the step person's primary runner, for the current |
| +// attempt of a step that has not ended; anything else is dropped (the |
| +// frame is not durable, so nothing waits on it). |
| +func (t *txn) stepActivity(l Lease, v *wire.StepActivityReport) error { |
| + var s stepRecord |
| + if err := t.db.Where("id = ? AND task_id = ?", v.StepID, v.TaskID).First(&s).Error; errors.Is(err, gorm.ErrRecordNotFound) { |
| + return nil |
| + } else if err != nil { |
| + return err |
| + } |
| + if s.Person != l.Runner.Person || v.Attempt != s.Attempt || wire.StepTerminal(s.State) { |
| + return nil |
| + } |
| + primary, err := t.s.authority.PrimaryRunner(t.db, s.Person) |
| + if err != nil { |
| + return err |
| + } |
| + if primary != l.Runner.RunnerID { |
| + return nil |
| + } |
| + kind := v.Kind |
| + if !slices.Contains(activityKinds, kind) { |
| + kind = wire.ActivityOther |
| + } |
| + lines := append(decodeActivity(s.Activity), wire.ActivityLine{Kind: kind, Subject: activitySubject(v.Subject), At: t.now()}) |
| + if len(lines) > wire.MaxStepActivity { |
| + lines = lines[len(lines)-wire.MaxStepActivity:] |
| + } |
| + raw, _ := json.Marshal(lines) |
| + if err := t.db.Model(&stepRecord{}).Where("id = ?", s.ID).Update("activity", string(raw)).Error; err != nil { |
| + return err |
| + } |
| + members, err := t.members() |
| + if err != nil { |
| + return err |
| + } |
| + data := wire.StepActivity{TaskID: s.TaskID, StepID: s.ID, Attempt: s.Attempt, Activity: lines} |
| + for _, m := range members { |
| + if err := t.event(m, wire.EventActivity, wire.ResourceStep, s.ID, 0, "", "", s.Attempt, data); err != nil { |
| + return err |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// taskExtras fills what the screens show around a task: the creator's |
| +// name, the message it was noted from, a possible duplicate and the |
| +// coordinator at work on it. |
| +func (t *txn) taskExtras(v *wire.Task, k taskRecord, steps []stepRecord) error { |
| + v.CreatorName, _ = DisplayName(k.Creator) |
| + if k.TurnID != "" { |
| + var m messageRecord |
| + err := t.db.Where("turn_id = ? AND person = ? AND role = ?", k.TurnID, k.Creator, wire.RolePerson).Order("seq").First(&m).Error |
| + if err == nil { |
| + at := m.CreatedAt |
| + v.SourceMessageID, v.SourceAt = m.ID, &at |
| + } else if !errors.Is(err, gorm.ErrRecordNotFound) { |
| + return err |
| + } |
| + } |
| + if k.DuplicateOf != "" { |
| + var d taskRecord |
| + err := t.db.Select("id", "title", "stage").Where("id = ?", k.DuplicateOf).First(&d).Error |
| + if err == nil { |
| + v.DuplicateOf = &wire.TaskRef{ID: d.ID, Title: d.Title, Stage: d.Stage} |
| + } else if !errors.Is(err, gorm.ErrRecordNotFound) { |
| + return err |
| + } |
| + } |
| + switch k.Stage { |
| + case wire.StageMerging: |
| + since := k.UpdatedAt |
| + for i := len(steps) - 1; i >= 0; i-- { |
| + if steps[i].Specialist == wire.SpecialistMerge { |
| + if steps[i].StartedAt != nil { |
| + since = *steps[i].StartedAt |
| + } |
| + break |
| + } |
| + } |
| + v.Coordinator = &wire.TaskActivity{Kind: wire.CoordinatorMerging, Since: since} |
| + case wire.StageNoted, wire.StageInvestigated: |
| + if k.TurnID == "" { |
| + break |
| + } |
| + var r turnRecord |
| + err := t.db.Select("id", "state", "created_at").Where("id = ?", k.TurnID).First(&r).Error |
| + if err == nil && !wire.Terminal(r.State) { |
| + v.Coordinator = &wire.TaskActivity{Kind: wire.CoordinatorLooking, Since: r.CreatedAt} |
| + } else if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { |
| + return err |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// MarkDuplicate folds a task into another open task of the same project: |
| +// only its creator; the task is cancelled as Cancel does, and its title |
| +// and brief go on the other task's thread as a report. |
| +func (s *Store) MarkDuplicate(ctx context.Context, person, id string, in wire.MarkDuplicate) (out wire.Task, err error) { |
| + err = s.tx(ctx, func(t *txn) error { |
| + if err := s.authority.CurrentPerson(ctx, t.db); err != nil { |
| + return err |
| + } |
| + k, err := t.loadTask(id) |
| + if err != nil { |
| + return err |
| + } |
| + if k.Creator != person { |
| + return ErrForbidden |
| + } |
| + if wire.FinalStage(k.Stage) || k.CancelRequested { |
| + return ErrTaskEnded |
| + } |
| + of := strings.TrimSpace(in.Of) |
| + if of == "" || of == k.ID { |
| + return ErrInvalid |
| + } |
| + target, err := t.loadTask(of) |
| + if err != nil { |
| + return err |
| + } |
| + if target.ProjectID != k.ProjectID || wire.FinalStage(target.Stage) || target.CancelRequested { |
| + return ErrInvalid |
| + } |
| + if err := t.db.Model(&taskRecord{}).Where("id = ?", k.ID).Update("duplicate_of", target.ID).Error; err != nil { |
| + return err |
| + } |
| + if _, err := t.cancelTask(person, k.ID); err != nil { |
| + return err |
| + } |
| + var n int64 |
| + if err := t.db.Model(&entryRecord{}).Where("task_id = ? AND kind <> ?", target.ID, entryFinding).Count(&n).Error; err != nil { |
| + return err |
| + } |
| + if n < wire.MaxThread { |
| + text := k.Title |
| + if k.Brief != "" { |
| + text += "\n\n" + k.Brief |
| + } |
| + text = clip(text, wire.MaxThreadText) |
| + e := entryRecord{ID: newID("e_"), TaskID: target.ID, IdempotencyKey: "duplicate:" + k.ID, Kind: entryReport, Author: person, Text: text, CreatedAt: t.now()} |
| + if err := t.db.Create(&e).Error; err != nil { |
| + return err |
| + } |
| + if err := t.saveTask(&target); err != nil { |
| + return err |
| + } |
| + } |
| + if k, err = t.loadTask(k.ID); err != nil { |
| + return err |
| + } |
| + out, err = t.taskView(k) |
| + return err |
| + }) |
| + return out, err |
| +} |
| + |
| +func clip(s string, n int) string { |
| + if len(s) <= n { |
| + return s |
| + } |
| + s = s[:n] |
| + for !utf8.ValidString(s) { |
| + s = s[:len(s)-1] |
| + } |
| + return s |
| +} |
| + |
| +// stackNames are the catalog's hints as people name them. |
| +var stackNames = map[string]string{"go": "Go", "swift": "Swift", "swiftui": "SwiftUI", "javascript": "JavaScript", "react": "React", "vue": "Vue", "svelte": "Svelte", "next": "Next.js", "vite": "Vite", "rust": "Rust", "python": "Python", "android": "Android"} |
| + |
| +// catalogEntry is what a runner's index knows of repo: the viewer's |
| +// primary runner first, else any active member's that lists it. |
| +func (t *txn) catalogEntry(repo string) (wire.RepoInfo, bool, error) { |
| + if t.catalogs == nil { |
| + t.catalogs = map[string]wire.RepoInfo{} |
| + members, err := t.members() |
| + if err != nil { |
| + return wire.RepoInfo{}, false, err |
| + } |
| + if t.viewer != "" { |
| + members = append([]string{t.viewer}, members...) |
| + } |
| + for _, m := range members { |
| + h, err := t.hello(m) |
| + if err != nil { |
| + return wire.RepoInfo{}, false, err |
| + } |
| + for _, e := range h.Catalog { |
| + if _, ok := t.catalogs[e.Repo]; !ok { |
| + t.catalogs[e.Repo] = e |
| + } |
| + } |
| + } |
| + } |
| + e, ok := t.catalogs[repo] |
| + return e, ok, nil |
| +} |
| + |
| +// projectFacts adds what the index knows of the project's repositories |
| +// and who is involved in it. |
| +func (t *txn) projectFacts(v *wire.Project, p projectRecord) error { |
| + v.Stack, v.People = []string{}, []wire.PersonRef{} |
| + for i := range v.Attachments { |
| + a := &v.Attachments[i] |
| + if a.Kind != wire.AttachmentRepo { |
| + continue |
| + } |
| + e, ok, err := t.catalogEntry(a.Ref) |
| + if err != nil { |
| + return err |
| + } |
| + if !ok { |
| + continue |
| + } |
| + a.DefaultBranch, a.HeadSHA, a.HeadSubject = e.DefaultBranch, e.HeadSHA, e.HeadSubject |
| + if !e.UpdatedAt.IsZero() { |
| + at := e.UpdatedAt |
| + a.HeadAt = &at |
| + } |
| + } |
| + if e, ok, err := t.catalogEntry(p.Repo); err != nil { |
| + return err |
| + } else if ok { |
| + v.Description = e.Summary |
| + for _, h := range e.Hints { |
| + if n := stackNames[h]; n != "" && !slices.Contains(v.Stack, n) { |
| + v.Stack = append(v.Stack, n) |
| + } |
| + } |
| + c := wire.ProjectChecks{Here: e.Gate != "" && e.ChecksReason == "", Gate: e.Gate, Reason: e.ChecksReason} |
| + if c.Reason == "" && e.Gate == "" { |
| + c.Reason = wire.ChecksNone |
| + } |
| + v.Checks = &c |
| + } |
| + var creators []string |
| + if err := t.db.Raw("SELECT creator FROM chat_tasks WHERE project_id = ? GROUP BY creator ORDER BY MIN(created_at), creator", p.ID).Scan(&creators).Error; err != nil { |
| + return err |
| + } |
| + for _, a := range append([]string{p.AddedBy}, creators...) { |
| + if a != "" && !slices.ContainsFunc(v.People, func(r wire.PersonRef) bool { return r.Address == a }) { |
| + v.People = append(v.People, personRef(a)) |
| + } |
| + } |
| + return nil |
| +} |
diff --git a/internal/equipo/chat/projects.go b/internal/equipo/chat/projects.go| index d3f3a7a4..0e6221ca 100644 |
| --- a/internal/equipo/chat/projects.go |
| +++ b/internal/equipo/chat/projects.go |
| @@ -205,8 +205,10 @@ func (t *txn) projectView(p projectRecord) (wire.Project, error) { |
| } |
| v := wire.Project{ID: p.ID, Revision: p.Revision, Repo: p.Repo, Name: ProjectName(p.Repo), Title: title, State: p.State, AddedBy: p.AddedBy, CreatedAt: p.CreatedAt, UpdatedAt: p.UpdatedAt} |
| var err error |
| - v.Attachments, err = t.attachments(p.ID) |
| - return v, err |
| + if v.Attachments, err = t.attachments(p.ID); err != nil { |
| + return v, err |
| + } |
| + return v, t.projectFacts(&v, p) |
| } |
| func (t *txn) cardView(c cardRecord) (wire.Card, error) { |
| @@ -370,6 +372,7 @@ func (t *txn) isOwner(person string) error { |
| // Projects lists the team's active projects and the person's allowlist. |
| func (s *Store) Projects(ctx context.Context, person string) (out wire.ProjectList, err error) { |
| err = s.tx(ctx, func(t *txn) error { |
| + t.viewer = person |
| if err := s.authority.CurrentPerson(ctx, t.db); err != nil { |
| return err |
| } |
diff --git a/internal/equipo/chat/runner.go b/internal/equipo/chat/runner.go| index 1fc4e479..34636966 100644 |
| --- a/internal/equipo/chat/runner.go |
| +++ b/internal/equipo/chat/runner.go |
| @@ -220,6 +220,8 @@ func (s *Store) Apply(ctx context.Context, l Lease, f wire.Frame, body any) erro |
| return t.answer(l, v) |
| case *wire.BranchReport: |
| return t.branchMoved(l, v) |
| + case *wire.StepActivityReport: |
| + return t.stepActivity(l, v) |
| } |
| return ErrInvalid |
| }) |
diff --git a/internal/equipo/chat/store.go b/internal/equipo/chat/store.go| index 187334e4..d47edd72 100644 |
| --- a/internal/equipo/chat/store.go |
| +++ b/internal/equipo/chat/store.go |
| @@ -105,6 +105,10 @@ type txn struct { |
| ctx context.Context |
| db *gorm.DB |
| touched map[string]bool |
| + // viewer is the person a read is for (their runner's catalog first); |
| + // catalogs caches the runners' catalogs by repository. |
| + viewer string |
| + catalogs map[string]wire.RepoInfo |
| } |
| func (t *txn) now() time.Time { return t.s.now() } |
diff --git a/internal/equipo/chat/stream.go b/internal/equipo/chat/stream.go| index 75532b0c..737c98cc 100644 |
| --- a/internal/equipo/chat/stream.go |
| +++ b/internal/equipo/chat/stream.go |
| @@ -153,7 +153,7 @@ func (rc *runnerConn) read(ctx context.Context) websocket.StatusCode { |
| switch v := body.(type) { |
| case *wire.Hello: |
| err = store.Heartbeat(ctx, rc.lease, *v) |
| - case *wire.Sync, *wire.Ack, *wire.DeltaReport, *wire.Reply, *wire.TurnReport, *wire.ToolCall, *wire.ActivityReport, *wire.MoveIn, *wire.NotebookReport, *wire.StepReport, *wire.MergedReport, *wire.AnswerReport, *wire.BranchReport: |
| + case *wire.Sync, *wire.Ack, *wire.DeltaReport, *wire.Reply, *wire.TurnReport, *wire.ToolCall, *wire.ActivityReport, *wire.MoveIn, *wire.NotebookReport, *wire.StepReport, *wire.MergedReport, *wire.AnswerReport, *wire.BranchReport, *wire.StepActivityReport: |
| err = store.Apply(ctx, rc.lease, f, body) |
| case *wire.LeaseCheck: |
| // Answered only while this connection holds the lease. |
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go| index b13964ae..ddbd3808 100644 |
| --- a/internal/equipo/chat/tasks.go |
| +++ b/internal/equipo/chat/tasks.go |
| @@ -55,6 +55,9 @@ type taskRecord struct { |
| MergeStrategy string |
| MergedWithoutChecks bool |
| MergedAt *time.Time |
| + // DuplicateOf is an open task that read like this one when it was |
| + // recorded anyway, or the task it was folded into. |
| + DuplicateOf string |
| } |
| func (taskRecord) TableName() string { return "chat_tasks" } |
| @@ -111,6 +114,8 @@ type stepRecord struct { |
| MergeInto string |
| MergeStrategy string |
| WithoutChecks bool |
| + // Activity is the newest activity lines of the attempt (JSON). |
| + Activity string |
| } |
| func (stepRecord) TableName() string { return "chat_steps" } |
| @@ -270,7 +275,7 @@ func (t *txn) latestStep(taskID string) (stepRecord, bool, error) { |
| func stepView(s stepRecord) wire.Step { |
| return wire.Step{ID: s.ID, Revision: s.Revision, TaskID: s.TaskID, Index: s.Idx, Specialist: s.Specialist, State: s.State, Reason: s.Reason, Attempt: s.Attempt, BaseSHA: s.BaseSHA, CandidateSHA: s.CandidateSHA, Pushed: s.Pushed, Terminated: s.Terminated, Summary: s.Summary, LogTail: s.LogTail, StartedAt: s.StartedAt, FinishedAt: s.FinishedAt, |
| Round: s.Round, Family: s.Family, Account: s.Account, Verdict: s.Verdict, ReviewLabel: s.ReviewLabel, Findings: decodeFindings(s.Findings), Checks: s.Checks, Gate: s.Gate, ExitCode: s.ExitCode, Askable: s.Askable, |
| - Rebase: s.Rebase, MergeSHA: s.MergeSHA, Into: s.MergeInto, Strategy: s.MergeStrategy, WithoutChecks: s.WithoutChecks} |
| + Rebase: s.Rebase, MergeSHA: s.MergeSHA, Into: s.MergeInto, Strategy: s.MergeStrategy, WithoutChecks: s.WithoutChecks, Activity: decodeActivity(s.Activity)} |
| } |
| // taskView is the task with its project, findings, steps and thread. |
| @@ -324,7 +329,7 @@ func (t *txn) taskView(k taskRecord) (wire.Task, error) { |
| if v.Reports, err = reportCount(t.db, k.ID); err != nil { |
| return v, err |
| } |
| - return v, nil |
| + return v, t.taskExtras(&v, k, steps) |
| } |
| // members are the active team members, who all see team records. |
| @@ -342,7 +347,7 @@ func (t *txn) saveTask(k *taskRecord) error { |
| } |
| k.Revision++ |
| k.UpdatedAt = t.now() |
| - if err := t.db.Model(&taskRecord{}).Where("id = ?", k.ID).Select("stage", "base_sha", "cancel_requested", "revision", "updated_at", "moved_from", "branch_head", "merged_sha", "merged_into", "merge_strategy", "merged_without_checks", "merged_at").Updates(k).Error; err != nil { |
| + if err := t.db.Model(&taskRecord{}).Where("id = ?", k.ID).Select("stage", "base_sha", "cancel_requested", "revision", "updated_at", "moved_from", "branch_head", "merged_sha", "merged_into", "merge_strategy", "merged_without_checks", "merged_at", "duplicate_of").Updates(k).Error; err != nil { |
| return err |
| } |
| if wire.FinalStage(k.Stage) && !wire.FinalStage(before) { |
| @@ -378,7 +383,7 @@ func (t *txn) taskEvent(k taskRecord) error { |
| func (t *txn) saveStep(s *stepRecord, k *taskRecord) error { |
| s.Revision++ |
| s.UpdatedAt = t.now() |
| - if err := t.db.Model(&stepRecord{}).Where("id = ?", s.ID).Select("state", "reason", "attempt", "base_sha", "candidate_sha", "pushed", "terminated", "summary", "log_tail", "started_at", "finished_at", "revision", "updated_at", "family", "account", "verdict", "review_label", "findings", "checks", "gate", "exit_code", "output", "republish", "from_attempt", "askable", "rebase", "from_base", "from_candidate", "merge_sha", "merge_into", "merge_strategy", "without_checks").Updates(s).Error; err != nil { |
| + if err := t.db.Model(&stepRecord{}).Where("id = ?", s.ID).Select("state", "reason", "attempt", "base_sha", "candidate_sha", "pushed", "terminated", "summary", "log_tail", "started_at", "finished_at", "revision", "updated_at", "family", "account", "verdict", "review_label", "findings", "checks", "gate", "exit_code", "output", "republish", "from_attempt", "askable", "rebase", "from_base", "from_candidate", "merge_sha", "merge_into", "merge_strategy", "without_checks", "activity").Updates(s).Error; err != nil { |
| return err |
| } |
| members, err := t.members() |
| @@ -432,6 +437,17 @@ func (t *txn) recordTask(r turnRecord, repo, title, brief string, separate bool) |
| now := t.now() |
| k := taskRecord{ID: newTaskID(), ProjectID: p.ID, Title: title, Brief: brief, Stage: wire.StageNoted, Creator: r.Person, TurnID: r.ID, Revision: 1, CreatedAt: now, UpdatedAt: now} |
| k.Branch = wire.TaskBranch(k.ID, title) |
| + if separate { |
| + // Recorded anyway: the most similar open task is named as a |
| + // possible duplicate, for the person to fold it if it is one. |
| + similar, err := t.similarTasks(p.ID, title, brief) |
| + if err != nil { |
| + return wire.ToolResult{}, err |
| + } |
| + if len(similar) > 0 { |
| + k.DuplicateOf = similar[0].ID |
| + } |
| + } |
| if err := t.db.Create(&k).Error; err != nil { |
| return wire.ToolResult{}, err |
| } |
| @@ -1031,6 +1047,7 @@ func (s *Store) RetryTask(ctx context.Context, person, id string) (attempt int64 |
| st.Republish = republish |
| st.State, st.Reason, st.Pushed, st.Terminated, st.Summary, st.LogTail, st.StartedAt, st.FinishedAt = wire.StepQueued, "", false, false, "", "", nil, nil |
| st.Verdict, st.ReviewLabel, st.Findings, st.Checks, st.Gate, st.ExitCode, st.Output, st.Askable = "", "", "", "", "", nil, "", false |
| + st.Activity = "" |
| if st.Specialist == wire.SpecialistEngineering && !republish { |
| // Engineering runs again from the step's base: a new candidate. |
| st.CandidateSHA = "" |
diff --git a/internal/equipo/migrations/0048_thin_ux1.sql b/internal/equipo/migrations/0048_thin_ux1.sql| new file mode 100644 |
| index 00000000..7c543cd1 |
| --- /dev/null |
| +++ b/internal/equipo/migrations/0048_thin_ux1.sql |
| @@ -0,0 +1,2 @@ |
| +ALTER TABLE chat_steps ADD COLUMN activity text; |
| +ALTER TABLE chat_tasks ADD COLUMN duplicate_of text; |
diff --git a/internal/equipo/migrations/schema.sql b/internal/equipo/migrations/schema.sql| index 1f4dee4b..5cf0a7bd 100644 |
| --- a/internal/equipo/migrations/schema.sql |
| +++ b/internal/equipo/migrations/schema.sql |
| @@ -592,9 +592,9 @@ CREATE TABLE chat_coordinators (person text PRIMARY KEY, state text, turn_id tex |
| CREATE TABLE chat_notebooks (person text PRIMARY KEY, entries text, revision integer, updated_at datetime); |
| CREATE INDEX chat_card_task ON chat_cards(task_id); |
| CREATE TABLE chat_project_attachments (project_id text, kind text, ref text, name text, created_at datetime, PRIMARY KEY (project_id, kind, ref)); |
| -CREATE TABLE chat_tasks (id text PRIMARY KEY, project_id text, title text, brief text, stage text, branch text, base_sha text, creator text, turn_id text, cancel_requested numeric, revision integer, created_at datetime, updated_at datetime, watching text, moved_from text, branch_head text, merge_asked text, merged_sha text, merged_into text, merge_strategy text, merged_without_checks numeric, merged_at datetime); |
| +CREATE TABLE chat_tasks (id text PRIMARY KEY, project_id text, title text, brief text, stage text, branch text, base_sha text, creator text, turn_id text, cancel_requested numeric, revision integer, created_at datetime, updated_at datetime, watching text, moved_from text, branch_head text, merge_asked text, merged_sha text, merged_into text, merge_strategy text, merged_without_checks numeric, merged_at datetime, duplicate_of text); |
| CREATE INDEX chat_task_project ON chat_tasks(project_id); |
| -CREATE TABLE chat_steps (id text PRIMARY KEY, task_id text, idx integer, specialist text, person text, state text, reason text, attempt integer, base_sha text, candidate_sha text, pushed numeric, terminated numeric, summary text, log_tail text, started_at datetime, finished_at datetime, revision integer, created_at datetime, updated_at datetime, round integer, family text, account text, verdict text, review_label text, findings text, checks text, gate text, exit_code integer, output text, republish numeric, from_attempt integer, askable numeric, rebase numeric, from_base text, from_candidate text, merge_sha text, merge_into text, merge_strategy text, without_checks numeric); |
| +CREATE TABLE chat_steps (id text PRIMARY KEY, task_id text, idx integer, specialist text, person text, state text, reason text, attempt integer, base_sha text, candidate_sha text, pushed numeric, terminated numeric, summary text, log_tail text, started_at datetime, finished_at datetime, revision integer, created_at datetime, updated_at datetime, round integer, family text, account text, verdict text, review_label text, findings text, checks text, gate text, exit_code integer, output text, republish numeric, from_attempt integer, askable numeric, rebase numeric, from_base text, from_candidate text, merge_sha text, merge_into text, merge_strategy text, without_checks numeric, activity text); |
| CREATE INDEX chat_step_task ON chat_steps(task_id); |
| CREATE TABLE chat_task_entries (id text PRIMARY KEY, task_id text, idempotency_key text, kind text, author text, text text, repo text, path text, line integer, created_at datetime); |
| CREATE INDEX chat_entry_task ON chat_task_entries(task_id); |
diff --git a/internal/thintest/client.go b/internal/thintest/client.go| index 3d44843f..a1cd0d02 100644 |
| --- a/internal/thintest/client.go |
| +++ b/internal/thintest/client.go |
| @@ -133,6 +133,11 @@ func (c *Client) CancelTask(ctx context.Context, id string) (out wire.TaskAccept |
| return out, c.do(ctx, "POST", "/api/v1/tasks/"+id+"/cancel", nil, &out) |
| } |
| +// MarkDuplicate folds the task into another open task of its project. |
| +func (c *Client) MarkDuplicate(ctx context.Context, id, of string) (out wire.Task, err error) { |
| + return out, c.do(ctx, "POST", "/api/v1/tasks/"+id+"/duplicate", wire.MarkDuplicate{Of: of}, &out) |
| +} |
| + |
| // RetryTask starts a new attempt once the last one's termination is known. |
| func (c *Client) RetryTask(ctx context.Context, id string) (out wire.TaskAccepted, err error) { |
| return out, c.do(ctx, "POST", "/api/v1/tasks/"+id+"/retry", nil, &out) |
| @@ -248,6 +253,8 @@ type Conversation struct { |
| Stages map[string][]string |
| // Activity is each turn's activity in arrival order, until its reply. |
| Activity map[string][]wire.Activity |
| + // StepActivity is each step's activity events in arrival order. |
| + StepActivity map[string][]wire.StepActivity |
| // FirstDelta records when each turn's first delta arrived; |
| // FirstActivity when its first activity line did. |
| FirstDelta map[string]time.Time |
| @@ -264,7 +271,7 @@ type Conversation struct { |
| } |
| func NewConversation(s wire.Snapshot) *Conversation { |
| - c := &Conversation{Messages: map[string]wire.Message{}, Turns: map[string]wire.Turn{}, Drafts: map[string]string{}, FirstDelta: map[string]time.Time{}, FirstActivity: map[string]time.Time{}, Activity: map[string][]wire.Activity{}, changed: make(chan struct{})} |
| + c := &Conversation{Messages: map[string]wire.Message{}, Turns: map[string]wire.Turn{}, Drafts: map[string]string{}, FirstDelta: map[string]time.Time{}, FirstActivity: map[string]time.Time{}, Activity: map[string][]wire.Activity{}, StepActivity: map[string][]wire.StepActivity{}, changed: make(chan struct{})} |
| c.Reset(s) |
| return c |
| } |
| @@ -414,7 +421,13 @@ func (c *Conversation) Apply(e wire.Event) bool { |
| } |
| case wire.EventActivity: |
| var a wire.Activity |
| - if json.Unmarshal(e.Data, &a) == nil { |
| + if e.Resource == wire.ResourceStep { |
| + var sa wire.StepActivity |
| + if wire.Strict(e.Data, &sa) == nil { |
| + c.StepActivity[sa.StepID] = append(c.StepActivity[sa.StepID], sa) |
| + applied = true |
| + } |
| + } else if json.Unmarshal(e.Data, &a) == nil { |
| if _, ok := c.FirstActivity[a.TurnID]; !ok { |
| c.FirstActivity[a.TurnID] = time.Now() |
| } |
diff --git a/internal/thintest/inner_contract_test.go b/internal/thintest/inner_contract_test.go| new file mode 100644 |
| index 00000000..cfe06ffa |
| --- /dev/null |
| +++ b/internal/thintest/inner_contract_test.go |
| @@ -0,0 +1,246 @@ |
| +package thintest |
| + |
| +import ( |
| + "net/http" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// activity sends one step activity line (not durable: no ack). |
| +func (r *toolRig) activity(id string, a wire.StepActivityReport) { |
| + r.t.Helper() |
| + if err := r.runner.Send(r.ctx, id, wire.FrameStepActivity, a); err != nil { |
| + r.t.Fatal(err) |
| + } |
| +} |
| + |
| +// TestContractStepActivity: a running step's activity lines come only |
| +// from the step person's primary runner, for the current attempt; the |
| +// newest five are kept on the step and every member gets each line as |
| +// an activity event; a new attempt starts with none. |
| +func TestContractStepActivity(t *testing.T) { |
| + a := newToolRig(t) |
| + ctx := a.ctx |
| + b := personToolRig(t, a, "second@example.com", equipo.RoleOwner) |
| + id := taskID(t, a.call("k1", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Swipe back from the edge does nothing", "brief": "x"})) |
| + a.call("k2", wire.ToolStartTask, map[string]string{"task": id, "brief": "go"}) |
| + _, body := a.expect(wire.FrameDispatch) |
| + d := body.(*wire.DispatchCommand) |
| + a.step("r-s1", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: strings.Repeat("1", 40)}) |
| + |
| + // Another person's runner, about A's step: dropped. B's own turn |
| + // activity after it shows B's frame was applied first. |
| + if err := b.runner.Send(ctx, "b-act", wire.FrameStepActivity, wire.StepActivityReport{TaskID: id, StepID: d.StepID, Attempt: 1, Kind: wire.ActivityRead, Subject: "secret.go"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := b.runner.Send(ctx, "b-turn", wire.FrameActivity, wire.ActivityReport{TurnID: b.turn, Attempt: 1, Kind: wire.ActivityThink}); err != nil { |
| + t.Fatal(err) |
| + } |
| + b.wait("B turn activity", func(c *Conversation) bool { return len(c.Activity[b.turn]) > 0 }) |
| + // A stale attempt: dropped. |
| + a.activity("a-stale", wire.StepActivityReport{TaskID: id, StepID: d.StepID, Attempt: 2, Kind: wire.ActivityRead, Subject: "stale.go"}) |
| + lines := []wire.StepActivityReport{ |
| + {Kind: wire.ActivityRead, Subject: "/workspace/panes/swipe.go"}, |
| + {Kind: wire.ActivitySearch, Subject: "EdgeSwipe"}, |
| + {Kind: "launch_missiles", Subject: "x"}, |
| + {Kind: wire.ActivityEdit, Subject: "panes/swipe.go"}, |
| + {Kind: wire.ActivityRun, Subject: "go test ./panes\nrm -rf /"}, |
| + {Kind: wire.ActivityRun, Subject: "make \x1b[31mci" + strings.Repeat("x", 300)}, |
| + {Kind: wire.ActivityEdit, Subject: "panes/swipe_test.go"}, |
| + } |
| + for i, l := range lines { |
| + l.TaskID, l.StepID, l.Attempt = id, d.StepID, 1 |
| + a.activity("a-act-"+itoa(i), l) |
| + } |
| + for _, r := range []*toolRig{a, b} { |
| + r.wait("every line, to every member", func(c *Conversation) bool { return len(c.StepActivity[d.StepID]) == len(lines) }) |
| + } |
| + var got []wire.StepActivity |
| + a.conv.Locked(func(c *Conversation) { got = c.StepActivity[d.StepID] }) |
| + first, last := got[0].Activity, got[len(got)-1].Activity |
| + if len(first) != 1 || first[0].Kind != wire.ActivityRead || first[0].Subject != "panes/swipe.go" || first[0].At.IsZero() || got[0].TaskID != id || got[0].Attempt != 1 { |
| + t.Fatalf("first line %+v", got[0]) |
| + } |
| + if len(last) != wire.MaxStepActivity || last[0].Kind != wire.ActivityOther || last[2].Subject != "go test ./panes" || strings.ContainsRune(last[3].Subject, 0x1b) || len(last[3].Subject) > wire.MaxActivitySubject || last[4].Subject != "panes/swipe_test.go" { |
| + t.Fatalf("kept lines %+v", last) |
| + } |
| + for _, e := range got { |
| + for _, l := range e.Activity { |
| + if l.Subject == "secret.go" || l.Subject == "stale.go" { |
| + t.Fatalf("a dropped line was kept: %+v", e) |
| + } |
| + } |
| + } |
| + k, err := a.client.Task(ctx, id) |
| + if err != nil || len(k.Steps[0].Activity) != wire.MaxStepActivity || k.Steps[0].Activity[4].Subject != "panes/swipe_test.go" { |
| + t.Fatalf("step activity on the task: %+v %v", k.Steps, err) |
| + } |
| + // The step keeps its last lines after it ends; a retry starts afresh. |
| + a.step("r-s2", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepFailed, Reason: "runner_restarted", Termination: true}) |
| + if k, _ := a.client.Task(ctx, id); len(k.Steps[0].Activity) != wire.MaxStepActivity { |
| + t.Fatalf("ended step lost its lines: %+v", k.Steps[0]) |
| + } |
| + a.activity("a-after", wire.StepActivityReport{TaskID: id, StepID: d.StepID, Attempt: 1, Kind: wire.ActivityRead, Subject: "late.go"}) |
| + if _, err := a.client.RetryTask(ctx, id); err != nil { |
| + t.Fatal(err) |
| + } |
| + a.expect(wire.FrameDispatch) |
| + k, _ = a.client.Task(ctx, id) |
| + if len(k.Steps[0].Activity) != 0 || k.Steps[0].Attempt != 2 { |
| + t.Fatalf("retry kept the old activity: %+v", k.Steps[0]) |
| + } |
| +} |
| + |
| +// TestContractTaskSourceAndDuplicates: a task names its creator, the |
| +// message it was noted from and the coordinator looking into it; a task |
| +// recorded anyway beside a similar open one names it as a possible |
| +// duplicate, and only its creator may fold it into that one. |
| +func TestContractTaskSourceAndDuplicates(t *testing.T) { |
| + a := newToolRig(t) |
| + ctx := a.ctx |
| + b := personToolRig(t, a, "second@example.com", equipo.RoleOwner) |
| + first := taskID(t, a.call("k1", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Swipe back from the edge does nothing", "brief": "On iOS, swiping from the left edge does not go back."})) |
| + var source wire.Message |
| + a.conv.Locked(func(c *Conversation) { |
| + for _, m := range c.Messages { |
| + if m.Role == wire.RolePerson && m.TurnID == a.turn { |
| + source = m |
| + } |
| + } |
| + }) |
| + k, err := a.client.Task(ctx, first) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if k.CreatorName != "Owner" || source.ID == "" || k.SourceMessageID != source.ID || k.SourceAt == nil || !k.SourceAt.Equal(source.CreatedAt) { |
| + t.Fatalf("creator and source: %q %q %v, message %+v", k.CreatorName, k.SourceMessageID, k.SourceAt, source) |
| + } |
| + if k.Coordinator == nil || k.Coordinator.Kind != wire.CoordinatorLooking || k.Coordinator.Since.IsZero() || k.DuplicateOf != nil { |
| + t.Fatalf("coordinator looking: %+v dup %+v", k.Coordinator, k.DuplicateOf) |
| + } |
| + |
| + similar := map[string]any{"repo": "oficina/sample", "title": "Swipe from the edge to go back does nothing", "brief": "Swiping from the left edge does not go back on iOS."} |
| + if res := a.call("k2", wire.ToolRecordTask, similar); res.Code == "recorded" { |
| + t.Fatalf("a similar task was recorded: %+v", res) |
| + } |
| + similar["separate"] = true |
| + second := taskID(t, a.call("k3", wire.ToolRecordTask, similar)) |
| + k, _ = a.client.Task(ctx, second) |
| + if k.DuplicateOf == nil || k.DuplicateOf.ID != first || k.DuplicateOf.Title != "Swipe back from the edge does nothing" || k.DuplicateOf.Stage != wire.StageNoted { |
| + t.Fatalf("duplicate_of: %+v", k.DuplicateOf) |
| + } |
| + other := taskID(t, a.call("k4", wire.ToolRecordTask, map[string]string{"repo": "oficina/equipo", "title": "Rename the coordinator", "brief": "y"})) |
| + |
| + // Only the creator folds a task, into another open task of its project. |
| + if _, err := b.client.MarkDuplicate(ctx, second, first); Status(err) != http.StatusForbidden { |
| + t.Fatalf("another person folded it: %v", err) |
| + } |
| + for of, want := range map[string]int{second: 422, "": 422, other: 422, "tknope": 404} { |
| + if _, err := a.client.MarkDuplicate(ctx, second, of); Status(err) != want { |
| + t.Fatalf("fold into %q: %v, want %d", of, err, want) |
| + } |
| + } |
| + folded, err := a.client.MarkDuplicate(ctx, second, first) |
| + if err != nil || folded.Stage != wire.StageCancelled || folded.DuplicateOf == nil || folded.DuplicateOf.ID != first { |
| + t.Fatalf("fold: %+v %v", folded, err) |
| + } |
| + k, _ = a.client.Task(ctx, first) |
| + if len(k.Thread) != 1 || k.Thread[0].Author != Owner || !strings.Contains(k.Thread[0].Text, "Swipe from the edge to go back does nothing") || !strings.Contains(k.Thread[0].Text, "on iOS.") || k.Reports != 1 { |
| + t.Fatalf("report on the kept task: %+v reports %d", k.Thread, k.Reports) |
| + } |
| + if _, err := a.client.MarkDuplicate(ctx, second, first); Status(err) != http.StatusConflict { |
| + t.Fatalf("fold an ended task: %v", err) |
| + } |
| + b.wait("B sees the fold", func(c *Conversation) bool { return c.Tasks[second].Stage == wire.StageCancelled }) |
| +} |
| + |
| +// TestContractCoordinatorMerging: while Equipo merges a task, the task |
| +// says the coordinator is merging it, since the merge step started. |
| +func TestContractCoordinatorMerging(t *testing.T) { |
| + r := newToolRig(t) |
| + base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40) |
| + id := r.judgedTask("a", "Fix the README typo", base, cand, wire.ChecksPassed, "") |
| + _, body := r.expect(wire.FrameDispatch) |
| + m := body.(*wire.DispatchCommand) |
| + r.step("mg-run", wire.StepReport{TaskID: id, StepID: m.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: base, CandidateSHA: cand}) |
| + k, _ := r.client.Task(r.ctx, id) |
| + started := k.Steps[len(k.Steps)-1].StartedAt |
| + if k.Stage != wire.StageMerging || k.Coordinator == nil || k.Coordinator.Kind != wire.CoordinatorMerging || started == nil || !k.Coordinator.Since.Equal(*started) { |
| + t.Fatalf("merging: %s %+v started %v steps %d", k.Stage, k.Coordinator, started, len(k.Steps)) |
| + } |
| + r.mergedStep("mg-m", m, strings.Repeat("e", 40)) |
| + r.wait("done", func(c *Conversation) bool { return c.Tasks[id].Stage == wire.StageDone }) |
| + if k, _ := r.client.Task(r.ctx, id); k.Coordinator != nil { |
| + t.Fatalf("done task still busy: %+v", k.Coordinator) |
| + } |
| +} |
| + |
| +// TestContractProjectFacts: a project says what the runners' index knows |
| +// of it (description, stack, whether checks run, the default branch's |
| +// newest commit) and who is involved; a repository no index knows has no |
| +// facts, never invented ones. |
| +func TestContractProjectFacts(t *testing.T) { |
| + a := newToolRig(t) |
| + ctx := a.ctx |
| + head := time.Date(2026, 11, 7, 9, 30, 0, 0, time.UTC) |
| + hello := wire.Hello{Generation: a.runner.Welcome.Generation, Repos: []string{"amadan.net/oficina/sample", "amadan.net/oficina/equipo"}, CreateIn: []string{"oficina"}, Agent: "equipo-test", Catalog: []wire.RepoInfo{{Repo: "amadan.net/oficina/sample", DefaultBranch: "main", Summary: "Woodstar is a reading app.", Names: []string{"sample", "Woodstar"}, Hints: []string{"swift", "swiftui", "unknown"}, UpdatedAt: head, HeadSHA: strings.Repeat("3", 40), HeadSubject: "Trim the compose sheet", ChecksReason: "needs_macos"}}, Accounts: []wire.Account{{ID: "claude-a", Provider: "claude", Email: Owner, Healthy: true}}, Versions: map[string]string{"runner": "test", "claude": "2.1.312"}} |
| + if err := a.runner.Send(ctx, "h2", wire.FrameHello, hello); err != nil { |
| + t.Fatal(err) |
| + } |
| + b := personToolRig(t, a, "nora.k@example.com", equipo.RoleOwner) |
| + taskID(t, a.call("k1", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Timeline jumps", "brief": "x"})) |
| + taskID(t, b.call("k2", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Images load late", "brief": "y"})) |
| + taskID(t, a.call("k3", wire.ToolRecordTask, map[string]string{"repo": "oficina/equipo", "title": "Rename the coordinator", "brief": "z"})) |
| + list, err := a.client.Projects(ctx) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var sample, equipoP wire.Project |
| + for _, p := range list.Items { |
| + switch p.Repo { |
| + case "amadan.net/oficina/sample": |
| + sample = p |
| + case "amadan.net/oficina/equipo": |
| + equipoP = p |
| + } |
| + } |
| + if sample.Description != "Woodstar is a reading app." || strings.Join(sample.Stack, ",") != "Swift,SwiftUI" || sample.Checks == nil || sample.Checks.Here || sample.Checks.Reason != "needs_macos" { |
| + t.Fatalf("sample facts: %+v %+v", sample, sample.Checks) |
| + } |
| + at := sample.Attachments[0] |
| + if at.DefaultBranch != "main" || at.HeadSHA != strings.Repeat("3", 40) || at.HeadSubject != "Trim the compose sheet" || at.HeadAt == nil || !at.HeadAt.Equal(head) { |
| + t.Fatalf("attachment head: %+v", at) |
| + } |
| + if len(sample.People) != 2 || sample.People[0].Address != Owner || sample.People[0].Name != "Owner" || sample.People[1].Name != "Nora" || sample.People[1].Initials != "N" { |
| + t.Fatalf("people: %+v", sample.People) |
| + } |
| + if equipoP.Checks != nil || equipoP.Description != "" || len(equipoP.Stack) != 0 || equipoP.Attachments[0].HeadSHA != "" { |
| + t.Fatalf("invented facts: %+v", equipoP) |
| + } |
| + // A gate this runner can run: checks run here. |
| + hello.Catalog[0].ChecksReason, hello.Catalog[0].Gate, hello.Catalog[0].Hints = "", "make ci", []string{"go"} |
| + if err := a.runner.Send(ctx, "h3", wire.FrameHello, hello); err != nil { |
| + t.Fatal(err) |
| + } |
| + deadline := time.Now().Add(5 * time.Second) |
| + for { |
| + list, _ = a.client.Projects(ctx) |
| + var c *wire.ProjectChecks |
| + for _, p := range list.Items { |
| + if p.Repo == "amadan.net/oficina/sample" { |
| + c = p.Checks |
| + } |
| + } |
| + if c != nil && c.Here && c.Gate == "make ci" && c.Reason == "" { |
| + break |
| + } |
| + if time.Now().After(deadline) { |
| + t.Fatalf("checks here: %+v", c) |
| + } |
| + time.Sleep(20 * time.Millisecond) |
| + } |
| +} |