extradoc: fix insertTable footprint undercount corrupting downstream edits - #76
Open
cassus wants to merge 1 commit into
Open
extradoc: fix insertTable footprint undercount corrupting downstream edits#76cassus wants to merge 1 commit into
cassus wants to merge 1 commit into
Conversation
…edits _batch_insert_size_from_reqs undercounted an insertTable's footprint by one newline: it returned the bare table span 1 + rows*(1+cols*2) instead of span + 1. That value feeds post_insert_shift for matched-element updates, so every update op downstream of an inserted table was shifted one char early, garbling in-paragraph edits (append landing past the paragraph \n, mid-word drift). A controlled real-API probe confirms an insertTable shifts following content by exactly one \n around the table span — the pre-split newline mid-document or the trailing carrier at end-of-segment, never both. The correct footprint is 3 + rows*(1+cols*2), matching _final_doc_size_from_reqs. The offline mock hid the bug because mock/table_ops emitted both newlines; it now adds the carrier only when nothing (or another table) follows, so the oracle models the real span+1. Toy simulator in the story-content test updated to match. Verified: full suite green; a real SUGGEST push of an 8-amendment document now accepts 227/227 paragraphs in order (was 7/227 before the fix).
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.
Closes #74.
What
_batch_insert_size_from_reqs(reconcile_v3/lower.py) undercounted thefootprint of a body
insertTableby one\n, returning the bare tableskeleton
1 + rows*(1+cols*2)instead of3 + rows*(1+cols*2). That valuefeeds
post_insert_shift, so every matched-paragraph update op downstream ofan inserted table (in the same batch) was shifted one char early — corrupting
in-paragraph edits (text landing mid-word or past the wrong
\n).The corrected
3 + rows*(1+cols*2)matches the sibling accounting in_final_doc_size_from_reqs(2 + rows*(1+cols*2) + 1), which was alreadycorrect; the two functions had silently disagreed by exactly the missing
newline. See #74 for the full root-cause, the real-API probe, and why the
offline mock hid the bug.
Changes
reconcile_v3/lower.py— footprint corrected to3 + rows*(1+cols*2).mock/table_ops.py::handle_insert_table— emit the trailing carrierparagraph only when nothing (or another table) follows, so the offline
oracle models the real span+1 instead of masking the bug.
tests/reconcile_v3/test_story_content_update_bug.py— toy simulatorupdated to the real footprint; exercises the regression.
Verification
to exact desired text, in order (was 7/227 garbled before the fix).