Repository navigation
chore(hygiene): 评估修正批次 1 —— 运行态产物忽略缺口 + 入口路由与文档口径(5 处 + 守卫测试) - #140
Merged
Merged
Conversation
来源:docs/reviews/2026-10-16-swarm-audit-master.md(P1-2)、2026-10-16-repo-structure-and-docs-audit.md(P2-1/P2-2/P2-4/P2-8)。全部是「已定案、不需决策、无危险」的条目;代码级修复(P0-1/P0-2/P1-1)与需决策项一律未动。
- .gitignore(P1-2):补 /launch.log、/launch.log.*、/lan-address.txt 三条根级规则。桌面壳把这三个产物写在数据目录,而便携模式(DELECTOR_PORTABLE=1)或源码运行时数据目录就是仓库根(data_dir_bootstrap.resolve_data_dir → program_dir())⇒ 与 *.db* 同一威胁模型:一次 git add -A 会把运行态日志(启动堆栈/端口冲突详情)与内网 IP 提交进历史。编排者实测三者由 NOT-IGNORED → IGNORED,且历史从未进过这三个文件。
- .gitignore(P2-4):补 .superpowers/ 根级兜底(原靠自身嵌套 .gitignore 内容 * 自忽略;工具升级重建目录时可能整棵漏进 status)。
- .env.example(P2-8):数据目录注释改正。实测 resolve_data_dir({}) = %LOCALAPPDATA%\DeLector(Linux/macOS: ~/.local/share/DeLector),**不是**仓库根;只有 DELECTOR_PORTABLE=1 才回落程序所在目录。
- CLAUDE.md(P2-1):新增「文档路由(先读这个)」一节指向 AGENTS.md —— 此前只读 CLAUDE.md 的会话完全不知道 architecture/ops 存在(AGENTS.md:3 自称「同 CLAUDE.md 形态」但 CLAUDE.md 没有路由表)。
- .cursorrules + .agent-rules.md(P2-2):沉淀草稿目录 08-Inbox → 99-Inbox(实测 08-Inbox 不存在、99-Inbox 存在;四份入口文件此前两个地址)。
守卫:tests/test_server.py 新增 test_runtime_artifacts_protected_by_gitignore —— 沿用 test_keystore_protected_by_gitignore_and_hook 惯例,另加两层:① git check-ignore 实证(防规则写错/被重新包含);② 与 desktop.py 的 LOG_FILE_NAME/LOG_BACKUP_SUFFIX/LAN_ADDRESS_FILE_NAME 常量对账(防改了常量忘了改规则)。变异自证:删掉三条规则 ⇒ 该测试红。
门禁:守卫 1 passed;ruff check . 全绿;mypy --strict delector 67 files 0;mypy --follow-imports=skip tests/test_server.py 0;前端契约闸过。
全量 pytest 1983 passed + 2 skipped + 2 failed —— 两条失败已用 git stash 在 master 态复现,证实是 tests/conftest.py:16-19 明文记载的「根目录有库 ⇒ test_save_wb_state_cost 迁移闸拒绝运行 ⇒ 本地红/CI 绿」既有分歧,与本 PR 无关;未删用户库文件(属危险操作,留待用户处置)。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
用户睡觉期间自主推进的一批低风险修正:全部来自已定稿的评估报告(
docs/reviews/2026-10-16-*.md),标准是「已定案、不需用户决策、无危险操作」。代码级修复(swarm audit 的 P0-1 还原丢表 / P0-2 退出挂死 / P1-1 密钥进备份)与需决策项(P1-1 分支纪律机械闸、P2-7.gitattributesCRLF 契约、P2-3 design-system 状态)一律未动,留给用户醒后决定。.gitignore.superpowers/根级兜底.gitignore.env.exampleCLAUDE.md缺文档路由CLAUDE.md.cursorrules、.agent-rules.md重点:P1-2(本轮唯一 P1)
.gitignore漏了桌面壳的三个运行态产物。威胁链已实测:这与
.gitignore:21-24自己写下的威胁模型("一次git add -A就会把用户数据提交进历史")完全同类,而.githooks/pre-commit的文件名黑名单不含.log/.txt,钩子拦不住。好消息:
git log --all -- launch.log lan-address.txt为空 —— 这三个文件从未进过历史,本轮是纯预防。守卫测试(防回归,且有判别力)
tests/test_server.py::test_runtime_artifacts_protected_by_gitignore,沿用仓里test_keystore_protected_by_gitignore_and_hook的惯例,另加两层:git check-ignore实证(不只查规则字符串)—— 防规则写错或被后续规则重新包含;desktop.py常量对账(LOG_FILE_NAME/LOG_BACKUP_SUFFIX/LAN_ADDRESS_FILE_NAME)—— 防改了常量却忘了改忽略规则。变异自证:删掉三条规则 ⇒ 该测试红(判别力成立,非空转)。
门禁(本地实测)
关于那 2 条 failed(
tests/test_save_wb_state_cost.py):已用git stash回到 master 态复现同样 2 failed ⇒ 与本 PR 无关。它们是tests/conftest.py:16-19明文记载的既有分歧:「根目录有库 ⇒preflight_data_dir迁移闸拒绝运行 ⇒ 本地红、CI 绿(CI 是干净克隆)」。修它需要删仓库根的用户库文件 —— 属危险操作,未做,留待用户处置(建议:把根目录delector.db/progress.db确认已迁移到%LOCALAPPDATA%\DeLector后再删,或按README「数据目录与旧版迁移」的口径走)。未做清单(留给用户决策)
f49d359推红事故)—— 需定 CI job 的白名单口径,且gh无workflowscope ⇒ 合并要走 SSH 本地--no-ff。.gitattributesCRLF 契约 —— 会改变 Linux/macOS clone 的行尾行为,需用户拍板。git gc/ P2-3 design-system 状态定夺。