a3bb78e06b
Security Quality Gate / npm audit, Bandit, pip-audit, detect-secrets (pull_request) Failing after 16m35s
2.7 KiB
2.7 KiB
V2 Phase 3 Structured Review Results Backfill And Query
Date: 2026-06-30
This note records the second Slice 3.5 step after the structured review result tables were added.
Scope
Implemented an idempotent historical backfill command for existing review_tasks.risk_items and review_tasks.citations, plus a persistence-level structured risk query helper.
This slice does not change API responses, frontend behavior, or the legacy JSON compatibility fields.
Backfill Command
Module:
yuqei_contract_api.review_results_backfill_cli
Commands:
python -m yuqei_contract_api.review_results_backfill_cli assess
python -m yuqei_contract_api.review_results_backfill_cli backfill
python -m yuqei_contract_api.review_results_backfill_cli backfill --apply
python -m yuqei_contract_api.review_results_backfill_cli backfill --apply --force
Behavior:
assessis read-only.backfillwithout--applyis dry-run.backfill --applyonly rebuilds missing or count-inconsistent structured rows.backfill --apply --forcerebuilds all succeeded review tasks.- Repeated non-force apply runs are idempotent and should report
updated_task_count = 0after the first successful completion.
Query Helper
Added query_structured_review_risks(...) in:
yuqei_contract_api.persistence.review_results
Supported filters:
tenant_idcontract_idreview_task_idrisk_levelclause_idlimit
This helper intentionally remains persistence-only for now. No public API endpoint was added in this slice.
Compatibility
Still retained:
review_tasks.risk_itemsreview_tasks.citationsreview_tasks.primary_sources
No cleanup migration was added. No old JSON fields were removed.
Verification
python -m compileall -q yuqei-contract-platform\services\contract-api\src\yuqei_contract_api
python -m pytest yuqei-contract-platform\services\contract-api\tests\test_structured_review_results.py -q
python -m pytest yuqei-contract-platform\services\contract-api\tests\test_contract_workflow.py yuqei-contract-platform\services\contract-api\tests\test_health.py yuqei-contract-platform\services\contract-api\tests\test_display_cache_governance.py yuqei-contract-platform\services\contract-api\tests\test_structured_review_results.py -q
python -m alembic -c alembic.ini heads
Result:
- Compile passed.
- Structured review result backfill/query tests passed.
- Contract API core regression passed.
- Alembic head remains
20260630_0023.
Next Step
Recommended next step:
- Run
assessand non-forcebackfill --applyin the 192.168.3.90 smoke PostgreSQL environment after the20260630_0023migration is applied. - Then decide whether to expose structured risk query read paths through Contract API endpoints.