Skip to content

fix(view): share typed expansions in layout drawn-set queries - #2134

Open
devin-ai-integration[bot] wants to merge 1 commit into
developfrom
fix/shared-view-tree-expansion
Open

devin-ai-integration[bot] wants to merge 1 commit into
developfrom
fix/shared-view-tree-expansion

Conversation

@devin-ai-integration

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

Copy link
Copy Markdown
Contributor

What and why

Layout validation materialized complete view trees just to determine which elements were drawn. After #1224 correctly expanded typed usages through their definitions, widely shared definitions multiplied those occurrences: a TMT diagnostic reached 1,000,000 nodes for 32,726 distinct elements in 132 seconds, despite the existing depth bound.

Renderer.DrawnIn now shares equivalent expansions in a query-only DAG, retaining owner, qualification, recursion barriers and remaining-depth coverage. Condensed member-graph reachability, effective-member and geometry caches, and guarded edge traversal avoid repeated work. Identity generation also caches metadata membership positions and identity annotation sites rather than rescanning metadata-heavy scopes. Full rendering retains its existing expansion and output; no rendering fold or size guard is introduced.

Why shallower-depth reuse is safe

Drawn records view-wide semantic presence by element/relationship origin and owning declaration, not a separate result for every rendered occurrence. A cache entry is installed only after that walk completes, and reuse requires the same symbol, owner, qualification and reachable active recursion barriers in the same view. A previously completed shallower occurrence has at least as much remaining depth as a later deeper occurrence. Any additional descendants carried by its reused query node therefore already have a full-render witness at that shallower occurrence, with the same semantic owners; attaching that node deeper cannot introduce an element absent from the full view's drawn set. This argument concerns the union of drawn elements, not occurrence-by-occurrence diagram equivalence. Reuse in the opposite direction is prohibited: a cached deeper walk cannot satisfy a shallower request, which must expand with its larger remaining budget. Render continues to build each occurrence independently at its actual depth.

How it was verified

  • go build ./..., go vet ./..., gofmt -l . (empty), go test -timeout 45m ./... (135 passing packages), make lint, hygiene, document-ID and changelog checks pass. The repository timeout replaces the default 10-minute package timeout.
  • Drawn-set equivalence against full rendering covers 299 fixture views across supported kinds, with the query run first. Additional regressions cover deep shared definitions, recursive and cyclic contexts, multiple declared types, and metadata-body identities.
  • The synthetic layout regression completes in 0.12 seconds; develop was stopped at its 15-second timeout.
  • Fresh default migration matches the supplied develop artifact byte for byte. Strict migration and strict validation output match the base byte for byte.

TMT validation

Default validation was previously stopped after 20 minutes at about 10 GB RSS. Two unloaded query runs finish in 1m29.37s and 1m35.35s, with 7.42–7.91 GiB maximum RSS, exit 0, 0 errors and 254 warnings. This remains above the approximately one-minute target. The earlier pre-#1224 bisect baseline was about 51 seconds; a later unloaded 1ac2af4593 rerun on the bisect input took 7.30 seconds and produced identical diagnostics. The old implementation also omits the typed expansion introduced by #1224.

Warning code 1ac2af4593, bisect input Query, same bisect input Query, fresh default input
diagram-layout-unplaced 109 110 177
bound-feature-types 2 57 57
name-conflict 10,016 0 17
subsetting-multiplicity 3 3 3
Total 10,130 170 254

On the identical bisect input, 112 diagnostics are unchanged. All 10,016 removed name warnings were import collisions at expose statements, retired by #1635. The 55 added type warnings concern integer values bound to ditSetup : second, covered by the feature-value conformance check from #1621. Two tree Route warnings disappear because mode and state now draw relationship edges; three interconnection Layout warnings concern declared ports that the current full rendering does not draw as standalone nodes. The query matches full rendering on all four TMT views containing these five layout changes. The fresh input additionally reports 35 sequence Layout warnings, 32 sequence Route warnings and 17 inherited self name conflicts; these are existing migration/sequence behavior, outside this change.

TMT HTML documents

-render-documents <dir> -doc-form html, capped at 30 minutes, terminated with SIGKILL/exit 137 after 14m11.52s at 29.94 GiB RSS. Temporary measurement-only progress logging records all 104 plans evaluated without errors, 46 HTML documents completed in memory, and termination during HTML generation for TMT-SE How to Add an new Observation Workflow Document. The remaining 57 HTML documents were not reached. The set writer commits only after generating the complete set, so no files were committed. The Workflow document's IR evaluation alone took 474.00 seconds. Full-render memory growth remains a known limitation.

The three other large documents complete when rendered individually, each capped at 30 minutes and exiting 0 with an HTML document rather than an error page:

Document Whole CLI run HTML bytes
TMT-APS Analysis Document 1m43.82s 68,316
TMT-APS Use Case Development Document 1m51.54s 832,441
TMT-APS Use Cases Document 1m49.55s 7,740,988

Individual timings include loading and checking the model; they are not isolated HTML-formatting times. The bulk run did not reach these documents' HTML phase.

Checklist

  • Full Go gate and make lint pass locally
  • Tests added for the change
  • Existing rendering and diagnostic contracts preserved
  • Changelog fragments added under changes/unreleased/
  • No generated baselines changed
  • No internal work-item labels in the body, documentation or changelog

🟢 Devin Review found nothing to fix · View findings

Devin Review

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@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
devin-ai-integration Bot marked this pull request as ready for review November 11, 2026 09:08

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

This branch has not been deployed

No deployments
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