Repository navigation
Feat/reliability and tests - #5
Merged
Merged
Conversation
perform_full_scrape catches its own exceptions and rolls back, so it never raises. run_scraper_loop then stamped last_scraped_time = now unconditionally. /overview reads that field for its freshness label, so after a pipeline error the site reported "Live" about data the scraper had just failed to refresh - the exact silent failure that hid the decommissioned Groq model. perform_full_scrape now returns True only when the final commit landed. The loop stamps last_scraped_time on success alone, and otherwise counts consecutive_failures and records last_failure_time, so the next step can make a broken scraper loud instead of invisible. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…data /health returned "status": "ok" as a literal - with the database unreachable, and with data weeks old. Checked against the local DB, last scraped 18 July: the old endpoint reported ok on data 81,714 minutes stale. - app/services/health.py: assess_freshness(), pure, classifying the data as fresh / stale (older than 2h, four missed cycles) / failing (2+ consecutive failed cycles) / never. It falls back to the newest ToolSnapshot because the in-process scrape stamp resets on every restart, which on a sleeping free tier is often. - /health stays 200 - a platform restarting the process would not fix stale data - but its status is now ok / degraded / error and it carries the freshness report. - /health/data returns 503 whenever the data is not fresh. That is the URL to give an uptime monitor. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The key hashed in the middle of the endpoint, where the only way to check it was a deploy - and each of its three omissions (search, deny, the gate logic) was found that way, as a fix that appeared to do nothing for 24 hours. It is now a pure function beside video_matches and GATE_VERSION, which it depends on. Same tuple, same order: all 13 production keys are unchanged, so no cached video is invalidated by this. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The repo had no tests. Yesterday's four walkthrough bugs were all found by reading production output by hand, and every one lives in a pure function. tests/test_projects.py (33 tests, 0.04s): - the six titles that actually reached live project pages, as regressions - "How to Run Claude Code Completely Free" on the Rust grep brief, "no Tensorflow/PyTorch" on the PyTorch one, a MERN build and a payments episode on the Next.js URL shortener - the gate rules: negation (and that "notebook"/"known" are not negations), deny beating a full match, case, missing titles - video_cache_slug changes with search, must, any, deny AND GATE_VERSION - each was once missing from the key - no project slug is a prefix of another, which the LIKE 'project:<slug>%' purge silently depends on - normalise_steps shapes, and every brief has a search string and a gate Mutation-checked: with the negation pattern replaced by one that never matches, 5 tests fail. pytest lives in requirements-dev.txt so the production image is unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
11 tests for assess_freshness: fresh / stale / failing / never, the exact window boundary, one tolerated failure, stale outranking failing, the ToolSnapshot fallback after a restart wipes the in-process stamp, naive SQLite datetimes, Z-suffixed and unparseable timestamps. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Drives run_scraper_loop for exactly one cycle with a fake pipeline: success stamps and resets the failure count; a pipeline returning False or raising leaves the previous stamp alone and increments consecutive_failures. Run against the pre-fix scheduler, a failed cycle stamped the current time - the bug these tests pin down. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
30 tests on the number the product is built on, where a bug still produces a plausible 0-100: - scores are absolute - a tool's score is identical alone, beside a 230k-star repo, or beside an empty one - no flat base (no signal = 0), capped at 100, bounded for any input, and monotonic in stars - community activity saturates at 25 mentions and carries exactly 25 points - a single mention registers (the old round(0.5) = 0 sink) - _norm_log floor, ceiling and geometric midpoint - word-boundary matching, one count per item, integer counts, and Dev.to descriptions and tags being searched - growth-stage and trend thresholds at every boundary Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
tests/conftest.py now points DATABASE_URL at a temp SQLite file before anything imports the app, blanks every API key, and disables both background startup tasks - so the suite gives the same answer on a CI runner with no database as on a laptop with months of scrapes. (Against the local test.db the "never scraped" test would have read "stale" instead.) main.py: WARM_RESOURCE_CACHE=0 skips the startup cache warm, which otherwise calls YouTube from the test process. Default unchanged. tests/test_api.py (7 tests): boots with no keys and seeds 31 tools; a never-scraped DB is degraded on /health and 503 on /health/data; fresh data is ok; repeated failures fail /health/data; /projects serves every brief; a project with no key and an unverifiable video still ships docs and five fully shaped steps; unknown project is 404. 85 tests, 1.5s. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
health.py used Optional[...] where the repo's ruff config wants X | None, and main.py's startup imports were unsorted. Import ordering only in main.py; the app boot is exercised by tests/test_api.py and still passes. Ruff on app/: 199 findings on main, 195 on this branch. The lint job was already failing before this work; this branch leaves it no worse. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Backend CI only checked that the app imports and has a /tools route. It now installs requirements-dev.txt and runs pytest before the import check. The suite needs no database, secrets or network, so it runs on a bare runner. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…oring model - replace "There is no test suite" with how to run it and what conftest isolates - document /health vs /health/data and point uptime monitoring at the latter - record that perform_full_scrape returns success and only a clean cycle stamps last_scraped_time - correct the scoring description: scores are absolute per-tool, not percentile ranks across tools - the old text said the opposite of the code - add WARM_RESOURCE_CACHE to the env var list Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Backend CI has failed on every run since at least 8 September, main included. The failing step was an inline python -c route assertion; it exits 1 and the public annotations say nothing more. The same assertion passes locally, and on the runner the pytest step - which imports and boots the same app - passed. The check now lives in tests/test_api.py and names ten public routes explicitly, so a failure says which route is missing. The inline step is removed rather than debugged blind. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Found it. From FastAPI 0.141 an included router appears in app.routes as a single path-less _IncludedRouter. Walking app.routes therefore finds no /api/v1 route at all while every request still returns 200. requirements.txt does not pin fastapi, so CI installs 0.141.1 and this laptop has 0.135.1 - which is why the old inline route check failed on every CI run since at least 8 September and passed locally, and why its replacement failed the same way. Reproduced with a minimal app on both versions. The route test now reads the OpenAPI schema, which is public and version-stable. Full suite: 86 passed on 0.135.1 and 86 passed on 0.141.1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.