Todos Update/Edit/Replace: merge-safe writes across all 6 SDKs
π€ Drafted with agent assistance; submitted by @jeremy.
Closes #372.
What
Every SDK's Todos.Update presented a typed partial-update surface but transmitted a sparse PUT to an endpoint whose contract is full replace, omission clears β silently wiping description, dates, and subscribers (two production data-loss incidents; ~80 lines of CLI workaround). This PR replaces that with a three-method, two-state surface in all six languages:
updateβ merge-safe: GET β overlay explicitly-set fields β full-representation PUT. An omitted field is untouched, guaranteed; an explicitly-passed empty collection still clears.editβ read-modify-write closure over the full writable state (TodoFields), the primary API. Clear = set empty; a closure error aborts before the PUT. Python's form is a context manager with.result.replaceβ the wire operation, verbatim: sparse PUT, no GET, omission clears,contentrequired.
Spec and route
UpdateTodoβReplaceTodoin place (same flat URI),content@required, new@basecampWriteSemantics(mode: "replace", clearsOmitted: true)trait surfaced asx-basecamp-write-semanticsand awriteclause inbehavior-model.json.- The canonical flat route stays β no bucket-scoped switch. #372's original bucket-route criterion was amended (see the issue): BC3's API tests prove the flat route persists
descriptionwhencontentis present, and the maintainer disposition on #259 labels the bucket route legacy. #259 closed separately as misdiagnosed.
Hook contract
update/edit compose the public get + replace, so hooks observe the wire operations under each SDK's native identities (conceptually one GetTodo + one ReplaceTodo) β never a synthetic composite. Retry/idempotency policy stays keyed to the wire operation; the mutation is always observable/gateable as a replace. Documented in SPEC.md Β§5 and tested per language.
Full-state serialization (update/edit)
Content, description, and both ID lists are always sent (empties included, so clears survive); dates only when non-empty (the server clears an omitted date, and "" is a format error); notify only when true (send directive, never populated from GET). Go splits this explicitly: public Replace uses a sparse builder, the Update/Edit composites use a full-state builder through a shared private transport with one hook envelope and one generated-call site.
Conformance
Harness upgraded full-width: new requestMethod / requestBody / requestBodyAbsent assertions, requestPath (and all per-request assertions) honor index, and Python/Ruby/TypeScript runners moved to method-agnostic sequential response queues constrained to the active API origin β retiring their multi-hop UploadsDownload skips (now passing). New todos_write.json fixtures (update-merge, edit-clear, replace-omission-clears) pass in all five runners; Swift (no runner) mirrors them natively in XCTest.
#355 (partial)
Go Todo gains CompletionSubscribers and CommentsCount, with nil-vs-empty preserved on completion_subscribers (server [] β non-nil empty slice; absent β nil; deliberately not omitempty) for fail-closed consumers like the CLI. description_attachments remains (read-only server-side; not a data-loss risk) β issue stays open.
Live incident replay (sandbox, via the SDK β no raw HTTP)
Run against a scratch project in a personal account at the release head, Go SDK end-to-end, then cleaned up (todo + project trashed):
create (description + due/starts + assignee + completion subscriber) ok
update content-only β description, due_on, starts_on, assignees,
completion subscribers ALL preserved ok
edit clear date range β dates cleared, description/assignees kept ok
replace sparse β description/dates/assignees/subscribers cleared ok
replace full body on canonical flat route β description persisted ok
(0 failures)
Two server-native behaviors surfaced by the replay (documented, not defects): rich-text descriptions are normalized (<div> β <div dir="auto">), and dates are a range β clearing due_on alone collapses the range onto starts_on, so a full clear sets both empty.
Release notes / migration hazards (0.8.0)
updatenever clears by omission anymore. Callers relying on omission-clears through the old sparse PUT (e.g. basecamp-cli's clear paths) must move toedit/replacein the same change that bumps the SDK.- The generated
updateis nowreplace, withcontentrequired;UpdateTodoRequest/UpdateTodoBodycompat types remain for the merge-safe surface. - Kotlin: source-compatible but binary-incompatible for already-compiled consumers β the todos accessor's declared type is now the hand-written subclass.
Verification
make check(full umbrella: all six languages, drift gates, conformance) β green.- Targeted assertions: no
operation UpdateTodoin the spec, noUpdateTodooperationId in openapi.json/behavior-model/metadata,ReplaceTodopresent in every generated surface. - Go 71/71 conformance; Kotlin 61 pass/10 skipped (pre-existing); TS 67 pass/4 skipped (pre-existing); Ruby 63 pass/8 skipped (pre-existing); Python 68 pass/3 skipped (pre-existing).
Review convergence round (9c6003f8)
Four commits addressing the first review pass; all seven threads replied to and resolved in place.
- Conformance hardening (07b18640): implicit first-request method invariant in all five runners (restores the wire-verb enforcement the origin-wide queues dropped; mutation-tested by flipping a fixture's GET to POST β Python, Ruby, and Go all fail it, pass again on revert); Kotlin
requestBodyAbsentnow fails on an unresolvable index like the other assertions; Python/Ruby origin interception normalizes mixed-case hosts and explicit default ports, with a new paths.json regression case (Go runner skips it β it dials the override origin for real). - Lock hygiene (0a7292fa):
python/uv.lockand the conformance TS runner'spackage-lock.jsonwere still at 0.7.3 β synced, bump script extended to cover both, andmake releasenow fails on stale locks (uv lock --check+ runner-lock version). - Architecture disposition (634bc5a0): the composite update/edit surface contradicted the letter of "no hand-written API methods"; SPEC.md Β§18 now defines sanctioned composite methods (generated wire methods only, native hook identities, conformance coverage, declared placement) and AGENTS.md aligns.
- Kotlin KDoc (9c6003f8):
VERB_PATTERNSdoc comment reanchored.
Conformance counts after the round (+1 new origin-normalization case): Go 71 pass/1 skipped, Kotlin 62/10, TS 68/4, Ruby 64/8, Python 69/3 β all zero failures. make check green at the new head.
Follow-up: #374 rolls the triad across sibling recordables (messages, documents, cards, todolists, schedule entries) with todos as the template.
Summary by cubic
Fixes todo update data loss by making writes merge-safe and adding edit and verbatim replace across all six SDKs; hardens the conformance harness, IPv6 origin handling, and release checks (addresses #372).
-
New Features
- Merge-safe
update(GET β overlay β full PUT), read-modify-writeedit, and verbatimreplacein Go, TypeScript, Python, Ruby, Kotlin, and Swift. - Wire op renamed
UpdateTodoβReplaceTodo; spec documents replace semantics viax-basecamp-write-semantics(mode: replace, clearsOmitted: true). Route stays flat. - Conformance: added method/body assertions, indexed per-request checks, origin normalization; new
todos_write.jsonfixtures. Paths fixtures now include full TimesheetEntry bodies. IPv6 origins normalized in Python and TypeScript; MSW path catch-all uses a RegExp; new bracketed-IPv6 regression case added (Go runner skips origin interception cases). - Go
Todo: addsCompletionSubscribers(nil-vs-empty preserved) andCommentsCount. - Release tooling:
make releasefails on stale locks; syncs Pythonuv.lockand conformance TSpackage-lock.json. - Python and Ruby full-write paths:
edit/updateraiseUsageErrorwhenassignee_ids/completion_subscriber_idsareNone/nil(use[]to clear). - Architecture: SPEC.md Β§18 and AGENTS.md sanction composite methods and the narrow Go pattern that marshals explicit bodies through generated
*WithBodywhenomitemptycannot express βalways-send-emptyβ.
- Merge-safe
-
Migration
updateno longer clears by omission. Useeditorreplaceto clear fields.- Generated
updateis nowreplaceand requirescontent; compat shims where needed (e.g., KotlinUpdateTodoBody). - Kotlin: todos accessor now returns a hand-written subclass; source-compatible but binary-incompatible for already-compiled consumers.
- Version bumped to 0.8.0 across SDKs.