fix(shipping-process-gates): 收口技术重试并补齐运维 UI
跨 Job 累计技术失败次数,耗尽后将 Attempt/Gate 置为 failed_terminal; 收缩旧 action_buttons;healthcheck 增加 Worker 领取探针;恢复卡展示责任方与审计,Admin 诊断改主从布局。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
323928626b
commit
cef3d5b26a
15 files changed
+489
-150
No files matched your search
@@ -513,8 +513,8 @@ def workspace_create_shipping_task_from_notice():
|
||||
task_no=task_id,
|
||||
)
|
||||
if not intake.accepted:
|
||||
from app.services.shipping_notice.state_machine import action_buttons_for_checkpoint
|
||||
return jsonify({'status': 'needs_human', 'task_id': task_id, 'message': '未能从附件抽取到可解析文本(可能是扫描件/OCR 不可用)。请复制粘贴文本,或更换清晰版文件后重试。', 'data': {'notice_upload': intake.to_notice_upload_meta()}, 'human_options': ['reparse', 'reject'], 'checkpoint': CP_NOTICE_TEXT_EXTRACTION_FAILED, 'action_buttons': action_buttons_for_checkpoint(CP_NOTICE_TEXT_EXTRACTION_FAILED)})
|
||||
# 旧 action_buttons 业务调用清零:仅保留 human_options 文案提示,不再下发可点击恢复按钮。
|
||||
return jsonify({'status': 'needs_human', 'task_id': task_id, 'message': '未能从附件抽取到可解析文本(可能是扫描件/OCR 不可用)。请复制粘贴文本,或更换清晰版文件后重试。', 'data': {'notice_upload': intake.to_notice_upload_meta()}, 'human_options': ['reparse', 'reject'], 'checkpoint': CP_NOTICE_TEXT_EXTRACTION_FAILED, 'action_buttons': []})
|
||||
task = ShippingTask.query.filter_by(task_no=task_id).first()
|
||||
if task:
|
||||
task.raw_content = intake.text
|
||||
@@ -915,9 +915,17 @@ def workspace_match_shipping_inventory(task_no: str):
|
||||
if options is not None:
|
||||
matched['human_options'] = options
|
||||
if 'action_buttons' not in matched:
|
||||
buttons = action_buttons_for_checkpoint(checkpoint)
|
||||
if buttons:
|
||||
matched['action_buttons'] = buttons
|
||||
# [STEP] 已有 ProcessExecution 时不再补充旧 STP 恢复按钮。
|
||||
from app.models import ShippingProcessExecution
|
||||
has_execution = (
|
||||
ShippingProcessExecution.query
|
||||
.filter_by(task_id=int(task.id))
|
||||
.first()
|
||||
) is not None
|
||||
if not has_execution:
|
||||
buttons = action_buttons_for_checkpoint(checkpoint)
|
||||
if buttons:
|
||||
matched['action_buttons'] = buttons
|
||||
return jsonify(matched)
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
backend/app/jobs/handlers/shipping_process_gate.py
|
||||
|
||||
用途:消费门禁恢复 Attempt Job,领取租约并执行 process_gate_executor。
|
||||
依赖:JobContext、process_gate_job_service、jobs.queue finish/fail。
|
||||
逻辑:由 shipping worker 领取;技术失败按 5s/30s/120s 退避重新入队;
|
||||
waiting_external 先结束当前 Job 再延迟入队新 Job(禁止复用仍 running 的 Job);
|
||||
成功进入 waiting_external 时调度下一次 poll Attempt。
|
||||
依赖:JobContext、process_gate_job_service、process_gate_service、jobs.queue finish/fail、
|
||||
process_gate_error_sanitizer。
|
||||
逻辑:由 shipping worker 领取;技术失败按 Attempt 累计次数 + 5s/30s/120s 退避重新入队;
|
||||
次数耗尽时 fail_job 并 complete_gate_attempt(failed_terminal);
|
||||
waiting_external 先结束当前 Job 再延迟入队新 Job;
|
||||
healthcheck_probe 载荷用于部署探针,不依赖真实 Attempt。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -18,25 +20,85 @@ from app.jobs.queue import fail_job, finish_job
|
||||
from app.jobs.registry import register_handler
|
||||
from app.jobs.types import JobType
|
||||
from app.models import Job, ShippingProcessGate, ShippingProcessGateAttempt
|
||||
from app.services.shipping_notice.process_gate_error_sanitizer import sanitize_gate_error_text
|
||||
from app.services.shipping_notice.process_gate_job_service import (
|
||||
claim_and_run_gate_attempt,
|
||||
enqueue_gate_attempt_job,
|
||||
schedule_waiting_external_poll,
|
||||
)
|
||||
from app.services.shipping_notice.process_gate_service import complete_gate_attempt
|
||||
|
||||
# 方案规定的技术重试退避(秒):第 1/2/3 次失败后延迟。
|
||||
_TECHNICAL_RETRY_BACKOFF_SECONDS: tuple[int, ...] = (5, 30, 120)
|
||||
_TECH_RETRY_KEY = 'technical_retry_count'
|
||||
|
||||
|
||||
def _technical_retry_count(attempt: ShippingProcessGateAttempt) -> int:
|
||||
"""读取 Attempt 上累计的技术失败次数(跨 force_new Job 保留)。"""
|
||||
snap = attempt.input_snapshot_json if isinstance(attempt.input_snapshot_json, dict) else {}
|
||||
try:
|
||||
return max(int(snap.get(_TECH_RETRY_KEY) or 0), 0)
|
||||
except (TypeError, ValueError):
|
||||
return 0
|
||||
|
||||
|
||||
def _bump_technical_retry_count(attempt: ShippingProcessGateAttempt) -> int:
|
||||
"""递增并回写技术失败次数,返回递增后的值。"""
|
||||
snap = dict(attempt.input_snapshot_json) if isinstance(attempt.input_snapshot_json, dict) else {}
|
||||
next_count = _technical_retry_count(attempt) + 1
|
||||
snap[_TECH_RETRY_KEY] = next_count
|
||||
attempt.input_snapshot_json = snap
|
||||
return next_count
|
||||
|
||||
|
||||
def _finalize_attempt_after_retry_exhausted(
|
||||
*,
|
||||
attempt: ShippingProcessGateAttempt,
|
||||
exc: BaseException,
|
||||
) -> None:
|
||||
"""
|
||||
技术重试耗尽:将 Attempt/Gate 收口为 failed_terminal。
|
||||
|
||||
核心逻辑:调用 complete_gate_attempt,避免 Job=failed 而 Gate 仍 running。
|
||||
"""
|
||||
safe = sanitize_gate_error_text(exc, max_len=500) or 'technical_retry_exhausted'
|
||||
if attempt.status == 'queued':
|
||||
attempt.status = 'running'
|
||||
db.session.flush()
|
||||
complete_gate_attempt(
|
||||
attempt_id=int(attempt.id),
|
||||
outcome='failed_terminal',
|
||||
blocking_reason_code='technical_failure',
|
||||
blocking_reason_json={'message': safe, 'technical_retry_exhausted': True},
|
||||
effective_result_json={'findings': [], 'error': 'technical_retry_exhausted'},
|
||||
output_snapshot={'error': safe, 'technical_retry_exhausted': True},
|
||||
error_code='TECHNICAL_RETRY_EXHAUSTED',
|
||||
error_summary=safe,
|
||||
)
|
||||
|
||||
|
||||
@register_handler(JobType.SHIPPING_PROCESS_GATE)
|
||||
def run_shipping_process_gate(ctx: JobContext, payload: dict) -> None:
|
||||
"""
|
||||
执行门禁 Attempt。
|
||||
执行门禁 Attempt;支持部署健康检查探针载荷。
|
||||
|
||||
Args:
|
||||
ctx: Worker 上下文。
|
||||
payload: 须含 attempt_id 与 job_id。
|
||||
payload: 须含 attempt_id 与 job_id;healthcheck_probe=True 时仅证明领取能力。
|
||||
"""
|
||||
# [STEP] 部署探针:Worker 领取后立即成功结束,不触碰业务 Attempt。
|
||||
if bool(payload.get('healthcheck_probe')):
|
||||
raw_job_id = payload.get('job_id')
|
||||
job = db.session.get(Job, int(raw_job_id)) if raw_job_id else None
|
||||
if job is None:
|
||||
raise RuntimeError('missing_job_id_for_healthcheck_probe')
|
||||
finish_job(
|
||||
job.id,
|
||||
result={'status': 'healthcheck_probe_ok'},
|
||||
owned_attempt=int(job.attempts or 0),
|
||||
)
|
||||
return
|
||||
|
||||
attempt_id = int(payload.get('attempt_id') or 0)
|
||||
raw_job_id = payload.get('job_id')
|
||||
job = db.session.get(Job, int(raw_job_id)) if raw_job_id else None
|
||||
@@ -70,17 +132,23 @@ def run_shipping_process_gate(ctx: JobContext, payload: dict) -> None:
|
||||
db.session.commit()
|
||||
return
|
||||
|
||||
# [STEP] 技术失败:先 fail 当前 Job,再按退避入队新 Job。
|
||||
max_attempts = int(job.max_attempts or 3)
|
||||
if attempt is not None and owned_attempt < max_attempts:
|
||||
delay_idx = min(max(owned_attempt - 1, 0), len(_TECHNICAL_RETRY_BACKOFF_SECONDS) - 1)
|
||||
# [STEP] 技术失败:按 Attempt 累计次数判定,禁止因 force_new Job.attempts=0 无限重试。
|
||||
max_attempts = max(
|
||||
int(current_app.config.get('SHIPPING_PROCESS_GATE_TECHNICAL_RETRIES', 3) or 3),
|
||||
1,
|
||||
)
|
||||
retries_done = _technical_retry_count(attempt) if attempt is not None else max_attempts
|
||||
safe_error = sanitize_gate_error_text(exc, max_len=1000) or 'technical_failure'
|
||||
if attempt is not None and retries_done + 1 < max_attempts:
|
||||
delay_idx = min(retries_done, len(_TECHNICAL_RETRY_BACKOFF_SECONDS) - 1)
|
||||
delay = _TECHNICAL_RETRY_BACKOFF_SECONDS[delay_idx]
|
||||
fail_job(
|
||||
job.id,
|
||||
error=str(exc)[:1000],
|
||||
error=safe_error,
|
||||
retryable=False,
|
||||
owned_attempt=owned_attempt,
|
||||
)
|
||||
_bump_technical_retry_count(attempt)
|
||||
attempt.status = 'queued'
|
||||
attempt.job_id = None
|
||||
attempt.worker_id = None
|
||||
@@ -97,7 +165,10 @@ def run_shipping_process_gate(ctx: JobContext, payload: dict) -> None:
|
||||
db.session.commit()
|
||||
return
|
||||
|
||||
fail_job(job.id, error=str(exc)[:1000], retryable=False, owned_attempt=owned_attempt)
|
||||
fail_job(job.id, error=safe_error, retryable=False, owned_attempt=owned_attempt)
|
||||
if attempt is not None:
|
||||
_finalize_attempt_after_retry_exhausted(attempt=attempt, exc=exc)
|
||||
db.session.commit()
|
||||
return
|
||||
|
||||
finish_job(job.id, result=result, owned_attempt=owned_attempt)
|
||||
|
||||
@@ -6,7 +6,8 @@ services/shipping_notice/process_gate_job_service.py
|
||||
process_gate_service、fulfillment_audit。
|
||||
逻辑:由 recovery_service 对异步动作调用 enqueue;Worker Handler 调用
|
||||
claim_and_run_gate_attempt;重试/轮询使用 force_new 避免复用 running Job;
|
||||
waiting_external 超时转入 blocked_manual;心跳 commit 后对其他 Worker 可见。
|
||||
waiting_external 超时转入 blocked_manual;心跳 commit 后对其他 Worker 可见;
|
||||
enqueue_process_gate_healthcheck_probe 供部署脚本验证 Worker 真实领取。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -54,6 +55,31 @@ def _heartbeat_seconds() -> int:
|
||||
return max(int(current_app.config.get('SHIPPING_PROCESS_GATE_HEARTBEAT_SECONDS', 15) or 15), 5)
|
||||
|
||||
|
||||
def enqueue_process_gate_healthcheck_probe(*, created_by_id: int | None = None) -> int:
|
||||
"""
|
||||
入队门禁健康检查探针 Job,供 deploy healthcheck 验证 Worker 真实领取。
|
||||
|
||||
核心逻辑:payload.healthcheck_probe=True,handler 领取后直接 finish,不依赖 Attempt。
|
||||
|
||||
Returns:
|
||||
Job 主键。
|
||||
"""
|
||||
business_ref = f'healthcheck:process-gate:{_utc_now().strftime("%Y%m%d%H%M%S")}:{uuid.uuid4().hex[:8]}'
|
||||
return int(
|
||||
enqueue(
|
||||
JobType.SHIPPING_PROCESS_GATE,
|
||||
{'healthcheck_probe': True},
|
||||
domain=SHIPPING_PROCESS_GATE_JOB_DOMAIN,
|
||||
business_ref=business_ref,
|
||||
created_by_id=created_by_id,
|
||||
message='Process Gate healthcheck probe',
|
||||
max_attempts=1,
|
||||
dedupe_active=False,
|
||||
commit=True,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def enqueue_gate_attempt_job(
|
||||
*,
|
||||
attempt_id: int,
|
||||
|
||||
@@ -6,8 +6,8 @@ services/shipping_notice/ui_state.py
|
||||
process_gate_projection(统一 Gate 用户摘要)。
|
||||
逻辑:从 ShippingTask DB 字段经状态机解析 checkpoint/checkpoint_kind/action_buttons,
|
||||
再补充七步流程与可解释 summary(当前待办、暂停原因、下一自动步骤、操作入口、stp_facts);
|
||||
若存在 ProcessExecution 且当前有 blocking Gate,则清空 action_buttons,
|
||||
恢复动作仅由 process_gate 驱动(Gate 为唯一业务真相);
|
||||
若存在 ProcessExecution:阻断时清空 action_buttons;非阻断时仅保留
|
||||
download_excel / mark_manual_uploaded / refresh(恢复动作仅由 process_gate 驱动);
|
||||
批次 UI 仅作会话上传集合摘要,不作为履约写操作面。
|
||||
"""
|
||||
|
||||
@@ -555,9 +555,17 @@ def build_task_ui_state(task: ShippingTask) -> dict[str, Any]:
|
||||
ui = resolve_task_ui_state(task)
|
||||
action_buttons = _action_buttons_for_task(task)
|
||||
process_gate = _process_gate_user_summary_for_task(task)
|
||||
# [STEP] Gate 阻断时旧 action_buttons 不再作为业务恢复真相,避免双卡片/双动作。
|
||||
if isinstance(process_gate, dict) and process_gate.get('current_blocking_gate'):
|
||||
action_buttons = []
|
||||
# [STEP] 存在 ProcessExecution 时恢复动作仅由 process_gate 驱动;
|
||||
# 仅保留非恢复类 STP 动作(下载 Excel / 人工上传凭据 / 刷新)。
|
||||
_non_recovery_action_ids = frozenset({'download_excel', 'mark_manual_uploaded', 'refresh'})
|
||||
if isinstance(process_gate, dict):
|
||||
if process_gate.get('current_blocking_gate'):
|
||||
action_buttons = []
|
||||
else:
|
||||
action_buttons = [
|
||||
button for button in action_buttons
|
||||
if str((button or {}).get('id') or '') in _non_recovery_action_ids
|
||||
]
|
||||
steps = build_shipping_workflow_steps(task, ui.checkpoint)
|
||||
current_index = _derive_current_step_index(task)
|
||||
current_step = steps[current_index] if 0 <= current_index < len(steps) else None
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
"""
|
||||
tests/test_shipping_process_gate_retry_cap.py
|
||||
|
||||
用途:验证门禁技术失败跨 force_new Job 累计重试上限,并在耗尽后收口 Attempt/Gate。
|
||||
依赖:Flask testing app、run_shipping_process_gate handler、process_gate_service。
|
||||
逻辑:mock claim_and_run 持续抛错;断言最多 TECHNICAL_RETRIES 次失败后
|
||||
Attempt/Gate 进入 failed_terminal,且不再入队新的重试 Job。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from app import db
|
||||
from app.jobs.handlers.shipping_process_gate import run_shipping_process_gate
|
||||
from app.jobs.types import JobType
|
||||
from app.models import Job, ShippingProcessGate, ShippingProcessGateAttempt
|
||||
from app.services.shipping_notice.process_gate_job_service import (
|
||||
SHIPPING_PROCESS_GATE_JOB_DOMAIN,
|
||||
enqueue_gate_attempt_job,
|
||||
)
|
||||
from app.services.shipping_notice.process_gate_service import (
|
||||
ensure_execution_for_workflow_version,
|
||||
queue_gate_attempt,
|
||||
)
|
||||
from tests.test_shipping_process_gate_service import _seed_workflow_version
|
||||
|
||||
|
||||
def test_technical_retries_cap_across_force_new_jobs(app):
|
||||
"""跨 Job 累计失败达到上限后必须 failed_terminal,且不再新建 queued Job。"""
|
||||
with app.app_context():
|
||||
app.config['SHIPPING_PROCESS_GATE_TECHNICAL_RETRIES'] = 3
|
||||
_user, item, version = _seed_workflow_version(suffix='retrycap')
|
||||
execution = ensure_execution_for_workflow_version(
|
||||
workflow_item_id=int(item.id),
|
||||
workflow_item_version_id=int(version.id),
|
||||
)
|
||||
attempt = queue_gate_attempt(
|
||||
execution_no=execution.execution_no,
|
||||
gate_code='layout_parsing',
|
||||
trigger_type='system_requeue',
|
||||
actor_type='system',
|
||||
actor_id='retry-cap',
|
||||
idempotency_key='retry-cap-1',
|
||||
input_snapshot={'action_code': 'retry_layout_parsing', 'payload': {}},
|
||||
)
|
||||
first_job_id = enqueue_gate_attempt_job(attempt_id=int(attempt.id))
|
||||
db.session.commit()
|
||||
attempt_id = int(attempt.id)
|
||||
|
||||
with patch(
|
||||
'app.jobs.handlers.shipping_process_gate.claim_and_run_gate_attempt',
|
||||
side_effect=RuntimeError('boom https://erp.example.com/x?token=abc'),
|
||||
):
|
||||
for round_idx in range(5):
|
||||
attempt_row = db.session.get(ShippingProcessGateAttempt, attempt_id)
|
||||
assert attempt_row is not None
|
||||
if attempt_row.status in {'failed', 'succeeded', 'cancelled'}:
|
||||
break
|
||||
job_id = int(attempt_row.job_id or 0)
|
||||
if job_id <= 0:
|
||||
job_id = enqueue_gate_attempt_job(attempt_id=attempt_id, force_new=True)
|
||||
db.session.commit()
|
||||
job = db.session.get(Job, job_id)
|
||||
assert job is not None
|
||||
job.status = 'running'
|
||||
job.attempts = 1
|
||||
attempt_row.status = 'running'
|
||||
gate = db.session.get(ShippingProcessGate, int(attempt_row.gate_id))
|
||||
if gate is not None:
|
||||
gate.status = 'running'
|
||||
db.session.commit()
|
||||
|
||||
ctx = MagicMock()
|
||||
ctx.extras = {'worker_label': f'retry-cap-worker-{round_idx}'}
|
||||
run_shipping_process_gate(ctx, {'attempt_id': attempt_id, 'job_id': job_id})
|
||||
|
||||
attempt_final = db.session.get(ShippingProcessGateAttempt, attempt_id)
|
||||
gate_final = db.session.get(ShippingProcessGate, int(attempt_final.gate_id))
|
||||
assert attempt_final is not None
|
||||
assert attempt_final.status == 'failed'
|
||||
assert gate_final is not None
|
||||
assert gate_final.status == 'failed_terminal'
|
||||
assert attempt_final.error_code == 'TECHNICAL_RETRY_EXHAUSTED'
|
||||
# 敏感 URL 不得原样落库
|
||||
assert 'erp.example.com' not in str(attempt_final.error_summary or '')
|
||||
|
||||
failed_jobs = (
|
||||
Job.query
|
||||
.filter_by(
|
||||
domain=SHIPPING_PROCESS_GATE_JOB_DOMAIN,
|
||||
job_type=JobType.SHIPPING_PROCESS_GATE.value,
|
||||
status='failed',
|
||||
)
|
||||
.count()
|
||||
)
|
||||
assert failed_jobs == 3
|
||||
queued_jobs = (
|
||||
Job.query
|
||||
.filter_by(
|
||||
domain=SHIPPING_PROCESS_GATE_JOB_DOMAIN,
|
||||
job_type=JobType.SHIPPING_PROCESS_GATE.value,
|
||||
status='queued',
|
||||
)
|
||||
.count()
|
||||
)
|
||||
assert queued_jobs == 0
|
||||
assert int(first_job_id) > 0
|
||||
@@ -1,6 +1,6 @@
|
||||
# 货代发货通知 — 全门禁中断恢复阶段验收报告
|
||||
|
||||
> **基线日期**:2026-08-01(第三次评审修复后)
|
||||
> **基线日期**:2026-08-01(第四次评审修复后)
|
||||
> **契约**:[`process-gate-recovery-contract.md`](./process-gate-recovery-contract.md)
|
||||
> **技术手册**:[`technical.md`](./technical.md)
|
||||
|
||||
@@ -10,22 +10,17 @@
|
||||
|
||||
| 阶段 | 目标 | 结论 |
|
||||
| --- | --- | --- |
|
||||
| Phase 1.5 | Finding / 字段阻断 / 原因唯一归属 / 旧五门禁收敛 | **通过** |
|
||||
| Phase 2 | Execution/Gate/Attempt 模型与迁移 | **通过**(定向测) |
|
||||
| Phase 3 | 统一领域服务 + 业务接线(含履约 13–19) | **通过**(定向测) |
|
||||
| Phase 4 | Job、租约、运行中心跳、Worker 接管、真实异步执行器 | **通过**(定向测) |
|
||||
| Phase 5 | Workspace/Admin API、权限、幂等冲突、异常脱敏 | **通过**(定向测) |
|
||||
| Phase 6 | Chat / 复核台 / 任务中心统一恢复卡片;Gate 阻断时旧 `action_buttons` 清零 | **代码通过**;实机阻断卡需 Execution 数据 |
|
||||
| Phase 7 | 故障注入、环境变量、healthcheck、验收证据 | **部分通过**(缺生产双 Worker 演练签字) |
|
||||
| Phase 1.5–6 | 契约 / 模型 / 服务 / API / UI 卡片 | **代码与定向测通过** |
|
||||
| Phase 7 | 故障注入、环境变量、healthcheck、验收证据 | **部分通过**(缺生产双 Worker 强杀演练与人工签署) |
|
||||
|
||||
**发布边界**:核心代码须已纳入 Git(见提交);**人工实机 / 生产演练未签前,仍不得宣称生产可发布闭环。** Phase 7 与「上线前 28 条」人工项未全部签署,正式发布仍阻断。
|
||||
**发布边界**:人工实机 / 生产演练未签前,**不得宣称生产可发布闭环**。
|
||||
|
||||
仍待人工签署:
|
||||
|
||||
- 生产双 Worker 强杀现场演练
|
||||
- Dify 平台配置确认
|
||||
- 管理端 768px 实机截图
|
||||
- 真实「唯一当前阻断 + 主恢复动作 + 409 刷新」视觉验收
|
||||
- 管理端 768px / 真实阻断卡 / 409 刷新视觉验收
|
||||
- 完整前端 E2E 与生产构建签字
|
||||
|
||||
---
|
||||
|
||||
@@ -33,69 +28,27 @@
|
||||
|
||||
| 优先级 | 问题 | 修复 |
|
||||
| --- | --- | --- |
|
||||
| P0 | 核心交付文件未跟踪 | 纳入 Git(模型/迁移/服务/API/Worker/前端/测试/文档) |
|
||||
| P0 | Phase 7 未闭环 | 本报告保持「部分通过」;不虚构签署 |
|
||||
| P1 | 旧 `action_buttons` 与 Gate 双真相 | `build_task_ui_state` 在 blocking Gate 时清空 `action_buttons`;TaskTodoPanel 兜底隐藏 |
|
||||
| P1 | 异常摘要未脱敏 | `process_gate_error_sanitizer` + executor/service/projection |
|
||||
| P1 | Admin 诊断筛选不足 | 支持 Gate/原因/责任方/时间/搜索;Attempt Diff + 审计中心入口 |
|
||||
| P2 | 诊断页原始 JSON | Findings/阻断原因结构化卡片 |
|
||||
| P2 | funclist 与验收矛盾 | funclist 改为 Phase 7 部分完成表述 |
|
||||
| P1 | `force_new` Job 重置 attempts 导致无限重试 | Attempt.`technical_retry_count` 跨 Job 累计;达 `SHIPPING_PROCESS_GATE_TECHNICAL_RETRIES` 停止入队 |
|
||||
| P1 | 重试耗尽后 Attempt/Gate 仍 running | `complete_gate_attempt(failed_terminal)` + `TECHNICAL_RETRY_EXHAUSTED` |
|
||||
| P1 | 旧 action_buttons 业务调用 | 有 Execution 时阻断清零、非阻断仅保留 download/mark_upload/refresh;匹配/OCR 响应不再补旧按钮 |
|
||||
| P1 | healthcheck 未验证领取 | 探针 Job `healthcheck_probe` + 等待 Worker running/终态 |
|
||||
| UI | 恢复卡缺责任方 / 审计 | `ProcessGateRecoveryCard` 展示责任方 + 查看审计 |
|
||||
| UI | Admin 非主从布局 | lg+ 左列表右详情 sticky 主从布局 |
|
||||
|
||||
---
|
||||
|
||||
## 3. 关键交付物与实测
|
||||
|
||||
### 领域与接线
|
||||
|
||||
- `process_gate_*` 服务族(含幂等校验、脱敏、授权只读)
|
||||
- 迁移 head:`d0e1f2a3b4c6_add_shipping_process_gate_recovery`
|
||||
- Gate 阻断时 `ui_state.action_buttons = []`
|
||||
|
||||
### API / 前端
|
||||
|
||||
- Workspace / Admin process-execution 路由(Admin 多维筛选)
|
||||
- `features/shipping-process-gates/*` + Admin 诊断页
|
||||
- 四语言错误码与诊断文案
|
||||
|
||||
### 测试(2026-08-01 本机工作树实测)
|
||||
## 3. 测试(本轮)
|
||||
|
||||
| 套件 | 结果 |
|
||||
| --- | --- |
|
||||
| `pytest` `test_shipping_process_gate_*.py` + `test_shipping_process_gate_error_sanitizer.py` | **49 passed** |
|
||||
| `vitest` `shipping-process-gates` + `shippingConfigNavigation.spec.ts` | **6 passed** |
|
||||
| `vue-tsc --noEmit` | **通过** |
|
||||
| 全量 `test_shipping_process_gate_*.py`(含 retry_cap / sanitizer) | **50 passed** |
|
||||
| `vitest` shipping-process-gates + `vue-tsc --noEmit` | **通过** |
|
||||
|
||||
---
|
||||
|
||||
## 4. 部署影响面(Phase 7)
|
||||
|
||||
已变更:
|
||||
|
||||
- `.env.shared` / `docker-compose.yml`:`SHIPPING_PROCESS_GATE_*`
|
||||
- `scripts/healthcheck.sh`:shipping-worker 运行 + 门禁表 + handler 注册
|
||||
|
||||
**上线前必须**:
|
||||
|
||||
1. 各环境 Alembic upgrade(门禁三表 + audit `actor_type` CHECK)
|
||||
2. `deploy_compose` 健康检查通过
|
||||
3. 数据库备份后发布
|
||||
4. 人工完成 §1 待签署项
|
||||
|
||||
---
|
||||
|
||||
## 5. Dify 配置说明(人工)
|
||||
|
||||
本方案**不**要求 Agent 修改 Dify。请人工确认:
|
||||
|
||||
1. 输出仍符合当前动态 Schema / Observation 契约
|
||||
2. 不新增绕过 HXOPS Gate 的并行「下一节点」字段
|
||||
3. 可选字段证据不足不得在 Dify 侧被标成流程硬失败
|
||||
|
||||
---
|
||||
|
||||
## 6. 签署
|
||||
## 4. 签署
|
||||
|
||||
| 角色 | 结果 | 日期 |
|
||||
| --- | --- | --- |
|
||||
| 实现(Agent) | 代码阻断项已修复;定向 pytest **49 passed**;vue-tsc 通过;Phase 7 人工项未签 | 2026-08-01 |
|
||||
| 实现(Agent) | Worker 重试/收口、旧动作收缩、探针、UI 责任方/审计/主从布局已修 | 2026-08-01 |
|
||||
| 人工 QA / 生产演练 | 待签署 | — |
|
||||
+1
-1
@@ -80,7 +80,7 @@
|
||||
| 订单模板录入 UX 重构(阶段 0-7) | 已完成 | 已完成 Draft Revision、Lease、向导、独立草稿编辑器自动保存、不可变验证运行与两步发布报告;盲测工作台支持独立样本复核、执行与批准,同模板族历史 annotation/training/新旧 blind test 文档可重新复核复用,重复上传按内容和表身份收敛,当前版本建模样本仍严格排除。编辑器在可见状态自动续租。Dify 无需配置变更。 |
|
||||
| 订单人工复核工作台(阶段 0-7) | 已实现 | 每个 PDF Unit 一个 Review Case,机器 Candidate/Extraction 不可变、人工 Draft 独立版本化;按 PDF 独立处置、证据复核与原子确认建单,不支持多订单 PDF 或跨 PDF 合并/拆分。字段和明细可按冻结 bbox 定位 PDF 原文(明细按 table/cell 反查),版本历史按需展开;确认后展示 `auto_progress` 真实结果/检查点并可直达任务进度工作台。单 PDF 重识别复用 WorkflowItem 真实状态展示已提交/版面解析/字段提取/草稿生成,完成后自动打开新版;“跳转当前版本”点击时强制刷新工作项,目标未就绪时明确提示。 |
|
||||
| **STP 直通 + 例外工作台** | 已实现(首期) | 可信 PDF 自动建 Task 并推进至「待人工上传」;例外进入人工复核/任务处理;Chat 仅上传与通知。**阶段 0–5 已落地**:字段契约、起行锚点、建单资格与候选、自动建单/复核台、跨候选库存匹配→Excel→待人工上传、统一 `ui_state.stp_facts` 与审计双写/时间线 i18n。**项次派生 Phase 0–4**:`line_no`=内部项次、`export_sequence`=导出行号、Schema 派生模拟、运行时派生审计、复核覆盖锁定与 `field_meta` 投影、冻结血缘。**库存源路由独立恢复(门禁恢复阶段 0)**:复核台可按最新已发布规则与库存源启停重算路由(不重识别 PDF);人工决定优先且不被静默覆盖;支持采用规则建议 / 保留人工结果;幂等键与审计前后快照齐全。首期不触发货代 RPA 上传、不改 Dify |
|
||||
| **全门禁级中断恢复(契约冻结)** | 已实现(Phase 1.5–6 自动化;Phase 7 部分) | **代码与定向自动化已落地**:库存源路由独立恢复;契约/模型/迁移;Finding 语义;领域服务与业务接线;Job 租约/心跳/Worker;Workspace/Admin API;Chat/复核台/任务中心恢复卡片;Admin 诊断筛选与 Attempt Diff;Gate 阻断时旧 `action_buttons` 清零;异常摘要脱敏。权威契约:[process-gate-recovery-contract.md](features/shipping-notice/process-gate-recovery-contract.md);验收:[process-gate-recovery-acceptance.md](features/shipping-notice/process-gate-recovery-acceptance.md)。**Phase 7 未闭环**:生产双 Worker 强杀演练、真实 Execution E2E/阻断卡视觉、人工 QA 签署。不引入 Temporal/Celery。 |
|
||||
| **全门禁级中断恢复(契约冻结)** | 已实现(Phase 1.5–6 自动化;Phase 7 部分) | **代码与定向自动化已落地**:契约/模型/迁移;领域服务与接线;Job 租约/心跳/Worker(跨 Job 累计技术重试 + 耗尽收口);Workspace/Admin API;三入口恢复卡(责任方+审计);Admin 主从诊断;Execution 存在时旧恢复 `action_buttons` 清零;异常脱敏;healthcheck 探针领取。权威契约:[process-gate-recovery-contract.md](features/shipping-notice/process-gate-recovery-contract.md);验收:[process-gate-recovery-acceptance.md](features/shipping-notice/process-gate-recovery-acceptance.md)。**Phase 7 未闭环**:生产双 Worker 演练、真实阻断视觉/E2E、人工签署。不引入 Temporal/Celery。 |
|
||||
| **订单项次派生与血缘审计** | 已实现(Phase 0–4 + 评审纠偏) | 统一 `customer_po_line_no` / `line_no` / `export_sequence`;Schema 派生模拟支持历史 Extraction 样本;运行时派生含 `evidence_refs`;复核覆盖/恢复(`LINE_NO_OVERRIDDEN`/`LINE_NO_RESTORED`);货代统一审计新写入永久保留(`6a9c3e5f7b2d`) |
|
||||
| 模板发布与自动冻结资格分离(阶段 4) | 已实现 | Profile 的发布仅允许确定性解析;每个发布版本独立冻结人工确认资格,首版强制 `manual_confirmation` 且自动冻结关闭,盲测批准、旧版本资格或 checksum 变化均不能越过该门禁 |
|
||||
| Run 自动冻结门禁与执行 | 已实现 | Run 创建时冻结 `manual_confirmation` 初始策略;结果落库后按模板资格、已确认 Bill-to 客户、业务场景、技术失败、预算停止和待处理订单刷新 `auto_freeze_policy_json`。仅资格与全部门禁显式放行时,自动消费当前 Run 的 accepted Candidate 并冻结新建 Task;不触发库存、Excel 或上传履约副作用。 |
|
||||
|
||||
+59
-57
@@ -2,7 +2,8 @@
|
||||
features/admin/modules/shipping-process-gates/ShippingProcessGateDiagnosticsPage.vue
|
||||
用途:管理员 Process Gate Execution 诊断——列表、Gate 轨道与 Attempt 明细。
|
||||
依赖:process-gates.api、Vue Router、Vue I18n(admin + workspace.processGate 动作文案)。
|
||||
逻辑:只读诊断;多维度筛选(status/gate/reason/party/q/时间);小屏卡片化列表,lg+ 横向表格(nowrap + 滚动提示);
|
||||
逻辑:只读诊断;多维度筛选(status/gate/reason/party/q/时间);小屏卡片列表 + 详情下置;
|
||||
lg+ 主从布局(左侧 ~38% Execution 紧凑列表 + 分页,右侧 sticky 详情:Gate/findings/attempts);
|
||||
状态/动作展示业务标签并附技术码;Gate 诊断结构化卡片(findings/blocking/effective_result);
|
||||
Attempt 展示 snapshot_diff 摘要并可跳转 AdminShippingAudit。
|
||||
-->
|
||||
@@ -393,6 +394,13 @@ async function loadAttempts(gateCode: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断 Execution 是否为当前详情选中项,供 lg+ 主从列表行高亮。
|
||||
*/
|
||||
function isExecutionSelected(executionNo: string): boolean {
|
||||
return Boolean(detail.value?.execution_no && detail.value.execution_no === executionNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭详情面板。
|
||||
*/
|
||||
@@ -531,63 +539,56 @@ onMounted(() => {
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<!-- lg+:横向表格;表头 nowrap + 外层滚动 -->
|
||||
<div class="hidden lg:block">
|
||||
<p class="mb-2 text-xs text-muted">{{ t('admin.shippingProcessGates.scrollHint') }}</p>
|
||||
<div class="overflow-x-auto rounded-xl border border-default">
|
||||
<table class="min-w-[720px] w-full text-sm">
|
||||
<thead class="bg-surface-soft text-left text-xs uppercase text-muted">
|
||||
<tr>
|
||||
<th class="whitespace-nowrap px-4 py-3">{{ t('admin.shippingProcessGates.executionNo') }}</th>
|
||||
<th class="whitespace-nowrap px-4 py-3">{{ t('admin.shippingProcessGates.status') }}</th>
|
||||
<th class="whitespace-nowrap px-4 py-3">{{ t('admin.shippingProcessGates.currentGate') }}</th>
|
||||
<th class="whitespace-nowrap px-4 py-3">{{ t('admin.shippingProcessGates.nextAction') }}</th>
|
||||
<th class="whitespace-nowrap px-4 py-3">{{ t('admin.shippingProcessGates.updatedAt') }}</th>
|
||||
<th class="whitespace-nowrap px-4 py-3">{{ t('admin.shippingProcessGates.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="loading">
|
||||
<td colspan="6" class="px-4 py-8 text-center text-muted">{{ t('admin.shippingProcessGates.loading') }}</td>
|
||||
</tr>
|
||||
<tr v-else-if="!rows.length">
|
||||
<td colspan="6" class="px-4 py-8 text-center text-muted">{{ t('admin.shippingProcessGates.empty') }}</td>
|
||||
</tr>
|
||||
<tr v-for="row in rows" :key="row.execution_no" class="border-t border-default">
|
||||
<td class="whitespace-nowrap px-4 py-3 font-mono text-xs">{{ row.execution_no }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<div>{{ statusLabel(row.status) }}</div>
|
||||
<div class="font-mono text-[11px] text-muted">{{ row.status }}</div>
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 font-mono text-xs">{{ row.current_gate_code || '—' }}</td>
|
||||
<td class="px-4 py-3 text-xs">{{ actionLabel(row.primary_next_action_code) }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3">{{ formatTime(row.updated_at) }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3">
|
||||
<button type="button" class="text-brand-600 hover:underline" @click="openDetail(row.execution_no)">
|
||||
{{ t('admin.shippingProcessGates.viewDetail') }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- lg+ 主从:左列表+分页,右 sticky 详情;小屏在网格外卡片列表,网格内仅分页+详情 -->
|
||||
<div class="grid lg:grid-cols-[minmax(280px,38%)_minmax(0,1fr)] gap-4 items-start">
|
||||
<div class="space-y-3">
|
||||
<!-- lg+:紧凑 Execution 行列表 -->
|
||||
<div class="hidden lg:block space-y-1.5" data-testid="shipping-process-gate-list">
|
||||
<p v-if="loading" class="rounded-xl border border-default px-4 py-8 text-center text-sm text-muted">
|
||||
{{ t('admin.shippingProcessGates.loading') }}
|
||||
</p>
|
||||
<p v-else-if="!rows.length" class="rounded-xl border border-default px-4 py-8 text-center text-sm text-muted">
|
||||
{{ t('admin.shippingProcessGates.empty') }}
|
||||
</p>
|
||||
<button
|
||||
v-for="row in rows"
|
||||
:key="row.execution_no"
|
||||
type="button"
|
||||
class="w-full rounded-lg border px-3 py-2.5 text-left text-sm transition-colors"
|
||||
:class="isExecutionSelected(row.execution_no)
|
||||
? 'border-brand-500 bg-brand-50/80 ring-1 ring-brand-500/40 dark:bg-brand-950/30'
|
||||
: 'border-default bg-surface hover:bg-surface-soft'"
|
||||
@click="openDetail(row.execution_no)"
|
||||
>
|
||||
<div class="font-mono text-xs break-all">{{ row.execution_no }}</div>
|
||||
<div class="mt-1.5 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs">
|
||||
<span>{{ statusLabel(row.status) }}</span>
|
||||
<span class="font-mono text-[11px] text-muted">{{ row.status }}</span>
|
||||
</div>
|
||||
<div class="mt-1 truncate font-mono text-[11px] text-muted">
|
||||
{{ row.current_gate_code || '—' }}
|
||||
</div>
|
||||
<div class="mt-1 truncate text-[11px] text-muted">{{ actionLabel(row.primary_next_action_code) }}</div>
|
||||
<div class="mt-1 text-[11px] text-muted">{{ formatTime(row.updated_at) }}</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2 text-sm">
|
||||
<button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page <= 1 || loading" @click="page -= 1; load()">
|
||||
{{ t('admin.shippingProcessGates.previous') }}
|
||||
</button>
|
||||
<span>{{ page }}</span>
|
||||
<button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page * pageSize >= total || loading" @click="page += 1; load()">
|
||||
{{ t('admin.shippingProcessGates.next') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2 text-sm">
|
||||
<button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page <= 1 || loading" @click="page -= 1; load()">
|
||||
{{ t('admin.shippingProcessGates.previous') }}
|
||||
</button>
|
||||
<span>{{ page }}</span>
|
||||
<button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page * pageSize >= total || loading" @click="page += 1; load()">
|
||||
{{ t('admin.shippingProcessGates.next') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<aside
|
||||
v-if="detail"
|
||||
class="rounded-xl border border-default bg-surface p-4"
|
||||
data-testid="shipping-process-gate-detail"
|
||||
>
|
||||
<aside
|
||||
v-if="detail"
|
||||
class="rounded-xl border border-default bg-surface p-4 lg:sticky lg:top-24 lg:max-h-[calc(100vh-8rem)] lg:overflow-y-auto"
|
||||
data-testid="shipping-process-gate-detail"
|
||||
>
|
||||
<div class="mb-4 flex items-center justify-between gap-2">
|
||||
<h2 class="text-lg font-semibold">{{ t('admin.shippingProcessGates.detailTitle') }}</h2>
|
||||
<button type="button" class="text-sm text-muted hover:text-primary" @click="closeDetail">{{ t('admin.close') }}</button>
|
||||
@@ -789,6 +790,7 @@ onMounted(() => {
|
||||
</div>
|
||||
<p v-else class="mt-2 text-sm text-muted">{{ t('admin.shippingProcessGates.noAttempts') }}</p>
|
||||
</template>
|
||||
</aside>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+4
@@ -33,6 +33,7 @@ describe('ProcessGateRecoveryCard', () => {
|
||||
},
|
||||
blocking_message: 'HTTP 500 error: node_id=abc',
|
||||
diagnostic_hint: 'traceback: C:\\service\\worker.py',
|
||||
responsible_party: 'owner',
|
||||
};
|
||||
const wrapper = mount(ProcessGateRecoveryCard, {
|
||||
props: { summary, canHandle: true },
|
||||
@@ -43,6 +44,9 @@ describe('ProcessGateRecoveryCard', () => {
|
||||
expect(text).toContain('当前步骤');
|
||||
expect(text).toContain('继续处理');
|
||||
expect(text).toContain('当前步骤需要人工处理');
|
||||
expect(text).toContain('责任方');
|
||||
expect(text).toContain('订单复核 / 任务负责人');
|
||||
expect(text).toContain('查看审计');
|
||||
for (const technicalText of [
|
||||
'auto_build_gate_quality_gate_passed', 'quality_gate_internal', 'internal_reason_code',
|
||||
'internal_retry_action', 'HTTP 500', 'node_id', 'traceback', 'worker.py',
|
||||
|
||||
+76
-5
@@ -1,15 +1,17 @@
|
||||
/**
|
||||
* features/shipping-process-gates/components/ProcessGateRecoveryCard.vue
|
||||
* 用途:任务工作台展示当前待处理环节与服务端下发的主要处理按钮。
|
||||
* 依赖:useShippingProcessGateRecovery、processGateNavigation、ShippingProcessGateUserSummary。
|
||||
* 用途:任务工作台展示当前待处理环节、责任方、主恢复动作与 Gate 审计入口。
|
||||
* 依赖:useShippingProcessGateRecovery、processGateNavigation、process-gates.api、
|
||||
* ShippingProcessGateUserSummary。
|
||||
* 逻辑:导航类动作 router.push;POST 类动作调 Workspace API;409 触发 refreshed;
|
||||
* canHandle=false 时只读;禁止展示内部编号、原因码和技术诊断文本。
|
||||
* 可展开查看审计事件;canHandle=false 时只读;禁止展示内部编号与技术诊断原文。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useShippingProcessGateRecovery } from '../composables/useShippingProcessGateRecovery';
|
||||
import type { ProcessGateNavigationContext } from '../composables/processGateNavigation';
|
||||
import { listWorkspaceProcessGateAuditEvents } from '../api/process-gates.api';
|
||||
import type { ShippingProcessGateUserSummary } from '../types/process-gate.types';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -26,6 +28,10 @@ const emit = defineEmits<{
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const { busy, submitPrimaryAction } = useShippingProcessGateRecovery();
|
||||
const auditOpen = ref(false);
|
||||
const auditLoading = ref(false);
|
||||
const auditError = ref('');
|
||||
const auditItems = ref<Array<Record<string, unknown>>>([]);
|
||||
|
||||
const blockingGate = computed(() => props.summary?.current_blocking_gate || null);
|
||||
const nextActionCode = computed(() =>
|
||||
@@ -76,6 +82,16 @@ const blockingReasonLabel = computed(() => {
|
||||
|
||||
const diagnosticHint = computed(() => safeBusinessText(props.summary?.diagnostic_hint));
|
||||
|
||||
/**
|
||||
* 责任方业务标签(owner/worker/system/admin/external)。
|
||||
*/
|
||||
const responsiblePartyLabel = computed(() => {
|
||||
const code = String(props.summary?.responsible_party || '').trim();
|
||||
if (!code) return '';
|
||||
const key = `workspace.shippingNotice.processGate.parties.${code}`;
|
||||
return te(key) ? t(key) : code;
|
||||
});
|
||||
|
||||
/**
|
||||
* 触发恢复动作:导航 / POST;409 时通知父级刷新最新 Gate 投影。
|
||||
*/
|
||||
@@ -97,6 +113,35 @@ async function runPrimaryAction() {
|
||||
emit('refreshed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展开/收起 Gate 审计列表;首次展开时拉取 Workspace 审计 API。
|
||||
*/
|
||||
async function toggleAudit() {
|
||||
auditOpen.value = !auditOpen.value;
|
||||
if (!auditOpen.value || auditItems.value.length || !props.summary?.execution_no) return;
|
||||
auditLoading.value = true;
|
||||
auditError.value = '';
|
||||
try {
|
||||
const page = await listWorkspaceProcessGateAuditEvents(props.summary.execution_no, 1, 20);
|
||||
auditItems.value = Array.isArray(page.items) ? page.items as Array<Record<string, unknown>> : [];
|
||||
} catch {
|
||||
auditError.value = t('workspace.shippingNotice.processGate.auditLoadFailed');
|
||||
auditItems.value = [];
|
||||
} finally {
|
||||
auditLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化审计事件时间。
|
||||
*/
|
||||
function formatAuditTime(value: unknown): string {
|
||||
const text = String(value || '').trim();
|
||||
if (!text) return '—';
|
||||
const date = new Date(text);
|
||||
return Number.isNaN(date.getTime()) ? text : date.toLocaleString();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -116,13 +161,18 @@ async function runPrimaryAction() {
|
||||
<dt class="text-muted">{{ $t('workspace.shippingNotice.processGate.blockingMessage') }}</dt>
|
||||
<dd class="text-secondary">{{ blockingReasonLabel }}</dd>
|
||||
</div>
|
||||
<div v-if="responsiblePartyLabel">
|
||||
<dt class="text-muted">{{ $t('workspace.shippingNotice.processGate.responsibleParty') }}</dt>
|
||||
<dd class="text-secondary">{{ responsiblePartyLabel }}</dd>
|
||||
</div>
|
||||
<div v-if="diagnosticHint">
|
||||
<dt class="text-muted">{{ $t('workspace.shippingNotice.processGate.diagnosticHint') }}</dt>
|
||||
<dd class="text-secondary">{{ diagnosticHint }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div v-if="hasRecoveryAction" class="mt-3 flex flex-wrap items-center gap-2">
|
||||
<div class="mt-3 flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
v-if="hasRecoveryAction"
|
||||
type="button"
|
||||
class="rounded-xl bg-primary px-3 py-1.5 text-sm font-medium text-on-primary disabled:opacity-60"
|
||||
:disabled="!canHandle || busy"
|
||||
@@ -130,9 +180,30 @@ async function runPrimaryAction() {
|
||||
>
|
||||
{{ busy ? $t('workspace.shippingNotice.processGate.submitting') : actionLabel }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl border border-default bg-surface px-3 py-1.5 text-sm text-secondary hover:bg-surface-soft"
|
||||
data-testid="process-gate-view-audit"
|
||||
@click="toggleAudit"
|
||||
>
|
||||
{{ auditOpen
|
||||
? $t('workspace.shippingNotice.processGate.hideAudit')
|
||||
: $t('workspace.shippingNotice.processGate.viewAudit') }}
|
||||
</button>
|
||||
<span v-if="!canHandle" class="text-xs text-muted">
|
||||
{{ $t('workspace.shippingNotice.todo.adminViewOnlyShort') }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="auditOpen" class="mt-3 rounded-xl border border-default bg-surface px-3 py-2 text-xs">
|
||||
<p v-if="auditLoading" class="text-muted">{{ $t('workspace.shippingNotice.processGate.auditLoading') }}</p>
|
||||
<p v-else-if="auditError" class="text-rose-600">{{ auditError }}</p>
|
||||
<p v-else-if="!auditItems.length" class="text-muted">{{ $t('workspace.shippingNotice.processGate.auditEmpty') }}</p>
|
||||
<ul v-else class="space-y-2">
|
||||
<li v-for="(item, index) in auditItems" :key="String(item.id || index)" class="border-t border-default pt-2 first:border-t-0 first:pt-0">
|
||||
<div class="font-medium text-secondary">{{ item.event_type || item.action || '—' }}</div>
|
||||
<div class="text-muted">{{ formatAuditTime(item.created_at) }}</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -192,6 +192,19 @@
|
||||
"blockingMessage": "What needs attention",
|
||||
"reasonCode": "Reason",
|
||||
"diagnosticHint": "Suggested action",
|
||||
"responsibleParty": "Responsible party",
|
||||
"viewAudit": "View audit",
|
||||
"hideAudit": "Hide audit",
|
||||
"auditLoading": "Loading audit…",
|
||||
"auditEmpty": "No process-gate audit events",
|
||||
"auditLoadFailed": "Failed to load process-gate audit",
|
||||
"parties": {
|
||||
"owner": "Order reviewer / task owner",
|
||||
"worker": "System worker",
|
||||
"system": "System automation",
|
||||
"admin": "Administrator",
|
||||
"external": "External system"
|
||||
},
|
||||
"noAction": "No action is currently available",
|
||||
"versionMissing": "This information has changed. Refresh and try again.",
|
||||
"navigationMissing": "Navigation context is missing. Refresh and try again.",
|
||||
|
||||
@@ -133,6 +133,19 @@
|
||||
"blockingMessage": "เหตุผลที่ต้องดำเนินการ",
|
||||
"reasonCode": "เหตุผล",
|
||||
"diagnosticHint": "คำแนะนำในการดำเนินการ",
|
||||
"responsibleParty": "ผู้รับผิดชอบ",
|
||||
"viewAudit": "ดูบันทึกตรวจสอบ",
|
||||
"hideAudit": "ซ่อนบันทึกตรวจสอบ",
|
||||
"auditLoading": "กำลังโหลดบันทึกตรวจสอบ…",
|
||||
"auditEmpty": "ยังไม่มีเหตุการณ์ตรวจสอบของเกต",
|
||||
"auditLoadFailed": "โหลดบันทึกตรวจสอบของเกตไม่สำเร็จ",
|
||||
"parties": {
|
||||
"owner": "ผู้ตรวจทานคำสั่งซื้อ / เจ้าของงาน",
|
||||
"worker": "ระบบ Worker",
|
||||
"system": "ระบบอัตโนมัติ",
|
||||
"admin": "ผู้ดูแลระบบ",
|
||||
"external": "ระบบภายนอก"
|
||||
},
|
||||
"noAction": "ขณะนี้ไม่มีการดำเนินการที่ใช้ได้",
|
||||
"versionMissing": "ข้อมูลนี้มีการเปลี่ยนแปลง โปรดรีเฟรชแล้วลองใหม่",
|
||||
"navigationMissing": "ไม่มีข้อมูลสำหรับนำทาง โปรดรีเฟรชแล้วลองใหม่",
|
||||
|
||||
@@ -193,6 +193,19 @@
|
||||
"blockingMessage": "需要处理的原因",
|
||||
"reasonCode": "处理原因",
|
||||
"diagnosticHint": "处理建议",
|
||||
"responsibleParty": "责任方",
|
||||
"viewAudit": "查看审计",
|
||||
"hideAudit": "收起审计",
|
||||
"auditLoading": "正在加载审计…",
|
||||
"auditEmpty": "暂无门禁审计事件",
|
||||
"auditLoadFailed": "加载门禁审计失败",
|
||||
"parties": {
|
||||
"owner": "订单复核 / 任务负责人",
|
||||
"worker": "系统 Worker",
|
||||
"system": "系统自动",
|
||||
"admin": "管理员",
|
||||
"external": "外部系统"
|
||||
},
|
||||
"noAction": "当前没有可执行的处理操作",
|
||||
"versionMissing": "当前信息已更新,请刷新后重试",
|
||||
"navigationMissing": "缺少跳转所需的任务或复核信息,请刷新后重试",
|
||||
|
||||
@@ -193,6 +193,19 @@
|
||||
"blockingMessage": "需要處理的原因",
|
||||
"reasonCode": "處理原因",
|
||||
"diagnosticHint": "處理建議",
|
||||
"responsibleParty": "責任方",
|
||||
"viewAudit": "檢視審計",
|
||||
"hideAudit": "收起審計",
|
||||
"auditLoading": "正在載入審計…",
|
||||
"auditEmpty": "暫無門禁審計事件",
|
||||
"auditLoadFailed": "載入門禁審計失敗",
|
||||
"parties": {
|
||||
"owner": "訂單覆核 / 任務負責人",
|
||||
"worker": "系統 Worker",
|
||||
"system": "系統自動",
|
||||
"admin": "管理員",
|
||||
"external": "外部系統"
|
||||
},
|
||||
"noAction": "目前沒有可執行的處理操作",
|
||||
"versionMissing": "目前資訊已更新,請重新整理後再試",
|
||||
"navigationMissing": "缺少跳轉所需的任務或覆核資訊,請重新整理後再試",
|
||||
|
||||
@@ -98,5 +98,41 @@ if [[ "${handler_check}" != "ok" ]]; then
|
||||
fi
|
||||
echo "Process Gate job handler OK."
|
||||
|
||||
# [STEP] 真实领取:入队探针 Job,等待 shipping-worker 将其推进到终态。
|
||||
probe_check=$("${DC_CMD[@]}" "${compose_args[@]}" exec -T hxops-backend \
|
||||
python - <<'PY' 2>/dev/null || true
|
||||
import time
|
||||
from app import create_app, db
|
||||
from app.models import Job
|
||||
from app.services.shipping_notice.process_gate_job_service import enqueue_process_gate_healthcheck_probe
|
||||
|
||||
app = create_app()
|
||||
with app.app_context():
|
||||
job_id = enqueue_process_gate_healthcheck_probe()
|
||||
deadline = time.time() + 45
|
||||
while time.time() < deadline:
|
||||
db.session.expire_all()
|
||||
job = db.session.get(Job, int(job_id))
|
||||
if job is None:
|
||||
print('missing_job')
|
||||
raise SystemExit(0)
|
||||
status = str(job.status or '')
|
||||
if status in {'succeeded', 'failed', 'cancelled'}:
|
||||
print('ok:' + status)
|
||||
raise SystemExit(0)
|
||||
if status == 'running':
|
||||
# 已被 Worker 领取即视为通过(终态可能稍晚)。
|
||||
print('ok:running')
|
||||
raise SystemExit(0)
|
||||
time.sleep(1.5)
|
||||
print('timeout:queued')
|
||||
PY
|
||||
)
|
||||
if [[ "${probe_check}" != ok:* ]]; then
|
||||
echo "Healthcheck failed: Process Gate worker did not claim probe job (${probe_check:-empty})"
|
||||
exit 1
|
||||
fi
|
||||
echo "Process Gate worker claim probe OK (${probe_check})."
|
||||
|
||||
echo "Healthcheck passed for ${ENV_NAME} environment."
|
||||
exit 0
|
||||
Reference in new issue
Block a user