Report actual specialist status instead of overall task stage
Added execution snapshots to report, start and read tools, distinguishing queued, running, stopped, retrying, held, completed and uncertain states with attempt numbers, timestamps and safe reasons. Instructions now require fresh evidence and explicitly warn that a later retry cannot disprove an earlier stopped report; scheduling and cancellation are unchanged. Chat tests and build, vet, formatting, budget and migration checks passed. Full validation remains incomplete because static-check dependencies were unavailable offline and the dead-reference check required Git. Equipo task tkymiebhgecg, Engineering step attempt 1.
5 files changed,
+220
−8
.rastrillo/budgets.txt+1 −1internal/equipo/chat/execution.go+102 −0internal/equipo/chat/execution_test.go+97 −0internal/equipo/chat/merge.go+5 −1internal/equipo/chat/tasks.go+15 −6
CI passed — run details
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt| index cd84f0e1..ea10d129 100644 |
| --- a/.rastrillo/budgets.txt |
| +++ b/.rastrillo/budgets.txt |
| @@ -56,7 +56,7 @@ perf GET /api/v1/tasks/{id} skip Thin v1 person API: bearer-only JSON for device |
| perf GET /api/v1/assistant/snapshot skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen. |
| perf GET /api/v1/assistant/messages skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen. |
| perf GET /api/v1/assistant/events skip Assistant event stream (Server-Sent Events), bearer-only and long-lived; not a screen. |
| -size internal/equipo/chat 30698 - Transactional access visit, reconnect catch-up and continuation presentation. Measured 30698 source lines. |
| +size internal/equipo/chat 30813 - Transactional access visit, reconnect catch-up and continuation presentation; execution snapshots share private step and runner projections in the transaction. Measured 30813 source lines. |
| perf GET /api/v1/questions/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads questions on /tasks/{id}. |
| perf GET /api/v1/steps/{id}/log skip Thin v1 person API: bearer-only JSON for devices; the browser shows the log tail on /tasks/{id}. |
| perf GET /api/v1/connections/preference skip Connections slice 1 person API: bearer-only JSON for devices; the browser shows the preference on /conversation/connections. |
diff --git a/internal/equipo/chat/execution.go b/internal/equipo/chat/execution.go| new file mode 100644 |
| index 00000000..4f456fde |
| --- /dev/null |
| +++ b/internal/equipo/chat/execution.go |
| @@ -0,0 +1,102 @@ |
| +package chat |
| + |
| +import ( |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// Execution is observation, not task workflow. Retry resets the stored attempt, |
| +// so this projection deliberately makes no claims about earlier attempts. |
| +type executionSnapshot struct { |
| + ObservedAt time.Time `json:"observed_at"` |
| + Steps []executionStep `json:"steps"` |
| + Note string `json:"note"` |
| +} |
| + |
| +type executionStep struct { |
| + ID string `json:"step"` |
| + Specialist string `json:"specialist"` |
| + Attempt int64 `json:"attempt"` |
| + State string `json:"state"` |
| + ReportedState string `json:"reported_state"` |
| + At *time.Time `json:"evidence_at,omitempty"` |
| + Reason string `json:"reason,omitempty"` |
| + Retrying bool `json:"retrying,omitempty"` |
| +} |
| + |
| +// A recent start/activity report is evidence of work, not merely a live |
| +// connection or a task update. Silence is uncertainty, never proof of a stop. |
| +const executionFreshness = 5 * time.Minute |
| + |
| +func projectExecution(s stepRecord, online bool, now time.Time) executionStep { |
| + v := stepViewSwitched(s) // same state and scheduler hold as the task UI |
| + x := executionStep{ID: v.ID, Specialist: v.Specialist, Attempt: v.Attempt, State: "unknown", ReportedState: v.State, At: &s.UpdatedAt} |
| + if wire.StepReasons[v.Reason] { |
| + x.Reason = v.Reason |
| + } |
| + switch v.State { |
| + case wire.StepDone: |
| + x.State, x.At = "completed", v.FinishedAt |
| + case wire.StepFailed, wire.StepCancelled: |
| + x.State, x.At = "stopped", v.FinishedAt |
| + case wire.StepQueued, wire.StepRunning: |
| + x.Retrying = v.Attempt > 1 |
| + if v.Hold != nil { |
| + x.State, x.At = "held", s.HeldAt |
| + if wire.HoldReasons[v.Hold.Reason] { |
| + x.Reason = v.Hold.Reason |
| + } |
| + } else if v.Placement == wire.PlacementResearch { |
| + x.State, x.Reason = "held", "waiting_for_research" |
| + } else if v.State == wire.StepQueued { |
| + x.State = "queued" |
| + switch v.Placement { |
| + case wire.PlacementWaiting, wire.PlacementSandbox: |
| + x.Reason = v.Placement |
| + case wire.PlacementBoundary, wire.PlacementSources, wire.PlacementInventory: |
| + x.State, x.Reason = "held", v.Placement |
| + } |
| + if x.Retrying && x.State == "queued" { |
| + x.State = "retrying" |
| + } |
| + } else { |
| + x.At = v.StartedAt |
| + for _, a := range v.Activity { |
| + if x.At == nil || a.At.After(*x.At) { |
| + at := a.At |
| + x.At = &at |
| + } |
| + } |
| + x.State, x.Reason = "stale/unknown", "no_recent_step_evidence" |
| + if !online { |
| + x.Reason = "runner_offline_or_unknown" |
| + } else if x.At != nil && !x.At.After(now) && now.Sub(*x.At) <= executionFreshness { |
| + x.State, x.Reason = "running", "" |
| + } |
| + } |
| + } |
| + return x |
| +} |
| + |
| +func (t *txn) execution(taskID string) (executionSnapshot, error) { |
| + out := executionSnapshot{ObservedAt: t.now(), Steps: []executionStep{}, Note: "Task stage is not execution status. Running requires fresh step evidence and an online runner. This snapshot cannot establish earlier attempt states or stop reasons; retries replace attempt details. A later running attempt does not refute an earlier stopped report. Re-read before claiming active work."} |
| + steps, err := t.steps(taskID) |
| + if err != nil { |
| + return out, err |
| + } |
| + for _, s := range steps { |
| + if s.Retired { |
| + continue |
| + } |
| + online := false |
| + if s.State == wire.StepRunning { |
| + online, err = t.runnerOnline(s.Person, s.RunnerID) |
| + if err != nil { |
| + return out, err |
| + } |
| + } |
| + out.Steps = append(out.Steps, projectExecution(s, online, out.ObservedAt)) |
| + } |
| + return out, nil |
| +} |
diff --git a/internal/equipo/chat/execution_test.go b/internal/equipo/chat/execution_test.go| new file mode 100644 |
| index 00000000..dd1bf33f |
| --- /dev/null |
| +++ b/internal/equipo/chat/execution_test.go |
| @@ -0,0 +1,97 @@ |
| +package chat |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "testing" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +func TestExecutionEvidence(t *testing.T) { |
| + now := time.Date(2026, 11, 17, 17, 15, 0, 0, time.UTC) |
| + recent, old := now.Add(-time.Minute), now.Add(-time.Hour) |
| + for _, tc := range []struct { |
| + name string |
| + step stepRecord |
| + online bool |
| + state, reason string |
| + }{ |
| + {"stopped despite in_progress task", stepRecord{State: wire.StepFailed, Reason: "push_failed", FinishedAt: &recent}, true, "stopped", "push_failed"}, |
| + {"assignment is queued", stepRecord{State: wire.StepQueued}, true, "queued", ""}, |
| + {"retry queued", stepRecord{State: wire.StepQueued, Attempt: 2}, true, "retrying", ""}, |
| + {"retry running", stepRecord{State: wire.StepRunning, Attempt: 2, StartedAt: &recent}, true, "running", ""}, |
| + {"stale connected", stepRecord{State: wire.StepRunning, StartedAt: &old, UpdatedAt: now}, true, "stale/unknown", "no_recent_step_evidence"}, |
| + {"disconnected", stepRecord{State: wire.StepRunning, StartedAt: &recent}, false, "stale/unknown", "runner_offline_or_unknown"}, |
| + {"current activity", stepRecord{State: wire.StepRunning, StartedAt: &old, Activity: asJSON([]wire.ActivityLine{{At: recent, Kind: wire.ActivityRead}})}, true, "running", ""}, |
| + {"research hold", stepRecord{State: wire.StepQueued, Placement: wire.PlacementResearch}, true, "held", "waiting_for_research"}, |
| + {"scheduler hold", stepRecord{State: wire.StepRunning, Hold: asJSON(wire.StepHold{Reason: wire.HoldHeadroom}), HeldAt: &recent}, true, "held", wire.HoldHeadroom}, |
| + {"completed", stepRecord{State: wire.StepDone, FinishedAt: &recent}, false, "completed", ""}, |
| + {"unknown", stepRecord{State: "unrecognized", Reason: "private arbitrary text"}, true, "unknown", ""}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + tc.step.ID, tc.step.Specialist = "step", wire.SpecialistEngineering |
| + got := projectExecution(tc.step, tc.online, now) |
| + if got.State != tc.state || got.Reason != tc.reason || got.Attempt != tc.step.Attempt || got.ReportedState != tc.step.State { |
| + t.Fatalf("snapshot: %+v", got) |
| + } |
| + if tc.name == "current activity" && (got.At == nil || !got.At.Equal(recent)) { |
| + t.Fatalf("activity timestamp: %+v", got) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestExecutionToolSnapshots(t *testing.T) { |
| + for _, tool := range []string{"start", "report", "read"} { |
| + t.Run(tool, func(t *testing.T) { |
| + r := placementRig(t) |
| + if tool != "start" { |
| + if err := r.s.db.G.Model(&taskRecord{}).Where("id = ?", "tk_move").Update("stage", wire.StageInProgress).Error; err != nil { |
| + t.Fatal(err) |
| + } |
| + st := stepRecord{ID: "stopped", TaskID: "tk_move", Specialist: wire.SpecialistEngineering, State: wire.StepFailed, Reason: "push_failed", Attempt: 1} |
| + if err := r.s.db.G.Create(&st).Error; err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + err := r.s.tx(context.Background(), func(tx *txn) error { |
| + turn := turnRecord{ID: "turn", Person: hkOwner} |
| + var result wire.ToolResult |
| + var err error |
| + switch tool { |
| + case "start": |
| + result, err = tx.startTask(turn, "tk_move", "") |
| + case "report": |
| + result, err = tx.addReport(turn, json.RawMessage(`{"task":"tk_move","text":"It showed stopped."}`)) |
| + case "read": |
| + result, err = tx.readTask("tk_move") |
| + } |
| + if err != nil { |
| + return err |
| + } |
| + var out struct { |
| + Execution executionSnapshot `json:"execution"` |
| + } |
| + if err := json.Unmarshal([]byte(result.Text), &out); err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(out.Execution.Steps) != 1 { |
| + t.Fatalf("missing snapshot: %s", result.Text) |
| + } |
| + want := "stopped" |
| + if tool == "start" { |
| + want = "queued" |
| + } |
| + if out.Execution.Steps[0].State != want { |
| + t.Fatalf("snapshot: %s", result.Text) |
| + } |
| + return nil |
| + }) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/equipo/chat/merge.go b/internal/equipo/chat/merge.go| index 0a1118a2..dc462ca6 100644 |
| --- a/internal/equipo/chat/merge.go |
| +++ b/internal/equipo/chat/merge.go |
| @@ -416,7 +416,11 @@ func (t *txn) addReport(r turnRecord, args json.RawMessage) (wire.ToolResult, er |
| if err := t.cardEvent(c); err != nil { |
| return wire.ToolResult{}, err |
| } |
| - raw, _ := json.Marshal(map[string]string{"task": k.ID, "title": k.Title, "link": TaskLink(k.ID), "stage": k.Stage, "note": toolReportAdded}) |
| + execution, err := t.execution(k.ID) |
| + if err != nil { |
| + return wire.ToolResult{}, err |
| + } |
| + raw, _ := json.Marshal(map[string]any{"task": k.ID, "title": k.Title, "link": TaskLink(k.ID), "stage": k.Stage, "execution": execution, "note": toolReportAdded}) |
| return wire.ToolResult{Code: "reported", Text: string(raw)}, nil |
| } |
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go| index 4517a454..927da9bf 100644 |
| --- a/internal/equipo/chat/tasks.go |
| +++ b/internal/equipo/chat/tasks.go |
| @@ -328,13 +328,13 @@ const ( |
| toolNoTask = "No such task. Use the task id record_task returned." |
| toolTaskEnded = "That task is done or cancelled." |
| toolTaskStarted = "That task already has its Engineering step. Use read_task to see how it is going." |
| - toolStarted = "Engineering is working on it on the task's branch; then the change is checked and reviewed, and the person decides whether it merges. Reply in one or two lines at the outcome level, naming the task as a markdown link, and do not wait." |
| + toolStarted = "Engineering has been assigned to the task's branch. Assignment does not mean running. Report the execution snapshot, not the task stage; then the change is checked and reviewed, and the person decides whether it merges. Reply in one or two lines at the outcome level, naming the task as a markdown link, and do not wait." |
| toolFindingSaved = "Attached to the task." |
| toolCancelAsked = "Cancelling. The person sees it on the task card." |
| toolNotOwner = "Only an owner's runner can run work." |
| toolNotYours = "That task is another person's: you may read it, but only the person who asked for it can change, start or cancel it." |
| - toolSimilar = "Nothing was recorded: these open tasks in the same project look like the same problem. If one of them is, call add_report with its task id and the person's words, then tell the person in one line that it is already logged, naming it as a markdown link [title](link), and where it stands. If this really is a different problem, call record_task again with separate: true." |
| - toolReportAdded = "Added the person's report to this task. Tell them in one line that it is already logged, naming it as a markdown link [title](link), and where it stands. Do not record it again." |
| + toolSimilar = "Nothing was recorded: these open tasks in the same project look like the same problem. If one of them is, call add_report with its task id and the person's words, then tell the person in one line that it is already logged, naming it as a markdown link [title](link), and where it stands from fresh step evidence in the execution snapshot, not from task stage or assignment. If this really is a different problem, call record_task again with separate: true." |
| + toolReportAdded = "Added the person's report to this task. Tell them in one line that it is already logged, naming it as a markdown link [title](link), and where it stands using the execution snapshot, never inferring running from task stage. Do not record it again." |
| toolMerging = "Equipo is merging that task now, so it cannot be cancelled. It ends Done, or back at Ready to merge if the merge is refused." |
| toolTaskEndedReport = "That task is done or cancelled. If the problem is back, record a new task with record_task and separate: true." |
| ) |
| @@ -979,7 +979,11 @@ func (t *txn) startTask(r turnRecord, id, brief string) (wire.ToolResult, error) |
| if err := t.saveStep(&s, &k); err != nil { |
| return wire.ToolResult{}, err |
| } |
| - raw, _ := json.Marshal(map[string]string{"task": k.ID, "title": k.Title, "link": TaskLink(k.ID), "note": toolStarted}) |
| + execution, err := t.execution(k.ID) |
| + if err != nil { |
| + return wire.ToolResult{}, err |
| + } |
| + raw, _ := json.Marshal(map[string]any{"task": k.ID, "title": k.Title, "link": TaskLink(k.ID), "execution": execution, "note": toolStarted}) |
| return wire.ToolResult{Code: "started", Text: string(raw)}, nil |
| } |
| @@ -1162,10 +1166,15 @@ func (t *txn) readTask(id string) (wire.ToolResult, error) { |
| // The questions and answers are the person's with the specialists; |
| // the coordinator points people there and never relays them. |
| v.Questions = []wire.Question{} |
| + execution, err := t.execution(k.ID) |
| + if err != nil { |
| + return wire.ToolResult{}, err |
| + } |
| raw, _ := json.Marshal(struct { |
| - Link string `json:"link"` |
| + Execution executionSnapshot `json:"execution"` |
| + Link string `json:"link"` |
| wire.Task |
| - }{TaskLink(v.ID), v}) |
| + }{execution, TaskLink(v.ID), v}) |
| return wire.ToolResult{Code: "task", Text: clipText(string(raw), 16<<10)}, nil |
| } |