fix: harden the task write API and share completion semantics #9

Merged
agent-navi merged 1 commit from fix/task-write-api-hardening into main 2026-11-15 22:25:21 -05:00
Contributor

Follow-up to #8 after a three-way review.

Broken agent path (live on prod, reproduced): PATCH /api/tasks/:id re-ran the client-side tool executor, so the epoch-millisecond dates the MCP server and CLI send returned 400 Invalid date format, and fields the executor does not model were silently dropped with a 200. It also fell back to fuzzy title search, so a stale ID updated a lookalike task.

Changes:

  • server/src/task-mutations.ts: exact-ID/unique-prefix resolution (no fuzzy), shared updateTask() application, read-back of what was stored
  • zod validation: unknown fields, bad statuses and wrong types return 400; deleted/isDeleted must be booleans, and isDeleted:false restores
  • dates accept ISO strings or epoch ms
  • passthrough for standupStatus, note, remind and scoring fields, repeatPreservePriority
  • by-title treats title as the match key, not a rename
  • completion semantics unified in business/task-completion.ts with a parity matrix test; dueDate is cleared only on the transition into done; a reopen patch that omits doneDate clears it; repeatType without an interval persists 1
  • closed means finished, documented
  • sync push reports repaired documents as conflicts with a bumped updatedAt
  • reset service self-heals legacy done/doneDate:0 rows; storage rewrites are audited

just check passes 9/9.

Follow-up to #8 after a three-way review. **Broken agent path (live on prod, reproduced):** `PATCH /api/tasks/:id` re-ran the client-side tool executor, so the epoch-millisecond dates the MCP server and CLI send returned `400 Invalid date format`, and fields the executor does not model were silently dropped with a 200. It also fell back to fuzzy title search, so a stale ID updated a lookalike task. **Changes:** - `server/src/task-mutations.ts`: exact-ID/unique-prefix resolution (no fuzzy), shared `updateTask()` application, read-back of what was stored - zod validation: unknown fields, bad statuses and wrong types return 400; `deleted`/`isDeleted` must be booleans, and `isDeleted:false` restores - dates accept ISO strings or epoch ms - passthrough for `standupStatus`, `note`, remind and scoring fields, `repeatPreservePriority` - `by-title` treats `title` as the match key, not a rename - completion semantics unified in `business/task-completion.ts` with a parity matrix test; `dueDate` is cleared only on the transition into done; a reopen patch that omits `doneDate` clears it; `repeatType` without an interval persists 1 - `closed` means finished, documented - sync push reports repaired documents as conflicts with a bumped `updatedAt` - reset service self-heals legacy `done`/`doneDate:0` rows; storage rewrites are audited `just check` passes 9/9.
fix: harden the task write API and share completion semantics
All checks were successful
buildbot/nix-eval Build done.
buildbot/nix-build Build done.
09f0955254
Follow-up to #8 after a three-way review found the first cut shipped a
broken agent path and duplicated completion logic.

Agent API:
- PATCH /api/tasks/:id no longer re-enters the client-side tool executor,
  which rejected the epoch-millisecond dates the MCP server and CLI send
  (400 Invalid date format) and dropped fields it does not model
- new server/src/task-mutations.ts resolves exact IDs or unique prefixes,
  never fuzzy titles, so a stale ID 404s instead of updating a lookalike
- zod validation rejects unknown fields, bad statuses and wrong types with
  400 instead of persisting them; deleted/isDeleted must be booleans and
  isDeleted:false restores a soft-deleted task
- pass through standupStatus, note, remind settings, scoring fields and
  repeatPreservePriority
- by-title treats title as the match key, not a rename

Semantics:
- completion rules now live in one shared implementation
  (business/task-completion.ts) used by updateTask and the storage boundary,
  with a parity matrix test
- dueDate is cleared only on the transition into done, so later edits to a
  done one-off task no longer destroy it
- a reopen patch that omits doneDate clears it
- repeatType without repeatInterval persists interval 1
- closed means finished: documented, and the invariant no longer implies
  closed repeats
- sync push reports a repaired document as a conflict with a bumped
  updatedAt so LWW converges on the repaired state; uses the client's own
  timestamp for offline completion
- the reset service self-heals legacy done rows with doneDate 0 from
  updatedAt and records audit entries; storage-boundary rewrites are audited

Docs updated across code-map, README, task-lifecycle, sync-architecture,
database-client, audit-logs, ai-voice-chat and the in-repo scoredo skill.
agent-navi deleted branch fix/task-write-api-hardening 2026-11-15 22:25:21 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jeremy/scoredo!9
No description provided.