Skip to content

fix(view): fold repeated definition expansions in views over 10,000 nodes - #2192

Merged
HuiJun merged 15 commits into
developfrom
fix/fold-repeated-view-expansions
Nov 13, 2026
Merged

HuiJun merged 15 commits into
developfrom
fix/fold-repeated-view-expansions

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Repeated definition expansions can dominate large tree and interconnection views. Fold equivalent inherited expansions only when the unfolded expanded-node occurrence count exceeds 10,000. Activation uses memoized subtree sizes capped at 10,001 without materializing a rendered tree. Views below the threshold retain byte-identical output.

A later occurrence folds only to an earlier fully emitted equivalent occurrence expanded at least as deeply. The representative with the most remaining depth wins, with ties resolved by walk order. Own and redefined features remain. Positioned elements, edge endpoints and the ancestors needed to reach them are protected; folding happens only at complete expansion boundaries and preserves Render().Drawn() == DrawnIn().

Equivalence uses the rewrite-aware query key. Empty keys, occurrences rewritten into association lines or relationship dots, and their descendants cannot become representatives. Regressions cover connection definitions/usages, generic references typed by connection definitions, n-ary connections, dependencies and missing rewrite IDs. This builds on #2134's shared typed-expansion queries and #2178's rendered-edge parity.

A folded occurrence says:

features of [definition names] shown at [earlier occurrence]; repeated expansion folded

The existing backend notice mechanisms emit:

Repeated definition expansions folded: N later occurrences of M definitions. Each definition's features are shown at an earlier occurrence expanded at least as deeply; later occurrences retain their own and redefined features.

HTML displays the notice above both SVG and source figures. The threshold remains internal, with no new CLI flag or validation diagnostic.

The two review fixes release render-scoped fold plans and definition pointers when rendering finishes, after constructing the unchanged notice, on both rendering entry points. Returned renderings and clones retain neither map, including below the threshold. Interconnection omission, expansion sizing and note fallback share the walk's drawn-member predicate, so ignored actions and other members the walk does not draw cannot inflate fold counts or produce false notices. Tree parameters remain pinned and excluded from expansion counts.

The branch integrates develop through af6ab41f2f, including #2184, #2146, #2189, #2133 and #2185.

The core compressed wasm budget increases in its own commit from 7,400,000 to 7,450,000 bytes. The combined budget remains 12,000,000, already on develop in #2187. Engine, syntax and browser REPL budgets are unchanged.

Specification basis

Repeated-definition folding, depth-dominant representative selection and the 10,000-occurrence threshold are a tool rendering convention, not a specification requirement. The pinned 2026-09 graphical notation defines no normative requirement for this policy. The rendering guide and view compliance source describe the convention without claiming specification conformance for elision. The compliance row includes the required implemented-status marker, allowing validation census and document-count checks to evaluate it normally.

How it was verified

Acceptance is on 670d7c7125, with develop af6ab41f2f as the DocGen baseline.

  • Build, vet, empty gofmt -l ., make lint, view/document tests, hygiene, changelog and doc-ID checks pass. The full native command go test -count=1 -p 2 -timeout 45m ./... passes in 1,528.698 seconds after all five required training, pilot, specification-example, library-XMI and PSSM corpus downloads, with their require variables enabled. The full tools module passes.
  • Regression tests cover completed renderings and clones below/above the threshold, RenderExposed, unchanged notice text, action-only and mixed members, drawn parts beside ignored actions, tree parameters, fallback names, depth dominance and protected/rewrite members. All 299 fixture views pass forced-threshold drawn-set parity.
  • The original TMT census covered 2,813 declarations: 2,800 rendered/compared and 13 unsupported textual views. The final-head rerun of all 97 previously folded views renders every requested view, with 97 still folded, no count changes, zero mismatches and zero skipped/unprocessed. Across that subset, expanded-walk occurrences decrease from 165,645,926 to 121,503,363, with 2,137,963 folded occurrences; emitted nodes after lowering total 111,987,021. Render/query node totals both equal 2,307,108, and edge totals both equal 769,919. The rerun takes 9,183.693 seconds.
  • All 104 HTML documents render. The 99 without folded views are byte-identical to develop in both automatic/SVG and source forms, 198/198 outputs. The other five documents retain 14 folded figures and their notices in each form. All diagram figures match the previous folded outputs; the only complete-file differences are the same image URL rebased for a deeper output directory in two forms of one document.
  • Official view-golden regeneration, notation measurement and make docs-counts leave no tracked changes. Validation/notation census checks pass. Incoming generated assets come from the develop merges above.
  • Both standalone and detached-combination wasm gates pass with the generated library snapshot under Go 1.27.4. The detached check combines the accepted head with #2193 and #2195 and runs OPENSYSML_REQUIRE_WASM=1 make wasm-check.
