Merged
feat(governance): 登记 Runtime API 通用功能标签 #184
Hou_jialinAdd on 9 days ago
feat(governance): 登记 Runtime API 通用功能标签 #184
Merged
Total: 4 files changed+104-1
| @@ -61,6 +61,16 @@ SYNTHETIC_API_METADATA = { | |||
| 61 | "platforms": ["a2"], | 61 | "platforms": ["a2"], |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | +EXECUTION_TOPIC_TAGS = ( | ||
| 65 | + "topic.implementation.resource_lifecycle", | ||
| 66 | + "topic.implementation.resource_query", | ||
| 67 | + "topic.implementation.error_handling", | ||
| 68 | + "topic.implementation.cross_process", | ||
| 69 | + "topic.implementation.callback", | ||
| 70 | + "topic.implementation.kernel_launch", | ||
| 71 | + "topic.implementation.api_layer.cpp_api", | ||
| 72 | +) | ||
| 73 | + | ||
| 64 | 74 | ||
| 65 | def load_lint_module(): | 75 | def load_lint_module(): |
| 66 | spec = importlib.util.spec_from_file_location("knowledge_lint_test", LINT) | 76 | spec = importlib.util.spec_from_file_location("knowledge_lint_test", LINT) |
| @@ -624,6 +634,19 @@ class RouteContractTests(unittest.TestCase): | |||
| 624 | ] | 634 | ] |
| 625 | self.assertEqual([], self.contract.validate_card(relative, metadata, "# Synthetic API\n")) | 635 | self.assertEqual([], self.contract.validate_card(relative, metadata, "# Synthetic API\n")) |
| 626 | 636 | ||
| 637 | + def test_execution_topic_tags_accept_only_registered_values(self) -> None: | ||
| 638 | + for tag in EXECUTION_TOPIC_TAGS: | ||
| 639 | + for prefix in ("runtime", "ops/ascendc"): | ||
| 640 | + with self.subTest(tag=tag, domain=prefix): | ||
| 641 | + relative = Path(f"knowledge/{prefix}/apis/synthetic_api.md") | ||
| 642 | + metadata = {**SYNTHETIC_API_METADATA, "tags": ["task.lookup", tag]} | ||
| 643 | + self.assertEqual([], self.contract.validate_card( | ||
| 644 | + relative, metadata, "# Synthetic API\n", | ||
| 645 | + )) | ||
| 646 | + metadata["tags"] = ["task.lookup", tag + ".unknown"] | ||
| 647 | + issues = self.contract.validate_card(relative, metadata, "# Synthetic API\n") | ||
| 648 | + self.assertIn("tag.unknown", {issue.code for issue in issues}) | ||
| 649 | + | ||
| 627 | def test_api_source_headers_reject_invalid_shape(self) -> None: | 650 | def test_api_source_headers_reject_invalid_shape(self) -> None: |
| 628 | relative = Path("knowledge/ops/ascendc/apis/synthetic_api.md") | 651 | relative = Path("knowledge/ops/ascendc/apis/synthetic_api.md") |
| 629 | for value in ([123], "not-a-list", [""], ["include/a.h", "include/a.h"]): | 652 | for value in ([123], "not-a-list", [""], ["include/a.h", "include/a.h"]): |
| @@ -222,6 +222,54 @@ class RetrievalCaseTests(unittest.TestCase): | |||
| 222 | 222 | ||
| 223 | 223 | ||
| 224 | class RetrievalIndexTests(unittest.TestCase): | 224 | class RetrievalIndexTests(unittest.TestCase): |
| 225 | + def test_execution_topic_filters_are_exact_and_conjunctive(self) -> None: | ||
| 226 | + topics = ( | ||
| 227 | + "topic.implementation.resource_lifecycle", | ||
| 228 | + "topic.implementation.resource_query", | ||
| 229 | + ) | ||
| 230 | + with tempfile.TemporaryDirectory() as temporary: | ||
| 231 | + root = Path(temporary) | ||
| 232 | + make_root(root) | ||
| 233 | + runtime = root / "knowledge/runtime/apis" | ||
| 234 | + runtime.mkdir(parents=True) | ||
| 235 | + (runtime / "unrelated.md").write_text(SYNTHETIC_CARD, encoding="utf-8") | ||
| 236 | + for tag in topics: | ||
| 237 | + (runtime / f"{tag.rsplit('.', 1)[1]}.md").write_text( | ||
| 238 | + SYNTHETIC_CARD.replace("topic.compilation", tag), encoding="utf-8", | ||
| 239 | + ) | ||
| 240 | + built = run_index(root, "build") | ||
| 241 | + self.assertEqual(0, built.returncode, built.stderr) | ||
| 242 | + command = [sys.executable, str(QUERY), "--knowledge-root", str(root), "search", | ||
| 243 | + "--query", "Synthetic API", "--domain", "runtime", "--type", "apis", | ||
| 244 | + "--platform", "a2", "--match", "literal", "-k", "20"] | ||
| 245 | + | ||
| 246 | + def search(*filters): | ||
| 247 | + return subprocess.run([*command, *filters], capture_output=True, text=True) | ||
| 248 | + | ||
| 249 | + unfiltered = search() | ||
| 250 | + self.assertEqual(0, unfiltered.returncode, unfiltered.stderr) | ||
| 251 | + self.assertEqual(len(topics) + 1, json.loads(unfiltered.stdout)["count"]) | ||
| 252 | + for tag in topics: | ||
| 253 | + with self.subTest(tag=tag): | ||
| 254 | + result = search("--tag", tag, "--task", "lookup") | ||
| 255 | + self.assertEqual(0, result.returncode, result.stderr) | ||
| 256 | + self.assertEqual( | ||
| 257 | + [f"runtime/apis/{tag.rsplit('.', 1)[1]}"], | ||
| 258 | + [hit["path"] for hit in json.loads(result.stdout)["results"]], | ||
| 259 | + ) | ||
| 260 | + invalid = search("--tag", tag + ".unknown") | ||
| 261 | + self.assertEqual(2, invalid.returncode) | ||
| 262 | + self.assertIn("unknown tag", invalid.stderr) | ||
| 263 | + for filters in ( | ||
| 264 | + ("--tag", "topic.implementation"), | ||
| 265 | + ("--tag", topics[0], "--tag", topics[1]), | ||
| 266 | + ("--tag", topics[0], "--task", "implementation"), | ||
| 267 | + ): | ||
| 268 | + with self.subTest(filters=filters): | ||
| 269 | + result = search(*filters) | ||
| 270 | + self.assertEqual(0, result.returncode, result.stderr) | ||
| 271 | + self.assertEqual([], json.loads(result.stdout)["results"]) | ||
| 272 | + | ||
| 225 | def test_kirin_api_filter_keeps_platform_boundaries(self) -> None: | 273 | def test_kirin_api_filter_keeps_platform_boundaries(self) -> None: |
| 226 | with tempfile.TemporaryDirectory() as temporary: | 274 | with tempfile.TemporaryDirectory() as temporary: |
| 227 | root = Path(temporary) | 275 | root = Path(temporary) |
| @@ -389,7 +389,7 @@ tags: | |||
| 389 | description: 强化学习、rollout、奖励与策略更新 | 389 | description: 强化学习、rollout、奖励与策略更新 |
| 390 | topic.checkpointing: | 390 | topic.checkpointing: |
| 391 | dimension: topic | 391 | dimension: topic |
| 392 | - description: Checkpoint 保存、恢复、切分与重计算 | 392 | + description: 状态检查点与快照的保存、恢复,以及模型检查点切分与重计算 |
| 393 | topic.multimodal: | 393 | topic.multimodal: |
| 394 | dimension: topic | 394 | dimension: topic |
| 395 | description: 多模态模型、输入与跨模态处理 | 395 | description: 多模态模型、输入与跨模态处理 |
| @@ -486,6 +486,9 @@ tags: | |||
| 486 | topic.implementation.api_layer.c_api: | 486 | topic.implementation.api_layer.c_api: |
| 487 | dimension: topic | 487 | dimension: topic |
| 488 | description: C API | 488 | description: C API |
| 489 | + topic.implementation.api_layer.cpp_api: | ||
| 490 | + dimension: topic | ||
| 491 | + description: C++ 接口、命名空间、模板与重载封装 | ||
| 489 | topic.implementation.api_layer.high_level_api: | 492 | topic.implementation.api_layer.high_level_api: |
| 490 | dimension: topic | 493 | dimension: topic |
| 491 | description: 高阶 API | 494 | description: 高阶 API |
| @@ -498,9 +501,21 @@ tags: | |||
| 498 | topic.implementation.atomic: | 501 | topic.implementation.atomic: |
| 499 | dimension: topic | 502 | dimension: topic |
| 500 | description: 原子操作与原子写入 | 503 | description: 原子操作与原子写入 |
| 504 | + topic.implementation.callback: | ||
| 505 | + dimension: topic | ||
| 506 | + description: 回调函数的注册、注销与触发,以及 Host 函数调度 | ||
| 507 | + topic.implementation.cross_process: | ||
| 508 | + dimension: topic | ||
| 509 | + description: 进程间资源共享、句柄导入导出与访问授权 | ||
| 501 | topic.implementation.debugging: | 510 | topic.implementation.debugging: |
| 502 | dimension: topic | 511 | dimension: topic |
| 503 | description: 实现阶段的调试方法 | 512 | description: 实现阶段的调试方法 |
| 513 | + topic.implementation.error_handling: | ||
| 514 | + dimension: topic | ||
| 515 | + description: 错误码、异常信息、错误状态处理与故障恢复 | ||
| 516 | + topic.implementation.kernel_launch: | ||
| 517 | + dimension: topic | ||
| 518 | + description: 核函数二进制、启动参数与主机侧核任务下发 | ||
| 504 | topic.implementation.masking: | 519 | topic.implementation.masking: |
| 505 | dimension: topic | 520 | dimension: topic |
| 506 | description: 掩码控制与条件执行 | 521 | description: 掩码控制与条件执行 |
| @@ -513,6 +528,12 @@ tags: | |||
| 513 | topic.implementation.pipeline: | 528 | topic.implementation.pipeline: |
| 514 | dimension: topic | 529 | dimension: topic |
| 515 | description: 流水并行与阶段组织 | 530 | description: 流水并行与阶段组织 |
| 531 | + topic.implementation.resource_lifecycle: | ||
| 532 | + dimension: topic | ||
| 533 | + description: 资源对象的初始化、创建、绑定、引用配对与销毁 | ||
| 534 | + topic.implementation.resource_query: | ||
| 535 | + dimension: topic | ||
| 536 | + description: 资源数量、标识、属性、能力与执行状态查询 | ||
| 516 | topic.implementation.synchronization: | 537 | topic.implementation.synchronization: |
| 517 | dimension: topic | 538 | dimension: topic |
| 518 | description: 同步原语与执行顺序 | 539 | description: 同步原语与执行顺序 |
| @@ -1,5 +1,16 @@ | |||
| 1 | # 2026-10-29 | 1 | # 2026-10-29 |
| 2 | 2 | ||
| 3 | +## [21:06] update | 登记 Runtime API 通用功能标签 | ||
| 4 | + | ||
| 5 | +### Summary | ||
| 6 | + | ||
| 7 | +登记 7 个领域中立的功能标签,支持后续 Runtime API 卡按功能检索。 | ||
| 8 | + | ||
| 9 | +### Details | ||
| 10 | + | ||
| 11 | +- 新增资源生命周期、资源查询、错误处理、跨进程、回调、核任务与 C++ API 标签,并明确 checkpointing 的状态快照含义。 | ||
| 12 | +- 在现有治理与索引测试中补充标签接受、非法子标签拒绝、精确过滤及 AND 组合回归。 | ||
| 13 | + | ||
| 3 | ## [11:41] update | 注册 310B 并统一平台映射 | 14 | ## [11:41] update | 注册 310B 并统一平台映射 |
| 4 | 15 | ||
| 5 | ### Summary | 16 | ### Summary |