@suifei/dsh-ai-team 0.4.91 → 0.4.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.92 - 2026-11-14
4
+
5
+ **会议并发回帖不再被拒:迟到的回帖照收,并把错过的发言带回去;PMO 叫不醒就不开会**
6
+
7
+ 会议/复盘时多名成员读同一个 Thread head 后同时回帖,旧规则(`baseSeq` 必须等于 head,否则
8
+ `E_STALE_REPLY`)只放行第一条,其余重读、重写、再次落败——成员原话「三次回帖均因会议并发被拒」,
9
+ r09 一轮 46 次,失败计数全部来自这里。回帖本身没有错,只是晚了。
10
+
11
+ - `lib/domain/thread.js` `appendReply`:不再拒绝落后的 `baseSeq`,条目照记自己的 `baseSeq`,并返回
12
+ `missed`(读取之后新增的条目);超前的 `baseSeq` 仍是 `E_INVALID_ARGUMENT`。`E_STALE_REPLY` 错误码移除;
13
+ - `lib/host/member-tools.js` `reply`:有错过的他人发言时返回 `missed`(正文截 2000 字)与提示「只有它们
14
+ 改变了你的结论才再补一条」;自己的旧帖不算错过;
15
+ - PMO 叫不醒就不开会(`lib/host/waker.js` `pmo/continue`):r13 中 PMO 因 AUTH 失败,定时推进仍把其余 5 名
16
+ 成员拉进会议,无人主持、无人收口。现在 owner 不可唤醒(failed / retired / 缺失)时整场会议不规划;
17
+ - 测试:`node --test` **331 通过 / 1 跳过**;`waker` 新增无主持会议 1 条,`domain` 改写 1 条,新增 `thread-meeting`(三人并发全部落帖、
18
+ 迟到者拿到错过的两条)。
19
+ - E2E(隔离 DSH_HOME,项目「排序-B」派一种排序,12 分钟):线程 7 条回帖中 2 条迟到(seq 4 基于 2、seq 5
20
+ 基于 3)全部落帖,`E_STALE_REPLY` 0、`dispatch.fail` 0(旧规则下这 2 条会被拒并重写)。
21
+
3
22
  ## 0.4.91 - 2026-11-14
4
23
 
5
24
  **停止即中断成员回合;重启不再惊动已静默的团队;已绑定的 PMO 会话启动即归入工作区**
@@ -24,7 +24,6 @@ export const ERRORS = {
24
24
  BLOCKED: 'E_TASK_BLOCKED',
25
25
  NOT_READY: 'E_TASK_NOT_READY',
26
26
  NOT_ELIGIBLE: 'E_REVIEWER_NOT_ELIGIBLE',
27
- STALE_REPLY: 'E_STALE_REPLY',
28
27
  LIMIT: 'E_LIMIT',
29
28
  IRREVERSIBLE_CONFIRM: 'E_IRREVERSIBLE_CONFIRM_REQUIRED',
30
29
  INVALID_ARGUMENT: 'E_INVALID_ARGUMENT',
@@ -1,54 +1,46 @@
1
- import { ERRORS, fail } from './errors.js';
2
-
3
- /** A thread is one append-only conversation attached to a Task. */
4
- export function createThread(taskId) {
5
- return { taskId, headSeq: 0, entries: [] };
6
- }
7
-
8
- /**
9
- * Append a reply. Agents must reply against the current head; a stale baseSeq
10
- * is rejected with the entries that changed since the reader last looked.
11
- * Human replies bypass the check (the Human sees the live thread).
12
- */
13
- export function appendReply(thread, input, options = {}) {
14
- const body = typeof input.body === 'string' ? input.body.trim() : '';
15
- if (body === '') fail(ERRORS.INVALID_ARGUMENT, 'reply body is required');
16
- if (body.length > 16_384) fail(ERRORS.INVALID_ARGUMENT, 'reply body is too long');
17
- if (typeof input.authorId !== 'string' || input.authorId === '') fail(ERRORS.INVALID_ARGUMENT, 'authorId is required');
18
- const baseSeq = input.baseSeq ?? 0;
19
- if (!Number.isSafeInteger(baseSeq) || baseSeq < 0) fail(ERRORS.INVALID_ARGUMENT, 'baseSeq must be a non-negative integer');
20
- if (baseSeq > thread.headSeq) fail(ERRORS.INVALID_ARGUMENT, 'baseSeq is ahead of the thread head');
21
- if (input.actorKind !== 'human' && baseSeq !== thread.headSeq) {
22
- const changed = thread.entries.filter((entry) => entry.seq > baseSeq);
23
- fail(ERRORS.STALE_REPLY, 'thread changed since you read it; re-read before replying', {
24
- details: {
25
- taskId: thread.taskId,
26
- baseSeq,
27
- headSeq: thread.headSeq,
28
- changes: changed.map((entry) => ({
29
- seq: entry.seq,
30
- authorId: entry.authorId,
31
- at: entry.at,
32
- excerpt: entry.body.slice(0, 200),
33
- })),
34
- },
35
- });
36
- }
37
- const entry = {
38
- seq: thread.headSeq + 1,
39
- authorId: input.authorId,
40
- baseSeq,
41
- body,
42
- at: options.at ?? Date.now(),
43
- refs: [...(input.refs ?? [])],
44
- };
45
- return {
46
- thread: { ...thread, headSeq: entry.seq, entries: [...thread.entries, entry] },
47
- entry,
48
- };
49
- }
50
-
51
- /** Entries after `baseSeq`, used by the stale-reply error and the UI diff. */
52
- export function entriesSince(thread, baseSeq) {
53
- return thread.entries.filter((entry) => entry.seq > baseSeq);
54
- }
1
+ import { ERRORS, fail } from './errors.js';
2
+
3
+ /** A thread is one append-only conversation attached to a Task. */
4
+ export function createThread(taskId) {
5
+ return { taskId, headSeq: 0, entries: [] };
6
+ }
7
+
8
+ /**
9
+ * Append a reply. `baseSeq` is the head the author read; it is recorded on the
10
+ * entry, and every entry that landed after it comes back as `missed`, so the
11
+ * author learns what it did not see and can follow up if that changes its view.
12
+ *
13
+ * A stale `baseSeq` used to be rejected (E_STALE_REPLY). In a meeting five
14
+ * members read the same head and answer at once: only the first got through,
15
+ * the rest re-read, re-wrote and lost again ("三次回帖均因会议并发被拒";
16
+ * r09: 46 rejections in one round). The reply itself was never wrong — only
17
+ * late — so it is accepted and the gap is reported instead.
18
+ */
19
+ export function appendReply(thread, input, options = {}) {
20
+ const body = typeof input.body === 'string' ? input.body.trim() : '';
21
+ if (body === '') fail(ERRORS.INVALID_ARGUMENT, 'reply body is required');
22
+ if (body.length > 16_384) fail(ERRORS.INVALID_ARGUMENT, 'reply body is too long');
23
+ if (typeof input.authorId !== 'string' || input.authorId === '') fail(ERRORS.INVALID_ARGUMENT, 'authorId is required');
24
+ const baseSeq = input.baseSeq ?? 0;
25
+ if (!Number.isSafeInteger(baseSeq) || baseSeq < 0) fail(ERRORS.INVALID_ARGUMENT, 'baseSeq must be a non-negative integer');
26
+ if (baseSeq > thread.headSeq) fail(ERRORS.INVALID_ARGUMENT, 'baseSeq is ahead of the thread head');
27
+ const missed = entriesSince(thread, baseSeq);
28
+ const entry = {
29
+ seq: thread.headSeq + 1,
30
+ authorId: input.authorId,
31
+ baseSeq,
32
+ body,
33
+ at: options.at ?? Date.now(),
34
+ refs: [...(input.refs ?? [])],
35
+ };
36
+ return {
37
+ thread: { ...thread, headSeq: entry.seq, entries: [...thread.entries, entry] },
38
+ entry,
39
+ missed,
40
+ };
41
+ }
42
+
43
+ /** Entries after `baseSeq`, reported as `missed` on a late reply and used by the UI diff. */
44
+ export function entriesSince(thread, baseSeq) {
45
+ return thread.entries.filter((entry) => entry.seq > baseSeq);
46
+ }
@@ -3,8 +3,9 @@
3
3
  * once the AI Team runtime booted (see index.js `when`); the tool itself still
4
4
  * refuses any session that is not a live Team member (`E_NOT_MEMBER`).
5
5
  *
6
- * Mutations require `expectedRevision` (Task CAS) and `baseSeq` (Thread stale
7
- * reply protection); errors are returned as data so the member can re-read.
6
+ * Task mutations require `expectedRevision` (CAS). A reply carries `baseSeq`
7
+ * (the head it was written against); a late reply is accepted and the entries it
8
+ * missed come back in the result. Errors are returned as data so the member can re-read.
8
9
  */
9
10
  import { taskCard } from './views.js';
10
11
  import { isQaMember } from '../domain/member-profile.js';
@@ -62,7 +63,7 @@ export function createTeamTool(options) {
62
63
  action: { type: 'string', enum: ACTIONS, description: 'Operation to perform.' },
63
64
  taskId: { type: 'string', description: 'Task id from tasks.' },
64
65
  expectedRevision: { type: 'integer', description: 'Task revision from tasks/claim; required for claim/submit/accept/requestChanges.' },
65
- baseSeq: { type: 'integer', description: 'Thread headSeq read before replying; required for reply.' },
66
+ baseSeq: { type: 'integer', description: 'Thread headSeq read before replying; required for reply. A late reply is still posted and returns the entries you missed.' },
66
67
  afterSeq: { type: 'integer', description: 'Return Thread entries after this seq.' },
67
68
  summary: { type: 'string', description: 'What was done, for submit.' },
68
69
  evidence: { type: 'array', items: { type: 'string' }, description: 'Evidence strings/paths, at least one for submit.' },
@@ -297,7 +298,18 @@ export function createTeamTool(options) {
297
298
  if (!Number.isSafeInteger(args.baseSeq)) return failure({ code: 'E_INVALID_ARGUMENT', message: 'baseSeq is required; read thread first' });
298
299
  if (typeof args.body !== 'string' || args.body.trim() === '') return failure({ code: 'E_INVALID_ARGUMENT', message: 'body is required' });
299
300
  const result = await command('thread.post', { taskId: args.taskId, baseSeq: args.baseSeq, body: args.body });
300
- return { ok: true, taskId: args.taskId, headSeq: result.thread.headSeq, entry: result.entry };
301
+ const missed = (result.missed ?? []).filter((entry) => entry.authorId !== member.id);
302
+ if (missed.length === 0) return { ok: true, taskId: args.taskId, headSeq: result.thread.headSeq, entry: result.entry };
303
+ // 迟到的回帖照收(会议里并发是常态),把读取之后新增的发言带回去:
304
+ // 只有它们改变了你的结论才再补一条,不要为了「对齐」重复发言。
305
+ return {
306
+ ok: true,
307
+ taskId: args.taskId,
308
+ headSeq: result.thread.headSeq,
309
+ entry: result.entry,
310
+ missed: missed.map((entry) => ({ seq: entry.seq, authorId: entry.authorId, body: entry.body.slice(0, 2000) })),
311
+ note: `posted; ${missed.length} repl${missed.length === 1 ? 'y' : 'ies'} landed after you read the thread (shown in missed). Reply again only if they change your answer.`,
312
+ };
301
313
  }
302
314
  if (args.action === 'say') {
303
315
  // 核心模型:只有项目 PMO 面向 Human 说话(主对话);成员在各自 Task Thread 里协作。
@@ -1380,7 +1380,7 @@ export class TeamService {
1380
1380
  projectId: command.projectId,
1381
1381
  at: this.now(),
1382
1382
  });
1383
- return { thread: this.state.threads?.[taskId] ?? outcome.thread, entry: outcome.entry };
1383
+ return { thread: this.state.threads?.[taskId] ?? outcome.thread, entry: outcome.entry, missed: outcome.missed };
1384
1384
  });
1385
1385
  }
1386
1386
 
package/lib/host/waker.js CHANGED
@@ -286,8 +286,11 @@ export function planWakes(state, result, actor = {}, options = {}) {
286
286
  const bucket = event.payload?.bucket ?? Math.floor(Date.now() / 600_000);
287
287
  const ownerId = project?.ownerMemberId;
288
288
  // PMO meetings include every agent member; the owner leads, everyone
289
- // else contributes from their own professional seat.
290
- for (const member of Object.values(state.members ?? {})) {
289
+ // else contributes from their own professional seat. No wakeable owner,
290
+ // no meeting: r13 convened five members around a failed PMO (AUTH) —
291
+ // a headless meeting that nobody chairs or closes.
292
+ const members = agentMember(state, ownerId) === null ? [] : Object.values(state.members ?? {});
293
+ for (const member of members) {
291
294
  if (member.kind !== 'agent' || member.status === 'retired') continue;
292
295
  if (member.id === ownerId) {
293
296
  add(member.id, null, 'pmo_continue', `pmo:${project?.id ?? 'project'}:${bucket}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.4.91",
3
+ "version": "0.4.92",
4
4
  "type": "module",
5
5
  "description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
6
6
  "license": "MIT",