4.1 KiB
V2 Phase 3 Legal Fulltext Versioning
Date: 2026-07-02
Status
This slice closes the first implementation step for selected legal fulltext versioning.
Completed:
- Added Alembic migration
20260702_0027_add_legal_fulltext_versions.py. - Added ORM model
LegalFulltextVersionModel. - Added
LegalFulltextVersionRepository. - Added runtime schema-check coverage for
legal_fulltext_versions. - Switched
/api/v1/legal-articleslist/detail to repository-backed reads. - Switched legal change impact scan article resolution to repository-backed reads.
- Kept static
SELECTED_LEGAL_ARTICLESas compatibility fallback. - Added demo/dev seed of current selected legal articles into
legal_fulltext_versionsasv1.
Not changed in this slice:
- No bulk import tool for the full V1 legal corpus yet.
- No frontend legal-fulltext edit/version management UI yet.
- No remote smoke deployment for migration
20260702_0027yet.
Runtime Behavior
Legal article read order is now:
- Read the latest non-deleted article version from
legal_fulltext_versions. - If no version rows exist for the environment, fall back to the existing static selected legal articles.
Legal change impact scanning now resolves article_id and source_id through the repository first, so scans can target DB-only legal articles that do not exist in the static fixture.
The existing API contract remains unchanged:
GET /api/v1/legal-articlesGET /api/v1/legal-articles/{article_id}POST /api/v1/legal-change-impacts/scan
Schema
New table:
legal_fulltext_versions
Key fields:
tenant_idarticle_idversionsource_idsource_aliasessource_titlearticle_notitlearticle_textsummarykeywordstagsstatuseffective_datepublished_at- governance fields:
created_by,updated_by,deleted_at
Schema-check now treats the table as a Contract API core table and validates governance columns.
Validation
Local validation passed:
python -m py_compile `
yuqei-contract-platform/services/contract-api/src/yuqei_contract_api/legal_fulltext.py `
yuqei-contract-platform/services/contract-api/src/yuqei_contract_api/persistence/legal_fulltext.py `
yuqei-contract-platform/services/contract-api/src/yuqei_contract_api/persistence/models.py `
yuqei-contract-platform/services/contract-api/src/yuqei_contract_api/sqlalchemy_contract_repository.py `
yuqei-contract-platform/services/contract-api/src/yuqei_contract_api/sqlalchemy_repository_wiring.py `
yuqei-contract-platform/services/contract-api/src/yuqei_contract_api/schema_check.py `
yuqei-contract-platform/services/contract-api/migrations/versions/20260702_0027_add_legal_fulltext_versions.py
python -m pytest yuqei-contract-platform/services/contract-api/tests/test_contract_workflow.py -q
python -m pytest yuqei-contract-platform/services/contract-api/tests/test_health.py -q
Added/updated tests:
- selected legal articles remain queryable
- DB-only legal article versions are listable, fetchable, and usable by impact scan
- latest legal fulltext version wins over the static fixture
- schema-check reports
legal_fulltext_versionsas a missing core/governance table on stale schemas
Remaining Items From The User's Closure List
Done:
- Phase 3 Slice 3.6 published snapshots
- Selected legal fulltext versioning first implementation slice
Still pending:
- Remote smoke deployment and verification of migration
20260702_0027 - Full V1 legal corpus import/backfill tooling
- AI Platform tenant/Trace governance
- Provider/OCR secret ref compatibility
- pgvector extension/dimension/index schema-check
- Delivery quality gates rerun: Docker smoke, schema-check, interface benchmark, security scan, CI quality gate
- Deployment docs update after remote smoke and remaining quality gates
Recommended Next Step
Deploy this Contract API slice to 192.168.3.90 smoke, run Alembic to 20260702_0027, then verify:
/api/v1/runtime/schema-checkGET /api/v1/legal-articles?keyword=违约金GET /api/v1/legal-articles/LEGAL-CIVIL-0585POST /api/v1/legal-change-impacts/scan
After smoke passes, continue with AI Platform tenant/Trace governance.