chore(config): freeze CodeIqConfig mutation surface (#49)#53
Merged
Conversation
…e helper Collapse the four production call sites that mutate the CodeIqConfig Spring singleton (ServeCommand, EnrichCommand, CliOutput, Analyzer) through a single package-adjacent helper. This pins the "mutation happens once at CLI startup" contract in one place and sets up a follow-up commit to tighten the bean's setter visibility to package-private. - New CliStartupConfigOverrides with applyServeOverrides / applyCacheDir / applyServiceName. Null/blank inputs are no-ops — never overwrite an in-code default with an absent value. - Analyzer.runSmartWithCache now routes service-name propagation through the helper (same semantics, same guard condition). - Six unit tests verify each helper mutates only the intended fields on a freshly-adapted CodeIqConfig and that null/blank inputs are no-ops.
…rivate Drop `public` from every setter on CodeIqConfig and its Graph inner class. Production mutation is now restricted at compile time to: - UnifiedConfigAdapter.toCodeIqConfig (once, at Spring startup) - CliStartupConfigOverrides (once per JVM, at CLI entry) Both live in `io.github.randomcodespace.iq.config` and reach the package-private setters directly. Every other code path — controllers, MCP tools, background workers — loses the compile-time ability to mutate the Spring singleton. This is the mutation hazard cleanup #49 called for. Test migration: - Two in-package tests (CodeIqConfigTest, GraphBootstrapperTest) keep working unchanged. - 15 out-of-package test classes across `iq.api`, `iq.cli`, `iq.intelligence.*`, `iq.mcp`, `iq.query` are migrated to route setter calls through a new test-only helper CodeIqConfigTestSupport (lives in src/test/java/io/github/randomcodespace/iq/config/, so tests compile against the package-private setters). Fluent API keeps call sites readable: `CodeIqConfigTestSupport.override(config).rootPath(x).done();` The name makes the test-only intent unmistakable and the helper is not reachable from production code paths. - 51 call sites rewritten; semantics preserved verbatim. Full suite green: 3278 tests, 0 failures, 31 skipped (baseline unchanged).
|
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
Closes follow-up task #49: eliminate the setter-mutation hazard on the Spring-singleton
CodeIqConfigbean. Production code outside theio.github.randomcodespace.iq.configpackage can no longer mutate the bean.Approach (Path 3 — package-relocate + tighten visibility)
Four production CLI sites were mutating the shared
CodeIqConfigsingleton after Spring startup, propagating state to every@Autowiredconsumer. Rather than a cascading architectural refactor (routing CLI flags throughConfigResolver.cliOverlay()— Phase-C work), this PR:CliStartupConfigOverridesin theiq.configpackage — a small, named, documented helper for the CLI startup phase with three entry points:applyServeOverrides,applyCacheDir,applyServiceName. Null/blank-safe.ServeCommand,CliOutput,EnrichCommand,Analyzer) to the helper.publicfrom everyCodeIqConfigsetter. External packages no longer compile against the mutation surface; future-drift is impossible without a deliberate helper extension.CodeIqConfigTestSupport(test classpath only,iq.configpackage) so 15 test classes can keep constructing arbitrary per-test instances without scattering them across packages.Commits
6ea345erefactor(config): centralize CLI startup overrides in a config-package helperc032373refactor(config): tighten CodeIqConfig setter visibility to package-privateTests
CodeIqConfigTestSupport.override(config).rootPath(x).done()API.Notable
CliOutput.setServiceName; routed throughapplyServiceName.CodeIqConfigTestSupportlives in the test classpath only. Production code cannot import it.Follow-ups (tracked)
SQL_ENTITYNodeKindUnifiedConfigBeansTestto avoid full@SpringBootTestcontextTest plan
mvn -B teston merge commit reports 3278 passcode-iq serve <root>still correctly scopes to the given rootcode-iq enrich --cache-dir <path> <root>still writes cache to the given directory🤖 Generated with Claude Code