I need to understand the current queue system in this codebase to review a refactoring plan. Specifically I need to understand:
How autofix promotion works currently — look at snapshot.py, synthetic.py, and any cluster-related code
How synthetic items (workflow::, triage::, subjective::) are created and detected — look for prefix checks
How rendering decides what's autofix vs not — look at render.py files and is_auto_fix_command
How clusters store their metadata currently — look at cluster schema/types
Focus on these directories:
desloppify/engine/_work_queue/
desloppify/engine/_plan/
desloppify/app/commands/
Search for:
"workflow::" and "triage::" prefix checks
is_auto_fix_command
autofix promotion logic
cluster action_type or similar fields
synthetic item creation
Be thorough — read the key files in full. I need to understand the current state to evaluate whether a proposed refactoring plan makes sense.
Assistant
I'll conduct a thorough investigation of the queue system, synthetic item creation, and autofix promotion logic. Let me start with parallel searches to map out the codebase.
Assistant
Let me search more specifically for synthetic item creation and prefix checks:
Assistant
Now let me read the key files in detail:
Assistant
Now let me read the synthetic_workflow.py and render files:
Assistant
Now let me look at the plan schema and cluster-related code:
Assistant
Let me read more of the plan schema and the next render files:
Assistant
Now let me search for cluster-related operations and autofix logic:
Assistant
Now let me check how autofix clusters are detected and promoted, and look at the cluster operations:
Assistant
Let me read the plan_order.py file to understand how action_type is determined:
Assistant
Perfect! Now let me check the cluster strategy code to see how autofix clusters are created:
Assistant
Now let me look at how rendering handles clusters and autofix commands in the next command:
Assistant
Excellent! Now let me create a comprehensive summary. Let me check one more file about how action_type is set on clusters:
Assistant
Perfect! Now I have enough information to provide a comprehensive analysis. Let me create the summary:
Queue System Architecture Analysis
I've thoroughly investigated the queue system, synthetic item creation, and autofix promotion logic. Here's what I found:
Workflow items (synthetic_workflow.py): Built by functions like build_run_scan_item(), build_create_plan_item(), build_score_checkpoint_item(), etc. Each checks if its ID is in plan["queue_order"] before creating a synthetic item.
Triage items (synthetic.py::build_triage_stage_items()): Reads TRIAGE_IDS from plan queue, builds stage items with kind="workflow_stage" and detector="triage".
Subjective items (synthetic.py::build_subjective_items()): Creates kind="subjective_dimension" items from dimension scores below threshold, with id="subjective::<slug>".
Prefix Detection: Synthetic prefixes are checked with:
python
SYNTHETIC_PREFIXES = ("triage::", "workflow::", "subjective::")
not any(issue_id.startswith(prefix) for prefix in SYNTHETIC_PREFIXES)
2. AUTOFIX PROMOTION LOGIC
Auto-Promotion Entry Point (snapshot.py::_auto_promoted_autofix_ids()):
python
def _auto_promoted_autofix_ids(plan: dict | None) -> set[str]:
"""Return auto-cluster member IDs eligible to execute without manual promotion."""
for cluster in plan.get("clusters", {}).values():
if not isinstance(cluster, dict) or not cluster.get("auto"):
continue
action = str(cluster.get("action", ""))
if "desloppify autofix" not in action: # <-- KEY DETECTION
continue
for issue_id in cluster.get("issue_ids", []):
if isinstance(issue_id, str) and issue_id and issue_id not in skipped_ids:
autofix_ids.add(issue_id)
return autofix_ids
Key Logic:
Only auto-clusters (cluster["auto"] == True)
Check if "desloppify autofix" string is in cluster["action"]
Add all non-skipped member IDs to executable set
These IDs are added to explicit_queue_ids (line 309) alongside manually queued items
Anchored execution includes both tracked plan IDs AND auto-promoted IDs (line 328)
3. ACTION_TYPE DETERMINATION
For Regular Issues (helpers.py::action_type_for_detector()):
Looks up detector in DETECTORS registry
Returns detector's meta.action_type or defaults to "manual_fix"
For Cluster Meta-Items (plan_order.py::_build_cluster_meta()):
python
action = cluster_data.get("action") or ""
if "desloppify autofix" in action:
action_type = "auto_fix"
elif "desloppify move" in action:
action_type = "reorganize"
else:
action_type = action_type_for_detector(detector)
if action_type == "auto_fix" and "desloppify autofix" not in action:
action_type = "refactor" # <-- Detector says autofix but action doesn't match
Result stamped on clusters:
cluster["action_type"] is set based on the action field (string matching)
If detector is auto_fix but action lacks "desloppify autofix", downgrade to "refactor"
String Matching is Central: The entire autofix detection system hinges on checking if "desloppify autofix" appears in cluster["action"]. This is fragile if you want to evolve the action field format.
Action Field Dual Purpose:
Serves as the primary resolution command hint
Used for action_type classification
Stored as autofix_hint in UI rendering
Three Layers of Detection:
Plan layer: cluster["action"] string matching in _auto_promoted_autofix_ids()
Cluster layer: action_type enum in _build_cluster_meta()
UI layer: is_auto_fix_command() regex on rendered primary_command
No Explicit Flag: Unlike cluster["auto"] boolean, action_type is inferred from action field + detector registry, never persisted as a separate field on the cluster.
Promotion Timing: Auto-promotion happens at snapshot build time, not at plan load. This means re-scanning can change what's executable without explicit user action.