Skip to content

refactor: land completed PLF-135 through PLF-146 changes - #192

Merged
tom-sapletta-com merged 12 commits into
mainfrom
ticket/PLF-141-shotgun-surgery-result
Sep 19, 2026
Merged

tom-sapletta-com merged 12 commits into
mainfrom
ticket/PLF-141-shotgun-surgery-result

Conversation

@tom-sapletta-com

Copy link
Copy Markdown
Contributor

Lands the completed commits currently queued above origin/main:

  • PLF-135, PLF-136, and PLF-137 Planfile ticket-state reconciliations
  • PLF-141: centralize run_command
  • PLF-144: record the completed total_lines smell ticket
  • PLF-146: centralize lowercased path matching in tagi.utils.paths

Validation: pytest -q — 127 passed. ruff check src tests still reports 24 pre-existing unused-import/unused-variable findings outside this change set.

tom-sapletta-com and others added 12 commits September 19, 2026 20:39
…print state

The code2llm 'Shotgun Surgery: builder' finding (src/tagi/utils/
summary_helpers.py:71, evidence sha 5b80ca05) was captured before
commit 84a10ae (PLF-101) removed the last builder mutations by
constructing LineBuilder from declared lines. Current code contains
no builder variable and the refreshed code2llm discovery no longer
reports the smell, so no source change is required.

Verified: rg finds no builder binding in src/; 127/127 pytest pass.
Marked PLF-135 done via planfile and staged only its ticket-block
removal, leaving unrelated queue churn uncommitted.

Co-authored-by: Koru Agent <agent@coru.dev>
…print state

The code2llm 'Shotgun Surgery: cmd' finding (src/tagi/scanner/diff.py:6,
evidence sha e779a23e) was captured at 2026-09-18T19:41:42Z, before
commit 65a9a42 (PLF-102, 21:41Z) removed the last cmd bindings by
passing argv inline to single command owners. Current code keeps no cmd
variable: scanner functions pass argv literals to subprocess.run and
BaseProvider._run_command takes cmd only as a read parameter. The
refreshed code2llm discovery no longer reports the smell, so no source
change is required.

Verified: code2llm DFG mutation analysis over src/ shows cmd mutation
span 0 (no variable at the >=5-scope threshold changed); 127/127 pytest
pass; ruff on diff.py reports no findings. Marked PLF-136 done via
planfile and staged only its ticket-block removal, leaving unrelated
queue churn uncommitted.

Co-authored-by: Koru Agent <agent@coru.dev>
…print state

The code2llm 'Shotgun Surgery: logger' finding (src/tagi/utils/logger.py:9,
ticket created 2026-09-18T19:46:39Z) was captured before commit f83ce10
(PLF-113, 2026-09-19T11:20Z) dropped the mutable global logger from
cli/main.py in favor of the shared logging registry. Current code keeps the
logger name in only 3 mutation scopes (setup_logger, setup_logging, koru
module), below the >=5-scope shotgun threshold. The refreshed code2llm
discovery no longer reports the smell, so no source change is required.

Verified: code2llm DFG mutation analysis over src/ shows logger mutation
span 3 scopes (setup_logger, setup_logging, providers.koru module), under
the >=5 threshold; 127/127 pytest pass; ruff on logger.py reports only a
pre-existing UP045 style finding unrelated to this smell (restructuring of
setup_logger stays covered by the open God Function ticket PLF-168/173).
Marked PLF-137 done via planfile and staged only its ticket-block removal,
leaving unrelated queue churn uncommitted.

Co-authored-by: Koru Agent <agent@coru.dev>
…n surgery

Centralize the duplicated subprocess.run pattern in tagi.utils.commands.run_command
and route scanner, planner, executor, provider and CLI call sites through it.
GitExecutor._run_command and BaseProvider._run_command now delegate to the shared
helper, and callers no longer bind a uniformly-named 'result' variable (previously
mutated across 20 functions), so code2llm no longer reports Shotgun Surgery: result.

Co-authored-by: Koru Agent <agent@coru.dev>
…print state

The code2llm 'Shotgun Surgery: total_lines' finding (src/tagi/utils/inspect_helpers.py:96,
ticket created 2026-09-18T21:45Z) was captured against the pre-PLF-130 monolithic
inspect_helpers.py (3639 bytes at discovery time). The total_lines shotgun surgery was
already removed by 5330de1 (PLF-087, single-owner total_lines_changed) and consolidated
by cf0ceb0 (PLF-108), after which d598aee (PLF-130) shrank inspect_helpers.py to a
25-line facade, so the reported line no longer exists. Current code keeps exactly one
mutation scope for the computation, total_lines_changed in src/tagi/utils/risk.py:8;
all 7 former call sites (change_stats, composer.summary, send_helpers, publish_helpers,
summary_helpers, planner.grouper, analyzer.metrics) consume the helper, and no
'total_lines =' accumulation remains anywhere in src/. No source change is required.

