Skip to content

Build end-to-end argument analyzer API#7

Open
Spbd1 wants to merge 1 commit into
codex/build-classification-layer-for-offline-usefrom
codex/build-end-to-end-analyzer-and-api
Open

Build end-to-end argument analyzer API#7
Spbd1 wants to merge 1 commit into
codex/build-classification-layer-for-offline-usefrom
codex/build-end-to-end-analyzer-and-api

Conversation

@Spbd1
Copy link
Copy Markdown
Owner

@Spbd1 Spbd1 commented May 18, 2026

Motivation

  • Provide a deterministic, taxonomy-grounded end-to-end analyzer that accepts text and returns a structured argument risk report via HTTP.
  • Add calibrated scoring, false-positive guards, and human-review signals so reported risks are conservative and explainable.
  • Expose a simple API surface for integration and preserve backwards compatibility with legacy endpoints and summary fields.

Description

  • Implemented calibrated scoring and guards in engine/argument_risk_engine/scoring/ by adding calibration.py (calibration profile, thresholds, severity weights) and expanding scorer.py with calculate_risk_score, score_classification, legacy compatibility, and gating logic.
  • Built the analyzer pipeline in engine/argument_risk_engine/analyzer.py to extract claims, retrieve candidates, classify deterministically, convert evidence to absolute offsets, apply scoring, assemble structured claim/risk outputs, compute stable text_id, and expose diagnostic/healthy-pattern toggles.
  • Added richer explanations and false-positive messaging in engine/argument_risk_engine/explanation/explainer.py for inclusion in the report.
  • Wired backend API and types: added backend/app/schemas/analysis.py (request/response and nested models), backend/app/services/analyzer_service.py to call the analyzer, and backend/app/api/routes_analysis.py to add POST /analyze and keep legacy POST /api/analysis/analyze while also exposing /api/analyze; added an import shim in backend/app/__init__.py to ensure the engine package is importable from the app.
  • Added lightweight uvicorn module shims for local python -m uvicorn invocation and updated tests to validate scoring, analyzer shape/stability, and API endpoints (tests/test_scorer.py, tests/test_analyzer.py, tests/test_api_analysis.py).

Testing

  • Ran the full test suite with pytest -q, which passed (39 passed, 3 warnings).
  • Compiled code with python -m compileall backend engine tests uvicorn with no compile errors.
  • Verified backend can be started with the module form via python -m uvicorn backend.app.main:app --reload as a smoke test; the console entrypoint form uvicorn ... is not available in this environment (not installed) but the module start succeeded.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant