Auto-resolve overloaded service pyspec files in pyAnalyzeLaurel#515
Draft
joehendrix wants to merge 3 commits intomainfrom
Draft
Auto-resolve overloaded service pyspec files in pyAnalyzeLaurel#515joehendrix wants to merge 3 commits intomainfrom
joehendrix wants to merge 3 commits intomainfrom
Conversation
Walks a Python AST against a dispatch overload table to discover which service modules a program actually uses, so only the needed pyspec files are loaded. Output is sorted, deduplicated module names, one per line. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When --dispatch files are provided, pyAnalyzeLaurel now automatically discovers which pyspec files are needed by walking the program AST with resolveOverloads, eliminating the need for manual --pyspec flags in the common case. Explicit --pyspec flags are still supported and appended after auto-resolved paths. Also extracts shared helpers (readDispatchOverloads, extractStmtsFromProgram) and simplifies pyResolveOverloadsCommand to use the shared dispatch-reading logic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move all dispatch-reading and auto-resolve logic into a standalone resolveAndBuildPrelude function, keeping pyAnalyzeLaurelCommand focused on the verification pipeline. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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.
Summary
When verifying Python programs that use overloaded service clients,
users currently must manually specify a
--pyspecflag for everyservice module the program touches. This is tedious and error-prone,
especially as programs grow.
This PR integrates the
resolveOverloadsAST walker (added in theprevious commit) into
pyAnalyzeLaurelso that when--dispatchfilesare provided, the command automatically discovers which
.pyspec.st.ionfiles are needed and loads them—eliminating the needfor manual
--pyspecflags in the common case.Details
overload table,
pyAnalyzeLaurelnow walks the Python AST withresolveOverloadsto collect the set of service modules actuallyused. For each resolved module, it derives the pyspec path relative
to the dispatch file's directory and checks that the file exists on
disk. Auto-resolved files that are not found are skipped with a
warning on stderr, since the program may reference services for
which no spec has been written yet. In contrast, files explicitly
provided via
--pyspecor--dispatchstill produce a hard errorif they are missing or unreadable, since an explicit flag implies
the user expects the file to exist.
readDispatchOverloadshelper. The dispatch-file-readingloop (read DDM, extract overloads, print warnings, merge tables) was
duplicated between
pyAnalyzeLaurelCommandandpyResolveOverloadsCommand. Both now call a singlereadDispatchOverloadsfunction, reducing duplication and ensuringconsistent error handling.
extractStmtsFromProgramhelper. Small utility that encapsulatestoPyCommands+unwrapModulefor extracting top-level Pythonstatements from a Strata program.
--pyspecflags continue towork unchanged; they are appended after auto-resolved paths so that
user-specified specs always take effect.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.