fix: harden initialization races and manuscript splitting - #2
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
该 PR 主要增强“初始化书籍(init-book)”在并发/竞态场景下的安全性与可回滚性,并改进“导入稿件分章(chapter-splitter)”对 Markdown 一级标题的边界识别,从而避免把正文中的普通 H1 误当作结构分隔符。
Changes:
init-book:mkdir竞态下仅在目标确为目录时容忍EEXIST,并确保 content/runtime 根目录必须由本次初始化创建,否则拒绝继续写入;回滚时避免把并发产生的父目录纳入“本次创建”的所有权集合。chapter-splitter:将“任意 Markdown H1”改为“仅特定非章节说明类 H1”作为分隔标记,保留章节正文中的任意 H1,同时继续隔离明确的尾注/作者的话等片段。- 测试与 CI:新增竞态与标题保留回归测试;新增 GitHub Actions 在 PR/主分支运行
npm ci+npm run check。
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/schema-boundaries.test.ts | 修正无效实体用例的 id/type 组合,使测试与实体类型匹配 |
| tests/unit/init-book-race.test.ts | 新增目录并发创建/同名文件占用的回归测试,覆盖 EEXIST 竞态分支 |
| tests/unit/chapter-splitter.test.ts | 新增“正文 H1 保留 + 明确尾注隔离/章间说明隔离”的分章回归测试 |
| src/project/init-book.ts | 加固目录创建竞态处理与根目录并发占用拒绝逻辑,并调整回滚所有权记录 |
| src/project/chapter-splitter.ts | 将结构标记从“任意 H1”收敛为“特定非章节说明 H1”,避免误切分正文 |
| .github/workflows/ci.yml | 新增 CI 工作流,运行 npm run check |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ACBBZ
commented
Jul 29, 2026
ACBBZ
left a comment
Owner
Author
There was a problem hiding this comment.
已完成逐文件审查,未发现阻塞性问题。
重点核对:
EEXIST仅在目标是非符号链接真实目录时被接受,且并发创建的父目录不会被纳入本次回滚所有权;最终内容根和运行时根必须由本次初始化创建。- 任意一级 Markdown 标题会保留在章节正文中,只有明确的前言、作者说明、尾注、附录等标题仍作为待确认片段切分。
- 新增回归测试覆盖目录竞争、同名普通文件、正文 H1、尾注和章节间作者说明。
- Schema 边界测试已按 ID 类型对齐。
- CI 在仓库实际依赖
/usr/bin/lockf的 macOS 运行环境中通过npm ci、TypeScript 检查和完整测试。
当前登录账号与 PR 作者相同,GitHub 不允许自我 APPROVE,因此以 COMMENT 形式记录审查结论;结论为可合并。
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.
Summary
mkdironly when they are real directoriesnpm run checkRisk controls
EEXISTtargets remain rejected第N章headings and explicit non-chapter metadata headingsValidation
npm ciandnpm run checkon pull requests