I need to understand how subjective dimension items (IDs like "subjective::design_coherence") get into the work queue and how they're ranked relative to objective findings.
Look at:
desloppify/engine/_work_queue/core.py - the build_work_queue function - how does it add subjective items? Is there injection logic?
desloppify/engine/_work_queue/ranking.py - the item_sort_key function - how are subjective items ranked vs objective findings?
desloppify/engine/_work_queue/helpers.py - any helper functions that inject subjective items
The bug: with 931 objective findings open, a subjective under-target dimension ("Design coherence 42.8%") is showing as queue item #1 even after removing the stale cluster. I need to understand why subjective items rank higher than objective findings in the sort order.
Just research - don't modify any code. Report the relevant code sections and the ranking logic.
Assistant
I'll investigate how subjective dimension items are injected into the work queue and how they're ranked relative to objective findings.
Assistant
Now let me check the NON_OBJECTIVE_DETECTORS constant to understand how objective findings are classified:
Assistant
Perfect. Let me also check the enrich_with_impact function more carefully to understand the impact computation:
Assistant
Now let me check the CONFIDENCE_ORDER to understand sort precedence:
Assistant
Perfect. Now let me create a comprehensive summary of my findings by analyzing the code flow:
Summary of Findings: Subjective Item Ranking and Injection
Based on my research of the codebase, here's how subjective dimension items are injected into the work queue and ranked relative to objective findings:
1. Subjective Item Injection (core.py:92-108)
Subjective items are injected in build_work_queue():
python
# Lines 92-108 in core.py
if (
resolved_options.include_subjective
and status in {"open", "all"}
and not resolved_options.chronic
):
subjective_items = build_subjective_items(
state,
state.get("findings", {}),
threshold=subjective_threshold_value,
)
for item in subjective_items:
if not scope_matches(item, resolved_options.scope):
continue
# Stale reruns only surface when objective backlog is zero
if item.get("stale_review") and objective_count > 0:
continue
all_items.append(item)
Key points:
Subjective items are added to all_itemsafter finding items (line 84)
Stale subjective items are blocked if objective_count > 0 (lines 86-90, 106-107)
objective_count counts findings with detectors NOT in NON_OBJECTIVE_DETECTORS: {"review", "concerns", "subjective_review", "subjective_assessment"}
2. How Subjective Items Are Built (helpers.py:344-453)
The build_subjective_items() function creates synthetic kind="subjective_dimension" items:
python
User
I need to understand all the places where "should subjective work surface?" decisions are made in this codebase. This is a refactoring task to consolidate scattered gating logic into a single policy function.
Find and document ALL locations where subjective dimension visibility is gated. Key areas to search:
desloppify/engine/_plan/stale_dimensions.py — sync_stale_dimensions() and sync_unscored_dimensions() — how they decide to inject/prune subjective IDs from queue_order
desloppify/engine/_plan/auto_cluster.py — _sync_subjective_clusters() — how it decides to create stale/unscored/under-target clusters and inject into queue_order
desloppify/engine/_work_queue/core.py — build_work_queue() — the initial_review/objective_count gating at query time
desloppify/engine/_work_queue/helpers.py — build_subjective_items() — how it creates synthetic subjective items and tags them
desloppify/engine/_work_queue/ranking.py — item_sort_key() — tier -3 for initial_review vs tier 1 for regular subjective
Also search for:
Any "preflight" or "postflight" or "pre_flight" or "post_flight" patterns related to review
NON_OBJECTIVE_DETECTORS usage — every place that computes "has objective backlog"
has_real_items or has_objective_items computations
Any other place that decides whether to show/hide subjective content
For each location, note:
The exact file and line range
What decision it makes (inject, prune, block, rank)
What inputs it uses (stale_ids, unscored_ids, under_target_ids, objective_count)
The comment/docstring explaining the policy
Be very thorough — the goal is to find EVERY scattered gating decision so we can consolidate them.
Assistant
I'll conduct a thorough search to find all locations where subjective dimension visibility gating decisions are made. Let me start with the specific files you mentioned and then expand to find related patterns.
Assistant
Now let me search for additional patterns and gating locations:
Assistant
Let me look at the preflight files and search for more gating patterns:
User
Search the desloppify codebase for ALL "preflight" and "postflight" (or "pre_flight", "post_flight", "pre-flight", "post-flight") patterns. The user suspects these relate to the same subjective gating policy issue.
Specifically:
Search for files/functions with "preflight" or "postflight" in their names
Read the review preflight module: desloppify/app/commands/review/preflight.py
Check scan preflight: desloppify/app/commands/scan/ for any preflight patterns
Look for any "guardrail" patterns that gate review commands
Search for print_triage_guardrail or similar guardrail functions
Check desloppify/app/commands/helpers/guardrails.py if it exists
For each preflight/postflight/guardrail:
What does it check?
Does it check objective backlog status?
Does it check subjective dimension state (stale/unscored/under-target)?
Is it making the same kind of "should we surface subjective work?" decision?
Also look for any "ugly" or duplicated patterns:
Multiple places computing the same thing differently
Inconsistent naming (stale vs refresh vs needs_review_refresh)
Functions that are too long or do too many things
Dead code or unused parameters
Assistant
I'll search the desloppify codebase for preflight/postflight and guardrail patterns systematically.
Assistant
Let me check the queue_policy and other planning files:
Assistant
Good! Now let me read the main preflight/guardrails files and search for the patterns:
Assistant
Now let me look at the plan.py file and check how plan reconciliation works:
Assistant
Now let me search for where these preflight/guardrail functions are called:
Assistant
Let me check the status command and rendering files:
User
Search the desloppify codebase to understand the subjective dimension state computation layer. I need to know all the functions that classify subjective dimensions and their relationships.
Key functions to find and read:
_current_stale_ids() in stale_dimensions.py
current_unscored_ids() in stale_dimensions.py
current_under_target_ids() in stale_dimensions.py
scorecard_subjective_entries() — where it lives and what it returns
build_subjective_items() in _work_queue/helpers.py — how it classifies items as initial_review vs stale_review vs under-target
Also search for:
subjective_strict_scores() or similar score-fetching helpers
Any caching of subjective state (are these functions called multiple times per operation?)
SUBJECTIVE_PREFIX usage across the codebase
NON_OBJECTIVE_DETECTORS — its definition and all usage sites
Constants like _STALE_KEY, _UNSCORED_KEY, _UNDER_TARGET_KEY
Document the data flow: state dict → classification functions → gating decisions. Note any inconsistencies in how different callers compute the same classification.
Assistant
I'll conduct a comprehensive search of the desloppify codebase to map the subjective dimension state computation layer. Let me start with strategic searches.
Assistant
Now let me look at where these are called:
Assistant
Let me check the show_subjective_followup function and the next command:
Assistant
Now let me read the key files:
Assistant
Let me check the status_parts/render.py file for the show_subjective_followup function:
Assistant
Now let me check the next and status commands to see how they use guardrails:
Assistant
Let me find the show_subjective_followup implementation:
Assistant
Now let me read the scorecard_projection module and auto_cluster to understand the complete flow:
Assistant
Let me check the scan_reporting_dimensions for the build_subjective_followup function:
Assistant
Now let me search for patterns related to subjective dimension gating and check tests:
Assistant
Let me read the scorecard_projection module to understand how entries are computed:
Assistant
Let me search for where the objective_backlog decision affects subjective visibility in a broader way:
Assistant
Now let me search for where subjective visibility decisions are made and look for duplicated logic:
Assistant
Now let me search for all callers and usages:
Assistant
Now let me look at reconcile.py to see how plan syncs happen:
Assistant
Let me check the status_cmd.py more closely and also look at the subjective dimension handling:
Assistant
Let me check the reconcile function more completely:
Assistant
Now let me check the work_queue core module to see the complete picture:
Assistant
Now let me check where the subjective dimension decision to surface is made:
Assistant
Now let me check the scan_workflow to see how plan syncing is orchestrated:
Assistant
Let me search for how the state itself stores subjective assessments:
Assistant
Now let me look at the test for actionability and see what it's testing:
Assistant
Perfect! Now let me check how the narrative system decides what to surface:
Assistant
Let me look at the schema files and tests to understand the data structures:
Assistant
Let me now search for how the queue breakdown is computed:
Assistant
Perfect! Now let me check the scan workflow where "stale" dimensions get marked:
Assistant
Perfect. Now let me search for how the integrity module relates:
Assistant
Excellent! Now let me look at the scorecard projection where stale is computed:
Assistant
Perfect! Now I have comprehensive understanding. Let me compile this into a detailed report. Let me also check one more critical location - the show command to see how it renders subjective items:
Assistant
Let me check the show command's build_work_queue call:
Assistant
Excellent! Now I have a comprehensive view. Let me create a summary document of my findings:
Summary of Preflight/Postflight/Guardrail Patterns in Desloppify
I've completed a thorough search of the desloppify codebase for all preflight, postflight, and guardrail patterns. Here are my findings:
Purpose: Returns set of subjective::<slug> IDs that are currently unscored (placeholder)
Data source: Dual-path fallback:
Primary: subjective_assessments dict with placeholder: True
Fallback: dimension_scores with subjective_assessment.placeholder: True (when assessments empty)
Logic:
If subjective_assessments is populated and non-empty, iterate its entries
Check each entry for placeholder: True flag
Fall back to scanning dimension_scores directly for entries with detectors.subjective_assessment.placeholder: True
Convert to IDs via slugify
Assistant
Now I have enough information to write a comprehensive report. Let me compile all the findings:
Summary of Subjective Dimension Visibility Gating Decisions
Based on my thorough analysis of the codebase, I've identified ALL locations where "should subjective work surface?" decisions are made. These are scattered across the planning engine, work queue construction, and display rendering. Here's the complete inventory:
1. Plan Queue Synchronization — desloppify/engine/_plan/stale_dimensions.py
sync_unscored_dimensions() (lines 203-241)
Decision: Inject unscored (placeholder) subjective dimensions unconditionally at front of queue
Inputs:current_unscored_ids(state) — dimensions with placeholder=True
Action: Always prepend unscored IDs after any promoted items
Policy Comment: "unconditionally prepend...so initial reviews are the first priority"
Prune Logic: Removes subjective IDs that are no longer unscored AND not stale (leaves stale for stale_sync to manage)
sync_stale_dimensions() (lines 248-292)
Decision: Conditionally inject stale (previously-scored, now-stale) dimensions ONLY when objective backlog is empty
Inputs:_current_stale_ids(state) — dimensions with stale=True
Gate Computation (lines 279-284):
python
has_real_items = any(
f.get("status") == "open"
and f.get("detector") not in NON_OBJECTIVE_DETECTORS
and not f.get("suppressed")
for f in state.get("findings", {}).values()
)
if not has_real_items and stale_ids: # GATE: no objective work remaining
# inject stale IDs to queue
Policy Comment: "append stale...when no objective items remain"
sync_create_plan_needed() (lines 395-440)
Decision: Inject workflow::create-plan only when:
No unscored dimensions remain
At least one objective finding exists
User
Based on thorough codebase exploration, I need to design a refactoring plan to consolidate scattered "should subjective work surface?" logic into a single policy module.
Current State (Problems)
The "should subjective work surface?" decision is made independently in 5+ places:
1. Objective backlog computation — duplicated in 5 places
Each uses this pattern but with slightly different variable names:
python
any/sum(
f.get("status") == "open"
and f.get("detector") not in NON_OBJECTIVE_DETECTORS
and not f.get("suppressed")
for f in findings.values()
)
build_work_queue() — same gating as stale (falls through)
3. Dimension key normalization — duplicated
_normalize_dimension_key() in preflight.py
_canonical_subjective_dimension_key() in scorecard_projection.py
Assistant
I'll explore the codebase thoroughly to understand the current state of the scattered subjective visibility logic, then design a detailed implementation plan.
Assistant
Now let me read the other key files to understand the scattered logic.
Assistant
Now let me look at additional consumers and related files.
Assistant
Now let me check the scan workflow to understand where syncs are called and how state flows through.
Assistant
Let me now check if there are any other consumers of NON_OBJECTIVE_DETECTORS and the key normalization functions, as well as look at tests.
Assistant
Let me also check the show command's render module and the queue_progress module where _objective_backlog is computed differently.
Assistant
Let me now check the show command to see how it computes objective_backlog, and look at relevant test files.
Assistant
Let me check a few more files to understand the test patterns and the existing stale_dimensions tests.
Assistant
Now let me also check the sync_create_plan_needed function (another consumer of the backlog check) and the dimension key normalization in scorecard_projection.py.
Assistant
Let me check one more important piece -- the engine/plan.py facade and how the sync functions are re-exported.
Assistant
Now I have a comprehensive understanding of the codebase. Let me check one more thing -- the show/cmd.py doesn't pass objective_backlog to show_subjective_followup. Let me verify the current signature call.
Assistant
Good. The show/cmd.py calls show_subjective_followup without passing objective_backlog -- it defaults to 0, meaning subjective nudges always show there. That's a minor inconsistency I should note.
Now I have a thorough understanding of the entire scattered landscape. Let me compile the complete implementation plan.
Assistant
I now have a thorough understanding of the entire codebase landscape. Let me compile the complete implementation plan based on everything I've explored.
The "should subjective work surface?" decision is made independently in 6+ locations with duplicated objective-backlog computation, scattered three-tier gating policy, and duplicated dimension-key normalization. This creates maintenance burden and risk of policy drift.
Inventory of All Duplication Sites
Objective backlog computation (6 sites):
/Users/user_c042661f/Documents/desloppify/desloppify/engine/_plan/stale_dimensions.py:279 -- has_real_items in sync_stale_dimensions()
/Users/user_c042661f/Documents/desloppify/desloppify/engine/_plan/stale_dimensions.py:425 -- has_objective in sync_create_plan_needed()
/Users/user_c042661f/Documents/desloppify/desloppify/engine/_plan/auto_cluster.py:492 -- has_objective_items in _sync_subjective_clusters()
/Users/user_c042661f/Documents/desloppify/desloppify/engine/_work_queue/core.py:87 -- objective_count in build_work_queue()
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/helpers/subjective.py:36 -- objective_backlog parameter in print_subjective_followup()
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/status_cmd.py:116-118 -- _objective_backlog computed from QueueBreakdown
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/preflight.py:60 -- _normalize_dimension_key() using re.sub(r"[^a-z0-9_]+", "_", text).strip("_")
/Users/user_c042661f/Documents/desloppify/desloppify/engine/_scoring/subjective/core.py:39 -- _normalize_dimension_key() using "_".join(name.strip().lower().replace("-", "_").split())
/Users/user_c042661f/Documents/desloppify/desloppify/engine/_work_queue/helpers.py:116 -- slugify() using re.sub(r"[^a-z0-9_]+", "_", text.lower()).strip("_")
Plus _canonical_subjective_dimension_key() at helpers.py:120 which wraps slugify with DISPLAY_NAMES lookup.
User
Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
This summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing development work without losing context.
Before providing your final summary, wrap your analysis in tags to organize your thoughts and ensure you've covered all necessary points. In your analysis process:
Chronologically analyze each message and section of the conversation. For each section thoroughly identify:
The user's explicit requests and intents
Your approach to addressing the user's requests
Key decisions, technical concepts and code patterns
Specific details like:
file names
full code snippets
function signatures
file edits
Errors that you ran into and how you fixed them
Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
Double-check for technical accuracy and completeness, addressing each required element thoroughly.
Your summary should include the following sections:
Primary Request and Intent: Capture all of the user's explicit requests and intents in detail
Key Technical Concepts: List all important technical concepts, technologies, and frameworks discussed.
Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Pay special attention to the most recent messages and include full code snippets where applicable and include a summary of why this file read or edit is important.
Errors and fixes: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
All user messages: List ALL user messages that are not tool results. These are critical for understanding the users' feedback and changing intent.
Pending Tasks: Outline any pending tasks that you have explicitly been asked to work on.
Current Work: Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
Optional Next Step: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests, and the task you were working on immediately before this summary request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests or really old requests that were already completed without confirming with the user first.
If there is a next step, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no drift in task interpretation.
Assistant
Initial request: User asked to implement a plan for fixing issue #186 - "Stale subjective re-review surfaced before objective backlog drained". The plan had 3 changes: fix stale cluster membership, evict under-target IDs when objective backlog returns, and add regression tests.
Bug 1 fix: I edited auto_cluster.py to change stale_queue_ids computation to intersect with _current_stale_ids(state). Also removed duplicate stale_state_ids computation.
Bug 2 fix: Added eviction pass after the under-target injection block to remove under-target IDs from queue_order when has_objective_items is True.
Regression tests: Added _under_target_state helper and 3 tests to test_auto_cluster.py.
Stale dimensions test fix: test_stale_cluster_updated in test_stale_dimensions.py failed because it added a dimension to queue_order without adding it to state. Fixed by providing proper state with all 3 dimensions.
User interrupted with real data from Reigh repo showing 0 actual stale dimensions, 931 objective findings, but stale-review at queue position #1. User confirmed the bug.
User asked to investigate deeper: "There is still a bug. You can look at the state in documents/reigh and even run next there to replicate it yourself"
Investigation of real data: Found 14 under-target IDs in queue_order, all in auto/stale-review cluster. My fixes correctly cleaned these up when run against real data.
Third bug discovered: After my plan-level fixes, next still showed subjective "Design coherence (42.8%)" as #1. Investigation via explore agent revealed that build_work_queue() in core.py injects synthetic subjective items at query time, and only gated stale_review items, not under-target items.
Bug 3 fix: Changed gating in core.py from if item.get("stale_review") and objective_count > 0 to if not item.get("initial_review") and objective_count > 0.
Package installation issue: python -m desloppify from Reigh dir was loading the site-packages copy (v0.8.0), not the local source. Fixed with .
Computed from compute_health_breakdown() in health.py
The Real Problem:
If a subjective dimension has high configured weight and low score (e.g., 42.8%), it gets very high headroom (57.2%)
Combined with subjective dimension weights (from SUBJECTIVE_DIMENSION_WEIGHTS), this can produce very high impact values
When -impact is the second sort element, higher impact sorts FIRST (negative values sort smaller)
A subjective item with impact = 50 produces tuple (1, -50, ...) which sorts BEFORE an objective finding with impact = 30 producing (1, -30, ...)
5. Stale Subjective Blocking (core.py:86-107)
The stale blocking mechanism checks:
python
# Count open objective findings (BEFORE adding subjective items)
objective_count = sum(
1 for item in finding_items
if item.get("detector") not in NON_OBJECTIVE_DETECTORS
)
# ...later, when adding subjective items:
if item.get("stale_review") and objective_count > 0:
continue # Skip stale subjective items if objective_count > 0
But: With 931 objective findings, if the subjective item is NOT marked stale_review (because it's not also initial_review=False), the stale block doesn't apply.
With "Design coherence 42.8%" showing as queue item #1 despite 931 objective findings:
Impact calculation: The subjective dimension likely has high configured weight (e.g., 10x) + low score (42.8%) = high headroom (57.2%) → very high impact value
Sort order: Both subjective and objective are tier 1, but subjective ranks by (-impact, subjective_score, id) while objectives rank by (-impact, confidence, review_weight, count, id)
Impact dominates: If subjective impact >> objective impacts, the subjective item sorts first even with 931 other findings
Stale bypass: The item is NOT blocked by stale checking because it's either not marked stale_review, or it's not in the stale queue yet
The fundamental issue is that subjective dimension weight × (100 - subjective_score) can be artificially inflated, causing a single under-target dimension to dominate the sort order regardless of the size of the objective backlog.
Three functions:
triage_guardrail_status() — pure detection, returns TriageGuardrailResult
print_triage_guardrail_info() — shows yellow info banner if stale
require_triage_current_or_exit() — exits(1) if stale and not bypassed
SUBJECTIVE VISIBILITY GATING PATTERN
The codebase has TWO DISTINCT but related places making "should we surface subjective work?" decisions:
A. During status/next/show rendering: Objective backlog gating
Extensive coverage of edge cases (first run vs rerun, per-dimension targeting, stale filtering)
KEY DESIGN INSIGHT
The "subjective gating policy" actually has two layers:
Preflight layer: Prevents review reruns when backlog exists (backlog = objective + open subjective queue)
Actionability layer: Suppresses subjective nudges during rendering when objective backlog > 0
These work together: preflight keeps you from running reviews while backlog exists, and actionability layer hides subjective suggestions when you should focus on objective work. Stale items are special—they're marked as work but DON'T block preflight (they ARE the work you should do).
Note: Cannot use scorecard_subjective_entries() here because it "intentionally hides placeholders"
Purpose: Creates synthetic subjective work items for queue display
Classification logic (lines 418-421):
python
is_unassessed = bool(entry.get("placeholder")) or (
name in unassessed_dims
or (strict_val <= 0.0 and int(entry.get("issues", 0)) == 0)
)
is_stale = bool(entry.get("stale"))
{
"naming_quality": {
"score": 75.0,
"placeholder": False, # or True for unscored
"needs_review_refresh": True, # marks as stale
"refresh_reason": "...",
"stale_since": "ISO timestamp",
"source": "review_...",
}
}
Classification Decision Tree
code
For each dimension in dimension_scores:
1. Is it subjective?
└─ Check: "subjective_assessment" in detectors OR lowered_name in subjective_display_names
2. Compute placeholder:
└─ assessment.placeholder OR (score==0 AND issues==0 AND checks==0)
3. Compute stale:
└─ subjective_assessments[dim_key].needs_review_refresh == True
4. Compute strict:
└─ dimension.strict OR dimension.score
5. Classify item:
├─ If placeholder → "initial_review" (unscored)
├─ Else if stale → "stale_review" (needs refresh)
├─ Else if strict < target → "under_target" (optional, objective-backlog dependent)
└─ Else → not included (at target)
Queue Gating Logic
In build_work_queue() (core.py lines 86-110):
python
# Count objective findings
objective_count = sum(
1 for item in finding_items
if item.get("detector") not in NON_OBJECTIVE_DETECTORS
)
# Gate subjective items
if include_subjective and status in {"open", "all"} and not chronic:
subjective_items = build_subjective_items(...)
for item in subjective_items:
# Initial review: always surface
if item.get("initial_review"):
all_items.append(item)
# Stale/under-target: only when objective backlog empty
elif objective_count > 0:
continue # skip
else:
all_items.append(item)
In plan sync (stale_dimensions.py lines 278-291):
python
has_real_items = any(
f.get("status") == "open"
and f.get("detector") not in NON_OBJECTIVE_DETECTORS
and not f.get("suppressed")
for f in state.get("findings", {}).values()
)
if not has_real_items and stale_ids:
# Inject stale dimensions at back of queue
Decision: Create/update/delete clusters for unscored, stale, and under-target dimensions
Unscored cluster (lines 435-449):
Gate: Min size 1 (always created if unscored items exist)
Action: Creates auto/initial-review cluster for all unscored dimensions
Stale cluster (lines 451-468):
Gate: Min size 2
Action: Creates auto/stale-review cluster for all stale dimensions
Under-target cluster (lines 470-527):
Gate Computation (lines 492-497):
python
has_objective_items = any(
f.get("status") == "open"
and f.get("detector") not in NON_OBJECTIVE_DETECTORS
and not f.get("suppressed")
for f in findings.values()
)
if not has_objective_items and len(under_target_queue_ids) >= _MIN_CLUSTER_SIZE:
# Create optional under-target cluster
Eviction Logic (lines 529-536): When objective backlog returns, ALL under-target IDs are removed from queue_order
Comment: "only inject under-target items when no objective findings remain — mirror the guard used by sync_stale_dimensions()"
3. Work Queue Construction — desloppify/engine/_work_queue/core.py
build_work_queue() (lines 59-158)
Decision: Gate whether non-initial subjective items appear in the work queue
Gate Logic (lines 86-110):
python
objective_count = sum(
1 for item in finding_items
if item.get("detector") not in NON_OBJECTIVE_DETECTORS
)
if (
resolved_options.include_subjective
and status in {"open", "all"}
and not resolved_options.chronic
):
subjective_items = build_subjective_items(...)
for item in subjective_items:
if not scope_matches(item, resolved_options.scope):
continue
# Non-initial subjective items only surface when objective
# backlog is drained — stale reruns AND under-target dims
# should wait until all mechanical work is done.
if not item.get("initial_review") and objective_count > 0:
continue # GATE: skip non-initial when objective work exists
all_items.append(item)
Policy Comment: "Non-initial subjective items only surface when objective backlog is drained"
Blocks if:objective_total > 0 or subjective_total > 0
Subjective Backlog Count (lines 66-100):
python
def _count_open_subjective_queue_items(state, *, dimensions=None):
queue = build_work_queue(
state,
options=QueueBuildOptions(
status="open",
include_subjective=True,
count=None,
),
)
count = 0
for item in queue.get("items", []):
if item.get("kind") != "subjective_dimension":
continue
# Stale reruns are not blocking backlog — they ARE the work
if item.get("stale_review"):
continue # GATE EXCEPTION: stale is the work, not blocking work
if normalized_dims is None:
count += 1
6. Display Rendering — Visibility in Status/Next/Show
Decision: Suppress quality nudges when objective backlog > 0
python
def print_subjective_followup(followup, *, objective_backlog: int = 0):
if followup.low_assessed and objective_backlog <= 0:
# Print quality improvement suggestions
if followup.integrity_lines:
# Always print integrity warnings (anti-gaming)
Policy Comment: "When objective_backlog > 0, quality nudges are suppressed entirely — the queue already surfaces subjective work when it becomes actionable."
7. Plan Reconciliation — desloppify/engine/_plan/reconcile.py
reconcile_plan_after_scan() (lines 132-217)
Decision: Move disappeared findings to superseded (not directly subjective, but manages plan state)
Doesn't inject/eject subjective dimensions
Synthetic IDs (prefixes: triage::, workflow::, subjective::) are exempted (lines 158-161)
Maps to subjective_threshold parameter in QueueBuildOptions
Used in build_subjective_items() to filter items below threshold
Default 95.0, clamped to [0.0, 100.0]
Key Policy Consolidation Points
The Three-Tier Injection Policy:
Item Kind
Condition
Location
Unscored (placeholder)
ALWAYS
sync_unscored_dimensions() front of queue
Stale (needs re-review)
objective_count == 0
sync_stale_dimensions() back of queue
Under-target (improving)
objective_count == 0 AND min size 2
_sync_subjective_clusters() back of queue (optional)
The Objective-Count Gate:
Used in 5 places:
sync_stale_dimensions() — line 279
_sync_subjective_clusters() — line 492
build_work_queue() — line 108
print_subjective_followup() — line 36
_render_dimension_legend() — line 65
Computed as:
python
objective_count = sum(
1 for f in findings.values()
if f.get("status") == "open"
and f.get("detector") not in NON_OBJECTIVE_DETECTORS
and not f.get("suppressed")
)
Exceptions to the Gate:
Stale review in preflight: Counted as the work itself, not blocking work (line 90 in preflight.py)
Integrity warnings: Always shown regardless of backlog (line 52 in subjective.py)
All 9 decision points are now documented. For consolidation, I recommend creating a new module desloppify/engine/_policy/subjective_visibility.py with a single policy function that encapsulates:
This would replace the scattered logic currently spread across 5+ files.
Slugify patterns in work_queue helpers
4. Classification functions — reasonably centralized but consumers duplicate decisions
_current_stale_ids(), current_unscored_ids(), current_under_target_ids() all live in stale_dimensions.py, which is good. But their consumers each independently compute the backlog check and decide what to do.
5. Review preflight — related policy
review_rerun_preflight() in preflight.py gates review reruns when "backlog exists" (both objective + open subjective queue). It explicitly excludes stale_review items from the blocking count because stale items ARE the work.
Design Proposal
New module: desloppify/engine/_plan/subjective_policy.py
A single policy class that encapsulates ALL the decisions:
python
@dataclass(frozen=True)
class SubjectiveVisibility:
"""Single source of truth for subjective dimension visibility."""
# Classification sets
stale_ids: frozenset[str]
unscored_ids: frozenset[str]
under_target_ids: frozenset[str]
# Backlog state
objective_open_count: int
@property
def has_objective_backlog(self) -> bool:
return self.objective_open_count > 0
# Policy decisions
@property
def surface_unscored(self) -> bool:
"""Unscored dims always surface (onboarding priority)."""
return True
@property
def surface_stale(self) -> bool:
"""Stale dims only surface when objective backlog is drained."""
return not self.has_objective_backlog
@property
def surface_under_target(self) -> bool:
"""Under-target dims only surface when objective backlog is drained."""
return not self.has_objective_backlog
def should_surface(self, item_id: str, *, initial_review: bool = False) -> bool:
"""Should a subjective item appear in the work queue?"""
if initial_review or item_id in self.unscored_ids:
return True
return not self.has_objective_backlog
def should_inject_to_queue(self, item_id: str) -> bool:
"""Should a subjective ID be injected into plan queue_order?"""
if item_id in self.unscored_ids:
return True
if item_id in self.stale_ids:
return self.surface_stale
if item_id in self.under_target_ids:
return self.surface_under_target
return False
def should_evict_from_queue(self, item_id: str) -> bool:
"""Should a subjective ID be evicted from plan queue_order?"""
if item_id in self.unscored_ids:
return False # never evict unscored
if item_id in self.under_target_ids and self.has_objective_backlog:
return True
return False
Factory function
python
def compute_subjective_visibility(
state: StateModel,
*,
target_strict: float = 95.0,
) -> SubjectiveVisibility:
"""Compute the current subjective visibility policy from state."""
findings = state.get("findings", {})
objective_count = sum(
1 for f in findings.values()
if f.get("status") == "open"
and f.get("detector") not in NON_OBJECTIVE_DETECTORS
and not f.get("suppressed")
)
return SubjectiveVisibility(
stale_ids=frozenset(_current_stale_ids(state)),
unscored_ids=frozenset(current_unscored_ids(state)),
under_target_ids=frozenset(current_under_target_ids(state, target_strict=target_strict)),
objective_open_count=objective_count,
)
Consumer Refactoring
1. sync_stale_dimensions() — use policy.surface_stale
Replace:
python
has_real_items = any(...)
if not has_real_items and stale_ids:
With:
python
if policy.surface_stale and stale_ids:
2. _sync_subjective_clusters() — use policy throughout
Replace 3 separate computations with policy lookups:
3. build_work_queue() — use policy.should_surface()
Replace:
python
objective_count = sum(...)
if not item.get("initial_review") and objective_count > 0:
continue
With:
python
if not policy.should_surface(item["id"], initial_review=item.get("initial_review", False)):
continue
4. print_subjective_followup() — use policy.has_objective_backlog
Replace: objective_backlog > 0 parameter with policy.has_objective_backlog
5. Review preflight — use policy.has_objective_backlog
The preflight already has distinct logic (counts both objective AND open subjective queue items as blocking). It should still use policy.has_objective_backlog for the objective part.
Also clean up:
Move NON_OBJECTIVE_DETECTORS to the new policy module (it's the policy's concept)
Keep SUBJECTIVE_PREFIX in stale_dimensions.py (it's an ID format, not policy)
Consider: should classification functions move to the policy module too? They're already in stale_dimensions.py which is getting overloaded.
Key constraints:
The policy object must be frozen/immutable — compute once, use everywhere in a single operation
Must not break the existing scan workflow order (sync functions run sequentially)
Must maintain backward compatibility for all public APIs
Tests should be updated to use the policy where they currently construct ad-hoc checks
Questions to consider:
Should the policy be computed once in scan_workflow and passed down, or should each consumer compute it?
Recommendation: Compute once and pass down. The scan workflow already loads state once.
Should classification functions move from stale_dimensions.py to the new policy module?
Recommendation: Move them. stale_dimensions.py is overloaded with ID helpers + sync functions + classification.
Should the preflight use the same policy object?
Recommendation: Yes for objective_backlog, but keep its own subjective queue counting (different purpose).
Please design a detailed implementation plan with specific file-level changes, function signatures, and migration strategy.
Phase 1: Create the Policy Module
New file: desloppify/engine/_plan/subjective_policy.py
This module has two parts: a frozen dataclass capturing the computed policy state, and a factory function that computes it from state.
python
"""Single source of truth for subjective dimension visibility policy.
Centralizes the 'should subjective work surface?' decision that was
previously scattered across sync_stale_dimensions, auto_cluster,
build_work_queue, and display helpers.
The policy is:
- **Unscored** (initial_review): ALWAYS surface -- onboarding priority.
- **Stale**: Only surface when objective backlog is drained.
- **Under-target**: Only surface when objective backlog is drained.
"""
from __future__ import annotations
from dataclasses import dataclass
from desloppify.engine._state.schema import StateModel
# Detectors whose findings are NOT objective mechanical work.
# Used to decide when the objective backlog is drained.
NON_OBJECTIVE_DETECTORS: frozenset[str] = frozenset({
"review", "concerns", "subjective_review", "subjective_assessment",
})
@dataclass(frozen=True)
class SubjectiveVisibility:
"""Immutable snapshot of subjective dimension visibility decisions.
Compute once per operation, pass to all consumers.
"""
stale_ids: frozenset[str]
unscored_ids: frozenset[str]
under_target_ids: frozenset[str]
objective_open_count: int
@property
def has_objective_backlog(self) -> bool:
return self.objective_open_count > 0
@property
def surface_stale(self) -> bool:
"""Stale dims only surface when objective backlog is drained."""
return not self.has_objective_backlog
@property
def surface_under_target(self) -> bool:
"""Under-target dims only surface when objective backlog is drained."""
return not self.has_objective_backlog
def should_surface(self, item_id: str, *, initial_review: bool = False) -> bool:
"""Should a subjective item appear in the work queue?"""
if initial_review or item_id in self.unscored_ids:
return True
return not self.has_objective_backlog
def should_inject_to_queue(self, item_id: str) -> bool:
"""Should a subjective ID be injected into plan queue_order?"""
if item_id in self.unscored_ids:
return True
if item_id in self.stale_ids:
return self.surface_stale
if item_id in self.under_target_ids:
return self.surface_under_target
return False
def should_evict_from_queue(self, item_id: str) -> bool:
"""Should a subjective ID be evicted from plan queue_order?"""
if item_id in self.unscored_ids:
return False
if item_id in self.under_target_ids and self.has_objective_backlog:
return True
return False
def count_objective_open(state: StateModel) -> int:
"""Count open, non-suppressed, objective findings."""
return sum(
1 for f in state.get("findings", {}).values()
if f.get("status") == "open"
and f.get("detector") not in NON_OBJECTIVE_DETECTORS
and not f.get("suppressed")
)
def compute_subjective_visibility(
state: StateModel,
*,
target_strict: float = 95.0,
) -> SubjectiveVisibility:
"""Compute the current subjective visibility policy from state.
This is the single factory function. Call once per scan/command,
pass the result to all consumers.
"""
from desloppify.engine._plan.stale_dimensions import (
_current_stale_ids,
current_under_target_ids,
current_unscored_ids,
)
return SubjectiveVisibility(
stale_ids=frozenset(_current_stale_ids(state)),
unscored_ids=frozenset(current_unscored_ids(state)),
under_target_ids=frozenset(
current_under_target_ids(state, target_strict=target_strict)
),
objective_open_count=count_objective_open(state),
)
Key design decisions:
NON_OBJECTIVE_DETECTORS moves here from stale_dimensions.py (with a re-export alias at the old location for backward compatibility).
The lazy imports of _current_stale_ids, current_unscored_ids, current_under_target_ids inside compute_subjective_visibility() avoid circular imports since stale_dimensions.py will import from this module for the constant.
count_objective_open() is a standalone helper so sync_create_plan_needed can use it too (it does not suppress findings, unlike the backlog check in work queue which filters by scope).
The dataclass is frozen/immutable -- compute once, use everywhere in a single operation.
Remove the NON_OBJECTIVE_DETECTORS definition (lines 36-38).
Import it from the new policy module:
python
from desloppify.engine._plan.subjective_policy import NON_OBJECTIVE_DETECTORS
Keep it in __all__ for backward compatibility (re-export).
Classification functions (_current_stale_ids, current_unscored_ids, current_under_target_ids) stay here for now -- they are ID-computation helpers, not policy.
has_real_items = any(
f.get("status") == "open"
and f.get("detector") not in NON_OBJECTIVE_DETECTORS
and not f.get("suppressed")
for f in state.get("findings", {}).values()
)
if not has_real_items and stale_ids:
from desloppify.engine._plan.subjective_policy import (
SubjectiveVisibility,
compute_subjective_visibility,
)
# Use provided policy or compute one
_policy = policy or compute_subjective_visibility(state)
# ... (prune logic stays the same) ...
# --- Inject: populate when no objective items remain -----------------
if _policy.surface_stale and stale_ids:
existing = set(order)
for sid in sorted(stale_ids):
if sid not in existing:
order.append(sid)
result.injected.append(sid)
has_objective = any(
f.get("status") == "open"
and f.get("detector") not in NON_OBJECTIVE_DETECTORS
for f in findings.values()
)
if not has_objective:
return result
With:
python
_policy = policy or compute_subjective_visibility(state)
if not _policy.has_objective_backlog:
return result
Note: sync_create_plan_needed previously did not check suppressed. This is a subtle semantic difference -- the policy's count_objective_open() checks not f.get("suppressed"). This is actually the correct behavior (suppressed findings shouldn't count as backlog), so this is a bug fix.
Phase 4: Refactor _sync_subjective_clusters() to Accept Policy
# Current:
objective_count = sum(
1 for item in finding_items
if item.get("detector") not in NON_OBJECTIVE_DETECTORS
)
# ...
if not item.get("initial_review") and objective_count > 0:
continue
With:
python
_policy = resolved_options.policy
for item in subjective_items:
if not scope_matches(item, resolved_options.scope):
continue
if _policy is not None:
if not _policy.should_surface(
item["id"], initial_review=item.get("initial_review", False)
):
continue
else:
# Fallback: compute inline (backward compat for callers without policy)
objective_count = sum(
1 for it in finding_items
if it.get("detector") not in NON_OBJECTIVE_DETECTORS
)
if not item.get("initial_review") and objective_count > 0:
continue
all_items.append(item)
Important: The work queue's objective_count is computed from finding_items (already scope-filtered), while the policy's objective_open_count is computed from all findings. This is a semantic difference. The policy should be the source of truth -- the scoped count was never intentionally different. For the first iteration, keep the fallback for callers that don't provide a policy, but document the intent to converge.
# Current:
if followup.low_assessed and objective_backlog <= 0:
# New:
_has_backlog = (
policy.has_objective_backlog if policy is not None
else objective_backlog > 0
)
if followup.low_assessed and not _has_backlog:
The objective_backlog: int parameter is kept for backward compatibility but deprecated.
Update _render_dimension_legend, show_dimension_table, and show_subjective_followup to accept policy parameter (with objective_backlog kept for backward compat):
Wait -- the scan_workflow wraps sync functions through local helper functions that take a sync_fn callable. The cleanest approach is to update those local helpers:
Or better -- just call the sync functions directly now rather than through indirection. The indirection was useful when the functions were simpler, but adding policy to the lambda wrappers is awkward. Update the scan_workflow callers to call sync functions directly with the policy kwarg.
test_no_injection_when_queue_has_real_items -- should still pass (state has objective findings). Optionally add a variant that passes a pre-computed policy.
Add new tests that exercise the policy= parameter directly.
The preflight version and slugify are effectively identical. The subjective/core.py version differs for edge cases (consecutive spaces, mixed hyphens). Recommendation: adopt slugify as the canonical implementation and have preflight and subjective/core delegate to it. But this is a separate cleanup -- do NOT bundle it with the policy consolidation to keep the PR focused.
Implementation Sequence
Step
Description
Risk
Files Changed
1
Create subjective_policy.py with SubjectiveVisibility, compute_subjective_visibility, count_objective_open, and NON_OBJECTIVE_DETECTORS
Steps 1-2 can be done first and independently verified. Steps 3-5 are the core refactoring. Steps 6-7 are the wiring. Step 9 should be interleaved -- write the new policy tests after step 1, update test expectations after steps 3-5.
Risks and Mitigations
Semantic difference in scope filtering: build_work_queue currently computes objective_count from scope-filtered finding_items, while the policy computes from all findings. Mitigation: Keep the inline fallback in step 5 for callers without a policy. Document the intent to converge. The "all findings" semantics is more correct -- you don't want stale-subjective gating to change based on what --scope you pass to show.
sync_create_plan_needed bug fix: The existing code does not check f.get("suppressed") in its backlog count. The policy does. This is a minor behavioral change that is actually a bug fix (suppressed findings should not count as backlog). Mitigation: Call it out in the PR description.
Circular imports: subjective_policy.py needs stale_dimensions.py for classification functions, and stale_dimensions.py will import from subjective_policy.py for NON_OBJECTIVE_DETECTORS. Mitigation: Use lazy imports in compute_subjective_visibility() (already shown in the design).
Backward compatibility: All existing public APIs keep their old parameters. The policy parameter is always optional with a None default. Old callers continue to work unchanged.
Critical Files for Implementation
/Users/user_c042661f/Documents/desloppify/desloppify/engine/_plan/subjective_policy.py - New file: the core policy dataclass and factory function
/Users/user_c042661f/Documents/desloppify/desloppify/engine/_plan/auto_cluster.py - Replace 3 separate backlog computations with policy lookups
/Users/user_c042661f/Documents/desloppify/desloppify/engine/_work_queue/core.py - Add policy to QueueBuildOptions, use policy.should_surface()
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/scan/scan_workflow.py - Compute policy once in _reconcile_plan_post_scan, pass to all sync functions
Here's an example of how your output should be structured:
Key Technical Concepts:
[Concept 1]
[Concept 2]
[...]
Files and Code Sections:
[File Name 1]
[Summary of why this file is important]
[Summary of the changes made to this file, if any]
[Important Code Snippet]
[File Name 2]
[Important Code Snippet]
[...]
Errors and fixes:
[Detailed description of error 1]:
[How you fixed the error]
[User feedback on the error if any]
[...]
Problem Solving:
[Description of solved problems and ongoing troubleshooting]
All user messages:
[Detailed non tool use user message]
[...]
Pending Tasks:
[Task 1]
[Task 2]
[...]
Current Work:
[Precise description of current work]
Optional Next Step:
[Optional Next step to take]
Please provide your summary based on the conversation so far, following this structure and ensuring precision and thoroughness in your response.
There may be additional summarization instructions provided in the included context. If so, remember to follow these instructions when creating the above summary. Examples of instructions include:
Compact Instructions
When summarizing the conversation focus on typescript code changes and also remember the mistakes you made and how you fixed them.
IMPORTANT: Do NOT use any tools. You MUST respond with ONLY the ... block as your text output.
pip install -e .
Test updates: Updated test_subjective_items_do_not_starve_objective_queue_head in both work_queue_cases.py and integration/work_queue_cases.py to expect subjective items are blocked (not present) when objective backlog exists.
Full test suite: 3853 passed, 3 skipped. Final Reigh test showed objective structural finding at #1.
User asked about root cause: I explained the three independent systems problem.
User asked to consolidate: "Let's do that. Let's make it the whole structure. Beautiful. And let's make it be something that applies to the pre-flight and post-flight thing..."
Entered plan mode: Launched 3 explore agents to research all subjective gating locations, preflight/postflight patterns, and subjective state helpers.
Launched Plan agent: Designed a comprehensive refactoring plan for a SubjectiveVisibility policy dataclass.
Read critical files to verify plan details: stale_dimensions.py, core.py, scan_workflow.py, subjective.py, preflight.py, status_cmd.py, render.py.
Currently: In plan mode, about to write the final plan to the plan file and call ExitPlanMode.
Bug 1 fix: Changed stale_queue_ids to intersect with actual stale IDs
Bug 2 fix: Added eviction of under-target IDs when objective backlog returns
The function was refactored into _sync_finding_clusters(), _sync_subjective_clusters(), _prune_stale_clusters(), and auto_cluster_findings() (facade)
Bug 1 fix (lines 429-433):
python
stale_state_ids = _current_stale_ids(state)
stale_queue_ids = sorted(
fid for fid in all_subjective_ids
if fid in stale_state_ids and fid not in unscored_state_ids
)
Bug 2 fix (lines 528-536):
python
if has_objective_items:
_objective_evict = [
fid for fid in order
if fid in under_target_ids
]
for fid in _objective_evict:
order.remove(fid)
changes += 1
Also removed duplicate stale_state_ids = _current_stale_ids(state) that was at old line 476
desloppify/engine/_work_queue/core.py — Work queue building
Bug 3 fix: Changed subjective gating from stale_review-only to blocking all non-initial subjective items when objective backlog exists
Lines 105-109:
python
# Non-initial subjective items only surface when objective
# backlog is drained — stale reruns AND under-target dims
# should wait until all mechanical work is done.
if not item.get("initial_review") and objective_count > 0:
continue
QueueBuildOptions dataclass at line 32-47 — will need policy field added
desloppify/engine/_plan/stale_dimensions.py — Subjective dimension sync and classification
desloppify/engine/_work_queue/plan_order.py — Plan ordering
apply_plan_order() (lines 23-120) — items in queue_order go FIRST, then remaining existing, then new items
collapse_clusters() (lines 184-234) — replaces cluster member items with single cluster meta-items
Errors and fixes:
test_stale_cluster_updated failed: After Bug 1 fix, the test added convention_drift to queue_order but not to state's stale dimensions. With the fix, the ID correctly wasn't recognized as stale. Fixed by providing state2 = _state_with_stale_dimensions("design_coherence", "error_consistency", "convention_drift").
next command still showed subjective items after Bug 1+2 fixes: Investigation revealed a third bug — build_work_queue() in core.py injects synthetic subjective items at query time independently of plan queue_order, and only gated stale_review items, not under-target items.
python -m desloppify used stale site-packages copy: When running from Reigh directory, Python loaded the installed v0.8.0 from ~/.pyenv/versions/3.11.11/lib/python3.11/site-packages/desloppify/ instead of local source. The installed copy had old stale_review check. Fixed with pip install -e ..
Clearing __pycache__ didn't help: Even after clearing pycache, the site-packages copy was still loaded because of Python's import path resolution (CWD not in sys.path when running from Reigh).
test_subjective_items_do_not_starve_objective_queue_head failed in TWO locations: Both tests/review/work_queue_cases.py and tests/review/integration/work_queue_cases.py had the same test. Had to update both.
Active cluster focus on subjective-high-impact was filtering the queue to only 4 items during testing — had to clear plan["active_cluster"].
Problem Solving:
Solved: Bug 1 (stale cluster membership misclassifying under-target as stale)
Solved: Bug 2 (under-target IDs persisting in queue when objective backlog returns)
Solved: Bug 3 (synthetic subjective items bypassing gating in build_work_queue)
Solved: All 3853 tests pass, Reigh next shows objective structural finding as #1
Root cause identified: Three independent systems (plan sync, auto-clustering, work queue building) each independently decide "should subjective work surface?" without sharing a policy, leading to drift and inconsistency
Currently planning: Consolidation of scattered gating into a single SubjectiveVisibility policy module
All user messages:
"Implement the following plan: # Fix: Stale subjective re-review surfaced before objective backlog drained (#186)..." [detailed plan with 3 changes]
"is that the last item in the queue? Any more data? That shouldn't be shown until the queue is empty?" [interrupted test run, provided diagnostic data showing 931 objective findings, 0 stale dimensions, but stale-review at queue #1]
"There is a still bug. You can look at the state in documents/reigh and even run next there to replicate it yourself, can you get to the bottom of it?"
"It could be that we're allowed, we moved this, like it was in the queue, and we moved it up or something like that. So that could be possible that we can look at how we reorder stuff and see if we're actually just reordering it or something."
"We shouldn't be, if we have reordered, we shouldn't be able to reorder these, these clusters or these items."
"This seems to be pointing to some kind of deeper issue maybe there's like multiple layers of indirection or there's something weird happening but this feels like a deeper issue that we need to fix"
"Look at how we do the manual reorder. It could be in that."
"Did you spot any deeper structural issues while you were working through this? Like, could you get to the actual root of why it happened?"
"Let's do that. Let's make it the whole structure. Beautiful. And let's make it be something that applies to the pre-flight and post-flight thing, because I think it's kind of like the same thing in theory is it? And try to think of related things if they're ugly as well."
Pending Tasks:
Write the final plan file at /Users/user_c042661f/.claude/plans/curious-foraging-hummingbird.md with the consolidation design
Call ExitPlanMode to get user approval
Implement the consolidation once approved:
Create desloppify/engine/_plan/subjective_policy.py with SubjectiveVisibility dataclass and compute_subjective_visibility() factory
Move NON_OBJECTIVE_DETECTORS to policy module
Add policy= parameter to sync_stale_dimensions(), auto_cluster_findings(), build_work_queue() (via QueueBuildOptions)
Wire through scan_workflow.py to compute once and pass everywhere
Current Work:
I am in plan mode, having completed Phase 1 (exploration via 3 agents) and Phase 2 (design via Plan agent). I have read critical files to verify the plan details. I need to write the final plan to the plan file and call ExitPlanMode for user approval.
The plan file is at: /Users/user_c042661f/.claude/plans/curious-foraging-hummingbird.md
The design is for a new SubjectiveVisibility frozen dataclass in desloppify/engine/_plan/subjective_policy.py that centralizes:
The objective backlog computation (currently duplicated 5+ times)
With a compute_subjective_visibility(state, target_strict=95.0) factory function computed once per operation and passed to all consumers.
Optional Next Step:
Write the final plan to /Users/user_c042661f/.claude/plans/curious-foraging-hummingbird.md and call ExitPlanMode. The user's most recent request was: "Let's do that. Let's make it the whole structure. Beautiful. And let's make it be something that applies to the pre-flight and post-flight thing, because I think it's kind of like the same thing in theory is it? And try to think of related things if they're ugly as well."