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.