Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
72cad19
Add Streamlit render smoke test + reconcile mock verdict schema
claude Jun 6, 2026
79f1933
Extend UI smoke test with interaction paths
claude Jun 7, 2026
eca6dd5
Add CLAUDE.md: codebase guide + production-readiness roadmap
claude Jun 7, 2026
dbd532a
P0.2: migrate deprecated use_container_width -> width="stretch"
claude Jun 7, 2026
c293cce
P0.4: schema-drift guard (models vs migrations)
claude Jun 7, 2026
ebf0d20
P0.1: Redis-backed cache + checkpoint store (horizontal scaling)
claude Jun 7, 2026
461dc7f
P0.3 (part 1): account deletion, data export, reset-token safety
claude Jun 7, 2026
ed73f56
P0.3 (part 2): email verification on signup
claude Jun 7, 2026
5c413e2
docs: mark P0 roadmap items done in CLAUDE.md
claude Jun 7, 2026
7a0e320
P1: CI quality gates (ruff, mypy, bandit, pip-audit, coverage, JS)
claude Jun 7, 2026
ca3495d
P1: agentic web-search fallback + live e2e harness
claude Jun 7, 2026
daaee4d
P1 #6: envelope-encrypt the TOTP secret at rest
claude Jun 7, 2026
f3bd01f
P1 #7: LLM cost controls — token accounting, budgets, completion cache
claude Jun 7, 2026
ff7675b
P1 #8: observability shipping — Prometheus exposition + /metrics endp…
claude Jun 7, 2026
baa841e
P2 #11: durable webhook delivery via Celery with retry/backoff
claude Jun 8, 2026
2626b56
P2 #12: Postgres backups, restore drill, and operations runbook
claude Jun 8, 2026
0f698d4
P2 #10 + #13: JS-board ingestion via hosted browser; edge deploy guide
claude Jun 8, 2026
c783245
fix(security): close review findings — OAuth takeover, API cost bypas…
claude Jun 8, 2026
88c9e7c
test(e2e): add use-case journey layer (real services + orchestrator, …
claude Jun 8, 2026
d31e4c1
refactor: webhooks fire from the service layer; orchestrator surfaces…
claude Jun 8, 2026
9ff823c
refactor: central typed config layer + shared ownership helper
claude Jun 8, 2026
628229a
refactor: invert utils.llm→services.usage coupling; type the provider…
claude Jun 8, 2026
36544e2
refactor: de-duplicate helpers, drop dead shims, tidy imports; docume…
claude Jun 9, 2026
5926859
ci(mypy): pin mypy to 1.x + fix the strict-mypy type errors
claude Jun 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .coverage
Binary file not shown.
54 changes: 53 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
# NEWS_API_KEY=... # newsapi.org for real company news
# LAYOFFS_DATASET_URL=... # JSON dataset URL with layoff records

# Agentic web-search fallback (keyless): when NEWS_API_KEY is absent but an
# LLM provider key IS set, the company-news fetch falls back to an LLM-directed
# DuckDuckGo search ([research] extra: ddgs) + synthesis. Disable with:
# COMPANY_RESEARCH_FALLBACK=0
# DDG_MAX_RESULTS=5
# Optional hosted headless agentic browser for deep-fetching a top result:
# BROWSERBASE_API_KEY=...
# BROWSERBASE_PROJECT_ID=... # both required; falls back to local
# # Playwright when BROWSER_SCRAPER_ENABLED=1

# Phase 4 — real salary benchmarks via Adzuna (free tier, ~1000 calls/month)
# Sign up at https://developer.adzuna.com/
# ADZUNA_APP_ID=...
Expand All @@ -47,6 +57,13 @@
# CELERY_BROKER_URL=redis://localhost:6379/0
# CELERY_RESULT_BACKEND=redis://localhost:6379/0

# Webhook delivery durability — with a Celery broker, deliveries run as a
# retrying task (at-least-once) instead of a best-effort daemon thread.
# WEBHOOK_ASYNC=1 # 0 to force the inline/thread path
# WEBHOOK_MAX_ATTEMPTS=5 # total tries (initial + retries)
# WEBHOOK_RETRY_BACKOFF=10 # base seconds; backoff = base * 2**retry
# WEBHOOK_TIMEOUT=8 # per-POST timeout (seconds)

# Browser scraper (optional — needs the [browser] extra: playwright).
# Enables headless rendering for JS job boards + Numbeo COL where APIs are
# paid/unavailable. Heavy; opt in explicitly. Then: `playwright install chromium`.
Expand All @@ -71,13 +88,48 @@
# RL_ANALYSIS_MAX=30
# RL_ANALYSIS_WINDOW=3600

# LLM cost controls (services/usage). Token usage of every real provider call
# is ledgered (table llm_usage) with an estimated USD cost. Set a per-user
# spend cap over a rolling window; 0/unset disables budgeting (count-based
# RL_ANALYSIS_* still applies).
# LLM_BUDGET_USD=0
# LLM_BUDGET_WINDOW_SECONDS=2592000 # default 30 days
# Override the estimated price table (USD per 1k tokens) wholesale:
# LLM_PRICING_JSON={"gpt-4o-mini": [0.00015, 0.0006], "claude-sonnet-4-6": [0.003, 0.015]}
# Cache identical completions (same provider/model/params/prompt) for free
# reuse — off by default; valuable for repeated/identical analyses.
# LLM_CACHE_COMPLETIONS=1

# UI / discoverability
# TELEGRAM_BOT_USERNAME=YourBot # if set, sidebar shows a link to t.me/...
# REDIS_URL=redis://localhost:6379/1 # distributed rate-limit backend (else in-mem)
# REDIS_URL=redis://localhost:6379/1 # shared backend for rate-limit + cache +
# # analysis checkpoints (REQUIRED for >1
# # app instance; else each is in-process).
# # CELERY_BROKER_URL is used as a fallback.
# CACHE_TTL_SECONDS=3600
# CHECKPOINT_TTL_SECONDS=3600

# Observability — expose this process's metrics for Prometheus.
# The REST API serves GET /metrics in Prometheus text format when enabled.
# Off by default (returns 404); set a token on any public deployment so the
# metrics aren't world-readable (Prometheus sends Authorization: Bearer <tok>).
# METRICS_ENABLED=1
# METRICS_TOKEN=change-me
# Stop-gap push path (cron): `python -m worker.metrics_dump --push`
# METRICS_PUSHGATEWAY_URL=http://pushgateway:9091
# METRICS_JOB=joboffer_scanner

# Telegram bot channel (alternative to the Streamlit UI)
# TELEGRAM_BOT_TOKEN=... # from @BotFather

# Secrets at rest — envelope-encrypt the TOTP 2FA secret (and any future
# sensitive low-volume fields). Set to any string/passphrase; a Fernet key is
# derived from it (SHA-256). When UNSET, secrets are stored plaintext (dev/demo)
# and legacy rows are re-encrypted lazily once a key is configured. In prod,
# source this from a KMS-decrypted data key at boot. Rotating the key without
# re-encrypting existing rows will break 2FA verification for those users.
# SECRETS_ENCRYPTION_KEY=change-me-to-a-long-random-string

# Password reset — self-hosted convenience flag.
# Set to 1 ONLY in single-user/self-hosted deployments to display reset
# tokens directly in the UI. Leave UNSET in multi-tenant production.
Expand Down
84 changes: 76 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,71 @@ on:
pull_request:
branches: [main]

# Opt JS-based actions (checkout, setup-python) into the Node 24 runtime so the
# Node 20 deprecation warnings go away ahead of the forced cutover.
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"

jobs:
lint:
name: ruff lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- run: pip install ruff>=0.6
- run: ruff check .

typecheck:
name: mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- name: Install deps + type stubs
run: |
python -m pip install --upgrade pip
pip install -e ".[telegram,worker,dev]"
- run: mypy

security:
name: bandit + pip-audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- run: pip install "bandit>=1.7" "pip-audit>=2.7"
# bandit is a hard gate (we keep it clean at medium+high severity).
# Explicit -x (rather than pyproject config) avoids needing bandit[toml].
- run: bandit -r . -ll -x ./tests,./migrations,./.venv
# pip-audit is ADVISORY: transitive-dep CVEs are often outside our
# control (base-image setuptools/wheel, etc.), so it informs without
# blocking the build.
- name: pip-audit (advisory)
continue-on-error: true
run: pip-audit --progress-spinner off || true

js-tests:
name: chrome-extension JS tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
- run: node chrome-extension/extract.test.mjs

test:
name: unittest (Python ${{ matrix.python-version }})
name: unittest + coverage (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -26,21 +88,26 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Telegram extra so the bot-handler tests can run.
pip install -e ".[telegram]"

- name: Show installed package versions
run: pip freeze | sort
# Telegram extra so the bot-handler tests can run; dev extra for coverage.
pip install -e ".[telegram,dev]"

- name: Run unit tests
- name: Run unit tests under coverage
# Strip any provider keys the CI environment may inject so the demo
# smoke test exercises the no-key path deterministically.
env:
ANTHROPIC_API_KEY: ""
OPENAI_API_KEY: ""
FEATHERLESS_API_KEY: ""
LLM_PROVIDER: ""
run: python -m unittest discover -s tests -v
run: coverage run -m unittest discover -s tests

- name: Enforce coverage floor on the logic packages
# app.py (the dense Streamlit UI) is only smoke-tested, so the gate is
# on the service/logic packages where coverage is meaningful (~87%).
run: |
coverage report \
--include="services/*,utils/*,db/*,tools/*,agents/*,api/*,bot/*,worker/*" \
--fail-under=80

migrations-postgres:
name: alembic up/down/up on Postgres
Expand Down Expand Up @@ -101,6 +168,7 @@ jobs:
"telegram_links", "audit_events", "background_analyses",
"user_two_factor", "application_shares", "api_tokens",
"webhooks", "webhook_deliveries", "oauth_identities",
"email_verification_tokens", "llm_usage",
}
missing = required - tables
assert not missing, f"missing tables after migrate: {missing}"
Expand Down
Loading
Loading