Investigate GitHub issue #193: plan queue displays wontfixed findings when queueorder is…
- User
Investigate GitHub issue #193: plan queue displays wontfixed findings when queue_order is empty.
The bug: when
queue_orderin plan.json is empty ([]),desloppify plan queueauto-generates the queue from open findings in state. But it includes findings withstatus: "wontfix"— these should be filtered out.I need to understand:
- Where is the plan queue auto-generated when queue_order is empty? Look in
desloppify/engine/_plan/anddesloppify/engine/_work_queue/directories. - How does the queue filtering work — does it filter by finding status?
- Where does the
plan queuecommand render its output? Look indesloppify/app/commands/plan/directory. - What does the
plan_order.pyfile do in the work queue?
Be thorough — read the relevant files to trace the full code path from the
plan queuecommand through to how it decides what findings to show. Focus especially on any filtering (or lack thereof) of findings by status. - Where is the plan queue auto-generated when queue_order is empty? Look in
Assistant
I'll investigate this GitHub issue systematically by tracing the code path from the
plan queuecommand through to how findings are filtered. Let me start by exploring the relevant directories and files.Assistant
Now let me start by examining the
plan queuecommand entry point:Assistant
Now let me examine the
build_work_queuefunction which is the critical entry point:Assistant
Now let me check the
build_finding_itemsfunction which is where the status filtering happens:Assistant
Good, I can see the
build_finding_itemsfunction at line 92. Let me check thestatus_matcheshelper function:Assistant
Perfect! Now I can see the
status_matchesfunction at line 33. Now let me look at what happens whenqueue_orderis empty. Let me check the plan reconciliation and understand what should generate the auto queue:Assistant
Let me search more specifically for where the auto-queue is generated in the plan:
Assistant
Let me examine the plan reconciliation code to understand how the queue is auto-generated:
Assistant
Now let me look at the plan generation code to understand how it auto-generates queue when empty. Let me search for where the plan queue gets initialized from state findings:
Assistant
Let me look at the plan_cmd.py which was referenced in the cmd.py file as the implementation of _plan_output_impl:
Assistant
Now I see this calls
planning_mod.generate_plan_md. But the key question is: where doesbuild_work_queuefind the findings whenqueue_orderis empty? Let me trace throughbuild_finding_itemsmore carefully. The issue is that whenqueue_orderis empty, all findings with status="open" get included. But the code seems to only filter bystatus="open"on line 107 of ranking.py. Let me examine what happens on thecmd_plan_queuecall path more carefully.Looking back at the code flow:
cmd_plan_queue(queue_render.py line 141) callsbuild_work_queuewithstatus="open"build_work_queue(core.py line 64) callsbuild_finding_itemswith the same status filterbuild_finding_items(ranking.py line 92) filters bystatus_matches(finding.get("status", "open"), status_filter)
The
status_matchesfunction at line 33 of helpers.py does:pythonAssistant
I see now. The
apply_plan_orderfunction just reorders items - it doesn't add findings that weren't already passed in. So the filtering must be happening before. Let me trace through the actual issue more carefully. Let me check what finding statuses exist:Assistant
Great! Now let me understand the code flow. When
queue_orderis empty, the build_work_queue should only include findings with status="open". But wait - let me look more carefully at whatcmd_plan_queuedoes. Let me trace the execution path again by reading queue_render.py more carefully:Looking at queue_render.py lines 141-170, the
cmd_plan_queuefunction:- Loads the plan
- Calls
build_work_queuewithstatus="open" - Gets items from the queue result
Now, the key question is: when
queue_orderis empty, doesbuild_finding_itemsget called with the right status filter? Let me look atbuild_finding_itemsagain. It filters findings at line 107 withstatus_matches.BUT WAIT - I think I see the issue! Let me check the plan queue auto-generation. When is the queue being auto-generated from findings? Let me search for where queue_order gets populated from findings in state:
Assistant
Let me check the render_sections.py file which handles the auto-generation of queue items:
Assistant
Let me continue reading render.py to find where it builds items from findings:
Assistant
Perfect! Now I see it. On line 289, the planning render calls
build_work_queuewithstatus="open". So the plan generation code is correct. But the issue is aboutplan queuecommand. Let me double-check the queue_render.py call again:Looking back at queue_render.py lines 156-168, I see:
pythonqueue = build_work_queue( state, options=QueueBuildOptions( count=None, scan_path=state.get("scan_path"), status="open", include_subjective=True, plan=plan_data, include_skipped=include_skipped, cluster=effective_cluster, collapse_clusters=True, ), )So
status="open"is being passed. This should filter out all wontfix findings inbuild_finding_items.Wait! Let me re-read the issue description more carefully. The issue says: "when
queue_orderin plan.json is empty ([]),desloppify plan queueauto-generates the queue from open findings in state. But it includes findings with "Assistant
Hmm, let me think about this differently. The code currently does NOT auto-generate the queue_order - it just passes all open findings to
build_work_queuewhenqueue_orderis empty. The filtering happens inbuild_finding_itemsat the status level.But wait - could the issue be that the plan is being STORED with wontfix findings in queue_order? Let me search for where items get added to queue_order:
Assistant
Let me search for actual append operations:
Assistant
Found it! Let me look at the operations.py file where queue_order gets appended to:
Assistant
Good! Now let me check the reconcile.py again to see if it also adds things to queue_order:
Assistant
Found it! At line 254, in
sync_plan_after_review_import, new findings are added to queue_order. Let me check whatcompute_new_finding_idsdoes - it might not be filtering by status:Assistant
Good! So
compute_new_finding_idsDOES filter bystatus == "open"on line 546. That's correct. Now let me check the plan_cmd.py usage in rendering. But the real issue might be elsewhere. Let me look for where queue gets auto-populated or at what point wontfix findings could enter queue_order. Let me check the scan workflow:Assistant
Now I need to understand when queue_order gets auto-populated. The issue says "when
queue_orderin plan.json is empty ([]),desloppify plan queueauto-generates the queue from open findings in state." Let me look at whether there's actually any auto-generation happening or if the issue is that the filtering just isn't working:Let me create a comprehensive test to see what happens. But first, let me check if there's any auto-generation of queue_order from findings in the actual queue_render.py:
Looking back at the code path:
cmd_plan_queueloads the plan- It calls
_resolve_plan_contextwhich checks if plan hasqueue_orderoroverridesorclusters - If plan_data is None, it doesn't use the plan
- It calls
build_work_queuewith or without plan
Let me trace through what happens when the plan HAS findings with wontfix status. Let me check if there's any place where wontfix findings could be getting into the queue. Let me look at where review findings get added:
Assistant
Now let me think about this more carefully. The issue description says findings with
status: "wontfix"are showing up inplan queueoutput when queue_order is empty. This must mean one of these scenarios:- queue_order is NOT being used (it IS empty), and the findings being returned have wontfix status
- OR queue_order IS being populated with wontfix findings somehow
Let me verify by checking what statuses the
cmd_plan_queueactually passes to build_work_queue:Looking at queue_render.py lines 156-168 again, I see it ALWAYS passes . So the filtering should work.
Assistant
Aha! There's a
_check_queue_order_guardfunction that seems to be related. Let me check that test:Assistant
Now I understand! The test at line 116-122 shows that wontfix status BYPASSES the guard. But that's in the resolve command. Let me check what
_check_queue_order_guardactually does:Assistant
Interesting! This function filters resolved IDs at line 59-64 to only keep those with
status == "open". So it's properly filtering. Now let me go back to the original issue and think about this differently.Let me re-examine the actual bug report. The issue says "when
queue_orderin plan.json is empty (), auto-generates the queue from open findings in state. But it includes findings with "Assistant
So there's only one place where
plan queuecallsbuild_work_queue. Let me now check if maybe there's an issue with how the plan is being loaded or processed. Let me check if maybe the issue is that findings marked as wontfix end up in the plan's queue_order during the scan->plan reconciliation. Let me look at that flow again:Actually, let me just search for where findings with wontfix status could be getting added to queue_order. Let me check all the places in operations.py where queue_order gets modified:
Assistant
Let me look at lines 240-260 and 280-290 to see where findings get unskipped and added back to queue_order:
Assistant
Assistant
Let me check if there's a GitHub issue file or reference:
Assistant
Assistant
Found it! Let me look at the
cmd_plan_skipfunction:Assistant
PERFECT! I found it! At line 195-199, when a finding is marked as permanent (wontfix), the STATE is also updated with
resolve_findingsto set the status to "wontfix"!Assistant
Good, so
skip_itemsjust adds the finding to the skipped dict and calls_remove_id_from_lists. Let me check that function:Assistant
- User
I'm investigating unnecessary complexity in desloppify's work queue system. The core question is: "which findings should appear in the queue and in what order?" — but the current implementation spreads this across many files and layers.
Please do a VERY THOROUGH exploration of the entire
desloppify/engine/_work_queue/directory. For each file, read it completely and note:- What is its responsibility?
- How many public functions does it export?
- What does it import from other files in the same package?
- Are there functions that are trivially simple but abstracted into their own function/file?
- Where is filtering logic (deciding what to include/exclude)?
- Where is ordering/sorting logic?
- Where is enrichment logic (adding computed fields to items)?
Also check the
__init__.pyto understand the public API surface.I want to understand the full shape of this package — every file, every function, every cross-dependency.
Assistant
I'll conduct a thorough exploration of the
desloppify/engine/_work_queue/directory. Let me start by examining the structure and then dive into each file.Assistant
Now let me read all the files in this directory:
- User
I'm investigating unnecessary complexity in desloppify's work queue system. I need to understand WHO calls into the work queue and HOW.
Please search for all callers of:
build_work_queue— find every call siteQueueBuildOptions— find every instantiationbuild_finding_items— is it called directly outside the work queue package?- Any direct imports from
desloppify.engine._work_queue.*submodules (not through the init.py)
For each call site, note:
- Which file it's in
- What QueueBuildOptions fields are actually used (which are set to non-default values)
- Whether the caller does additional filtering/processing on the results
Also check: are there callers that build queue items WITHOUT going through build_work_queue? (e.g., directly calling build_finding_items, or constructing items by hand)
This will help me understand if the 12-field QueueBuildOptions is actually needed or if most callers only use 2-3 fields.
Assistant
Perfect! I have now read all six files in the
_work_queuepackage. Let me verify I have the complete picture by checking if there are any additional cross-references or dependencies I should understand:Assistant
I'll help you investigate the work queue system. Let me search for all the call sites and usage patterns.
Assistant
Now let me read the work_queue module structure to understand the code, then examine each call site:
Assistant
Good! Now let me check the specific call sites from the grep results:
- User
I'm investigating unnecessary complexity in desloppify's work queue system. Specifically, I want to understand how the "plan" concept (living plan in
engine/_plan/) is entangled with the work queue (engine/_work_queue/).Please explore:
- Read
desloppify/engine/_plan/— what files exist, what are their responsibilities? - Read
desloppify/app/commands/plan/queue_render.pycompletely — how does it bridge plan and queue? - Read
desloppify/app/commands/plan/— what other plan subcommands exist? Which ones touch the queue? - How does
_resolve_plan_contextin queue_render.py work — what is it really deciding? - Read
desloppify/engine/_work_queue/plan_order.pycompletely — what does apply_plan_order actually do? - Read
desloppify/engine/_work_queue/core.pycompletely — how much of build_work_queue is about plan logic vs core queue logic?
I want to understand: is the plan-queue interaction inherently complex, or has it been over-engineered? Could the plan ordering be a simple sort key rather than a separate reordering pass? Could plan-related filtering (skipped items, clusters) be handled differently?
Focus on identifying coupling points and whether they're necessary.
- Read
Assistant
Now let me check the remaining call sites:
Assistant
I'll explore the plan-queue interaction systematically to identify coupling points and unnecessary complexity. Let me start with reading the directory structures and key files.
Assistant
Now let me read the key files to understand the architecture:
Assistant
Now let me check the test files to see how they use these functions:
Assistant
Let me continue reading the preflight file to see how it uses QueueBuildOptions:
Assistant
Now let me read the critical files to understand the coupling:
Assistant
Now let me check for any direct calls to build_finding_items or any direct work_queue submodule imports:
Assistant
Now let me read the remaining critical files:
Assistant
Now let me check how build_finding_items is used in those files that directly import it:
Assistant
Now let me examine plan subcommands and how they interact with the queue:
Assistant
Perfect! Now let me get a comprehensive view of what fields are actually set in each call site:
Assistant
Let me examine more work queue helpers to understand what filtering logic lives there:
Assistant
Now let me create a comprehensive summary. Let me make one more check to ensure I understand all the usage patterns for stale_dimensions:
Assistant
Now let me check how plan operations are called from command handlers:
Assistant
Now let me check how subjective policy filtering works:
Assistant
Perfect. Now let me check how the plan is integrated at the top-level facade:
Assistant
Assistant
Now let me check the public API surface by looking at what's exported:
Assistant
Assistant
Assistant
- User
Assistant
I'll explore the codebase thoroughly to understand the current architecture, dependencies, and test coverage before designing the simplification plan.
Assistant
Now let me examine the callers and test files to understand the full dependency picture.
Assistant
Now let me look at the callers to understand which fields each one uses.
Assistant
Let me read the key callers more carefully.
Assistant
Now let me look at the
nextcommand and other key callers.Assistant
Now let me check the next.py command to see its full QueueBuildOptions usage.
Assistant
Now let me look at the test files that directly import from the _work_queue internals.
Assistant
Now let me look at the
__init__.pyfor the package and the resolve queue_guard to understand all imports.Assistant
Let me check the
__init__.pyof the _work_queue package and see the remaining test files that import from internals.Assistant
Let me also verify the
_collapse_clustersre-export situation incore.pysince the test imports it from there.Assistant
Now let me check how many tests exist and what the full test coverage looks like.
Assistant
Now I have a thorough understanding of the entire system. Let me trace the exact filtering pipeline one more time to be sure I understand all the filter points, then design the plan.
Assistant