c55b861 "simplify triage display and stage validation flow"
7dd2811 "simplify triage completion and review import flows"
9404e4f "reduce review merge and prompt complexity"
73b5d34 "split scan reconcile pipeline without short-circuiting"
c5a7171 "switch review import APIs to config-first signatures"
23021a4 "move plan operations to option objects"
For each commit, run git show <hash> --stat and git diff <hash>~1..<hash> to see the full diff. Then evaluate:
Is the refactoring making the code genuinely better (simpler, clearer, more maintainable)?
Or is it overzealous: extracting single-use helpers needlessly, adding complexity in the name of reducing it, over-abstracting, wrapping things in classes/dataclasses unnecessarily?
Look for cases where the original inline code was perfectly readable and the extraction just adds indirection.
Look for cases where code got LONGER or HARDER to understand after refactoring.
Look for unnecessary new abstractions (dataclasses, TypedDicts, wrapper functions) for one-time use.
Focus on concrete problems. Don't just summarize what each commit does — identify specific bad patterns. Report the file path, line numbers, and what's wrong.
This is a RESEARCH task — just analyze and report back. Do NOT edit any files.
Assistant
I'll analyze each commit systematically. Let me start by getting the stats and diffs for all 8 commits.
Assistant
Now let me get the full diffs for each commit. I'll do them in parallel.
Assistant
Let me read the full diff for commit 8 since it was truncated.
Assistant
Now let me read the full commit 8 diff more carefully, especially the operations files.
Assistant
Now I have a comprehensive picture. Here is my analysis:
Analysis of 8 Refactoring Commits
Overall Pattern
Commits 1-7 extract inline code into single-use helper functions. Commit 8 then reverts most of what commits 3, 4, and 5 did to those same files, putting the code back inline. This means the branch is churning -- extracting code in one commit and un-extracting it in another. The net effect of commits 3+8, 4+8, and partially 5+8 is largely zero for the files they share. I'll focus on what remains after commit 8 (the final state).
Verdict: Overzealous. Several extractions add indirection without benefit.
Specific problems:
/Users/user_c042661f/Documents/desloppify/app/commands/next/output.py -- _add_workflow_state() and _add_plan_metadata() are void functions that mutate a dict passed in. The original code was 15 lines of straightforward if-checks inline in serialize_item(). Extracting them into two separate mutating functions makes the data flow harder to follow (you now need to track that serialized is being mutated by side-effect across function calls). _add_plan_metadata uses a loop over keys that obscures the plan_skipped special case that follows.
/Users/user_c042661f/Documents/desloppify/app/commands/next/render.py -- _normalize_issue_detail(), _render_issue_detail_fields(), _render_issue_code_snippet(), and _render_plan_item_context() are all called exactly once from _render_issue_detail(). The original was ~30 lines of linear code; now it's 4 function calls plus 4 function definitions (~65 lines of code total). Each helper is trivial (3-8 lines of logic). _render_special_item() wraps two checks that were perfectly readable as 4 lines inline.
/Users/user_c042661f/Documents/desloppify/app/commands/next/render_support.py -- _render_cluster_action_steps(), _render_cluster_members(), and _render_cluster_primary_action() are each called once from render_cluster_item(). The original render_cluster_item was already a well-scoped function. Breaking it into sub-functions just adds indirection.
/Users/user_c042661f/Documents/desloppify/app/commands/plan/cluster_handlers.py -- , , , and are all single-use extractions from . The original was ~30 lines of clear procedural code. Now you have to read 4 function signatures to understand the same logic.
User
Fix the **legacy_kwargs backward-compatibility shim in /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/importing/cmd.py.
The project's CLAUDE.md says: "No backward compatibility for import paths or APIs. This is an internal tool, not a library."
Currently do_import() and do_validate_import() accept **legacy_kwargs and use _legacy_import_config() to convert them. All callers pass kwargs like config=, allow_partial=, manual_override=, attested_external=, manual_attest=, trusted_assessment_source=, trusted_assessment_label=.
Task: Convert all callers to pass import_config=ReviewImportConfig(...) directly, then remove the legacy_kwargs support.
The callers are:
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/cmd.py lines ~183-205 — two calls:
In the function bodies, just use import_config or ReviewImportConfig() instead of _legacy_import_config(...)
Note: ReviewImportConfig is imported from .flags and is a frozen dataclass. Make sure it's also imported in the caller files that need it.
IMPORTANT: Also check if ReviewImportConfig needs a config field for the runtime.config dict that some callers pass. Read the dataclass definition in /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/importing/flags.py first.
This is a CODE EDITING task. Make the changes.
Assistant
Let me read the relevant files first.
User
Fix the overzealous _run_sync_steps lambda-list pattern in /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/scan/plan_reconcile.py.
This wraps straightforward sequential calls in lambdas for no benefit. Replace with the original simple pattern:
python
def _sync_post_scan_without_policy(*, plan, state) -> bool:
dirty = False
if _apply_plan_reconciliation(plan, state, reconcile_plan_after_scan):
dirty = True
if _sync_unscored_and_log(plan, state):
dirty = True
return dirty
def _sync_post_scan_with_policy(*, plan, state, target_strict, policy, cycle_just_completed) -> bool:
dirty = False
if _sync_stale_and_log(plan, state, policy=policy, cycle_just_completed=cycle_just_completed):
dirty = True
if _sync_auto_clusters_and_log(plan, state, target_strict=target_strict, policy=policy, cycle_just_completed=cycle_just_completed):
dirty = True
if _sync_communicate_score_and_log(plan, state, policy=policy):
dirty = True
if _sync_create_plan_and_log(plan, state, policy=policy):
dirty = True
if _sync_triage_and_log(plan, state, policy=policy):
dirty = True
if _sync_plan_start_scores_and_log(plan, state):
dirty = True
if _sync_postflight_scan_completion_and_log(plan, state):
dirty = True
return dirty
Delete _run_sync_steps entirely. Also remove the Callable import if it's no longer used.
This is a CODE EDITING task. Make the changes.
Assistant
Good, ReviewImportConfig already has a config field. Now let me check the imports in the caller files and find _do_import in the batch orchestrator.
Assistant
Now I have all the info needed. Let me make all the edits.
User
Fix overzealous single-use helper extractions in these files. The goal is to inline trivial helpers (3-8 lines, called exactly once) back into their only caller.
Inline _add_workflow_state() and _add_plan_metadata() back into serialize_item(). These are void functions that mutate a dict passed in — the original inline code was clearer. The result should look like:
python
def serialize_item(item):
if item.get("kind") == "cluster":
return _serialize_cluster_item(item)
serialized = _serialize_issue_item_base(item)
# Workflow state
blocked_by = item.get("blocked_by")
if blocked_by:
serialized["blocked_by"] = blocked_by
if item.get("is_blocked"):
serialized["is_blocked"] = True
explain = item.get("explain")
if explain is not None:
serialized["explain"] = explain
# Plan metadata
for key in ("queue_position", "plan_description", "plan_note", "plan_cluster"):
value = item.get(key)
if value:
serialized[key] = value
if item.get("plan_skipped"):
serialized["plan_skipped"] = True
serialized["plan_skip_kind"] = item.get("plan_skip_kind", "temporary")
skip_reason = item.get("plan_skip_reason")
if skip_reason:
serialized["plan_skip_reason"] = skip_reason
return serialized
Delete _add_workflow_state and _add_plan_metadata functions.
Inline these 4 single-use helpers back into _render_issue_detail():
_normalize_issue_detail() — just 5 lines of type coercion
— just prints some fields
Assistant
I'll read all four files first, then make the edits.
Assistant
Now clean up cmd.py - remove the legacy shim functions and update the signatures.
Assistant
Now I'll make all four sets of changes.
File 1: output.py - Inline _add_workflow_state and _add_plan_metadata into serialize_item, delete the two helpers.
Assistant
Now update the do_import signature and body:
Assistant
Now update do_validate_import:
Assistant
File 2: render.py - Inline _render_plan_item_context, _normalize_issue_detail, _render_issue_detail_fields, _render_issue_code_snippet into _render_issue_detail. Inline _render_special_item and _render_standard_issue_header into _render_item.
Assistant
Now let me check for any tests that use the legacy kwargs pattern:
Assistant
There's a test that specifically tests the legacy kwargs behavior. Let me read it.
Assistant
This test is for load_import_issues_data in the helpers module, not for do_import/do_validate_import in cmd.py. That's a separate legacy kwargs shim in the helpers layer. The task only asks about the cmd.py shim, so I'll leave that alone.
Let me also check for tests that call do_import or do_validate_import with legacy kwargs:
Assistant
Good - no test calls use legacy kwargs. Let me also check for any other callers I might have missed:
Assistant
All legacy kwargs callers have been converted. Now let me also check if do_import_fn=_do_import at line 357 of orchestrator.py passes legacy kwargs somewhere:
Assistant
Now inline _render_special_item and _render_standard_issue_header into _render_item:
Assistant
That just passes the function reference as a dependency. Let me check how it's called in the phases module:
Assistant
Another caller using legacy kwargs. Let me fix this one too.
Assistant
Let me do a final check for any remaining legacy kwargs usage on do_import or do_validate_import:
Assistant
File 3: render_support.py - Inline _render_cluster_action_steps, _render_cluster_members, _render_cluster_primary_action into render_cluster_item.
Assistant
Now let me check the imports for Callable.
Assistant
Now let me verify the final state of the cleaned-up cmd.py and run the tests:
Assistant
Now check if Callable is used anywhere else in the file besides line 6 and 390.
Now let me check if any tests reference _run_sync_steps.
Assistant
No remaining references. Let me run the relevant tests to confirm nothing broke.
Assistant
All 44 tests pass. Here's what was done:
Deleted_run_sync_steps() helper function (lines ~390-396) from /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/scan/plan_reconcile.py
Inlined the sequential calls in both _sync_post_scan_without_policy() and _sync_post_scan_with_policy() using simple if step(): dirty = True patterns
Removed the now-unused Callable import from the typing import line
Assistant
There are test failures. Let me check the test files that call do_import/do_validate_import with legacy kwargs:
Assistant
Now let me verify nothing references the deleted helpers from outside these files:
Assistant
All references are gone. Let me run the tests to verify nothing is broken:
Assistant
Hmm, passes individually. Let me check if the other failures are related to my changes or pre-existing. Let me check the review_commands_cases.py which is shared between the two test_review_commands test files:
Assistant
Tests pass individually. The failures are likely pre-existing or caused by test ordering. Let me check if the external test is my issue:
Assistant
This test is checking kwargs directly. Let me read it:
Assistant
The test captures **kwargs from do_import. Now that we pass import_config=ReviewImportConfig(...), the test needs updating. Let me also check the dry_run validate test:
Assistant
Now update the test that checks captured kwargs:
Assistant
Now let me check the review_commands_cases.py for any legacy kwargs usage:
Assistant
The test cases already use import_config=ReviewImportConfig(...) - they're already in the modern style. The failures were likely pre-existing or from test ordering. Let me run the specific failing tests:
Assistant
Let me check if those failures are pre-existing (unrelated to my changes) by looking at one:
Assistant
These failures are pre-existing -- they come from triage runner and review tests which are in the dirty working tree (see git status showing modified files in those paths). None are related to my changes in the next/output.py, next/render.py, next/render_support.py, or plan/cluster_handlers.py files.
Let me verify the specific test files related to my changes pass:
Assistant
The base test_review_commands all pass. The integration run_batches tests still fail. Let me check the error:
Assistant
All 68 related tests pass. Here is a summary of what was done:
Inlined _render_plan_item_context(), _normalize_issue_detail(), _render_issue_detail_fields(), and _render_issue_code_snippet() into _render_issue_detail(), then deleted all four helpers.
Inlined _render_special_item() and _render_standard_issue_header() into _render_item(), then deleted both helpers.
Inlined _render_cluster_action_steps(), _render_cluster_members(), and _render_cluster_primary_action() into render_cluster_item(), then deleted all three helpers.
Inlined _all_known_issue_ids(), _print_suggestions(), _hash_suffix_suggestions(), and _slug_suggestions() into _suggest_close_matches(), then deleted all four helpers.
All behavior is preserved exactly. 68 directly related tests pass, and the 18 failures in the full suite are pre-existing (from unrelated dirty working tree changes in triage runner and review modules).
Assistant
Passes individually too. These are test-ordering issues, not related to my changes. Let me verify with the full suite one more time, focusing only on review tests:
Assistant
All 1023 review tests pass. Let me also clean up the blank line left from removing the legacy functions:
Assistant
Done. Here's what was changed:
Files modified:
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/importing/cmd.py -- Removed _optional_bool(), _optional_text(), and _legacy_import_config(). Changed do_import and do_validate_import signatures to drop **legacy_kwargs and use import_config or ReviewImportConfig() directly.
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/cmd.py -- Both callers now construct ReviewImportConfig(...) and pass it as import_config=. Added import of ReviewImportConfig.
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/external.py -- Both do_validate_import and do_import calls now pass import_config=ReviewImportConfig(...). Shared config extracted to a local _import_config variable since both branches use the same settings. Added import of ReviewImportConfig.
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/batch/orchestrator.py -- The _do_import call now passes import_config=ReviewImportConfig(...). Added import of ReviewImportConfig.
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/batch/execution_results.py -- The do_import_fn call now passes import_config=ReviewImportConfig(...). Added import of ReviewImportConfig.
/Users/user_c042661f/Documents/desloppify/desloppify/tests/review/import_scoring/test_review_external.py -- Updated test assertion to check kwargs["import_config"].attested_external instead of kwargs["attested_external"].
ReviewImportConfig already had a config: dict | None = None field, so no changes were needed to the dataclass itself. All 1023 review tests pass.
User
Review the two most recent commits on this branch for issues:
afc07f7 "desloppify: reduce command complexity and harden triage/review flows"
For each commit, run git diff <parent>..<hash> (use git diff 64532d8..27a7c9e and git diff 27a7c9e..afc07f7) and review:
Correctness: Are there any bugs introduced? Look for:
Wrong variable names, typos, off-by-one errors
Functions that lost parameters or gained wrong defaults
Missing imports
Broken test assertions that don't match the code they test
Overzealous refactoring: Are there still single-use helper extractions that shouldn't exist? The goal was to INLINE trivial helpers back into callers, not to create new ones.
Unintended changes: Did the agents accidentally change behavior that should have been preserved? Look carefully at function signatures — did any public API change in a way that breaks callers?
helpers.py cleanup: The review importing helpers.py had _config_and_legacy_kwargs_conflict and some legacy infrastructure. Was it cleaned up properly or were things left half-done?
Test coverage: Do the test changes make sense? Are any test assertions testing the wrong thing after the refactoring?
Focus on concrete problems. Report file paths and line numbers. This is a RESEARCH task — do NOT edit files.
Assistant
I'll start by examining both diffs in parallel.
Assistant
The second diff is large. Let me read the full output and also check some key files for context.
Assistant
Let me read the remaining parts more efficiently by looking at key files directly.
Assistant
Let me now look at specific areas of concern. Let me check the key files that changed for potential bugs.
Assistant
Now let me check the test changes and some specific areas for correctness issues.
Assistant
Now let me check some critical areas more carefully. Let me look at the _preflight_stage function and how it accesses si:
Assistant
Now let me check the type annotation mismatch. _execute_stage has si: dict but _preflight_stage uses getattr(si, "open_issues", {}), which expects an object with attributes, not a dict:
Assistant
Let me check what si actually is when passed to _execute_stage at the call site:
Assistant
So si is the return value of collect_triage_input. Let me check what that returns:
Assistant
Good -- TriageInput is a dataclass with open_issues as an attribute. The getattr(si, "open_issues", {}) call is correct for a dataclass. The type annotation si: dict on _execute_stage is misleading but si is actually a TriageInput at runtime. Not a bug but worth noting.
Now let me check the sync_communicate_score_needed removal from plan_sync.py and whether that's safe:
Assistant
Now let me check the _sync_plan_start_scores_and_log change more carefully -- the _has_objective_cycle guard was removed:
Assistant
So _has_objective_cycle still exists and is used in _sync_postflight_scan_completion_and_log but was removed from _sync_plan_start_scores_and_log. Let me see the full current state of _seed_plan_start_scores:
Assistant
Now let me check the delta_str calculation where delta could be 0.0 (falsy but valid):
Assistant
Now let me check the _seed_plan_start_scores ordering change and its tests, plus a few more areas:
Assistant
There's a bug on line 459-465. The code does:
python
dirty = _sync_post_scan_with_policy(...) or dirty
This means if _sync_post_scan_without_policy returned True (dirty=True), but _sync_post_scan_with_policy returns True, the result is correctly True. But if _sync_post_scan_with_policy returns True and the first was False, it's also correct. However, the issue is the ordering: _sync_post_scan_with_policy(...) or dirty will SHORT-CIRCUIT. If _sync_post_scan_with_policy returns True, it won't even evaluate dirty. That's fine for a boolean. Actually wait, dirty is already a value, not a function call. So True or True = True, True or False = True, False or True = True. This is actually correct. No bug here.
Wait, but compare to the original: the original code was dirty = _sync_post_scan_without_policy(...) then dirty = _sync_post_scan_with_policy(...) or dirty. Before the reorder, both were called. Now with the reorder, if _sync_post_scan_with_policy returns False and dirty from the first was True, the result is True. If the policy returns True and dirty was False, result is True. All correct.
Let me now look at the execution_summary.py changes more carefully and the do_run_batches removal:
Assistant
Now I see something interesting -- execution_summary.py still has build_run_summary_writer but execution_phases.py now constructs the summary writer directly using partial. Let me check if execution_summary.py is still imported anywhere:
Assistant
So execution_summary.py's build_run_summary_writer is now only used by a test. It was removed from execution_phases.py (which was its only production caller). The first commit refactored execution_phases.py to construct the BatchRunSummaryConfig directly and use partial(write_run_summary_impl, ...) instead of going through build_run_summary_writer. This makes execution_summary.py dead code (only tested in isolation).
Let me also verify the do_import and do_validate_import signature changes are consistent with callers:
Assistant
Let me check the callers in detail for the new signatures:
Assistant
Good, all callers now pass import_config=ReviewImportConfig(...) instead of legacy kwargs, and the **legacy_kwargs was removed from do_import and do_validate_import.
Now let me check the batch orchestrator's _do_import:
Assistant
Good. That's using the new API. Let me check _sync_communicate_score_and_log to see if it passes current_scores:
Assistant
Now let me look at the order issue: _sync_communicate_score_and_log runs BEFORE _sync_plan_start_scores_and_log. The communicate-score sync now does rebaselining, but scores are seeded by _sync_plan_start_scores_and_log which runs AFTER. Let me check this more carefully:
Assistant
The ordering concern: _sync_communicate_score_and_log (with rebaseline) runs before _sync_plan_start_scores_and_log (with seeding). But in sync_communicate_score_needed, the function checks if WORKFLOW_COMMUNICATE_SCORE_ID in order (early exit) and if "previous_plan_start_scores" in plan (early exit). Then seeding runs after and would clear previous_plan_start_scores if it's a new cycle. The sequence is:
communicate-score: if conditions met, rebaselines plan_start_scores and sets previous_plan_start_scores
seed-start-scores: if plan_start_scores is empty/reset, seeds it and clears previous_plan_start_scores
This seems intentional: communicate runs within an active cycle, seeding happens at cycle boundaries. The previous_plan_start_scores sentinel prevents re-injection within the same cycle.
Now let me check a few more specific areas. Let me verify the next/render_scoring.py change:
Assistant
Now let me check the stage_prompts_instruction_shared.py changes:
Assistant
Now let me check one more critical area -- the _validate_reflect_issue_accounting being used in two different places with different function signatures:
Assistant
Let me also check the _analyze_reflect_issue_accounting import -- the pipeline imports both _analyze_reflect_issue_accounting and _validate_reflect_issue_accounting:
Assistant
Wait -- _analyze_reflect_issue_accounting is imported from _stage_validation but is it in the __all__?
Assistant
_analyze_reflect_issue_accounting is NOT in __all__. It's still accessible since it's a module-level function and __all__ only affects from module import * — the explicit import from .._stage_validation import _analyze_reflect_issue_accounting works fine regardless of __all__. Not a bug, just inconsistent.
Now let me check the validate_stage function to see how the new reflect validation test works:
Assistant
Now let me look at the test for test_validate_reflect_requires_full_issue_accounting:
The test creates a plan with missing_issue_ids: ["review::design::ccccdddd"] (non-empty) and expects validate_stage("reflect", ...) to return not ok with "unaccounted" in the message. Looking at line 142-143, it checks stages["reflect"].get("missing_issue_ids", []) and returns f"Reflect report leaves {len(missing)} issue(s) unaccounted for.". This matches -- "unaccounted" is in the message. Test looks correct.
Now let me check for the delta_str bug I noticed earlier:
Line 229 in synthetic_workflow.py:
python
delta_str = f" ({'+' if delta > 0 else ''}{delta:.1f})" if delta else ""
This is a bug: when delta is 0 (or 0.0), the if delta condition is False, so delta_str becomes "". But delta being exactly 0.0 is a valid, non-None value. Previously with plan_start this same pattern existed though, so it's a pre-existing issue, not introduced by these commits. Let me verify by checking the old code:
Assistant
Yes, the if delta pattern already existed in the old code. It's pre-existing, not introduced.
Let me check the extract_issue_citations import:
Assistant
Now let me verify extract_issue_citations is exported through engine/plan.py:
Assistant
Good.
Let me now look at the execution_results.py changes:
Assistant
Good -- this caller was also updated to use the new ReviewImportConfig pattern.
Let me now check the _sync_plan_start_scores_and_log change more carefully. The _has_objective_cycle guard was removed. Previously the logic was:
Check if there's an objective cycle (queue has objective actionable items)
If yes, seed scores
If no, try to clear scores
Now the logic is:
Always try to seed scores
If seeding didn't happen (already seeded), try to clear scores
The _seed_plan_start_scores function itself checks if scores are already set (if existing and not existing.get("reset"): return False), so seeding will be a no-op if scores are already frozen. The key behavioral change is: previously, scores were NOT seeded if there were no objective actionable items. Now they're seeded whenever there are scores available and plan_start_scores is empty. This could be an intentional change to support the rebaseline flow, but it's a behavioral change that removed the "only seed when there's a queue cycle to track" gate. The test removal of test_does_not_seed_when_only_postflight_work_remains confirms this is intentional.
Let me check if there are any remaining callers that still use the old do_run_batches from execution.py:
Assistant
Good. Let me verify the _PREAMBLE_SELF_RECORD has {cli_command} placeholder since build_stage_prompt formats it:
Looking at line 37: Use the exact CLI command prefix shown in the CLI Command Reference: \{cli_command}`.` -- yes it has the placeholder.
Let me do a quick check of the stage_prompts_sense.py changes:
Assistant
Now let me check the _config_and_legacy_kwargs_conflict function -- the question was whether helpers.py cleanup was done properly:
Assistant
Let me look at how _config_and_legacy_kwargs_conflict is now called:
Assistant
This is fine. The _resolve_import_load_config was a thin wrapper around _config_and_legacy_kwargs_conflict + config construction. Now load_import_issues_data calls _config_and_legacy_kwargs_conflict directly and constructs the config inline. The refactoring is clean.
However, there's a remaining concern about _config_and_legacy_kwargs_conflict itself. Now that all callers use ReviewImportConfig objects, is load_import_issues_data still called with legacy kwargs? Let me check:
Assistant
The function load_import_issues_data still has the legacy kwargs interface (takes individual keyword args like lang_name, allow_partial, etc., OR a config object). This is because the function itself is called both from the do_import/do_validate_import flow (which now always passes config=ImportLoadConfig(...)) and from tests. The _config_and_legacy_kwargs_conflict function and the dual interface on load_import_issues_data remain for backward compatibility of the function signature. Per the CLAUDE.md policy, this is an internal tool with no backward-compat requirement for APIs, so this legacy dual interface could have been cleaned up further, but it's not a bug.
Let me now quickly run the tests to see if they pass:
Assistant
All 109 tests pass. Let me also run the broader test suite for the affected areas:
Assistant
9 failures. Let me look at what's failing:
Assistant
This is a real bug. The new _validate_reflect_issue_accounting check is now running during the reflect stage recording flow (via _auto_confirm_reflect_for_organize), and it rejects the reflect report because it doesn't contain the issue IDs. The existing tests use simple issue IDs like "r1", "r2" that aren't 8+ hex characters, so the hash matching in _analyze_reflect_issue_accounting can't find them.
Let me verify this by looking at the flow:
Assistant
The issue is clear. The _auto_confirm_reflect_for_organize function now validates that the reflect report accounts for every open issue. The test uses simple issue IDs like "r1" and "r2", and the reflect report is just a long generic text that doesn't mention these IDs. The _validate_reflect_issue_accounting function uses extract_issue_citations which looks for 8+ hex char patterns -- and "r1", "r2" don't match that pattern.
This means the _validate_reflect_issue_accounting function silently fails on non-standard issue IDs: the short_id_map only matches 8+ hex chars, and extract_issue_citations uses a regex for issue ID patterns. With IDs like "r1" and "r2", valid_ids - cited = all IDs, so they're all "missing" and the validation fails.
This is a real correctness issue. The new validation is too aggressive -- it blocks the reflect stage recording path when called from _auto_confirm_reflect_for_organize. The 9 failing tests all exercise the reflect or organize stage recording with simple test issue IDs.
Now let me also check the stage_flow_observe_reflect_organize.py reflect flow:
Assistant
This is the direct cmd_stage_reflect flow, and it also calls _validate_reflect_issue_accounting. With real issue IDs (8+ hex), this works. The bug manifests only when tests use simplified IDs.
However -- looking at it more carefully, the _auto_confirm path (called when organizing) checks the reflect report that was already recorded. If the reflect report was recorded successfully (it must have passed the validation in cmd_stage_reflect), then the _auto_confirm_reflect_for_organize validation is a redundant re-check. But if the reflect was recorded before this validation existed (e.g., from a previous version), it could legitimately fail.
The 9 test failures all use cmd_plan_triage which routes through stage_flow_observe_reflect_organize.py. The reflect recording path now has _validate_reflect_issue_accounting as a gate. With test IDs like "r1", "r2" that aren't hex hashes, ALL ids are "missing" and validation fails.
This is the main bug in these commits. Let me summarize all findings.
do_run_batches was removed from execution.py and its logic moved into orchestrator.py (lines 341-381), calling execution_phases directly.
execution_summary.py's build_run_summary_writer was simplified from a partial-based factory to accept a pre-built BatchRunSummaryConfig, and execution_phases.py was updated to construct BatchRunSummaryConfig directly.
All test assertions updated correctly.
Dead code left behind
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/batch/execution_summary.py -- build_run_summary_writer is no longer called from production code. Its only import is from the test file test_review_batch_execution_summary_direct.py. The function in execution_phases.py now constructs the writer directly using functools.partial(write_run_summary_impl, ...), bypassing execution_summary.py entirely. This module is dead code.
helpers.py cleanup (question 4)
The _resolve_import_load_config wrapper was removed from helpers.py and its logic inlined into . The cleanup is correct. However, and the dual interface on (accepting both and individual kwargs) remain. Per the backward-compat policy in CLAUDE.md, this could be cleaned up further since all callers now pass .
User
Fix a bug in /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/plan/triage/_stage_validation.py in the _analyze_reflect_issue_accounting function.
The problem: the function uses extract_issue_citations which only matches hex-hash-based IDs ([a-z_]+::[a-f0-9]{8,} or bare [0-9a-f]{8,} suffixes). When issue IDs don't contain hex hashes (e.g., test IDs like "r1", "r2"), zero IDs are matched and all are reported as "missing", causing 9 test failures.
The fix: In _analyze_reflect_issue_accounting, after the extract_issue_citations fallback path (the else branch after the Coverage Ledger check), also check for full valid_id strings appearing literally in the report text. This handles non-hex test IDs.
Replace lines ~183-191 (the fallback path after the Coverage Ledger check):
python
cited = extract_issue_citations(report, valid_ids)
short_hits = Counter(
short_id_map[token]
for token in re.findall(r"[0-9a-f]{8,}", report)
if token in short_id_map
)
duplicates = sorted(issue_id for issue_id, count in short_hits.items() if count > 1)
missing = sorted(valid_ids - cited)
return cited, missing, duplicates
With:
python
cited = extract_issue_citations(report, valid_ids)
# Also match valid IDs that appear literally in the report
# (handles non-hex IDs like test fixtures).
for issue_id in valid_ids:
if issue_id in report:
cited.add(issue_id)
short_hits = Counter(
short_id_map[token]
for token in re.findall(r"[0-9a-f]{8,}", report)
if token in short_id_map
)
duplicates = sorted(issue_id for issue_id, count in short_hits.items() if count > 1)
missing = sorted(valid_ids - cited)
return cited, missing, duplicates
After making the fix, run: python -m pytest desloppify/tests/commands/plan/test_triage_confirmation.py desloppify/tests/commands/plan/test_triage_fold_confirm.py desloppify/tests/commands/plan/test_triage_jump_back.py desloppify/tests/commands/plan/test_triage_logging.py -q --tb=short
If they still fail, read the failing tests to understand what report text they use and what issue IDs they have. The issue is that the test reports don't contain the issue IDs at all — in that case the tests need to include the issue IDs in their report text. Check each failing test's report string and the issue IDs in the state/plan.
This is a CODE EDITING task.
Assistant
Let me start by reading the file to understand the current code.
Assistant
Now I'll apply the fix.
User
Clean up two pieces of dead/legacy code:
1. Remove legacy kwargs from load_import_issues_data in helpers.py
In /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/importing/helpers.py, the function load_import_issues_data (around line 299) still accepts individual legacy kwargs alongside config: ImportLoadConfig. All callers now pass config=ImportLoadConfig(...) directly.
Per CLAUDE.md: "No backward compatibility for import paths or APIs."
Changes needed:
Remove the individual kwargs (lang_name, allow_partial, trusted_assessment_source, trusted_assessment_label, attested_external, manual_override, manual_attest, colorize_fn) from load_import_issues_data's signature. Keep only config: ImportLoadConfig.
Make config required (not optional) since all callers pass it.
Delete _config_and_legacy_kwargs_conflict function entirely.
Simplify the function body — just use config directly instead of the options = config or ImportLoadConfig(...) fallback.
Also check if there's a DUPLICATE load_import_issues_data in parse.py — grep found one there too. If it exists, it's probably the OLD version. Check if anything imports from parse.py directly. If nothing does, leave it alone (it may be dead too but don't remove it without checking).
2. Dead execution_summary.py module
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/batch/execution_summary.py has build_run_summary_writer which is only imported by its test file. The production code in execution_phases.py now constructs the writer directly.
However, DON'T delete the module — it's still imported by a test. Instead, just note this as a known dead-code issue. The test file tests the function directly so it provides coverage of the helper pattern. Leave it.
Focus only on the helpers.py cleanup. Run: python -m pytest desloppify/tests/review/ -q --tb=short after making changes to verify nothing breaks.
This is a CODE EDITING task.
Assistant
Now let me run the tests.
Assistant
Let me start by reading the relevant files.
Assistant
The tests are still failing because the report text doesn't contain the issue IDs. Let me look at the failing tests to understand the report strings and issue IDs used.
Assistant
I need to check the test file and the callers more carefully. The test file uses legacy kwargs extensively. Let me check the callers in cmd.py and the test file.
Assistant
The test file heavily uses legacy kwargs. I need to update both the helpers.py function AND the test file. Let me also check the parse.py duplicate.
Assistant
Good. The parse.py version is a separate older function with a different signature (ImportParseOptions). One test (test_direct_coverage_priority_modules.py) checks it's callable. It's not imported by production code from parse.py. I'll leave it alone as instructed.
Now let me update the helpers.py and test file. First, the helpers.py changes:
Assistant
Now I can see the pattern. The failing tests have report strings that don't contain the issue IDs (like "r1", "r2", etc.). The reports are generic strings like "A sufficiently long report about strategy and comparing issues against completed work and more text" — none of them mention "r1", "r2", etc.
The tests need their report strings updated to include the issue IDs. Let me check exactly which tests fail and what reports they use.
The issue is that the reflect stage validation checks that the report accounts for all open review issues. The stored reports and new reports in these tests don't mention the issue IDs.
The cleanest fix: update each test's report string to include the issue IDs. But first let me check how the _plan_with_stages helper creates reports — many tests reuse stored reports from there.
For _plan_with_stages in each file, the stored report is generic and doesn't include issue IDs. When reflect reuses its stored report, validation still fails. I need to update:
The _plan_with_stages helpers in all 4 files to include issue IDs in stored reports
The explicit report strings in failing tests
Assistant
Now I need to update all the test call sites. Let me rewrite the test file systematically. Each call using legacy kwargs needs to be converted to use config=ImportLoadConfig(...).
Assistant
So valid_ids comes from si.open_issues.keys() — which are the state issue IDs. In the tests, these are the IDs passed to _state_with_issues or _state_with_review_issues (e.g., "r1", "r2" or "r1"..."r5").
The fix needs the report to mention all these issue IDs. The simplest approach: update the test report strings to include the issue IDs. Let me update all 4 test files.
Line 164/180: reports for reflect with state("r1","r2") — need r1, r2 in report
Line 249: report for organize with state("r1","r2") — need r1, r2 in report
For test_triage_fold_confirm.py:
_plan_with_stages report: need to contain issue IDs
Line 117-119: reflect_report needs r1-r5
Line 219-222: organize_report needs r1-r5
For test_triage_jump_back.py:
_plan_with_stages report: needs r1-r5 (most tests use 5 issues)
Line 114-117: new_report needs r1-r5
Line 326-329: new_report needs r1-r5
For test_triage_logging.py:
_plan_with_stages report: similar
Line 132: report needs r1, r2
The simplest, most robust fix: update _plan_with_stages in each file to include the cited_ids in the report text, and update each explicit report string to mention the relevant issue IDs.
Let me make the edits:
Assistant
Now remove the test for the legacy kwargs conflict (it tests deleted functionality):
Assistant
Now test_triage_fold_confirm.py:
Assistant
Now update the remaining test call sites. Let me handle them all:
Assistant
Now test_triage_jump_back.py:
Assistant
Now update the two explicit new_report strings in test_triage_jump_back.py. There are two instances — lines 114 and 326.
Assistant
Now test_triage_logging.py:
Assistant
Now let me also check test_jump_back_then_fold_confirm_forward more carefully. It jumps back to reflect (reuse mode, no report) at line 219, which uses the stored report. The stored report now contains "r1 r2 r3 r4 r5". But then at step 2 (line 229), it has an explicit organize_report.
Assistant
Wait, the organize stage doesn't go through reflect issue accounting — that's only for the reflect stage. Let me re-check what the test failure was about. Looking back at the error:
For test_jump_back_then_fold_confirm_forward (line 225):
code
assert stages["organize"].get("confirmed_at") is None
E AssertionError: assert '2025-06-01T00:01:00Z' is None
This is in Step 1 (line 219-225), where it runs --stage reflect with no report (reuse mode). The test expects that organize's confirmation gets cleared (cascade). But the reflect stage validation is failing (report doesn't mention issue IDs), so the stage isn't being recorded at all, so the cascade doesn't happen, so organize's confirmed_at remains.
With my fix to include issue IDs in the stored report, the reflect reuse should now succeed, and the cascade should clear organize's confirmation.
Let me also check: does the organize stage also go through reflect issue accounting? Let me check what validation happens for organize.
Assistant
Only called once, in the reflect flow. Good. The organize stage should be fine without issue IDs in its report.
Now let me also check the test_stage_progress_shows_needs_confirm test (line 340). It runs reflect with new_report (now includes r1-r5), then runs with no args for dashboard. This should work now.
Let me run the tests again:
Assistant
All 34 tests pass. Here's a summary of what was done:
Bug fix in /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/plan/triage/_stage_validation.py:
In _analyze_reflect_issue_accounting, added a loop after extract_issue_citations() in the fallback path (lines ~183-187) that checks if each valid_id appears literally in the report text. This handles non-hex IDs (like "r1", "r2") that extract_issue_citations can't match with its hex-hash regex patterns.
Test fixes (4 files) — added issue IDs to report strings so the accounting validation can find them:
/Users/user_c042661f/Documents/desloppify/desloppify/tests/commands/plan/test_triage_confirmation.py — updated _plan_with_stages report template and 3 explicit report strings to include issue IDs
Now let me also check the other test file that references load_import_issues_data and remove the unused _colorize function if it's no longer needed.
Assistant
That test just checks the function is callable, so it doesn't need updating. Now let me check if _colorize is still used in the test file.
Assistant
_colorize is still used by _render_import_load_error and print_assessment_mode_banner, so keep it. Now run the tests.
Assistant
All 1023 tests pass. Let me also run the broader commands test suite to make sure the coverage test that checks load_import_issues_data is callable still works.
Converted all 22+ call sites from legacy kwargs to config=ImportLoadConfig(...) style
Removed test_import_config_rejects_legacy_kwargs_mix test (tested deleted functionality)
Not touched (as instructed):
parse.py duplicate load_import_issues_data -- it exists with a different signature (ImportParseOptions), is only referenced by a callable-check test, and is effectively dead code
execution_summary.py -- noted as dead code but left in place since its test provides coverage of the helper pattern
_all_known_issue_ids()
_print_suggestions()
_hash_suffix_suggestions()
_slug_suggestions()
_suggest_close_matches()
Commit 2: 0b92cbf -- split plan command complexity hotspots
Verdict: Overzealous in some places, reasonable in others.
Specific problems:
/Users/user_c042661f/Documents/desloppify/app/commands/plan/cmd.py -- _plan_queue_line(), _skip_kind_counts(), _print_cluster_summary(), _print_commit_tracking() are all single-use extractions from _cmd_plan_show(). _skip_kind_counts() returns a 4-tuple that must be unpacked -- the original 6 lines of inline code were more readable. _plan_queue_line() wraps a try/except that was fine inline. _print_commit_tracking() hides a config load behind a function name -- the original inline code with _cfg made it clear config was loaded once.
/Users/user_c042661f/Documents/desloppify/app/commands/plan/commit_log_handlers.py -- _resolve_commit_identity() returns a tuple (sha, branch) where the caller then checks if not sha: return. The original inline code was more straightforward. _select_commit_issue_ids() uses [] vs None as a sentinel value, which is a subtle API contract (the caller checks if issue_ids == []: return). This is worse than the original which just had if not uncommitted and if not issue_ids.
/Users/user_c042661f/Documents/desloppify/app/commands/plan/queue_render.py -- _resolve_effective_cluster(), _build_queue_items(), _compute_visible_new_ids(), _render_cluster_banners(), _render_queue_rows() are all single-use. The original cmd_plan_queue() was a linear function. Now it dispatches to 5 helpers, each with their own keyword args. _build_queue_items() returns a tuple[list[dict], dict] which makes the caller less readable.
Verdict: Mixed. Display extractions are borderline reasonable; stage_validation lambda-dispatch is worse than if/elif.
Specific problems (that survive commit 8):
/Users/user_c042661f/Documents/desloppify/app/commands/plan/triage/display.py -- _cluster_tags(), _print_active_clusters(), _unclustered_issue_ids(), _print_unclustered_issues(), _print_completed_clusters(), _print_resolved_issue_deltas(), _print_recurring_or_first_triage() -- all single-use. The functions that were extracted from print_progress() and print_reflect_dashboard() are borderline. The originals were medium-length but clear. The extraction is not harmful but adds no significant value either.
Note: The stage_validation.py changes from this commit (lambda dispatch table) are reverted by commit 8, which puts the if/elif chain back. So this was wasted churn.
Verdict: Significantly overzealous in helpers.py. Mostly reverted by commit 8.
The stage_completion_commands.py and triage_handlers.py changes are reverted by commit 8. What survives is in review/importing/:
/Users/user_c042661f/Documents/desloppify/app/commands/review/importing/cmd.py -- _resolve_import_payload(), _build_working_state(), _apply_assessment_policy(), _raise_on_partial_skip(), _append_assessment_import_audit(), _persist_import_state() -- six single-use extractions from do_import(). The original was a sequential pipeline that read top-to-bottom. Now you have to hop between 6 helper functions. _build_working_state() is 4 lines. _persist_import_state() is 4 lines. These don't justify their own functions.
/Users/user_c042661f/Documents/desloppify/app/commands/review/importing/helpers.py -- This file gets the worst treatment. The original _normalize_import_payload_shape() was a single function with inline validation for each field. Commit 4 explodes it into _normalize_issues(), _normalize_optional_mapping(), _normalize_reviewed_files(), _normalize_policy(). Then commit 8 reverts this back to the inline version. Similarly, _parse_and_validate_import() was split into _load_raw_import_payload(), _normalize_raw_import_payload(), _validate_assessment_flag_combo(), _apply_assessment_policy_checked(), _manual_override_attest_errors(), _validate_assessment_feedback_requirements(), _schema_validation_errors() -- and commit 8 reverts most of this back inline.
Net result after commit 8: helpers.py goes through massive churn (split then unsplit) but the print_assessment_policy_notice() function stays split into 5 per-mode print functions (_print_trusted_notice, _print_trusted_internal_notice, etc.) dispatched via a lambda dict. The original if/elif chain was clearer.
Commit 5: 9404e4f -- reduce review merge and prompt complexity
Verdict: Overzealous in merge.py. The prompt_sections changes are reasonable.
/Users/user_c042661f/Documents/desloppify/app/commands/review/merge.py -- _resolve_similarity(), _open_holistic_review_items(), _group_duplicate_issue_concepts(), _apply_merge_group(), _print_merge_group_summary() are all single-use extractions from do_merge(). The original was a ~80-line function. _resolve_similarity() is a 4-line try/except/clamp. _open_holistic_review_items() is a one-liner list comprehension. _apply_merge_group() returns a tuple[str, list[str]] -- but it also mutates group items in place as a side effect, which the return type doesn't communicate. This is actually worse than the original where the mutation was visible inline.
After commit 8: merge.py changes from commit 5 are reverted, so this was pure churn.
/Users/user_c042661f/Documents/desloppify/app/commands/review/prompt_sections.py -- _concern_signal_lines() and _iter_valid_concern_signals() are reasonable extractions. The loop body was non-trivial. This is fine.
Commit 6: 73b5d34 -- split scan reconcile pipeline without short-circuiting
Verdict: Actively harmful. Introduces a bug pattern and makes code harder to understand.
Specific problems:
/Users/user_c042661f/Documents/desloppify/app/commands/scan/plan_reconcile.py -- _run_sync_steps() wraps a list of lambdas that each return bool. The original was a simple sequence of if step(): dirty = True calls. The lambda list adds indirection without benefit. Worse, _sync_post_scan_without_policy() and _sync_post_scan_with_policy() wrap groups of these calls. The final call site has:
python
dirty = _sync_post_scan_without_policy(plan=plan, state=runtime.state)
dirty = _sync_post_scan_with_policy(...) or dirty
The or dirty placement is correct but fragile -- if someone changes the order to dirty = dirty or _sync_post_scan_with_policy(...), Python's short-circuit evaluation would skip the second call when dirty is already True. The original code had no such footgun.
Also in this commit: _sync_communicate_score_and_log() now creates a ScoreSnapshot object inline with field-by-field copy from state_mod.score_snapshot(). This is new logic introduced alongside the refactoring that should be in a separate commit.
Verdict: Worst offender. Adds **legacy_kwargs to public APIs, creating a strictly worse interface.
Specific problems:
/Users/user_c042661f/Documents/desloppify/app/commands/review/importing/cmd.py -- do_import() and do_validate_import() now accept **legacy_kwargs alongside import_config: ReviewImportConfig | None. The _legacy_import_config() function validates legacy_kwargs at runtime by checking allowed keys. This replaces explicit typed keyword arguments with an untyped **kwargs bag -- losing IDE autocompletion, type checking, and clear function signatures. The CLAUDE.md explicitly says "No backward compatibility for import paths or APIs" -- so this compatibility shim contradicts the project's own policy.
/Users/user_c042661f/Documents/desloppify/app/commands/review/importing/helpers.py -- Same pattern: load_import_issues_data() now takes **legacy_kwargs instead of named parameters. A frozen LegacyImportLoadArgs dataclass is introduced solely to validate these kwargs at runtime. This is ~60 lines of validation/coercion code (_legacy_bool, _legacy_text, _coerce_legacy_import_load_kwargs, LegacyImportLoadArgs) that replaces zero lines -- it's a backward-compat shim for an internal tool that doesn't need backward compat.
Commit 8: 23021a4 -- move plan operations to option objects
Verdict: This commit is mostly a revert of commits 3, 4, and 5. The operation object changes are fine but should have been the only content.
This commit does two things:
Reverts the helper extractions from commits 3 (stage_validation, triage_handlers, stage_completion_commands), 4 (stage_completion_commands, triage_handlers), and 5 (merge.py) back to inline code.
Makes changes to engine/_plan/ operation modules (commit_tracking, operations_meta, operations_skip).
The reverts confirm that those extractions were overzealous -- the author recognized this and undid them. But this creates a messy commit history where 3 commits of work are silently reverted in a later commit.
Summary of Concrete Problems to Address
Patterns that should be reverted/cleaned up (still in the tree after commit 8):
Commit 7's **legacy_kwargs pattern in cmd.py and helpers.py -- violates the project's explicit no-backward-compat policy, replaces typed signatures with untyped kwargs bags, adds ~100 lines of runtime validation that shouldn't exist. Files:
Commit 6's lambda-list sync pipeline in /Users/user_c042661f/Documents/desloppify/app/commands/scan/plan_reconcile.py -- _run_sync_steps() with lambda lists is more fragile and less readable than the original sequential if step(): dirty = True pattern.
Commit 1's trivial single-use extractions in output.py, render.py, render_support.py, and cluster_handlers.py -- add indirection without reducing complexity. Particularly bad: void-mutating functions _add_workflow_state() and _add_plan_metadata().
Commit 2's trivial single-use extractions in cmd.py, commit_log_handlers.py, and queue_render.py -- the tuple-return patterns (_skip_kind_counts returning a 4-tuple, _select_commit_issue_ids using [] as sentinel) are worse than inline code.
Surviving helper.py splits from commit 4 -- the print_assessment_policy_notice dispatch via lambda dict in helpers.py is more complex than the original if/elif chain.
_render_issue_detail_fields()
_render_issue_code_snippet() — reads and prints a snippet
_render_plan_item_context() — prints plan metadata
The result _render_issue_detail() should be a single function that does all of:
Render plan context (plan_description, plan_cluster, plan_note)
Print file and ID
Normalize and render detail fields
Render code snippet
Also inline _render_special_item() back into _render_item() — it's just two checks.
And inline _render_standard_issue_header() back into _render_item() — it's just 3 lines.
Inline these 3 single-use helpers back into render_cluster_item():
_render_cluster_action_steps()
_render_cluster_members()
_render_cluster_primary_action()
These are each called once from render_cluster_item(). Inline them. Keep the other helpers that ARE called from multiple places (_render_cluster_files, _render_cluster_sample, _step_display_text, _render_optional_cluster_commands, _render_required_cluster_commands).
Inline these 4 single-use helpers back into _suggest_close_matches():
_all_known_issue_ids()
_print_suggestions()
_hash_suffix_suggestions()
_slug_suggestions()
The original _suggest_close_matches was a single function that collected IDs and printed fuzzy matches. Restore that.
This is a CODE EDITING task. Read each file first, then make the changes. Preserve all existing behavior exactly.
load_import_issues_data
_config_and_legacy_kwargs_conflict
load_import_issues_data
config=ImportLoadConfig(...)
config=ImportLoadConfig(...)
Commit 2: afc07f7 "reduce command complexity and harden triage/review flows"
Bug: 9 test failures from _validate_reflect_issue_accounting gate
Files:
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/plan/triage/_stage_validation.py (lines 151-220) -- new _validate_reflect_issue_accounting function
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/plan/triage/stage_flow_observe_reflect_organize.py (line 209) -- new validation call in cmd_stage_reflect
Problem:_validate_reflect_issue_accounting uses extract_issue_citations and a re.findall(r"[0-9a-f]{8,}", report) pattern to match issue hashes. It then computes missing = valid_ids - cited. When issue IDs don't contain 8+ hex suffixes (e.g., test IDs like "r1", "r2"), zero IDs are ever cited, so ALL IDs are reported as "missing" and the validation fails.
This breaks the reflect stage recording path (cmd_stage_reflect and _auto_confirm_reflect_for_organize) for any plan with non-standard issue IDs. The 9 failing tests are:
_execute_stage declares si: dict (line 227) but the actual runtime value is a TriageInput dataclass. The _preflight_stage function uses getattr(si, "open_issues", {}) (line 205) which works correctly on a dataclass but would fail on a dict. The type annotation is misleading. Not a runtime bug since si is always a TriageInput at the call site (line 539).
The _has_objective_cycle guard was removed. Previously, scores were only seeded when the queue had objective actionable items. Now scores are seeded unconditionally (whenever plan_start_scores is empty and scores exist). The test test_does_not_seed_when_only_postflight_work_remains was removed to match. This appears intentional to support the new rebaseline flow, but it changes when score baselines are established.
Behavioral change: sync_communicate_score_needed removed from import path
File:/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/importing/plan_sync.py (lines removed around 100-110)
The sync_communicate_score_needed call was removed from the post-import sync. The communicate-score injection now only happens during scan reconciliation. This means scores imported via do_import no longer trigger immediate communicate-score injection -- it waits until the next scan.
_load_prior_reports_from_plan (lines 62-70) is a new single-use helper called only from run_codex_pipeline. It's simple enough to inline. Similarly _read_stage_output (lines 178-184) is trivial and called once.
Clean inlining (positive)
The next/render.py and next/render_support.py inlining is well-done -- _render_plan_item_context, _normalize_issue_detail, _render_issue_detail_fields, _render_issue_code_snippet, _render_special_item, _render_standard_issue_header, _render_cluster_action_steps, _render_cluster_members, and _render_cluster_primary_action were all correctly inlined into their single callers.
The cluster_handlers.py inlining (_all_known_issue_ids, _print_suggestions, _hash_suffix_suggestions, _slug_suggestions into _suggest_close_matches) is also correct.
Test coverage
Tests are appropriate for the new features. The new tests in test_triage_runner.py and test_triage_split_modules_direct.py correctly exercise the new prompt modes, preflight validation, and CLI helper functionality. The only issue is the 9 pre-existing tests that were not updated to accommodate the new reflect validation gate.
Let me also check which tests have 5 issues vs 2-3 to match correctly. Let me update the _plan_with_stages helpers and explicit report strings.
For _plan_with_stages - the cited_ids are always ["r1", "r2", "r3"], so mentioning those in the report. But some tests create state with 5 issues (r1-r5) or 2 issues (r1, r2). The issue accounting checks against valid_ids from state, not cited_ids.
Let me trace the logic more carefully. Let me look at what valid_ids is passed to the validation function.