Archived
fix(ops): 实例时间线第 9 步的结果跟第 8 步走 —— 已放行的单不再永远停在 pending
放行那一步(T_release,人工激活)**没有自己的收步事件** —— 人签字后 `submit` 直接把整单落终态, 计划项本身从没被 finish 过。于是一单已 `released` 的详情里第 9 步永远是 `pending`, 而它前面拟落账那一步早就 `done`:同一张单上两句话互相打脸。 `followRes` 纯函数在服务端交出详情之前把第 9 步的 `res` 与 `at` 跟上第 8 步(2026-08-28 用户定,`at` 也跟); **用时不编** —— 那一步没有自己的起止痕;两步有一步不在(别的活动步数不同)就什么都不动。 《API文档-活动模块》§ 时间线补一行口径。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0167qWjeyBwvfdGovd7FWbCu
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { parseCmmn } from '@modules/loop-engine';
|
||||
import type { ItemRuntime } from '@modules/loop-engine';
|
||||
import { stepsOf } from '../activity-ops/instance-steps.ts';
|
||||
import { followRes, stepsOf } from '../activity-ops/instance-steps.ts';
|
||||
|
||||
const XML = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<definitions xmlns="http://www.omg.org/spec/CMMN/20151109/MODEL" id="d">
|
||||
@@ -84,3 +84,18 @@ describe('stepsOf', () => {
|
||||
expect(steps[1]?.res).toBe('current');
|
||||
});
|
||||
});
|
||||
|
||||
describe('followRes:第 9 步跟第 8 步(放行那一步没有自己的收步事件)', () => {
|
||||
const step = (seq: number, res: 'done' | 'current' | 'pending' | 'fail') => ({ seq, name: `S${seq}`, by: 'agent' as const, byName: 'llm', at: null, durationMs: null, res, note: '' });
|
||||
it('已放行的单:第 8 步 done → 第 9 步也 done、时刻跟第 8 步;别的字段不动', () => {
|
||||
const steps = [...Array.from({ length: 7 }, (_, i) => step(i + 1, 'done')), { ...step(8, 'done'), at: '2026-08-27T14:30:26.080Z' }, { ...step(9, 'pending'), by: 'human' as const, byName: '柴浩' }];
|
||||
const out = followRes(steps, { seq: 9, from: 8 });
|
||||
expect(out[8]).toEqual({ ...step(9, 'done'), at: '2026-08-27T14:30:26.080Z', by: 'human', byName: '柴浩' });
|
||||
expect(out.slice(0, 8)).toEqual(steps.slice(0, 8));
|
||||
});
|
||||
it('第 8 步 fail / pending 时第 9 步照样跟;步数不够 9 的活动什么都不动', () => {
|
||||
expect(followRes([step(1, 'done'), ...Array.from({ length: 7 }, (_, i) => step(i + 2, 'pending')), step(9, 'pending')].map((s) => (s.seq === 8 ? { ...s, res: 'fail' as const } : s)), { seq: 9, from: 8 })[8]?.res).toBe('fail');
|
||||
const seven = Array.from({ length: 7 }, (_, i) => step(i + 1, 'done'));
|
||||
expect(followRes(seven, { seq: 9, from: 8 })).toEqual(seven);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user