Skip to content

Feat/reliability and tests - #5

Merged
amantebriwal4321 merged 13 commits into
mainfrom
feat/reliability-and-tests
Sep 13, 2026
Merged

amantebriwal4321 merged 13 commits into
mainfrom
feat/reliability-and-tests

Conversation

@amantebriwal4321

Copy link
Copy Markdown
Owner

No description provided.

amantebriwal4321 and others added 13 commits September 13, 2026 16:52
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>
@vercel

vercel Bot commented Sep 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
stack-radar Ready Ready Preview Sep 13, 2026 11:50am UTC
stack-radar-a3jy Ready Ready Preview Sep 13, 2026 11:50am UTC

@amantebriwal4321
amantebriwal4321 merged commit 38802fa into main Sep 13, 2026
6 checks passed

This branch was successfully deployed

2 active deployments
Preview – stack-radar-a3jy — cd243d15 Deployed Sep 13, 2026 by vercel[bot]
Preview – stack-radar — cd243d15 Deployed Sep 13, 2026 by vercel[bot]
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