Commit graph

6 commits

Author SHA1 Message Date
5a21133b1d feat(observability): structured logging, metrics wiring, graceful degradation
- Item 5: Convert remaining printf-style logger call to structured logging
  (key=value format) in x402_middleware.py
- Item 6: Wire CACHE_HITS counter into cache get() and per-tier SCRAPE_LATENCY
  histogram into UltimateScraper scrape loop
- Item 7: Add circuit-breaker checks in extractor.py (Ollama) and
  routers/vision.py (OpenRouter) to fail fast and record success/failure
  when external services are down; attach recovery results to resilience
  registry for per-service circuit state

560 tests passing, ruff clean
2026-07-03 12:13:03 +02:00
1f9e71d294 refactor(settings): unify config.py, mconfig.py, and settings.py into single PrySettings
- Merge all configuration into settings.py with PRY_* env var prefix.
- Add legacy env aliases (PROXY_URL, TOR_ENABLED, MAX_RETRIES, etc.) for migration.
- Load and persist runtime overrides from JSON config file (default /app/config.json).
- Update scraper.py, deps.py, routers/config.py to use unified settings.
- Add resolved_proxy_chain and resolved_proxy_url properties.
- Replace tests/test_mconfig.py with tests/test_settings.py (9 tests).
- Update .env.example with new PRY_* options.
- All 500 tests pass; ruff clean.
2026-07-03 05:04:29 +02:00
8b52f14774 feat(pry): phase 0 — split routers, add tests, apify schema, pry api key (#5)
Some checks failed
CI / Secret scan (gitleaks) (push) Successful in 34s
CI / Security audit (bandit) (push) Successful in 35s
CI / test (push) Successful in 1m23s
CI / lint (push) Failing after 49s
CI / typecheck (push) Successful in 55s
2026-07-03 03:43:02 +02:00
07288a01d7 feat(db): add Alembic migrations (#6)
All checks were successful
CI / typecheck (push) Successful in 51s
CI / Secret scan (gitleaks) (push) Successful in 32s
CI / lint (push) Successful in 47s
CI / Security audit (bandit) (push) Successful in 35s
CI / test (push) Successful in 1m20s
2026-07-03 02:22:33 +02:00
a7c30b12cd chore(lint): auto-fix 253 of 283 ruff issues (F401, I001, E402, RUF100, UP037, SIM105)
Some checks failed
CI / lint (push) Failing after 2s
CI / typecheck (push) Failing after 2s
CI / test (push) Failing after 2s
CI / Secret scan (gitleaks) (push) Failing after 1s
CI / Security audit (bandit) (push) Failing after 2s
Mass ruff auto-fix:
  - ruff check --fix: 109 issues fixed (F401 unused imports,
    I001 unsorted imports, UP037 quoted annotations, SIM105
    suppressible exception, RUF100 unused-noqa)
  - ruff check --fix --unsafe-fixes: 22 additional issues
  - ruff format: 70 files reformatted
  - Manual pass: fix 16 misplaced import httpx lines
  - Manual pass: fix remaining E402 (import-after-docstring)

Result: 283 errors -> 30 errors.

The remaining 30 are real issues that need manual review:
  5 F401 unused-import (likely auto-generated stubs)
  5 F821 undefined-name (real bugs in code that references
    redis/pydantic/LLMRegistry without imports)
  3 BLE001 (the compliance LLM fallback is intentional; the
    other two are real)
  3 RUF012 mutable-class-default
  3 SIM105, 3 SIM117, 2 E722, 2 E741
  1 B007, 1 B025, 1 E402, 1 RUF200 (pyproject.toml issue)

Tests: 436/437 pass (1 pre-existing SSE sandbox failure).
format check + import sort: now clean.
make ci: still gated on the 30 remaining real issues.
Follow-up: triage the 30 issues file-by-file.
2026-07-02 21:51:25 +02:00
00db352faa refactor(api): split Auth endpoints into routers/auth.py (127 lines)
This is the first split of api.py (4,668 lines) into a routers/
package, one router per OpenAPI tag. This commit demonstrates the
pattern by splitting just the Auth tag (6 endpoints, 127 lines in
the new file). The remaining 51 tags can be split in subsequent
commits, one router per commit.

The full split is a multi-hour refactor; this commit sets up the
infrastructure (routers/__init__.py, the include_router pattern,
the SPDX headers) so future splits are mechanical.

Changes:
- New package routers/
  - __init__.py (45 lines, package docstring, migration order)
  - auth.py (127 lines, 6 endpoints, all behavior identical to
    the inline versions that were in api.py)
- api.py: removed the 6 inline Auth endpoint definitions, replaced
  with a single `app.include_router(auth_router)` call
- api.py LOC: 4,668 -> 4,627 (-41 lines)
- Total FastAPI routes: 197 -> 192 (the 6 inline removed, 1
  _IncludedRouter placeholder added; 5 unique paths in OpenAPI
  spec - same as before, since GET+POST share a path)
- All routes registered, all behavior preserved
- Tests: 436/437 pass (1 pre-existing SSE sandbox failure, unrelated)

The pattern for future commits:
  1. Read a tag's endpoints from api.py
  2. Create routers/<tag>.py with the same code, but using a
     local `router = APIRouter(tags=["<Tag>"])` instead of
     `@app.post(..., tags=["<Tag>"])`
  3. Replace the inline section in api.py with
     `from routers.<tag> import router as <tag>_router`
     `app.include_router(<tag>_router)`
  4. Commit

Suggested commit order (smallest first, to spread risk):
  - health (3 endpoints, ~50 lines)
  - stats (1 endpoint, ~30 lines)
  - costing (4 endpoints, ~150 lines)
  - freshness (3 endpoints, ~100 lines)
  - structure (3 endpoints, ~120 lines)
  - seo (3 endpoints, ~120 lines)
  - compliance (2 endpoints, ~200 lines)
  - gdpr (8 endpoints, ~300 lines)
  - sessions (5 endpoints, ~200 lines)
  - monitoring (5 endpoints, ~250 lines)
  - intelligence (4 endpoints, ~300 lines)
  - scraping (8 endpoints, ~400 lines)
  - extraction (8 endpoints, ~400 lines)
  - advanced (16 endpoints, ~700 lines - needs to be split further)

When all routers are split, api.py will be ~500 lines (the
lifespan, models, helpers, app definition, and include_router
calls), well under the 500-line per-file rule.
2026-07-02 21:17:40 +02:00