755 Commits

Author SHA1 Message Date
copilot-swe-agent[bot] 571cc81789 feat(api): add per-user health-aware upload rate limiting
Introduces a Redis-backed sliding-window rate limiter for upload
endpoints (/api/ui-upload, /api/process-url) that:
- Enforces per-user limits (default: 20 uploads / 60 s)
- Dynamically reduces limits under system stress (queue depth, CPU load)
- Returns 429 with Retry-After header when exceeded
- Fails open when Redis is unavailable
- Works with the existing client-side adaptive back-off

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-17 12:12:50 +00:00
copilot-swe-agent[bot] 56bf665397 fix(db): use NullPool for SQLite and expose pool tuning settings
SQLite engines now use NullPool instead of QueuePool, eliminating the
"QueuePool limit of size 5 overflow 10 reached" TimeoutError under
concurrent load.  PostgreSQL/MySQL engines use a configurable QueuePool
with sensible defaults (pool_size=10, max_overflow=20) exposed via
DB_POOL_SIZE, DB_MAX_OVERFLOW, DB_POOL_TIMEOUT, DB_POOL_RECYCLE env
vars.  pool_pre_ping is enabled on all backends.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-17 12:03:04 +00:00
copilot-swe-agent[bot] 0f6a1ee1ec fix(api): add ttl_seconds to QR challenge response and fix client-side countdown
The QR login page countdown timer compared the server's UTC expiration
timestamp against the client's local clock, causing the QR code to appear
immediately expired when the client clock was ahead of the server.

Changes:
- Add ttl_seconds field to CreateChallengeResponse (seconds until expiry)
- Frontend countdown now uses relative elapsed time since response was
  received, eliminating clock-skew issues
- Mobile app: replace alert-only QR button with actual camera-based
  QR code scanner using expo-camera
- Add QRScannerScreen with barcode scanning, permission handling, and
  scan area overlay
