Add project rename control and ship the update
Updated the status expectation and added a runner-to-instance rename test covering replay, stale writes, status and project cards. Project revision conflicts now use the correct error without changing unrelated card behavior. Formatting completed, but package tests remain blocked by dependency-download restrictions. Nothing was deployed: passing checks, review, approved merge, staged release and live server/runner verification are still required. Equipo task tkataquuxfrw, Engineering step attempt 1.
6 files changed,
+69
−6
docs/project-rename-delivery.md+8 −0internal/equipo/chat/rename.go+2 −2internal/equipo/chat/rename_test.go+1 −1internal/equipo/chat/tools.go+1 −1internal/equipo/chat_page.go+1 −1internal/thintest/tools_contract_test.go+56 −1
CI failed — run details
diff --git a/docs/project-rename-delivery.md b/docs/project-rename-delivery.md| index c5b25d9b..93f5b53e 100644 |
| --- a/docs/project-rename-delivery.md |
| +++ b/docs/project-rename-delivery.md |
| @@ -22,6 +22,14 @@ writes, no-op revisions, project events and cross-attempt ledger lookup. |
| Browser/form integration and the full normal CI suite still need to run. |
| New UI copy also needs the normal copy review. No release was built or deployed. |
| +Review follow-up: updated the status contract for project ID/title/revision and |
| +added a runner-to-instance rename contract covering replay, stale revision, |
| +status, project cards and stable repository identity. Project stale writes now |
| +use ErrRevision without changing other card-conflict HTTP behavior. Formatting |
| +completed. Retried the thintest, chat and instance package suites with writable |
| +temporary Go caches; dependency downloads were blocked by sandbox networking, |
| +and the escalation request was rejected. These suites remain unverified. |
| + |
| ## Required handoff after review |
| 1. Run targeted tests, the normal CI/review gates and copy acceptance. Review |
diff --git a/internal/equipo/chat/rename.go b/internal/equipo/chat/rename.go| index ec43a025..d1084299 100644 |
| --- a/internal/equipo/chat/rename.go |
| +++ b/internal/equipo/chat/rename.go |
| @@ -41,7 +41,7 @@ func (t *txn) renameProject(person, id, title string, revision int64) (wire.Proj |
| return wire.Project{}, err |
| } |
| if p.Revision != revision { |
| - return wire.Project{}, ErrCardConflict |
| + return wire.Project{}, ErrRevision |
| } |
| if p.Title == title { |
| return t.projectView(p) |
| @@ -52,7 +52,7 @@ func (t *txn) renameProject(person, id, title string, revision int64) (wire.Proj |
| return wire.Project{}, result.Error |
| } |
| if result.RowsAffected != 1 { |
| - return wire.Project{}, ErrCardConflict |
| + return wire.Project{}, ErrRevision |
| } |
| if err := t.projectEvent(p); err != nil { |
| return wire.Project{}, err |
diff --git a/internal/equipo/chat/rename_test.go b/internal/equipo/chat/rename_test.go| index 03aca13e..69cbd3d9 100644 |
| --- a/internal/equipo/chat/rename_test.go |
| +++ b/internal/equipo/chat/rename_test.go |
| @@ -52,7 +52,7 @@ func TestRenameProject(t *testing.T) { |
| return err |
| })) |
| _, err = r.s.RenameProject(r.ctx, hkOwner, p.ID, "Old edit", 1) |
| - if !errors.Is(err, ErrCardConflict) { |
| + if !errors.Is(err, ErrRevision) { |
| t.Fatalf("stale: %v", err) |
| } |
| same, err := r.s.RenameProject(r.ctx, hkOwner, p.ID, p.Title, 2) |
diff --git a/internal/equipo/chat/tools.go b/internal/equipo/chat/tools.go| index ed3fbbd0..5bc185bd 100644 |
| --- a/internal/equipo/chat/tools.go |
| +++ b/internal/equipo/chat/tools.go |
| @@ -398,7 +398,7 @@ func (t *txn) runTool(l Lease, v *wire.ToolCall) (wire.ToolResult, error) { |
| return refused("invalid", toolBadInput), nil |
| case errors.Is(err, ErrNotFound): |
| return refused("not_found", toolUnknownProject), nil |
| - case errors.Is(err, ErrCardConflict): |
| + case errors.Is(err, ErrRevision): |
| return refused("conflict", "Project changed. Read status before trying again."), nil |
| case err != nil: |
| return wire.ToolResult{}, err |
diff --git a/internal/equipo/chat_page.go b/internal/equipo/chat_page.go| index f4e3fafd..b3880d64 100644 |
| --- a/internal/equipo/chat_page.go |
| +++ b/internal/equipo/chat_page.go |
| @@ -446,7 +446,7 @@ func (a *application) chatNotebookReset(w http.ResponseWriter, r *http.Request) |
| } |
| func chatError(err error) error { |
| - for from, to := range map[error]error{chat.ErrCardConflict: ErrConflict, chat.ErrBusy: ErrConflict, chat.ErrInvalid: ErrInvalid, chat.ErrConflict: ErrConflict, chat.ErrNotFound: ErrNotFound, chat.ErrForbidden: ErrForbidden, chat.ErrNotAllowed: ErrInvalid, chat.ErrTaskEnded: ErrConflict, chat.ErrNotRetryable: ErrConflict, chat.ErrMerging: ErrConflict, chat.ErrNotMergeable: ErrConflict, chat.ErrNotAskable: ErrConflict} { |
| + for from, to := range map[error]error{chat.ErrRevision: ErrConflict, chat.ErrBusy: ErrConflict, chat.ErrInvalid: ErrInvalid, chat.ErrConflict: ErrConflict, chat.ErrNotFound: ErrNotFound, chat.ErrForbidden: ErrForbidden, chat.ErrNotAllowed: ErrInvalid, chat.ErrTaskEnded: ErrConflict, chat.ErrNotRetryable: ErrConflict, chat.ErrMerging: ErrConflict, chat.ErrNotMergeable: ErrConflict, chat.ErrNotAskable: ErrConflict} { |
| if errors.Is(err, from) { |
| return to |
| } |
diff --git a/internal/thintest/tools_contract_test.go b/internal/thintest/tools_contract_test.go| index 92d71b00..b3d9b0b4 100644 |
| --- a/internal/thintest/tools_contract_test.go |
| +++ b/internal/thintest/tools_contract_test.go |
| @@ -121,7 +121,7 @@ func TestContractTools(t *testing.T) { |
| shape(t, "api/projects.json", list) |
| status := r.call("u3", wire.ToolStatus, map[string]string{}) |
| - for _, want := range []string{`"projects":[{"name":"oficina/sample"}]`, `"can_add":["oficina/equipo","oficina/sample"]`, `"create_in":["oficina"]`} { |
| + for _, want := range []string{`"projects":[{"name":"oficina/sample","id":"p_`, `"title":`, `"revision":`, `"can_add":["oficina/equipo","oficina/sample"]`, `"create_in":["oficina"]`} { |
| if !strings.Contains(status.Text, want) { |
| t.Fatalf("status lacks %s: %s", want, status.Text) |
| } |
| @@ -225,6 +225,61 @@ func TestContractTools(t *testing.T) { |
| } |
| } |
| +func TestContractRenameProject(t *testing.T) { |
| + r := newToolRig(t) |
| + if res := r.call("add", wire.ToolAddProject, map[string]string{"repo": "oficina/sample"}); res.IsError { |
| + t.Fatalf("add: %+v", res) |
| + } |
| + list, err := r.client.Projects(r.ctx) |
| + if err != nil || len(list.Items) != 1 { |
| + t.Fatalf("projects: %+v %v", list, err) |
| + } |
| + p := list.Items[0] |
| + args := map[string]any{"project": p.ID, "title": "Barber", "revision": p.Revision} |
| + res := r.call("rename", wire.ToolRenameProject, args) |
| + if res.IsError || res.Code != "renamed" { |
| + t.Fatalf("rename: %+v", res) |
| + } |
| + if again := r.call("rename", wire.ToolRenameProject, args); again != res { |
| + t.Fatalf("replay: %+v vs %+v", again, res) |
| + } |
| + if stale := r.call("stale", wire.ToolRenameProject, args); !stale.IsError || stale.Code != "conflict" { |
| + t.Fatalf("stale: %+v", stale) |
| + } |
| + status := r.call("status", wire.ToolStatus, map[string]string{}) |
| + var got struct { |
| + Projects []struct { |
| + Name string `json:"name"` |
| + ID string `json:"id"` |
| + Title string `json:"title"` |
| + Revision int64 `json:"revision"` |
| + } `json:"projects"` |
| + } |
| + if err := json.Unmarshal([]byte(status.Text), &got); err != nil || status.IsError || len(got.Projects) != 1 { |
| + t.Fatalf("status: %+v %v", status, err) |
| + } |
| + project := got.Projects[0] |
| + if project.ID != p.ID || project.Name != p.Name || project.Title != "Barber" || project.Revision != p.Revision+1 { |
| + t.Fatalf("status project: %+v", project) |
| + } |
| + r.wait("renamed project card", func(c *Conversation) bool { |
| + for _, card := range c.Cards { |
| + if card.Kind == wire.CardProject && card.ProjectID == p.ID && card.Name == "Barber" { |
| + return true |
| + } |
| + } |
| + return false |
| + }) |
| + list, err = r.client.Projects(r.ctx) |
| + if err != nil || len(list.Items) != 1 { |
| + t.Fatalf("renamed projects: %+v %v", list, err) |
| + } |
| + renamed := list.Items[0] |
| + if renamed.ID != p.ID || renamed.Repo != p.Repo || renamed.Title != "Barber" || renamed.Revision != p.Revision+1 { |
| + t.Fatalf("renamed project: %+v", renamed) |
| + } |
| +} |
| + |
| func TestContractProjectsAPI(t *testing.T) { |
| r := newToolRig(t) |
| if _, err := r.client.AddProject(r.ctx, "oficina/secret"); Status(err) != 422 { |