mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #2386] rbf0_encode: write back a short-count element with text or child content (RBF0-ENCODE-SHORT-COUNT-CONTENT) #2386
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2386
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2386
Author: @syfyra
Created: 11/26/2026
Status: 🔄 Open
Base:
main← Head:fix/rbf0-encode-short-count-content📝 Commits (1)
4f1ca18rbf0_encode: write back a short-count element with text or child content (RBF0-ENCODE-SHORT-COUNT-CONTENT)📊 Changes
2 files changed (+23 additions, -1 deletions)
View changed files
📝
tests/test_rbf0_encode.py(+15 -0)📝
tools/rbf0_encode.py(+8 -1)📄 Description
Claimed in the coordination issue as: RBF0-ENCODE-SHORT-COUNT-CONTENT (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7198218440)
What and why
tools/rbf0_encode.pywrites anrbf0_tree.pydocument back to bytes and fails closed.docs/rbf0.md9.6 lists the refusals. For attribute counts it refuses "an element with more attribute records than its attribute count" and "an element short of its attribute count with a value in its content", because that value would decode as an attribute.rbf0_tree._attachsetsattribute_order_violationin two cases:The encoder refused every flagged element as "an attribute after content". An element short of its count whose content is text or a child element was therefore refused, although no attribute follows its content, no value is in it, and its bytes write back exactly. A short-count element with no content at all already encoded (
test_fewer_attribute_records_than_the_count).The encoder now refuses on the flag when an attribute record's offset comes after the first content record's, the real attribute-after-content case. It also still refuses when the records carry no offsets to tell (a tree built by hand fails closed as before). The existing check for a value in the content of a short-count element is unchanged, and
rbf0_treeis untouched, so its counts and reports stay the same.Measured corpus effect: none. 9.6 found no such element among the 1,263
data.rpfresources, and the only refusals there are the 23 invalid-UTF-8 ones. This is the encoder agreeing with its documented rule.Different topic from #1574 (same files); the two merge cleanly.
Tested
Windows 11, Python 3.14.7, synthetic RBF0 streams only:
python -I tests/test_rbf0_encode.py: 37 tests OK.test_fewer_attribute_records_than_the_countnow also takes a root withattrs=2, one int attribute, then text or a child element:okand flagged;mainrefuses both;order.test_attribute_after_content(a value after text with a short count) still refuses withorder.tests/test_rbf0_tree.pyOK.python -m compileall;scripts/check_no_game_data.pyon both files.GPUs tested: n/a (CPU-only tool)
AI-assisted: yes (Claude Code, 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)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.