Only release a project for Equipo project-not-found errors
Co-Authored-By: Codex GPT-6-Astra <noreply@openai.com>
3 files changed,
+41
−2
native/PROJECTS-REPORT.md+8 −0native/apple/Sources/EquipoKit/Session/EquipoSession.swift+5 −2native/apple/Tests/EquipoKitTests/ProjectsFinalReviewTests.swift+28 −0
diff --git a/native/PROJECTS-REPORT.md b/native/PROJECTS-REPORT.md| index e37859b6..b8f0bc50 100644 |
| --- a/native/PROJECTS-REPORT.md |
| +++ b/native/PROJECTS-REPORT.md |
| @@ -291,3 +291,11 @@ notice together, including an ordinary send that goes offline. The regression |
| `nextComposerSendClearsReleasedSelectionNotice` failed before the fix, passed |
| after it, and failed again when notice clearing was deliberately removed. |
| Both existing platform composer tests also pass. |
| + |
| +P3 404 scope: only a decoded Equipo not_found/api.not_found 404 for a |
| +conversation body with a nonempty project_id releases the project. Native |
| +conversation sends reference no other resource; task-thread sends are excluded. |
| +A seven-case regression covers genuine project loss, other codes, foreign copy |
| +keys, plain HTTP 404s, another status, no project, and task threads. It failed |
| +first, passed after the fix, and caught separate code and copy-key mutations. |
| +Unrelated failures retain the original retry body and key. |
diff --git a/native/apple/Sources/EquipoKit/Session/EquipoSession.swift b/native/apple/Sources/EquipoKit/Session/EquipoSession.swift| index fc36b733..10411967 100644 |
| --- a/native/apple/Sources/EquipoKit/Session/EquipoSession.swift |
| +++ b/native/apple/Sources/EquipoKit/Session/EquipoSession.swift |
| @@ -352,9 +352,12 @@ public final class EquipoSession { |
| if let i = outgoing.firstIndex(where: { $0.id == id }) { |
| outgoing[i].state = error == .offline ? .waiting : .failed |
| outgoing[i].notice = ProjectNotice.knownText(error) |
| - if case .server(404, _) = error, |
| + // This native conversation body references only one resource: its selected project. |
| + // A proxy 404, another API code, or a missing task is not evidence about that project. |
| + if case .server(404, let body) = error, body.code == "not_found", body.copyKey == "api.not_found", |
| + item.taskID == nil, |
| let fields = try? JSONSerialization.jsonObject(with: item.write.body) as? [String: String], |
| - let project = fields["project_id"] { |
| + let project = fields["project_id"], !project.isEmpty { |
| outgoing[i].goneProject = true |
| outgoing[i].projectName = nil |
| outgoing[i].notice = EquipoStrings.text("projects.selection_lost") |
diff --git a/native/apple/Tests/EquipoKitTests/ProjectsFinalReviewTests.swift b/native/apple/Tests/EquipoKitTests/ProjectsFinalReviewTests.swift| index 7ed09fef..20cb3a5b 100644 |
| --- a/native/apple/Tests/EquipoKitTests/ProjectsFinalReviewTests.swift |
| +++ b/native/apple/Tests/EquipoKitTests/ProjectsFinalReviewTests.swift |
| @@ -19,3 +19,31 @@ extension ProjectsReviewTests { |
| #expect(s.outgoing.first?.state == .waiting) |
| } |
| } |
| + |
| +extension ProjectsReviewTests { |
| + @Test func onlyEquipoProjectNotFoundReleasesTheRetrySelection() async throws { |
| + let cases: [(Int, String?, String?, String?, String?, Bool)] = [ |
| + (404, "not_found", "api.not_found", "p_star", nil, true), |
| + (404, "route_missing", "api.not_found", "p_star", nil, false), |
| + (404, "not_found", "proxy.not_found", "p_star", nil, false), |
| + (404, nil, nil, "p_star", nil, false), |
| + (500, "not_found", "api.not_found", "p_star", nil, false), |
| + (404, "not_found", "api.not_found", nil, nil, false), |
| + (404, "not_found", "api.not_found", "p_star", "tk1", false), |
| + ] |
| + for (status, code, key, project, task, releases) in cases { |
| + let t = ScriptedTransport(); let s = try session(t) |
| + let route = task.map { "POST /tasks/\($0)/thread" } ?? "POST /messages" |
| + let data = code.map { Data("{\"code\":\"\($0)\",\"copy_key\":\"\(key!)\",\"request_id\":\"r\"}".utf8) } ?? Data("Not found".utf8) |
| + t.on(route, .success(APIResponse(status: status, data: data))) |
| + await s.send("Fix it", inThreadOf: task, projectID: project) |
| + let outgoing = try #require(s.outgoing.first) |
| + #expect(outgoing.goneProject == releases, "status=\(status), code=\(code ?? "none"), key=\(key ?? "none"), task=\(task ?? "none")") |
| + #expect((s.projectCatalog.selectionNotice != nil) == releases) |
| + await s.retry(outgoing.id) |
| + let sent = t.sent(route) |
| + #expect(sent.count == 2) |
| + #expect((sent[0].body == sent[1].body) == !releases) |
| + } |
| + } |
| +} |