-
Notifications
You must be signed in to change notification settings - Fork 0
Research-grade evidence, bounded chat storage, and blocking quality gates #27
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
Changes from all commits
ef922b8
25445f3
ae62bf5
cb3bb34
aaab234
74c635a
7d12fbe
5b28865
4c09efe
89265c7
12072d3
10b40e5
50af1a9
b5579c6
00d8e19
ecdf5e7
e4dcad6
23899ba
1ea5286
47b02bb
8b11e98
71e6974
f74b3f5
b5edd66
1c277e8
385a8d9
9f77366
39e78cb
7b909b7
d05a95b
3739c16
da0a2b9
79fb5da
fdd7a40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,11 +26,19 @@ jobs: | |||||||||||||||||||||||||||||||
| python-version: "3.11" | ||||||||||||||||||||||||||||||||
| cache: pip | ||||||||||||||||||||||||||||||||
| - name: Install quality tooling | ||||||||||||||||||||||||||||||||
| run: python -m pip install --upgrade pip ruff black | ||||||||||||||||||||||||||||||||
| run: python -m pip install --upgrade pip ruff black bandit | ||||||||||||||||||||||||||||||||
| - name: Validate Python syntax | ||||||||||||||||||||||||||||||||
| run: python -m compileall -q app backend tests | ||||||||||||||||||||||||||||||||
| - name: Run blocking Ruff correctness checks | ||||||||||||||||||||||||||||||||
| run: ruff check app backend tests/test_api.py tests/test_chat_service.py tests/test_inference_cache.py --select E9,F63,F7,F82 | ||||||||||||||||||||||||||||||||
| - name: Run blocking Ruff and Bandit checks | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| ruff check backend/api.py backend/routes backend/services app/core/security.py benchmarks tests/test_api.py tests/test_backend_hardening.py tests/test_benchmark.py tests/test_security.py | ||||||||||||||||||||||||||||||||
| bandit -q backend/api.py backend/config.py backend/routes/*.py backend/services/*.py app/core/inference_cache.py app/core/security.py app/services/chat_service.py -f json -o bandit-report.json | ||||||||||||||||||||||||||||||||
| - name: Upload static-analysis report | ||||||||||||||||||||||||||||||||
| if: always() | ||||||||||||||||||||||||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: static-analysis-report | ||||||||||||||||||||||||||||||||
| path: bandit-report.json | ||||||||||||||||||||||||||||||||
| - name: Publish formatting advisory | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| black --check app backend tests/test_api.py tests/test_chat_service.py tests/test_inference_cache.py \ | ||||||||||||||||||||||||||||||||
|
|
@@ -63,7 +71,16 @@ jobs: | |||||||||||||||||||||||||||||||
| tests/test_api.py \ | ||||||||||||||||||||||||||||||||
| tests/test_chat_service.py \ | ||||||||||||||||||||||||||||||||
| tests/test_inference_cache.py \ | ||||||||||||||||||||||||||||||||
| --cov=app \ | ||||||||||||||||||||||||||||||||
| tests/test_backend_hardening.py \ | ||||||||||||||||||||||||||||||||
| tests/test_benchmark.py \ | ||||||||||||||||||||||||||||||||
| tests/test_security.py \ | ||||||||||||||||||||||||||||||||
| --cov=backend.api \ | ||||||||||||||||||||||||||||||||
| --cov=backend.routes.chat_routes \ | ||||||||||||||||||||||||||||||||
| --cov=backend.routes.ws_routes \ | ||||||||||||||||||||||||||||||||
| --cov=backend.services.chat_service \ | ||||||||||||||||||||||||||||||||
| --cov=app.core.inference_cache \ | ||||||||||||||||||||||||||||||||
| --cov=app.services.chat_service \ | ||||||||||||||||||||||||||||||||
| --cov-fail-under=90 \ | ||||||||||||||||||||||||||||||||
| --cov-report=term-missing \ | ||||||||||||||||||||||||||||||||
| --cov-report=xml \ | ||||||||||||||||||||||||||||||||
| --junitxml=pytest-results.xml \ | ||||||||||||||||||||||||||||||||
|
|
@@ -90,20 +107,36 @@ jobs: | |||||||||||||||||||||||||||||||
| cache: pip | ||||||||||||||||||||||||||||||||
| - name: Install audit tooling | ||||||||||||||||||||||||||||||||
| run: pip install pip-audit | ||||||||||||||||||||||||||||||||
| - name: Generate dependency audit report | ||||||||||||||||||||||||||||||||
| - name: Enforce dependency audit | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| set +e | ||||||||||||||||||||||||||||||||
| pip-audit -r requirements.txt --progress-spinner off --format json --output pip-audit.json | ||||||||||||||||||||||||||||||||
| status=$? | ||||||||||||||||||||||||||||||||
| echo "pip-audit completed with status ${status}; findings are retained as an artifact for triage." | ||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||
| - name: Upload dependency audit | ||||||||||||||||||||||||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||||||||||||||||||||||||
|
Comment on lines
+110
to
114
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Ensure the dependency audit report is uploaded on failure. If 🛠️ Proposed fix - name: Upload dependency audit
+ if: success() || failure()
uses: actions/upload-artifact@v4📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: pip-audit-report | ||||||||||||||||||||||||||||||||
| path: pip-audit.json | ||||||||||||||||||||||||||||||||
| if-no-files-found: warn | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| frontend-build: | ||||||||||||||||||||||||||||||||
| name: "Continuous Integration / Frontend Build" | ||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
| defaults: | ||||||||||||||||||||||||||||||||
| run: | ||||||||||||||||||||||||||||||||
| working-directory: frontend | ||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||
| - uses: actions/setup-node@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| node-version: "20" | ||||||||||||||||||||||||||||||||
| cache: npm | ||||||||||||||||||||||||||||||||
| cache-dependency-path: frontend/package-lock.json | ||||||||||||||||||||||||||||||||
| - name: Install locked dependencies | ||||||||||||||||||||||||||||||||
| run: npm ci --ignore-scripts | ||||||||||||||||||||||||||||||||
| - name: Enforce high-severity dependency audit | ||||||||||||||||||||||||||||||||
| run: npm audit --audit-level=high | ||||||||||||||||||||||||||||||||
| - name: Build production frontend | ||||||||||||||||||||||||||||||||
| run: npm run build | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| container-smoke-test: | ||||||||||||||||||||||||||||||||
| name: "Deployment / Container Build & Smoke Test" | ||||||||||||||||||||||||||||||||
| needs: test-matrix | ||||||||||||||||||||||||||||||||
|
|
@@ -126,7 +159,7 @@ jobs: | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| release-readiness: | ||||||||||||||||||||||||||||||||
| name: "Release Engineering / Artifact Readiness" | ||||||||||||||||||||||||||||||||
| needs: [test-matrix, dependency-audit, container-smoke-test] | ||||||||||||||||||||||||||||||||
| needs: [test-matrix, dependency-audit, frontend-build, container-smoke-test] | ||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,33 @@ | ||
| # Changelog | ||
| All notable changes to TrojanChat will be documented in this file. | ||
|
|
||
| ## [Unreleased] | ||
| ### Added | ||
| - Reproducible before/after latency, throughput, and peak-memory benchmark with raw JSON evidence. | ||
| - Unit and integration tests for bounded storage, negative API cases, and WebSocket lifecycle. | ||
| - CodeQL default-setup documentation, blocking static/security scans, audit, and production checklist. | ||
|
|
||
| ### Changed | ||
| - Canonical critical-path coverage is enforced at 90%. | ||
| - Message retention is bounded and thread-safe; API inputs and history queries are constrained. | ||
|
|
||
| ### Performance | ||
| - Reference run reduced peak Python allocations by 80.06% with a 6.8% throughput tradeoff. | ||
|
|
||
| ### Security | ||
| - Sanitized internal errors and changed dependency/Trivy findings from advisory to blocking. | ||
| - Upgraded Next.js from 14.2.15 to 15.5.20 to remove current HIGH-severity advisories; added a blocking frontend audit and production build. | ||
| - Removed pip/setuptools/wheel build tooling from the runtime image and constrained SARIF output to the declared HIGH/CRITICAL policy. | ||
|
|
||
| ## [0.2.0] - 2026-04-02 | ||
| ### Changed | ||
| - **Python runtime**: Docker base image upgraded from `python:3.10-slim` to `python:3.12-slim` | ||
| - **CI/CD**: GitHub Actions updated — `actions/checkout@v3→v4`, `actions/setup-python@v4→v5`, Python `3.11→3.12` | ||
| - **CI/CD**: GitHub Actions updated — `actions/checkout@v3→v4`, `actions/setup-python@v4→v5`, Python `3.11→3.12` | ||
| - **CI/CD**: Fixed `backend/requirements.txt` reference (created missing file) and corrected test runner path | ||
| - **requirements.txt**: Pinned minimum versions for all Python dependencies; added `pydantic-settings>=2.5.0`, `fastapi>=0.115.0`, `uvicorn>=0.30.0`, `httpx>=0.27.0`, `pytest-asyncio>=0.24.0` | ||
| - **Pydantic v2**: Migrated `BaseSettings` import in `app/core/app/core/config.py` from `pydantic` to `pydantic_settings` package | ||
| - **Deprecation fixes**: Replaced `datetime.utcnow()` (deprecated in Python 3.12) with `datetime.now(timezone.utc)` in `mcp_adapter.py`, `app/core/security.py`, and `backend/services/chat_service.py` | ||
| - **Node.js (server/)**: Upgraded dependencies — `express@4.18→4.21`, `socket.io@4.7→4.8`, `mongoose@7→8`, `dotenv@16.0→16.4`, `jest@29.5→29.7`, `supertest@6→7`, `nodemon@2→3` | ||
| - **Node.js (server/)**: Upgraded dependencies — `express@4.18→4.21`, `socket.io@4.7→4.8`, `mongoose@7→8`, `dotenv@16.0→16.4`, `jest@29.5→29.7`, `supertest@6→7`, `nodemon@2→3` | ||
|
Comment on lines
+25
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Fix character encoding corruption (mojibake). Several Markdown files contain text corrupted by a character encoding mismatch (e.g., UTF-8 bytes interpreted as Windows-1252), resulting in artifacts like
📍 Affects 3 files
🤖 Prompt for AI Agents |
||
|
|
||
| ### Breaking Changes | ||
| - **Pydantic v2**: `BaseSettings` is no longer exported from `pydantic`; it requires the `pydantic-settings` package. Run `pip install pydantic-settings` or use the updated `requirements.txt`. | ||
|
|
@@ -31,4 +49,3 @@ All notable changes to TrojanChat will be documented in this file. | |
| ### Security | ||
| - Added JWT expiration | ||
| - Added request rate limiting | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Separate Ruff and Bandit into distinct steps.
Because GitHub Actions runs shell scripts with
set -eby default, ifruff checkfinds issues and returns a non-zero exit code, thebanditcommand will not execute. Splitting these into two steps ensures both tools run and report their findings regardless of the other's status.🛠️ Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents