fix(sync): push marks only applied or duplicate operations and replays refusals within bounds #159

Merged
maximus merged 4 commits from issue-151-push-results-refusals into master 2026-10-25 01:22:19 +00:00

4 commits

Author SHA1 Message Date
le king fu
b88ca81e07 test(sync): close the reviewer mutation gaps of the stack
Tests for mutations that stayed green in the reviews of PRs #154 to #159,
all added at the top of the stack (decision of Max, 2026-10-24):

- route: a task sent to an archived regular list stays there; the most
  recent active inbox wins the redirect; every POST cleans the
  idempotency store (#145, #147)
- idempotency store: a refreshed key moves to the newest end (#147)
- syncRules: an unknown result status is neither marked nor counted; the
  429 retry bound fails the test instead of hanging the suite (#151)
- smoke source check of syncClient.ts wiring: `since` forwarded by the
  pull, kept rows re-queued then left untouched, local row passed to
  pulled*Values, no local tag version in any form, SYNC_EPOCH stamped
  before the full pull of initialMerge, successful batches marked even
  after a failed one, widget refreshed after marking (#149, #150, #151)

Refs #151

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 20:55:44 -04:00
le king fu
fa16a5be44 test(sync): lock refusal replay and marked ids of the push
A refused operation replayed with the same idempotency key must come back
skipped with an error again (otherwise the app marks it synced and loses
it), and pushChanges must mark only the ids kept by classifyOutbox. Both
gaps were found by reviewer mutations on PR #159.

Refs #151

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 17:17:26 -04:00
le king fu
a65d72b7a0 fix(sync): read a missing Retry-After as null, not 0
Number(null) and Number('') are 0: a 429 without a Retry-After header
made initialMerge resend the same batch three times with no wait instead
of waiting 60 s. The header is now read by parseRetryAfter (syncRules.ts,
tested under node), and the smoke guard locks its use in postBatch.

Found by the autopilot self-review of PR #159.

Refs #151

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 17:16:10 -04:00
le king fu
079a17b2f5 fix(sync): push marks only applied or duplicate operations and replays refusals within bounds
pushChanges marked the whole outbox as synced once every POST answered
200, so an operation the server refused (skipped with an error) was lost.
It now reads the results: applied and skipped-without-error entries are
marked, a refusal is replayed at every push for 30 days, among the 100
most recent, until a newer entry of the same entity goes through. A
failed batch no longer hides the results of the batches before it.

The batch loop moves to syncRules.ts (sendInBatches), tested under node:
pushChanges sends 8 batches at most and stops at a 429, initialMerge
sends every batch and waits for the Retry-After of a 429 (60 s at most,
3 resends), so a first sync no longer fails at its eleventh batch.

Server side, comments only, plus a test of the results contract.

Refs #151

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 17:16:10 -04:00