Skip to content

fix(resolve): memoize an import's resolved target (#636) - #638

Merged
HuiJun merged 2 commits into
Open-MBEE:developfrom
someshSandbox:fix/636-memoize-import-targets
Sep 28, 2026
Merged

HuiJun merged 2 commits into
Open-MBEE:developfrom
someshSandbox:fix/636-memoize-import-targets

Conversation

@someshSandbox

@someshSandbox someshSandbox commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #636.

A view with many exposes and a metadata usage stalls validation:

metadata def Tag;
package P1 { }
package P2 { }
// … P12
view v {
    expose P1::*;
    expose P2::*;
    // … expose P12::*;
    @Tag;
}
exposes before after
10 3 s 0.03 s
11 31 s 0.03 s
12 no result in 60 s 0.03 s
200 — 0.04 s

Cause: each expose's target was resolved again on every lookup in the view, never memoized (it resolves under inAllVisible), so every lookup searched the other exposes in every order.

Change: a new importTargets table keeps each import's resolved target.

  • Only hits are kept. A miss can still mean a sibling import was suspended.
  • It is never read or written under InCondition (review finding).
  • It is journaled like implicitParams and counted in MemoSize.

This matches the OMG pilot, where an import's target is a linked cross-reference resolved once.

Tests:

  • tests/model/expose_scaling_test.go: 20 exposes must analyse within 10 s. Fails on develop, passes here (0.5 s).
  • filter_test.go, TestAnImportTargetFoundWhileAConditionIsResolvedIsNotRemembered: a target found in condition mode doesn't leak to an ordinary lookup.
  • internal/semantic/..., tests/model/... and internal/workspace/... all pass on develop with this change.
  • gofmt is clean. make lint wasn't run (tools not installed).

Does not fix #633 (a public import cycle, a different path).

🤖 Generated with Claude Code

devin-ai-integration[bot]

This comment was marked as resolved.

someshSandbox added a commit to someshSandbox/OpenSysML that referenced this pull request Sep 27, 2026
A filter condition's own names resolve unfiltered (InCondition), and
nothing resolved meanwhile may be memoized. importTargets kept such a
target, so an ordinary lookup could reach a namespace the filter rejects.
It is now neither read nor written while a condition resolves.
TestAnImportTargetFoundWhileAConditionIsResolvedIsNotRemembered fails
without this and passes with it (review finding on Open-MBEE#638).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
someshSandbox and others added 2 commits September 27, 2026 22:31
Analysing a view resolved each expose's target afresh on every name
lookup in the view, and each resolution searched the other exposes'
unresolved targets again, in every order: 11 exposes took 35 s and 12
did not finish. An import's resolved target is now kept in importTargets,
hits only; a miss is still never memoized, since it may only mean that
sibling imports were suspended. This matches the OMG pilot, which links
an import's target once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A filter condition's own names resolve unfiltered (InCondition), and
nothing resolved meanwhile may be memoized. importTargets kept such a
target, so an ordinary lookup could reach a namespace the filter rejects.
It is now neither read nor written while a condition resolves.
TestAnImportTargetFoundWhileAConditionIsResolvedIsNotRemembered fails
without this and passes with it (review finding on Open-MBEE#638).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@someshSandbox
someshSandbox force-pushed the fix/636-memoize-import-targets branch from 780228a to 7bb778c Compare September 28, 2026 02:37
@HuiJun
HuiJun merged commit 5516de6 into Open-MBEE:develop Sep 28, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants