Skip to content

feat: tell stale sessions to reload, skip unclearable challenges and block pages - #21

Merged
samgozman merged 1 commit into
mainfrom
fix/stale-server-and-challenges
Nov 30, 2026
Merged

samgozman merged 1 commit into
mainfrom
fix/stale-server-and-challenges

Conversation

@samgozman

Copy link
Copy Markdown
Owner

Why

A month of real usage (30 Oct – 29 Nov) showed refetch resolving only 5 of 12 failed reads it picked up. Checking each failure against the events DB, the transcripts and a replay through 0.5.0 found:

  • Most of the losses came from a stale session. The 27 Nov session ran the 0.3.0 MCP server (no Wayback step) days after 0.5.0 was installed: Claude Code keeps a session on the plugin version it started with. Replayed through 0.5.0, 12 of the 16 failed fetches succeed, 7 of them through Wayback.
  • Headless Chrome spent ~13 s on each of 5 challenges that never cleared (2 Cloudflare managed challenges, 1 Cloudflare block page, 2 Imperva block pages).
  • Some rows were misclassified. An F5 "Request Rejected" page (HTTP 200) counted as ok, a usage-limit message counted as a failed read, and tiny api.php JSON replies were flagged as "page needs JavaScript".

What changes

  • Stale sessions: the SessionStart note, failed fetch_page results and refetch doctor say when a newer refetch is installed next to the running one, and to run /reload-plugins or restart Claude Code. events.db records the refetch version on every row (schema v2, upgraded in place; older binaries keep writing to it). refetch stats splits fetches by version when more than one shows up.
  • Challenges: headless Chrome gives a challenge 8 s to clear instead of the whole render timeout, and stops at once on a block page.
  • Block pages: Cloudflare's "you have been blocked", Imperva's incident page, F5 BIG-IP's rejection and Akamai's Access Denied are refusals. They skip headless Chrome and go to the Wayback Machine, and a snapshot or render of one is not counted as a read.
  • Hook: Claude Code's own errors (usage limits, the auto mode classifier, a declined permission) are recorded as denied and get no nudge. A tiny reply from an API address is no longer "page needs JavaScript".

Verified

  • make test, make cover-check (92.5%) and make lint pass. New tests cover block pages, the challenge cap (real Chrome), the v1→v2 migration with concurrent opens, the stale-plugin check and the hook cases.
  • On the live sites: holmesplace ~21 s → 4 s, adn.sura ~20 s → 7 s (both via Wayback); factor75 and rohlik 13 s → ~9 s of headless before Wayback reads them.
  • A copy of the real events.db upgrades cleanly, and the 0.3.0 and 0.5.0 binaries still write to it.

🤖 Generated with Claude Code

…lock pages

From a month of real usage: most failed reads came from a session still
running refetch 0.3.0 days after 0.5.0 was installed, so the Wayback step
never ran; headless Chrome spent 13 s on each of 5 challenges that never
cleared; and a few rows were misclassified.

- Stale sessions: the SessionStart note, fetch_page errors and doctor say
  when a newer refetch is installed next to the running one, and to run
  /reload-plugins or restart Claude Code. events.db records the refetch
  version on every row (schema v2, upgraded in place), and stats splits
  fetches by version when more than one shows up.
- Challenges: headless Chrome gives a challenge 8 s to clear instead of the
  whole render timeout, and stops at once on a block page.
- Block pages: Cloudflare's "you have been blocked", Imperva's incident
  page, F5 BIG-IP's rejection (served with HTTP 200) and Akamai's Access
  Denied are refusals, not challenges or pages: they skip headless Chrome
  and go to the Wayback Machine, and a snapshot of one is not a read.
- Hook: Claude Code's own errors (usage limits, the auto mode classifier,
  a declined permission) are recorded as denied and get no nudge; a tiny
  reply from an API address is no longer "page needs JavaScript".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.75258% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.66%. Comparing base (7798dfb) to head (d385c32).

Files with missing lines Patch % Lines
cmd/refetch/archive.go 0.00% 2 Missing ⚠️
cmd/refetch/hook.go 93.75% 1 Missing ⚠️
cmd/refetch/main.go 50.00% 1 Missing ⚠️
cmd/refetch/mcp.go 75.00% 1 Missing ⚠️
cmd/refetch/stale.go 96.77% 1 Missing ⚠️
fetch/detect.go 85.71% 1 Missing ⚠️
store/store.go 95.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #21      +/-   ##
==========================================
+ Coverage   92.62%   92.66%   +0.03%     
==========================================
  Files          43       44       +1     
  Lines        3933     3994      +61     
==========================================
+ Hits         3643     3701      +58     
- Misses        288      291       +3     
  Partials        2        2              
Files with missing lines Coverage Δ
cmd/refetch/doctor.go 90.28% <100.00%> (-0.53%) ⬇️
fetch/fetch.go 95.80% <100.00%> (+1.86%) ⬆️
render/drive.go 90.85% <100.00%> (+0.68%) ⬆️
stats/stats.go 97.45% <100.00%> (+0.01%) ⬆️
stats/text.go 92.20% <100.00%> (+0.20%) ⬆️
cmd/refetch/hook.go 89.83% <93.75%> (+0.19%) ⬆️
cmd/refetch/main.go 87.98% <50.00%> (+0.05%) ⬆️
cmd/refetch/mcp.go 90.47% <75.00%> (-0.50%) ⬇️
cmd/refetch/stale.go 96.77% <96.77%> (ø)
fetch/detect.go 93.33% <85.71%> (-2.32%) ⬇️
... and 2 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samgozman
samgozman merged commit 2832b62 into main Nov 30, 2026
6 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.

1 participant