feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-06 10:18:37 +08:00
1 parent 3a9fbac2fc
commit d2b3d74def
571 files changed
+78064 -24681

No files matched your search

@@ -1,13 +1,12 @@
"""
services/schedule/shipping_audit_retention_job.py
用途:货代统一审计到期清理与哈希链抽样校验的 platform Job 入口。
依赖:audit_query_service.purge_expired_shipping_audit_events、
用途:货代统一审计到期清理、XFA 加密快照到期清理与哈希链抽样校验的 platform Job 入口。
依赖:audit_query_service.purge_expired_shipping_audit_events / purge_expired_xfa_audit_snapshots、
audit_snapshot_service.verify_event_hash_chain、progress_feature_flags.audit_retention_days。
逻辑:platform_api_path=shipping-audit-retention 时由 job_registry 调用;仅清理
retention_expires_at 非空且已到期的事件;新写入事件永久保留(expires=None)永不删除;
PostgreSQL 上 purge 在同事务设置 hxops.shipping_audit_purge=1,配合 append-only DELETE 触发器;
可选对近期聚合抽样校验 previous_event_hash / event_hash 链完整性。
retention_expires_at 非空且已到期的事件与 XFA 快照;新写入事件永久保留(expires=None)
永不删除;XFA 快照默认 3 年;哈希校验抽样检测篡改断链。
"""
from __future__ import annotations
@@ -17,7 +16,10 @@ from typing import Any
from flask import current_app
from app.models import ShippingAuditEvent
from app.services.shipping_notice.audit_query_service import purge_expired_shipping_audit_events
from app.services.shipping_notice.audit_query_service import (
purge_expired_shipping_audit_events,
purge_expired_xfa_audit_snapshots,
)
from app.services.shipping_notice.audit_snapshot_service import verify_event_hash_chain
from app.services.shipping_notice.progress_feature_flags import audit_retention_days
@@ -94,6 +96,11 @@ def run_shipping_audit_retention_schedule(task: Any, run: Any) -> dict[str, Any]
actor_id=f'schedule:{getattr(task, "id", "unknown")}',
)
result['retention_days'] = audit_retention_days()
result['xfa_snapshots'] = purge_expired_xfa_audit_snapshots(
limit=int(params.get('xfa_snapshot_limit') or params.get('limit') or 1000),
dry_run=dry_run,
actor_id=f'schedule:{getattr(task, "id", "unknown")}',
)
hash_verify_enabled = bool(
current_app.config.get('SHIPPING_NOTICE_AUDIT_HASH_VERIFY_ENABLED', True)