I need to understand how the subjective/holistic review prompts in this codebase present context from mechanical detector findings.
Look in desloppify/ for:
The review/holistic prompt templates - how are they constructed?
How mechanical detector findings are formatted and fed into these prompts
What kind of context gets included (findings, code snippets, file info, etc.)
The tone/language used when presenting these findings to the LLM
Be very thorough - check directories like desloppify/languages/, desloppify/engine/, desloppify/intelligence/, and any review-related modules. Look for prompt construction, template strings, and anything that formats findings for LLM consumption.
Assistant
I'll conduct a thorough search of the codebase to understand how holistic review prompts are constructed and how mechanical detector findings are presented to the LLM.
Assistant
Great! Let me start by examining the key prompt template and review-related files:
Assistant
Now let me look at more specific review context and how findings are formatted:
Assistant
Now let me examine how concerns are generated and formatted:
Assistant
Now let me look at how the LLM review is conducted - the system prompts and structure:
Assistant
Let me find the actual dimension JSON files:
Assistant
Now let me examine how this context flows into the batch prompt and look at more context:
Assistant
Now let me check the cluster detection logic that generates concern signals:
Assistant
Perfect! Now let me look at a concrete example of how the full prompt is assembled for the LLM:
Assistant
Perfect! Now let me look at the core batch runner to see how the prompt is actually used:
Assistant
Excellent! Now I have a comprehensive understanding. Let me create a detailed summary of my findings:
Summary: How Holistic Review Prompts Present Mechanical Detector Findings
Based on thorough examination of the desloppify codebase, here's a comprehensive report on how subjective/holistic review prompts construct context from mechanical detector findings:
The main batch prompt is built in /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/batch/prompt_template.py using a modular rendering system with distinct sections:
Mechanical findings are synthesized into 11+ evidence clusters organized by detector patterns:
code
- complexity_hotspots: LOC, parameters, nesting depth, monster functions, cyclomatic complexity
- error_hotspots: Files with 3+ error-handling issues grouped by severity
- mutable_globals: Module-level state mutations
- boundary_violations: Cross-architectural imports
- dead_code: Orphaned files
- private_crossings: Private symbol usage violations
- deferred_import_density: Function-level import pressure
- duplicate_clusters: Cross-file duplication patterns
- naming_drift: Directory-level naming inconsistency
- flat_dir_issues: Overloaded/fragmented directories
- signal_density: Files flagged by multiple detectors (high-signal files)
- systemic_patterns: Single smell appearing 5+ times across codebase
- security_hotspots: Files with 3+ security issues
- package_size_census: Top-level packages >15% of codebase
Tone/Language When Presenting Findings
The evidence is presented as hypotheses for the LLM to confirm or refute, not definitive statements:
python
# From prompt_template.py line 148-151
"Mechanical concern signals (detector synthesis hypotheses):",
"Treat each as a hypothesis: confirm or refute with direct code evidence."
"Is this pattern intentional or debt?" (reframe as judgment question)
"assess if extraction is warranted" (position as design choice)
Each concern includes question field: "Should this be decomposed?" vs "must be decomposed"
3. Concern Signal Construction (engine/concerns.py)
Concerns bundle mechanical signals into three types:
Per-File Concerns
Aggregates ALL mechanical issues for a file into one concern so LLM sees the full picture:
Triggering: 2+ judgment detectors OR 1 detector with elevated signals (monster functions, high params, deep nesting)
Evidence includes:
Detector names that fired
File size, max parameters, max nesting depth
Individual issue summaries (max 10)
Monster function details with function names
Example summary template (line 216-224):
python
"mixed_responsibilities": "Issues from {detector_count} detectors — may have too many responsibilities"
"duplication_design": "Duplication pattern — assess if extraction is warranted"
"structural_complexity": "Structural complexity: {monster_functions_detail}, nesting depth X, Y parameters"
Cross-File Systemic Patterns
Flags 3+ files with the same detector combination:
python
# Example from concerns.py line 511-514
"summary": "8 files share the same problem pattern (dupes, responsibility_cohesion)"
"evidence": ["Affected files: file1.py, file2.py, ...", "Shared detectors: dupes, responsibility_cohesion"]
Single Smell Patterns
Flags when one smell_id appears 5+ files:
python
# Example from concerns.py line 569-576
"summary": "'broad_except' appears in 12 files — likely a systemic pattern"
"question": "Is this a codebase-wide convention that should be addressed systemically..."
4. Batch-Level Context Presentation
Investigation Batches (prepare_batches.py)
9 thematic batches organize findings by domain:
Architecture & Coupling: god modules, import-time side effects, boundary violations, deferred imports
For each relevant dimension, the prompt guides LLM to specific evidence sources:
python
# Example from lines 54-87
"initialization_coupling": (
"For initialization_coupling, use evidence from "
"`holistic_context.scan_evidence.mutable_globals` and "
"`holistic_context.errors.mutable_globals`. Investigate initialization ordering "
"dependencies, coupling through shared mutable state, and whether state should "
"be encapsulated behind a proper registry/context manager."
)
"design_coherence": (
"use evidence from `holistic_context.scan_evidence.signal_density` — files where "
"multiple mechanical detectors fired. Investigate what design change would address "
"multiple signals simultaneously. Check `scan_evidence.complexity_hotspots` for "
"files with high responsibility cluster counts."
)
# Lines 2-10 establish the voice:
"You are a code quality reviewer. Evaluate the provided codebase for subjective quality issues..."
"Navigate the codebase as you see fit — you may focus on individual files..."
# Rule 10 (POSITIVE OBSERVATION TEST):
"Before emitting any finding, ask: 'Does this describe something that needs to change?'"
"If the answer is no, it is NOT a finding"
# Confidence calibration examples (lines ~2700+):
HIGH: "utils.py imported by 23/30 modules — god module, split by domain"
MEDIUM: "processData is vague — callers use it for invoice reconciliation"
LOW: "Function has 6 params — consider grouping related params"
Mechanical Concern Tone:
"Mechanical concern signals (detector synthesis hypotheses)" — frames as provisional
"Treat each as a hypothesis: confirm or refute with direct code evidence"
Questions not assertions: "Is this pattern intentional or debt?"
"consistent with evidence-first scoring" — anchors to code observation, not quota