refactor(analyzer): extract synthesizers + resolution_outcomes into pure cores#169
Merged
Conversation
…ure cores Pull the synthesizers and resolution-outcomes analyzers out of the MCP handlers into a new internal/analyzer package as pure calculations (graph in, struct out): AnalyzeSynthesizers, AnalyzeResolutionOutcomes, and ClassifyUnresolved. The taxonomy constants now live in internal/analyzer as the single source of truth, with thin aliases kept in the mcp package for existing call sites and tests. handleAnalyzeSynthesizers and handleAnalyzeResolutionOutcomes now delegate to the cores; output shapes are unchanged, so the existing MCP-layer tests are the regression net. The stdlib_header outcome is carried into the core, and nodeIsDefinitionKind stays in the mcp package because id_resolve.go also depends on it. Adds unit tests for both cores: synthesizer grouping + name filter, and the full unresolved-edge taxonomy + reason filter + stdlib_header. Co-authored-by: avfirsov <afirsov410@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.
What
Extracts the synthesizers and resolution_outcomes analyzers out of their MCP handlers into a new
internal/analyzerpackage as pure calculations (graph in, struct out):AnalyzeSynthesizersAnalyzeResolutionOutcomes/ClassifyUnresolvedhandleAnalyzeSynthesizersandhandleAnalyzeResolutionOutcomesnow delegate to these cores. Output shapes are unchanged — the existing MCP-layer tests pass as-is and are the safety net for the refactor. The resolution-outcome taxonomy constants now live ininternal/analyzeras the single source of truth, with thin aliases retained in themcppackage so existing call sites/tests keep compiling.Provenance
This is the reusable half of #84 by @avfirsov, kept as a co-authored commit. The daemonless
gortex analyzeCLI from that PR is intentionally not included here:gortex analyzealready exists onmainas a daemon-routed verb over the full analyze dispatcher (all kinds,--format json|gcx|toon|text,gortex analyze kinds), and a parallel in-process command would both collide with it and cut against the daemon-centric direction. This PR keeps only the part with lasting value — the pure-core extraction and the DRY refactor of the two handlers.Two reconciliations against current
main(both landed after #84's base, so the original PR couldn't see them):stdlib_headeroutcome (C/C++/ObjC standard-library angle-includes) is carried into the extracted core, with a matching core-level test.nodeIsDefinitionKindstays in themcppackage becauseid_resolve.goalso depends on it; onlyclassifyUnresolved/sameLanguageFamilymove into the analyzer.Tests
internal/analyzer: unit/shape tests for both cores — synthesizer grouping + name filter; the full unresolved-edge taxonomy + reason filter +stdlib_header.internal/mcpanalyze handler tests unchanged and green.go build ./...,go vet, andgolangci-lintclean;go test ./internal/analyzer/... ./internal/mcp/...passes (2470 tests).Running
analyzein CI (no resident daemon to babysit)The original motivation behind #84 was a one-shot, CI-style invocation — "index a path once, get JSON, exit" — e.g. to A/B a fork against baseline. That capability already ships via the daemon-routed
gortex analyze; in CI the daemon is ephemeral per-run, so reproducibility is intact. Modeled onexamples/.github/workflows/gortex-architecture.yml:gortex track --wait(PR #170) blocks until the daemon has indexed the repo, so the recipe needs no poll loop. On a build without that flag, replace it withgortex track .followed by a wait — e.g.for i in $(seq 1 60); do gortex status | grep -qE '[1-9][0-9]* nodes' && break; sleep 2; done.gortex analyze kindslists every supported kind. For a fork-vs-baseline A/B, run the same steps against each checkout anddiffthe JSON. On native Windows where two builds run side by side, isolate state per build (separateGORTEX_HOME/ socket) rather than reaching for a separate daemonless code path.