Re-check consumer scripts when an included module changes (#165)#167
Open
bentsherman wants to merge 1 commit into
Open
Re-check consumer scripts when an included module changes (#165)#167bentsherman wants to merge 1 commit into
bentsherman wants to merge 1 commit into
Conversation
Editing a module left stale diagnostics in its consumers. The consumer was re-type-checked, but only the directly-changed files were re-parsed, so the consumer's nodes kept stale INFERRED_TYPE metadata and getType() short-circuited on the cached value -- a changed process output type was never observed. Transitive consumers were not re-checked at all. Expand the invalidation set (before parsing) to include every cached file that transitively includes a changed file, so consumers are re-parsed from fresh AST nodes and their cross-file inferred types are recomputed. Signed-off-by: Ben Sherman <bentshermann@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Follow-up to b29edb8 for #165. That commit fixed the cold-scan false warning by type-checking included modules before their includers. This addresses the remaining incremental-invalidation half of the issue:
Root cause
Editing a module did add its direct consumer to the change set, so the consumer was re-type-checked — but only the directly-changed files are re-parsed. Consumers pulled in during analysis were re-type-checked over their old AST nodes, which still carried
INFERRED_TYPEmetadata from the previous run. SincegetType()short-circuits on cachedINFERRED_TYPE, a changed process output type was never observed (e.g.ch_producedkept resolving to the staleChannel<Record{id, data}>). Transitive consumers (A → B → C) were never re-checked at all.Fix
Add an
expandInvalidation()hook inASTNodeCache.update()(default no-op) that runs before parsing.ScriptAstCacheoverrides it to walk the reverse include graph and pull every transitive consumer into the invalidation set, so consumers are re-parsed from fresh (metadata-free) AST nodes and their cross-file inferred types are recomputed. Reuses the existing parse→analyze pipeline and thelocalIncludeUrihelper.Testing
New test in
ScriptDiagnosticsTest: with a compatible producer→consumer wiring, edit only the producer module to emit an incompatible record → the consumer call now reports the mismatch; restore the producer → the stale warning clears. Verified it fails without the fix and passes with it. Full suite green.Known ceiling
expandInvalidationrebuilds the reverse graph each update andlocalIncludeUridoes oneFiles.isDirectorystat per include — fine at debounced-update cadence; memoize if it shows up on a large workspace. Remote/plugin includes are still not tracked.