Skip to content

Summarize a model from an already-parsed structure - #29

Merged
ww-mw merged 2 commits into
mainfrom
parsed-model-summary
Sep 16, 2026
Merged

ww-mw merged 2 commits into
mainfrom
parsed-model-summary

Conversation

@ww-mw

@ww-mw ww-mw commented Sep 16, 2026

Copy link
Copy Markdown
Member

A host opening a model parses it twice: once itself, to build the model rows, and once inside summarizeFiles, to build the usage summary over the same bytes. The second parse produces nothing the caller was not already holding.

summarizeParsedModel takes the parse instead of the bytes. It is the model branch of summarizeFiles with the parse lifted out, and summarizeFiles' own model branch now routes through it — so the two ways to summarize a model are one implementation rather than two that happen to agree.

It answers with a whole FileSummaries holding just that one model rather than a bare ModelSummary, so it is exactly what summarizeFiles([{srcId, filename, bytes}]) returns for a model, and mergeFileSummaries folds it in beside the dictionaries and MAT-files a host only ever reads as bytes.

Purely additive — no existing signature or behaviour changes. The tests pin the equality BETWEEN the two paths per model fixture: block parameters, a real model workspace, mask workspaces, file links with no blocks, and a model that parses and defines nothing (where both paths owe the same empty-ish summary rather than a throw). Bytes the parser refuses have no parsed path at all — the caller's own parseModel threw and has nothing to hand over — and that is pinned as the one case the two cannot be compared.

Version bumped to 1.20.0 on the branch so the release tag can match, per the pattern in 684e36c.

Consumer: data-explorer-vscode's shared-source-cache work, which calls this to build the Usage graph from the parse it already has.

A host opening a model parses it twice. It runs parseModel itself to build the
model's rows, and summarizeFiles runs parseModel again over the same bytes to
build the usage summary — a second full parse per model open, spent to produce
nothing the caller was not already holding.

summarizeParsedModel takes the parse instead of the bytes. It is the model
branch of summarizeFiles with the parse lifted out: it reuses modelSummary, and
summarizeFiles' own model branch now goes through it, so the two ways to
summarise a model are one implementation rather than two that agree today.

It answers with a whole FileSummaries holding just that one model, not a bare
ModelSummary, so it is exactly what summarizeFiles([{srcId, filename, bytes}])
returns for a model and mergeFileSummaries folds it in beside the dictionaries
and MAT-files a host only ever reads as bytes.

Purely additive: no existing signature or behaviour changes. What the tests pin
is the equality BETWEEN the two paths, per model fixture — block parameters, a
real model workspace, mask workspaces, file links with no blocks, and a model
that parses and defines nothing, where both paths owe the same empty-ish summary
rather than a throw. Bytes the parser refuses have no parsed path at all: the
caller's own parseModel threw and has nothing to hand over, which is the one case
the two cannot be compared and is pinned as such.
@ww-mw
ww-mw merged commit ef9d0c0 into main Sep 16, 2026
1 check passed
@ww-mw
ww-mw deleted the parsed-model-summary branch September 16, 2026 13:49
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