Skip to content

fix(holon-viz): emit valid SysML v2 syntax; add real-parser validation (ufo_types::sysml) - #197

Open
elasticdotventures wants to merge 2 commits into
mainfrom
fix/holon-viz-emitter-sysml-v2-syntax
Open

fix(holon-viz): emit valid SysML v2 syntax; add real-parser validation (ufo_types::sysml)#197
elasticdotventures wants to merge 2 commits into
mainfrom
fix/holon-viz-emitter-sysml-v2-syntax

Conversation

@elasticdotventures

Copy link
Copy Markdown
Member

What

Follow-up from the SysML v2 epic's retrospective + issue #195. The
unmerged spike PR #187 (sysml-v2-parser round-trip investigation) already
found that holon-viz's SysmlV2Emitter doesn't produce parseable SysML
v2 at all — this PR fixes both bugs it found and lands a reusable real-parser
validator, rather than leaving the finding as a spike writeup nobody acted
on.

Bugs fixed in SysmlV2Emitter

  1. Comment swallows the closing brace. The emitter wrote the closing
    } on the same line as a trailing // id: ..., kind: ... comment —
    // runs to end of line, so the brace was never actually there
    syntactically.
  2. block def is SysML v1, not v2. SysML v1 called this construct
    Block; SysML v2 renamed it to part def. block is not a SysML v2
    keyword — parse()/parse_for_editor() reject it outright.

Both confirmed against the real grammar, not asserted from reading the
spec.

New: ufo_types::sysml

A shared SysmlV2Syntax constraint + validate_sysml_v2() function (and
Satisfies<SysmlV2Syntax> impls for str/String), wired to the
sysml-v2-parser crate (pinned =0.54.0, matching the spike's own
recommendation given its pre-1.0/high-churn release cadence). This gives
every crate that generates SysML v2 text (today: holon-viz,
sysml-derive — see the follow-up PR wiring this into #196) one shared,
real-grammar oracle instead of each hand-rolling its own heuristic (the
"no <> characters" check I originally used to validate #196 was exactly
this kind of heuristic).

Important dependency-graph note: sysml-v2-parser pulls in stacker,
which is not wasm32-compatible. ufo-types itself is never compiled to
wasm in this repo, so it's a normal dependency there. holon-viz, however,
is compiled to wasm (holon-viz-wasm) — so ufo-types is added there
only as a dev-dependency, used in a new test
(tests/sysml_v2_roundtrip.rs) that feeds SysmlV2Emitter's own output
through the real parser. This must not become a runtime dependency of
holon-viz.

Verification

  • cargo test -p ufo-types: 17/17 pass (4 new, including one that asserts
    block def is rejected and one that asserts the comment/brace bug is
    rejected — both against the real parser).
  • cargo test -p holon-viz: all pass, including the 3 new round-trip
    tests (previously these exact same inputs failed to parse — this is the
    concrete "did we close the round-trip" signal PR spike: sysml-v2-parser round-trip against holon-viz emitter #187's writeup asked
    for).
  • Updated the two pre-existing tests that asserted on the literal string
    "block def" to expect "part def" instead (one count changed from 2
    to 3, since nodes and containment edges now correctly share one
    keyword instead of an artificial v1/v2-mixed split).
  • cargo check --workspace --all-features: clean.

…eal parser validation into ufo-types

Ran SysmlV2Emitter's own output through the real sysml-v2-parser crate
(docs/sysml-v2-parser-spike.md, an existing unmerged spike) and confirmed
two bugs make it non-parseable:

- The closing '}' was on the same line as a trailing '//' comment, so the
  comment swallowed it -- the block was never syntactically closed.
- The emitter used SysML v1's 'block def' keyword. SysML v2 renamed this
  construct to 'part def'; 'block' is not a SysML v2 keyword at all.

Fixed both. Added ufo_types::sysml -- a shared Constraint/Satisfies-based
SysML v2 syntax validator wired to sysml-v2-parser (pinned to =0.54.0 per
the spike's crate-health findings; not wasm32-compatible, so this must
stay out of holon-viz's runtime dependency graph -- added to holon-viz
only as a dev-dependency, used in a new round-trip test that feeds the
emitter's own output through the real parser instead of just asserting on
substrings.

This is the concrete round-trip-closed signal the existing spike (PR #187)
called out as the next step.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant