Fold checks inside the fold; fixtures, routes, budgets, screenshots
The fold re-reads both tasks in its transaction and refuses unless one active creator owns both, in one project, neither ended, merging or folded, no open card on either and nothing at work; refusals stay a link. MarkDuplicate never folds into another person's task. Fixtures carry combined; the uncombine route is listed; chat size record 8200.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 files changed,
+128
−12
.rastrillo/budgets.txt+1 −1docs/mockups/built/2026-11-08/ux1-after-index-390-dark.pngbinarydocs/mockups/built/2026-11-08/ux1-after-index-390-light.pngbinarydocs/mockups/built/2026-11-08/ux1-after-index-open-390.pngbinarydocs/mockups/built/2026-11-08/ux1-after-needs-1280-dark.pngbinarydocs/mockups/built/2026-11-08/ux1-after-needs-1280-light.pngbinarydocs/mockups/built/2026-11-08/ux1-after-needs-390-dark.pngbinarydocs/mockups/built/2026-11-08/ux1-after-needs-390-light.pngbinarydocs/mockups/built/2026-11-08/ux1-after-project-1280-dark.pngbinarydocs/mockups/built/2026-11-08/ux1-after-project-1280-light.pngbinarydocs/mockups/built/2026-11-08/ux1-after-project-390-dark.pngbinarydocs/mockups/built/2026-11-08/ux1-after-project-390-light.pngbinarydocs/mockups/built/2026-11-08/ux1-after-projects-1280-dark.pngbinarydocs/mockups/built/2026-11-08/ux1-after-projects-1280-light.pngbinarydocs/mockups/built/2026-11-08/ux1-after-projects-390-dark.pngbinarydocs/mockups/built/2026-11-08/ux1-after-projects-390-light.pngbinarydocs/mockups/built/2026-11-08/ux1-after-task-1280-dark.pngbinarydocs/mockups/built/2026-11-08/ux1-after-task-1280-light.pngbinarydocs/mockups/built/2026-11-08/ux1-after-task-390-dark.pngbinarydocs/mockups/built/2026-11-08/ux1-after-task-390-light.pngbinarydocs/mockups/built/2026-11-08/ux1-after-task-details-open-1280.pngbinarydocs/mockups/built/2026-11-08/ux1-after-task-details-open-390.pngbinarydocs/mockups/built/2026-11-08/ux1-after-task-live-1280-dark.pngbinarydocs/mockups/built/2026-11-08/ux1-after-task-live-1280-light.pngbinarydocs/mockups/built/2026-11-08/ux1-after-task-live-390-dark.pngbinarydocs/mockups/built/2026-11-08/ux1-after-task-live-390-light.pngbinarydocs/mockups/built/2026-11-08/ux1-after-tasks-1280-dark.pngbinarydocs/mockups/built/2026-11-08/ux1-after-tasks-1280-light.pngbinarydocs/mockups/built/2026-11-08/ux1-after-tasks-390-dark.pngbinarydocs/mockups/built/2026-11-08/ux1-after-tasks-390-light.pngbinarydocs/superpowers/plans/UX1-PROGRESS.md+18 −4internal/equipo/chat/duplicates.go+53 −5internal/equipo/chat/inner.go+4 −0internal/equipo/work_views.go+1 −1internal/plan3test/person_api_contract_test.go+1 −1internal/thintest/duplicates_contract_test.go+50 −0
CI failed — run details
Intent
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt| index 87da1fc5..06e464c1 100644 |
| --- a/.rastrillo/budgets.txt |
| +++ b/.rastrillo/budgets.txt |
| @@ -48,6 +48,6 @@ perf GET /api/v1/projects skip Thin v1 person API: bearer-only JSON for devices; |
| perf GET /api/v1/notebook skip Thin v1 person API: bearer-only JSON for devices; the browser reads the notebook through /conversation/notebook. |
| perf GET /api/v1/tasks skip Thin v1 person API: bearer-only JSON for devices; the browser reads tasks through /tasks. |
| perf GET /api/v1/tasks/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads a task through /tasks/{id}. |
| -size internal/equipo/chat 7500 - Connections slice 1 adds connection records from hello and attempts, the connect mailbox, the API, usage rows and the turn's mutation ledger (connections.go and tools.go, about 600 lines); measured 7400 after merging UX1. Thin v1 UX1 adds step activity lines, duplicates and their fold, the coordinator at work on a task, project facts from the runner catalog and open merge cards for the pages (inner.go, about 330 lines); measured 6610 with slice 4c's review fixes. Thin v1 slice 4c adds the merge policy, the merge card, the rebase round and duplicate reports (merge.go, about 380 lines). Thin v1 instance core: conversation, projects, tasks, review and, from slice 4b, questions to the specialists (questions.go, about 470 lines) share one store, transaction and event log; splitting would export the transaction internals. Measured 5514 source lines; revisit at the slice 7 sweep. |
| +size internal/equipo/chat 8200 - Thin v1 UX1 round 3 adds Equipo combining duplicate tasks reversibly (duplicates.go: detection, the in-transaction fold checks, fold, Undo, about 400 lines) and headlines on findings and steps (headline.go); measured 7898. Connections slice 1 adds connection records from hello and attempts, the connect mailbox, the API, usage rows and the turn's mutation ledger (connections.go and tools.go, about 600 lines); measured 7400 after merging UX1. Thin v1 UX1 adds step activity lines, duplicates and their fold, the coordinator at work on a task, project facts from the runner catalog and open merge cards for the pages (inner.go, about 330 lines); measured 6610 with slice 4c's review fixes. Thin v1 slice 4c adds the merge policy, the merge card, the rebase round and duplicate reports (merge.go, about 380 lines). Thin v1 instance core: conversation, projects, tasks, review and, from slice 4b, questions to the specialists (questions.go, about 470 lines) share one store, transaction and event log; splitting would export the transaction internals. Measured 5514 source lines; revisit at the slice 7 sweep. |
| 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}. |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-index-390-dark.png b/docs/mockups/built/2026-11-08/ux1-after-index-390-dark.png| index 7b9791c6..c4d7d8ed 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-index-390-dark.png and b/docs/mockups/built/2026-11-08/ux1-after-index-390-dark.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-index-390-light.png b/docs/mockups/built/2026-11-08/ux1-after-index-390-light.png| index ddb60a58..261b98cf 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-index-390-light.png and b/docs/mockups/built/2026-11-08/ux1-after-index-390-light.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-index-open-390.png b/docs/mockups/built/2026-11-08/ux1-after-index-open-390.png| index ddecd2c5..eead2e24 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-index-open-390.png and b/docs/mockups/built/2026-11-08/ux1-after-index-open-390.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-needs-1280-dark.png b/docs/mockups/built/2026-11-08/ux1-after-needs-1280-dark.png| index 56e24526..01f51190 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-needs-1280-dark.png and b/docs/mockups/built/2026-11-08/ux1-after-needs-1280-dark.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-needs-1280-light.png b/docs/mockups/built/2026-11-08/ux1-after-needs-1280-light.png| index b32029e8..62e53f7d 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-needs-1280-light.png and b/docs/mockups/built/2026-11-08/ux1-after-needs-1280-light.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-needs-390-dark.png b/docs/mockups/built/2026-11-08/ux1-after-needs-390-dark.png| index 2f7ef80f..ed2a81e2 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-needs-390-dark.png and b/docs/mockups/built/2026-11-08/ux1-after-needs-390-dark.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-needs-390-light.png b/docs/mockups/built/2026-11-08/ux1-after-needs-390-light.png| index 8d3e9e5b..53ab6c45 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-needs-390-light.png and b/docs/mockups/built/2026-11-08/ux1-after-needs-390-light.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-project-1280-dark.png b/docs/mockups/built/2026-11-08/ux1-after-project-1280-dark.png| index 57ce6349..beccf9e0 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-project-1280-dark.png and b/docs/mockups/built/2026-11-08/ux1-after-project-1280-dark.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-project-1280-light.png b/docs/mockups/built/2026-11-08/ux1-after-project-1280-light.png| index d9bef4d4..e3f98ddd 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-project-1280-light.png and b/docs/mockups/built/2026-11-08/ux1-after-project-1280-light.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-project-390-dark.png b/docs/mockups/built/2026-11-08/ux1-after-project-390-dark.png| index 493b20f7..a86d0787 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-project-390-dark.png and b/docs/mockups/built/2026-11-08/ux1-after-project-390-dark.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-project-390-light.png b/docs/mockups/built/2026-11-08/ux1-after-project-390-light.png| index eb027fcf..0cce6319 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-project-390-light.png and b/docs/mockups/built/2026-11-08/ux1-after-project-390-light.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-projects-1280-dark.png b/docs/mockups/built/2026-11-08/ux1-after-projects-1280-dark.png| index c2c3fc63..36f95447 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-projects-1280-dark.png and b/docs/mockups/built/2026-11-08/ux1-after-projects-1280-dark.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-projects-1280-light.png b/docs/mockups/built/2026-11-08/ux1-after-projects-1280-light.png| index 6843c581..e04cb412 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-projects-1280-light.png and b/docs/mockups/built/2026-11-08/ux1-after-projects-1280-light.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-projects-390-dark.png b/docs/mockups/built/2026-11-08/ux1-after-projects-390-dark.png| index 0049440c..77f80b8e 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-projects-390-dark.png and b/docs/mockups/built/2026-11-08/ux1-after-projects-390-dark.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-projects-390-light.png b/docs/mockups/built/2026-11-08/ux1-after-projects-390-light.png| index cd6843f1..1d99e07b 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-projects-390-light.png and b/docs/mockups/built/2026-11-08/ux1-after-projects-390-light.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-task-1280-dark.png b/docs/mockups/built/2026-11-08/ux1-after-task-1280-dark.png| index 53458dc3..20ca6d30 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-task-1280-dark.png and b/docs/mockups/built/2026-11-08/ux1-after-task-1280-dark.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-task-1280-light.png b/docs/mockups/built/2026-11-08/ux1-after-task-1280-light.png| index 54922152..12453764 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-task-1280-light.png and b/docs/mockups/built/2026-11-08/ux1-after-task-1280-light.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-task-390-dark.png b/docs/mockups/built/2026-11-08/ux1-after-task-390-dark.png| index e5c636e3..47eeac9a 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-task-390-dark.png and b/docs/mockups/built/2026-11-08/ux1-after-task-390-dark.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-task-390-light.png b/docs/mockups/built/2026-11-08/ux1-after-task-390-light.png| index 14512102..b4dbe6b3 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-task-390-light.png and b/docs/mockups/built/2026-11-08/ux1-after-task-390-light.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-task-details-open-1280.png b/docs/mockups/built/2026-11-08/ux1-after-task-details-open-1280.png| new file mode 100644 |
| index 00000000..206664e4 |
| Binary files /dev/null and b/docs/mockups/built/2026-11-08/ux1-after-task-details-open-1280.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-task-details-open-390.png b/docs/mockups/built/2026-11-08/ux1-after-task-details-open-390.png| new file mode 100644 |
| index 00000000..77b1542a |
| Binary files /dev/null and b/docs/mockups/built/2026-11-08/ux1-after-task-details-open-390.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-task-live-1280-dark.png b/docs/mockups/built/2026-11-08/ux1-after-task-live-1280-dark.png| index 27c005d7..59139021 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-task-live-1280-dark.png and b/docs/mockups/built/2026-11-08/ux1-after-task-live-1280-dark.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-task-live-1280-light.png b/docs/mockups/built/2026-11-08/ux1-after-task-live-1280-light.png| index 30649e0b..9a88a6d4 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-task-live-1280-light.png and b/docs/mockups/built/2026-11-08/ux1-after-task-live-1280-light.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-task-live-390-dark.png b/docs/mockups/built/2026-11-08/ux1-after-task-live-390-dark.png| index 166013f8..42118c85 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-task-live-390-dark.png and b/docs/mockups/built/2026-11-08/ux1-after-task-live-390-dark.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-task-live-390-light.png b/docs/mockups/built/2026-11-08/ux1-after-task-live-390-light.png| index 6ef9448d..942e5de8 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-task-live-390-light.png and b/docs/mockups/built/2026-11-08/ux1-after-task-live-390-light.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-tasks-1280-dark.png b/docs/mockups/built/2026-11-08/ux1-after-tasks-1280-dark.png| index 20084634..0e0845d8 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-tasks-1280-dark.png and b/docs/mockups/built/2026-11-08/ux1-after-tasks-1280-dark.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-tasks-1280-light.png b/docs/mockups/built/2026-11-08/ux1-after-tasks-1280-light.png| index f9b74e0e..6fd38e59 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-tasks-1280-light.png and b/docs/mockups/built/2026-11-08/ux1-after-tasks-1280-light.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-tasks-390-dark.png b/docs/mockups/built/2026-11-08/ux1-after-tasks-390-dark.png| index d9fea5ea..5eb53e31 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-tasks-390-dark.png and b/docs/mockups/built/2026-11-08/ux1-after-tasks-390-dark.png differ |
diff --git a/docs/mockups/built/2026-11-08/ux1-after-tasks-390-light.png b/docs/mockups/built/2026-11-08/ux1-after-tasks-390-light.png| index e7bccff6..e7afea2e 100644 |
| Binary files a/docs/mockups/built/2026-11-08/ux1-after-tasks-390-light.png and b/docs/mockups/built/2026-11-08/ux1-after-tasks-390-light.png differ |
diff --git a/docs/superpowers/plans/UX1-PROGRESS.md b/docs/superpowers/plans/UX1-PROGRESS.md| index 163d8962..0eec805f 100644 |
| --- a/docs/superpowers/plans/UX1-PROGRESS.md |
| +++ b/docs/superpowers/plans/UX1-PROGRESS.md |
| @@ -205,10 +205,24 @@ pass". Conventions as in `SLICE1-PROGRESS.md` to `SLICE4C-PROGRESS.md`. |
| - Any other pair is only named: the weaker task's `duplicate_of` |
| ("Possible duplicate of …"). No Needs you card for duplicates. |
| - When: at every start (`TidyDuplicates` in `RouterWithStore`, after |
| - migration 0051) and after every recorded task. Staging's two |
| - Woodstar tasks of Paul's (filed before de-duplication) combine on |
| - the next deploy: "Swipe from the edge to go back" (stopped) into |
| - "Swipe back from the edge" (Ready to merge, its merge card stays). |
| + migration 0051) and after every recorded task. |
| + - Safety (Astra, housekeeping review): the fold re-reads both tasks |
| + inside its own transaction (`foldable`) and refuses unless they |
| + share a creator who is still an active member, share a project, |
| + neither is ended, merging or already folded, neither has an open |
| + card, and nothing is at work on the folded one; a refusal leaves |
| + only the "Possible duplicate of" link and never touches the other |
| + task. `MarkDuplicate` (the creator's own fold) now refuses a target |
| + owned by someone else (403), and the quiet menu offers it only for |
| + one's own task. Tests: a fold into a teammate's task refused by the |
| + API and never automatic, the other task unchanged; an open merge |
| + card on the survivor keeps the pair apart; a departed creator's |
| + pair is left alone (mutation of the member check killed). |
| + - Staging consequence: Paul's two Woodstar tasks will NOT combine on |
| + the next deploy, because the one that would survive ("Swipe back |
| + from the edge", Ready to merge) has an open merge card. They show |
| + "Possible duplicate of". Once he answers the card, the next start |
| + or recorded task combines them. |
| - Wire: `TaskRef.creator`, `Task.folded`, `Task.combined`, card |
| `combined`. Test: `TestContractCombineDuplicates` (the round trip |
| through Undo, the coordinator's separate pairs, a task at work, a |
diff --git a/internal/equipo/chat/duplicates.go b/internal/equipo/chat/duplicates.go| index f1c10f33..39eb3fff 100644 |
| --- a/internal/equipo/chat/duplicates.go |
| +++ b/internal/equipo/chat/duplicates.go |
| @@ -147,13 +147,16 @@ func (t *txn) tidyDuplicates(projectID string) (int, error) { |
| if stronger(b, a, stopped) { |
| keep, fold = b, a |
| } |
| - if high && keep.Creator == fold.Creator && keep.Stage != wire.StageMerging && fold.Stage != wire.StageMerging && !busy[fold.ID] && !slices.Contains(carded, fold.ID) { |
| - if err := t.fold(fold, keep); err != nil { |
| + if high && keep.Creator == fold.Creator && keep.Stage != wire.StageMerging && fold.Stage != wire.StageMerging && !busy[fold.ID] && !slices.Contains(carded, fold.ID) && !slices.Contains(carded, keep.ID) { |
| + err := t.fold(fold, keep) |
| + if err == nil { |
| + folded++ |
| + acted = true |
| + continue |
| + } |
| + if !errors.Is(err, errNotFoldable) { |
| return folded, err |
| } |
| - folded++ |
| - acted = true |
| - continue |
| } |
| if fold.DuplicateOf == "" { |
| fold.DuplicateOf = keep.ID |
| @@ -174,10 +177,55 @@ func (t *txn) tidyDuplicates(projectID string) (int, error) { |
| return folded, nil |
| } |
| +// errNotFoldable: the pair fails a check fold makes in its own |
| +// transaction; it stays a "Possible duplicate of" link. |
| +var errNotFoldable = errors.New("chat: not foldable") |
| + |
| +// foldable re-reads both tasks inside the fold's transaction and checks |
| +// everything a fold needs (Astra, housekeeping review): one creator who |
| +// is still an active member, one project, neither ended, merging or |
| +// already folded, no open card on either, and nothing at work on the one |
| +// folded. Anything else never touches the other task. |
| +func (t *txn) foldable(k, into taskRecord) (taskRecord, taskRecord, error) { |
| + var err error |
| + if k, err = t.loadTask(k.ID); err != nil { |
| + return k, into, err |
| + } |
| + if into, err = t.loadTask(into.ID); err != nil { |
| + return k, into, err |
| + } |
| + switch { |
| + case k.ID == into.ID, k.Creator != into.Creator, k.ProjectID != into.ProjectID, |
| + wire.FinalStage(k.Stage), wire.FinalStage(into.Stage), k.CancelRequested, into.CancelRequested, |
| + k.Stage == wire.StageMerging, into.Stage == wire.StageMerging, k.FoldedInto != "", into.FoldedInto != "": |
| + return k, into, errNotFoldable |
| + } |
| + var active int64 |
| + if err := t.db.Raw("SELECT COUNT(*) FROM members WHERE address = ? AND active = 1", k.Creator).Scan(&active).Error; err != nil { |
| + return k, into, err |
| + } |
| + var cards int64 |
| + if err := t.db.Model(&cardRecord{}).Where("task_id IN ? AND state = ? AND kind <> ?", []string{k.ID, into.ID}, wire.CardOpen, wire.CardTask).Count(&cards).Error; err != nil { |
| + return k, into, err |
| + } |
| + var busy int64 |
| + if err := t.db.Model(&stepRecord{}).Where("task_id = ? AND state IN ?", k.ID, []string{wire.StepQueued, wire.StepRunning}).Count(&busy).Error; err != nil { |
| + return k, into, err |
| + } |
| + if active == 0 || cards > 0 || busy > 0 { |
| + return k, into, errNotFoldable |
| + } |
| + return k, into, nil |
| +} |
| + |
| // fold combines k into into: k's report, findings and thread are copied |
| // onto into, marked as folded from k; k is cancelled without merging, |
| // keeping the stage it had for Undo; the creator gets a quiet receipt. |
| func (t *txn) fold(k, into taskRecord) error { |
| + k, into, err := t.foldable(k, into) |
| + if err != nil { |
| + return err |
| + } |
| now := t.now() |
| var entries []entryRecord |
| if err := t.db.Where("task_id = ? AND (folded_from IS NULL OR folded_from = '')", k.ID).Order("created_at, id").Find(&entries).Error; err != nil { |
diff --git a/internal/equipo/chat/inner.go b/internal/equipo/chat/inner.go| index 4ab501a9..fc705883 100644 |
| --- a/internal/equipo/chat/inner.go |
| +++ b/internal/equipo/chat/inner.go |
| @@ -201,6 +201,10 @@ func (s *Store) MarkDuplicate(ctx context.Context, person, id string, in wire.Ma |
| if target.ProjectID != k.ProjectID || wire.FinalStage(target.Stage) || target.CancelRequested { |
| return ErrInvalid |
| } |
| + // Never into another person's task: a fold appends to the target. |
| + if target.Creator != k.Creator { |
| + return ErrForbidden |
| + } |
| if err := t.db.Model(&taskRecord{}).Where("id = ?", k.ID).Update("duplicate_of", target.ID).Error; err != nil { |
| return err |
| } |
diff --git a/internal/equipo/work_views.go b/internal/equipo/work_views.go| index 71c56210..a486aa17 100644 |
| --- a/internal/equipo/work_views.go |
| +++ b/internal/equipo/work_views.go |
| @@ -427,7 +427,7 @@ func (v *taskLine) richOf(t wire.Task, viewer string, card *wire.Card, now time. |
| } |
| } |
| if v.Mine && !wire.FinalStage(t.Stage) && t.Stage != wire.StageMerging { |
| - if v.Dup != nil && !wire.FinalStage(v.Dup.Stage) { |
| + if v.Dup != nil && !wire.FinalStage(v.Dup.Stage) && v.Dup.Creator == t.Creator { |
| v.Menu = append(v.Menu, menuItem{Action: "duplicate", Value: v.Dup.ID, Label: fmt.Sprintf(copyText("work.menu.fold"), v.Dup.Title), Note: copyText("work.menu.fold_note")}) |
| } |
| if v.Merge { |
diff --git a/internal/plan3test/person_api_contract_test.go b/internal/plan3test/person_api_contract_test.go| index 0b429e20..7d5d6ef5 100644 |
| --- a/internal/plan3test/person_api_contract_test.go |
| +++ b/internal/plan3test/person_api_contract_test.go |
| @@ -56,7 +56,7 @@ func personAPIContractCoverage(t *testing.T) { |
| f := newFixture(t) |
| registered := map[string]bool{} |
| // Thin v1 conversation routes are contracted by internal/wire fixtures. |
| - thin := map[string]bool{"GET /messages": true, "POST /messages": true, "GET /turns/{id}": true, "POST /turns/{id}/cancel": true, "GET /snapshot": true, "GET /events": true, "DELETE /projects/{id}": true, "POST /cards/{id}/answer": true, "GET /notebook": true, "POST /notebook/reset": true, "POST /tasks/{id}/retry": true, "POST /tasks/{id}/merge": true, "POST /tasks/{id}/duplicate": true, "POST /tasks/{id}/thread": true, "GET /steps/{id}/log": true, "POST /tasks/{id}/questions": true, "POST /questions/{id}/cancel": true, "POST /connections": true, "POST /connections/{id}/cancel": true} |
| + thin := map[string]bool{"GET /messages": true, "POST /messages": true, "GET /turns/{id}": true, "POST /turns/{id}/cancel": true, "GET /snapshot": true, "GET /events": true, "DELETE /projects/{id}": true, "POST /cards/{id}/answer": true, "GET /notebook": true, "POST /notebook/reset": true, "POST /tasks/{id}/retry": true, "POST /tasks/{id}/merge": true, "POST /tasks/{id}/duplicate": true, "POST /tasks/{id}/uncombine": true, "POST /tasks/{id}/thread": true, "GET /steps/{id}/log": true, "POST /tasks/{id}/questions": true, "POST /questions/{id}/cancel": true, "POST /connections": true, "POST /connections/{id}/cancel": true} |
| must(t, chi.Walk(f.Store.PersonAPIHandler().(chi.Routes), func(method, path string, _ http.Handler, _ ...func(http.Handler) http.Handler) error { |
| if thin[method+" "+path] { |
| return nil |
diff --git a/internal/thintest/duplicates_contract_test.go b/internal/thintest/duplicates_contract_test.go| index a1edbf56..d4b24bef 100644 |
| --- a/internal/thintest/duplicates_contract_test.go |
| +++ b/internal/thintest/duplicates_contract_test.go |
| @@ -159,6 +159,56 @@ func TestContractCombineDuplicates(t *testing.T) { |
| t.Fatalf("a teammate's look-alike: folded %+v, named %+v", k.Folded, k.DuplicateOf) |
| } |
| + // Never into another person's task, automatically or by hand, and the |
| + // other task is left exactly as it was. |
| + keepNow, _ := r.client.Task(ctx, keep) |
| + if len(keepNow.Combined) != 0 || text(keepNow) != text(keptBefore) { |
| + t.Fatalf("a teammate's look-alike changed the owner's task: %+v %q", keepNow.Combined, text(keepNow)) |
| + } |
| + theirsBefore, _ := b.client.Task(ctx, theirs) |
| + mineToo := taskID(t, r.call("d9", wire.ToolRecordTask, map[string]any{"repo": "oficina/sample", "title": "Crash on launch after the update", "brief": "Again."})) |
| + if _, err := r.client.MarkDuplicate(ctx, mineToo, theirs); Status(err) != 403 { |
| + t.Fatalf("fold into another person's task: %v", err) |
| + } |
| + if after, _ := b.client.Task(ctx, theirs); text(after) != text(theirsBefore) || after.Stage != theirsBefore.Stage { |
| + t.Fatal("a refused fold changed the other person's task") |
| + } |
| + |
| + // An open card on either task keeps them apart (staging's pair: the |
| + // survivor waits on its merge card), and so does a creator no longer |
| + // on the team. |
| + ready := r.judgedTask("dc", "Timeline jumps when images load", strings.Repeat("3", 40), strings.Repeat("4", 40), wire.ChecksCannotRun, "needs_macos") |
| + r.wait("merge card", func(c *Conversation) bool { |
| + for _, k := range c.Cards { |
| + if k.Kind == wire.CardMerge && k.TaskID == ready && k.State == wire.CardOpen { |
| + return true |
| + } |
| + } |
| + return false |
| + }) |
| + again := taskID(t, r.call("d10", wire.ToolRecordTask, map[string]any{"repo": "oficina/sample", "title": "Timeline jumps when the images load", "brief": "Again.", "separate": true})) |
| + r.forgetPair(again, ready) |
| + r.tidy() |
| + if k, _ := r.client.Task(ctx, again); k.Folded != nil || k.DuplicateOf == nil || k.DuplicateOf.ID != ready { |
| + t.Fatalf("folded beside an open card: folded %+v, named %+v", k.Folded, k.DuplicateOf) |
| + } |
| + one := taskID(t, b.call("d11", wire.ToolRecordTask, map[string]any{"repo": "oficina/sample", "title": "Compose sheet keyboard covers the send button", "brief": "x"})) |
| + two := taskID(t, b.call("d12", wire.ToolRecordTask, map[string]any{"repo": "oficina/sample", "title": "Keyboard covers the compose sheet send button", "brief": "y", "separate": true})) |
| + m, err := r.inst.Store.Member(context.Background(), "second@example.com") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := r.inst.Store.SetMember(context.Background(), equipo.Actor{Address: Owner}, "second@example.com", equipo.RoleOwner, false, m.Revision); err != nil { |
| + t.Fatal(err) |
| + } |
| + r.forgetPair(one, two) |
| + r.tidy() |
| + for _, id := range []string{one, two} { |
| + if k, _ := r.client.Task(ctx, id); k.Folded != nil || len(k.Combined) != 0 { |
| + t.Fatalf("combined the tasks of someone no longer on the team: %s", id) |
| + } |
| + } |
| + |
| // A test person's tasks are its own: listed to itself only, and never |
| // paired with anyone else's. |
| tester := personToolRig(t, r, "suite@staging.invalid", equipo.RoleOwner) |