I need to understand the workflow of desloppify's plan/next/score systems. Specifically:
How does plan command work? What does it show the user? Look at desloppify/app/commands/plan/cmd.py and related files.
How does next command work? What does it show? Look at desloppify/app/commands/next.py and desloppify/app/commands/next_parts/.
How does scoring work and where is the "strict score" shown? Look at desloppify/app/output/scorecard_parts/ and desloppify/app/commands/helpers/score_update.py.
What is the "work queue" and how does it relate to the plan? Look at desloppify/engine/_work_queue/.
How does the show command display things? Look at desloppify/app/commands/show/.
I want to understand the user journey: scan -> plan -> next -> fix -> repeat. What information is shown at each step? Where does the strict score appear? What is the "queue" concept?
Be very thorough - read the key files in full.
Assistant
I'll conduct a thorough exploration of desloppify's plan/next/score systems. Let me start by reading the key files.
Assistant
Now let me read the next parts files and other scoring/display related files:
Assistant
Now let me read more about the work queue ranking and helpers, plus the show command's render module:
Assistant
Let me now read the plan-related files that explain the "queue" and state modules:
Assistant
Now let me read the plan queue policy and next_parts output module:
Assistant
Let me check the output module for next:
Assistant
Now let me read the state schema to understand the scoring structure:
Assistant
Perfect! Now let me read more of the schema file to see the scoring functions:
Assistant
Excellent! Now let me review one more critical piece - the plan command output:
Assistant
Let me check the planning module that generates the plan markdown:
Assistant
User
I need to find every place in the desloppify codebase where the strict score, overall score, or any score metrics are displayed to the user. This includes:
The print_score_update function and everywhere it's called - look at desloppify/app/commands/helpers/score_update.py and find all callers
The "North Star" section in next command output - look at desloppify/app/commands/next_parts/render.py for where strict score is rendered
Score display in plan command output - look at desloppify/app/commands/plan/cmd.py and desloppify/app/commands/plan/queue_render.py
Score display in show command - look at desloppify/app/commands/show/render.py
Score display in fix command - look at desloppify/app/commands/fix/cmd.py
Score display in resolve command - look at desloppify/app/commands/resolve/cmd.py
Score display in output - look at
Assistant
I'll help you find all the places where scores are displayed and look for queue completion logic. Let me start by searching through the codebase systematically.
Assistant
Good start. Now let me read the specific files mentioned and search for all score display locations:
User
I need to understand the queue lifecycle and how desloppify tracks queue state. Specifically:
Read desloppify/engine/_work_queue/core.py - understand build_work_queue() and how items are counted
Read desloppify/engine/_plan/schema.py - understand the plan data structure, especially queue_order
Read desloppify/engine/_plan/operations.py - understand how items are added/removed from the queue
Read desloppify/engine/plan.py - the public API for plan operations
Read desloppify/app/commands/plan/queue_render.py - how queue status is rendered
How do we know when the queue is "empty" / fully cleared?
Is there a concept of "queue started" vs "queue in progress" vs "queue completed"?
When items are resolved/fixed, how does the queue shrink?
What happens after the last item is cleared?
Is there any existing "completion" event or celebration?
How does the plan track progress through the queue?
Read all files thoroughly and report back with specifics.
Assistant
Now let me read the other commands that display scores:
Assistant
I'll read all these files to understand the queue lifecycle and state tracking. Let me start by reading them in parallel.
Assistant
Let me continue reading the relevant files:
Assistant
Now let me search for any "completion" or "celebration" related logic in the codebase to understand if there's existing celebration behavior:
Assistant
Now let me search for the "North Star" section and check for any queue empty messages more systematically:
Assistant
Now let me check the reconcile and completion logic more carefully:
Assistant
Let me get some more crucial information about score display in the scan command and status command:
Assistant
Let me search for the scan command and status command:
Assistant
Now let me check the status_parts/render.py for score display:
Assistant
Perfect. Now let me search for all the score display functions and queue completion patterns more systematically:
Assistant
Now let me get a comprehensive view of the scan command and any "queue completion" logic:
Assistant
Assistant
User
Assistant
I'll start by thoroughly exploring the codebase to understand the current score display system, queue mechanics, and rendering patterns before designing the implementation plan.
Assistant
Now let me explore the remaining files that are referenced in the requirements.
Assistant
Now let me explore the next command entry point to understand how it calls the render functions, and the plan/state infrastructure for detecting queue state.
Assistant
Now let me examine the status command and the plan persistence layer to understand how to cheaply detect queue state.
Assistant
Now let me look at the state module to understand score_snapshot and the finding count mechanism, plus how status is rendered from the status command itself.
Assistant
Now let me look at the scan workflow to understand where scores are displayed during scan.
Assistant
Now let me understand how cheaply we can count queue items without building the full work queue. Let me check the state's findings directly.
Assistant
Let me also look at the _print_next_command in resolve/render.py more carefully, plus check how WorkQueueResult total is used since that gives us the cheap count.
Assistant
Now let me check how the resolve command's _print_next_command counts remaining findings -- this gives insight into a lightweight count approach.
Assistant
Let me also check the remaining call sites in the resolve/cmd.py (line 242) and review/import_cmd.py and review/merge.py to understand the full scope.
Assistant
Now I have a thorough understanding of the codebase. Let me compile the complete implementation plan.
Assistant
Let me check one last thing -- the review/merge.py call site, and then verify the __init__.py for the helpers to understand the module structure.
Assistant
Perfect! Now I have a comprehensive understanding of the system. Let me create a detailed summary document:
Comprehensive Workflow Analysis: Plan/Next/Score Systems in Desloppify
Based on my thorough exploration of the codebase, here is the complete user journey and information architecture:
1. USER JOURNEY: scan → plan → next → fix → repeat
Phase 1: desloppify scan (Entry Point)
The scan command populates the state (.desloppify/state.json) with:
Findings: Problems discovered by language-specific detectors (tiered 1-4, with confidence levels)
Four canonical scores:
overall_score (lenient, includes subjective dimensions)
objective_score (mechanical dimensions only)
strict_score (strict, includes subjective dimensions)
List of epics with thesis, root_cause, action_steps, finding_ids
plan Command Output:
plan (no subcommand): Generates markdown with tier-grouped findings, dimension health, and action recommendations
plan show: Displays plan metadata summary (queue size, clusters, skipped counts, epics, focus status)
plan queue: Shows prioritized items in order
plan move/describe/note/focus/skip/cluster: Edit the living plan
plan synthesize: Interactive planning workflow (observe findings, group by root cause, create action steps)
The plan is plan-aware: it reorders the queue so user-prioritized items appear first, and applies plan metadata (descriptions, cluster memberships) to every item.
Phase 3: desloppify next (Show Next Highest-Priority Item)
This is the primary user-facing command. It displays:
Tier Navigator (header)
code
Open: T1:5 T2:12 T3:28 T4:3
Shows how many items exist at each tier. User can switch: desloppify next --tier 2
Fallback Reason (if requested tier has 0 items)
E.g., "Requested T1 has 0 open → showing T2 (nearest non-empty)"
Queue Items (in priority order)
Built by build_work_queue() (ranked by: tier asc, confidence asc, count desc, id asc)
Applied plan order (user-prioritized items first)
Collapsed auto-clusters into meta-items (unless drilling into a cluster with --cluster)
Includes synthesis::pending and epic items when plan has them
Item Card Format (for each of the --count items, default 1):
code
[#1]
(Tier 2, high confidence)
────────────────────
Find orphaned imports in typescript files
→ [plan description if set]
Cluster: ... (if member of cluster)
Note: ... (if annotated)
File: src/main.ts
ID: ts::orphaned_imports::abc123def
Lines: 45, 67, 89
Dimension: Code Quality — 87.5% (strict: 85.0%) (3 of 8 checks failing)
Impact: fixing this is worth ~+2.1 pts on overall score
Auto-fixable: 3 similar findings. Run `desloppify fix orphaned_imports --dry-run` to fix all at once.
Special Item Types:
Synthesis card (when synthesis::pending is in queue): Full planning orchestrator showing stages, enrichment gaps, next actions
Subjective dimension cards: Re-review tasks for design dimensions below target
Epic cards: Large epics with thesis, root cause, dependency order, action steps
Cluster meta-items: Collapsed groups showing member count, file distribution, sample IDs
North Star Section (bottom):
code
Key Flags:
--tier N: Show only T1/T2/T3/T4 items
--count N: Show top N items (default 1)
--scope PATTERN: Filter by file/detector/dimension
--status open|fixed|all: Which findings to include
--group item|detector|file: Organize output
--explain: Show ranking rationale for each item
--cluster NAME: Drill into auto-cluster (show members)
--output FILE: Write JSON payload to file
Query Payload (written to .desloppify/query.json for IDE integration):
Contains items, queue metadata, scores, narrative, plan summary.
Phase 4: desloppify fix / Manual Work
For each next item:
Run the suggested command (e.g., desloppify fix orphaned_imports --dry-run)
Or manually resolve and annotate: desloppify plan done <id> --note "..." --attest "..."
Confidence scores and scoring engine credit fixes
Score Update Display (shown after fix):
code
Scores: overall 72.5/100 (+1.2) objective 71.0/100 (+0.8) strict 69.5/100 (+0.9) verified 68.0/100 (+1.1)
Strict 69.5 (target: 95.0) — run `desloppify next` to find the next improvement
Phase 5: desloppify scan (Re-scan to Close Loop)
Scan again:
Reconciles plan (purges resolved findings from queue, resurfaces stale skips)
Auto-clusters findings by detector
Updates all four scores
Triggers optional synthesis sync if subjective dimensions changed
2. THE "WORK QUEUE" CONCEPT
The work queue is a ranked list of actionable items built dynamically every time next or plan is called. It is not persisted (that's what the living plan is for).
Queue Construction Pipeline:
Filter findings by status (open/fixed/all), scope (path/detector/dimension)
Convert to queue items: Each finding becomes an item dict with:
E. Follow-up nudges (bottom of next output):
Shows low-scoring dimensions below target, stale reviews, unassessed dimensions, open review findings, and files needing re-review.
4. THE SHOW COMMAND
desloppify show <pattern> filters and displays findings by file/detector/dimension/pattern.
Entity Resolution:
show concerns: Design concerns from mechanical signals
show subjective: All subjective review findings + integrity dashboard
show <detector>: Findings from one detector (e.g., show unused_imports)
show <file>: Findings in that file
show <dimension>: All findings contributing to a dimension
QueueBuildOptions (for constructing a work queue):
python
QueueBuildOptions(
tier=None, # Filter to specific tier or None
count=1, # How many items to return
scan_path=None, # Scope (from state.scan_path)
scope=None, # Additional scope filter
status="open", # "open", "fixed", "all"
include_subjective=True, # Include review findings
subjective_threshold=100.0, # Only include subjective < threshold
chronic=False, # Only chronic (reopened 2+x)
no_tier_fallback=False, # Disable auto-fallback to next tier
explain=False, # Include ranking explanation
plan=plan_dict, # Living plan for reordering
include_skipped=False, # Include skipped items
cluster="name", # Drill into cluster
collapse_clusters=True # Auto-collapse clusters into meta-items
)
Used by: IDE extensions, automated agents, JSON output (--output FILE)
9. SUMMARY: USER EXPERIENCE
Typical session:
desloppify scan → populates state + plan reconciliation
desloppify plan → shows markdown plan with dimension health
desloppify next --count 5 → see top 5 tasks (team triage)
desloppify next (repeat) → work through items one at a time
desloppify fix <detector> --dry-run OR desloppify plan done <id> --note "..." --attest "..."
Score nudges after each operation show progress toward strict target
desloppify next --tier 2 → switch to different tier if needed
desloppify plan focus <epic> → enter focused mode on an epic
Repeat until desloppify next shows "Nothing to do! Strict score: 95.0/100"
Key Takeaway: The system provides continuous progress visibility (strict score), ranked prioritization (tier + confidence + plan), and plan-aware synthesis (epics + clusters) to guide user through codebase improvements in order of business impact.
Files Read (Absolute Paths)
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/plan/cmd.py — Plan command dispatcher
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/next.py — Next command implementation
Any other place scores are printed/rendered to terminal
For each location, note:
The exact file and function
What score(s) are shown (strict, overall, objective, verified)
The context (is it after a fix? in a queue display? in a summary?)
The exact line numbers and code
Also look for the concept of "queue completion" or "queue empty" - is there any existing logic that detects when the queue is fully cleared? Search for patterns like "nothing to do", "queue empty", "all done", "no items", etc.
Be very thorough - read every relevant file completely.
Perfect! Now I have all the information I need. Let me create a comprehensive report of the queue lifecycle:
Queue Lifecycle Analysis - Key Findings
Based on my thorough examination of the code, here's how desloppify tracks queue state and lifecycle:
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/plan/queue_render.py:99-101 → checks if not items
Current behavior:
python
# When queue has no items:
print(colorize("\n Queue is empty.", "green")) # Line 100 in queue_render.py
# In next command:
print(colorize(f"\n Nothing to do!{suffix}", "green")) # Line 375 in render.py
Test coverage:test_allowed_when_queue_empty() in test_review_preflight.py and test_empty_state_returns_empty_queue() in test_work_queue.py
3. Queue Lifecycle States
No explicit "started" vs "in progress" vs "completed" states exist, but there is implicit progression:
Queue started: When a plan is first created with empty_plan() and items added via queue_order
Queue in progress: Items are processed via:
move_items() - reorder queue_order
skip_items() - move to skipped (can be temporary with review_after)
unskip_items() - restore from skipped back to queue_order
Queue completed: When queue_order is empty AND skipped has no temporary items (only permanent/false_positive)
skip_items() (line 130-166): Move to skipped dict with kind metadata
unskip_items() (line 169-203): Restore from skipped back to queue_order
purge_ids() (line 467-495): Remove entirely from queue_order, skipped, and cluster memberships (used after findings resolve)
reconcile_plan_after_scan(): Post-scan, findings no longer in state are moved to superseded and removed from queue_order
5. Completion Events
No explicit "celebration" or completion event exists, but there are two completion mechanisms:
A. Synthesis-cluster completion (reconcile.py:229-236)
python
# When all findings in a synthesis-cluster are resolved:
if not alive and cluster.get("status") != "completed":
cluster["status"] = "completed"
_archive_cluster(plan, cluster, now)
del clusters[cname] # Remove from active clusters
Clusters are archived to completed_clusters with a timestamp
Archives are kept for 180 days (COMPLETED_CLUSTER_TTL_DAYS)
B. Queue empty detection (render.py:375 and queue_render.py:100)
Archiving completed regular findings (not just synthesis-clusters)
Tracking completion rate percentage as queue shrinks
All the plumbing exists in reconcile_plan_after_scan() to detect completion events—it just doesn't record them for celebration or historical tracking.
Excellent! Now I have enough information to compile a comprehensive report. Let me create a summary of all score display locations and queue completion logic:
COMPREHENSIVE REPORT: Score Display and Queue Completion in Desloppify
Based on my thorough analysis of the codebase, here are ALL the places where scores are displayed to users and the queue completion logic:
Lines 48-54: Checks if data["total_candidates"] == 0
Prints: "All production files have been reviewed. Nothing to do." (green)
3. TARGET REACHED LOGIC
Pattern: When strict score meets or exceeds target (gap ≤ 0)
print_strict_target_nudge() (lines 59-68 in score_update.py)
Green message: "Strict {strict:.1f} — target {target:.1f} reached!"
score_summary_lines() (lines 47-50 in summary.py)
Green message: "Strict {strict:.1f} — target {target:.1f} reached!"
render_followup_nudges() (lines 714-720 in next_parts/render.py)
Green message: "North star: strict X.X/100 meets target Y.Y"
4. SCORE METRICS DISPLAYED IN EACH COMMAND
Command
Scores Shown
Context
scan
overall, objective, strict, verified
Summary after scan with deltas, always shows guide
status
overall, objective, strict, verified
Dashboard view with full context
next
strict (in North Star section)
Shows progress toward target
fix (auto-fix)
overall, objective, strict, verified
After applying fixes with deltas
resolve
overall, objective, strict, verified
After resolving findings with deltas
ignore
overall, objective, strict, verified
After adding ignore pattern with deltas
show
None in main flow
Focuses on findings, not scores
plan
None in queue display
Shows queue metadata, not scores
5. KEY PATTERNS FOR DETECTING "ALL DONE"
show_empty_queue(queue, tier, strict) - Returns True when no items
if not items: checks in plan queue render
SYNTHESIS_ID checks - Blocks queue until synthesis complete
Stale dimension injection - Auto-adds items when queue empties
total_candidates == 0 in review flow
6. STRICT SCORE DISPLAY CONSISTENCY
The strict score is displayed/tracked in:
North Star section (next command) - PRIMARY USER-FACING
All state-changing command summaries (fix, resolve, ignore)
Status dashboard
Scan report with delta calculation
Target progress calculations in multiple places
The strict score is the "north star" metric mentioned throughout, used as the definitive measure of codebase health excluding wontfix items.
I'm designing a UX change for desloppify where the score is hidden during the "execution phase" (working through the queue) and only revealed when the queue is fully cleared or when starting a new plan cycle.
Current State
Score display locations (all need to change):
next command (app/commands/next_parts/render.py:705-720): Shows "North Star: strict X.X/100 → target Y.Y (+Z.Z needed)" at bottom of every next output
fix command (app/commands/fix/apply_flow.py:85-86): Calls print_score_update(state, prev) showing all 4 scores with deltas after every fix
resolve command (app/commands/resolve/render.py:61-132 and cmd.py:242): Shows all 4 scores with deltas after resolving findings
plan queue command (app/commands/plan/queue_render.py:78-100): Shows queue header with item counts
scan command (app/commands/scan/scan_reporting_summary.py:60-134): Shows all 4 scores after scan
status command (app/commands/status_parts/summary.py:9-57): Shows 4-score summary
Empty queue (app/commands/next_parts/render.py:371-384): Shows "Nothing to do!" with strict score suffix
Score update helper:
print_score_update() in app/commands/helpers/score_update.py:10-46 - central function that prints all 4 scores with deltas, always calls print_strict_target_nudge()
print_strict_target_nudge() in same file, lines 59-68 - shows strict vs target gap
Queue system:
Queue items are built by build_work_queue() in engine/_work_queue/core.py
Queue order stored in plan's queue_order list
Items removed via purge_ids() and skip_items() in engine/_plan/operations.py
No explicit queue progress tracking exists currently
Empty queue detected in show_empty_queue() - just prints "Nothing to do!"
Desired Behavior
Core principle: The score is the REWARD for clearing the entire queue. During execution, only show queue progress.
During execution (queue has items):
next: Show queue progress ("12 items remaining") instead of North Star score. Add message: "Clear the queue to see your updated score"
fix: Show queue progress ("12 → 11 items remaining") instead of 4-score update
Queue cleared (next shows "Nothing to do!"): This is the big moment - show the full score with celebration
Starting new plan (after scan): Scan should still show scores since it's the assessment point
plan creation: Show score prominently as the starting point
What about status and scan?
scan should keep showing scores - it's the natural re-assessment point and kicks off a new plan cycle
status is trickier - maybe show a simplified version or just queue progress with a note about running scan for scores
Design Requirements
Need a lightweight way to get queue item count (total remaining) that can be called from fix/resolve/next without building full work queue
Need a "queue progress" display function to replace print_score_update() in execution contexts
Need an enhanced "score reveal" for when queue is cleared
The score_update.py helper needs to become context-aware (are we mid-queue or at a milestone?)
Keep internal score computation unchanged - only change what's DISPLAYED
Please design a detailed implementation plan covering:
What each file change looks like
New helper functions needed
How to detect "queue has items" vs "queue is clear" cheaply
The exact messages/formatting for queue progress vs score reveal
Edge cases (what if there's no plan? what if queue was never started?)
Now I have a thorough understanding of the entire system. Let me compile my complete design.
Implementation Plan: Score-as-Reward UX
1. Design Philosophy
The core idea: during the "execution phase" (when the work queue has items), the numeric score is noise. Replace it with queue progress -- a countdown that gives the user tangible momentum. The score becomes the payoff for clearing the queue.
2. Cheaply Detecting Queue State
Problem: Building the full work queue (build_work_queue) is expensive -- it loads state, iterates all findings, sorts, applies plan ordering, collapses clusters. We need a cheap way to ask "are there queue items?"
Solution: A new lightweight function in desloppify/app/commands/helpers/score_update.py (or a new module) that counts open findings from state without building the full queue. The existing pattern from resolve/render.py:182-187 already does this:
python
remaining = sum(
1
for finding in state["findings"].values()
if finding.get("status") == Status.OPEN.value
and not finding.get("suppressed")
)
However, "queue items" and "open findings" are not identical. The queue includes subjective dimension items, synthesis items, and epic items. A truly accurate count requires build_work_queue.
Recommended approach: A two-tier strategy:
Cheap check:has_queue_items(state) -> bool -- just checks if any open, unsuppressed findings exist. This covers 95% of cases and is O(n) over findings only.
Accurate count (when needed for display): When we actually need to show "12 items remaining", we should use the queue total field from WorkQueueResult. The fix and resolve commands already have state loaded; building the queue at that point is acceptable because we're at the end of the command (after the actual work is done).
But there is a simpler, even cheaper approach: The plan's queue_order list already contains the ordered item IDs. We can count items in queue_order minus items in skipped, cross-referenced with open findings in state. However, this still misses items not explicitly in queue_order (auto-discovered findings).
Final recommendation: Create a queue_progress_count(state, plan) function that:
Counts open, unsuppressed findings in state
Adds subjective dimension items (count of dimensions below threshold)
This is cheap (just iterates the findings dict + a small dimension check)
This matches what the queue builder produces to within ~1-2 items, which is fine for a progress display
3. New Module: Queue Progress Display
Create a new file: desloppify/app/commands/helpers/queue_progress.py
This module centralizes all queue-progress and score-reveal display logic.
No changes needed. Keep print_score_update intact -- it is still used by scan, status, review import, and review merge (which are assessment/milestone contexts where scores should show). The new print_execution_or_score function in queue_progress.py replaces it only in execution-phase call sites.
Change: Replace print_score_update(state, prev) with print_execution_or_score(state, prev).
Before (line 84-86):
python
new = state_mod.score_snapshot(state)
print(f"\n Auto-resolved {len(resolved_ids)} findings in state")
print_score_update(state, prev)
After:
python
from desloppify.app.commands.helpers.queue_progress import print_execution_or_score
new = state_mod.score_snapshot(state)
print(f"\n Auto-resolved {len(resolved_ids)} findings in state")
# Capture prev count before operation for delta display
print_execution_or_score(state, prev)
Note: We need to capture the queue count BEFORE the fix operation runs. Add prev_queue_count = queue_item_count(state) just after loading state (line 79), then pass it through. Actually, looking at the flow more carefully: state is loaded at line 79, then _resolve_fixer_results mutates it (resolving findings), then save_state is called. So prev_queue_count should be captured at line 79 right after state = state_mod.load_state(state_file).
from desloppify.app.commands.helpers.queue_progress import print_execution_or_score
print_execution_or_score(state, prev, prev_queue_count=prev_queue_count)
Add prev_queue_count = queue_item_count(state) right after line 84 (prev = _previous_score_snapshot(state)).
Important edge case: The resolve command currently has special logic for review findings (lines 113-125 in render.py: "Scores unchanged (review findings don't affect scores directly)") and wontfix warnings (lines 103-112). These nuances are valuable but only when showing scores. During execution phase (queue has items), they are irrelevant because we are not showing scores at all. When queue clears, they could be shown. For the initial implementation, we can skip these nuances in the queue-progress path and preserve them in _print_score_movement for use only when explicitly calling that function (e.g., from a future "show my scores" command).
Change: Replace the "North Star" score display with queue progress when there are items.
The function currently shows:
code
North star: strict 82.3/100 -> target 95.0 (+12.7 needed)
Replace with queue progress display. The next command already has access to queue (from cmd_next -> _get_items), which includes total. So the simplest approach is to pass queue_total into render_followup_nudges.
Inside, replace the North Star block (lines 705-720):
python
if queue_total > 0:
print(
colorize(
f"\n Queue: {queue_total} items remaining. Clear the queue to see your updated score.",
"cyan",
)
)
else:
# Show the score as the reward for clearing the queue
if strict_score is not None:
gap = round(float(target_strict_score) - float(strict_score), 1)
if gap > 0:
print(
colorize(
f"\n North star: strict {strict_score:.1f}/100 -> target {target_strict_score:.1f} (+{gap:.1f} needed)",
"cyan",
)
)
else:
print(
colorize(
f"\n North star: strict {strict_score:.1f}/100 meets target {target_strict_score:.1f}",
"green",
)
)
Change: Replace score summary with queue progress when queue has items. Status is the "trickier" case from the requirements.
Recommended approach: Show a simplified version. When queue has items, show queue progress at the top, then the full dimension table (which is the actionable detail), but suppress the top-line score numbers.
Modify cmd_status around lines 102-109:
python
# Check if we're in execution phase
from desloppify.app.commands.helpers.queue_progress import has_active_queue
if has_active_queue(state):
# Show queue progress instead of top-line scores
from desloppify.app.commands.helpers.queue_progress import queue_item_count
count = queue_item_count(state)
print(colorize(f"\n Queue: {count} items remaining", "cyan"))
print(colorize(" Clear the queue to see your updated scores. (Or run `desloppify scan` for a full re-assessment.)", "dim"))
else:
for line, style in score_summary_lines(
overall_score=scores.overall,
objective_score=scores.objective,
strict_score=scores.strict,
verified_strict_score=scores.verified,
target_strict=target_strict_score,
):
print(colorize(line, style))
Keep the dimension table, structural areas, and everything else -- those are informational. Just suppress the numeric score headline.
4i. desloppify/app/commands/plan/queue_render.py
No change needed. The plan queue command already shows item counts ("Queue: 23 items (T1:2 T2:5 T3:12 T4:4)"). This is queue progress by nature.
4j. desloppify/app/commands/review/import_cmd.py (line 372) and review/merge.py (line 221)
Decision: These are borderline. Importing review results and merging reviews are significant operations that fundamentally change the scoring landscape. They could be considered "assessment moments" like scan. However, they happen mid-cycle.
Recommendation: Apply the same print_execution_or_score pattern here. When queue has items, show queue progress. When queue is empty, show the celebration.
5. Edge Cases
No plan exists: If load_plan() returns an empty plan (no queue_order, no clusters), we are in "unplanned" mode. In this case, has_active_queue(state) still works because it checks open findings in state, not the plan's queue_order. An unplanned queue with open findings should still show queue progress. An empty state with no findings shows scores (or "run scan").
Queue was never started (no scans yet):require_completed_scan(state) gates most commands. If state is empty, commands like next, fix, resolve either bail early or scores are unavailable. No special handling needed.
User wants to peek at scores mid-queue: This is deliberate -- the point is to hide scores during execution. However, status --json still dumps full scores for programmatic access. And scan always shows scores. So if they really want to see scores, they can run scan.
Synthesis phase: During synthesis, the queue has items (synthesis::pending) but no mechanical work is happening. The queue progress display should still work -- "1 item remaining" (the synthesis task). This is correct because synthesis IS the blocker.
Score becomes unavailable: If scores are None (no dimension scores computed), both old and new code handle this with "run desloppify scan" messages. No change needed.
6. Summary of All Changes
File
Change
Type
app/commands/helpers/queue_progress.py
NEW FILE -- queue progress display functions
New
app/commands/fix/apply_flow.py:78-86
Replace print_score_update with print_execution_or_score
Replace print_score_update with print_execution_or_score
Modify
app/commands/next_parts/render.py:371-384
Enhance show_empty_queue with score celebration
Modify
app/commands/next_parts/render.py:687-720
Replace North Star with queue progress
Modify
app/commands/next.py:166,184
Pass queue_total and extra args to render functions
Modify
app/commands/status_cmd.py:102-109
Conditionally show queue progress vs scores
Modify
app/commands/review/import_cmd.py:372
Replace print_score_update with print_execution_or_score
Modify
app/commands/review/merge.py:221
Replace print_score_update with print_execution_or_score
Modify
app/commands/scan/scan_reporting_summary.py
NO CHANGE -- scan always shows scores
Keep
app/commands/plan/queue_render.py
NO CHANGE -- already shows queue counts
Keep
app/commands/helpers/score_update.py
NO CHANGE -- kept for scan/assessment contexts
Keep
7. Testing Strategy
Unit tests for queue_progress.py: Test queue_item_count with various state shapes, has_active_queue, and the display functions with capsys.
Existing test updates: Tests in test_score_update.py remain unchanged (they test the unchanged print_score_update). Tests for fix, resolve, and next commands that assert score output need updating to expect queue progress output instead.
Integration-level tests: Test the full flow: fix a finding when queue has items (expect queue progress), fix the last finding (expect celebration).
Critical Files for Implementation
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/helpers/queue_progress.py - New module: all queue progress display logic (to be created)
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/helpers/score_update.py - Existing score display kept for scan/assessment contexts; reference for formatting patterns
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/fix/apply_flow.py - Fix command: replace print_score_update call at line 86 with execution-aware display
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/next_parts/render.py - Next command rendering: modify show_empty_queue (celebration) and render_followup_nudges (hide score during execution)
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/resolve/cmd.py - Resolve command: replace _print_score_movement call and print_score_update call with execution-aware display
North star: strict 87.3/100 → target 95.0 (+7.7 needed)
Gap shown in dim; when target reached, prints in green: "target 95.0 reached!"
Subjective Followup Summary:
code
Subjective: 2 dimensions below target, 1 stale, 3 unassessed.
Run `desloppify show subjective` for details.
"""Queue progress display for execution-phase commands."""
from __future__ import annotations
from desloppify import state as state_mod
from desloppify.core.enums import Status
from desloppify.core.output_api import colorize
def queue_item_count(state: dict) -> int:
"""Cheaply count approximate queue items from state.
Counts open, unsuppressed findings. This is an approximation --
the real queue may include subjective items, synthesis items, etc.
But it's fast (O(n) over findings) and accurate enough for display.
"""
findings = state.get("findings", {})
if not isinstance(findings, dict):
return 0
return sum(
1
for f in findings.values()
if isinstance(f, dict)
and f.get("status") == Status.OPEN.value
and not f.get("suppressed")
)
def has_active_queue(state: dict) -> bool:
"""Return True if the execution queue has remaining items."""
return queue_item_count(state) > 0
def print_queue_progress(
state: dict,
prev_count: int | None = None,
*,
label: str = "Queue",
) -> None:
"""Print queue progress instead of scores during execution phase.
Args:
state: Current state dict.
prev_count: If provided, shows delta (e.g., "12 -> 11 items remaining").
label: Prefix label.
"""
current = queue_item_count(state)
if prev_count is not None and prev_count != current:
resolved = prev_count - current
print(
colorize(
f"\n {label}: {prev_count} -> {current} items remaining "
f"({resolved} resolved)",
"green" if resolved > 0 else "yellow",
)
)
else:
suffix = "s" if current != 1 else ""
print(
colorize(
f"\n {label}: {current} item{suffix} remaining",
"cyan",
)
)
print(
colorize(
" Clear the queue to see your updated score.",
"dim",
)
)
def print_queue_cleared_celebration(
state: dict,
prev: state_mod.ScoreSnapshot,
*,
config: dict | None = None,
) -> None:
"""Show the full score reveal when the queue is cleared.
This is the reward moment -- show scores prominently with celebration.
"""
from desloppify.app.commands.scan.scan_helpers import format_delta
new = state_mod.score_snapshot(state)
if new.strict is None:
print(colorize("\n Queue cleared! Run `desloppify scan` for scores.", "green"))
return
print(colorize("\n Queue cleared!", "green"))
print(colorize(" " + "=" * 50, "green"))
if new.overall is not None and new.strict is not None:
overall_s, overall_c = format_delta(new.overall, prev.overall)
strict_s, strict_c = format_delta(new.strict, prev.strict)
print(
colorize(f" Overall: {new.overall:.1f}/100{overall_s}", overall_c)
)
print(
colorize(f" Strict: {new.strict:.1f}/100{strict_s}", strict_c)
)
if new.objective is not None:
objective_s, objective_c = format_delta(new.objective, prev.objective)
print(
colorize(
f" Objective: {new.objective:.1f}/100{objective_s}",
objective_c,
)
)
if new.verified is not None:
verified_s, verified_c = format_delta(new.verified, prev.verified)
print(
colorize(
f" Verified: {new.verified:.1f}/100{verified_s}",
verified_c,
)
)
print(colorize(" " + "=" * 50, "green"))
if config is None:
from desloppify.core import config as config_mod
config = config_mod.load_config()
from desloppify.app.commands.helpers.score import target_strict_score_from_config
target = target_strict_score_from_config(config, fallback=95.0)
gap = round(target - (new.strict or 0), 1)
if gap > 0:
print(
colorize(
f" Strict {new.strict:.1f} -> target {target:.1f} (+{gap:.1f} to go)",
"cyan",
)
)
print(
colorize(
" Run `desloppify scan` to refresh findings, then `desloppify plan` for next cycle.",
"dim",
)
)
else:
print(colorize(f" Target {target:.1f} reached!", "green"))
def print_execution_or_score(
state: dict,
prev: state_mod.ScoreSnapshot,
*,
config: dict | None = None,
label: str = "Scores",
prev_queue_count: int | None = None,
) -> None:
"""Context-aware display: queue progress during execution, scores at milestones.
This is the drop-in replacement for print_score_update() in execution commands.
"""
current_count = queue_item_count(state)
if current_count == 0:
# Queue is clear -- this is the reward moment!
print_queue_cleared_celebration(state, prev, config=config)
else:
# Still working -- show progress, not scores
print_queue_progress(state, prev_queue_count, label=label)