@suifei/dsh-ai-team 0.4.24 → 0.4.27

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,43 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.27 - 2026-11-12
4
+
5
+ **审计 LOW 收尾(195/195)**
6
+
7
+ - **诊断可区分**:成员输出探针成功行改名 `member.output.probe`(此前与异常共用 `.fail`,errors 级无法区分);`request-error` 链三处 catch 补 `*.fail` 诊断(失败记录/换路/恢复)。
8
+ - **判别正确性**:`classifyLlmFailure` 把 429 判定提到 billing 之前(带 quota 字样的限流不再被当成致命计费错误);`scoreSkillRubric` 拒绝 `NaN` dim8;`formatRubric` 的 weakest 排除 dim8,与 `weakestDimension` 同口径。
9
+ - **技能目录**:`formatSkillCatalog` 过滤 `modelInvocable === false`(禁止模型调用的技能不再进成员 prompt);`skillProvider.get()` 读取失败返回 `undefined` 而不是抛错打断回合;disposer 兼容函数/control 两种形状并调用 `invalidate`。
10
+ - **账本**:`_scan` 检测重复事件 id 并以 `E_LEDGER_CORRUPT`(`duplicate-id`)拒绝载入。
11
+ - **命令层**:`bootstrap` 对未知 `projectId` 报 `E_NOT_FOUND`(与 board/quadrants 同口径);`decision.answer` 要求答案覆盖全部问题(未知/缺失均 `E_INVALID_ARGUMENT`)。
12
+ - **生命周期**:`roots()` 优先挑真正的 Human 根会话(无 `parentSession`、非 subagent);`member.retire`/`member.leave` 成功后释放常驻 activation 句柄;损坏 job 文件保留并告警。
13
+ - 测试:`node --test` **195/195**(+2:`resilience` 的 429/quota 回归、`service` 的 bootstrap+决策完整性)。
14
+
15
+ ## 0.4.26 - 2026-11-12
16
+
17
+ **审计后续:MEDIUM/LOW 三批清理(193/193)**
18
+
19
+ - **账本写入安全**:`_rollback` 本身失败时置 `E_LEDGER_POISONED`(要求 close+open),不再让 `fd=null` 的句柄继续接单;段号改为按**磁盘最大段号 + 1**推导(旧实现会复用已存在段号 → 永久 `EEXIST`);空账本不再预创建段文件(否则空段被当尾段删掉,首段跳到 `000002`)。
20
+ - **命令层输入校验**:`member.add` 校验 id 类型/唯一性与 status 枚举;`member.config.update` 忽略请求里夹带的 `policy`(防止自行放宽白名单);`inbox.ack` 校验归属;`decision` 写入投影;`project.create` 校验工作目录存在并拒绝重复 id;`task.assign/reassign` 校验目标成员存在且未退役。
21
+ - **路径与作者身份**:`backfillHumanMentions` 只接受工作目录内的 `.md`(`resolve+relative` 包含性校验);`postStream` 按 actor 写 `kind`(agent 发言不再冒充 `human_message`)。
22
+ - **调度**:PMO tick 按 Project 去重(`pmoBusy` + `pmo.tick.skip`);`wakeKeys` 改为先判定工作目录再占键(跳过不再永久丢事件);`waker` 去重键追加成员与 Project 作用域;`task/created` 按 `payload.taskId` 回投影取任务。
23
+ - **SkillOpt 判别质量**:多数决要求有效票过半(3→2、5→3);`parseJudgeOutput` 逐个尝试平衡括号对象并取**最后**一个合法结论(模板回显不再丢票);rubric dim6 在无 `resourcePaths` 时按「未验证」给中性分;评审通道 job 补 30 分钟兜底 TTL。
24
+ - **视图与前端**:`q4Limit` 真正生效;周报不再把 PMO 自动决策算作 Human 介入;`findReportPath` 支持正斜杠与带空格/引号路径;`g` 前缀快捷键恢复;Thread 冲突检测改读 `headSeq` 并在发送后推进基线;`loadPending` 失败不再伪装成「没有待验收」;`loadRisks` 不再借用 people 的加载态;SSE 断流首次可见提示。
25
+ - 测试:`node --test` **193/193**(+9:`judge-parse` 5、`weekly-report-path` 2、`ledger` 2)。
26
+
27
+ ## 0.4.25 - 2026-11-12
28
+
29
+ **全量代码审计收口:17 条 HIGH 全部修复**
30
+
31
+ - **成员回合永久 `blocked` 的根因(R6)**:`archived-session-gate` 会沿 subagent 血缘上溯,而旧版为隐藏会话把 Team Host **归档**——所有成员都是它的子会话,于是每回合在发出模型请求前被拒(实测 453 blocked / 0 completed)。`lib/runtime/host-agent.js` 不再归档 host;新增 `lib/runtime/host-repair.js` 在 boot 与 `ensureParent` 时把 host 及成员 `parentSession` 解归档。
32
+ - **`team` 首回合不可见**:可见性原按「请求者是否已知成员」判定,而成员 `sessionId` 在 `activate()` 返回后才写入 → 首个 model step 恒缺 `team`(43→44 工具)。改为 `when: () => booted !== null`,非成员仍由工具自身 `E_NOT_MEMBER` 拒绝。
33
+ - **SkillOpt 越权面**:新增 `lib/skillopt/tool-access.js`——`run/adopt/schedule/unschedule/optimize/jobs/judge` 只允许 Team 成员或 Human 面对根会话,一次性子代理调用一律拒绝。
34
+ - **SkillOpt 落盘链**:`apply-candidate` 先落 job 再改 live;keep/revert 落盘前比对 sha(冲突则 `failed`)+ 备份 + `tmp+rename` 原子替换;`results.tsv` 增 `proposal_sha` 列,adopt 门的 keep 必须绑定本次候选。
35
+ - **评审票序**:每票带 `orderId`,按 id 归票、去重、票数 ≤ 请求数;乱序/重复回帖不再移位或反转 keep/revert。
36
+ - **waker**:`task/created` 按 `payload.taskId` 回投影取任务(原读不存在的 `payload.task`,该路径永不唤醒);去重键追加成员与 Project 作用域。
37
+ - **其他**:项目归档同步写 registry;冷唤醒只 resume 一次并由 resumed agent 投递(不再二次冷恢复导致 `NOT_RESUMABLE` 丢历史);自愈判据改用结构化错误码;`turn/end` 的 `blocked`/`error` 不再静默丢弃;`taskCard` 补 `submission`/`completedAt`/`acceptedBy`。
38
+ - 测试:`node --test` **180/180**(新增 `tool-access`、`host-repair`、`review-votes` 三套)。
39
+ - 审计报告:`docs/审计报告-2026-11-12-全量代码审计.md`。
40
+
3
41
  ## 0.3.90 - 2026-11-12
