feat(shipping-notice): 收敛阶段能力投影并修复库存 RPA 运行链路

下发 preparation capabilities 并与右卡展示同源授权;
库存 RPA 运行态请求内 memo;取消会话 Profile 本地 TTL;
并为 shipping-worker 挂载共享盘。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-09-07 14:46:48 +08:00
1 parent f773237226
commit a6edc4fe61
16 files changed
+433 -179

No files matched your search

@@ -1471,6 +1471,71 @@ describe('ShippingOrderReviewView layout phase 1', () => {
expect(wrapper.get('[data-testid="review-current-task-status"]').text()).not.toContain('自动处理失败');
});
it('submits retry_inventory_preparation from A even when B.actions lacks the code', async () => {
// 回归:右卡只读 A.primary_action 展示「重新获取库存(RPA)」;若仍按 B.actions
// 授权,会落到「未识别的动作」。A 展示即写路径授权;capabilities 可作 bypass。
activeCase.value = {
...activeCase.value,
status: 'confirmed', has_formal_ot: true, task_missing: false,
confirmed_task_id: 905, confirmed_task_no: 'SN-RPA-A-ONLY',
};
shippingProcessingProjection.value = {
workItemType: 'order_task', workItemNo: 'SN-RPA-A-ONLY',
status: 'failed', userStatus: 'retryable', stage: 'inventory_fetching',
progressVersion: 3, currentGate: { status: 'blocked_retryable' },
uiState: {
status: 'retryable', stage: 'inventory_fetching', lifecycleStage: 'fulfillment_prep',
primary_action: { code: 'retry_inventory_preparation' },
secondary_actions: [],
},
} as any;
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-RPA-A-ONLY', status: 'processing', lines: [], events: [],
ui_state: {
// B.actions 故意为空:模拟展示单源收敛后 B 滞后 / 无同码。
actions: { primary: null, secondary: [] },
process_gate: {
execution_no: 'EXEC-RPA-A-ONLY',
current_blocking_gate: {
gate_code: 'inventory_preparation', evaluation_version: 2, status: 'blocked_retryable',
},
allowed_actions: ['retry_inventory_preparation'],
recovery_targets: [{ action_code: 'retry_inventory_preparation' }],
},
stage_context: {
preparation: {
status: 'blocked', source_locked: false, source_options: [{ source_code: 'DSV' }],
capabilities: [{
code: 'retry_inventory_preparation', scope: 'task',
action_code: 'retry_inventory_preparation', enabled: true,
}],
frozen_order_lines: [], lines: [],
},
},
summary: {}, steps: [],
},
} as any);
submitProcessGatePrimaryActionMock.mockClear();
messageMocks.info.mockClear();
const wrapper = await mountView({ lifecycle_stage: 'fulfillment_prep' });
await flushPromises();
await wrapper.get('[data-testid="review-current-processing-retry"]').trigger('click');
await flushPromises();
expect(messageMocks.info).not.toHaveBeenCalledWith(
expect.stringMatching(/未识别的动作|Unrecognized action/),
);
expect(submitProcessGatePrimaryActionMock).toHaveBeenCalledWith(
expect.any(Object),
expect.objectContaining({
actionCode: 'retry_inventory_preparation',
stageCapabilityBypass: true,
}),
);
});
it('refreshes the processing projection after field-conflict adjudication refreshes the Case', async () => {
activeCase.value = {
...activeCase.value,
@@ -1829,16 +1829,26 @@ async function handleCurrentTaskAction(
) {
const params = (parameters || {}) as Record<string, unknown>;
const normalizedCode = String(code || '').trim();
// [AUTHORITY] 正式 OT 的所有可写动作都从任务详情的 ui_state.actions 原样委托。
// 缺少同码的正式动作即不执行,不能降级到历史 Projection 或 Case 快照。
// [AUTHORITY] 正式 OT:右卡按钮只读 A(shippingProcessingProjection.ui_state),
// 点击必须与展示同源授权;capabilities 供 stageCapabilityBypass,B.actions
// 仅作兼容回退。禁止「A 已展示、B 无同码」时落到 actionUnknown。
if (hasFormalOt.value) {
// [STAGE_CAPABILITY] 阶段能力(重抓/重读/改源)从右侧卡点击时,走 submitFormalGateAction
// 的能力分支——绕过门禁 gate-membership 守卫并直达后端 request_gate_action。
if (!(await ensureFormalTaskDetailReady())) return;
// [STAGE_CAPABILITY] 命中能力(含 disabled)走 submitFormalGateAction,
// 由能力分支展示 disabled_reason 或 stageCapabilityBypass 提交。
const capability = formalPreparationContext.value?.capabilities?.find(
(cap) => cap.enabled && String(cap.action_code || '').trim() === normalizedCode,
(cap) => String(cap.action_code || '').trim() === normalizedCode,
);
if (capability) {
if (!(await ensureFormalTaskDetailReady())) return;
await submitFormalGateAction(normalizedCode);
return;
}
// [§2.4 单源] A 已下发的主/侧路动作与展示同源,直接提交 Gate,不要求 B.actions。
const aPrimary = String(currentTaskUiState.value?.primary_action?.code || '').trim();
const aSecondaryHit = (currentTaskUiState.value?.secondary_actions || []).some(
(action) => action.enabled && String(action.code || '').trim() === normalizedCode,
);
if (normalizedCode && (normalizedCode === aPrimary || aSecondaryHit)) {
await submitFormalGateAction(normalizedCode);
return;
}
@@ -1849,7 +1859,6 @@ async function handleCurrentTaskAction(
msg.info(t('chat.shippingOrderReview.currentTask.actionUnknown', { code: normalizedCode }));
return;
}
if (!(await ensureFormalTaskDetailReady())) return;
await executeFormalTaskAction(formalAction, params);
return;
}
@@ -3548,8 +3557,16 @@ const submitFormalGateAction = async (
const authorized = formalTaskActions.value.some((action) => (
action.enabled && String(action.code || '').trim() === normalizedCode
));
// [§2.4 单源] A 已展示的主/侧路动作与右卡同源,允许作为写路径授权(B.actions 可能滞后)。
const aPrimary = String(currentTaskUiState.value?.primary_action?.code || '').trim();
const aAuthorized = Boolean(normalizedCode) && (
normalizedCode === aPrimary
|| (currentTaskUiState.value?.secondary_actions || []).some(
(action) => action.enabled && String(action.code || '').trim() === normalizedCode,
)
);
// [STEP] 阶段能力分支:capability 命中优先按 enabled/disabled_reason 裁决,
// 仅在未命中能力时回退到通用 Gate noAction 校验(Task 5)。
// 仅在未命中能力时回退到 A 展示授权或 B.actions / Gate noAction 校验。
const capability = formalPreparationContext.value?.capabilities?.find(
(c) => String(c.action_code || '') === normalizedCode,
);
@@ -3560,7 +3577,7 @@ const submitFormalGateAction = async (
: t('workspace.shippingNotice.processGate.noAction'));
return;
}
} else if (!normalizedCode || !gate || !authorized) {
} else if (!normalizedCode || !gate || !(authorized || aAuthorized)) {
msg.info(t('workspace.shippingNotice.processGate.noAction'));
return;
}