Repository navigation
feat: Phase 12 - Application Performance Monitoring and Security Governance #224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a31f0d6
feat: implement phase 12 apm and security governance
seonghobae a01760d
docs: add Phase 11 & Phase 12 implementation plans and ignore cache dirs
seonghobae cb56ce8
fix(ci): use correct LiteLLM provider prefix github/gpt-4o for Strix
seonghobae 1f2ff8d
Merge remote-tracking branch 'origin/master' into feature/phase12-apm…
seonghobae d189195
docs: fix markdown headers and add missing auth context requirements
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-5.83 KB
backend/tests/__pycache__/test_access_policy.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-4.1 KB
backend/tests/__pycache__/test_accounts_api.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-2.99 KB
backend/tests/__pycache__/test_apm_observability.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-7.83 KB
backend/tests/__pycache__/test_archive.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-26.6 KB
backend/tests/__pycache__/test_auth_real.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-10.9 KB
backend/tests/__pycache__/test_bootstrap_db.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-17 KB
backend/tests/__pycache__/test_calendar_api.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-3.35 KB
backend/tests/__pycache__/test_calendar_service.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-2.06 KB
backend/tests/__pycache__/test_calendar_sync.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-2.87 KB
backend/tests/__pycache__/test_dav_api.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-4.93 KB
backend/tests/__pycache__/test_email_client.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-27.6 KB
backend/tests/__pycache__/test_email_client_smtp.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-9.16 KB
backend/tests/__pycache__/test_email_parser.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-28.7 KB
backend/tests/__pycache__/test_emails_api.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-6.32 KB
backend/tests/__pycache__/test_embedding.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-876 Bytes
backend/tests/__pycache__/test_imap_worker_sync.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-12.4 KB
backend/tests/__pycache__/test_import_fixtures.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-1.08 KB
backend/tests/__pycache__/test_infra_evaluations.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-2.37 KB
backend/tests/__pycache__/test_knowledge_extractor.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-4.24 KB
backend/tests/__pycache__/test_llm_api.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-15.1 KB
backend/tests/__pycache__/test_llm_providers_api.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-8.24 KB
backend/tests/__pycache__/test_llm_service.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-10.1 KB
backend/tests/__pycache__/test_network_api.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-4.73 KB
backend/tests/__pycache__/test_ontology_api.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-22.7 KB
backend/tests/__pycache__/test_prompts_api.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-21 KB
backend/tests/__pycache__/test_release_governance.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-5.61 KB
backend/tests/__pycache__/test_repo_hygiene.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-10.3 KB
backend/tests/__pycache__/test_runner_config_api.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-1.88 KB
backend/tests/__pycache__/test_runtime_config_api.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-19.6 KB
backend/tests/__pycache__/test_tasks_api.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-9.9 KB
backend/tests/__pycache__/test_tenant_config_api.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-8.08 KB
backend/tests/__pycache__/test_tenant_config_model.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-7.73 KB
backend/tests/__pycache__/test_tenant_config_model.cpython-311-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-3.41 KB
backend/tests/__pycache__/test_text_safety.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
Binary file removed
BIN
-4.73 KB
backend/tests/__pycache__/test_threading_service.cpython-310-pytest-9.0.3.pyc
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Phase 11: Email Threading, DAG Ontology Pipeline, and CalDAV Sync Implementation Plan | ||
|
|
||
| > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. | ||
|
|
||
| **Goal:** Wire the previously defined schema and core logic (from Phase 10) into the actual background sync workers and API endpoints. Implement true email threading, DAG ontology persistence, reply tracking, and CalDAV/WebDAV integration. | ||
|
|
||
| **Architecture:** Use the existing `ImapSyncWorker` to trigger ontology and fingerprinting logic. Use `SenderRelationship` to store the DAG. Expose these via REST endpoints for the frontend. | ||
|
|
||
| **Tech Stack:** FastAPI, SQLAlchemy, PostgreSQL, Python | ||
|
|
||
| --- | ||
|
|
||
| ## Task 1: Email Threading and Deduplication Pipeline | ||
|
|
||
| **Files:** | ||
| - Modify: `backend/services/threading_service.py` (or create if needed) | ||
| - Modify: `backend/services/imap_worker.py` (or wherever email fetching happens) | ||
| - Test: `backend/tests/test_threading_pipeline.py` | ||
|
|
||
| - [ ] **Step 1: Write a test for threading/deduplication using `generate_email_fingerprint`** | ||
| - [ ] **Step 2: Update the worker to compute fingerprint before DB insertion** | ||
| - [ ] **Step 3: If fingerprint exists, update existing thread instead of inserting duplicate** | ||
| - [ ] **Step 4: Verify tests pass** | ||
|
|
||
| ## Task 2: DAG Ontology & Self-to-Self Knowledge Extraction | ||
|
|
||
| **Files:** | ||
| - Modify: `backend/services/ontology_service.py` | ||
| - Modify: `backend/api/ontology.py` (or create if needed) | ||
| - Test: `backend/tests/test_ontology_pipeline.py` | ||
|
|
||
| - [ ] **Step 1: Write a test that inserts a `SenderRelationship` to DB based on `analyze_sender_relationship`** | ||
| - [ ] **Step 2: Update `ontology_service.py` to accept DB session and save the relationship including explicit tenant_id and source_id/thread_id fields** | ||
| - [ ] **Step 3: If `process_self_to_self` is true, trigger a knowledge extraction task passing tenant and source context** | ||
| - [ ] **Step 4: Create/Update `/api/ontology/relationships` to fetch the DAG for the frontend, filtering by tenant_id and source_id. Explicitly require the default signed-session authentication by registering the router with the `get_auth_context` dependency.** | ||
|
|
||
| ## Task 3: Reply Tracking Background Job | ||
|
|
||
| **Files:** | ||
| - Modify: `backend/services/reply_tracking_service.py` | ||
| - Modify: `backend/api/emails.py` | ||
| - Test: `backend/tests/test_reply_tracking.py` | ||
|
|
||
| - [ ] **Step 1: Write a test for identifying sent emails awaiting replies** | ||
| - [ ] **Step 2: Implement a background task that runs daily (or periodically) to flag missing replies** | ||
| - [ ] **Step 3: Expose `requires_reply` and `schedule_conflict` in `/api/emails` response, verifying the router remains protected by `get_auth_context` and uses the authenticated context.** | ||
|
|
||
| ## Task 4: CalDAV/WebDAV Background Sync | ||
|
|
||
| **Files:** | ||
| - Modify: `backend/services/caldav_service.py` | ||
| - Modify: `backend/services/webdav_service.py` | ||
| - Test: `backend/tests/test_dav_sync.py` | ||
|
|
||
| - [ ] **Step 1: Write tests for CalDAV event parsing and WebDAV file listing** | ||
| - [ ] **Step 2: Implement `sync_caldav_accounts` to fetch and store events locally** | ||
| - [ ] **Step 3: Implement `sync_webdav_folders` to fetch folder structures** | ||
| - [ ] **Step 4: Ensure it supports N-accounts and ties data back to the `user_id`** | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Phase 12: Application Performance Monitoring (APM) and Security Governance Plan | ||
|
|
||
| > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. | ||
|
|
||
| **Goal:** Implement Open Source Application Performance Monitoring (APM) via OpenTelemetry and enforce security/GRC rules including RBAC endpoints and authentication. | ||
|
|
||
| **Architecture:** | ||
| - Add OpenTelemetry SDK instrumentation to FastAPI. | ||
| - Complete the APM infrastructure (Prometheus, Loki, Tempo, Grafana) definition in `docker-compose.infra.yml`. | ||
| - Implement actual backend dependencies for `get_current_user_role` and enforce RBAC on specific endpoints. | ||
| - Address any `Timeout`, `Fatal`, `Warn`, `Denied` suppression to ensure tests pass strictly. | ||
|
|
||
| **Tech Stack:** FastAPI, OpenTelemetry, Prometheus, Docker Compose. | ||
|
|
||
| --- | ||
|
|
||
| ## Task 1: OpenTelemetry Instrumentation | ||
|
|
||
| **Files:** | ||
| - Modify: `backend/requirements.txt` | ||
| - Modify: `backend/main.py` | ||
| - Modify: `backend/tests/test_apm_observability.py` | ||
|
|
||
| - [ ] **Step 1: Write a test ensuring `/metrics` is exposed and traces are configurable** | ||
| - [ ] **Step 2: Add `opentelemetry-instrumentation-fastapi` and `prometheus-fastapi-instrumentator` to requirements** | ||
| - [ ] **Step 3: Wire up `FastAPIInstrumentor.instrument_app(app)` in `main.py`** | ||
| - [ ] **Step 4: Verify test passes without warnings** | ||
|
|
||
| ## Task 2: Grafana & APM Infrastructure Definition | ||
|
|
||
| **Files:** | ||
| - Modify: `docker-compose.infra.yml` | ||
| - Create: `observability/grafana/provisioning/datasources/datasources.yaml` | ||
| - Create: `observability/prometheus.yml` | ||
| - Create: `observability/tempo.yaml` | ||
|
|
||
| - [ ] **Step 1: Write tests ensuring these files exist in `test_apm_observability.py`** | ||
| - [ ] **Step 2: Define Loki, Tempo, Prometheus, and Grafana containers in `docker-compose.infra.yml`** | ||
| - [ ] **Step 3: Create the config files for the observability stack** | ||
| - [ ] **Step 4: Verify tests pass** | ||
|
|
||
| ## Task 3: RBAC Endpoint Enforcement | ||
|
|
||
| **Files:** | ||
| - Modify: `backend/api/tenant_config.py` | ||
| - Modify: `backend/tests/test_tenant_config_api.py` | ||
|
|
||
| - [ ] **Step 1: Write tests asserting non-admins receive 403 Forbidden for admin endpoints** | ||
| - [ ] **Step 2: Use `get_current_user_role` to secure `/api/tenant_config/global`** | ||
| - [ ] **Step 3: Verify the changes correctly deny access to `member` roles** |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.