Skip to content

20 — show: read production crawl output by default, DB fallback - #18

Open
MirjamOdile wants to merge 2 commits into
mainfrom
pr/20-show-production-output
Open

20 — show: read production crawl output by default, DB fallback#18
MirjamOdile wants to merge 2 commits into
mainfrom
pr/20-show-production-output

Conversation

@MirjamOdile

Copy link
Copy Markdown
Contributor

What was broken: show — the command for eyeballing what a spider collected — read only the database. But production crawls deliberately write files, never DB rows; the database holds only the little --limit test samples. So for any spider that had run for real, show displayed stale test data as if it were the collection (observed: 272 old test items shown while the real corpus held 1,600 rows), and it disagreed with overview/audit by design. Reviewers learned to distrust it.

What it does now: show reads the spider's real crawl files whenever they exist (newest items first, same --limit/--url/--title/--text filters), clearly states which source it's showing, and falls back to the database for fresh spiders — so the standard "test 5 items, then check" workflow works unchanged. --source db|crawls|auto overrides (e.g. --source db to re-verify a test crawl after production files exist).

Details

  • cli/show.py: self-contained JSONL reader (newest file first, lines bottom-up — crawl files are append-only), no quality-tool import, so this PR is independent of the quality-tool stack.
  • DB branch untouched; the fallback keeps Phase-4 test verification working with no flag needed.
  • Request doc: docs/requests/20-show-production-output.md.

Behavior changes

  • show's default source changes for any spider that has production crawl files: it now shows the real collection instead of stale DB test samples. To inspect fresh test items on such a spider (e.g. re-testing selectors during a repair), use --source db.
  • Fresh spiders (no crawl files yet) behave exactly as before — the Phase-4 "test 5 items then show" workflow needs no flag.

Verified

5 unit tests (tests/unit/test_show_crawls.py): newest-first ordering across files, all three filters (case-insensitive, matching the DB branch's ilike), limit, garbage-line tolerance. The DB branch is untouched.

show queried only the scraped_items DB table, which holds test-crawl items —
production crawls write crawls/*.jsonl, never DB rows — so it systematically
misrepresented what a spider collected (one spider: show said 272 stale test
items while the production corpus held 1,600 rows) and disagreed with
overview/audit by design.

Default source is now the spider's crawl files when they exist (newest items
first, same --limit/--url/--title/--text filters), with a stated fallback to
the DB otherwise — so Phase-4 test verification (no crawl files yet) works
unchanged. --source db|crawls|auto overrides. The JSONL reader is
self-contained (no quality-tool import), keeping this independent of the
quality-tool PR.

docs/requests/20-show-production-output.md
@iRanadheer
iRanadheer force-pushed the pr/20-show-production-output branch from e911780 to dfa5912 Compare July 30, 2026 08:53
@iRanadheer
iRanadheer force-pushed the pr/20-show-production-output branch from 67b76ad to 5119a74 Compare August 10, 2026 12:23
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