Fix todos update silently clearing completion subscribers

Merged
JE
5mo ago
+402-12

Fixes #538.

Problem

Every basecamp todos update wiped the todo's completion subscribers ("When done, notify…"). The BC3 todos PUT has replace semantics — omitted field = cleared — and neither update branch included completion_subscriber_ids. The #412/#413 read-modify-write merge couldn't preserve them because the SDK's Todo model drops completion_subscribers in todoFromGenerated (basecamp/basecamp-sdk#355), so the merge had nothing to carry forward.

Fix

Preservation — a plain update now reads the current subscriber ids via a raw GET of the flat /todos/{id}.json route (which serves the field the SDK model drops) and carries them into the PUT, in both the typed-merge and raw-clear branches. The read fails closed: an HTTP error, malformed JSON, or a response missing the completion_subscribers key aborts before any PUT — the command never reaches the write without either explicit user intent or a verified read of current state. The completionSubscriberIDs helper is commented as temporary; it and both call sites go away once the SDK round-trips the field and the CLI collapses onto the SDK's merge-safe update.

Explicit control — subscribers become directly editable:

  • todos create --notify-on-completion <names or ids> and todos update --notify-on-completion <names or ids> set them (comma-separated, people-name tab completion)
  • todos update --no-notify-on-completion clears them (clearing works by omission; explicit intent skips the preservation read entirely)

Tests

  • Unit: the update mock transport now records ordered requests and serves the flat route configurably. Coverage: preservation of existing subscribers through title-only, due-only, and --no-due updates; flat-route assertion (no /buckets/ read); explicit set/clear with no preservation GET; a fail-closed matrix (missing key / malformed JSON / HTTP 500 × merge / clear branch) asserting no PUT occurs; flag-conflict usage error; completion_subscriber_ids in the create body.
  • Live smoke: new BATS scenario — create with subscriber → title-only update preserves → --no-due preserves → --no-notify-on-completion clears → trash. Not yet run against a live server (no QA credentials in the authoring session); needs a make smoke pass before this counts as runtime-verified.
  • bin/ci fully green (fmt, vet, lint, unit, replay e2e, naming, surface, skill drift, bare groups, smoke coverage, provenance, tidy).

Bookkeeping

  • skills/basecamp/SKILL.md documents the new flags and that plain updates preserve subscribers.
  • .surface gains the three new flag records, hand-inserted and verified identical to fresh generation. A full snapshot regeneration is deliberately deferred: the committed snapshot has ~9k lines of unrelated drift since #499 changed the generator — tracked separately in #539.

Summary by cubic

Stops basecamp todos update from wiping "When done, notify…" subscribers. Preserves existing subscribers and adds flags to set or clear them explicitly.

  • Bug Fixes

    • Preserve subscribers by reading completion_subscribers from /todos/{id}.json and sending completion_subscriber_ids in PUTs (both merge and clear paths).
    • Fail closed: abort on read errors, missing/malformed responses, or any subscriber with a missing/invalid id; no PUT on failure.
    • Read errors pass through convertSDKError to keep structured SDK codes/hints.
    • Use completion‑subscriber wording in --notify-on-completion errors; person resolution is parameterized so messages reference subscribers, not assignees.
    • Tests: cover name‑resolution failures, exact flat route usage, explicit set/clear skipping the read, and preservation in both branches.
  • New Features

    • todos create --notify-on-completion <names|ids> and todos update --notify-on-completion <names|ids> set subscribers (with people‑name completion).
    • todos update --no-notify-on-completion clears subscribers; explicit set/clear skips the preservation read.
    • Docs updated and flags added in .surface.