rbf0_encode: write back a short-count element with text or child content (carry of #2386) #3096
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3096"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T10:31:45Z.
Claimed in the coordination issue as: RBF0-ENCODE-SHORT-COUNT-CONTENT (original author's item ID, claimed at https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7198218440)
What and why
Carry of #2386 (syfyra), unchanged since 2026-11-26 (head
4f1ca189); branch = main (80910637f) + the author's head (commit kept, merged without conflicts) + my commit.The author's change:
tools/rbf0_encode.pyrefused every element flaggedattribute_order_violationas "an attribute after content", including a short-count element whose content is text or a child element, although its bytes write back exactly (docs/rbf0.md9.6). The encoder now refuses on the flag only when an attribute record's offset follows the first content record's, or when the records carry no offsets to tell.Review defect fixed (reviewers
imShangLi,aegish-zagiand the CHANGES_REQUESTED review fromaslan2142): the new code read.get("offset")of every attribute and content record before the shape checks. On current main, a malformedattributesorcontent(None,[123],["bad"]) raisedTypeErrororAttributeErrorinstead ofEncodeError("value"), which failed 4 subtests oftest_bool_recorded_lengths_and_malformed_element_children. My commit moves the shape checks ahead of the offset lists and adds a regression subtest (a flagged element with each of the four malformed shapes must refuse withvalue).Tested
Windows 11, Python 3.14, no GPU, no game files, on main
80910637fplus this branch:python -I tests/test_rbf0_encode.py: 41 tests, OK.python -I tests/test_rbf0_tree.py: 38 tests, OK (1 skipped).python -I tests/test_rbf0_encode.pywith 41 tests, errors=4, as the reviewers reported.tools/rbf0_encode.pyrestored to main's version and this branch's tests kept,python -I tests/test_rbf0_encode.pyruns 41 tests, FAILED (failures=4, errors=2), all six in subtests oftest_fewer_attribute_records_than_the_count: 2 errors for the text and child short-count cases, 4 failures for the flagged malformed-record cases. The file was restored afterwards.python -I scripts/check_no_game_data.py tools/rbf0_encode.py tests/test_rbf0_encode.py: clean.Not run: the full suite, CI.
GPUs tested: n/a (unit tests only)
AI-assisted: yes. Models: Claude Opus 5.5 in Claude Code (carry, conflict resolution, fixes, tests); separate read-only reviewer agent: Claude Opus 5.5.
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)Supersedes #2386 once merged; the original stays open until a maintainer decides.
🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T12:19:01Z.
Verified by OreoFR (oreofr-agent, AI-assisted; third-party red/green). Head
b56408e2d79ac1e048c0f53f7d06e80dcf450ecfmerged into mainf6dd2242e02b5f579d245f1c19dd5150d42e00a1with no conflicts. Windows 11, Python 3.12, CPU only.tests/test_rbf0_encode.pyOK;tests/test_rbf0_tree.pyOK (skipped=1).tools/rbf0_encode.pyrestored and this PR's tests kept:test_rbf0_encode.pyFAILED (failures=4, errors=2), matching the description;test_rbf0_tree.pyunchanged, OK.Safe to merge: it merges cleanly, CI is green, and it touches only a tool and its test. Not merged by me.
Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T12:56:05Z.
Ran natively on Windows 11, Python 3.13, head
b56408e2dmerged into currentmain(23a51c494), no conflicts.py -3.13 -I tests/test_rbf0_encode.py: OK. Red/green is already shown twice above, so I tried to find an element the narrower check now lets through but does not write back exactly.Sweep with throwaway streams built by the test file's
Streamhelper: root element with a declared attribute count of 0..3, followed by every sequence of 0..4 records drawn from {int, bool, string, text, empty child, child with one attribute}, in both the wide and the narrow form. That is 12,440 elements. Each one goesrbf0_tree.parse_resource->rbf0_encode.encodeand the output is compared with the input bytes.attribute_order_violationorderSo the 1,404 shapes the PR now accepts all round-trip exactly, and nothing encodes to different bytes. To check that the 5,184 still refused really need refusing, I dropped the flag from each of them and encoded again: 1,188 then come out with different bytes and 3,996 are refused as
descriptor. None of them would have written back exactly, so the new check does not refuse anything it could have kept, at least in this space.Not checked: nesting deeper than one child, more than 4 records per element, real resources (no game files used).
GPUs tested: n/a (CPU-only tests).
AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by aegish-zagi on 2026-12-02T14:37:55Z.
Verification — VERIFY-3096
b56408e2d7; MERGEABLE against current main (acc350745)tests/test_rbf0_encode.pyrun standalone in a scratch worktree: (a) PR test file against plain main code, (b) PR test file against the PR headAI-assisted: yes (Muse Wonder, Muse by Meta)
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T20:36:02Z.
Merging. Head
b56408e2dmerges cleanly withmainb41763227and does not force a rebase of #2566. Carry of #2386, CI green on this head Merged by MoonEyes.AI-assisted (Claude Code).