Gzipped wasm artifact Accepted head bytes With #2193 and #2195 Budget
Core 7,408,688 7,409,854 7,450,000
Engine 10,931,201 10,931,247 11,000,000
Syntax 1,663,639 1,663,639 1,800,000
Combined 11,517,064 11,517,833 12,000,000
Browser REPL 16,182,724 16,181,930 16,200,000

Browser REPL headroom is 17,276 bytes (0.107%) on the accepted head and 18,070 bytes (0.112%) in the detached combination.

Checklist

  • Full Go gate and make lint pass locally
  • Tests cover folding, lifetime, drawn-member eligibility, lowerings, depth, protection and notices
  • Existing documentation and in-tree CLI skill extended
  • Changelog fragment added under changes/unreleased/
  • Official regeneration and make docs-counts leave committed baselines current
  • No internal work-item labels in the body, docs or changelog

🟢 Devin Review found nothing to fix · View findings

Devin Review

devin-ai-integration Bot and others added 9 commits November 12, 2026 15:52
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
The shared view walkers now link the repeated-expansion counter, protection and notice machinery into the core used by layout validation. The gzipped js core grows from 7,391,901 bytes at develop 904e302 to 7,406,377, an increase of 14,476 compressed bytes. Query execution still disables folding.

Plain develop 0ad055b measures 7,391,881 bytes. After integrating it, the folded build measures 7,406,375 bytes with the generated library snapshot and 5,740,214 without it under go1.27.4. Raise the core budget from 7,400,000 to 7,450,000 and record both measurements; the other artifact budgets remain unchanged.
With Go 1.27.4 and the generated library snapshot, sysml-wasm measures 11,483,242 compressed bytes on develop 0ad055b and 11,504,481 with repeated view expansions folded: 21,239 additional bytes (0.185%).

Raise the combined gzip budget from 11,500,000 to 12,000,000 to leave room for further growth. Keep the engine, browser REPL and syntax budgets unchanged.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
After merging develop bc95b41, measure the snapshot-backed core at 7,408,199 gzip bytes (5,740,899 without the snapshot) and combined sysml-wasm at 11,505,952, against 11,480,824 on plain bc95b41.

The previously recorded 0ad055b comparison remains 11,483,242 to 11,504,481 combined bytes. Only refresh the measured comments; keep the approved core 7,450,000 and combined 12,000,000 budgets and all other budgets unchanged.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
…view-expansions

Co-Authored-By: jason.han <hanhuijun@gmail.com>

# Conflicts:
#	tests/wasm/combined_test.go
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

devin-ai-integration Bot and others added 5 commits November 13, 2026 06:35
Finish the fold notice before releasing render-scoped plans and definition symbols in Render and RenderExposed. Returned renderings and their clones retain only the notice and scalar fold counts. Measure threshold totals on a separate, unfinished rendering.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Share the member emission predicate with omission, size measurement and fallback definition notices. Ignore undrawn actions, included case references and members excluded from mixed structural walks. Keep tree parameters pinned before omission and exclude them from fallback definitions.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Give the rendering convention row the status marker required by validation-census, retaining the explicit distinction from a specification requirement.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
devin-ai-integration[bot]

This comment was marked as resolved.

@HuiJun
HuiJun added this pull request to the merge queue Nov 13, 2026
Merged via the queue into develop with commit f98700d Nov 13, 2026
30 checks passed
@HuiJun
HuiJun deleted the fix/fold-repeated-view-expansions branch November 13, 2026 14:57
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