Skip to content

Store large values in parts that AdGuard keeps (6.13.1) - #25

Merged
jitdor merged 4 commits into
mainfrom
claude/gracious-keller-do6d7n
Nov 14, 2026
Merged

jitdor merged 4 commits into
mainfrom
claude/gracious-keller-do6d7n

Conversation

@jitdor

@jitdor jitdor commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Why

On AdGuard for Mac, "Restored N visited URLs from the worker" still appeared on every page load with 6.13.0, and each page downloaded the whole history again.

AdGuard sends each GM_setValue to its app as one request, with the value URL-encoded in it. A value too large for that request is not kept, and the script is not told: the writing page still reads it back from its own copy. Once the history passed a few hundred visits it survived no page load at all. Small values, such as the sync settings and session record, were kept, which is why the failure looked like something else.

What changes

  • Parts. A value larger than the device keeps is stored as parts, cut at 80% of the measured limit and counted as if JSON- and then URL-encoded. A short pointer to them is written after a settle delay. The pointer also names the previous complete set, and readers fall back to it if a part is missing. A history found incomplete but recent is not written over.
  • Saves made as a page is left. Saves not made by a sync pause briefly before writing parts, so a page that navigates away writes none. The journal and the replay note carry the change to the next page.
  • Cleanup. A tab removes the set before the one it replaced. Part sets nothing refers to are removed two minutes after being written, at boot and after main saves.
  • Save coalescing. A save that hasn't started yet absorbs later requests, so a burst of clicks costs one or two saves.
  • Storage probe. Values of 2, 8, 32 and 128 KB are written and judged on the next page load. The largest kept size becomes the limit, shown in the panel, and is re-measured weekly. Until then parts are about 6 KB. Managers with change notifications, such as Tampermonkey, are not probed.
  • The worker is unchanged. Its version moves to 6.13.1 with the script.

Testing

  • The harness gains maxEncodedValue (JVS_VALUE_LIMIT), modelling a manager that drops oversized values while the writing tab still reads them back.
  • Under an 8 KB limit, 6.13.0 fails 12 tests, including a reproduction of the reported symptom.
  • This branch passes 150/150 in four configurations: npm test, JVS_DOTTED=1, JVS_VALUE_LIMIT=8000, and both together.
  • New: tests/storage-size.test.mjs and the review's tests/review-parts.test.mjs (P1–P5: storage bloat, probe leaks, missing-part fallback, interrupted upload, JSON-encoded size).
  • Not run on a real AdGuard install. After updating, the panel shows the measured limit, which confirms or rules out this cause on the device.

Generated by Claude Code

AdGuard sends each GM_setValue to its app as one request with the value
URL-encoded in it, and drops a value too large for that request without
telling the script, while the writing page still reads it back. Past a
few hundred visits the history survived no page load at all, so every
page downloaded it again with "Restored N visited URLs".

Values larger than the device keeps are stored as parts under that size,
plus a pointer written last; a value with a missing part reads as
missing. Each tab trims the part sets it replaced (keeping two), and
parts nothing refers to are removed 30 minutes after they were written.
The device's limit is measured with probe values (2/8/32/128 KB) judged
on the next page load, and shown in the panel; until known, parts are
about 6 KB.

The harness gains maxEncodedValue (JVS_VALUE_LIMIT) to model this; under
an 8 KB limit 6.13.0 fails 12 tests and this passes all 144.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCuhK4TQqcEbLXdmxLjggy
P1 orphaned history copies per page load, P2 leaked probe values,
P3 missing part wipes history despite kept previous set, P4 click-navigate
lands pointer before parts, P5 JSON-encoded size exceeds measured limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCuhK4TQqcEbLXdmxLjggy
Review found that a page usually saved the history once, so replaced part
sets lingered 30 minutes (a full copy per page load); that one missing
part made the next save write a near-empty history over a complete
previous set; that an unordered or interrupted upload could land the
pointer without its parts; that encoded size was measured more loosely
than AdGuard may count it; and that tabs probing together leaked probe
values.

- Pointers name the previous complete set; readers fall back to it, and
  a history found incomplete but recent is not written over.
- Parts are cut at 80% of the measured limit, counted JSON-then-URL
  encoded; the pointer waits for parts to arrive; saves not made by a
  sync pause before writing parts, so a page being left writes none.
- Tabs trim the set before the one they replaced; unreferenced parts go
  after two minutes; retirement also runs after main saves.
- Queued saves coalesce, so a burst of clicks costs one or two saves.
- Fixed probe keys, cleared by the judging page; last limit kept while
  re-measuring; a floor when nothing was kept.
- A save stopped by leaving the page is not reported as a failure.

Adds the review's tests (review-parts.test.mjs) and a test for leaving
mid-save; 150/150 pass with and without an 8 KB value limit and with the
dotted GM API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCuhK4TQqcEbLXdmxLjggy
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T22:29:43.152800Z ce896bd PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

jitdor commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

Workers Builds: javstore-sync fails on this PR, but not because of this change.

  • Cloudflare builds only production for this worker, so a PR branch's build fails at once (started_at equals completed_at).
  • The worker code is unchanged here. Only WORKER_VERSION moves, to stay in step with the script.
  • The repo's own test check is what decides whether this can merge.

Generated by Claude Code

@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: ce896bd5e3

ℹ️ 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 thread javstore-full-layout-cleanup.user.js Resolved
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Failed ❌

View logs ↗
8c51c71 2026-11-14T22:38:20.251Z View logs ↗
  • Build: Failed ❌

View logs ↗
ce896bd 2026-11-14T22:11:37.373Z View logs ↗

A page that read the previous part set because the newest one was missing
a part did not count the value as incomplete, so its next save could
replace the pointer before the late part landed and drop the visits only
the newest set held.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VCuhK4TQqcEbLXdmxLjggy
@jitdor
jitdor merged commit a72cae3 into main Nov 14, 2026
1 of 2 checks passed
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