Repository navigation
Commit dc50953
authored
* fix: author-filtered accept_all/reject_all resolve only that author's elements (ROADMAP.md #75)
accept_all(author=A) and reject_all(author=A) selected revisions by author
but resolved them by w:id against an index holding every author's elements.
Where a producer repeats a w:id across authors (LibreOffice does, and the
corpus has such files), the id lookup returned the other author's element:
reject_all(author="A") deleted B's inserted text and accept_all(author="A")
made it permanent, both reporting 2.
_revision_element_index gains an optional author parameter and _resolve_all
passes it, so a filtered call has no other author's element to land on. The
filter uses list_revisions' own author expression -- a missing w:author reads
as "Unknown" -- so the index and the listing cannot disagree about who owns
an element, which is what would otherwise turn the fix into a silent no-op.
The group/changeset path (_resolve_ids) needs no author scoping: a member id
is never a duplicated one, since _reconstruct_groups bars every occurrence of
a repeated w:id from every group and _seed_max_change_id keeps a freshly
allocated id above every id already in the file.
* test: pin author-filtered resolution against duplicate w:ids across authors (ROADMAP.md #75)
Flips the pin that documented the defect (accept_all's filtered pass no longer
resolves another author's same-id revision as collateral) and adds the exact
ROADMAP shape -- B's w:ins w:id="7" before A's w:del w:id="7" -- with the
data-loss case, the accept counterpart, both unfiltered paths (so the scoping
cannot regress into over-filtering), and a count-equals-listed-rows check.
test_unattributed_revision_resolves_under_the_unknown_author covers the other
half of the index's author expression: dropping the "Unknown" fallback leaves
accept_all(author="Unknown") returning 0 on an unattributed revision, with the
revision still pending and no warning raised, and passed every other test.
TestGroupResolutionWithDuplicateIds pins why the group/changeset path needs no
author scoping: both duplicate rows report group_id and changeset_id None, the
neighbouring real group resolves exactly its own member, and the duplicated id
is not a group or changeset id either.
* docs: state that author= resolution holds across duplicate w:ids (ROADMAP.md #75)
The "author= filters process each author's changes independently" bullet now
says the guarantee survives a producer repeating a w:id across authors.
* fix: key the w:id index on the id the listing reports (ROADMAP.md #75)
The index keyed on the raw w:id attribute while every lookup asks for
str(int(w:id)) and the listing reports int(w:id), so a nonconforming
w:id="007" listed as id 7 and was reachable by nothing: accept_all() returned
0, left it pending, and reported a clean document. Nothing warned, because a
mark with a numeric id is not part of the unhandled honesty floor -- and
groups_are_dead() read the live group as dead, which reaps its note comment.
Both sides now normalize on _adjudicable_id: the index keys on str of it and
drops elements that have none (nothing id-keyed can reach those, and
_unhandled_elements already reports them), and the fresh scan in
_find_revision_element compares the parsed id instead of the raw string.
Every consumer already looked ids up in the normalized form.
_revision_author joins _adjudicable_id in dom.py as the one definition of the
other half of a revision's identity, replacing five copies of
`getAttribute("w:author") or "Unknown"` in listing.py. That makes the
index-and-listing agreement this fix rests on structural rather than a
docstring claim backed by one regression test.
* test: ask for an unallocated group id rather than a revision id (ROADMAP.md #75)
test_unknown_id_still_raises passed for the wrong reason: it asked
accept_group/accept_changeset for id 7 -- a w:id -- and group and changeset
ids come from their own counters, so it raised only because this fixture's
counters never reach 7, and would have started testing the opposite thing had
they. It now asks for an id past the one actually allocated.
DUPLICATE_ID_BODY builds its runs with the file's own _ins_xml/_del_xml
helpers, which emit byte-identical XML, instead of hand-writing them.
* docs: note the per-id duplicate-w:id caveat and file the adjacent defects
The duplicate-w:id guarantee belongs to accept_all/reject_all alone:
accept_revision(id)/reject_revision(id) take only the id, so a duplicated one
resolves whichever element comes first in the document. SKILL.md recommended
the per-id pattern with no caveat; it now points at the bulk call or the row's
group_id when an id is shared.
Files three defects the PR #96 multi-review turned up, all pre-existing and
each needing its own change and regression test:
- #83 the per-id half of #75, with a zero-cost ambiguity test the manager
already computes
- #84 _rejoin_paragraph drops the tail paragraph's w:pPr, destroying another
author's paragraph-mark revisions uncounted
- #85 marks recorded inside a change record list as live revisions
* fix: resolving revision id None must match nothing (ROADMAP.md #75)
Keying the fresh scan on _adjudicable_id made None match: the parse returns
None for exactly the marks no id-keyed call can reach, so an unguarded
comparison handed back the first of them. list_unhandled_revisions() reports
id=None for such a row, so this was reachable from the library's own output --
reject_revision(None) returned True and destroyed the mark's text, where
before it returned False. The index path never matched (no "None" key), so the
two lookup paths disagreed as well.
get_markup_text renders the adjudicable id too, so the one view that names
revision ids in text names the id accept_revision actually takes ("?" when
there is none) rather than the raw attribute.
Tests: id None resolves nothing through either verb and leaves the mark and
its text in place; and author scoping still holds for ids that collide only
once parsed (B's w:id="007" against A's w:id="7"), the duplicate-id class that
normalizing the key widened.
* docs: correct the duplicate-w:id guidance and sync docs/api.md
The per-id caveat advised falling back to the row's group_id, which is exactly
what a duplicated id does not have: _reconstruct_groups bars every occurrence
from grouping, as this PR's own TestGroupResolutionWithDuplicateIds asserts.
Two rows sharing an id in list_revisions() is the signal instead, and the
author-filtered bulk calls are the way to resolve them.
docs/api.md carried neither the author-scoping guarantee nor the per-id
caveat; its accept_all/reject_all/accept_revision/reject_revision sections now
match SKILL.md, as every prior change to this prose has kept them.
ROADMAP #75 no longer describes the fixed behaviour as current, and records
why the w:id index was scoped by author instead of the filed element-identity
suggestion. #83's fix direction named _reconstruct_groups as the sole writer
of an explicit None group; _adopt_split_tail also writes one for an
unambiguous split tail, so it points at the duplicate_ids set instead.
has_own_revisions says why it keeps the raw w:author rather than
_revision_author: an editor named "Unknown" must not claim unattributed marks.
* fix: read a revision id the same way on both lookup paths (ROADMAP.md #75)
Keying the index on the parsed id left the two paths comparing different
things: the fresh scan compared _adjudicable_id's int, the index looked up
str(id). Anything int-equal but not an int then resolved through one and not
the other -- accept_revision(True) destroyed revision 1 on the scan path
(bool subclasses int) while .get("True") found nothing, and None, which
list_unhandled_revisions() reports for a mark with no numeric id, matched
every unreachable mark through == while missing the index entirely.
Both sides now compare str of the adjudicable id. That restores what every id
type did before this PR -- including "7", which both paths accepted and which
narrowing to int would have broken for a caller round-tripping ids through
JSON -- while keeping w:id="007" reachable. The None special case goes away
with it, being just one value that now misses on both paths.
get_markup_text's id is pinned: w:id="007" renders [ins#7:A] and a mark with
no numeric id renders #?, the rows list_unhandled_revisions() reports.
* refactor: parse revision ids through _adjudicable_id in the group registry
The registry hand-rolled int(elem.getAttribute("w:id")) with a ValueError
guard in four places. Identical in behaviour -- int("") raises ValueError too
-- but it was the last place that answered "how is a revision id read?" on its
own, after the listing, the index and the honesty floor were folded onto one
definition.
* docs: scope the author-exact claim to targeting, and renumber the filed items
docs/api.md promised an author= call "resolves that author's own elements and
no one else's", which overstates a data-loss guarantee: the scoping decides
which elements are targeted, not what survives, and rejecting an insertion
still carries away revisions another author nested inside it. api.md's own
rationale-notes section already said so.
UnhandledRevision's docstring claimed its rows "carry no adjudicable id, so
handing them to accept_revision() could only fail". An unhandled mark often
does carry a numeric w:id, and where it collides with a handled revision's the
call resolves that other element: verified, reject_revision(row.id) on a
w:rPrChange id=7 deleted a w:ins id=7's text and left the rPrChange standing.
Filed as #87.
main added its own #83 (PR #95) after this branch forked, so the items filed
here move to #84/#85/#86 and #75's cross-reference follows them.
* docs: say what author= guarantees, and what it does not (ROADMAP.md #75)
The accept_all/reject_all docstrings and SKILL.md promised a filtered call
"resolves only that author's own elements". Scoping decides which elements are
targeted, not what survives: rejecting an insertion still carries away
revisions another author nested inside it, reject_all(author=...) included.
docs/api.md was corrected already; these are the sources it mirrors.
_resolve_all's index bullet claimed the call "resolves exactly the rows it
listed". It can resolve fewer -- a listed row nested inside a rejected
insertion goes with its host -- so the honest claim is the negative one: it
cannot resolve a row it did not list. The test named for the false
generalization is renamed and says why equality holds in its own fixture.
_revision_element_index's "a duplicated id resolves the same element whichever
path finds it" predates the author parameter and is now false by design: the
scan hands back the first element carrying the id, a scoped index the first
one that author wrote. It is scoped to the unscoped case.
accept_revision/reject_revision gain the duplicate-w:id caveat that SKILL.md
and docs/api.md already carry.
* test: pin group liveness for a non-canonical member id (ROADMAP.md #75)
groups_are_dead answers through the same w:id index resolution uses, so a
group whose member carries w:id="007" was reported dead while it was live --
and a dead group has nothing left to explain, which is what deletes its note=
comment. Nothing covered it; reverting the index key to the raw attribute now
fails this test.
_adopt_split_tail reads its origin id through _adjudicable_id like the rest of
the registry. ROADMAP #75 keeps the one-line record of the fix and leaves the
design rationale to the PR.
* docs: keep the targeting/survival distinction in _resolve_all (ROADMAP.md #75)
"never someone else's" still read as a survival guarantee where its siblings
had already been qualified: another author's revision nested inside a rejected
insertion does go with it, uncounted.
test_accept_all_author_filter_resolves_every_row_it_listed credited itself with
covering the author expression, which its fixture cannot -- both rows carry an
explicit w:author, so the "Unknown" fallback is pinned by
test_unattributed_revision_resolves_under_the_unknown_author instead. It now
says which half it covers and points at the other.
1 parent 794e943 commit dc50953
12 files changed
Lines changed: 582 additions & 71 deletions
File tree
- docs
- docx_editor/track_changes
- skills/docx
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
57 | 73 | | |
58 | 74 | | |
59 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
867 | 867 | | |
868 | 868 | | |
869 | 869 | | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
870 | 878 | | |
871 | 879 | | |
872 | 880 | | |
| |||
892 | 900 | | |
893 | 901 | | |
894 | 902 | | |
895 | | - | |
| 903 | + | |
| 904 | + | |
896 | 905 | | |
897 | 906 | | |
898 | 907 | | |
| |||
1080 | 1089 | | |
1081 | 1090 | | |
1082 | 1091 | | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
1083 | 1099 | | |
1084 | 1100 | | |
1085 | 1101 | | |
| |||
1109 | 1125 | | |
1110 | 1126 | | |
1111 | 1127 | | |
1112 | | - | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
1113 | 1131 | | |
1114 | 1132 | | |
1115 | 1133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
74 | 86 | | |
75 | 87 | | |
76 | 88 | | |
| |||
0 commit comments