Add historical analysis diffing between runs for same company #1695

Open
AI-Manager wants to merge 3 commits from feature/historical-analysis-diff into main
Owner

Summary

  • Add GET /analyze/{company_name}/diff?from=<id>&to=<id> endpoint returning structured diff (added/removed patents, score delta, changed fields, summary narrative)
  • Add GET /analyze/{company_name}/history endpoint for listing past runs
  • Add database methods get_analysis_by_id and list_company_analyses
  • Add frontend HistoryDiff page with company search, run selector, and diff visualization
  • Add "Compare with previous" button on Analysis results page
  • Add navigation link in sidebar

Test plan

  • 11 tests added covering:
    • Patent ID extraction helper
    • Diff computation logic (identical, added/removed, model change)
    • Happy-path API endpoint test
    • 404 when from_id not found
    • 404 when to_id not found
    • 404 when analysis belongs to different company
    • History endpoint returns list and empty list
  • All existing tests unaffected (pre-existing failures unchanged)

Closes #1671

## Summary - Add `GET /analyze/{company_name}/diff?from=<id>&to=<id>` endpoint returning structured diff (added/removed patents, score delta, changed fields, summary narrative) - Add `GET /analyze/{company_name}/history` endpoint for listing past runs - Add database methods `get_analysis_by_id` and `list_company_analyses` - Add frontend `HistoryDiff` page with company search, run selector, and diff visualization - Add "Compare with previous" button on Analysis results page - Add navigation link in sidebar ## Test plan - [x] 11 tests added covering: - Patent ID extraction helper - Diff computation logic (identical, added/removed, model change) - Happy-path API endpoint test - 404 when from_id not found - 404 when to_id not found - 404 when analysis belongs to different company - History endpoint returns list and empty list - [x] All existing tests unaffected (pre-existing failures unchanged) Closes #1671
AI-Manager added 3 commits 2026-05-19 15:46:00 +00:00
- Add api_keys table (id, user_id, key_hash, label, created_at) to schema
- Add POST /auth/apikeys to generate 32-byte hex API keys (bcrypt-hashed)
- Add GET /auth/apikeys to list active key metadata (no secrets)
- Add DELETE /auth/apikeys/{key_id} to revoke keys
- Extend get_current_user to accept either JWT Bearer or X-API-Key header
- Plaintext key returned only at creation time
- 16 new tests covering creation, listing, revocation, auth, and full flow

Closes leeworks-agents/SPARC#1673

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Enhance GET /admin/rate-limits to return per-IP breakdown, 24h throttled
  count, and hourly time-series of rejected requests
- Add AdminRateLimits React page with auto-refresh (configurable interval),
  summary cards, throttled-over-time bar chart, endpoint table, and per-IP
  breakdown table
- Add TypeScript types (RateLimitStatsResponse, etc.) and adminApi.getRateLimits()
- Wire up /admin/rate-limits route and nav link (admin-only)
- Expand unit tests: auth, empty state, per-IP, throttled_24h, time-series,
  response shape contract (10 tests total)

Closes leeworks-agents/SPARC#1686

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add GET /analyze/{company_name}/diff endpoint with from/to query params
- Add GET /analyze/{company_name}/history endpoint for run selection
- Add database methods get_analysis_by_id and list_company_analyses
- Add frontend HistoryDiff page with run selector and diff visualization
- Add Compare with previous button on Analysis results page
- Add navigation link in Layout sidebar
- Add 11 tests covering helpers, happy-path, and 404 scenarios

Closes leeworks-agents/SPARC#1671

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feature/historical-analysis-diff:feature/historical-analysis-diff
git checkout feature/historical-analysis-diff
Sign in to join this conversation.