8000 Count newly indexed URLs, not submitted results, in crawler stats by daoudclarke · Pull Request #609 · mwmbl/mwmbl · GitHub
[go: up one dir, main page]

Skip to content

Count newly indexed URLs, not submitted results, in crawler stats - #609

Merged
daoudclarke merged 2 commits into
mainfrom
claude/stoic-keller-0942zw
Nov 9, 2026
Merged

daoudclarke merged 2 commits into
mainfrom
claude/stoic-keller-0942zw

Conversation

@daoudclarke
Copy link
Copy Markdown
Contributor

Closes #608

What changed

  • index_documents now also returns IndexedURLs: the URLs it stored, and which of those the index didn't hold before. This is the same calculation index_new_documents already did, and that function now delegates to it.
  • POST /crawler/results records len(indexed.urls.new) instead of len(results.results). That number feeds the daily results count, the user and leaderboard counts, UserStats, the crawler-version spread and the device totals.
  • A submission that adds nothing still counts the crawler as active that day and records its version. It no longer creates a 0-score leaderboard entry or a UserStats row.

Why

Since the batched results API (#598), the crawler posts every local item that isn't SYNCED_WITH_MAIN_INDEX, every round:

  • Items the main index doesn't keep are never marked synced, so they get resubmitted every round.
  • A URL is repeated once for each term page it was retrieved from.

The server counted every submitted result, so the same pages were counted over and over.

Things to be aware of

  • Recrawls earn no credit. A recrawl of a URL the index already holds counts 0, and credit goes to whoever submits a URL first. Before the batched API, the crawler only submitted URLs missing from the remote term page, so this is close to the old meaning.
  • Mixed history. All-time leaderboard and UserStats history already includes the inflated numbers. This PR doesn't backfill them.
  • Volunteer tiers. The tier threshold (results/day) will be harder to reach under honest counting, so it may be worth revisiting.
  • Not fixed here (crawler side). The crawler still resubmits items the index didn't keep. That wastes upload and indexing work, but no longer inflates stats. Fixing it needs a crawler release.
  • Not fixed here (trust and safety, pre-existing). Fabricated unique URLs still each count as new. A per-key daily cap on new URLs would address it, but that's outside this issue.

Verification

  • New test/test_indexed_results_count.py:
    • Posting the same URL twice in one submission counts it once.
    • Resubmitting it alongside a new URL counts only the new one.
  • New test in test/test_stats.py for a zero-result submission.
  • make test: 1774 passed and 1 failed (a version-spread test that mocked indexing), which I then fixed. The affected test files pass afterwards (140 passed). ruff format --check and ruff check are clean.
  • ty reports the same 1211 diagnostics with and without this change in this environment, so make check fails here either way.
  • A review subagent did a standard, trust-and-safety and holistic review. I fixed the zero-result finding; the other findings are listed under "Things to be aware of".

Generated by Claude Code

Since the batched results API, a crawler posts every local item not yet
marked synced, on every round. Items the main index does not keep are
never marked synced, so they are resubmitted indefinitely, and a URL is
repeated once for each term page it is retrieved from. The server
counted len(results.results), so the daily results count, leaderboard,
user stats, crawler-version spread and device totals all over-counted.

index_documents now reports which URLs it stored and which of those the
index did not hold before (what index_new_documents already computed,
which now delegates to it), and POST /crawler/results records the
number of new URLs instead.

Closes #608

No functional changes to the crawler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DTbu4oERm8rGd9iRy29EiL
No functional changes to the crawler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DTbu4oERm8rGd9iRy29EiL
@codecov
codecov Bot commented Nov 8, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@daoudclarke
daoudclarke merged commit b6a56ce into main Nov 9, 2026
7 checks passed
@daoudclarke
daoudclarke deleted the claude/stoic-keller-0942zw branch November 9, 2026 05:56
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.

Fix over-counting of indexed sites

2 participants

0