Decision from Max (2026-10-21, after review comment 26317): forget the
parent existence check altogether. The review found that
orderSyncOperations was quadratic and synchronous, so one authenticated
request of a few MB could freeze the companion for every account, and
that the strict check on updates would silently refuse every edit of a
subtask already stored without its parent.
The tree is back to fdd4c95 (approved in comment 26259): a parentId held
by another account is still refused (assertIdNotTaken), a missing
parent is accepted as before.
This reverts commit e8abcfc217.
Refs #142
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Decision from Max (2026-10-21, /pr-brief of PR #144): a subtask whose
parent does not exist on the server is refused, instead of accepted
when no other account holds the id.
initialMerge pushes every local task in one batch, in SQLite order, so
a subtask could come before its parent. orderSyncOperations moves a
subtask create right after the create of its parent when both are in
the batch (nested subtasks and cycles handled); every other operation
keeps its relative order. A parent sent in a later batch is not found
and the subtask is skipped, which Max accepted.
Refs #142
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ownership checks added for #142 were only proven by benches kept
out of the repo: removing one left `npm test` green. route.test.ts runs
the real POST handler against PGlite (in-memory Postgres, migrations
0000-0002 applied) with two accounts: an initialMerge batch, userId and
other forbidden keys in data, task-tag links, task listId/parentId, and
list creation with an id held by another account. Each of the 11 route
guards, when removed, turns 1 to 4 tests red; 12 of 14 fail on master's
route.
PGlite is installed under the npm alias `electric-sql-pglite`. Under its
real name it satisfies drizzle-orm's optional peer, npm then counts it
in the production tree and `npm ci --omit=dev` would ship 35 MB in the
image. vitest.config.mts maps the real name to the alias and inlines
drizzle-orm so its pglite driver picks it up.
Refs #142
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
POST /api/sync copied the client's `data` into `.set()` for list, task
and tag updates, so an authenticated client could rewrite `userId`
(moving its rows into another account), `id`, `createdAt` or
`deletedAt`. Task-tag links, task `listId`/`parentId` and list creation
did not check that the referenced rows belong to the caller.
- web/src/lib/syncData.ts: one zod schema per entity and action. Unknown
keys are stripped rather than rejected, because the app marks its
outbox as synced on HTTP 200 and a skipped operation would be lost.
Strings are truncated to the mobile limits (notes 10000). Null maps
to undefined for NOT NULL columns.
- processOperation writes only the parsed output; taskTag create and
delete verify the task and the tag; task create/update verify
listId; parentId and list create ids are refused when taken by
another account (a missing parent passes, since initialMerge can push
a subtask before its parent).
- vitest 4.1 (vitest 5 requires @types/node >= 22, web is on 20) with
tests built from the payloads the app sends today.
- REVIEW.md: rules and pitfall updated, npm test added, syncData.ts in
the Haut table (review-levels.py --check passes).
Refs #142
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>