- Update camera permission description to mention QR code scanning
- Add tests for ttl_seconds computation

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-17 12:02:33 +00:00
copilot-swe-agent[bot] bcf2d00c33 fix(test): add missing _should_upload_to_sharepoint mock to send_to_all tests
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-17 11:32:48 +00:00
Christian Krakau-Louis 8905031d16 Merge branch 'main' into copilot/implement-log-off-everywhere-functionality 2026-03-17 12:12:50 +01:00
copilot-swe-agent[bot] c7d67031d4 fix: resolve merge conflicts with main branch
Merge origin/main into feature branch, resolving 18 conflicts:
- app/api/__init__.py: add classification_rules_router alongside system_reset_router
- app/config.py: keep system reset settings from main
- app/models.py: keep ClassificationRuleModel alongside main's models
- app/utils/settings_service.py: keep factory reset settings from main
- app/views/__init__.py: keep system_reset_router from main
- tests/conftest.py: add ClassificationRuleModel import
- migrations/env.py: add ClassificationRuleModel import
- .env.demo, docs/*, frontend/*, mobile/*: keep additions from main
- BUILD_DATE, GIT_SHA, RUNTIME_INFO, VERSION, CHANGELOG.md: accept main's version

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-17 11:09:39 +00:00
copilot-swe-agent[bot] 03712cfb08 feat(ui): add dedicated Devices page for mobile tokens and registered devices
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-17 11:00:36 +00:00
copilot-swe-agent[bot] a022dec9c2 fix(auth): resolve timezone-naive datetime comparisons in QR challenge functions and update docs
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-17 10:13:19 +00:00
Christian Krakau-Louis 7b7554decf Merge pull request #751 from christianlouis/copilot/improve-database-migration-handling
feat(db): Add migration chain validation to CI, pre-commit, and developer docs
2026-03-17 10:55:10 +01:00
copilot-swe-agent[bot] a007b4fd98 fix(db): address code review feedback - fix comment stripping, type hints, test skip, and docs
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-17 09:21:11 +00:00
copilot-swe-agent[bot] aa49fa3ae6 feat(db): add migration chain CI validation, pre-commit hook, script template, docs, and tests
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-17 09:18:11 +00:00
copilot-swe-agent[bot] f75b125992 feat(scaling): enable horizontal scaling for API and worker pods
- Add unauthenticated /api/diagnostic/healthz/live and /healthz/ready
  probe endpoints for Kubernetes liveness/readiness checks
- Separate Celery Beat into dedicated beat service in docker-compose.yaml
- Remove container_name from api and worker services to allow scaling
- Create Helm beat-deployment.yaml for standalone Beat scheduler pod
- Remove -B flag from worker-deployment.yaml so workers can scale safely
- Add beat section and fix probe paths in Helm values.yaml
- Add tests for the new probe endpoints

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 23:52:56 +00:00
copilot-swe-agent[bot] d5e1d92d6f Changes before error encountered
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 22:54:13 +00:00
copilot-swe-agent[bot] d1ebac74a1 Changes before error encountered
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 22:54:09 +00:00
copilot-swe-agent[bot] 204000aabc fix: merge main branch and renumber migration 027→037
Resolve 3 merge conflicts and renumber the automation_hooks migration
to follow main's migration chain (036_add_document_translation_fields).

Conflicts resolved:
- app/api/__init__.py: add automation_router alongside main's new routers
- app/utils/settings_service.py: add automation_hooks_enabled alongside compliance_enabled
- tests/conftest.py: add AutomationHook alongside AuditLog/ComplianceTemplate imports

Migration renumbered:
- 027_add_automation_hooks → 037_add_automation_hooks
- down_revision: 026_add_scheduled_jobs → 036_add_document_translation_fields

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 22:40:15 +00:00
copilot-swe-agent[bot] 7dffdc0554 fix(system-reset): address code review feedback
- Add path traversal guard in reimport file copy loop
- Improve error log message context for table wipe failures
- Use conditional role=alert/status on result banner for accessibility
- Make test assertions more specific (exact status codes)
- Rename ambiguous view test

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 22:38:24 +00:00
copilot-swe-agent[bot] 651b48658c fix: resolve merge conflicts with main branch
Merge origin/main into feature branch, resolving 3 conflicts:
- app/api/__init__.py: add classification_rules_router alongside new
  routers from main (audit_logs, i18n, mobile, compliance, translation)
- app/models.py: keep ClassificationRuleModel alongside new models from
  main (MobileDevice, ComplianceTemplate, PipelineRoutingRule)
- tests/conftest.py: import both ClassificationRuleModel and new models
  from main (AuditLog, ComplianceTemplate)

Also renumber migration from 027 to 037 to chain from the latest
migration on main (036_add_document_translation_fields).

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 22:33:59 +00:00
copilot-swe-agent[bot] 96bfba8057 test(system-reset): add comprehensive tests and documentation
- 21 tests covering unit, integration, API, and view layers
- Update ConfigurationGuide.md with System Reset section
- Update API.md with system reset endpoint docs
- All tests pass, ruff clean

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 22:32:31 +00:00
copilot-swe-agent[bot] 20e61db050 merge: resolve conflicts with main branch (keep both SharePoint + iCloud integrations)
Merge origin/main into copilot/add-sharepoint-integration.
All four conflicts were resolved by keeping both the SharePoint
additions (from this branch) and the iCloud additions (from main):
- app/models.py: added both SHAREPOINT and ICLOUD to IntegrationType
- app/tasks/send_to_all.py: added both to service_map and services list
- app/tasks/upload_to_user_integration.py: kept both upload handlers
- frontend/templates/files.html: added both filter options

No database migration conflicts — SharePoint does not require schema changes.
2026-03-16 22:25:51 +00:00
copilot-swe-agent[bot] 195c3c3446 fix(tasks): dispatch per-user notifications on document processed/failed events
The per-user notification functions (notify_user_document_processed /
notify_user_document_failed) were defined but never called from the
document processing pipeline.

- Call notify_user_document_processed in finalize_document_storage
  when owner_id is available (creates in-app + email/webhook notifications)
- Add _dispatch_user_failure_notification helper to celery_app.py that
  extracts file_id from failed task args and dispatches
  notify_user_document_failed for document pipeline tasks
- Add comprehensive tests for both success and failure notification paths

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 16:10:01 +00:00
Christian Krakau-Louis ebbbd3d62e Merge pull request #731 from christianlouis/copilot/fix-mobile-app-login
fix: resolve CI failures from stale request mocks, Annotated+Depends pattern, and CodeQL sensitive data logging
2026-03-16 15:29:15 +01:00
copilot-swe-agent[bot] 0444b14d87 fix(test): update url_upload test mocks from requests to httpx
The tests were patching `app.api.url_upload.requests.get` but the module
uses `httpx.AsyncClient`. Updated 4 tests across 2 files to use the
correct `httpx.AsyncClient.stream` mock pattern with `AsyncMock`,
matching the existing working tests in test_url_upload.py.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 13:03:18 +00:00
Christian Krakau-Louis c81914f78d Merge pull request #729 from christianlouis/copilot/add-default-language-version-support
feat(translation): automatic document translation to configurable default language
2026-03-16 13:55:25 +01:00
copilot-swe-agent[bot] 075a505085 feat(profile): expose default_document_language in profile API and UI
- Add default_document_language to ProfileResponse and ProfileUpdateRequest
- Handle validation in PATCH /api/profile endpoint
- Add dropdown in profile.html template with Alpine.js binding
- Add translation keys for profile UI labels
- Add comprehensive tests for profile default language feature

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 12:13:54 +00:00
copilot-swe-agent[bot] 8cc817930d Merge remote-tracking branch 'origin/main' into copilot/fix-mobile-app-login 2026-03-16 11:58:14 +00:00
copilot-swe-agent[bot] 9d6bfde288 feat(tasks): extract and map embedded PDF metadata in upload_to_email
Implement extraction of embedded PDF metadata using pypdf, mapping
/Title, /Author, /Subject, /Keywords to filename, absender,
document_type, and tags respectively. JSON metadata takes precedence;
PDF metadata fills missing fields only.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 11:27:34 +00:00
copilot-swe-agent[bot] 9a256741d5 fix(auth): address review comments - improve debug logging, use SimpleNamespace, fix session cleanup
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 11:26:52 +00:00
copilot-swe-agent[bot] 15a9ed9435 fix(auth): resolve Bearer token in get_current_owner_id for mobile API auth
get_current_owner_id() only checked the session for authenticated users.
When the mobile app sends Authorization: Bearer <token>, there is no
session cookie, so the Depends(_get_owner_id) dependency raised HTTP 401
before the @require_login wrapper could resolve the Bearer token.

The function now checks three sources in order:
1. Session user dict (existing behavior)
2. request.state.api_token_user (cached by require_login or prior call)
3. Direct Bearer token resolution via _resolve_bearer_user (new)

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 11:25:02 +00:00
Christian Krakau-Louis 3447a408db Merge pull request #714 from christianlouis/perf/async-onedrive-token-refresh-7215258063318287629
 Async OneDrive token validation using httpx
2026-03-16 12:15:39 +01:00
Christian Krakau-Louis b8a1ac52b3 Merge branch 'main' into perf/async-url-upload-7099409897484162483 2026-03-16 12:12:21 +01:00
Christian Krakau-Louis cb1e81355d Merge pull request #726 from christianlouis/add-tests-saved-searches-4325714364005279059
🧪 Add tests for saved searches API
2026-03-16 12:08:31 +01:00
copilot-swe-agent[bot] c7ff177e17 fix: resolve test failures and mypy errors on main
- Fix Dropbox tests: patch httpx.AsyncClient instead of non-existent requests.post
- Add SETTING_METADATA entries for 6 logging settings (log_level, log_format, log_syslog_*)
- Add types-aiofiles to dev dependencies to fix mypy import-untyped error

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 10:32:20 +00:00
github-actions[bot] 46c4031276 style: apply ruff auto-fix
- Auto-formatted code with ruff format
- Applied ruff linting fixes with --fix

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-03-16 10:23:16 +00:00
google-labs-jules[bot] 7798ac3b57 🧪 Add tests for saved searches API endpoints
Added a new test file `tests/test_api_saved_searches.py` containing a comprehensive test suite for the CRUD operations provided in `app/api/saved_searches.py`. The suite validates happy paths, error conditions (like missing filters, name limits, duplicates), and user isolation using an in-memory SQLite database.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 10:22:18 +00:00
Christian Krakau-Louis 740d18555b Merge pull request #707 from christianlouis/copilot/fix-debug-logging-issue
feat: fix DEBUG logging and add LOG_LEVEL/LOG_FORMAT/LOG_SYSLOG for standard log management
2026-03-16 11:00:41 +01:00
Christian Krakau-Louis e679b71356 Merge pull request #697 from christianlouis/test-api-tokens-hash-token-18108337743020909528
🧪 Add unit test for hash_token function
2026-03-16 10:58:44 +01:00
Christian Krakau-Louis bcd49aa793 Merge pull request #695 from christianlouis/fix/rename-save-dropbox-settings-9203732237520055590
🧹 [code health improvement] Rename save_dropbox_settings to save_google_drive_settings
2026-03-16 10:58:07 +01:00
Christian Krakau-Louis 1c8cebb718 Merge pull request #694 from christianlouis/add-test-delete-saved-search-error-10537352409448038219
🧪 add error test for deleting saved search
2026-03-16 10:57:24 +01:00
Christian Krakau-Louis 3be78708cd Merge pull request #716 from christianlouis/code-health/simplify-save-onedrive-settings-12338634662690804221
🧹 [Code Health] Simplify save_onedrive_settings logic and extract env_utils
2026-03-16 10:56:25 +01:00
Christian Krakau-Louis 992adad978 Merge pull request #718 from christianlouis/perf-upload-15584535240168516797
 Optimize file upload endpoint to use asynchronous aiofiles
2026-03-16 10:55:57 +01:00
google-labs-jules[bot] 827979598e perf(onedrive): use async httpx for token refresh
Replaces the synchronous `requests.post` and `requests.get` calls in
`app/api/onedrive.py:test_onedrive_token` with an asynchronous
`httpx.AsyncClient` implementation. This unblocks the FastAPI event loop
when this endpoint is hit.

Fixed unused requests import in `app/api/onedrive.py` and sorted imports in the testing files updated previously to adhere to the repository formatting (`ruff check --fix`). Tests in `test_api_onedrive_extended.py` were also migrated to use AsyncMock properly.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 09:53:14 +00:00
Christian Krakau-Louis b9b8796153 Merge pull request #699 from christianlouis/improve-generate-api-token-coverage-1443605259252817388
🧪 Add unit tests for `generate_api_token`
2026-03-16 10:53:06 +01:00
Christian Krakau-Louis b3d1824d66 Merge pull request #700 from christianlouis/extract-pdf-metadata-upload-to-email-12238364102013658937
Extract embedded PDF metadata using pypdf
2026-03-16 10:52:51 +01:00
Christian Krakau-Louis e29e222833 Merge pull request #704 from christianlouis/test-settings-sync-error-handling-9908300433097254406
🧪 Add tests for notify_settings_updated error handling
2026-03-16 10:52:15 +01:00
Christian Krakau-Louis 0d606d480f Merge pull request #706 from christianlouis/test-saved-searches-update-3763426346293976504
🧪 Add error tests for updating saved searches
2026-03-16 10:51:37 +01:00
Christian Krakau-Louis a9af06ed17 Merge pull request #708 from christianlouis/test-create-saved-search-errors-7017236575137054898
🧪 Add missing error tests for create_saved_search
2026-03-16 10:51:18 +01:00
copilot-swe-agent[bot] 6da1e6fd81 feat(config): add JSON structured logging and syslog forwarding for application logs
- Add LOG_FORMAT setting (text/json) for structured JSON log output
- Add LOG_SYSLOG_* settings for direct syslog forwarding of app logs
- JSON format compatible with Grafana Loki, Splunk, ELK, Datadog
- Syslog forwarding uses Python's SysLogHandler (UDP/TCP)
- Update .env.demo and ConfigurationGuide.md with all new settings
- Add tests for JSON formatter and syslog config fields

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-03-16 09:51:16 +00:00
Christian Krakau-Louis 50846360b3 Merge pull request #712 from christianlouis/test-settings-sync-coverage-16903900720046903542
🧪 [testing improvement] add missing error logging tests for notify_settings_updated
2026-03-16 10:50:40 +01:00
Christian Krakau-Louis 13a156f4e3 Merge pull request #709 from christianlouis/test-settings-sync-5418518550614493591
🧪 Add tests for settings_sync utility
2026-03-16 10:50:02 +01:00
Christian Krakau-Louis c00a35bbac Merge pull request #711 from christianlouis/performance-optimize-dropbox-token-2748375428782384195
 Optimize Dropbox token check by using async httpx
2026-03-16 10:49:34 +01:00