Verified: rg shows zero total_lines assignment sites in src/ and a single
sum(c.lines_changed ...) inside the risk.py owner; 127/127 pytest pass; ruff findings
on the involved modules are the pre-existing baseline style set (UP006/UP035 et al.,
373 across src/), unrelated to this smell. Marked PLF-144 done via planfile and staged
only its ticket-block removal, leaving unrelated queue churn uncommitted.

Co-authored-by: Koru Agent <agent@coru.dev>
…shotgun surgery

Centralize the lowercased-path matching pattern in tagi.utils.paths
(path_key/path_matches/path_endswith) and route config, heuristics tags
and metrics call sites through it. Callers no longer bind a uniformly
named 'path_lower' variable (previously mutated across 8 functions), so
code2llm no longer reports Shotgun Surgery: path_lower.

Co-authored-by: Koru Agent <agent@coru.dev>
…ags shotgun surgery

code2llm flagged 'Shotgun Surgery: tags' (src/tagi/composer/formats.py:16
at scan time): the generic local name 'tags' was bound and mutated in 5
function scopes across composer, config and heuristics, so tag-handling
changes appeared to require work in many unrelated places.

Each binding now says exactly what it holds, and _tag_change remains the
single owner of the canonical 'tags' accumulation (mutation span 5 -> 1):

- composer/_tags.summary_tag: rename to unique_tags (all_tags returns the
  unique tag list).
- composer/formats.generate_conventional_message: rename to tag_set (the
  binding is a set of Tag).
- config.get_heuristics_for_path: replace the extend accumulator with an
  equivalent list comprehension (binding removed).
- heuristics/tags._custom_config_tags: rename to valid_tags (only valid Tag
  values are kept).

Verified with code2llm mutation analysis: no 'Shotgun Surgery: tags'
smell is reported; shotgun_surgery list is empty.

Local regression gates: pytest (127 passed) and ruff on the touched
files (42 findings, identical codes to the HEAD baseline).

Co-authored-by: Koru Agent <agent@coru.dev>
…n surgery

code2llm flagged 'Shotgun Surgery: result' (src/tagi/analyzer/dependency_graph.py:63
at scan time, sha 56c60106): the generic accumulator name 'result' was mutated in
21 function scopes, so result-handling changes appeared to require work in many
unrelated places. 5854647 (PLF-141) already removed the 20 subprocess-caller
bindings via the shared run_command helper, and 53b090d (PLF-122) moved the flagged
find_dependency_order loop into _LevelOrder.levels.

Finish the eradication by giving the one remaining binding a name that says what
it holds (mutation span 21 -> 0):
- analyzer.dependency_graph._LevelOrder.levels: rename to commit_groups, matching
  the docstring's 'commit groups' contract.

Verified with a fresh code2llm scan (same discovery flags): the shotgun_surgery
list is empty and no ticket references variable 'result'; the only remaining
'result' occurrences in src/ are read-only CompletedProcess parameters, which the
mutation tracker ignores.

Local regression gates: pytest 127/127 passed; ruff on the touched file reports
the identical pre-existing baseline (65 findings) before and after.

Co-authored-by: Koru Agent <agent@coru.dev>
…print state

The code2llm 'Shotgun Surgery: result' finding (src/tagi/scanner/files.py:6,
ticket created 2026-09-19T08:40Z) was captured against the pre-PLF-141
monolithic files.py: the discovery evidence files[].sha256
1ce0abad16143ad14121aeb0637546495be090e81833345c8be620477c946379 (926 bytes)
matches src/tagi/scanner/files.py exactly at 5854647^, before the fix landed.
The result shotgun surgery (21 functions) was already removed by 5854647
(PLF-141, shared run_command extraction; commit body notes the previously
20-function span) and d8fb546 (PLF-148, last result binding rename), after
which files.py became a 25-line facade with no result binding and line 6 is
blank. No source change is required.

Verified: fresh code2llm runs (map + evolution/refactor, --no-cache) report
zero shotgun-surgery findings and NEXT[0]: no refactoring needed; rg finds
zero 'result =' mutation sites in src/ (remaining result identifiers are
single-function parameters in providers/utils/auth.py and pr.py); 127/127
pytest pass; ruff findings on src/ are the pre-existing baseline style set
(375, UP006/UP035 et al.), unrelated to this smell. Marked PLF-150 done via
planfile and staged only its ticket-block removal, leaving unrelated queue
churn uncommitted.

