已合并
fix(governance): 按 checkout 实际文件类型校验本地源码导航 #65
fix(governance): 按 checkout 实际文件类型校验本地源码导航 #65
已合并
bububu创建于 9月26日
bububu
9月26日

描述

严格来源导航此前以本地 Git 路径末级名称是否包含 . 推断文件类型,导致固定提交 checkout 中实际存在的无扩展名文件无法作为源码文件链接;checkout 缺失时也会按名称猜测类型,与离线规则不符。

修复仅使用已登记来源和当前 checkout 状态:checkout 缺失时不作无法验证的文件类型判断;checkout 存在时通过 Path.is_file() / Path.is_dir() 确认来源和导航目标的真实类型,且只接受同仓库、同 revision 的实际文件链接。

逐 hunk 对账:

  • governance/contracts/checks/source_navigation.py:离线缺失 checkout 时跳过类型检查;恢复时按实际文件/目录类型判定,导航目标必须是文件。
  • evals/test_source_resources.py:真实临时 Git fixture 覆盖无扩展名 Makefile 可通过、带点号的目录不能冒充文件、缺失 checkout 不误报。
  • logs/2026-09-26.md:记录本次治理修复、回归结果及统一门禁的真实结果。

关联的Issue

关联 issue #14

测试

  • PYTHONDONTWRITEBYTECODE=1 python3 -m unittest evals.test_source_resources

    Ran 33 tests in 20.417s
    OK (skipped=1)
    
  • git diff --check:退出码 0,无输出。

  • ruff check governance/contracts/checks/source_navigation.py evals/test_source_resources.py:未运行,环境返回 /bin/bash: ruff: command not found(退出码 127);未安装全局依赖。

  • bash check.sh:未通过,退出码 1。真实摘要:严格 Lint checked=7718 P0=0 P1=0 P2=0;索引同步 Checked 662 indexes, stale 0;索引构建与完整验证均为 ok cards=7056;29 个检索断言全部 PASS、recall@k=1.000 MRR=1.000,但性能门槛失败:

    FAIL quality: p95=3771.6ms above 1000ms
    QUALITY recall@k=1.000 MRR=1.000 p95=3771.6ms cases=29
    

    该失败与本次源码导航修复无关;check.sh 因 set -e 未继续执行后续全库 unittest、ruff 和 shell 检查。本 PR 不改动无关检索逻辑。

文档更新

无。现有 governance/specs/schemas.md 已明确规定离线缺根时只校验路径形状。

类型标签

当前PR是否有AI参与:

[x] 是

__1. Agent平台信息: Codex CLI 0.153.4
__2. 模型信息: gpt-5.6-luna
__3. Prompt摘要: 根据已提交 issue #14 独立复现无扩展名源码误报,核对离线规范,实施并定向验证最小修复。

希望检视人员了解:

  1. 人工参与说明:账号所有者已提交并指派 issue #14,提供 case 证据并授权 PR-first;本轮独立复现、行号与规范核对、回归和门禁由 Agent 实际执行。未声称人工另行运行测试或修改代码。
  2. 修改范围与 issue #14 一致;未调整导航语法、Registry、知识卡或检索行为。
  3. 目标回归测试通过;全库门禁唯一已观测失败为检索评测 p95 性能阈值,具体真实输出见“测试”。
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 bububu 的贡献)
Bbububu
9月26日 创建了 pull request,commit d0b78f63
Bbububu
9月26日 关联了issue:[Bug-Report|缺陷反馈]: 严格来源导航将无扩展名的已登记 Git 源码文件误判为非文件
CANN-robot
CANN-robot成员
9月26日 评论:

Hi @LiJianhao2, welcome to submitting your first PR to cannbot-knowledge!

PR Merge Steps

1. CLA Signing

If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.

2. CI Check

Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.

3. Code Review

After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.

likedislike
CANN-robotCANN-robot成员
9月26日 添加了label:ai-co-authored
CANN-robotCANN-robot成员
9月26日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
9月26日 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/cannbot-knowledge ✅ qq_41667743, zhanghz1 (2/2) ✅ qq_41667743 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

LiJianhao2, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
bububu
9月26日 评论:

compile

likedislike
Bbububu
9月26日 预合并成功(commit_id: 6dc486717836ca78cd1871d0625a45759dc41332)
CANN-robot
CANN-robot成员
9月26日 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
9月26日 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
9月26日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
9月26日 添加了label:ci-pipeline-passed
zhanghz1
zhanghz1成员
28 天前 评论:

/lgtm

likedislike
汪超成员
28 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
28 天前 添加了label:lgtmapproved
CANN-robotCANN-robot成员
28 天前 合入了pull request