Repository navigation
Declare identifiers before parent links and clarify attribute order - #213
Conversation
trevor-cortex
left a comment
There was a problem hiding this comment.
Summary
Reorders the attributes of the five link nodes that carry an optional parent link (accountLinkNode, definedTypeLinkNode, instructionAccountLinkNode, instructionLinkNode, pdaLinkNode) so identifier is declared first, swaps label/value on valueLabelDisplayNode, and reframes the README's "data first, children last" rule as an authoring convention while making it explicit that generators emit declaration order verbatim (no regrouping). spec.json and docs/ are regenerated; a new test pins the link node attribute order.
The TS source, spec.json, and the regenerated docs all line up — definedTypeLinkNode keeps transforms trailing, programLinkNode is correctly untouched (no parent link), and the link node doc pages don't change because identifier/program were already split across the Data/Children tables. The only doc page diff is ValueLabelDisplayNode.md, which is expected since both label and value are classified as children there.
Things to watch
- Docs tables vs the new README wording. The README now says
docs/label"count as describing the node", but the docs renderer (isDocChild→isChildAttribute) still files everydocs/textattribute under the Children table (seedocs/AccountNode.md, wheredocssits in Children, andValueLabelDisplayNode.md, wherelabeldoes too). It's not wrong — the updated comment inrenderPages.tsnow explicitly says the tables are a readability grouping only — but a reader could reasonably find it at odds with the README. A follow-up that movesdocs/textinto the Data table would make the two consistent; not blocking here. - Bump level.
patchis defensible given the README's "on read, attribute order carries no semantics" rule, so nothing semantically breaks. Worth being aware that downstream codegen incodama/codama-rswill see a changed attribute order (struct field order, emitted JSON key order), so any snapshot/fixture tests there will churn when they pick up this version. Flagging for awareness, not asking for a change.
For subsequent reviewers
Nothing risky here; the generated artifacts match the source. If you want to double-check anything, confirm pnpm generate is clean on the branch (CI covers this) and that no other node has a child declared before an identifying scalar that this PR should have swept up — I checked the link nodes and found none remaining.
trevor-cortex
left a comment
There was a problem hiding this comment.
Re-review
Since my last pass the PR picked up the docs-renderer alignment I'd flagged: isDocChild now classifies docs/text as Data (with a unit test), and the 20 regenerated doc pages move docs, label, message, intent, interpolatedIntent and flattenPrefix out of the Children tables accordingly. That resolves the README-vs-docs inconsistency, so nothing from the prior review is outstanding.
I re-checked the regenerated pages against the source declarations (AccountNode, ConstantNode, ErrorNode, ProgramNode, InstructionStatusNode, InstructionRemainingAccountsNode, VariablePdaSeedNode, StructFieldTypeNode, and all five display node pages). Rows keep declaration order within each table and the only content change is which table they land in — column widths account for the rest of the churn. InstructionDisplayNode.md now has an empty-except-plugins Children table, which is the correct output of the renderer rather than something to fix here.
One minor note (non-blocking)
isDocChild short-circuits on a top-level docs/text type but not on one nested in an array, so an array(text()) attribute would fall through to isChildAttribute and (if that treats text as a child) land in Children. No node in the spec declares such an attribute today, so this is purely a latent edge case — flagging only so it's a known gap if one is ever added.
For subsequent reviewers
Everything is generated-output + two-line renderer tweak + test on top of the already-reviewed attribute reorder. Confirming pnpm generate is clean (CI) is the only verification needed.
This PR makes the attribute order of the spec the single source of truth for serialisation.
identifierbefore their optional parent link (programorinstruction), since that parent is often omitted, andvalueLabelDisplayNodedeclares itslabelbefore itsvalue.docscounts as describing the node), rather than a rule.