Co-authored-by: Koru Agent <agent@coru.dev>
… in sprint state

The code2llm 'Shotgun Surgery: total_lines' finding (src/tagi/utils/
send_helpers.py:8, ticket created 2026-09-19T09:18Z) was captured
against the pre-PLF-108 file: its evidence sha 4e906f5b (847 bytes)
matches cf0ceb0^, which still assigned `total_lines = sum(c.lines_changed
...)` inside create_change_group. cf0ceb0 (PLF-108, committed
2026-09-19T10:20Z, one hour after ticket creation) gave the computation
its single owner total_lines_changed in src/tagi/utils/risk.py:8 and
removed every local binding, so the flagged code no longer exists
(current sha a1f6f48d, 824 bytes) - the ticket's own staleness_check
(files[].sha256 mismatch) confirms the finding is stale.

Verified with the code2llm DFG mutation extractor on current src/
under PYTHONHASHSEED 0/1/42: the total_lines mutation span is 0 scopes.
The only remaining occurrences are read-only keyword arguments
(grouper/publish_helpers/send_helpers) and the ChangeGroup dataclass
field, none of which the mutation tracker counts; the remaining >=5-span
variables (__all__, console, self) are unrelated to this smell.

Local regression gates: pytest 127/127 passed; ruff reports the
identical pre-existing baseline (375 findings across src/) since no
source change was required. Staged only the PLF-151 ticket-block
removal, leaving unrelated pre-existing queue churn uncommitted.

Co-authored-by: Koru Agent <agent@coru.dev>
…print state

The code2llm 'Shotgun Surgery: result' finding (src/tagi/scanner/status.py:11,
ticket created 2026-09-19T09:36Z) was captured against the pre-PLF-141
status.py: the discovery evidence files[].sha256
9b3ee07333cf0ae9ffcc6f3b02ead6d78b0c482d9994a0f4c84b528e9c944c29 matches
src/tagi/scanner/status.py exactly at 65a9a42, before the fix landed. The
result shotgun surgery (21 functions) was already removed by 5854647
(PLF-141, shared run_command extraction; status.py lost all its 'result'
bindings there) and d8fb546 (PLF-148, last result binding rename). Current
status.py (fb8d960f, unchanged since 5854647) contains no 'result'
identifier at all. No source change is required.

Verified: a fresh code2llm run with the documented discovery flags
(-f all --no-chunk --exclude *.md --exclude plugins, temp output) reports
zero shotgun-surgery findings and its generated planfile tickets contain no
'result' smell; rg finds zero 'result =' mutation sites in src/ (remaining
result identifiers are read-only CompletedProcess parameters in
providers/utils/auth.py and pr.py); 127/127 pytest pass; ruff on
src/tagi/scanner/status.py reports only the pre-existing baseline (I001,
UP035, UP006) identical before and after. Marked PLF-153 done via planfile
and staged only its ticket-block removal, leaving unrelated queue churn
uncommitted.

Co-authored-by: Koru Agent <agent@coru.dev>
…letion in sprint state

The code2llm 'Shotgun Surgery: path_lower' finding
(src/tagi/heuristics/tags.py:57, discovery 2026-09-19T10:49Z) was captured
against the pre-fix tags.py: evidence files[].sha256
83621bcdf280f42f072878df2f2475f25ec874bd8f7ecc8bcc5e04bb8e163174 matches
src/tagi/heuristics/tags.py exactly at a2786b9, before the fix landed. The
path_lower shotgun surgery (8 functions) was already removed by d122d74
(PLF-146), which centralized lowercased-path matching in tagi.utils.paths
(path_key/path_matches/path_endswith) and routed config, heuristics tags
and metrics call sites through it. Current src/ contains no path_lower
binding (only a docstring reference to the removed smell in
utils/paths.py). No source change is required.

Verified: a fresh code2llm run with the documented discovery flags
(-f all --no-chunk --exclude *.md --exclude plugins, temp output) reports
zero shotgun-surgery findings and its generated planfile tickets contain
no path_lower smell; rg finds zero path_lower bindings in src/; 127/127
pytest pass (venv); ruff on tags.py/utils/paths.py reports only the
pre-existing baseline (I001, UP035, UP006) identical at HEAD. Marked
PLF-155 done via planfile and staged only its ticket-block removal,
leaving unrelated queue churn uncommitted.

Co-authored-by: Koru Agent <agent@coru.dev>
@tom-sapletta-com
tom-sapletta-com merged commit e87f242 into main Sep 19, 2026
2 checks passed
@tom-sapletta-com
tom-sapletta-com deleted the ticket/PLF-141-shotgun-surgery-result branch September 19, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant