feat: add safe native Mentor PDF exporter and tested portable UI

This commit is contained in:
Codex committed 2026-10-09 21:32:31 +08:00
1 parent 10a87d2cee
commit d4928af5b6
33 files changed
+2267 -13

No files matched your search

@@ -17,24 +17,34 @@
### Task 1: Native feasibility and safe core
Files: tests/test_scanner.py, tests/test_profiles.py, tests/test_workspace.py, src/mentor_pdf_export/{models,scanner,profiles,workspace,engine}.py, tools/live_smoke.py.
Interfaces: scan_projects(root, excluded_roots=()) -> list[ProjectInfo]; ExportOptions; prepare_workspace(project, run_dir, options) -> Path; build_command(engine, project, output, options) -> list[str].
- [ ] Write failing tests for recursive discovery/pruning, profile values and safe isolated workspace.
- [ ] Run pytest and confirm intended import/behavior failures.
- [ ] Implement core, rerun tests until passing.
- [ ] Export the local PON example ONLY from a copied workspace; retain logs and compare source hashes.
- [ ] Investigate config/ICT/font behavior and record actual evidence/limits.
- [x] Write failing tests for recursive discovery/pruning, profile values and safe isolated workspace.
- [x] Run pytest and confirm intended import/behavior failures.
- [x] Implement core, rerun tests until passing.
- [x] Export the local PON example ONLY from a copied workspace; retain logs and compare source hashes.
- [x] Investigate config/ICT/font behavior and record actual evidence/limits.
### Task 2: Reliable export transaction
Files: tests/test_exporter.py, tests/test_engine.py, src/mentor_pdf_export/{exporter,validation}.py.
Interfaces: Exporter.export(ProjectInfo, output_root, ExportOptions, cancel_event, event_callback) -> ExportResult; discover_engine(explicit=None) -> Path.
- [ ] Write failing tests for valid/invalid PDF, old output preservation, source changes, timeout/cancel and duplicate names.
- [ ] Run red, implement, then run green.
- [ ] Include isolated output staging, JSON run report and retained stdout/stderr.
- [x] Write failing tests for valid/invalid PDF, old output preservation, source changes, timeout/cancel and duplicate names.
- [x] Run red, implement, then run green.
- [x] Include isolated output staging, JSON run report and retained stdout/stderr.
### Task 3: Simple UI and portable release
Files: tests/test_ui.py, src/mentor_pdf_export/{ui,__main__,cli}.py, packaging/mentor_pdf.spec, README.md, Start-MentorPDF.cmd.
Interfaces: MainWindow(root=None, output=None); CLI --self-check/--export/--ui-smoke.
- [ ] Write failing Qt tests: scan checkbox state, settings locking, background signals, cancel, result display.
- [ ] Implement minimal usable UI; run Qt tests and capture window PNG.
- [ ] Run real UI batch on sample copy, render native PDF and check pages/text/colors visually.
- [ ] Build PyInstaller onedir and ZIP; execute packaged --self-check and UI smoke.
- [ ] Run full tests, review diff and document release limitations/evidence.
- [x] Write failing Qt tests: scan checkbox state, settings locking, background signals, cancel, result display.
- [x] Implement minimal usable UI; run Qt tests and capture window PNG.
- [x] Run real UI batch on sample copy, render native PDF and check pages/text/colors visually.
- [x] Build PyInstaller onedir and ZIP; execute packaged --self-check and UI smoke.
- [x] Run full tests, review diff and document release limitations/evidence.
## Safety review fix ledger
- Findings 1/2: whole-queue output/run path preflight and protected CLI report/screenshot destinations; unknown existing JSON is never overwritten. Added red/green regressions.
- Finding 3: suspended Windows process creation, explicit inherited handle whitelist, Job assignment before ResumeThread; worker scope engine.py/test_engine.py only, 20 engine tests passing.
- Findings 4/5: final source check before publication; fsync atomic commit/result pre-record, old output backup; post-commit record failures return traceable uncertain status. Batch pre-record prevents running without durable queue identity.
- Cleanup residual: staging exists/stat is inside guarded cleanup so result recording still happens after filesystem errors. Red/green test added.
- Full test suite after fixes: 63 passed; final rebuilt executable QA remains the release gate.
- Ruling: preserve the new feat/pdf-export repository in the requested directory, without merge/push/worktree cleanup; this task is local test-tool delivery, not shared-branch integration.
Final release gate: rebuilt exe native UI queue success2/failure0 (17 pages each), source209 files and library hashes unchanged, ZIP CRC and extracted clean-PATH self-check passed. Independent scoped review found no remaining blockers in the reported cases.
@@ -22,3 +22,7 @@ ui.py PySide6 工程表、配置栏、后台串行任务、日志、停止、结
## 验收
自动测试覆盖扫描、配置、复制路径安全、错误处理、输出冲突、取消超时、PDF 校验、UI 按钮与后台任务。真实副本导出记录参数、配置、日志、页数与源工程前后指纹,并渲染检查。UI 做 offscreen 行为测试及真实窗口截图。打包后 exe 至少做自检和 UI 启动,不以源码运行替代 exe 验收。
## 验证后补充的约束
实际示例工程的网络中心库不可达;提供用户显式指定对应本地 .lmc 的配置,仅覆盖副本的 CentralLibrary。白底彩色样张部分中文批注乱码与低对比度未消除,版本标为测试版,不能宣称出图质量全部通过。
全队列统一校验输出/运行路径,CLI 报告和截图不能写入源工程;CLI 不覆盖非工具 JSON。所有决定发布的源核验在提交之前完成;预先 fsync/原子记录提交状态,覆盖旧输出先留备份。提交后记录故障返回可追溯待核验,不丢弃当前结果。Windows 引擎必须在执行前进入自有 Job,不允许先启动再绑定的子进程逃逸竞态。