@v587d/capital-generation 2.31.0 → 2.31.3
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 +129 -0
- package/README.md +2 -2
- package/automation/package.json +1 -1
- package/chart-ui/package.json +1 -1
- package/config/package.json +1 -1
- package/lib/agents/messaging-policy.d.ts +23 -6
- package/lib/agents/messaging-policy.js +64 -9
- package/lib/agents/role-tool-policy.js +3 -3
- package/lib/analysis/registry.js +1 -1
- package/lib/analysis/schemas.d.ts +8 -2
- package/lib/analysis/schemas.js +8 -2
- package/lib/analysis/tools.js +5 -0
- package/lib/analysis/validation.js +72 -19
- package/lib/data-collector/store.js +3 -1
- package/lib/web-retriever/local-fetch.d.ts +1 -1
- package/lib/web-retriever/local-fetch.js +1 -1
- package/lib/web-retriever/wind-client.d.ts +1 -1
- package/lib/web-retriever/wind-client.js +1 -1
- package/package.json +1 -1
- package/preset/capital-generation/agent.patch.yml +23 -21
- package/preset/capital-generation/skills/capital-analysis-evidence/SKILL.md +22 -1
- package/preset/capital-generation/skills/capital-analysis-synthesis/SKILL.md +1 -1
- package/preset/capital-generation/skills/capital-analysis-validation/SKILL.md +9 -6
- package/preset/capital-generation/skills/capital-orchestration/SKILL.md +33 -28
- package/preset/capital-generation/skills/capital-senior-analysis/SKILL.md +16 -8
- package/python/analysis/modules/returns_risk/LICENSE +21 -0
- package/python/analysis/modules/returns_risk/module.json +66 -0
- package/python/analysis/modules/returns_risk/module.py +517 -0
- package/python/analysis/modules/scenario_sensitivity/LICENSE +21 -0
- package/python/analysis/modules/scenario_sensitivity/module.json +105 -0
- package/python/analysis/modules/scenario_sensitivity/module.py +379 -0
- package/watchlist/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,135 @@
|
|
|
7
7
|
- **第三位(patch)**:不破坏既有工具 / 配置 / 会话的新增与修复(如 2.1.1、2.1.2)。
|
|
8
8
|
- **第二位(minor)**:有需要用户知晓的行为变更,且段内附迁移说明(如 2.1.0 的图表呈现通道重做、2.2.0 的数据源与检索来源扩容、2.4.0 的**必须换宿主版本**、2.9.0 的选择器收敛与质检前置——本插件自己的工具与数据契约没变,所以只抬第二位)。
|
|
9
9
|
|
|
10
|
+
## [2.31.3] - 2026-11-25
|
|
11
|
+
|
|
12
|
+
高级分析师 Phase 6 收口:7 案真实会话评测、成本观测工具、D1 可编辑脚本重评估,以及评测暴露的路由与
|
|
13
|
+
锚点修复。senior analyst 的 P0–P6 至此全部完成;后续只按需补 P1 模块与数据面。
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **评测集 `docs/design/senior-analyst-eval.md`**:7 个固定题面逐字落库、七项检查表、首轮 7 案
|
|
18
|
+
pass/fail/blocked 与 after 复测记录;D8 口径(人工逐案判、不做百分比阈值、不得用投资收益证明质量)。
|
|
19
|
+
- **成本观测工具**:`scripts/analysis-eval-metrics.mjs` + `scripts/lib/session-metrics.mjs` 读宿主会话
|
|
20
|
+
事件,按会话汇总时长 / 轮数 / 工具调用 / 工具错误 / input-output-cache tokens;10 场真实会话的基线
|
|
21
|
+
写进评测文档(只作趋势记录)。
|
|
22
|
+
- 回归:`test/session-metrics.test.mjs`(宿主没记 usage 时不给 0、空 workspace 可见 skip)、
|
|
23
|
+
`test/analysis-validation.test.mjs` 的千分位与指数简称用例。
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- **判断类硬路由**:主 persona 把"复核 / 评估 / 对比 / 趋势 / 影响 / 风险特征 / 估值 / 情景结论"
|
|
28
|
+
写成必须派 `senior_analyst`;junior 的数值只是输入,禁止 lead 据此写结论或自己下判断;
|
|
29
|
+
`capital-orchestration` 路由表同步。修复首轮评测 4/5 案不派 senior 的问题。
|
|
30
|
+
- **最终答复模板**:主 persona 的"观察 / 验证 / 防守选项"改为"观察 / 验证 / 应对边界(不得给买卖、
|
|
31
|
+
仓位或目标价建议)",修掉评测里"降仓位 / 换资产"式建议。
|
|
32
|
+
- **D1 结论**:继续固定模块路线——三条前置只有 ①成立(真实会话端到端验收),②无容器或"可信本机
|
|
33
|
+
执行"授权,③ bad case 归因是缺模块 / 数据与路由,不是"模块 + 参数"表达力不足;证据写进评测文档 §5。
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- **千分位金额被拆成多个无锚点 token**:`30,000,515,859.60` 旧 tokenizer 拆成 30/000/515/859.60,
|
|
38
|
+
真实会话被拒两次;现在数字 token 与单位常数都认千分位。
|
|
39
|
+
- **指数简称里的数字被当成待溯源量**:"沪深300"的 300 会被判无锚点;现在沪深300 / 中证500 / 科创50
|
|
40
|
+
一类简称进豁免集。
|
|
41
|
+
- **路由缺陷(评测发现)**:首轮 5 个判断类 case 只有 1 个派 senior、4 个由 lead 自写结论;修复后
|
|
42
|
+
after 复测 3/3 派 senior 且 artifact 落盘(period 的 v2 还是 completed / pass)。
|
|
43
|
+
|
|
44
|
+
### Notes
|
|
45
|
+
|
|
46
|
+
- 版本:根包 + 四个随包嵌套包(chart-ui / config / watchlist / automation)+
|
|
47
|
+
`LOCAL_FETCH_CLIENT_VERSION` / `WIND_CLIENT_VERSION` 同步 2.31.3。
|
|
48
|
+
- 回归:`npm test` **1812 pass / 0 fail**;`smoke:boot` 五颗角色 preset 全 `broken: null`、族行 23/23;
|
|
49
|
+
`check:dsh` 40/40。
|
|
50
|
+
- 评测基线:10 场真实会话、约 80 分钟 wall time;单场 root + 3–5 子 Agent、80–218 颗工具、8–48 万
|
|
51
|
+
input tokens、8–34 min。换模型 / 宿主 / 模块后按 3 案抽样复测即可,不必全跑。
|
|
52
|
+
- 剩余(不在本版):P1 的 `valuation_sensitivity` 等模块、美股报表与事件数据能力,按需补;
|
|
53
|
+
不重启可编辑 `analysis.py` + shell(D1 不变)。
|
|
54
|
+
|
|
55
|
+
## [2.31.2] - 2026-11-25
|
|
56
|
+
|
|
57
|
+
高级分析师 Phase 5:补上 `returns_risk`(序列形状)与 `scenario_sensitivity`(假设网格形状)两颗分析模块。
|
|
58
|
+
至此模块协议的三种输入形状(三表横截面 / 价格序列 / 参数网格)各有一颗经审查的模块与手算 golden,
|
|
59
|
+
senior 的「取数 → 质检 → 分析 → 结论」不再只能回答财务质量一类问题。
|
|
60
|
+
|
|
61
|
+
### Added
|
|
62
|
+
|
|
63
|
+
- **`returns_risk 1.0.0`**:吃一份时间列 + 正价格序列 Dataset(可选第二份做基准),输出区间 / 年化收益、
|
|
64
|
+
年化波动、最大回撤、夏普 / 索提诺 / Calmar、历史 VaR / CVaR,有基准才有 beta / 相关;坏行跳过并写
|
|
65
|
+
`data_gaps`,重复日期、混用时间格式、找不到时间 / 价格列在启动前响亮失败,有效观测 < 3 个直接
|
|
66
|
+
`blocked`;样本 < 30 个收益只作方向性参考并写进 limitations。`risk_metrics.json` 保留逐日收盘与收益,
|
|
67
|
+
每个指标都能从这组输入复算。
|
|
68
|
+
- **`scenario_sensitivity 1.0.0`**(params-only,`capabilities: []`):调用方给显式恒等式
|
|
69
|
+
(`product` = Π factor^exponent / `sum` = Σ factor×exponent)+ 因子基准 + `oat` / `full` 网格 + 具名情景,
|
|
70
|
+
输出基准、情景表、格点表与 `inherited` 假设追踪;负基准小数指数、未声明因子、空网格 / 空情景在启动前
|
|
71
|
+
拒;基准为 0 时变化率给 null + 缺口,不写 0 冒充百分比。网格区间不是置信区间,摘要写明"不是预测"。
|
|
72
|
+
- 三颗模块的 fixtures / golden / provenance 齐全;新增模块的 `LICENSE` 随包、`fixtures/` 由 `.npmignore`
|
|
73
|
+
排除(打包测试按 registry 自动覆盖)。
|
|
74
|
+
|
|
75
|
+
### Changed
|
|
76
|
+
|
|
77
|
+
- `list_analysis_modules` / `describe_analysis_module` 的真实模块清单从 1 颗扩到 3 颗:`financial_quality`
|
|
78
|
+
(横截面)→ `returns_risk`(序列)→ `scenario_sensitivity`(假设网格)。`capital-analysis-evidence` §6
|
|
79
|
+
改成三颗模块的输入契约,`capital-senior-analysis` §5 加"按输入形状选模块",`docs/dev/senior-analysis.md`
|
|
80
|
+
的模块清单同步。
|
|
81
|
+
|
|
82
|
+
### Notes
|
|
83
|
+
|
|
84
|
+
- 版本:根包 + 四个随包嵌套包(chart-ui / config / watchlist / automation)+
|
|
85
|
+
`LOCAL_FETCH_CLIENT_VERSION` / `WIND_CLIENT_VERSION` 同步 2.31.2。
|
|
86
|
+
- 回归:`npm test` **1808 pass / 0 fail**(新增 `returns_risk` 8 例、`scenario_sensitivity` 8 例:手算 golden、
|
|
87
|
+
坏行 / 重复日期 / 极端参数等失败路径,全部走真实 worker 端到端),`smoke:boot` 五颗角色 preset 全
|
|
88
|
+
`broken: null`、族行 23/23,`check:dsh` 40/40。
|
|
89
|
+
- 本轮能力验证是模块协议 golden + 真实 worker,不是整条真机会话;Phase 6 的评测集会覆盖真实问答。
|
|
90
|
+
|
|
91
|
+
## [2.31.1] - 2026-11-25
|
|
92
|
+
|
|
93
|
+
高级分析师的协作层收尾:子 Agent 按邻接表直连(P4),同时修掉真实会话暴露的三处问题——跨 Agent 读 profile
|
|
94
|
+
的会话范围写错、20k 产物预算让综合多期报告反复删减重提、以及锚点校验把证券代码与四舍五入后的数字当成
|
|
95
|
+
无来源。本轮不新增分析模块;P5(模块扩展)与 P6(加固与评估)继续在 2.31.x 补丁里完成。
|
|
96
|
+
|
|
97
|
+
### Added
|
|
98
|
+
|
|
99
|
+
- **子 Agent 直连邻接表**(设计 §5.2):主 Agent → 直系子 Agent;data-collector → data-junior / senior-analyst;
|
|
100
|
+
data-junior 与 web-retriever → senior-analyst;senior-analyst → data-junior(只请求"用已有 Dataset/profile
|
|
101
|
+
补计算",新数据 / 新检索仍经主 Agent)与 lead;visualization-specialist 仍不发消息。目标按固定树内名匹配,
|
|
102
|
+
表外目标逐角色给具名拒语;`list_agents` / `interrupt_agent` 仍只归主 Agent。直连是路由纪律,不是安全边界。
|
|
103
|
+
- **补计算往返预算 3 次**(设计 §5.6-2):senior 第 4 次向 peer 发请求在发送侧被拒;`submit_analysis` 再按
|
|
104
|
+
`task_id` 核对 `peer_exchanges[]`,超 3 条抛 `analysis_peer_budget_exhausted`;有未回执项不能写 `completed`。
|
|
105
|
+
- **`waiting_peer` 收尾状态**:等补计算回执 ≠ 完成,只有主 Agent 收到最终回执才算完;状态词汇、对账表
|
|
106
|
+
(`capital-orchestration` §4/§6.1/§7)与四册消息章节同步。
|
|
107
|
+
|
|
108
|
+
### Changed
|
|
109
|
+
|
|
110
|
+
- **分析产物预算 20000 → 30000 字符**:综合多期产物实测落在 20–21.7k,20k 上限让 senior 反复删减重提
|
|
111
|
+
(真实会话 7 连拒、其中 6 次是体积);单段上限不变(headline 300 / thesis 1200 / statement 600 /
|
|
112
|
+
每侧 claims 20 / scenarios 8)。
|
|
113
|
+
- **数字锚点按显示精度匹配**:`1.23` 可命中 `1.2345`、`4.44%` 命中 `4.4444%`、整数百分比 `18%` 命中
|
|
114
|
+
`18.04%`(无小数的整数本身不按小数位放宽);六位证券代码(`600519` / `000858` / `920000`)与 ≤20 的
|
|
115
|
+
结构性计数(`5 条` / `0 次`)进豁免集;同一字段里重复的未命中数字去重。真正无锚点的数字仍硬拒。
|
|
116
|
+
- **协议文案同步**:`capital-senior-analysis` / `capital-analysis-validation` / `capital-orchestration`
|
|
117
|
+
的消息、预算与锚点口径更新;`docs/dev/senior-analysis.md` 记录直连邻接表、往返预算与收尾四条。
|
|
118
|
+
|
|
119
|
+
### Fixed
|
|
120
|
+
|
|
121
|
+
- **兄弟 Agent 永远读不到对方的 profile**:`ProfileRef.session_id` 写入的是产出者 session id,而 `readProfile`
|
|
122
|
+
按 `sessionScopeFor(session)` 比较,跨 Agent(如 senior 读 junior 的 profile)必然 `dataset_session_mismatch`。
|
|
123
|
+
改为写会话范围,并补跨兄弟 profile 读取回归。
|
|
124
|
+
- **peer-only 子 Agent 的唤醒噪声**:只跟 peer 通信、没向根投递 relay 的子 Agent 可能在收尾多唤醒一个空轮。
|
|
125
|
+
首版按噪声接受(不丢数据),行为写进 `settled-wake` 回归与 `docs/dev/chart-delivery-events.md`。
|
|
126
|
+
|
|
127
|
+
### Notes
|
|
128
|
+
|
|
129
|
+
- 升级无需迁移:本补丁不破坏工具 / 配置 / 会话契约;直连目标按树内名匹配,已有会话继续可用。
|
|
130
|
+
- 路由纠偏(估值 / 收益风险 / 事件不派 senior)与"不输出买卖建议"护栏加固排在 P5 之后整体处理(真实会话
|
|
131
|
+
证据见设计文档 §17 Phase 4 实测)。
|
|
132
|
+
- 版本:根包 + 四个随包嵌套包(chart-ui / config / watchlist / automation)+
|
|
133
|
+
`LOCAL_FETCH_CLIENT_VERSION` / `WIND_CLIENT_VERSION` 同步 2.31.1。
|
|
134
|
+
- 回归:`npm test` **1792 pass / 0 fail**(直连邻接表逐边正反、peer 预算、跨兄弟 profile、锚点放宽与
|
|
135
|
+
30000 体积各有用例),`smoke:boot` 五个角色 preset 全 `broken: null`、族行 23/23,`check:dsh` 40/40。
|
|
136
|
+
- 依据:2026-11-25 真实 web profile 会话三场(轻量 FY2024 / 五年期复核 / 估值边界)——能力结论与两处失败
|
|
137
|
+
记录在 `docs/design/senior-analyst-development-design.md` §17 Phase 4 实测。
|
|
138
|
+
|
|
10
139
|
## [2.31.0] - 2026-11-24
|
|
11
140
|
|
|
12
141
|
高级分析师(`senior_analyst`)上线:补上「取数 → 质检 → 分析 → 结论」的最后一段——新增一个根直系叶子角色、
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-green" alt="License"></a>
|
|
4
4
|
<a href="https://github.com/v587d/capital-generation"><img src="https://img.shields.io/badge/Financial%20Market-CN%20%7C%20HK%20%7C%20US-orange" alt="Market·CN+HK+US"></a>
|
|
5
5
|
<a href="https://github.com/deepseek-ai"><img src="https://img.shields.io/badge/DSH%20Baseline-0.2.2--rc.5-blue" alt="DSH@0.2.2-rc.5"></a>
|
|
6
|
-
<a href="https://github.com/v587d/capital-generation/releases"><img src="https://img.shields.io/badge/version-2.31.
|
|
6
|
+
<a href="https://github.com/v587d/capital-generation/releases"><img src="https://img.shields.io/badge/version-2.31.3-9cf" alt="Version"></a>
|
|
7
7
|
<a href="https://www.npmjs.com/package/@v587d/capital-generation"><img src="https://img.shields.io/npm/v/%40v587d%2Fcapital-generation" alt="npm version"></a>
|
|
8
8
|
</p>
|
|
9
9
|
|
|
@@ -192,7 +192,7 @@ Capital Generation 是运行在 [DeepSeek Harness(DSH)](https://github.com/d
|
|
|
192
192
|
- **配置在哪?** 打开「插件」→ 已安装的 **Capital Generation**,插件介绍下方就是「数据源 / 投研自动化 / 精选 Skills / 包含的组件 / 分析环境」五格,五把密钥都在第一格;第二格可指定任务统一使用的默认工作区,也能改自动检查间隔与最长运行时间等上限;第五格准备 Python 分析环境;不在 DSH 的普通「设置」页面,也不用点进任何一行组件。保存密钥后新建会话再试。
|
|
193
193
|
- **升级到 2.9.0 后,分析师和绘图专员去哪了?** 这一版把它们收进自动模式内部,不再出现在选择器与预设管理里,避免误开一个没有取数入口的空会话。旧会话仍能按原身份恢复;新任务直接用自动模式提出即可。
|
|
194
194
|
- **宿主更新后插件显示异常、三个模式消失?** 插件只支持**同一 minor** 的宿主(本版是 `>=0.2.2-rc.5 <0.2.3-0`):宿主跨到 0.2.3 及以上时,旧插件会被启动拒载(插件页显示「异常」)。先把宿主升到与插件同一条 minor,再在插件页更新插件;应急可用版本豁免(有崩溃风险,见 CHANGELOG 的 Migration)。日志里出现「宿主 dsh … 未逐项验证」说明你跑在同一 minor 的未验证补丁版上——能跑,但遇异常请先升级插件并把那行日志附在 issue 里。
|
|
195
|
-
- **桌面端升级后仍是旧版?** 桌面端安装时会固定所解析的版本,不会自动升级。卸载后重新安装,再到插件详情查看版本号;如需指定版本,可在地址末尾加 `#v2.31.
|
|
195
|
+
- **桌面端升级后仍是旧版?** 桌面端安装时会固定所解析的版本,不会自动升级。卸载后重新安装,再到插件详情查看版本号;如需指定版本,可在地址末尾加 `#v2.31.3` 或 `@2.31.3`。
|
|
196
196
|
- **刚发布的新版本装不到?** 桌面端取包时会跳过**刚发布不久**的版本(宿主侧包管理器的发布冷却策略,实测会静默装成上一个版本),国内镜像的同步也可能滞后一段时间。急着用最新代码,改用仓库地址安装最直接;但仓库地址安装的是 git 依赖,插件页不显示「版本」检查。
|
|
197
197
|
- **插件页的「版本」段怎么用?** 只有用包名从 npm 安装的版本才有;它只列比当前新的版本。回旧版要先卸载,再安装 `@v587d/capital-generation@版本号`(桌面端地址末尾加 `#v版本号`);旧版必须匹配当前 DSH 基线,对应关系见 [CHANGELOG 的 Migration](CHANGELOG.md)。
|
|
198
198
|
- **网页抓取失败?** 配置卡片中的「允许启动本地提取网页内容」默认开启:AnySearch 提取失败时可尝试本机直连。关闭后,本机直连的具名来源查询也不可用;请检查该开关和网络连接。
|
package/automation/package.json
CHANGED
package/chart-ui/package.json
CHANGED
package/config/package.json
CHANGED
|
@@ -1,21 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Call-level `send_message` target guard.
|
|
3
|
-
* each other;
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Call-level `send_message` target guard. The host lets any two members of one subagent tree message
|
|
3
|
+
* each other; this plugin keeps the adjacency table from design §5.2: root -> direct child only,
|
|
4
|
+
* peer edges only where listed, specialist -> none. Targets match fixed tree names because the guard
|
|
5
|
+
* is synchronous and sees raw strings only (a session id is shaped like a name), so this is routing
|
|
6
|
+
* discipline, not a security boundary. Non-Capital presets fail open.
|
|
7
|
+
*
|
|
8
|
+
* The analyst's outgoing peer sends also carry the §5.6 round-trip budget: the send edge stops the
|
|
9
|
+
* fourth request, and `validateArtifact` re-checks the recorded exchanges per `task_id`.
|
|
6
10
|
*/
|
|
7
11
|
import type { GuardedExecution, PolicyContext } from './root-tool-policy.js';
|
|
8
12
|
export declare const MESSAGE_TOOL_NAME = "send_message";
|
|
13
|
+
/** Fixed tree names from the delegation prompt; peer edges match these strings, never session ids. */
|
|
14
|
+
export declare const ROLE_TREE_NAMES: {
|
|
15
|
+
readonly collector: "data-collector";
|
|
16
|
+
readonly junior: "data-junior";
|
|
17
|
+
readonly retriever: "web-retriever";
|
|
18
|
+
readonly specialist: "visualization-specialist";
|
|
19
|
+
readonly analyst: "senior-analyst";
|
|
20
|
+
readonly lead: "lead";
|
|
21
|
+
};
|
|
9
22
|
export declare const ROOT_MESSAGE_DENIED: string;
|
|
10
23
|
export declare const LEAF_MESSAGE_DENIED = "send_message \u53EA\u80FD\u53D1\u7ED9 `lead`\uFF1A\u53F6\u5B50\u89D2\u8272\u4E0D\u76F4\u63A5\u627E\u5144\u5F1F\u6216\u5B59 Agent\uFF0C\u6750\u6599\u4E0E\u8BF7\u6C42\u90FD\u7ECF\u4E3B Agent \u4E2D\u7EE7\u3002";
|
|
11
24
|
export declare const SPECIALIST_MESSAGE_DENIED = "visualization_specialist \u4E0D\u76F4\u63A5\u53D1\u6D88\u606F\uFF1A\u628A\u56FE\u8868\u7ED3\u679C\u4F5C\u4E3A\u6700\u7EC8\u7B54\u590D\u8FD4\u56DE data_junior\uFF0C\u7531\u5B83\u6C47\u603B\u3002";
|
|
12
|
-
/** Allowed
|
|
25
|
+
/** Allowed send edges per role preset. Empty means no messaging at all. Extending one is a product decision. */
|
|
13
26
|
export declare const ROLE_MESSAGE_TARGETS: Readonly<Record<string, readonly string[]>>;
|
|
27
|
+
/** §5.6-2 budget: one analysis task may ask its peer at most three times. */
|
|
28
|
+
export declare const PEER_ROUND_TRIP_BUDGET = 3;
|
|
29
|
+
export declare const PEER_BUDGET_DENIED: string;
|
|
30
|
+
export declare function peerSendCount(sessionId: string): number;
|
|
14
31
|
/** The host owns the required-field error; the guard only judges a target it can actually read. */
|
|
15
32
|
export declare function sendMessageTargetOf(exec: GuardedExecution | undefined): string | undefined;
|
|
16
33
|
/** Root may address a direct child only: no tree path, and never itself. */
|
|
17
34
|
export declare function isDirectChildName(name: string): boolean;
|
|
18
35
|
/** Read identity per call because a created-time gate misses manually opened modes; fail open otherwise. */
|
|
19
36
|
export declare function sendMessageGuardReasonFor(ctx: PolicyContext): (exec: GuardedExecution | undefined) => string | undefined;
|
|
20
|
-
/**
|
|
37
|
+
/** Install globally once; a created-time gate misses manually opened modes. */
|
|
21
38
|
export declare function registerSendMessageGuard(ctx: PolicyContext): void;
|
|
@@ -1,19 +1,52 @@
|
|
|
1
|
-
import { recordGuardDecision } from './root-tool-policy.js';
|
|
1
|
+
import { agentSessionId, recordGuardDecision } from './root-tool-policy.js';
|
|
2
2
|
import { readPresetClaim } from '../preset-claim.js';
|
|
3
3
|
import { CAPITAL_PRESET_IDS, ROLE_PRESET_IDS, ROOT_PRESET_ID } from '../preset-ids.js';
|
|
4
4
|
export const MESSAGE_TOOL_NAME = 'send_message';
|
|
5
|
+
const LEAD_NAME = 'lead';
|
|
6
|
+
/** Fixed tree names from the delegation prompt; peer edges match these strings, never session ids. */
|
|
7
|
+
export const ROLE_TREE_NAMES = {
|
|
8
|
+
collector: 'data-collector',
|
|
9
|
+
junior: 'data-junior',
|
|
10
|
+
retriever: 'web-retriever',
|
|
11
|
+
specialist: 'visualization-specialist',
|
|
12
|
+
analyst: 'senior-analyst',
|
|
13
|
+
lead: LEAD_NAME,
|
|
14
|
+
};
|
|
5
15
|
export const ROOT_MESSAGE_DENIED = 'send_message 只能发给你的直系子 Agent:目标名不能是 `lead`,也不能含 `/`(孙 Agent 走 data_junior 中继)。'
|
|
6
16
|
+ '重新调用 list_agents() 取直系 name 后再发。';
|
|
7
17
|
export const LEAF_MESSAGE_DENIED = 'send_message 只能发给 `lead`:叶子角色不直接找兄弟或孙 Agent,材料与请求都经主 Agent 中继。';
|
|
8
18
|
export const SPECIALIST_MESSAGE_DENIED = 'visualization_specialist 不直接发消息:把图表结果作为最终答复返回 data_junior,由它汇总。';
|
|
9
|
-
/** Allowed
|
|
19
|
+
/** Allowed send edges per role preset. Empty means no messaging at all. Extending one is a product decision. */
|
|
10
20
|
export const ROLE_MESSAGE_TARGETS = {
|
|
11
|
-
[ROLE_PRESET_IDS.collector]: [
|
|
12
|
-
[ROLE_PRESET_IDS.junior]: [
|
|
13
|
-
[ROLE_PRESET_IDS.retriever]: [
|
|
21
|
+
[ROLE_PRESET_IDS.collector]: [ROLE_TREE_NAMES.junior, ROLE_TREE_NAMES.analyst, LEAD_NAME],
|
|
22
|
+
[ROLE_PRESET_IDS.junior]: [ROLE_TREE_NAMES.analyst, LEAD_NAME],
|
|
23
|
+
[ROLE_PRESET_IDS.retriever]: [ROLE_TREE_NAMES.analyst, LEAD_NAME],
|
|
14
24
|
[ROLE_PRESET_IDS.specialist]: [],
|
|
15
|
-
[ROLE_PRESET_IDS.analyst]: [
|
|
25
|
+
[ROLE_PRESET_IDS.analyst]: [ROLE_TREE_NAMES.junior, LEAD_NAME],
|
|
26
|
+
};
|
|
27
|
+
/** Per-role denial copy; the range gate (new data via lead) belongs in the message, not only in docs. */
|
|
28
|
+
const ROLE_MESSAGE_DENIED = {
|
|
29
|
+
[ROLE_PRESET_IDS.collector]: 'send_message 只能发给 lead、data-junior 或 senior-analyst:DatasetRef 可直达材料消费者,'
|
|
30
|
+
+ '新数据请求仍经 lead。',
|
|
31
|
+
[ROLE_PRESET_IDS.junior]: 'send_message 只能发给 lead 或 senior-analyst:补计算结果可直发 senior,其他兄弟与孙 Agent 经 lead。',
|
|
32
|
+
[ROLE_PRESET_IDS.retriever]: 'send_message 只能发给 lead 或 senior-analyst:带来源的证据可直发 senior,其他目标经 lead。',
|
|
33
|
+
[ROLE_PRESET_IDS.analyst]: 'send_message 只能发给 lead 或 data-junior:新数据/新检索经 lead,'
|
|
34
|
+
+ '只有"用已有 Dataset/profile 补计算"可直连 data-junior。',
|
|
16
35
|
};
|
|
36
|
+
/** §5.6-2 budget: one analysis task may ask its peer at most three times. */
|
|
37
|
+
export const PEER_ROUND_TRIP_BUDGET = 3;
|
|
38
|
+
export const PEER_BUDGET_DENIED = `补计算往返已达 ${PEER_ROUND_TRIP_BUDGET} 次上限:不要再向同行发请求,`
|
|
39
|
+
+ '改用 analysis_blocked + peer_budget_exhausted 把未决缺口回给 lead 裁决。';
|
|
40
|
+
const PEER_SEND_BUDGET = {
|
|
41
|
+
[ROLE_PRESET_IDS.analyst]: PEER_ROUND_TRIP_BUDGET,
|
|
42
|
+
};
|
|
43
|
+
/** Outgoing peer sends per sender session. One senior session carries one analysis task. */
|
|
44
|
+
const peerSends = new Map();
|
|
45
|
+
/** Bounded bookkeeping: leak-free enough without a session lifecycle hook. */
|
|
46
|
+
const PEER_SEND_TRACK_MAX = 256;
|
|
47
|
+
export function peerSendCount(sessionId) {
|
|
48
|
+
return peerSends.get(sessionId) ?? 0;
|
|
49
|
+
}
|
|
17
50
|
function isRecord(value) {
|
|
18
51
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
19
52
|
}
|
|
@@ -27,7 +60,27 @@ export function sendMessageTargetOf(exec) {
|
|
|
27
60
|
}
|
|
28
61
|
/** Root may address a direct child only: no tree path, and never itself. */
|
|
29
62
|
export function isDirectChildName(name) {
|
|
30
|
-
return name !==
|
|
63
|
+
return name !== LEAD_NAME && !name.includes('/');
|
|
64
|
+
}
|
|
65
|
+
/** Counts the send once it passes the edge check; the artifact check is the authoritative record. */
|
|
66
|
+
function peerBudgetReason(role, target, exec) {
|
|
67
|
+
const budget = PEER_SEND_BUDGET[role];
|
|
68
|
+
if (budget === undefined || target === LEAD_NAME)
|
|
69
|
+
return undefined;
|
|
70
|
+
const sessionId = agentSessionId(exec?.agent);
|
|
71
|
+
// No session pull (old host shape / unit call): leave counting to the artifact check.
|
|
72
|
+
if (sessionId === undefined)
|
|
73
|
+
return undefined;
|
|
74
|
+
const used = peerSends.get(sessionId) ?? 0;
|
|
75
|
+
if (used >= budget)
|
|
76
|
+
return PEER_BUDGET_DENIED;
|
|
77
|
+
peerSends.set(sessionId, used + 1);
|
|
78
|
+
if (peerSends.size > PEER_SEND_TRACK_MAX) {
|
|
79
|
+
const oldest = peerSends.keys().next().value;
|
|
80
|
+
if (typeof oldest === 'string')
|
|
81
|
+
peerSends.delete(oldest);
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
31
84
|
}
|
|
32
85
|
/** Read identity per call because a created-time gate misses manually opened modes; fail open otherwise. */
|
|
33
86
|
export function sendMessageGuardReasonFor(ctx) {
|
|
@@ -46,11 +99,13 @@ export function sendMessageGuardReasonFor(ctx) {
|
|
|
46
99
|
const allowed = ROLE_MESSAGE_TARGETS[claim.claim] ?? [];
|
|
47
100
|
if (allowed.length === 0)
|
|
48
101
|
return SPECIALIST_MESSAGE_DENIED;
|
|
49
|
-
|
|
102
|
+
if (!allowed.includes(target))
|
|
103
|
+
return ROLE_MESSAGE_DENIED[claim.claim] ?? LEAF_MESSAGE_DENIED;
|
|
104
|
+
return peerBudgetReason(claim.claim, target, exec);
|
|
50
105
|
};
|
|
51
106
|
}
|
|
52
107
|
const installedGuardRoots = new WeakSet();
|
|
53
|
-
/**
|
|
108
|
+
/** Install globally once; a created-time gate misses manually opened modes. */
|
|
54
109
|
export function registerSendMessageGuard(ctx) {
|
|
55
110
|
const ref = ctx.root ?? ctx;
|
|
56
111
|
if (installedGuardRoots.has(ref))
|
|
@@ -143,10 +143,10 @@ export function roleSiblingGuardReasonFor(ctx) {
|
|
|
143
143
|
+ '等待归主 Agent 的 wait_for_agents 负责。';
|
|
144
144
|
}
|
|
145
145
|
if (name === 'list_agents') {
|
|
146
|
-
return `${name} 不对人设 ${claim.claim}
|
|
147
|
-
+ '
|
|
146
|
+
return `${name} 不对人设 ${claim.claim} 开放:子 Agent 名单与调度归主 Agent;peer 边只认固定树名,`
|
|
147
|
+
+ '按邻接表直接 send_message。需要别的 Agent 配合,不要自己换工具硬做。';
|
|
148
148
|
}
|
|
149
|
-
return `${name} 不对人设 ${claim.claim}
|
|
149
|
+
return `${name} 不对人设 ${claim.claim} 开放:打断别的会话归主 Agent 决定(peer 之间也不许)。`
|
|
150
150
|
+ '需要别的 Agent 停下来,用 send_message 回告主 Agent;不要自己换工具硬做。';
|
|
151
151
|
};
|
|
152
152
|
}
|
package/lib/analysis/registry.js
CHANGED
|
@@ -11,7 +11,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
11
11
|
import { MODULE_DEFAULT_LIMITS } from './schemas.js';
|
|
12
12
|
const MODULE_ROOT = fileURLToPath(new URL('../../python/analysis/modules/', import.meta.url));
|
|
13
13
|
/** Registered ids, in listing order. Adding a module means adding its id here. */
|
|
14
|
-
const REGISTERED_MODULE_IDS = ['hello', 'financial_quality'];
|
|
14
|
+
const REGISTERED_MODULE_IDS = ['hello', 'financial_quality', 'returns_risk', 'scenario_sensitivity'];
|
|
15
15
|
const cache = new Map();
|
|
16
16
|
function readManifest(moduleId) {
|
|
17
17
|
const cached = cache.get(moduleId);
|
|
@@ -5,13 +5,19 @@
|
|
|
5
5
|
* `additionalProperties: false` everywhere is deliberate — an undeclared field is a protocol
|
|
6
6
|
* change, and silently accepting it would make the artifact contract a suggestion.
|
|
7
7
|
*/
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Submit-time budgets; exceeding one names the offending section (`analysis_result_too_large`).
|
|
10
|
+
* 30k: a comprehensive multi-period artifact naturally lands at 20–22k, and a 20k cap made the
|
|
11
|
+
* model rewrite the same artifact for minutes instead of finishing (2026-11-25 real session).
|
|
12
|
+
*/
|
|
13
|
+
export declare const ARTIFACT_MAX_CHARS = 30000;
|
|
10
14
|
export declare const HEADLINE_MAX_CHARS = 300;
|
|
11
15
|
export declare const THESIS_MAX_CHARS = 1200;
|
|
12
16
|
export declare const STATEMENT_MAX_CHARS = 600;
|
|
13
17
|
export declare const MAX_CLAIMS = 20;
|
|
14
18
|
export declare const MAX_SCENARIOS = 8;
|
|
19
|
+
/** §5.6-2 peer round-trip budget per task_id. The send edge stops the fourth request; this is the record check. */
|
|
20
|
+
export declare const MAX_PEER_EXCHANGES = 3;
|
|
15
21
|
/** Bounded evidence intake: single item bytes and total count. */
|
|
16
22
|
export declare const EVIDENCE_ITEM_MAX_BYTES = 2048;
|
|
17
23
|
export declare const EVIDENCE_MAX_ITEMS = 20;
|
package/lib/analysis/schemas.js
CHANGED
|
@@ -10,13 +10,19 @@ const strings = (description) => ({ type: 'array', items: { type: 'string' }, ..
|
|
|
10
10
|
// `oneOf`, not `anyOf`: the host's enforced JSON-Schema subset (dsh-tools) accepts exact-one only,
|
|
11
11
|
// and a tool definition outside that subset makes the whole family row unsupported at boot.
|
|
12
12
|
const nullable = (schema) => ({ oneOf: [schema, { type: 'null' }] });
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Submit-time budgets; exceeding one names the offending section (`analysis_result_too_large`).
|
|
15
|
+
* 30k: a comprehensive multi-period artifact naturally lands at 20–22k, and a 20k cap made the
|
|
16
|
+
* model rewrite the same artifact for minutes instead of finishing (2026-11-25 real session).
|
|
17
|
+
*/
|
|
18
|
+
export const ARTIFACT_MAX_CHARS = 30_000;
|
|
15
19
|
export const HEADLINE_MAX_CHARS = 300;
|
|
16
20
|
export const THESIS_MAX_CHARS = 1_200;
|
|
17
21
|
export const STATEMENT_MAX_CHARS = 600;
|
|
18
22
|
export const MAX_CLAIMS = 20;
|
|
19
23
|
export const MAX_SCENARIOS = 8;
|
|
24
|
+
/** §5.6-2 peer round-trip budget per task_id. The send edge stops the fourth request; this is the record check. */
|
|
25
|
+
export const MAX_PEER_EXCHANGES = 3;
|
|
20
26
|
/** Bounded evidence intake: single item bytes and total count. */
|
|
21
27
|
export const EVIDENCE_ITEM_MAX_BYTES = 2_048;
|
|
22
28
|
export const EVIDENCE_MAX_ITEMS = 20;
|
package/lib/analysis/tools.js
CHANGED
|
@@ -318,6 +318,11 @@ export function registerAnalysisTools(deps) {
|
|
|
318
318
|
});
|
|
319
319
|
const validation = validateArtifact(artifact, snapshot);
|
|
320
320
|
if (validation.tier1.length > 0) {
|
|
321
|
+
// The reserved code exists for exactly this budget (§5.6-2); a generic validation error
|
|
322
|
+
// would hide that the peer loop is the problem.
|
|
323
|
+
const budget = validation.tier1.find((issue) => issue.code === 'peer_budget_exhausted');
|
|
324
|
+
if (budget !== undefined)
|
|
325
|
+
throw new AnalysisError('analysis_peer_budget_exhausted', budget.detail);
|
|
321
326
|
throw new AnalysisError('analysis_validation_failed', `产物未通过硬校验(${validation.tier1.length} 条):${validation.tier1.slice(0, 6).map((issue) => `${issue.code} ${issue.detail}`).join(';')}`);
|
|
322
327
|
}
|
|
323
328
|
const downgraded = validation.tier2.length > 0 && artifact.status === 'completed' ? 'partial' : artifact.status;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HEADLINE_MAX_CHARS, MAX_CLAIMS, MAX_SCENARIOS, STATEMENT_MAX_CHARS, THESIS_MAX_CHARS } from './schemas.js';
|
|
1
|
+
import { HEADLINE_MAX_CHARS, MAX_CLAIMS, MAX_PEER_EXCHANGES, MAX_SCENARIOS, STATEMENT_MAX_CHARS, THESIS_MAX_CHARS } from './schemas.js';
|
|
2
2
|
/** Subset of JSON Schema used by the protocol: types, properties, required, items, enum, bounds. */
|
|
3
3
|
export function validateAgainstSchema(value, schema, path = '$') {
|
|
4
4
|
if (schema === undefined || Object.keys(schema).length === 0)
|
|
@@ -142,15 +142,24 @@ export function validateModuleResult(value, manifest) {
|
|
|
142
142
|
}
|
|
143
143
|
const UNIT_CONSTANTS = new Set([1e4, 1e6, 1e8, 1e12]);
|
|
144
144
|
const YEAR = /^(?:19|20)\d{2}$/u;
|
|
145
|
-
|
|
145
|
+
// Thousands separators are display formatting, not a digit boundary: `30,000,515,859.60` is one
|
|
146
|
+
// number. Without this a comma-grouped amount becomes five unrelated tokens and every one of them
|
|
147
|
+
// looks unanchored (2026-11-25 real session: submit rejected with 30/000/515/859.60 …).
|
|
148
|
+
const NUMBER_TOKEN = /-?\d{1,3}(?:,\d{3})+(?:\.\d+)?|-?\d+(?:\.\d+)?/gu;
|
|
146
149
|
const PERCENT_AFTER = /^\s*[%%]/u;
|
|
150
|
+
// Six-digit securities codes (`600519`, `000858`, `300750`, `920000`, funds `510300`) are identifiers,
|
|
151
|
+
// not measured values. Amounts that start with 1 or 2 still need an anchor.
|
|
152
|
+
const SECURITY_CODE = /^(?:0|[3-9])\d{5}$/u;
|
|
153
|
+
const COUNT_CLASSIFIER = /^\s*[个条项期只家次类轮档组段页册笔位名张份套种年]/u;
|
|
154
|
+
/** Index short-name numbers that must never be read as measured values. */
|
|
155
|
+
const INDEX_NAME_VALUES = new Set([50, 100, 300, 500, 1000]);
|
|
147
156
|
/** Numeric tokens with just enough context to honour the exemption set. */
|
|
148
157
|
export function numberTokens(text) {
|
|
149
158
|
const tokens = [];
|
|
150
159
|
for (const match of text.matchAll(NUMBER_TOKEN)) {
|
|
151
160
|
const start = match.index ?? 0;
|
|
152
161
|
const raw = match[0];
|
|
153
|
-
const value = Number(raw);
|
|
162
|
+
const value = Number(raw.replace(/,/gu, ''));
|
|
154
163
|
if (!Number.isFinite(value))
|
|
155
164
|
continue;
|
|
156
165
|
tokens.push({ text: raw, value, percent: PERCENT_AFTER.test(text.slice(start + raw.length)), start });
|
|
@@ -161,7 +170,7 @@ function tolerance(precision) {
|
|
|
161
170
|
const digits = typeof precision === 'number' && precision >= 0 && precision <= 12 ? precision : 4;
|
|
162
171
|
return 0.5 * 10 ** -digits;
|
|
163
172
|
}
|
|
164
|
-
function exemptToken(
|
|
173
|
+
function exemptToken(token, source) {
|
|
165
174
|
// Digits inside an identifier (`claim_1`, `FY2025`) are not quantities.
|
|
166
175
|
const before = source[token.start - 1];
|
|
167
176
|
const after = source[token.start + token.text.length];
|
|
@@ -169,15 +178,55 @@ function exemptToken(text, token, source) {
|
|
|
169
178
|
return true;
|
|
170
179
|
if (!token.percent && YEAR.test(token.text))
|
|
171
180
|
return true;
|
|
181
|
+
// A securities code is an identifier, not a measured value.
|
|
182
|
+
if (!token.percent && SECURITY_CODE.test(token.text))
|
|
183
|
+
return true;
|
|
172
184
|
if (Number.isInteger(token.value) && Math.abs(token.value) <= 20) {
|
|
173
|
-
const
|
|
174
|
-
if (/[第期条项]/u.test(
|
|
185
|
+
const head = source.slice(Math.max(0, token.start - 2), token.start);
|
|
186
|
+
if (/[第期条项]/u.test(head))
|
|
187
|
+
return true;
|
|
188
|
+
// Structural counts ("5 条"、"0 次"、"3 个情景") are not quantities to trace either.
|
|
189
|
+
if (!token.percent && COUNT_CLASSIFIER.test(source.slice(token.start + token.text.length)))
|
|
175
190
|
return true;
|
|
176
191
|
}
|
|
177
|
-
if (UNIT_CONSTANTS.has(token.value) &&
|
|
192
|
+
if (UNIT_CONSTANTS.has(token.value) && /^(?:\d+|\d{1,3}(?:,\d{3})+)$/u.test(token.text))
|
|
178
193
|
return true;
|
|
194
|
+
// Index short names are proper nouns, not quantities: 沪深300 / 中证500 / 科创50.
|
|
195
|
+
if (!token.percent && INDEX_NAME_VALUES.has(token.value)
|
|
196
|
+
&& /(?:沪深|中证|上证|深证|科创|创业板|北证|恒生)\s*$/u.test(source.slice(Math.max(0, token.start - 4), token.start))) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
179
199
|
return false;
|
|
180
200
|
}
|
|
201
|
+
/** Digits after the decimal point as written: `18.00` → 2, an integer → 0. */
|
|
202
|
+
function shownDecimals(text) {
|
|
203
|
+
const dot = text.indexOf('.');
|
|
204
|
+
return dot === -1 ? 0 : text.length - dot - 1;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Prose rounds stored values: `1.23` is how `1.2345` is written, `4.44%` is how `4.4444%` is
|
|
208
|
+
* written. Compare at the precision the prose actually shows, for fractional tokens only — an
|
|
209
|
+
* integer is a quantity in its own right, not a rounded fraction.
|
|
210
|
+
*/
|
|
211
|
+
function displayMatch(token, value) {
|
|
212
|
+
const decimals = shownDecimals(token.text);
|
|
213
|
+
if (decimals === 0)
|
|
214
|
+
return false;
|
|
215
|
+
// Symmetric half-digit tolerance, so negative values round the same way as positive ones.
|
|
216
|
+
return Math.abs(value - token.value) <= 0.5 * 10 ** -decimals + 1e-12;
|
|
217
|
+
}
|
|
218
|
+
function matchesToken(token, value, precision) {
|
|
219
|
+
const tol = tolerance(precision);
|
|
220
|
+
if (Math.abs(value - token.value) <= tol)
|
|
221
|
+
return true;
|
|
222
|
+
// Ratio written as a percentage (0.1823 ↔ 18.23) — same precision, scaled by 100.
|
|
223
|
+
if (Math.abs(value * 100 - token.value) <= Math.max(tol * 100, 0.5 * 10 ** -2))
|
|
224
|
+
return true;
|
|
225
|
+
if (displayMatch(token, value) || displayMatch(token, value * 100))
|
|
226
|
+
return true;
|
|
227
|
+
// Whole-number percentages are a rounded display too: 0.1804 written as 18%.
|
|
228
|
+
return token.percent && shownDecimals(token.text) === 0 && Math.abs(value * 100 - token.value) < 0.5;
|
|
229
|
+
}
|
|
181
230
|
function anchoredNumbers(artifact) {
|
|
182
231
|
const anchors = [];
|
|
183
232
|
const values = [];
|
|
@@ -195,20 +244,18 @@ function anchoredNumbers(artifact) {
|
|
|
195
244
|
}
|
|
196
245
|
function unmatchedNumbers(text, anchors, calculations) {
|
|
197
246
|
const misses = [];
|
|
247
|
+
const seen = new Set();
|
|
198
248
|
for (const token of numberTokens(text)) {
|
|
199
|
-
if (exemptToken(
|
|
249
|
+
if (exemptToken(token, text))
|
|
250
|
+
continue;
|
|
251
|
+
if (anchors.some((anchor) => matchesToken(token, anchor.value, anchor.precision)))
|
|
200
252
|
continue;
|
|
201
|
-
|
|
202
|
-
const tol = tolerance(anchor.precision);
|
|
203
|
-
if (Math.abs(anchor.value - token.value) <= tol)
|
|
204
|
-
return true;
|
|
205
|
-
// Ratio written as a percentage (0.1823 ↔ 18.23) — same precision, scaled by 100.
|
|
206
|
-
return Math.abs(anchor.value * 100 - token.value) <= Math.max(tol * 100, 0.5 * 10 ** -2);
|
|
207
|
-
});
|
|
208
|
-
if (hit)
|
|
253
|
+
if (calculations.some((value) => matchesToken(token, value, undefined)))
|
|
209
254
|
continue;
|
|
210
|
-
|
|
255
|
+
// The same unanchored value repeated in one field is one problem, not six.
|
|
256
|
+
if (seen.has(token.text))
|
|
211
257
|
continue;
|
|
258
|
+
seen.add(token.text);
|
|
212
259
|
misses.push(token.text);
|
|
213
260
|
}
|
|
214
261
|
return misses;
|
|
@@ -317,11 +364,17 @@ export function validateArtifact(artifact, snapshot) {
|
|
|
317
364
|
tier2.push({ code: 'calculation_without_anchor', severity: 'warning', field: `calculations[${index}]`, detail: `计算结果 ${calculation.metric}=${calculation.value} 没有对应锚点` });
|
|
318
365
|
}
|
|
319
366
|
}
|
|
320
|
-
// Peer exchanges: an unanswered peer request means the result is not final
|
|
321
|
-
|
|
367
|
+
// Peer exchanges: an unanswered peer request means the result is not final, and the round-trip
|
|
368
|
+
// budget is a hard rule (§5.6-2). The send edge prevents the fourth request; this rejects a record
|
|
369
|
+
// that claims more than the budget (fabricated or from an unguarded client).
|
|
370
|
+
const exchanges = artifact.peer_exchanges ?? [];
|
|
371
|
+
const unanswered = exchanges.filter((item) => item?.answered !== true);
|
|
322
372
|
if (unanswered.length > 0) {
|
|
323
373
|
tier2.push({ code: 'peer_unanswered', severity: 'warning', field: 'peer_exchanges', detail: `${unanswered.length} 条 peer 请求没有回执;产物最多 partial` });
|
|
324
374
|
}
|
|
375
|
+
if (exchanges.length > MAX_PEER_EXCHANGES) {
|
|
376
|
+
tier1.push({ code: 'peer_budget_exhausted', severity: 'error', field: 'peer_exchanges', detail: `peer 往返 ${exchanges.length} 条,超过 ${MAX_PEER_EXCHANGES} 次预算;超出部分应回 analysis_blocked + peer_budget_exhausted 交 lead 裁决` });
|
|
377
|
+
}
|
|
325
378
|
if (artifact.status === 'completed' && unanswered.length > 0) {
|
|
326
379
|
tier1.push({ code: 'peer_unanswered_completed', severity: 'error', field: 'status', detail: '存在未回执的 peer 请求时不能写 completed' });
|
|
327
380
|
}
|
|
@@ -379,7 +379,9 @@ export class WorkspaceDatasetStore {
|
|
|
379
379
|
profile_id: profileId,
|
|
380
380
|
dataset_id: ref.dataset_id,
|
|
381
381
|
task_id: input.task_id ?? null,
|
|
382
|
-
|
|
382
|
+
// Scope id, not the producing session: siblings under one root must read the same profile
|
|
383
|
+
// (senior read_profile / snapshot staging), and `readProfile` compares against the scope.
|
|
384
|
+
session_id: sessionScopeFor(session),
|
|
383
385
|
artifact_ref: canonicalProfileRef(profileId),
|
|
384
386
|
created_at: createdAt,
|
|
385
387
|
retention_until: Math.min(ref.retention_until, createdAt + this.retentionMs),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Known limit: DNS resolves per request but the IP is not pinned to the connection,
|
|
4
4
|
* so a rebinding window remains (same trade-off as dsh-search-first).
|
|
5
5
|
*/
|
|
6
|
-
export declare const LOCAL_FETCH_CLIENT_VERSION = "2.31.
|
|
6
|
+
export declare const LOCAL_FETCH_CLIENT_VERSION = "2.31.3";
|
|
7
7
|
export declare const LOCAL_FETCH_MAX_URL_LENGTH = 2048;
|
|
8
8
|
export type LocalFetchErrorCode = 'ABORTED' | 'TIMEOUT' | 'INVALID_URL' | 'BLOCKED_URL' | 'DNS' | 'REDIRECT' | 'HTTP' | 'TOO_LARGE' | 'UNSUPPORTED_CONTENT_TYPE';
|
|
9
9
|
export declare class LocalFetchError extends Error {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* so a rebinding window remains (same trade-off as dsh-search-first).
|
|
5
5
|
*/
|
|
6
6
|
import { htmlToMarkdown, stripInvisibleText } from './html-markdown.js';
|
|
7
|
-
export const LOCAL_FETCH_CLIENT_VERSION = '2.31.
|
|
7
|
+
export const LOCAL_FETCH_CLIENT_VERSION = '2.31.3';
|
|
8
8
|
export const LOCAL_FETCH_MAX_URL_LENGTH = 2048;
|
|
9
9
|
export class LocalFetchError extends Error {
|
|
10
10
|
code;
|
|
@@ -35,7 +35,7 @@ export interface WindCallResult {
|
|
|
35
35
|
code?: WindErrorCode;
|
|
36
36
|
}
|
|
37
37
|
/** Must match `package.json` version; a test pins the two together. */
|
|
38
|
-
export declare const WIND_CLIENT_VERSION = "2.31.
|
|
38
|
+
export declare const WIND_CLIENT_VERSION = "2.31.3";
|
|
39
39
|
export interface WindClient {
|
|
40
40
|
callTool(toolName: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<WindCallResult>;
|
|
41
41
|
}
|
|
@@ -19,7 +19,7 @@ export const WIND_SERVER_ENDPOINTS = {
|
|
|
19
19
|
analytics_data: 'https://mcp.wind.com.cn/vserver_analytics_data/mcp/',
|
|
20
20
|
};
|
|
21
21
|
/** Must match `package.json` version; a test pins the two together. */
|
|
22
|
-
export const WIND_CLIENT_VERSION = '2.31.
|
|
22
|
+
export const WIND_CLIENT_VERSION = '2.31.3';
|
|
23
23
|
function errorText(error) {
|
|
24
24
|
return error instanceof Error ? error.message : String(error);
|
|
25
25
|
}
|