Repository navigation
HUD plugins: the package format's descriptor table, strict parser and SVG mask checker - #1139
Merged
Merged
Conversation
…rmat, ordered strict_json) Lands the types and signatures that the parallel hud_format packages compile against. The format is PR5 part 1 of the player-HUD plugin plan (docs/hud-plugins.md follows). REAL bodies: - hud_format.rs: Severity, Code, Finding (lint shape: code, severity, pointer, rule, message, hint, nearest), the 32 frozen codes (codes::E0100..E0706, codes::ALL), REASON_NEWER / REASON_OLDER, pointer_push / pointer_index (RFC 6901), nearest (Levenshtein, at most 3, deterministic), has_error. - ui rec::strict_json is now a shared `pub mod`. The single visitor is generic over the tree it builds (Value output and budget charges unchanged); `Ordered` keeps document order AND duplicate keys; `decode_ordered(bytes, cap)`; Error/Map/Number/Value re-exported so appkit (which has no serde_json dependency) can hold them. - hud_format::schema: the descriptor-table TYPES (Since, Field, Node, NodeKind, Ty, Rule, Cmd, FaceState, Condition), lookups (all_nodes, node, field, command, condition), COMMANDS (the ten) and CONDITIONS (the eleven) complete for 1.0, the theme-tied allow-lists and resolvers (ink_token, size_rung with HUD_TITLE 54, space_token, builtin_icon), and ROOT (top level) plus APP. HUD_TITLE_PX mirrors player_hud's private HUD_TITLE_SZ; that file is left untouched, wave B unifies the two. - hud_format::parse: Parsed, Package, AppRange, Object, Val, Cond, Keyed, Ctx::v1 and the accessors. STUBS (marked CONTRACT FREEZE in the source): - schema: every node under ROOT's `layout` (B fills). - parse: parse() and validate_json() panic with unimplemented! (C fills). - svg_subset: check_asset() accepts every string (A fills); MAX_ASSET_BYTES and MAX_PATHS_PER_ASSET are landed with their ci/list-caps.ini rows. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… items and Up Next Fills every node of package format 1.0 below the top level: layout and its scrim union, bands, the cell with its twelve kinds, the playbar grab, the strip card, control items and Up Next, with required-ness, state-keyable numbers/inks/gaps/bold, defaults and cross-key rules as data. Adds the binding catalogue and per-position bind lists, the body-size list tied to the rungs, close and check as built-in faces, and the module doc's decisions and open items. Table self-consistency tests pin it. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…re, strict_json budget and nesting tests check_asset is a Rust tokenizer that enforces the icon contract before nanosvg sees the bytes: svg and path only, gradient and colour content refused as HUD-E0701/E0702 with the mask reason, entities and references as HUD-E0703, malformed documents as HUD-E0704, size and path bounds as HUD-E0705/E0706. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…rser drift test The valid fixtures parse with no finding. The invalid corpus asserts the frozen code AND the JSON pointer of every parse rule and every command parameter (the version rows carry the exact user-facing reasons). Seeded xorshift64* byte and key mutations never panic and always answer in the lint shape, through parse and through validate_json on the root node. The drift test walks schema::all_nodes and schema::COMMANDS, matching exhaustively on Ty, Pattern, NodeKind and Rule, and proves every listed value is accepted and every unlisted name refused. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
hud_format.rs did not declare 'mod tests;', so hud_format/tests.rs was never compiled. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ord (D) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…es, judge an item whose command is unknown - svg_subset: nanosvg ends any `<!` construct at the first `>`, so a comment that holds a `>` followed by a `<` hid elements (gradients, colour, any number of paths) from the checker that nanosvg then parsed. Such a comment is HUD-E0704. Prose with a lone `>` (a real icon mentions `<path>`) still passes. - parse: a palette name is at most ID_LEN like an id, `nearest` compares only the first 48 characters of a candidate, and a hint lists at most twelve declared assets, so one hostile package cannot make the parse quadratic in a name or a finding hundreds of KB. - parse: the reader gets a 16 MiB decoded-memory budget instead of the recorder's 64 MiB, and an over-budget package says it is too large to read rather than naming a recording. - parse: an item whose command is unknown or missing still has its own keys judged (duplicates, ranges, names, missing required keys), so one round reports every mistake. - parse: the doc no longer claims the parser names no key; a test fails if the table drops one it reads. - hud_format, schema: remove the parallel-lane "contract freeze / coordinator" text. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ound Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
The first part of PR5 in the player-HUD plugin plan (
docs/hud-plugins.md, added here): the package format's descriptor table, its strict parser and the SVG mask checker. Nothing calls the module yet. The compiler, the reachability check, the lint command and the schema emission come next, as their own PR on top of this one.What changes
appkit::hud_format::schema: one static descriptor table. It names every top-level key, layout key, band, cell kind, control-item key, widget, rest and focus style, command with typed parameters, condition and theme token, with the type, the allowed values, the default and the format minor each arrived in. The parser reads it, and the future schema emitter will too, so no name is listed twice.hud_format::parse: a strict parse into typed package values. Unknown or duplicate keys, unknown names and wrong types are findings. So is aformatnewer than this build ("Made for a newer PlxNative") or of another major ("Uses an older HUD format"). Conditions come from the closed list with!and AND only, and the palette takes lower-case names with#rrggbbvalues. Every finding has the lint shape {code, severity, JSON pointer, rule, hint, nearest valid names}.hud_format::svg_subset: a Rust tokenizer for the icon contract (<svg viewBox>+<path d>), run before nanosvg sees any bytes. Assets are masks tinted per state. Any element butsvgandpath, gradients included, isHUD-E0701. Any other attribute, and anyfillthat is not mask-white (a colour,url(#g)), isHUD-E0702. Each comes with a hint saying why. Bytes and path count per asset are bounded.ui::rec::strict_jsonis shared: it becomespub mod, and the parser calls its order-preserving reader with a 1 MiB cap on the input and a 16 MiB decoded-memory budget. It is still the repository's only duplicate-key reader, and the recorder'sdecode/decode_withkeep their visibility and behaviour.reference.plxhud.json) and a minimal package parse with zero findings;assets/icons/pass, and the icons that are not masks are refused.ci/list-caps.ini: classifies the four new bounds (MAX_NEAREST,MAX_PACKAGE_BYTES,MAX_ASSET_BYTES,MAX_PATHS_PER_ASSET).docs/hud-plugins.md: the design record the planner and critic approved.No Cargo change and no new dependency: appkit reaches
serde_json's types throughplx_ui::rec::strict_json.Issue
No issue tracks the HUD-plugin work, and none was opened for this PR.
Gates
Local runs, crate tests only (the full gate is this PR's CI), on head
84430d1e5:make test-crate C=plx_appkit T=hud_format:test result: ok. 121 passed; 0 failed; 0 ignored; 0 measured; 351 filtered out; finished in 5.12smake test-crate C=plx_ui:test result: ok. 1401 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 17.46sci/check-list-caps.py,ci/check-module-layers.py,ci/check-module-cycle.pyandci/check-deps.sh, run directly: green.Review
One Opus review, verdict FIX FIRST: one MAJOR, five MINOR. All six are fixed.
origin/mainmoved by six commits; the PR does not conflict with it (git merge-tree), so it was not merged in.<!construct at the first>. Fixed insvg_subset.rs::comment: a comment with a<after a>in its body isHUD-E0704. I did not take the review's "refuse<or>" literally:assets/icons/more.svghasone <path> soin its comment and ships, and a lone>leaves only text for nanosvg, so refusing it would reject a real icon (the_real_mask_icons_passfailed when I tried it). Red first: the review's smuggled asset, a> <bcomment and a two-path comment were accepted; they are refused now, and the prose anda < bcomments still pass.ID_LEN(40) like an id,nearestcompares at most 48 characters of a candidate, and the unknown-face hint lists twelve assets and says how many more. Test red before the fix: a 41-letter palette name was accepted. Not done: the palette's entry count and the findings count are still bounded only by the 1 MiB input, so thousands of unknown inks against tens of thousands of palette entries still cost work per ink. A cap there is a format decision for the plan, not a cheap fix.Package::from_objectis the one place keys are named) and addingthe_package_reader_names_only_keys_the_table_has, which fails ifschema::ROOTor theappnode drops or renames a key the reader uses.walk_unresolvedjudges the item's own keys (duplicates, ranges, names, missing required keys) and skips a key only the command's parameters could own, and the cross-key rules. Red first: the review's shape reported onlyE0301; it now reportsE0301,E0201,E0101andE0103.hud_format.rs; the same "contract freeze" paragraph inschema.rsis reworded.Also: the two new
.take(sites neededci/list-caps.inisections (nearest,listed);check-list-caps.pycaught it.🤖 Generated with Claude Code