4
42
 
5
43
  **Darwin Phase 2 自动 hill-climbing 循环(`skillopt_optimize`)**
package/client.js CHANGED
@@ -84,6 +84,7 @@ window.__ModuleLoader__.load({
84
84
  groupLess: '收起其余 {n} 项',
85
85
  fromDiscussion: '由讨论升格',
86
86
  loading: '加载中…',
87
+ streamDown: '实时更新已中断,界面可能滞后;正在自动重连…',
87
88
  loadFailedTitle: '工作台不可达',
88
89
  loadFailedBody: 'bootstrap 接口(/ai-team)无法访问;请确认插件已启用后重试。',
89
90
  spike: 'AI Team',
@@ -495,6 +496,7 @@ window.__ModuleLoader__.load({
495
496
  loading: 'Loading…',
496
497
  loadFailedTitle: 'Workbench unreachable',
497
498
  loadFailedBody: 'The bootstrap endpoint (/ai-team) cannot be reached; confirm the plugin is enabled and retry.',
499
+ streamDown: 'Live updates stopped; the view may lag while the stream reconnects…',
498
500
  spike: 'AI Team',
499
501
  spikeTitle: 'Wenyuan Pavilion AI Team workbench: compile, collate, edit; direction, acceptance and ledger.',
500
502
  navAria: 'Page navigation',
@@ -2607,18 +2609,20 @@ window.__ModuleLoader__.load({
2607
2609
  }
2608
2610
  // R-09 待验收跨项目队列。
2609
2611
  const [pendingRows, setPendingRows] = React.useState(null);
2612
+ // 拉取失败与「确实没有待验收」必须可区分(旧实现把失败写成空数组)。
2613
+ const [pendingError, setPendingError] = React.useState('');
2610
2614
  function loadPending() {
2611
2615
  fetch('/ai-team/api/pending-acceptance', { headers: { accept: 'application/json' } })
2612
2616
  .then(async (response) => {
2613
2617
  const payload = await response.json().catch(() => null);
2614
2618
  if (!response.ok) throw new Error(payload?.error?.message ?? ('HTTP ' + response.status));
2615
2619
  setPendingRows(Array.isArray(payload?.rows) ? payload.rows : []);
2620
+ setPendingError('');
2616
2621
  })
2617
- .catch(() => setPendingRows([]));
2622
+ .catch((error) => setPendingError(error?.message ?? String(error)));
2618
2623
  }
2619
2624
  function loadRisks() {
2620
2625
  const seq = ++riskSeqRef.current;
2621
- setPeopleLoading(true);
2622
2626
  fetch('/ai-team/api/risks' + (projectId ? '?project=' + encodeURIComponent(projectId) : ''), { headers: { accept: 'application/json' } })
2623
2627
  .then(async (response) => {
2624
2628
  const payload = await response.json().catch(() => null);
@@ -2627,10 +2631,12 @@ window.__ModuleLoader__.load({
2627
2631
  setRisksData(payload?.risks ?? null);
2628
2632
  })
2629
2633
  .catch(() => { if (seq === riskSeqRef.current) setRisksData(null); })
2630
- .finally(() => { if (seq === riskSeqRef.current) setPeopleLoading(false); });
2634
+ .finally(() => { /* 风险区自带空态,不复用 people 的 loading */ });
2631
2635
  }
2632
2636
  // 最新 scope 镜像:SSE 回调在 effect 闭包里拿不到最新值。
2633
2637
  const scopeRef = React.useRef(scope);
2638
+ // SSE 断流一次性提示:只提示一次,恢复后重置。
2639
+ const streamDownRef = React.useRef(false);
2634
2640
  scopeRef.current = scope;
2635
2641
  const [nBusy, setNBusy] = React.useState(false);
2636
2642
  const [nError, setNError] = React.useState('');
@@ -2733,6 +2739,7 @@ window.__ModuleLoader__.load({
2733
2739
  if (source) {
2734
2740
  source.addEventListener('change', (raw) => {
2735
2741
  if (!alive) return;
2742
+ streamDownRef.current = false;
2736
2743
  try {
2737
2744
  const frame = JSON.parse(raw.data);
2738
2745
  pushToast(notificationText(frame?.event));
@@ -2745,9 +2752,14 @@ window.__ModuleLoader__.load({
2745
2752
  load();
2746
2753
  });
2747
2754
  source.addEventListener('error', () => {
2748
- // One-shot diagnostic: EventSource reconnects by itself; this row
2749
- // only makes the console explain why the panel may lag behind.
2750
- if (alive && dataRef.current === null) console.error(PKG + ': event stream unavailable (retrying)');
2755
+ // EventSource 自己会重连,但**必须让用户看见**:旧实现只在首屏
2756
+ // (dataRef===null)时打印,面板已有数据时断流完全静默。
2757
+ if (!alive) return;
2758
+ console.error(PKG + ': event stream unavailable (retrying)');
2759
+ if (!streamDownRef.current) {
2760
+ streamDownRef.current = true;
2761
+ say(t('streamDown'));
2762
+ }
2751
2763
  });
2752
2764
  }
2753
2765
  return () => {
@@ -2797,7 +2809,8 @@ window.__ModuleLoader__.load({
2797
2809
  React.useEffect(() => {
2798
2810
  const current = dataRef.current;
2799
2811
  const thread = threadFor(current, selected);
2800
- setReplyBase(thread?.baseSeq ?? null);
2812
+ // 宿主投影里没有 baseSeq:读 headSeq。否则 ConflictBanner 永不出现。
2813
+ setReplyBase(thread?.headSeq ?? null);
2801
2814
  setAcceptChecked(false);
2802
2815
  const nextTask = current?.tasks?.find((task) => task.id === selected) ?? current?.tasks?.[0];
2803
2816
  setQaChecks((nextTask?.qaChecklist ?? []).map((item) => ({ item, passed: false })));
@@ -2860,13 +2873,16 @@ window.__ModuleLoader__.load({
2860
2873
  setShortcutsOpen(true);
2861
2874
  return;
2862
2875
  }
2863
- if (event.key.toLowerCase() !== 'g') return;
2864
- if (Date.now() - gPrefixRef.current > 600) {
2876
+ // g 前缀:先按 g 记录时间戳并返回;下一个键才做分发。
2877
+ // 旧实现把这两个动作写在同一个 `key !== 'g'` 判断之后,
2878
+ // 导致 i/b/p/c 永远走不到(g 前缀导航整体失效)。
2879
+ const key = event.key.toLowerCase();
2880
+ if (key === 'g') {
2865
2881
  gPrefixRef.current = Date.now();
2866
2882
  return;
2867
2883
  }
2884
+ if (Date.now() - gPrefixRef.current > 600) return;
2868
2885
  gPrefixRef.current = 0;
2869
- const key = event.key.toLowerCase();
2870
2886
  if (key === 'i') { event.preventDefault(); switchInbox(); }
2871
2887
  else if (key === 'b') { event.preventDefault(); switchBoard(); }
2872
2888
  else if (key === 'p') { event.preventDefault(); openPeople(); }
@@ -3690,6 +3706,8 @@ window.__ModuleLoader__.load({
3690
3706
  body: text,
3691
3707
  });
3692
3708
  setReply('');
3709
+ // 发送成功后把基线推进到新 headSeq,避免自己的回复触发冲突横幅。
3710
+ setReplyBase(typeof result.entry?.seq === 'number' ? result.entry.seq : null);
3693
3711
  sayRight(tf(t, 'replySent', { seq: result.entry?.seq ?? '' }));
3694
3712
  await reloadData();
3695
3713
  } catch (error) {
@@ -3903,6 +3921,8 @@ window.__ModuleLoader__.load({
3903
3921
  : inInbox
3904
3922
  ? h('div', { className: 'at-stream', role: 'region', 'aria-label': t('inboxTitle') },
3905
3923
  h('div', { className: 'at-streaminner' },
3924
+ // 失败必须可见:不能把「拉取失败」渲染成「没有待验收」。
3925
+ pendingError !== '' ? h('div', { className: 'at-peoplefail', role: 'status' }, tf(t, 'loadFailedBody') + (pendingError ? '(' + pendingError + ')' : '')) : null,
3906
3926
  // R-09 待验收跨项目队列。
3907
3927
  pendingRows !== null && pendingRows.length > 0
3908
3928
  ? h('details', { className: 'at-people', open: true },