Add APScheduler-based background task that periodically re-analyzes
tracked companies and alerts on significant patent count changes.
- Add tracked_companies and alerts tables to database schema
- Add SPARC/scheduler.py with configurable interval and threshold
- Add admin endpoints: GET/POST/DELETE /admin/tracked, GET /admin/alerts
- Scheduler starts at app startup; interval via SCHEDULE_INTERVAL_HOURS
- Change threshold configurable via CHANGE_THRESHOLD_PERCENT env var
- apscheduler is optional; graceful fallback if not installed
Closesleeworks-agents/SPARC#22
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a cursor query parameter to GET /jobs and return a next_cursor
field in the response envelope. Existing clients using only limit
continue to work without modification. The cursor is an opaque token
encoding created_at and job_id for stable keyset pagination.
Closesleeworks-agents/SPARC#25
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add test job to build.yaml that runs pytest and ruff before building images
- Add standalone test.yaml workflow for PRs
- Add ruff.toml with E/F/I rules configured
- Fix all ruff lint errors: sort imports, remove unused imports, fix re-exports
- Build jobs now depend on test job passing (needs: test)
Closesleeworks-agents/SPARC#18Closesleeworks-agents/SPARC#19
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace get_db_client() creating new DatabaseClient on every call with a
module-level singleton initialized once at startup via init_db_client()
- Add init_db_client() and close_db_client() lifecycle functions called
from FastAPI lifespan handler
- Migrate all DatabaseClient methods from legacy self.connect()/self.conn
to pooled self.get_conn() context manager for thread-safe connection reuse
- Pool is properly torn down on application shutdown
Closesleeworks-agents/SPARC#7
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add jobs table to database schema (job_id, status, progress, result_json, etc.)
- Add DatabaseClient methods: create_job, update_job, get_job, list_jobs
- Add mark_stale_jobs_failed() called at startup to handle interrupted jobs
- Refactor _run_batch_job and job endpoints to read/write from PostgreSQL
- Remove in-memory _jobs dict; job state now survives API restarts
- Update init_database.py to list all tables in output
Closesleeworks-agents/SPARC#8
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace USE_DATABASE toggle with USE_CACHE for smarter LLM response handling:
- Add prompt hashing for efficient cache lookups
- Cache API responses in database to reduce token usage
- Always store responses for analytics (cache or fresh)
Add user authentication infrastructure:
- User table with bcrypt password hashing
- CRUD operations for user management
- Role-based access control (admin/user)
Dependencies: add bcrypt and PyJWT for auth
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implements a database mode that stores LLM prompts and responses in PostgreSQL
instead of making API calls. This enables:
- Testing without consuming API credits
- Collecting analytics on usage patterns
- Development and debugging workflows
Changes:
- Added DatabaseClient class for PostgreSQL operations
- Modified LLMAnalyzer to support database/API mode toggle
- Added USE_DATABASE config flag to switch between modes
- Included Docker Compose setup for PostgreSQL
- Added utility scripts for database init and analytics viewing
- Comprehensive documentation in DATABASE_MODE.md
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>