Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
243 commits
Select commit Hold shift + click to select a range
883da34
WIP (vetted)
LPTK Sep 18, 2026
23eb13d
W
LPTK Sep 18, 2026
ad3cd74
Cache term shape member lookups by name
codex Sep 18, 2026
911f522
W
LPTK Sep 19, 2026
7ead619
Preserve context marks when returning from lambdas
codex Sep 19, 2026
84e94b1
W
LPTK Sep 21, 2026
957f8d1
Merge branch 'new-resolution' of https://github.com/LPTK/mlscript int…
LPTK Sep 21, 2026
fa0da12
W
LPTK Sep 21, 2026
6017aa9
WW
LPTK Sep 21, 2026
8715b64
Support bare class overloading with term definitions in new resolution
codex Sep 21, 2026
323c580
Resolve assignment term targets before lowering and document staged plan
codex Sep 22, 2026
8164a56
Preserve enclosing captures without module boundary marks
codex Sep 22, 2026
e8ce648
Tweak comment
LPTK Sep 22, 2026
f07653b
Resolve new-resolution opens through deferred shape listeners
codex Sep 22, 2026
13e8238
Thread required interpretations through elaboration
codex Sep 22, 2026
c393ca9
Simplify resolution error reporting and clarify use comment
codex Sep 22, 2026
18d73e6
Shorten interpretation names and require explicit term context
codex Sep 22, 2026
8fa221f
Resolve lexical selections through receivers and remove lowering fall…
codex Sep 22, 2026
0a56bf2
Enforce one self shape per inner symbol
codex Sep 22, 2026
06e710d
Complete deferred constructor-pattern resolution and inheritance lookup
codex Sep 22, 2026
fc7eaca
Minor
LPTK Sep 22, 2026
fa178bc
WIP
LPTK Sep 22, 2026
6c47ff0
Isolate new-resolution WASM tests from inherited JS execution
codex Sep 22, 2026
8aa2143
Recognize disabled flags in imported test directives
codex Sep 22, 2026
f7acacd
Minor
LPTK Sep 22, 2026
20905f9
Resolve explicit class projections through deferred shapes
codex Sep 22, 2026
6bd8d90
Point rejected shape diagnostics to their source origins
codex Sep 22, 2026
4206411
Cleanup
LPTK Sep 22, 2026
8e66dbe
Migrate initial WASM tests to new resolution
codex Sep 22, 2026
c265858
Restrict resolved symbol queries to lowering and publish IR class hea…
codex Sep 22, 2026
d4917fa
Migrate initial core test suites to new resolution
codex Sep 22, 2026
ea3f639
Merge branch 'hkmc2' into new-resolution
LPTK Sep 22, 2026
f405ae4
Preserve resolution when cloning terms during lowering
codex Sep 22, 2026
5d960f5
Reject legacy synthetic selections in new resolution
codex Sep 22, 2026
3a32f6f
Fail fast on builtin SimpleRef in new resolution
codex Sep 22, 2026
444498f
Minor
LPTK Sep 22, 2026
996092b
Attach runtime symbols to synthetic helper selections
codex Sep 23, 2026
c511dd2
Misc
LPTK Sep 23, 2026
924110a
Complete semantic term and synthetic split printing
codex Sep 23, 2026
c5dec62
Verify deferred calls and narrow the remaining migration work
codex Sep 23, 2026
6c984dc
Resolve tuple spreads through deferred shape candidates
codex Sep 23, 2026
dc2e933
Permit unknown-length spread arguments
codex Sep 23, 2026
8f9155c
Host tuple shapes on their syntax nodes
codex Sep 23, 2026
02d6b25
Doc
LPTK Sep 23, 2026
04bc987
Require annotation heads to be known during elaboration
codex Sep 23, 2026
bc19d20
Tighten annotation fallback and clean up diagnostics
codex Sep 23, 2026
e4a45d8
Refresh remaining new-resolution timeout findings
codex Sep 23, 2026
d8a837d
Support record field symbols in new resolution
codex Sep 23, 2026
637a928
Keep debug representations out of user-facing diagnostics
codex Sep 23, 2026
03b7d5f
Show definition and opening sites for ambiguous wildcard members
codex Sep 23, 2026
fa8993a
Make member lookup explicit and guard constructor-pattern invariants
codex Sep 23, 2026
129cb17
Document constructor-pattern context mixing as a migration blocker
codex Sep 23, 2026
7065846
Unify record member symbols and centralize aggregate subscriptions
codex Sep 23, 2026
42247ef
Explain record and spread regression comments with concrete failure c…
codex Sep 23, 2026
670d826
Add dynamic resolution shapes and relax general test suite ambiguity …
codex Sep 23, 2026
dd87eb9
Migrate 54 more worksheets to new resolution
codex Sep 23, 2026
22e4d45
Merge new-resolution updates and isolate remaining migration failures
codex Sep 24, 2026
f3deeaa
Normalize constructor contexts across lexical instance boundaries
codex Sep 24, 2026
92afcaf
Minor
LPTK Sep 24, 2026
f7e7023
Avoid constructing cached constructor shape bases eagerly
codex Sep 24, 2026
185f15a
Guard mark chain scans with a disabled debug flag
codex Sep 24, 2026
c0b1f66
Build cached application contexts in reverse order
codex Sep 24, 2026
7d5d5fa
Minor
LPTK Sep 24, 2026
b9874a8
Move signature erasure into a dedicated compiler phase
codex Sep 24, 2026
62cf317
Add Metals MCP config for Codex
LPTK Sep 24, 2026
ceaf352
Treat declared types as opaque resolution shapes
codex Sep 24, 2026
55674b9
Avoid collection snapshots during shape notification
codex Sep 24, 2026
6552449
Propagate function constraints and resolve typed tuple projections
codex Sep 24, 2026
f187f26
Expose Array interfaces on tuple shapes and migrate unblocked tests
codex Sep 24, 2026
82f399d
Minor
LPTK Sep 24, 2026
2bba991
Distinguish marked callees from overapplied constructors in diagnostics
codex Sep 24, 2026
c73967c
Instantiate declared generic methods and preserve Array.map result types
codex Sep 24, 2026
39b6e48
Isolate resolver inference with contextual listeners and lazy importe…
codex Sep 24, 2026
156e167
Keep annotation validation local to its defining block
codex Sep 24, 2026
ad031bb
Centralize erroneous syntax flags in PossiblyErroneous
codex Sep 24, 2026
d52a96c
Check exposed resolution interfaces with lazy unknown provenance
codex Sep 24, 2026
b370c01
Limit worksheet exposure checks to strict resolution and enforce gene…
codex Sep 24, 2026
afa8b6c
Minor
LPTK Sep 24, 2026
fcf4870
Port compilation fixtures and expand resolution interfaces
codex Sep 24, 2026
48c129c
Explain unknown shapes from unannotated constructor fields
codex Sep 24, 2026
f96ec7e
Identify type annotations in unknown-shape diagnostics
codex Sep 24, 2026
11dc8ea
Resolve named tuple fields as records and support structural interfaces
codex Sep 24, 2026
17aea8c
Locate unknown receivers and simplify annotation diagnostics
codex Sep 24, 2026
5bfe047
Migrate parser worksheets and inherit Object interfaces
codex Sep 24, 2026
9384df1
Restore Array constructor interface and preserve typed spreads
codex Sep 24, 2026
f002a93
Merge branch 'new-resolution' of https://github.com/LPTK/mlscript int…
codex Sep 24, 2026
55e916e
Minor
LPTK Sep 24, 2026
86e0214
docs: streamline new-resolution migration notes
codex Sep 24, 2026
237fb39
fix: align new-resolution control-flow results with lowering
codex Sep 24, 2026
dd607db
fix: propagate mutable array elements through Array type parameter
codex Sep 24, 2026
b46c194
docs: explain mutable array shape propagation with examples
codex Sep 24, 2026
ddf1fa4
docs: plan type-value flow distinct from type bounds
codex Sep 24, 2026
4b418ae
docs: compare type-value and instance shape representations
codex Sep 24, 2026
6b07672
refactor(resolution): retain instance type references and document co…
codex Sep 24, 2026
7b98db7
test(resolution): retain recursive generic array regression
codex Sep 24, 2026
de8ea64
Document finite call-site instantiation and partial signature inference
codex Sep 24, 2026
a70fd8e
Complete call-site instantiation and partial signature design review
codex Sep 24, 2026
831c0c5
Preserve quantified resolution signatures and bound instance allocation
codex Sep 24, 2026
11459e4
Instantiate callable signatures at application sites
codex Sep 24, 2026
5857fe0
Preserve call-site binder views through inferred function bodies
codex Sep 24, 2026
a7b62fe
Relate nominal type arguments through contextual constraints
codex Sep 24, 2026
facba31
Bind stored specializations at their application sites
codex Sep 24, 2026
0dc32f0
Infer omitted generic arguments in annotations
codex Sep 24, 2026
a442854
Instantiate constructor type parameters at application sites
codex Sep 24, 2026
cc8f635
Record recursive type-graph termination failures and scope proposal
codex Sep 24, 2026
83cdaaa
Clarify type-flow design review and nested variance regressions
codex Sep 24, 2026
26673b0
Preserve occurrence polarity during type argument substitution
codex Sep 24, 2026
7a93af5
Correct instantiation sites for specialization and by-name calls
codex Sep 25, 2026
304f7ab
Clarify regular structural types and remaining termination obligations
codex Sep 25, 2026
1092faa
Instantiate schemes at specialization and by-name invocation sites
codex Sep 25, 2026
4c4074f
Keep type alias and structural field projections outside value scopes
codex Sep 25, 2026
f6483c1
Project declared type bindings onto finite source dependencies
codex Sep 25, 2026
1f329f6
Document receiver context failures and cover finite argument resets
codex Sep 25, 2026
46f7902
Cover regular recursion through transparent type aliases
codex Sep 25, 2026
543aafe
Preserve contextual type references through captures and projections
codex Sep 25, 2026
7a4702f
Retain input obligations for supplied member type arguments
codex Sep 25, 2026
96ed819
Use ordinary marks for deferred reference transport
codex Sep 25, 2026
9a9e938
Document annotation substitution context requirements
codex Sep 25, 2026
63cef5e
Normalize applied aliases before retaining type environments
codex Sep 25, 2026
c81e33b
Normalize recursive alias and Boolean type arguments
codex Sep 25, 2026
200d7d3
Reject unsupported recursive type growth conservatively
codex Sep 25, 2026
b318f6c
Bind captured specializations in their application scope
codex Sep 25, 2026
2bf2955
Fix lexical scope transfers in declared array and primitive interfaces
codex Sep 25, 2026
af5e9cc
Consolidate resolution documentation around current contracts and def…
codex Sep 25, 2026
9dea35c
Elaborate the prelude with new resolution and share completed symbol …
codex Sep 25, 2026
4026001
Migrate parser token modules and remove the legacy Option copy
codex Sep 25, 2026
ffdf119
Remove redundant JVM compiler tests and prefer diff coverage
codex Sep 25, 2026
e7fa506
Test resolution mark laws and document type-graph review failures
codex Sep 25, 2026
4c4f877
Collapse nested tuple rest views to their parent
claude Sep 25, 2026
91cf93c
Declare Array.reduce with an initial accumulator
claude Sep 25, 2026
3c8449f
Fix resolution graph convergence and generic constraints
codex Sep 25, 2026
cbc78eb
Locate declared members at their class's definition
claude Sep 25, 2026
c28d59b
Reject unguarded recursive type aliases
codex Sep 25, 2026
57d733a
Cover inherited nominal paths and array accumulator flow
codex Sep 25, 2026
076293f
Merge remote-tracking branch 'LPTK/new-resolution-typing' into new-re…
codex Sep 25, 2026
8a8b37e
Clarify value views, specialization, and activation shape roles
codex Sep 25, 2026
52317ff
Separate activation events from semantic value shapes
codex Sep 25, 2026
dac6dca
Small debloating
LPTK Sep 25, 2026
4937cf2
Record inherited-field dead-parameter elimination regression
codex Sep 25, 2026
c4246e4
Encode resolver shape and substitution invariants
codex Sep 25, 2026
89440c1
Merge pull request #29 from LPTK/new-resolution-typing
LPTK Sep 25, 2026
aaf4d13
Merge branch 'hkmc2' into new-resolution
LPTK Sep 25, 2026
e69653d
Preserve reasons for unavailable type interfaces in diagnostics
codex Sep 29, 2026
ecf8b74
Address type-interface diagnostic review comments
codex Sep 29, 2026
ae5bccb
Merge pull request #31 from LPTK/new-resolution-fix-1
LPTK Sep 29, 2026
7e3f5f1
Resolve static array indexing to the element type
codex Sep 29, 2026
0b30e20
Preserve array-spread substitutions and positional alternatives
codex Sep 29, 2026
e0b3d77
Name the array resolution flag checked instead of static
codex Sep 29, 2026
ecd9037
Minor cleanup
LPTK Sep 29, 2026
a220b02
Remove machine-specific paths from tooling configuration
codex Sep 29, 2026
ec41724
Include type annotation origins in resolution diagnostics
codex Sep 29, 2026
d48b60e
Attach type origins directly to resolution error messages
codex Sep 29, 2026
618eb34
Preserve explicit source locations on semantic declarations
codex Sep 29, 2026
23065bf
Make annotation, statement, parameter-list and IR locations explicit
codex Sep 29, 2026
f30a648
Preserve complete declaration spans while unwrapping annotations
codex Sep 29, 2026
4f483e6
Construct folded literals with the original operation location
codex Sep 30, 2026
e80a756
Merge branch 'hkmc2' into new-resolution
codex Sep 30, 2026
68b6734
Fix nominal parent scope transport and document Lexer migration blockers
codex Sep 30, 2026
f6842d8
Port two more compilation tests
LPTK Sep 30, 2026
0ac2d45
Add disclaimers for slopdoc
LPTK Sep 29, 2026
074b678
Minor
LPTK Sep 30, 2026
31f24f7
WIP
LPTK Sep 30, 2026
c5aeaee
Fix calls through builtin Function annotations
codex Sep 30, 2026
89666cd
Rename Iter iterator implementation to IteratorImpl
codex Sep 30, 2026
fc1309c
Preserve Function annotations in call-result diagnostics
codex Sep 30, 2026
3541d4f
Check callbacks erased to Function before sealing resolution
codex Sep 30, 2026
94cbf86
Order interface diagnostics along their provenance paths
codex Sep 30, 2026
2a04ec6
Port compilation tests to 0.3 with explicit exposed interfaces
codex Oct 1, 2026
3b0214f
Fix scope transport for omitted type arguments and port Iter
codex Oct 1, 2026
3202d30
Refine alias binding shapes in pattern definitions
codex Oct 1, 2026
6be0cf1
Minor
LPTK Oct 1, 2026
b2cdc1e
Migrate resolution worksheets and cover getter read effects
codex Oct 1, 2026
69158b9
Make migration documentation a current status and worklist
codex Oct 1, 2026
c451b70
Forward-port annotated FingerTreeList file; make minor test updates
LPTK Oct 1, 2026
3242089
Identify concrete remaining fixture migration failures
codex Oct 1, 2026
b04e0ad
Migrate collection and parser fixtures to new resolution
codex Oct 1, 2026
58a6522
Minor
LPTK Oct 1, 2026
b088388
Fix migration shape propagation and migrate Predef
codex Oct 1, 2026
a6c3bd9
Preserve scope paths and stabilize recursive pattern refinement
codex Oct 1, 2026
7f1d4db
Merge branch 'hkmc2' into new-resolution
LPTK Oct 2, 2026
edf802a
Minor
LPTK Oct 2, 2026
c71d6fa
Migrate remaining unblocked compilation fixtures to new resolution
codex Oct 2, 2026
66dd8e5
Refine negated patterns and preserve null-check semantics
codex Oct 2, 2026
ec5cc9c
Minor
LPTK Oct 2, 2026
87c51a0
Centralize collection read interfaces and make Iterator covariant
codex Oct 2, 2026
384f271
Merge record intersection interfaces through deferred field types
codex Oct 2, 2026
bb03a2d
Exclude compiler setup from concurrent import timeout
codex Oct 2, 2026
06241b2
Preserve cold setup in the concurrent import regression
codex Oct 2, 2026
6c20c19
Allow fifteen-second compiler cache waits on CI
codex Oct 2, 2026
5d43add
Migrate mlscript/basics/MiscArrayTests.mls
LPTK Oct 2, 2026
e839002
Port unblocked diff tests to new resolution
codex Oct 2, 2026
eda7156
Preserve direct scrutinee references in new resolution
codex Oct 2, 2026
3d71d4d
Add old disclaimer back
LPTK Oct 2, 2026
ff957e8
Defer member resolution errors until no target is found
codex Oct 2, 2026
f00a5fa
Preserve public-interface checks and combine selection diagnostics
codex Oct 2, 2026
3f70a2c
Remove obsolete eager-resolution casts and rebindings
codex Oct 2, 2026
5ddaf49
Restore direct accesses after lenient resolution
codex Oct 2, 2026
c46cfde
Fix subclass pattern refinement of self references
codex Oct 2, 2026
acfbefb
Approximate Boolean constraints during member resolution
codex Oct 2, 2026
0469918
Cover function intersection constraints and migrate lastpiece
codex Oct 2, 2026
e18f0d6
Fix buffered class resolution and evaluation context interfaces
codex Oct 3, 2026
eda9975
Fix recursive getter resolution cycles
codex Oct 3, 2026
26229c1
Migrate recursive function worksheets to new resolution
codex Oct 3, 2026
791dae0
Make various changes to Prelude, tests
LPTK Oct 3, 2026
1cadd9c
Use brace bodies throughout the Prelude
codex Oct 3, 2026
ab3ef8b
Test abstract class interface annotations with brace bodies
codex Oct 3, 2026
f0c6b08
Update Prelude again
LPTK Oct 3, 2026
952069a
Exclude directory configuration files from test discovery
codex Oct 3, 2026
b201c3d
Minor
LPTK Oct 3, 2026
a530dbd
Implement runtime class selection with C.class
codex Oct 3, 2026
a34b61a
Restrict .class syntax to class declarations
codex Oct 3, 2026
11d30be
Instantiate inferred runtime class values
codex Oct 3, 2026
ee68508
Minor
LPTK Oct 3, 2026
747c8ab
Recover runtime classes uniformly from constructor shapes
codex Oct 3, 2026
475016b
Simplify class companions and distinguish Wasm constructors
codex Oct 3, 2026
df4f4d5
Resolve projection qualifiers by class identity
codex Oct 3, 2026
14fbf20
Resolve Wasm session imports by definition identity
codex Oct 3, 2026
f8c40da
Derive projection classes from normalized qualifiers
codex Oct 3, 2026
001df84
Encode projection qualifier selection type statically
codex Oct 3, 2026
72755ed
Share metadata copying for typed selection clones
codex Oct 3, 2026
ab32e93
Use singleton return types for clone copying helpers
codex Oct 3, 2026
3453d76
Merge branch 'new-resolution' of https://github.com/LPTK/mlscript int…
LPTK Oct 3, 2026
d44ab2a
Merge branch 'hkmc2' into new-resolution
codex Oct 3, 2026
895918e
Resolve override relationships and support explicit super references
codex Oct 3, 2026
680a43f
Cover selections across subclasses inheriting the same member
codex Oct 3, 2026
0478299
Seal classes to their compilation unit unless open or abstract
codex Oct 3, 2026
877fd4e
Simplify superclass lowering and override metadata lifetime
codex Oct 3, 2026
8b96b65
Reorganize term impl. definitions and make small cleanups
LPTK Oct 3, 2026
d69b953
Handle remaining new-resolution value forms explicitly
codex Oct 3, 2026
b2c21ef
Explain unsupported async result resolution and cover promise behavior
codex Oct 3, 2026
db4ff5f
Resolve async function results as promises and migrate async worksheets
codex Oct 3, 2026
866e903
Preserve promise payload types through async resolution and await
codex Oct 3, 2026
a8d30d8
Align Promise signatures with TypeScript and use undefined for void c…
codex Oct 3, 2026
4605419
Temporarily disable new-resolution for `nofib/lastpiece`
LPTK Oct 3, 2026
946d217
Salvage scratch cases into focused regression tests
codex Oct 3, 2026
2b504ed
Address Copilot's review
LPTK Oct 4, 2026
7c3e8dd
Misc
LPTK Oct 4, 2026
cff6a25
Merge branch 'hkmc2' into new-resolution
claude Oct 9, 2026
25864b4
Key effective class members by definition identity
claude Oct 10, 2026
c746b7d
Fix resolver variance substitution through nested type arguments
codex Oct 10, 2026
4dcecbd
Merge branch 'hkmc2' into new-resolution
codex Oct 10, 2026
a068c87
Lower class selections and constructions on computed class values
claude Oct 10, 2026
7caa629
Merge branch 'new-resolution' of https://github.com/LPTK/mlscript int…
LPTK Oct 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .codex/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[mcp_servers.metals]
# Coursier (cs) and Git must be available on Codex's PATH.
# Resolve the checkout at launch time, including when Codex starts in a subdirectory.
command = "sh"
args = ["-c", 'workspace=$(git rev-parse --show-toplevel) && exec cs launch org.scalameta:metals-mcp_2.13:1.6.9 -- --workspace "$workspace" --transport stdio']
startup_timeout_sec = 180
tool_timeout_sec = 600
32 changes: 31 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

## Workflow

When working on Scala code, use the Metals MCP tools when available for semantic
symbol searches, inspection, documentation, and finding usages, and for quick
file or module compilation feedback. Codex's project configuration in
`.codex/config.toml` can launch the headless Metals server automatically.
If Metals is unavailable, continue with source searches and SBT, and report the
connection problem. Metals compilation and test tools do not replace the SBT
test prerequisites and final validation below.

It is best to leave the SBT shell open (by just typing the `sbt` command line)
and issue commands directly in that shell, as SBT startup is very slow.

Expand All @@ -21,6 +29,11 @@ Any commit that does not include the latest changes to test outputs will fail th

Please also read the files in `.github/skills/hkmc2-difftests`.

Use `.mls` diff tests for compiler behavior. Do not add Scala tests that duplicate
that coverage or merely pin internal representation or assertion details. Reserve
unit tests for properties diff tests cannot reliably observe, such as concurrency,
cache isolation, bounded graph growth, or algebraic laws; state the extra coverage.

When you create a commit, author it under your (the agent's) own identity,
not under the user's identity.
Set this identity for the commit command only
Expand Down Expand Up @@ -73,6 +86,24 @@ When appropriate, explain the history of what led to the current implementation,
especially if it involves non-obvious decisions/trade-offs
or if alternative approaches were considered and rejected.

Comments must be understandable from the current code alone, without the conversation,
commit history, or an earlier version of the implementation. Explain the concrete
invariant, behavior, or failure being prevented. Name the relevant data and operations;
avoid vague claims about where a "lifecycle" or "responsibility" belongs. If history
or a rejected alternative matters, include enough context to explain the tradeoff
after commits are squashed.


## User-Facing Diagnostics

Never use `showDbg`, `shwDbg`, raw AST/IR `toString` output, or other debug-only
representations in user-facing error messages, warnings, or diagnostic notes.
Use source-level names and user-facing descriptions, with source locations to
identify the relevant definitions or expressions. Do not expose internal symbol
IDs, resolution marks, or compiler representation details to users.
Debug representations belong only in internal logs and explicitly requested
debug output, not in ordinary diagnostics.


## Editing Style

Expand All @@ -97,4 +128,3 @@ to ensure that no needless empty-line changes are included in the PR. If you fin

When working with IR representations, please refer to the "Important design notes" in `hkmc2/shared/src/main/scala/hkmc2/codegen/Block.scala`.


240 changes: 240 additions & 0 deletions doc/new-resolution-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
NOTE: This document was written by Codex Astra and has not been deeply reviewed;
it is not meant to be official documentation and
is in fact likely to contain parts that are unintelligible to readers who lack sufficient context.


# New-resolution implementation invariants

This note describes the resolver's implementation contracts. User-facing rules
are in the [language reference](reference.md#resolution-interfaces); outstanding
ports and implementation gaps belong in the [migration worklist](new-resolution-suite-migration.md).

## Inference ownership and completed references

[`NewResolverState`](../hkmc2/shared/src/main/scala/hkmc2/semantics/NewResolverState.scala)
owns the inference graph and caches. Listeners have type
`TermShape => NewResolverState ?=> Unit`, so imported callbacks access hosts
through the consuming state. Importing copies accessed hosts' candidates and
listeners lazily; caches consult individual source entries on demand. It must
not copy or enumerate an exporter's entire resolver maps.

Type-parameter references retain their originating host. This lets exporter-private
inference on third-party parameters survive re-exporting. Legacy annotation
interpretations also remain local, rather than attaching consumer callbacks to
shared prelude syntax.

Completion seals each file or diff-test block's recorded decisions and original
host data read by erasure/lowering. Symbol flow and elimination listeners remain
active against private host data, but cannot change completed reference targets.
This applies even between worksheet blocks sharing an elaborator state. An unknown
reaching a sealed elimination can still report an error without changing its target.

[`PublisherTest`](../hkmc2/jvm/src/test/scala/hkmc2/PublisherTest.scala)
checks independent consumers and unchanged source candidates and listeners,
cycles, reentrant replay, transitive private inference, and bounded copying
in the presence of unrelated exporter hosts. `newres/GenericMethods.mls` covers
exported mapped arrays and imported generic functions and methods.

## Captures and generic flow

[Instance types and parameter constraints](new-resolution-type-value-flow.md)
specifies instance wrappers, input/output constraints, variance, canonical binder
instances, shared body views, and partial-signature inference. Its
[shape roles](new-resolution-type-value-flow.md#value-views-consumed-schemes-and-activation-events)
section distinguishes captured value substitutions, consumed callable schemes,
and inference-event activations, with examples and their representation invariants.
[Regular structural types](new-resolution-regular-types.md) specifies normalization
and the conservative recursion restriction. Do not duplicate those algorithms in
member lookup or value-flow handling.

Context fragments compose from a definition to its consumer; argument flow
traverses that composition in reverse. A class and its constructor share one
resolution boundary. Methods capture their enclosing instance scope as well as
the enclosing function scopes. Alias qualification and structural type-field
projection introduce no value boundary; modules introduce no invocation boundary.

[Lexical paths in resolution](new-resolution-scopes.md) derives the normal form,
boundary agreement, and depth bound from walks in the lexical scope tree. It also
states the endpoint obligations on producers and the separate requirement for
stable identities in recursive inference graphs.

A normalized mark path contains entries followed by exits, with no repeated
lexical boundary in either direction. `Shape.scala` enables assertions for this
invariant. Checking each new tail costs linear time in its depth; it must not be
replaced by truncating or widening paths. In particular, wildcard exit followed
by wildcard entry is not an identity: it can discard a caller's activation ID.
Reference transport uses the same operations as ordinary value flow.

The prelude uses its own `#lang(0.3.x)` directive. Its loader applies file
configuration before elaboration and erasure, and supplies the block's original
symbols for builtin lookup during bootstrap. Its signatures therefore carry the
same `Capture` syntax as other new-resolution declarations.

Legacy consumers can read completed new-resolution signature symbols through
`legacyResolvedSym`. The lookup asserts that the referenced block is complete and
shares erasure's symbol-selection rules, including ambiguity and error checks.
It does not resolve imported syntax again or observe incomplete candidate sets.

`newres/SpecializationCaptures.mls`, `RecursiveEnvironment.mls`, and
`ConstructorFieldRecovery.mls` exercise captured specialization, recursion, and
partial construction. `PrimitiveMembers.mls`, `Arrays.mls`, `GenericMethods.mls`,
and `MutableArrays.mls` exercise prelude signature captures and array member paths.
Receiver reconstruction and omitted-argument context precision are
[deferred improvements](new-resolution-future-work.md).

## Declared interfaces and exposure checking

Type interpretations retain arrows, type arguments, and lexical captures.
Generic aliases and inherited declared interfaces substitute their arguments;
declared member selections carry those contexts without reading implementation
value flow. An unannotated member read through a declared interface produces an
unknown shape, rather than consulting its initializer or method body.
Inferring these missing member types is a [deferred improvement](new-resolution-future-work.md#inferred-member-signatures)
that also requires override compatibility checks.
Callback parameter types constrain implementation parameters, and callback results
constrain inferred type arguments. `newres/DeclaredTypes.mls` covers these paths,
separate signatures, tuple constraints, and distinct generic instantiations.

[`InterfaceExposure`](../hkmc2/shared/src/main/scala/hkmc2/semantics/InterfaceExposure.scala)
checks values reachable through a file's exposed interface before completion.
Worksheet blocks run this pass only under strict resolution. It seeds unannotated
parameters with `UnknownValueShape` and follows returned functions, record/tuple
contents, public instance members, and both interpretations of exposed overloads.
Callable result annotations constrain returned implementations through their
declared domains. Private helpers retain local inference unless their values escape.

Discovery uses a queue and temporary observers of shape publishers. Each reached
shape is processed once, with listeners discovering subsequent candidates;
there is no repeated whole-graph scan. Observers detach before completion and
are never copied into consumer states. Imported new-resolution definitions have
already had their interfaces checked and are not recursively checked by importers.

Unknown values and unresolved spreads carry shared, lazy provenance. Messages,
locations, and diagnostic chains are materialized only on error; provenance does
not affect shape equality. Diagnostics can identify the parameter and the storage
and return steps that expose it. `newres/InterfaceExposure.mls` covers discovery,
typed closures, overloads, and later exposure of a private definition from an
earlier block; its expected failures also document remaining precision gaps.

## Structural and dynamic shapes

Record fields have their own `BlockMemberSymbol`s. Lookup follows overwrites and
spreads in source order, preserving selected values' shapes and captures. Named
fields in term tuples are expressions, not type annotations. Tuple shapes group
them into one trailing record, matching lowering while retaining source evaluation
order, last-write-wins lookup, computed-key uncertainty, and property identities
across imports. See `newres/NamedFields.mls`, `ImportedNamedFields.mls`, and
`RecordInterfaces.mls`.

Tuples preserve zero-based projections and expose the builtin Array interface.
An Array callback receives candidate shapes from every element. The
[language reference](reference.md#10-arrays) specifies mutable-array behavior and
the restriction imposed by explicit element annotations.

For a mutable literal, all element reads and writes use the builtin `Array[T]`
parameter's symbol. Marks distinguish allocations and enclosing calls. Cache the
nominal view before subscribing to the initializer so empty arrays can receive
writes and recursive arrays can refer to themselves. Numeric projections, spreads,
patterns, and callbacks all use the same element endpoint.

The nominal interface is located at the literal's use site. Its element reference
carries the allocation exit; the interface itself does not. Member lookup already
exits the nominal class scope. Adding the allocation exit to the entire view would
therefore cross that boundary twice. Initializer shapes enter the allocation
context before reaching the parameter host.

When an array is returned or otherwise exposed to callers, `InterfaceExposure`
also follows its element shapes. A function stored in that array must be checked
for calls from outside the compilation unit, just like a directly returned
function. `newres/MutableArrays.mls` and `CompilerTest` cover element flow,
separation between calls and importing compilation units, and exposed functions.
See the [migration worklist](new-resolution-suite-migration.md) for the remaining
`splice` contract and storage-reassignment gaps.

When an array's element shape is unknown, indexed access produces an unknown
shape; that does not authorize arbitrary member access on the result.
Tuple-pattern transfer handles leading, trailing, and rest elements, including
declared Array element types. See `newres/Arrays.mls` and `TuplePatternBindings.mls`.

An unknown-length tuple segment retains a deferred element field, just as a
fixed tuple position does. Tuple views instantiate both through the same field
representation, and indexing, array interfaces, argument transfer, and patterns
observe that field through `listenTupleField`. Unknown length does not erase the
element's type arguments or captured environment. A positional selection after
a spread includes every field that can occupy that position, including a fixed
suffix when the spread is empty; positions before a spread remain precise.
`newres/ArraySpreadViews.mls` covers these cases and distinct generic callers.

`DynShape` is distinct from `UnknownValueShape`: recursive widening, mutable reads,
and other losses of precision do not license dynamic lookup or calls. Known invalid
alternatives still report errors alongside dynamic candidates. Constructor patterns
narrow unknown inputs to declared class interfaces, retaining unknown type arguments
and provenance for unannotated fields instead of specializing them from local calls.

Dynamic selections have no fabricated nominal definition. Lowering retains the
runtime receiver and property name. Dynamic values propagate through record/tuple
spreads and unique wildcard opens; competing wildcard receivers still need
disambiguation. Class projections, constructor patterns, and type references require
known, unambiguous identities. See `newres/Dynamic.mls`, `Records.mls`,
`SpreadCalls.mls`, and `loose/Targets.mls`.

## Recursive getter results

Parameterless definition bodies have a shared result host, cached by definition
and generic activation before following the body. Recursive references subscribe
to that host instead of traversing the body again. An unproductive cycle has no
normal result candidates; a productive branch publishes candidates through the
cycle, with the publisher suppressing duplicates. No unknown or dynamic fallback
is introduced to stop recursion.

The host stores results at the body's lexical endpoint, including their activation
events. Each reference still applies its own exit and capture marks. Resolver-state
caches and consumer-local publisher copies preserve this graph across imports
without sharing mutable inference between consumers. `newres/RecursiveGetters`
checks cycles, later candidates, captures, generic specializations, imports, and
runtime getter effects.

## Normal results of control flow

Resolution must agree with lowering about which expressions produce values.
Assignments, `drop`, imperative conditionals, and loops return unit; their
operands or branch results must not supply the result's member interface.
A normally completed `try` returns its body's value, preserving its capture
marks, while the `finally` clause runs for effects. `throw` and `continue` supply
no normal result. `newres/ControlFlowResults.mls` checks these contracts, including
backtracking assignment and independent calls through cleanup blocks.

## Overloads, foreign declarations, and lowering

Ordinary values select function/constructor overloads; selection receivers select
companion modules. Preserve this distinction through nested captures and opens.
`newres/OverloadedCalls.mls` covers direct, generic, stored-function, module-member,
and captured uses.

Bare classes can share their name with a function definition that has a parameter
list. The generated function owns the class reference, so JS uses the existing
`.class` property for references, selections, and imports. Arbitrary values,
parameterless functions, and term declarations cannot supply that companion:
their results may be primitive, aliased, or frozen, and must never be augmented.
Instance methods cannot supply per-instance companions either, because their
function objects are shared. Inlining may replace calls to a companion function,
but must preserve its binding while the class is used. WASM identifies constructor
functions by their class symbols, separately from explicit function companions.
Session imports follow the selected definition and cast target, rather than MIR
`freeVars`, which tracks lexical bindings introduced by `Scoped`. Importing a
class must not also import its function companion: the two have independent
signatures and can be shadowed independently in later worksheet blocks.

Foreign declarations expose call and constructor capabilities explicitly.
The JS backend uses native class values for `new` and patterns without generated
MLscript `.class` storage. Bodyless foreign methods use foreign-call normalization
even when `declare` is on the enclosing class, so JavaScript `undefined` results
follow the existing unit normalization. Prelude declarations are parsed as one
compilation unit, permitting references across blank lines.

Generated runtime-helper selections, such as `runtime.assertFail`, are synthetic;
they do not provide a fallback for unresolved source selections. Free-variable
collection and assignment lowering must handle resolved direct references and
retain the existing binding/assignment checks. Constructor-pattern resolution
discards every nested capture when recovering class identity; leaving one behind
can make generated patterns test a constructor function instead of its class.
Loading
Loading