Skip to content

Make the worker's visited history append-only (6.10.0) - #19

Merged
jitdor merged 1 commit into
mainfrom
ccr-c9f4e623-e1og9s
Sep 28, 2026
Merged

jitdor merged 1 commit into
mainfrom
ccr-c9f4e623-e1og9s

Conversation

@jitdor

@jitdor jitdor commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Problem

The worker applied every removal a device sent and hard-deleted the rows. One Clear visited history, one retention setting above 0, one unmarked card or one import of an older backup, on any device, wiped those visits from the worker and from every other device. The only way back was an exported backup.

Change

  • The worker ignores visit tombstones and the resetAt / prunedBefore horizons from devices, and reports both horizons as 0.
  • A visit outranks a visit tombstone an older worker already stored. A horizon an older worker stored is no longer reported to devices or used to refuse visits.
  • Clearing history, retention pruning, unmarking a card and the entries an import leaves out now apply only to the device they happen on. The clear confirmation says so when sync is on.
  • The 50,000-visit archive cap still drops the oldest visits. Per-card override removals still sync to every device.
  • READMEs and CHANGELOG updated. The worker needs redeploying, which the Cloudflare build does on merge.

Tests

Six tests rewritten or added for the new behaviour: unmark, clear (including a full re-download afterwards), import, the worker ignoring deletions and horizons (delta and 6.2.0 whole-document paths), and data left by an older worker. All six fail against the old worker. Full suite: 77/77 passing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BGAYvSDCqQt1R7AerUwSeT


Generated by Claude Code

The worker applied every removal a device sent and deleted the rows: one
clear, retention cutoff, unmark or backup import on any device wiped those
visits from the worker and every other device. It now ignores visit
tombstones and the resetAt/prunedBefore horizons, reports both horizons as
0, and lets a visit outrank a visit tombstone an older worker stored. Those
actions now apply only to the device they happen on. The 50,000-visit
archive cap and override removals are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BGAYvSDCqQt1R7AerUwSeT
@jitdor
jitdor merged commit f06cf1e into main Sep 28, 2026
2 of 3 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 466ae84ac6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +2634 to +2636
const kept = syncConfigured()
? 'Only this device is cleared: your sync worker and other devices keep their copies.'
: 'This cannot be undone unless you exported a backup.';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Warn before clearing through an older worker

When sync is configured but the worker has not yet been redeployed to 6.10.0, this confirmation falsely promises that the worker and other devices will keep their copies. The clear still sends the new resetAt through persistState(), and a pre-6.10 worker applies that horizon by deleting its visits and propagating the clear globally. Only show this reassurance after confirming a worker version with append-only behavior; otherwise warn that clearing may affect every device or require redeployment first.

Useful? React with 👍 / 👎.

Comment thread worker/src/worker.mjs
Comment on lines +191 to +193
// A visit tombstone a worker from before 6.10.0 stored never outranks a visit.
const buried = kind === 'v' && existing.deleted;
const wins = buried || at > existing.at || (at === existing.at && deleted && !existing.deleted);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Do not return pre-upgrade visit tombstones

When an upgraded Durable Object contains a visit tombstone from the old worker, sync() captures that tombstone in ahead before this branch replaces it with an incoming visit. A recovering device with an earlier cursor can therefore upload its retained visit, receive the obsolete tombstone in the same response, delete its local copy, and then record the cursor for the replacement sequence, so the worker's restored visit is never downloaded. Suppress legacy visit tombstones from responses or replace the captured row with the newly stored visit.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants