feat: deliver governed contract platform and async AI tasks
Build and Test Quality Gate / Contract Web typecheck and build (pull_request) Successful in 9m12s
Build and Test Quality Gate / Isolated Alibaba and Tencent KMS gateway (pull_request) Failing after 4m53s
Build and Test Quality Gate / Python tests and Contract API migration (pull_request) Failing after 24m55s
Security Quality Gate / npm audit, Bandit, pip-audit, detect-secrets (pull_request) Failing after 8m42s

This commit is contained in:
2026-08-26 12:48:13 +08:00
parent c2ac972d7b
commit 1d85329a6a
433 changed files with 72653 additions and 326 deletions
@@ -134,6 +134,27 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/ConnectivityCheckResult"
/api/v1/document-intelligence/extract-text:
post:
operationId: extractDocumentText
summary: Extract page-aware text from a contract document and delegate OCR when required
parameters:
- $ref: "#/components/parameters/TraceIdHeader"
- $ref: "#/components/parameters/TenantIdHeader"
- $ref: "#/components/parameters/UserIdHeader"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/DocumentExtractionRequest"
responses:
"200":
description: Document text extraction result
content:
application/json:
schema:
$ref: "#/components/schemas/DocumentExtractionResponse"
/api/v1/legal/qa:
post:
operationId: runLegalQa
@@ -155,6 +176,23 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/LegalQaResponse"
/api/v1/legal/qa/jobs:
post:
operationId: createLegalQaJob
summary: Queue a durable legal QA model job
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/LegalQaRequest"
responses:
"202":
description: Queued model job
content:
application/json:
schema:
$ref: "#/components/schemas/ModelInferenceJob"
/api/v1/legal/contract-review:
post:
operationId: runContractReview
@@ -176,6 +214,85 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/ContractReviewResponse"
/api/v1/legal/contract-review/jobs:
post:
operationId: createContractReviewJob
summary: Queue a durable contract review model job
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ContractReviewRequest"
responses:
"202":
description: Queued model job
content:
application/json:
schema:
$ref: "#/components/schemas/ModelInferenceJob"
/api/v1/model-jobs/{job_id}:
get:
operationId: getModelInferenceJob
summary: Poll a tenant-scoped model job
parameters:
- name: job_id
in: path
required: true
schema:
type: string
responses:
"200":
description: Model job state and result
content:
application/json:
schema:
$ref: "#/components/schemas/ModelInferenceJob"
/api/v1/model-jobs/{job_id}/retry:
post:
operationId: retryModelInferenceJob
summary: Requeue a retryable model job without hiding the prior outcome
parameters:
- name: job_id
in: path
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/ModelInferenceJobRetryRequest"
responses:
"202":
description: Requeued model job
content:
application/json:
schema:
$ref: "#/components/schemas/ModelInferenceJob"
/api/v1/model-jobs/{job_id}/handoff:
post:
operationId: handoffModelInferenceJob
summary: Transfer a fallback or failed model job to human review
parameters:
- name: job_id
in: path
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ModelInferenceJobHandoffRequest"
responses:
"200":
description: Human-owned model job
content:
application/json:
schema:
$ref: "#/components/schemas/ModelInferenceJob"
/api/v1/legal/review:
post:
operationId: runLegalReview
@@ -1440,6 +1557,79 @@ components:
type: number
format: float
nullable: true
ai_audit_run_id:
type: string
nullable: true
ModelInferenceJobRetryRequest:
type: object
properties:
triggered_by:
type: string
nullable: true
reason:
type: string
nullable: true
ModelInferenceJobHandoffRequest:
type: object
required: [reason]
properties:
reason:
type: string
note:
type: string
nullable: true
assignee:
type: string
nullable: true
ModelInferenceJob:
type: object
required:
- id
- tenant_id
- operation
- status
- stage
- progress_percent
- attempt_count
- max_attempts
- retryable
- fallback_used
- recommended_poll_after_ms
- created_at
- updated_at
properties:
id: { type: string }
tenant_id: { type: string }
operation: { type: string, enum: [legal_qa, contract_review] }
status:
type: string
enum: [queued, running, succeeded, fallback, failed, awaiting_human, resolved, cancelled]
stage: { type: string }
progress_percent: { type: integer, minimum: 0, maximum: 100 }
result:
type: object
nullable: true
additionalProperties: true
attempt_count: { type: integer }
max_attempts: { type: integer }
retryable: { type: boolean }
fallback_used: { type: boolean }
provider_status: { type: string, nullable: true }
audit_run_id: { type: string, nullable: true }
error_code: { type: string, nullable: true }
error_message: { type: string, nullable: true }
handoff_reason: { type: string, nullable: true }
handoff_note: { type: string, nullable: true }
handoff_assignee: { type: string, nullable: true }
resolution_note: { type: string, nullable: true }
queue_latency_ms: { type: integer }
execution_latency_ms: { type: integer }
total_latency_ms: { type: integer }
recommended_poll_after_ms: { type: integer }
created_at: { type: string, format: date-time }
updated_at: { type: string, format: date-time }
started_at: { type: string, format: date-time, nullable: true }
completed_at: { type: string, format: date-time, nullable: true }
ContractReviewRequest:
type: object
required:
@@ -1523,6 +1713,62 @@ components:
audit_run_id:
type: string
nullable: true
DocumentTextPage:
type: object
required:
- page_number
- text
properties:
page_number:
type: integer
minimum: 1
text:
type: string
DocumentExtractionRequest:
type: object
required:
- file_name
- content_base64
properties:
file_name:
type: string
content_base64:
type: string
content_type:
type: string
nullable: true
DocumentExtractionResponse:
type: object
required:
- status
- progress
- text
- pages
- page_count
- ocr_status
properties:
status:
type: string
enum: [parsed, ocr_required, failed]
progress:
type: integer
minimum: 0
maximum: 100
text:
type: string
pages:
type: array
items:
$ref: "#/components/schemas/DocumentTextPage"
page_count:
type: integer
minimum: 0
ocr_status:
type: string
enum: [not_required, skipped, succeeded, pending, failed]
message:
type: string
nullable: true
LegalReviewRequest:
type: object
required: