Skip to content

Reject invalid translated chunks before merge#15

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-4fae
Draft

Reject invalid translated chunks before merge#15
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-4fae

Conversation

@cursor

@cursor cursor Bot commented Jun 2, 2026

Copy link
Copy Markdown

Bug and impact

  • Whitespace-only translated chunks were treated as existing outputs by selective planning and then silently skipped during merge.
  • Severely truncated chunks only emitted warnings, allowing output.md and final book artifacts to be generated with missing or heavily incomplete content.

Root cause

  • run_state.py only checked output file size, not trimmed text content.
  • manifest.validate_for_merge() downgraded suspiciously short outputs to warnings and did not reject whitespace-only outputs.
  • merge_markdown_files() continued after read/blank failures and could write a partial merged file.

Fix

  • Reject unreadable and whitespace-only outputs in manifest validation, merge, and run-state recording/planning.
  • Promote <10% output-size checks to hard errors for substantive source chunks while preserving warnings for tiny chunks.
  • Add regression tests for blank outputs, stale output.md removal, legacy merge fallback, and suspiciously short manifest outputs.

Validation

  • python3 -m unittest tests.test_run_state tests.test_merge_and_build -v
  • python3 -m unittest discover -s tests -p 'test_*.py' -v (210 tests passed, 3 skipped)
  • python3 -m compileall scripts tests
  • Replayed the original blank-output repro: merge now fails, no output.md is written, and run-state schedules the blank chunk for translation.
  • Ran the standard Alice mock full pipeline: merge/HTML/DOCX/PDF succeeded; EPUB failed due to the documented Ubuntu Calibre 7.6.0 packaging bug.
Open in Web View Automation 

Co-authored-by: Rainman <deusyu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant