Skip to content

LSP: recheck dependents only when a package's public ABI changes (draft, known issues) - #1368

Draft
Frotty wants to merge 2 commits into
masterfrom
split/lsp-abi-invalidation
Draft

Frotty wants to merge 2 commits into
masterfrom
split/lsp-abi-invalidation

Conversation

@Frotty

@Frotty Frotty commented Oct 6, 2026

Copy link
Copy Markdown
Member

Split out of #1353. Draft, do not merge as is: a review found that gating importer invalidation on a public-ABI hash is not sound in its current form.

PackageAbi.computeAbiHash hashes what other packages can see of a package. ModelManagerImpl keeps the last hash per package and only pulls importers into the partial typecheck when it changed. syncCompilationUnit now reports every re-checked file, a newly added file clears its dependents, and syncProjectFiles() reconciles the model with the wurst/ folder. PrettyPrinter no longer indexes an empty buffer (printing a module hit it).

Confirmed problems (each reproduced with a throwaway test):

  • When the hash is unchanged, importers keep cached attributes that point at the replaced file's AST: stale go-to-definition and usages, and a stale IM translation when running tests on the live model. A body edit in P followed by an edit in K can report a false Cannot assign Foo to Foo. Fix direction: always clear the attributes of all transitive importers and gate only re-validation on the hash.
  • The hash misses constructor signatures (the isPublic filter never matches a valid constructor), members reached through non-public base classes or modules, interface method bodies (abstractness) and import initlater.
  • The hash is stored even when the check was skipped because of an unrelated error (an unresolved import).
  • calculateCUsToUpdate evaluates attrTyp() on a freshly parsed, detached unit and can publish spurious diagnostics.
  • updateModel now runs calculateCUsToUpdate for every new file during the initial load; measured load phase is about 2-3x slower at 1000-3000 files.
  • syncProjectFiles has no caller and mishandles .j files.

Opening it as a draft so the work and findings are not lost; the sound variant gives up most of the benefit.

PackageAbi hashes what other packages can see of a package (public signatures,
modifiers, inferred types, constant initialisers, module bodies). ModelManagerImpl
keeps the last hash per package and only pulls importers into a partial typecheck
when it differs, reports every re-checked file in Changes, clears dependents when a
new file appears, and gains syncProjectFiles() to reconcile the model with disk.
PrettyPrinter no longer indexes an empty buffer, which printing a module hit.
Frotty added a commit to Code-Fixxers/WurstScript that referenced this pull request Oct 6, 2026
Drop changes that are split out or independent of the chunk cache and validation
cache: the hashtable rewrite and compile-time runner changes (wurstscript#1367), the
ABI-gated model invalidation (wurstscript#1368), the EliminateGenerics rewrite, parallel/fused
lowering passes, the reachable-only LocalPlayerContextAnalyzer, the w3i cache, the
closure-name suffix and timing/micro-optimisation churn. Keeps what -incremental
needs: chunk cache, PackageAbi, validation cache, modular Lua translation, the
CLI/LSP incremental pipeline and their tests.
Keeps master's unchecked-unit tracking, Jass-name and removal propagation.
ABI hashes are stored only after a check that validated, and a package with
a config relative in the model propagates to all its users whatever the edit.

IncrementalModelOracleTests still fails (config seed 1): an importer keeps
its binding into a replaced unit whose public ABI did not change, the
known stale-attribute problem in the description.

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