Merged
fix(ops-perf-optimize): 适配新版知识仓检索与安装契约 #228
xieshengwei1024Add on Oct 27
fix(ops-perf-optimize): 适配新版知识仓检索与安装契约 #228
Merged
Total: 20 files changed+115-74
| @@ -377,25 +377,6 @@ | |||
| 377 | "./ascendc-registry-invoke-template" | 377 | "./ascendc-registry-invoke-template" |
| 378 | ] | 378 | ] |
| 379 | }, | 379 | }, |
| 380 | - { | ||
| 381 | - "name": "ops-perf-optimize-kb-skills", | ||
| 382 | - "description": "cannbot-knowledge 知识消费 Skill(1 项):knowledge-query 知识检索。供 ops-perf-optimize 的方案设计与方案实施引用知识卡。", | ||
| 383 | - "source": { | ||
| 384 | - "source": "git-subdir", | ||
| 385 | - "url": "https://gitcode.com/cann/cannbot-skills.git", | ||
| 386 | - "path": "plugins-community/cannbot-knowledge/skills", | ||
| 387 | - "sha": "f305e200aa4b1e1fed73cd21ff1f083b8df25a1e" | ||
| 388 | - }, | ||
| 389 | - "strict": false, | ||
| 390 | - "version": "4.1.0", | ||
| 391 | - "author": { | ||
| 392 | - "name": "CANNBot" | ||
| 393 | - }, | ||
| 394 | - "category": "skills", | ||
| 395 | - "skills": [ | ||
| 396 | - "./knowledge-query" | ||
| 397 | - ] | ||
| 398 | - }, | ||
| 399 | { | 380 | { |
| 400 | "name": "ops-perf-optimize", | 381 | "name": "ops-perf-optimize", |
| 401 | "source": "./plugins-official/ops-perf-optimize", | 382 | "source": "./plugins-official/ops-perf-optimize", |
| @@ -413,8 +394,7 @@ | |||
| 413 | ], | 394 | ], |
| 414 | "category": "development", | 395 | "category": "development", |
| 415 | "dependencies": [ | 396 | "dependencies": [ |
| 416 | - "ops-perf-optimize-skills", | 397 | + "ops-perf-optimize-skills" |
| 417 | - "ops-perf-optimize-kb-skills" | ||
| 418 | ] | 398 | ] |
| 419 | }, | 399 | }, |
| 420 | { | 400 | { |
| @@ -9,8 +9,7 @@ | |||
| 9 | "repository": "https://gitcode.com/cann/cannbot", | 9 | "repository": "https://gitcode.com/cann/cannbot", |
| 10 | "license": "CANN-2.0", | 10 | "license": "CANN-2.0", |
| 11 | "dependencies": [ | 11 | "dependencies": [ |
| 12 | - "ops-perf-optimize-skills", | 12 | + "ops-perf-optimize-skills" |
| 13 | - "ops-perf-optimize-kb-skills" | ||
| 14 | ], | 13 | ], |
| 15 | "agents": [ | 14 | "agents": [ |
| 16 | "./AGENTS.md" | 15 | "./AGENTS.md" |
| @@ -18,7 +18,6 @@ | |||
| 18 | "ops/ascendc-sync-audit", | 18 | "ops/ascendc-sync-audit", |
| 19 | "ops/ascendc-mc2-best-practice", | 19 | "ops/ascendc-mc2-best-practice", |
| 20 | "ops/ops-precision-standard", | 20 | "ops/ops-precision-standard", |
| 21 | - "ops/ascendc-registry-invoke-template", | 21 | + "ops/ascendc-registry-invoke-template" |
| 22 | - "plugins-community/cannbot-knowledge/skills/knowledge-query" | ||
| 23 | ] | 22 | ] |
| 24 | } | 23 | } |
| @@ -50,16 +50,50 @@ bash /path/to/cannbot/plugins-official/ops-perf-optimize/init.sh project opencod | |||
| 50 | 50 | ||
| 51 | 安装会自动完成: | 51 | 安装会自动完成: |
| 52 | 52 | ||
| 53 | -1. **Skills 安装**:本插件自带的 9 个工作流 Skill(`ops-perf-optimize-workflow` 入口、五个阶段、验收标准、性能检视与特征提取)从插件目录软链,17 个共享 AscendC Skill(profiling、精度调试、Blaze 路由等)与 `knowledge-query` 知识检索 Skill 从 `vendor/cannbot-skills` submodule 软链到目标项目的工具 skills 目录;源码安装可用 `--skills <SHA|本地仓路径>` 锁定共享 Skill 版本; | 53 | +1. **Skills 安装**:本插件自带的 9 个工作流 Skill(`ops-perf-optimize-workflow` 入口、五个阶段、验收标准、性能检视与特征提取)从插件目录软链,17 个共享 AscendC Skill(profiling、精度调试、Blaze 路由等)从 `vendor/cannbot-skills` submodule 软链到目标项目的工具 skills 目录;源码安装可用 `--skills <SHA|本地仓路径>` 锁定共享 Skill 版本。知识检索 Skill 使用下节知识仓自身的安装器,不再从该 submodule 安装旧版; |
| 54 | -2. **参考仓准备**:浅克隆 cannbot-knowledge 知识库、asc-devkit(经 `ascendc-docs-search` 清洗)与 cann-samples 到 `<项目>/.cannbot/dependencies/ops-perf-optimize/`,asc-devkit/cann-samples 在项目根暴露同名入口;断网/离线时告警跳过,`CANNBOT_SKIP_DEPENDENCY_REPOS=1` 可整体关闭; | 54 | +2. **参考仓准备**:浅克隆 cannbot-knowledge 知识仓、asc-devkit(经 `ascendc-docs-search` 清洗)与 cann-samples 到 `<项目>/.cannbot/dependencies/ops-perf-optimize/`,asc-devkit/cann-samples 在项目根暴露同名入口。克隆知识仓不等于已准备检索 Skill、资源与索引,需完成下节 consumer 安装;断网/离线时告警跳过,`CANNBOT_SKIP_DEPENDENCY_REPOS=1` 可整体关闭; |
| 55 | 3. **主 Agent 与主提示词**:`AGENTS.md` 作为 `perf-optimize` 主 Agent 安装到客户端 agents 目录(opencode/claude 为 `.opencode/agents/perf-optimize.md`、`.claude/agents/perf-optimize.md`,codex 为 `.codex/agents/perf-optimize.toml`),并以标记块写入项目 `CLAUDE.md`(claude)或 `AGENTS.md`(其他工具);五个阶段仍派发给客户端通用 subagent; | 55 | 3. **主 Agent 与主提示词**:`AGENTS.md` 作为 `perf-optimize` 主 Agent 安装到客户端 agents 目录(opencode/claude 为 `.opencode/agents/perf-optimize.md`、`.claude/agents/perf-optimize.md`,codex 为 `.codex/agents/perf-optimize.toml`),并以标记块写入项目 `CLAUDE.md`(claude)或 `AGENTS.md`(其他工具);五个阶段仍派发给客户端通用 subagent; |
| 56 | 4. **hook 注册**(仅 claude 工具):SessionStart 路由提示注册进 `.claude/settings.json`。 | 56 | 4. **hook 注册**(仅 claude 工具):SessionStart 路由提示注册进 `.claude/settings.json`。 |
| 57 | 57 | ||
| 58 | 命令可以幂等重跑,用于刷新插件或复查安装。各客户端通用参数与安装控制详见[插件安装与工作流](../../script/docs/cannbot-workflows.md)。 | 58 | 命令可以幂等重跑,用于刷新插件或复查安装。各客户端通用参数与安装控制详见[插件安装与工作流](../../script/docs/cannbot-workflows.md)。 |
| 59 | 59 | ||
| 60 | +### 知识库安装与配置 | ||
| 61 | + | ||
| 62 | +知识库用于方案设计和实施约束补证,安装方式参考 [ops-perf-evolution 快速入门](../../plugins-community/ops-perf-evolution/quickstart.md),实际参数以[知识仓当前安装器](https://gitcode.com/cann/cannbot-knowledge/blob/master/install.sh)为准。在同一调优工程中安装 consumer: | ||
| 63 | + | ||
| 64 | +```bash | ||
| 65 | +# 使用插件已克隆的知识仓;opencode 可换成 claude 或 codex | ||
| 66 | +bash /path/to/your/tuning-project/.cannbot/dependencies/ops-perf-optimize/cannbot-knowledge/install.sh \ | ||
| 67 | + opencode /path/to/your/tuning-project consumer | ||
| 68 | +``` | ||
| 69 | + | ||
| 70 | +若自动克隆被跳过,或使用 Marketplace 安装插件,可先检出知识仓: | ||
| 71 | + | ||
| 72 | +```bash | ||
| 73 | +git clone https://gitcode.com/cann/cannbot-knowledge.git /path/to/cannbot-knowledge | ||
| 74 | +bash /path/to/cannbot-knowledge/install.sh opencode /path/to/your/tuning-project consumer | ||
| 75 | +``` | ||
| 76 | + | ||
| 77 | +该安装器安装 `knowledge-query` 与 `ascendc-api-knowledge-query`,保留到完整知识仓的链接,准备运行依赖、文档/固定提交源码与检索索引,并在调优工程 `.cannbot/knowledge.env` 写入知识仓位置。普通检索可通过安装器 `--platform <已确认平台>` 配置缺省平台,任务目标不同时仍须按 Query 规则显式指定。 | ||
| 78 | + | ||
| 79 | +知识仓根是包含 `governance/` 与 `knowledge/` 的目录。可用 `export CANNBOT_KNOWLEDGE_ROOT=/path/to/cannbot-knowledge` 覆盖,或在工程/祖先的 `.cannbot/knowledge.env` 配置同名变量;Query 也可通过真实 Skill 链接定位其知识仓。仅配置路径不能替代完整 consumer 安装,不要独立复制检索 Skill。 | ||
| 80 | + | ||
| 81 | +升级已有工程时,先停止使用旧检索入口,按知识仓安装器提示迁移旧 `knowledge-query` 副本或链接;旧 Marketplace 依赖 `ops-perf-optimize-kb-skills` 也应卸载,避免继续加载 cannbot-skills 中的旧脚本。插件不再依赖该 bundle。 | ||
| 82 | + | ||
| 83 | +知识库不可用时,调优报告记录 `kb_unavailable` 与具体原因,并以无知识增强模式继续;精度与性能验收要求不变。索引缺失、损坏或陈旧交由知识仓安装器/维护者处理,调优阶段不自动重建。有效零命中记录为知识缺口,不视为技术不可行。 | ||
| 84 | + | ||
| 60 | ### 验证安装 | 85 | ### 验证安装 |
| 61 | 86 | ||
| 62 | -统一安装器输出 `Installed ops-perf-optimize@4.1.0 for <tool>`、skills/agents 数量及 quickstart 路径即表示安装完成。也可在目标项目确认 `.agents/skills/`(opencode/codex)或 `.claude/skills/`(claude)下的 27 个 Skill、`.opencode/agents/perf-optimize.md`(claude/codex 为对应 agents 目录)中的主 Agent,以及 `.cannbot/plugins/ops-perf-optimize/` 下的 hooks 资产与 `quickstart.md`;工作流定义和脚本随 `ops-perf-optimize-workflow` Skill 的 `workflows/`、`scripts/` 目录安装。 | 87 | +统一安装器输出 `Installed ops-perf-optimize@4.1.0 for <tool>`、skills/agents 数量及 quickstart 路径即表示插件安装完成。也可在目标项目确认 `.agents/skills/`(opencode/codex)或 `.claude/skills/`(claude)下的 26 个插件 Skill、`.opencode/agents/perf-optimize.md`(claude/codex 为对应 agents 目录)中的主 Agent,以及 `.cannbot/plugins/ops-perf-optimize/` 下的 hooks 资产与 `quickstart.md`;工作流定义和脚本随 `ops-perf-optimize-workflow` Skill 的 `workflows/`、`scripts/` 目录安装。完成知识仓 consumer 安装后,另有两个知识消费 Skill 及 `.cannbot/knowledge.env`。 |
| 88 | + | ||
| 89 | +从调优工程运行一次只读覆盖检查(所有客户端均可使用安装器创建的 `.agents/skills/` 规范入口): | ||
| 90 | + | ||
| 91 | +```bash | ||
| 92 | +cd /path/to/your/tuning-project | ||
| 93 | +python3 .agents/skills/knowledge-query/scripts/knowledge_query.py discover --json | ||
| 94 | +``` | ||
| 95 | + | ||
| 96 | +正常结果包含知识仓 `root` 与实际覆盖计数。调优中的检索流程以[当前 knowledge-query Skill](https://gitcode.com/cann/cannbot-knowledge/tree/master/.agents/skills/knowledge-query)为准:确认任务目标平台 → 按单个决策 `search` → 根据返回的路径、标题和描述选卡 → 阅读全文并按需沿链接补证;复杂性能任务按该 Skill 保存检索审计与真实实验结果。 | ||
| 63 | 97 | ||
| 64 | ## 2. 发起任务 | 98 | ## 2. 发起任务 |
| 65 | 99 | ||
| @@ -14,7 +14,7 @@ description: 用于冻结性能任务的基线 profiling、逐 case 瓶颈诊断 | |||
| 14 | 1. 先按 `ops-perf-acceptance-criteria` 的性能采集路由复用或采集当前基线;聚合指标等简单 profile 信息不足以支撑分析时,在采集阶段按需加载 `ops-perf-profile-feature-extractor` 提取诊断级性能特征(流水图、逐指令时序)。再读取 [analysis-execution.md](references/analysis-execution.md) 完成只读分析。采集阶段可使用隔离探针,分析推导不得重采、重选 case 或修改基线。 | 14 | 1. 先按 `ops-perf-acceptance-criteria` 的性能采集路由复用或采集当前基线;聚合指标等简单 profile 信息不足以支撑分析时,在采集阶段按需加载 `ops-perf-profile-feature-extractor` 提取诊断级性能特征(流水图、逐指令时序)。再读取 [analysis-execution.md](references/analysis-execution.md) 完成只读分析。采集阶段可使用隔离探针,分析推导不得重采、重选 case 或修改基线。 |
| 15 | 2. 读取 `$WORKFLOW_ROOT/workflows/references/source-isolation.md` 的共享源码隔离契约;generalization 先按共享 ratio 口径计算全集结果,再读 [generalization-selection.md](references/generalization-selection.md) 确定性选例。 | 15 | 2. 读取 `$WORKFLOW_ROOT/workflows/references/source-isolation.md` 的共享源码隔离契约;generalization 先按共享 ratio 口径计算全集结果,再读 [generalization-selection.md](references/generalization-selection.md) 确定性选例。 |
| 16 | 3. 仅在静态代码检视确有用途时加载 `ascendc-performance-review`,按其检查点索引只读排查;检查结论作为假设级证据并入本轮分析。 | 16 | 3. 仅在静态代码检视确有用途时加载 `ascendc-performance-review`,按其检查点索引只读排查;检查结论作为假设级证据并入本轮分析。 |
| 17 | -4. 算子族与模板按 `ascendc-performance-best-practices`,策略推导按 `ascendc-perf-optimize`,MC²/多 rank 的指标口径与流水判定按 `ascendc-mc2-best-practice`,具体 API 由 `ascendc-docs-search` 和本机 SDK 核验。方案设计前按信封 `KB_ROOT` 经 `knowledge-query` 检索优化方法、grounding chains 与反模式知识卡,方案须引用支撑卡片 doc-id;`KB_ROOT` 缺失时标注 `kb_unavailable`,按无知识增强继续。调用 `knowledge-query` 前先读其 SKILL 的参数表再组命令;需要脚本消费输出时加 `--json`,并保证 stdout 只有 JSON。 | 17 | +4. 算子族与模板按 `ascendc-performance-best-practices`,策略推导按 `ascendc-perf-optimize`,MC²/多 rank 的指标口径与流水判定按 `ascendc-mc2-best-practice`,具体 API 由 `ascendc-docs-search` 和本机 SDK 核验。方案设计前按信封 `KB_ROOT` 经 `knowledge-query` 检索优化方法、机制与反模式知识卡,方案须引用实际读过的卡片;`KB_ROOT` 缺失时标注 `kb_unavailable`,按无知识增强继续。调用前先读其 SKILL 与 `references/cli.md`,确认任务目标平台后按当前接口组命令;复杂性能任务按其性能优化模式与证据工作流记录审计,参数和输出字段以该 Skill 为准。 |
| 18 | 5. 交付一份 `roundN/analysis.md`、最多三份 exact/forbidden 实施契约和 source-isolation scope;每个调优 case 有瓶颈与目标差距证据,主 Agent 冻结 scope 后交实施。 | 18 | 5. 交付一份 `roundN/analysis.md`、最多三份 exact/forbidden 实施契约和 source-isolation scope;每个调优 case 有瓶颈与目标差距证据,主 Agent 冻结 scope 后交实施。 |
| 19 | 19 | ||
| 20 | 需要调用工具时使用 `$WORKFLOW_SCRIPTS/`;写进度或提交保存点时按需读取 `$WORKFLOW_ROOT/workflows/references/state-reporting.md`。保持现有 phase/round/gen 键,代码与证据身份不变时复用已有结果。阶段内不加载主编排 Skill `ops-perf-optimize-workflow` 或其他阶段 Skill;工程机械能力与共享验证能力按上述路由调用。 | 20 | 需要调用工具时使用 `$WORKFLOW_SCRIPTS/`;写进度或提交保存点时按需读取 `$WORKFLOW_ROOT/workflows/references/state-reporting.md`。保持现有 phase/round/gen 键,代码与证据身份不变时复用已有结果。阶段内不加载主编排 Skill `ops-perf-optimize-workflow` 或其他阶段 Skill;工程机械能力与共享验证能力按上述路由调用。 |
| @@ -18,7 +18,7 @@ | |||
| 18 | - 上一轮 `analysis.md`、`selection.json`(round1 为 absent); | 18 | - 上一轮 `analysis.md`、`selection.json`(round1 为 absent); |
| 19 | - `source-compatibility.md`:公开契约面、工程支持 SoC、目标工程代际隔离风格和证据; | 19 | - `source-compatibility.md`:公开契约面、工程支持 SoC、目标工程代际隔离风格和证据; |
| 20 | - `extraction-manifest.json`:原工程到独立工作工程的文件/依赖/调用入口映射; | 20 | - `extraction-manifest.json`:原工程到独立工作工程的文件/依赖/调用入口映射; |
| 21 | -- 信封 `KB_ROOT`(cannbot-knowledge 知识库根;absent 时本阶段无知识增强); | 21 | +- 信封 `KB_ROOT`(cannbot-knowledge 仓根,包含 `governance/` 与 `knowledge/`;absent 时本阶段无知识增强); |
| 22 | - 目标 SocVersion 与可验证本地 SDK/参考路径。 | 22 | - 目标 SocVersion 与可验证本地 SDK/参考路径。 |
| 23 | 23 | ||
| 24 | 按共享 [performance-collection.md](../../ops-perf-acceptance-criteria/references/performance-collection.md) 校验协议、身份和覆盖。只使用 `mapped_launches[]` 的 case/sample/role/kernel 映射;MC²/多 rank 不套用 application 协议,也不得按目录、kernel 名或 CSV 顺序猜测 case 映射。 | 24 | 按共享 [performance-collection.md](../../ops-perf-acceptance-criteria/references/performance-collection.md) 校验协议、身份和覆盖。只使用 `mapped_launches[]` 的 case/sample/role/kernel 映射;MC²/多 rank 不套用 application 协议,也不得按目录、kernel 名或 CSV 顺序猜测 case 映射。 |
| @@ -27,7 +27,7 @@ | |||
| 27 | 27 | ||
| 28 | 1. 逐 case 记录计算模式、dtype/shape/attrs、bound(VEC/MEM/SCALAR)、关键指标、`total_us` 和证据路径。每个冻结 case 必须恰好出现;spread >10% 标不确定性,不自行重采。按下文“效率与理论上限”计算逐 case 量化证据。多阶段融合算子若聚合指标不足以归因,优先用覆盖目标计算路径的完整仿真流水图定位阶段依赖、掩盖和同步等待,不再叠加消融;无有效仿真图时,才消费已登记的上板阶段隔离证据,其端到端耗时差只表示边际影响,不相加推算可节省耗时。 | 28 | 1. 逐 case 记录计算模式、dtype/shape/attrs、bound(VEC/MEM/SCALAR)、关键指标、`total_us` 和证据路径。每个冻结 case 必须恰好出现;spread >10% 标不确定性,不自行重采。按下文“效率与理论上限”计算逐 case 量化证据。多阶段融合算子若聚合指标不足以归因,优先用覆盖目标计算路径的完整仿真流水图定位阶段依赖、掩盖和同步等待,不再叠加消融;无有效仿真图时,才消费已登记的上板阶段隔离证据,其端到端耗时差只表示边际影响,不相加推算可节省耗时。 |
| 29 | 2. 先按 case 计算模式判定算子族,先按精确 `TARGET_SOCS` 执行两本策略/最佳实践 Skill 的代际前置路由,再读取 `ascendc-performance-best-practices` 对应族中目标适用的说明和模板代码,按决策树选路径。算子名不能锁定单一族;Broadcast、Elementwise、Reduction 分别按实际轴和计算结构判定,数据依赖读地址走 Gather,数据依赖写地址走 Scatter。 | 29 | 2. 先按 case 计算模式判定算子族,先按精确 `TARGET_SOCS` 执行两本策略/最佳实践 Skill 的代际前置路由,再读取 `ascendc-performance-best-practices` 对应族中目标适用的说明和模板代码,按决策树选路径。算子名不能锁定单一族;Broadcast、Elementwise、Reduction 分别按实际轴和计算结构判定,数据依赖读地址走 Gather,数据依赖写地址走 Scatter。 |
| 30 | -3. `KB_ROOT` 存在时,方案设计前加载 `knowledge-query`,固定以 `--knowledge-root "$KB_ROOT"` 执行 `preflight --task "<算子名> <族> <bound 结论与关键指标> 优化方案>"`,读取 `read_first` 中 relevance 为 strong/medium 的卡片;msprof 指标 → 诊断 → 候选方向的 grounding chains、跨算子优化方法与反模式卡用于约束方案空间。KB 检索结论是假设级证据,逐条标 `adopted`/`refuted`/`deferred` 后并入本轮分析,不替代本文件的分析标准和共享 Skill 路由;检索失败降级为 `kb_unavailable`,不阻塞分析。 | 30 | +3. `KB_ROOT` 存在时,方案设计前加载 `knowledge-query` 及其 `references/cli.md`、性能优化模式与证据工作流;以 `--knowledge-root "$KB_ROOT"` 固定知识仓。复用主 Agent 的 discover,以 `TARGET_SOCS` 确认任务目标平台,按该 Skill 的平台识别规则映射,不用本机型号或知识仓缺省平台覆盖任务目标;A2/A3 工程证据复用不代表知识卡可省略平台适用性核对。围绕主导 profiling 信号拆分独立 decision,以实体加一个关键约束的短 query 执行 `search`,按需限定 `ops` / `ascendc` 和已注册的优化、机制、API 或 runbook 类型;准确 API 用 literal,机制或现象用 text,默认 stable。先看返回的 `results` 中 `path` / `local_path`、`title` 和 `description` 选卡,再按绝对 `local_path` 阅读完整正文,核对平台、版本和适用边界,按需沿链接补证;不得把搜索摘要当作已核验知识。KB 检索结论是假设级证据,逐条标 `adopted`/`refuted`/`deferred` 后并入本轮分析,不替代本文件的分析标准和共享 Skill 路由。按 Query 的证据工作流保存独立 decision 的 receipt 与已读卡路径/指纹;有缺口时保留 gap/insufficient,不伪造 covered。退出码 0 的零命中记录知识缺口;参数或索引错误先按具体原因处理,仍不可用时记 `kb_unavailable` 与错误原因,不阻塞分析,也不自动构建索引。 |
| 31 | 4. 策略推导按 `ascendc-perf-optimize` 的 4 步流程执行:Step 1 Tiling 理论建模必选,产出理想 tiling data 作为后续修正对照,并结合标准 1 的 `compute_efficiency` 输出给出理论最优耗时(roofline 上限:`max(字节/带宽, FLOP/算力)`)与距该上限的可达 headroom,作为"值不值得调、最多能到哪"的定量上界;Step 2 仅命中 MC²/通信类算子时执行,按 `ascendc-mc2-best-practice` 的 `references/shared/profiling_mc2.md` 口径判定主导流水与通信隐藏率,只消费基线采集阶段已登记的 TilingData 与隔离测试证据(T_comm/T_compute/R 值),缺失时退回主 Agent 按协议补采,不得修改源码自行补采;Step 3 仅在跨核同步或共享目标写入时分析核间依赖、同步和负载;Step 4 单核流水 bound 诊断结论并入逐 case bound 证据。各步产出的 tiling 修正建议和优化策略直接映射为方案与实施契约 required features,不因流程推导重选 case 或重采性能。 | 31 | 4. 策略推导按 `ascendc-perf-optimize` 的 4 步流程执行:Step 1 Tiling 理论建模必选,产出理想 tiling data 作为后续修正对照,并结合标准 1 的 `compute_efficiency` 输出给出理论最优耗时(roofline 上限:`max(字节/带宽, FLOP/算力)`)与距该上限的可达 headroom,作为"值不值得调、最多能到哪"的定量上界;Step 2 仅命中 MC²/通信类算子时执行,按 `ascendc-mc2-best-practice` 的 `references/shared/profiling_mc2.md` 口径判定主导流水与通信隐藏率,只消费基线采集阶段已登记的 TilingData 与隔离测试证据(T_comm/T_compute/R 值),缺失时退回主 Agent 按协议补采,不得修改源码自行补采;Step 3 仅在跨核同步或共享目标写入时分析核间依赖、同步和负载;Step 4 单核流水 bound 诊断结论并入逐 case bound 证据。各步产出的 tiling 修正建议和优化策略直接映射为方案与实施契约 required features,不因流程推导重选 case 或重采性能。 |
| 32 | 5. 只有族级终选仍使用 SIMT 时才读取 SIMT 指南。不得因为原源码有 `__simt_vf__` 就跳过族级选路。 | 32 | 5. 只有族级终选仍使用 SIMT 时才读取 SIMT 指南。不得因为原源码有 `__simt_vf__` 就跳过族级选路。 |
| 33 | 6. 模板按证据分类:构建契约一致且已有编译证据才是“可直接使用”;上下文/契约待补为“集成边界待验证”;只有说明则是“设计参考”。不得用概念伪代码替代已找到的模板骨架。 | 33 | 6. 模板按证据分类:构建契约一致且已有编译证据才是“可直接使用”;上下文/契约待补为“集成边界待验证”;只有说明则是“设计参考”。不得用概念伪代码替代已找到的模板骨架。 |
| @@ -64,7 +64,7 @@ | |||
| 64 | 不同模板、运行时分支互斥的路径应融合进一个方案;同一分支的互斥策略才拆为并列方案。每套方案必须包含: | 64 | 不同模板、运行时分支互斥的路径应融合进一个方案;同一分支的互斥策略才拆为并列方案。每套方案必须包含: |
| 65 | 65 | ||
| 66 | - 稳定 `scheme_id`、目标瓶颈、Tiling/流水/模板路径、适用分支和逐 case 覆盖; | 66 | - 稳定 `scheme_id`、目标瓶颈、Tiling/流水/模板路径、适用分支和逐 case 覆盖; |
| 67 | -- 支撑知识卡:`kb_cards` 列出方案引用的 doc-id 及各自用途(方向约束/优化方法/反模式),与方案正文可对照;`KB_ROOT` 缺失时写 `kb_unavailable`,不虚构卡片; | 67 | +- 支撑知识卡:`kb_cards` 列出方案引用的 doc-id(使用搜索结果的 Concept `path`)、绝对 `local_path`、`card_sha256` 及各自用途(方向约束/优化方法/反模式),与方案正文及检索 receipt 可对照;只登记实际阅读全文的卡片,不把 Concept ID 当作相对文件名。`KB_ROOT` 缺失时写 `kb_unavailable`,有效零命中则记录知识缺口,不虚构卡片; |
| 68 | - 可证伪的收益假设与复盘条件,写成一行:`预测 <指标+比较方向+数值+case 集>;若观测到 <一次具体观测> 则记录 prediction_missed,供后续方案复盘`;预测未命中不改变已实施候选的门禁与终选资格; | 68 | - 可证伪的收益假设与复盘条件,写成一行:`预测 <指标+比较方向+数值+case 集>;若观测到 <一次具体观测> 则记录 prediction_missed,供后续方案复盘`;预测未命中不改变已实施候选的门禁与终选资格; |
| 69 | - 模板/VF readiness、目标构建契约、最小预检与 API 证据; | 69 | - 模板/VF readiness、目标构建契约、最小预检与 API 证据; |
| 70 | - 上一轮 deferred/落选手段的处置;区分策略机制被证伪、具体实现成本、正确性缺陷和采集无效,一次实现退化不能单独否定整类方向。 | 70 | - 上一轮 deferred/落选手段的处置;区分策略机制被证伪、具体实现成本、正确性缺陷和采集无效,一次实现退化不能单独否定整类方向。 |
| @@ -11,7 +11,7 @@ description: 用于性能任务的隔离方案实施、功能与性能门禁、 | |||
| 11 | 11 | ||
| 12 | ## 执行与交付 | 12 | ## 执行与交付 |
| 13 | 13 | ||
| 14 | -1. 读取 [implementation-execution.md](references/implementation-execution.md) 与 [engineering-constraints.md](references/engineering-constraints.md);消费已冻结方案和 scope,不改原工程或放宽 required features。信封 `KB_ROOT` 存在时,先读取所选方案 `kb_cards` 列出的支撑知识卡并按需经 `knowledge-query` 补充检索实施约束(API 语义、队列同步、精度反模式);`KB_ROOT` 缺失时标注 `kb_unavailable` 继续,不阻塞实施。调用 `knowledge-query` 前先读其 SKILL 的参数表再组命令;需要脚本消费输出时加 `--json`,并保证 stdout 只有 JSON。 | 14 | +1. 读取 [implementation-execution.md](references/implementation-execution.md) 与 [engineering-constraints.md](references/engineering-constraints.md);消费已冻结方案和 scope,不改原工程或放宽 required features。信封 `KB_ROOT` 存在时,先读取所选方案 `kb_cards` 列出的支撑知识卡并按需经 `knowledge-query` 补充检索实施约束(API 语义、队列同步、精度反模式);`KB_ROOT` 缺失时标注 `kb_unavailable` 继续,不阻塞实施。调用前先读其 SKILL 与 `references/cli.md`,确认任务目标平台后按当前接口组命令;复用分析阶段的适用卡片与审计,只对新证据缺口重入检索,按该 Skill 记录真实工程验证结果。 |
| 15 | 2. 按需读取 `$WORKFLOW_ROOT/workflows/references/source-isolation.md` 与 `ops-perf-acceptance-criteria` 的精度、采集和抖动路由;数值与功能故障诊断统一使用 `ascendc-precision-debug`,由本代理执行,不嵌套派发。 | 15 | 2. 按需读取 `$WORKFLOW_ROOT/workflows/references/source-isolation.md` 与 `ops-perf-acceptance-criteria` 的精度、采集和抖动路由;数值与功能故障诊断统一使用 `ascendc-precision-debug`,由本代理执行,不嵌套派发。 |
| 16 | 3. 读取 [selection-and-final.md](references/selection-and-final.md) 执行序列压测、eligible 候选一次性能采集、含 baseline 的唯一终选和 demo 全集验收;generalization 还读取共享 ratio 参考。 | 16 | 3. 读取 [selection-and-final.md](references/selection-and-final.md) 执行序列压测、eligible 候选一次性能采集、含 baseline 的唯一终选和 demo 全集验收;generalization 还读取共享 ratio 参考。 |
| 17 | 4. 每方案独立副本和证据;独立构建/静态检查可并行,设备采集排他。新组合代码是新候选,必须重过完整门禁。 | 17 | 4. 每方案独立副本和证据;独立构建/静态检查可并行,设备采集排他。新组合代码是新候选,必须重过完整门禁。 |
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | 开始前读取派发输入视图、本阶段 Skill、`$WORKFLOW_ROOT/workflows/references/source-isolation.md`、`BASELINE_DIR`、`extraction-manifest.json`、`source-compatibility.md`、`roundN/analysis.md`、实施契约和对应冻结 `source-isolation-<scheme_id>.json`。契约是实施符合性的机器真源:`implementation_mode=exact`、`substitution_policy=forbidden`;`target_socs` 必须与 manifest 一致,公开契约、非目标 SoC 及未涉及模板必须为不可变;required feature 不得因时间、复杂度或风险被删减。此真源范围不包括 `expected_effect`、历史 `abandon_if` 或整体优化目标;它们不得覆盖候选终选规则。正文与契约冲突时停止并给出具体差异;不可自行扩大 scope。 | 7 | 开始前读取派发输入视图、本阶段 Skill、`$WORKFLOW_ROOT/workflows/references/source-isolation.md`、`BASELINE_DIR`、`extraction-manifest.json`、`source-compatibility.md`、`roundN/analysis.md`、实施契约和对应冻结 `source-isolation-<scheme_id>.json`。契约是实施符合性的机器真源:`implementation_mode=exact`、`substitution_policy=forbidden`;`target_socs` 必须与 manifest 一致,公开契约、非目标 SoC 及未涉及模板必须为不可变;required feature 不得因时间、复杂度或风险被删减。此真源范围不包括 `expected_effect`、历史 `abandon_if` 或整体优化目标;它们不得覆盖候选终选规则。正文与契约冲突时停止并给出具体差异;不可自行扩大 scope。 |
| 8 | 8 | ||
| 9 | -信封 `KB_ROOT` 存在时,编码前先消费所选方案在 `analysis.md` 中登记的 `kb_cards`:逐张读取 `$KB_ROOT/<doc-id>`,并按需以 `knowledge-query` 的 `preflight --task "<方案要点> 实施约束"` 补充检索 API 语义、队列/同步与精度反模式。API 证据顺序为知识库 → `ascendc-docs-search` → 本机 SDK:知识卡补充证据与已知坑,不替代 docs-search 与 SDK 核验。实际读取的卡片与用途记入 `scheme-conformance.json` 顶层 `kb_cards`(`[{"doc_id": ..., "purpose": ...}]`);`KB_ROOT` 缺失或检索失败时记 `kb_unavailable`,按无知识增强继续,不阻塞实施。 | 9 | +信封 `KB_ROOT` 存在时,编码前先消费所选方案在 `analysis.md` 中登记的 `kb_cards`:按记录的绝对 `local_path` 阅读全文,核对 `card_sha256`、目标平台和适用边界;Concept `path` 是引用 ID,不拼成 `$KB_ROOT` 下的文件名。旧记录缺少路径或卡片身份改变时,按当前 `knowledge-query` Skill 与 `references/cli.md` 定向 `search` 重新定位并复核,不猜测目录或扩展名。复用分析阶段适用的已读证据,仅对新 API、队列/同步或精度反模式等缺口拆分 decision,确认任务目标平台后补充检索并按返回路径选卡阅读全文。API 证据顺序为知识库 → `ascendc-docs-search` → 本机 SDK:知识卡补充证据与已知坑,不替代 docs-search 与 SDK 核验。实际读取的卡片、路径、指纹与用途记入 `scheme-conformance.json` 顶层 `kb_cards`(`[{"doc_id": ..., "local_path": ..., "card_sha256": ..., "purpose": ...}]`);按 Query 证据工作流关联分析阶段的 state/receipt 与真实功能、性能产物,未覆盖决策保留缺口,不伪造 ready 或验证结果。`KB_ROOT` 缺失或检索失败时记 `kb_unavailable` 和具体原因,按无知识增强继续,不阻塞实施;有效零命中只记录知识缺口。 |
| 10 | 10 | ||
| 11 | ## 实施 | 11 | ## 实施 |
| 12 | 12 | ||
| @@ -12,7 +12,7 @@ description: AscendC 算子性能优化工作流的五阶段主编排入口( | |||
| 12 | 1. 完整读取 [workflow-contract.md](references/workflow-contract.md),这是阶段、派发、恢复和报告的唯一工作流真源。主 Agent 只需掌握编排契约,不预载阶段执行参考。 | 12 | 1. 完整读取 [workflow-contract.md](references/workflow-contract.md),这是阶段、派发、恢复和报告的唯一工作流真源。主 Agent 只需掌握编排契约,不预载阶段执行参考。 |
| 13 | 2. 将当前 Skill 所在目录设为 `SKILL_DIR`,`WORKFLOW_ROOT="$SKILL_DIR"`,`WORKFLOW_SCRIPTS="$WORKFLOW_ROOT/scripts"`;派发入口为 `$WORKFLOW_ROOT/workflows/task-prompts.md`。入口或脚本缺失时返回具体缺口。 | 13 | 2. 将当前 Skill 所在目录设为 `SKILL_DIR`,`WORKFLOW_ROOT="$SKILL_DIR"`,`WORKFLOW_SCRIPTS="$WORKFLOW_ROOT/scripts"`;派发入口为 `$WORKFLOW_ROOT/workflows/task-prompts.md`。入口或脚本缺失时返回具体缺口。 |
| 14 | 3. 已提供 `optimization-request.json` 时调用 `$WORKFLOW_SCRIPTS/prepare_case_sets.py validate-request` 并复用有效确认。需要创建/修复请求时才读 [request-intake.md](references/request-intake.md),一次性补齐缺失信息;不重复确认已授权事项。 | 14 | 3. 已提供 `optimization-request.json` 时调用 `$WORKFLOW_SCRIPTS/prepare_case_sets.py validate-request` 并复用有效确认。需要创建/修复请求时才读 [request-intake.md](references/request-intake.md),一次性补齐缺失信息;不重复确认已授权事项。 |
| 15 | -4. 按编排契约的知识库解析顺序解析一次 `KB_ROOT`(cannbot-knowledge,安装时自动克隆)并全程复用;解析成功且检索索引缺失时按需构建(失败仅告警)。不可用在报告标注 `kb_unavailable: true`,阶段以无知识增强模式继续,不阻塞主线。 | 15 | +4. 按编排契约解析一次 `KB_ROOT`(cannbot-knowledge 仓根,包含 `governance/` 与 `knowledge/`)并全程复用;使用知识仓 consumer 安装的 `knowledge-query` 只读检查覆盖,不在调优期间构建索引。不可用在报告标注 `kb_unavailable: true` 和具体原因,阶段以无知识增强模式继续,不阻塞主线。 |
| 16 | 5. 派发基线评估,接收 `run-manifest.json` 后初始化或恢复 `workflow-state.json`;首次状态操作读取 `$WORKFLOW_ROOT/workflows/references/state-reporting.md`。版本变更时才读取 [migration.md](references/migration.md)。 | 16 | 5. 派发基线评估,接收 `run-manifest.json` 后初始化或恢复 `workflow-state.json`;首次状态操作读取 `$WORKFLOW_ROOT/workflows/references/state-reporting.md`。版本变更时才读取 [migration.md](references/migration.md)。 |
| 17 | 17 | ||
| 18 | ## 编排 | 18 | ## 编排 |
Mplugins-official/ops-perf-optimize/skills/ops-perf-optimize-workflow/references/workflow-contract.md+3-1
| @@ -91,7 +91,9 @@ generalization 保留既有规则: | |||
| 91 | 91 | ||
| 92 | ## 6. 派发、状态与报告 | 92 | ## 6. 派发、状态与报告 |
| 93 | 93 | ||
| 94 | -诊断分析与实施验证的方案设计、方案实施引用 cannbot-knowledge 知识卡。主 Agent 在首次派发需要它的阶段前解析一次 `KB_ROOT` 并全程复用,按以下顺序:环境变量 `CANNBOT_KNOWLEDGE_ROOT`(已设置且目录存在)→ 从项目根 glob `.cannbot/dependencies/*/cannbot-knowledge/knowledge`(取第一个含 `ops/ascendc` 子目录的匹配)→ 运行已安装 `knowledge-query` Skill 的 `discover`。解析成功且检索索引缺失时按需构建(`knowledge_query.py --knowledge-root "$KB_ROOT" build`,失败仅告警,不影响卡片直读)。知识库不可用(依赖仓克隆被跳过、离线或解析失败)不是阻塞项:信封省略 `KB_ROOT`,阶段标注 `kb_unavailable`,按无知识增强继续,不降低精度与性能验收要求;主 Agent 在报告中登记该状态。 | 94 | +诊断分析与实施验证的方案设计、方案实施引用 cannbot-knowledge 知识卡。使用知识仓自身 `install.sh <tool> <project> consumer` 安装的 `knowledge-query`,不使用 cannbot-skills 中的旧版副本。主 Agent 在首次派发需要它的阶段前读取该 Skill 与 `references/cli.md`,解析一次 `KB_ROOT` 并全程复用:优先按 Query 自身规则使用环境变量 `CANNBOT_KNOWLEDGE_ROOT`、当前目录及祖先中的 `.cannbot/knowledge.env`、真实 Skill 所在知识仓;未配置且尚未定位时,可检查项目下 `.cannbot/dependencies/*/cannbot-knowledge`,或同级检出的 cannbot-knowledge,并显式交给 Query。`KB_ROOT` 必须是包含 `governance/` 与 `knowledge/` 的仓根绝对路径,不是 `knowledge/` Bundle 根;显式配置无效时报告配置错误,不静默改用别的仓。 |
| 95 | + | ||
| 96 | +首次进入该知识仓运行 `discover --json`,使用其返回的 `root` 与真实覆盖信息;同一任务、同一知识根且索引指纹未变时复用。Query 只读已准备的索引;索引缺失、损坏或 stale 时记录具体错误,由知识仓安装器或维护者准备,不在调优阶段自动重建或扫描全库兜底。知识库不可用(Skill 未安装、依赖仓克隆被跳过、离线、配置或索引错误)不是阻塞项:信封省略 `KB_ROOT`,阶段标注 `kb_unavailable`,按无知识增强继续,不降低精度与性能验收要求;主 Agent 在报告中登记原因与恢复方式。有效零命中保留为当前决策的知识缺口,不等同于知识库不可用,更不能作为技术不可行的证据。 | ||
| 95 | 97 | ||
| 96 | 读取 `$WORKFLOW_ROOT/workflows/task-prompts.md`,按 ROLE 只取对应模板;通用信封的字段定义以该稳定派发入口为准。传入 WORKFLOW_ROOT、WORKFLOW_SCRIPTS、REQUEST、RUN_MANIFEST、WORKFLOW_STATE、TUNING_MODE、TARGET_SOCS、ROUND、CODE_DIR、KB_ROOT(或省略)、输入/输出、ACCEPTANCE 和条件技能;不把整个编排契约复制给 subagent。 | 98 | 读取 `$WORKFLOW_ROOT/workflows/task-prompts.md`,按 ROLE 只取对应模板;通用信封的字段定义以该稳定派发入口为准。传入 WORKFLOW_ROOT、WORKFLOW_SCRIPTS、REQUEST、RUN_MANIFEST、WORKFLOW_STATE、TUNING_MODE、TARGET_SOCS、ROUND、CODE_DIR、KB_ROOT(或省略)、输入/输出、ACCEPTANCE 和条件技能;不把整个编排契约复制给 subagent。 |
| 97 | 99 | ||
Mplugins-official/ops-perf-optimize/skills/ops-perf-optimize-workflow/workflows/prompts/analysis.md+1-1
| @@ -14,7 +14,7 @@ TUNING_MODE: <standard|generalization> | |||
| 14 | TARGET_SOCS: <exact list from RUN_MANIFEST> | 14 | TARGET_SOCS: <exact list from RUN_MANIFEST> |
| 15 | ROUND: <N> | 15 | ROUND: <N> |
| 16 | CODE_DIR: <current baseline absolute path> | 16 | CODE_DIR: <current baseline absolute path> |
| 17 | -KB_ROOT: <cannbot-knowledge knowledge root for analysis/implementation, or absent> | 17 | +KB_ROOT: <absolute cannbot-knowledge repository root containing governance/ and knowledge/, or absent> |
| 18 | INPUT_ARTIFACTS: | 18 | INPUT_ARTIFACTS: |
| 19 | <standard: performance-tuning-cases.csv absolute path> | 19 | <standard: performance-tuning-cases.csv absolute path> |
| 20 | <generalization: roundN/generalization-tuning-cases.csv, competitor-performance.csv and current ratio-analysis.json absolute paths> | 20 | <generalization: roundN/generalization-tuning-cases.csv, competitor-performance.csv and current ratio-analysis.json absolute paths> |
Mplugins-official/ops-perf-optimize/skills/ops-perf-optimize-workflow/workflows/prompts/baseline.md+1-1
| @@ -14,7 +14,7 @@ TUNING_MODE: <standard|generalization, from REQUEST before freeze> | |||
| 14 | TARGET_SOCS: <exact list from REQUEST, then RUN_MANIFEST> | 14 | TARGET_SOCS: <exact list from REQUEST, then RUN_MANIFEST> |
| 15 | ROUND: absent | 15 | ROUND: absent |
| 16 | CODE_DIR: <isolated evaluation workspace absolute path> | 16 | CODE_DIR: <isolated evaluation workspace absolute path> |
| 17 | -KB_ROOT: <cannbot-knowledge knowledge root for analysis/implementation, or absent> | 17 | +KB_ROOT: <absolute cannbot-knowledge repository root containing governance/ and knowledge/, or absent> |
| 18 | INPUT_ARTIFACTS: | 18 | INPUT_ARTIFACTS: |
| 19 | <original source and existing inventories absolute paths> | 19 | <original source and existing inventories absolute paths> |
| 20 | <confirmed reference configuration and any existing reference measurements> | 20 | <confirmed reference configuration and any existing reference measurements> |
Mplugins-official/ops-perf-optimize/skills/ops-perf-optimize-workflow/workflows/prompts/generation.md+2-2
| @@ -16,7 +16,7 @@ TUNING_MODE: standard | |||
| 16 | TARGET_SOCS: <exact list from RUN_MANIFEST> | 16 | TARGET_SOCS: <exact list from RUN_MANIFEST> |
| 17 | ROUND: absent | 17 | ROUND: absent |
| 18 | CODE_DIR: <source code absolute path> | 18 | CODE_DIR: <source code absolute path> |
| 19 | -KB_ROOT: <cannbot-knowledge knowledge root for analysis/implementation, or absent> | 19 | +KB_ROOT: <absolute cannbot-knowledge repository root containing governance/ and knowledge/, or absent> |
| 20 | INPUT_ARTIFACTS: | 20 | INPUT_ARTIFACTS: |
| 21 | <operator interface absolute path> | 21 | <operator interface absolute path> |
| 22 | <performance-full-cases.csv absolute path> | 22 | <performance-full-cases.csv absolute path> |
| @@ -45,7 +45,7 @@ TUNING_MODE: generalization | |||
| 45 | TARGET_SOCS: <exact list from RUN_MANIFEST> | 45 | TARGET_SOCS: <exact list from RUN_MANIFEST> |
| 46 | ROUND: absent | 46 | ROUND: absent |
| 47 | CODE_DIR: <source code absolute path> | 47 | CODE_DIR: <source code absolute path> |
| 48 | -KB_ROOT: <cannbot-knowledge knowledge root for analysis/implementation, or absent> | 48 | +KB_ROOT: <absolute cannbot-knowledge repository root containing governance/ and knowledge/, or absent> |
| 49 | INPUT_ARTIFACTS: | 49 | INPUT_ARTIFACTS: |
| 50 | <operator interface and generation constraints absolute paths> | 50 | <operator interface and generation constraints absolute paths> |
| 51 | OUTPUT_ARTIFACTS: | 51 | OUTPUT_ARTIFACTS: |
| @@ -14,7 +14,7 @@ TUNING_MODE: <standard|generalization> | |||
| 14 | TARGET_SOCS: <exact list from RUN_MANIFEST> | 14 | TARGET_SOCS: <exact list from RUN_MANIFEST> |
| 15 | ROUND: <N> | 15 | ROUND: <N> |
| 16 | CODE_DIR: <isolated round workspace absolute path> | 16 | CODE_DIR: <isolated round workspace absolute path> |
| 17 | -KB_ROOT: <cannbot-knowledge knowledge root for analysis/implementation, or absent> | 17 | +KB_ROOT: <absolute cannbot-knowledge repository root containing governance/ and knowledge/, or absent> |
| 18 | INPUT_ARTIFACTS: | 18 | INPUT_ARTIFACTS: |
| 19 | <roundN/analysis.md absolute path> | 19 | <roundN/analysis.md absolute path> |
| 20 | <up to three implementation-contract-<scheme_id>.json absolute paths> | 20 | <up to three implementation-contract-<scheme_id>.json absolute paths> |
| @@ -14,7 +14,7 @@ TUNING_MODE: <standard|generalization> | |||
| 14 | TARGET_SOCS: <exact list from RUN_MANIFEST> | 14 | TARGET_SOCS: <exact list from RUN_MANIFEST> |
| 15 | ROUND: absent | 15 | ROUND: absent |
| 16 | CODE_DIR: <original project absolute path, restricted to frozen integration scope> | 16 | CODE_DIR: <original project absolute path, restricted to frozen integration scope> |
| 17 | -KB_ROOT: <cannbot-knowledge knowledge root for analysis/implementation, or absent> | 17 | +KB_ROOT: <absolute cannbot-knowledge repository root containing governance/ and knowledge/, or absent> |
| 18 | INPUT_ARTIFACTS: | 18 | INPUT_ARTIFACTS: |
| 19 | <final_optimized, ARCHIVE_MANIFEST.md and full demo validation reports> | 19 | <final_optimized, ARCHIVE_MANIFEST.md and full demo validation reports> |
| 20 | <functional-full inventory, performance-full inventory and performance-targets.json> | 20 | <functional-full inventory, performance-full inventory and performance-targets.json> |
| @@ -14,7 +14,7 @@ TUNING_MODE: <standard|generalization> | |||
| 14 | TARGET_SOCS: <exact list from RUN_MANIFEST> | 14 | TARGET_SOCS: <exact list from RUN_MANIFEST> |
| 15 | ROUND: absent | 15 | ROUND: absent |
| 16 | CODE_DIR: <isolated preparation workspace absolute path> | 16 | CODE_DIR: <isolated preparation workspace absolute path> |
| 17 | -KB_ROOT: <cannbot-knowledge knowledge root for analysis/implementation, or absent> | 17 | +KB_ROOT: <absolute cannbot-knowledge repository root containing governance/ and knowledge/, or absent> |
| 18 | INPUT_ARTIFACTS: | 18 | INPUT_ARTIFACTS: |
| 19 | <original project and target operator absolute paths> | 19 | <original project and target operator absolute paths> |
| 20 | <mode-specific frozen case inventory and performance-targets.json> | 20 | <mode-specific frozen case inventory and performance-targets.json> |
| @@ -35,7 +35,7 @@ TUNING_MODE: <standard|generalization> | |||
| 35 | TARGET_SOCS: <exact list from RUN_MANIFEST> | 35 | TARGET_SOCS: <exact list from RUN_MANIFEST> |
| 36 | ROUND: <N or absent> | 36 | ROUND: <N or absent> |
| 37 | CODE_DIR: <assigned isolated absolute path> | 37 | CODE_DIR: <assigned isolated absolute path> |
| 38 | -KB_ROOT: <cannbot-knowledge knowledge root for analysis/implementation, or absent> | 38 | +KB_ROOT: <absolute cannbot-knowledge repository root containing governance/ and knowledge/, or absent> |
| 39 | INPUT_ARTIFACTS: <absolute paths, one per line> | 39 | INPUT_ARTIFACTS: <absolute paths, one per line> |
| 40 | OUTPUT_ARTIFACTS: <absolute paths, one per line> | 40 | OUTPUT_ARTIFACTS: <absolute paths, one per line> |
| 41 | ACCEPTANCE: <mechanically verifiable completion conditions> | 41 | ACCEPTANCE: <mechanically verifiable completion conditions> |
| @@ -74,7 +74,7 @@ def test_knowledge_query_note_defers_to_its_own_skill() -> None: | |||
| 74 | """不把 knowledge-query 的 CLI 细节钉死在本插件文案里。""" | 74 | """不把 knowledge-query 的 CLI 细节钉死在本插件文案里。""" |
| 75 | for skill in ("ops-perf-analysis", "ops-perf-implementation"): | 75 | for skill in ("ops-perf-analysis", "ops-perf-implementation"): |
| 76 | entry = read(ROOT / "skills" / skill / "SKILL.md") | 76 | entry = read(ROOT / "skills" / skill / "SKILL.md") |
| 77 | - assert "先读其 SKILL 的参数表" in entry, skill | 77 | + assert "先读其 SKILL 与 `references/cli.md`" in entry, skill |
| 78 | - assert "`--json`" in entry, skill | 78 | + assert "确认任务目标平台" in entry, skill |
| 79 | assert "--limit" not in entry, skill | 79 | assert "--limit" not in entry, skill |
| 80 | assert "--platform" not in entry, skill | 80 | assert "--platform" not in entry, skill |
| @@ -10,9 +10,9 @@ | |||
| 10 | 10 | ||
| 11 | """cannbot-knowledge wiring: install-time dependency and graceful stage references. | 11 | """cannbot-knowledge wiring: install-time dependency and graceful stage references. |
| 12 | 12 | ||
| 13 | -Install clones the knowledge base and the knowledge-query Skill; the dispatch | 13 | +The plugin clones the knowledge repository; its consumer installer owns Query |
| 14 | -envelope carries KB_ROOT; analysis cites kb_cards per scheme and implementation | 14 | +and index preparation. Dispatch carries the repository root; stages consume |
| 15 | -consumes them, both degrading to kb_unavailable without blocking the workflow. | 15 | +selected full cards and degrade to kb_unavailable without blocking the workflow. |
| 16 | """ | 16 | """ |
| 17 | 17 | ||
| 18 | import json | 18 | import json |
| @@ -47,7 +47,7 @@ def read(path: Path) -> str: | |||
| 47 | return path.read_text(encoding="utf-8") | 47 | return path.read_text(encoding="utf-8") |
| 48 | 48 | ||
| 49 | 49 | ||
| 50 | -def test_install_declares_cannbot_knowledge_and_the_query_skill() -> None: | 50 | +def test_install_declares_knowledge_repo_without_bundling_legacy_query() -> None: |
| 51 | dependencies = json.loads(read(ROOT / "plugin-install.json"))["dependencies"] | 51 | dependencies = json.loads(read(ROOT / "plugin-install.json"))["dependencies"] |
| 52 | knowledge = [dep for dep in dependencies if dep["name"] == "cannbot-knowledge"] | 52 | knowledge = [dep for dep in dependencies if dep["name"] == "cannbot-knowledge"] |
| 53 | assert knowledge and knowledge[0]["repository"].endswith("cannbot-knowledge.git") | 53 | assert knowledge and knowledge[0]["repository"].endswith("cannbot-knowledge.git") |
| @@ -55,29 +55,29 @@ def test_install_declares_cannbot_knowledge_and_the_query_skill() -> None: | |||
| 55 | # .cannbot/dependencies, unlike the asc-devkit/cann-samples reference repos. | 55 | # .cannbot/dependencies, unlike the asc-devkit/cann-samples reference repos. |
| 56 | assert "expose" not in knowledge[0] | 56 | assert "expose" not in knowledge[0] |
| 57 | sources = json.loads(read(ROOT / "plugin-sources.json"))["skills"] | 57 | sources = json.loads(read(ROOT / "plugin-sources.json"))["skills"] |
| 58 | - assert "plugins-community/cannbot-knowledge/skills/knowledge-query" in sources | 58 | + assert not any("cannbot-knowledge" in source for source in sources) |
| 59 | manifest = json.loads(read(ROOT / ".claude-plugin" / "plugin.json")) | 59 | manifest = json.loads(read(ROOT / ".claude-plugin" / "plugin.json")) |
| 60 | - assert manifest["dependencies"] == [ | 60 | + assert manifest["dependencies"] == ["ops-perf-optimize-skills"] |
| 61 | - "ops-perf-optimize-skills", | ||
| 62 | - "ops-perf-optimize-kb-skills", | ||
| 63 | - ] | ||
| 64 | 61 | ||
| 65 | 62 | ||
| 66 | -def test_marketplace_bundle_covers_exactly_the_declared_skills() -> None: | 63 | +def test_marketplace_does_not_reinstall_the_legacy_query_bundle() -> None: |
| 67 | marketplace = json.loads(read(REPO / ".claude-plugin" / "marketplace.json")) | 64 | marketplace = json.loads(read(REPO / ".claude-plugin" / "marketplace.json")) |
| 68 | entries = {entry["name"]: entry for entry in marketplace["plugins"]} | 65 | entries = {entry["name"]: entry for entry in marketplace["plugins"]} |
| 69 | manifest = json.loads(read(ROOT / ".claude-plugin" / "plugin.json")) | 66 | manifest = json.loads(read(ROOT / ".claude-plugin" / "plugin.json")) |
| 70 | - bundle = entries["ops-perf-optimize-kb-skills"] | 67 | + assert "ops-perf-optimize-kb-skills" not in entries |
| 71 | - assert bundle["category"] == "skills" | ||
| 72 | - assert bundle["source"]["path"] == "plugins-community/cannbot-knowledge/skills" | ||
| 73 | - assert bundle["skills"] == ["./knowledge-query"] | ||
| 74 | assert entries["ops-perf-optimize"]["dependencies"] == manifest["dependencies"] | 68 | assert entries["ops-perf-optimize"]["dependencies"] == manifest["dependencies"] |
| 69 | + quickstart = read(ROOT / "quickstart.md") | ||
| 70 | + assert "install.sh opencode /path/to/your/tuning-project consumer" in quickstart | ||
| 71 | + assert ".cannbot/knowledge.env" in quickstart | ||
| 72 | + assert "discover --json" in quickstart | ||
| 75 | 73 | ||
| 76 | 74 | ||
| 77 | def test_dispatch_envelope_carries_kb_root() -> None: | 75 | def test_dispatch_envelope_carries_kb_root() -> None: |
| 78 | - prompts = read(ROOT / "skills" / "ops-perf-optimize-workflow" / "workflows" / "task-prompts.md") | 76 | + prompts = read( |
| 77 | + ROOT / "skills" / "ops-perf-optimize-workflow" / "workflows" / "task-prompts.md" | ||
| 78 | + ) | ||
| 79 | assert ( | 79 | assert ( |
| 80 | - "KB_ROOT: <cannbot-knowledge knowledge root for analysis/implementation, or absent>" | 80 | + "KB_ROOT: <absolute cannbot-knowledge repository root containing governance/ and knowledge/, or absent>" |
| 81 | in prompts | 81 | in prompts |
| 82 | ) | 82 | ) |
| 83 | assert "按编排契约解析一次后全程复用" in prompts | 83 | assert "按编排契约解析一次后全程复用" in prompts |
| @@ -92,17 +92,24 @@ def test_dispatch_envelope_carries_kb_root() -> None: | |||
| 92 | "preparation", | 92 | "preparation", |
| 93 | ): | 93 | ): |
| 94 | assert "KB_ROOT:" in read( | 94 | assert "KB_ROOT:" in read( |
| 95 | - ROOT / "skills" / "ops-perf-optimize-workflow" / "workflows" / "prompts" / f"{filename}.md" | 95 | + ROOT |
| 96 | - ), ( | 96 | + / "skills" |
| 97 | - filename | 97 | + / "ops-perf-optimize-workflow" |
| 98 | - ) | 98 | + / "workflows" |
| 99 | + / "prompts" | ||
| 100 | + / f"{filename}.md" | ||
| 101 | + ), filename | ||
| 99 | 102 | ||
| 100 | 103 | ||
| 101 | def test_contract_defines_bootstrap_order_and_non_blocking_degradation() -> None: | 104 | def test_contract_defines_bootstrap_order_and_non_blocking_degradation() -> None: |
| 102 | contract = read(CONTRACT) | 105 | contract = read(CONTRACT) |
| 103 | assert "环境变量 `CANNBOT_KNOWLEDGE_ROOT`" in contract | 106 | assert "环境变量 `CANNBOT_KNOWLEDGE_ROOT`" in contract |
| 104 | - assert ".cannbot/dependencies/*/cannbot-knowledge/knowledge" in contract | 107 | + assert ".cannbot/knowledge.env" in contract |
| 105 | - assert "`knowledge-query` Skill 的 `discover`" in contract | 108 | + assert ".cannbot/dependencies/*/cannbot-knowledge`" in contract |
| 109 | + assert "不是 `knowledge/` Bundle 根" in contract | ||
| 110 | + assert "discover --json" in contract | ||
| 111 | + assert "不在调优阶段自动重建或扫描全库兜底" in contract | ||
| 112 | + assert "有效零命中" in contract | ||
| 106 | assert "KB_ROOT(或省略)" in contract | 113 | assert "KB_ROOT(或省略)" in contract |
| 107 | assert "信封省略 `KB_ROOT`" in contract | 114 | assert "信封省略 `KB_ROOT`" in contract |
| 108 | assert "kb_unavailable" in contract | 115 | assert "kb_unavailable" in contract |
| @@ -119,12 +126,13 @@ def test_analysis_designs_schemes_on_cited_kb_cards() -> None: | |||
| 119 | assert "kb_unavailable" in analysis | 126 | assert "kb_unavailable" in analysis |
| 120 | execution = read(ANALYSIS_EXEC) | 127 | execution = read(ANALYSIS_EXEC) |
| 121 | assert "信封 `KB_ROOT`" in execution | 128 | assert "信封 `KB_ROOT`" in execution |
| 122 | - assert ( | ||
| 123 | - '`preflight --task "<算子名> <族> <bound 结论与关键指标> 优化方案>"`' | ||
| 124 | - in execution | ||
| 125 | - ) | ||
| 126 | assert '`--knowledge-root "$KB_ROOT"`' in execution | 129 | assert '`--knowledge-root "$KB_ROOT"`' in execution |
| 127 | - assert "read_first" in execution | 130 | + assert "`TARGET_SOCS`" in execution |
| 131 | + assert "`search`" in execution | ||
| 132 | + assert "`local_path` 阅读完整正文" in execution | ||
| 133 | + assert "Concept `path`" in execution | ||
| 134 | + assert "`card_sha256`" in execution | ||
| 135 | + assert "receipt" in execution | ||
| 128 | # Retrieved cards are hypothesis-level evidence, not a replacement for the | 136 | # Retrieved cards are hypothesis-level evidence, not a replacement for the |
| 129 | # analysis standards or the shared Skill routes. | 137 | # analysis standards or the shared Skill routes. |
| 130 | assert "不替代本文件的分析标准和共享 Skill 路由" in execution | 138 | assert "不替代本文件的分析标准和共享 Skill 路由" in execution |
| @@ -141,7 +149,10 @@ def test_implementation_consumes_scheme_cards_before_coding() -> None: | |||
| 141 | execution = read(IMPL_EXEC) | 149 | execution = read(IMPL_EXEC) |
| 142 | assert "信封 `KB_ROOT` 存在时" in execution | 150 | assert "信封 `KB_ROOT` 存在时" in execution |
| 143 | assert "编码前先消费所选方案" in execution | 151 | assert "编码前先消费所选方案" in execution |
| 144 | - assert "$KB_ROOT/<doc-id>" in execution | 152 | + assert "绝对 `local_path` 阅读全文" in execution |
| 153 | + assert "`card_sha256`" in execution | ||
| 154 | + assert "不拼成 `$KB_ROOT` 下的文件名" in execution | ||
| 155 | + assert "复用分析阶段适用的已读证据" in execution | ||
| 145 | # The KB complements but never replaces API verification. | 156 | # The KB complements but never replaces API verification. |
| 146 | assert "知识库 → `ascendc-docs-search` → 本机 SDK" in execution | 157 | assert "知识库 → `ascendc-docs-search` → 本机 SDK" in execution |
| 147 | assert "不替代 docs-search 与 SDK 核验" in execution | 158 | assert "不替代 docs-search 与 SDK 核验" in execution |
| @@ -149,6 +160,18 @@ def test_implementation_consumes_scheme_cards_before_coding() -> None: | |||
| 149 | assert "kb_unavailable" in execution | 160 | assert "kb_unavailable" in execution |
| 150 | 161 | ||
| 151 | 162 | ||
| 163 | +def test_runtime_instructions_do_not_use_retired_query_commands_or_fields() -> None: | ||
| 164 | + for path in (CONTRACT, ENTRY_SKILL, ANALYSIS, ANALYSIS_EXEC, IMPL, IMPL_EXEC): | ||
| 165 | + content = read(path) | ||
| 166 | + for retired in ( | ||
| 167 | + "preflight --task", | ||
| 168 | + "read_first", | ||
| 169 | + "$KB_ROOT/<doc-id>", | ||
| 170 | + 'knowledge_query.py --knowledge-root "$KB_ROOT" build', | ||
| 171 | + ): | ||
| 172 | + assert retired not in content, (path, retired) | ||
| 173 | + | ||
| 174 | + | ||
| 152 | def test_wrapper_stays_thin_and_carries_no_kb_bootstrap() -> None: | 175 | def test_wrapper_stays_thin_and_carries_no_kb_bootstrap() -> None: |
| 153 | wrapper = read(WRAPPER) | 176 | wrapper = read(WRAPPER) |
| 154 | assert "CANNBOT_KNOWLEDGE_ROOT" not in wrapper | 177 | assert "CANNBOT_KNOWLEDGE_ROOT" not in wrapper |
| @@ -480,6 +480,10 @@ for (const source of sources) { | |||
| 480 | for (const source of sources) { | 480 | for (const source of sources) { |
| 481 | test(`${source} installs ops-perf-optimize workflow tools`, () => { | 481 | test(`${source} installs ops-perf-optimize workflow tools`, () => { |
| 482 | const { target, result: installResult } = installPlugin("ops-perf-optimize", "opencode", source); | 482 | const { target, result: installResult } = installPlugin("ops-perf-optimize", "opencode", source); |
| 483 | + // Query is installed by the knowledge repository's consumer installer, | ||
| 484 | + // preserving its Contract dependencies and prepared index. | ||
| 485 | + assert.equal(existsSync(join(skillRoot(target, "opencode"), "knowledge-query")), false); | ||
| 486 | + assert.equal(readPluginRecord(target, "opencode", "ops-perf-optimize").skills.length, 26); | ||
| 483 | const pluginRoot = join(target, ".cannbot", "plugins", "ops-perf-optimize"); | 487 | const pluginRoot = join(target, ".cannbot", "plugins", "ops-perf-optimize"); |
| 484 | const workflowRoot = join(skillRoot(target, "opencode"), "ops-perf-optimize-workflow"); | 488 | const workflowRoot = join(skillRoot(target, "opencode"), "ops-perf-optimize-workflow"); |
| 485 | const workflowScripts = join(workflowRoot, "scripts"); | 489 | const workflowScripts = join(workflowRoot, "scripts"); |