refactor(cache,cqrs,config,performance): resolve data-clump smells (PLF-034..PLF-040) - #91
Merged
Merged
Conversation
Co-authored-by: Koru Agent <agent@coru.dev>
Add regix.yaml (bootstrapped via regix init) as the regression metrics gate — delta layer for CC / MI / coverage between git refs — on top of the existing prefact/redsl/pyqual current-state gates. Hard gates match the repo's declared pyqual.yaml standards (cc_max 15, coverage_min 40); docstring stays ungated (target-only) as pyqual has no docstring gate. Ignore local .regix/ gate artifacts. Verified: regix status loads config with all backends (lizard, radon, pytest-cov, ast); regix gates --ref HEAD reports 2 legacy hard violations (todo_manager._classify_legacy_lines cc 18, generator.generate_extended_config length 102); regix compare HEAD~1 HEAD detects the engine.py metric regressions introduced by the CQRS commit. redsl.yaml's enabled 'regix' validate step now resolves. Co-authored-by: Koru Agent <agent@coru.dev>
code2llm's duplication detector auto-created PLF-028 for the
DataProcessor pair in examples/01-individual-rules/unused-imports/
{before,after}.py — but those files are a before/after rule fixture
that is near-identical by design (after.py must equal prefact fix
output on before.py), like every directory under
examples/01-individual-rules/. Consolidating them would break the
standalone demo and be inconsistent with the other rule fixtures
that trigger the same finding class.
Exclude examples/ from code2llm analysis instead, by overriding the
code2llm tool preset in pyqual.tools.json (--exclude examples on the
pyqual analyze stage), mirroring koru's STARTER-276 'plugins'
precedent for intentional duplication. Decision recorded in ADR-0002
and indexed in docs/README.md.
Verified: baseline code2llm run reproduces the
code2llm:dup:DataProcessor ticket; re-run with --exclude examples
yields 0 duplicate-class tickets and 0 examples-referencing dedupe
keys while keeping 244 real src/ findings; pyqual resolves the
override with allow_failure=false preserved; prefact scan on the
untouched example directory still runs; tests/test_unused_imports.py
and tests/test_rule_registry.py pass (9 passed).
Co-authored-by: Koru Agent <agent@coru.dev>
…o (PLF-030) code2llm flagged 'Shotgun Surgery: engine' at examples/06-api-usage/example.py:121: the three demo functions each repeated 'engine = RefactoringEngine(config); engine.run()'. Extract run_engine() as the file's only engine construction point (engine-mutating scopes in the file: 3 -> 1, smell detector now clean). Also map the demo's result display onto the current PipelineResult model (issues_found/fixes_applied/validations) — the CQRS pipeline migration left the example crashing on stale attributes (files_scanned/issues_by_rule/fixes/ validation_failures), which blocked verifying the refactor end to end. Verified: pytest -m 'not slow' (123 passed, 1 pre-existing skip), ruff format clean and no new ruff findings, regix review --patch PASS, example runs in main and batch modes. Co-authored-by: Koru Agent <agent@coru.dev>
…emo (PLF-031) code2llm flagged 'Shotgun Surgery: message' at examples/01-individual-rules/string-concat/after.py:4 (variable 'message' mutated in 9 function scopes repo-wide). Inline the single-use temp into the return statement — the smallest change that removes the flagged mutation while keeping the f-string conversion demo intact (string-concat is scan-only, so after.py is illustrative, not fixer output; before.py keeps the concatenation input fixture untouched). Mirror the inline form in examples/generate_examples.py and the directory README so regeneration does not reintroduce the mutation. Note: the active pyqual code2llm gate already excludes examples/ (ADR-0002, PLF-028); a fresh gate-configured code2llm run generates no 'Shotgun Surgery: message' ticket. Verified: pytest -m 'not slow' (123 passed, 1 pre-existing skip), ruff format clean and no new ruff findings, regix review HEAD->local PASS, prefact scan on the example dir unchanged (before.py still flags ast-string-concat/string-concat-fstring, after.py clean of concat). Co-authored-by: Koru Agent <agent@coru.dev>
Extract GitHooks._is_prefact_hook() as the single source of truth for whether a hook file was installed by prefact. list_hooks() now builds its status mapping via a dict comprehension over that predicate, uninstall_hooks() reuses the same predicate instead of duplicating the content check, and the scattered 'status' variable mutations in list_git_hooks() and main() are removed. Resolves the code2llm 'Shotgun Surgery: status' smell reported at src/prefact/git_hooks.py:361. Co-authored-by: Koru Agent <agent@coru.dev>
…re (PLF-033) code2llm flagged 'Shotgun Surgery: user' at examples/sample-project/cli.py:15 (variable 'user' mutated in 5 function scopes repo-wide). Give each local a role-specific name so the generic shared name no longer spans functions: new_user for the constructed User in cli.main() and create_user(), loaded for the loop binding in load_users_from_file(), entry for the loop binding in cli.users(). The 01-individual-rules fixtures keep their illustrative bodies (out of scope; remaining scopes are below the detector threshold). The fixture keeps its intentional flaws (print statements, string concat, missing datetime import) so scan demos are unaffected. Verified: fresh code2llm planfile run generates no 'Shotgun Surgery: user' ticket; prefact scan on examples/sample-project unchanged (99 issues, identical per-rule counts); pytest -m 'not slow' (123 passed, 1 pre-existing skip); ruff format clean; ruff check shows only the 3 pre-existing F821 datetime findings present on HEAD; regix review PASS (0 errors). Resolves #28. Co-authored-by: Koru Agent <agent@coru.dev>
…ommands (PLF-052)
code2llm flagged 'Shotgun Surgery: console' at src/prefact/cli.py:440
(variable 'console' bound in 6 scopes repo-wide). Drop the per-function
Console() constructions in autonomous_cmd() and rules() and use the
shared console from prefact._base ('Shared console instance for the
entire prefact package'), reducing the binding count to 4 scopes —
below the detector's >=5 threshold.
Verified: fresh code2llm planfile run generates no 'Shotgun Surgery:
console' ticket; 'prefact rules' output unchanged; pytest -m 'not slow'
123 passed, 1 pre-existing skip; ruff format clean; ruff check pass;
regix review PASS (0 errors, +0.22 MI on cli.py).
Resolves #47.
Co-authored-by: Koru Agent <agent@coru.dev>
…nd critical (PLF-037) Co-authored-by: Koru Agent <agent@coru.dev>
Co-authored-by: Koru Agent <agent@coru.dev>
… (PLF-035, PLF-036) Co-authored-by: Koru Agent <agent@coru.dev>
Co-authored-by: Koru Agent <agent@coru.dev>
…-039) Co-authored-by: Koru Agent <agent@coru.dev>
…040) Co-authored-by: Koru Agent <agent@coru.dev>
…-sourcing # Conflicts: # .gitignore # docs/README.md # docs/decisions/0001-cqrs-event-sourcing.md # docs/decisions/0002-exclude-example-fixtures-from-code2llm-analysis.md # regix.yaml # src/prefact/cqrs/__init__.py # src/prefact/cqrs/bus.py # src/prefact/performance/cache/__init__.py # src/prefact/performance/cache/rule.py # src/prefact/performance/cache/scan.py # tests/test_cqrs.py Co-authored-by: Koru Agent <agent@coru.dev>
…-sourcing # Conflicts: # src/prefact/logging/logger.py Co-authored-by: Koru Agent <agent@coru.dev>
This was referenced Sep 19, 2026
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 #29, closes #30, closes #31, closes #33, closes #34, closes #35.
Verification