Find all code related to subjective reviews in this codebase — both "batch" and "manual" review paths. I need to understand:
Where review prompts are constructed/assembled
What gets sent to the LLM for each path
How the two paths differ
Search for files related to: review, batch review, subjective review, prompts, LLM calls. Look in directories like desloppify/review/, desloppify/intelligence/, desloppify/commands/, etc.
Read the key files thoroughly — I need to see the actual prompt templates/construction and how findings get formatted into prompts. Be very thorough.
Assistant
I'll start by finding the relevant files and directories related to reviews, prompts, and LLM calls.
Assistant
Let me now look at the key files. I'll start with the command-level entry points and the prompt construction files.
Assistant
Now let me read the batch review path files and the prepare modules.
Assistant
Now let me read the holistic review flow, the dimensions/holistic data, the runner_process (LLM call), and the cmd.py entry point.
Assistant
Now let me read the dimensions data, the prepare command, the runner_packets (blind packet building), and the feedback contract.
Assistant
Now let me look at the actual dimensions JSON file and the system prompt to see what gets embedded in the packet.
Assistant
Now I have a comprehensive picture. Let me check one more thing -- the per-file review context builder, to understand the "manual" path better.
Assistant
User
I need to understand what goes into the "blind packet" for the review system. Specifically:
Read /Users/user_c042661f/Documents/desloppify/desloppify/languages/_framework/review_data/dimensions.json — this contains dimension rubrics and the system prompt
Read /Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/prepare_holistic_flow.py — how the packet is assembled, especially how the system_prompt and dimension_prompts are included
Read /Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/prepare_batches.py — how batches are constructed, what seed files they get
I want to understand: what guidance does the reviewer actually get about HOW to discover issues? Is there a methodology described, or just "here are seed files, go find stuff"?
Assistant
I'll read all three files in parallel.
Assistant
Now let me also check what the HOLISTIC_WORKFLOW constant contains — that's included in the payload and likely describes the methodology.
Assistant
User
I need a precise inventory of redundancy and information layering in the review prompt system. For each piece of guidance the reviewer sees, I need to know ALL the places it appears.
Specifically:
Read the system_prompt from /Users/user_c042661f/Documents/desloppify/desloppify/languages/_framework/review_data/dimensions.json — this is what lives in the blind packet. Find the "system_prompt" key and read its full content.
Read /Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/feedback_contract.py — the global_prompt_contract() function that gets appended to system_prompt.
Read /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/prompt_sections.py — the render_task_requirements() and all the render_* functions.
Assistant
I'll read all the specified files in parallel to build a complete inventory.
Assistant
Now let me also check how the system_prompt from dimensions.json gets assembled with the contract. Let me verify the ensure_prompt_contract usage and the HOLISTIC_WORKFLOW usage.
Assistant
Let me read the dimensions/data.py to see how the system_prompt gets combined with the contract.
Assistant
User
Assistant
I'll start by thoroughly exploring the files involved to understand the current structure and identify all the redundancies.
Assistant
Now let me read the dimensions.json system_prompt to understand what's already covered there.
Assistant
Now let me check how the system_prompt is used in the blind packet and how the batch/external paths consume it.
Assistant
Now let me look at how the batch subagent actually receives the system_prompt -- is it passed as a separate system message, or is it embedded in the blind packet JSON?
Assistant
Let me check how the blind packet is assembled and how system_prompt gets into it, and also how the batch subagent actually receives the prompt vs blind packet.
Assistant
Now let me check how the batch subagent actually receives the system_prompt from the blind packet -- is it used as an LLM system message, or is it just part of the JSON context?
Assistant
Now I have a clear picture. The subagent receives a rendered prompt file (the batch prompt) and separately has access to the blind packet JSON file on disk. The system_prompt is a field inside the blind packet JSON -- the reviewer is told to read it via "Read the blind packet and follow system_prompt constraints exactly."
Let me check for tests that reference the functions I'm planning to change.
Assistant
Let me also check for tests covering prompt_sections and batch prompt_template more broadly.
Assistant
Now I have a comprehensive understanding. Let me also quickly check the HOLISTIC_WORKFLOW reference mentioned in the requirements.
Assistant
Good. Now I have a complete picture. Let me also check what callers of ensure_prompt_contract do with its return value to understand its role.
Assistant
I now have a thorough understanding of the entire review system. Here is my analysis.
Subjective Review System: Complete Architecture
Overview
There are two distinct review paths — both ultimately produce the same output format (assessments + issues JSON) that gets imported into state via import_review_issues / import_holistic_issues. The paths differ in how the LLM gets invoked and how the prompt is constructed.
Path 1: "Batch" Review (automated, local Codex subagents)
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/cmd.py -- cmd_review() dispatches to do_run_batches()
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/batch/orchestrator.py -- do_run_batches() orchestrates the full pipeline
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/batch/execution.py -- do_run_batches() (the inner one) handles the actual execution loop
This goes to /Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/prepare.py:prepare_holistic_review() which delegates to...
/Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/prepare_holistic_flow.py:prepare_holistic_review_payload() -- the main orchestrator that:
Each batch gets seed files drawn from the HolisticContext (god modules, exception hotspots, boundary violations, etc.).
Prompt construction for each batch subagent:
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/batch/prompt_template.py:render_batch_prompt() assembles the prompt by joining sections from...
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/prompt_sections.py -- shared section renderers used by BOTH paths
The batch prompt is built from these sections (in order):
code
1. _render_metadata_block() -- "You are a focused subagent reviewer..." + repo root, packet path, batch name/dims/rationale
2. render_scoring_frame() -- "YOUR TASK: Read the code..." + "WHAT WE GIVE YOU AND WHY..."
3. render_scan_evidence_note() -- navigation aid about holistic_context.scan_evidence
4. render_seed_files_block() -- "Seed files (start here):" + file list
5. render_historical_focus() -- Previously flagged issues (if retrospective)
6. render_mechanical_concern_signals() -- Confirm/refute mechanical concerns
7. render_task_requirements() -- 13 numbered rules (issues cap, scoring requirements, scope enums, dimension-specific focus)
8. render_scope_enums() -- impact_scope/fix_scope value definitions
9. _render_output_schema() -- JSON output schema with batch/assessments/dimension_notes/issues/retrospective
LLM invocation:
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/runner_process.py:run_codex_batch() shells out to codex exec --ephemeral with the prompt text as an argument
The command is: codex exec --ephemeral -C <repo> -s workspace-write -c approval_policy="never" -c model_reasoning_effort="<effort>" -o <output_file> <prompt>
Batches run in parallel via /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/runner_parallel.py
What the LLM receives (batch path):
The blind packet (a JSON file at packet_path) -- this is the full holistic review packet with score-anchoring metadata stripped (narrative, next_command, score_snapshot, strict_target removed). It contains: holistic_context, review_context, dimension_prompts, system_prompt, investigation_batches, lang_guidance, etc.
The prompt text rendered by render_batch_prompt() (see above) -- which tells the subagent to read the blind packet and follow its system_prompt
The subagent has workspace-read access to the actual repository files
Post-processing: Results from all batches are merged via merge_batch_results() in /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/batch/core.py -- evidence-weighted assessment merging, issue deduplication, quality telemetry -- then imported into state.
Path 2: "External" / "Manual" Review (Claude cloud or human reviewer)
Entry point:desloppify review --external-start --external-runner claude
Command flow:
cmd.py:cmd_review() dispatches to do_external_start() in /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/external.py
Packet preparation:
external.py:_prepare_packet_snapshot() calls the samereview_mod.prepare_holistic_review() as the batch path (line 148)
The packet content is identical -- same holistic context, same dimensions, same investigation batches
Prompt construction:
external.py:_build_claude_launch_prompt() (line 200) constructs a single combined prompt for ALL batches (unlike the batch path which creates one prompt per batch)
It uses the same shared section renderers from prompt_sections.py:
code
1. Header -- "You are an isolated blind reviewer..." + session id/token/paths
2. render_scoring_frame() -- SAME as batch path
3. render_scan_evidence_note() -- SAME as batch path
4. [For each batch]:
- "--- Batch N: <name> ---"
- Dimensions, Rationale
- render_seed_files_block() -- SAME
- render_historical_focus() -- SAME
- render_mechanical_concern_signals() -- SAME
5. render_task_requirements() -- SAME (but issues_cap is combined across all batches)
6. render_scope_enums() -- SAME
7. Output schema -- DIFFERENT: includes session.id/token fields, no batch/batch_index, no retrospective block
8. Session requirements -- session id/token preservation + "no provenance metadata" + "JSON only"
Key difference in output schema:
The external path expects a single flat result:
external.py:do_external_submit() validates session token match, wraps the payload with canonical provenance metadata, then delegates to do_import() for state ingestion
Key Differences Summary
Aspect
Batch Path
External Path
Entry CLI flag
--run-batches
--external-start / --external-submit
Prompt granularity
One prompt per batch (9+ separate subagent calls)
One combined prompt covering all batches
LLM runner
codex exec subprocess (automated)
Manual paste into Claude (human-mediated)
Parallelism
Batches run in parallel via thread pool
Single reviewer sees everything
Output format
Per-batch JSON with batch_index, retrospective
Flat JSON with session auth tokens
Result merging
Evidence-weighted merge across batch outputs
No merge needed (single output)
Score anchoring protection
Blind packet (score metadata stripped)
Same blind packet + session token auth
Authentication
None (local subprocess)
Session id + token verification
Shared Infrastructure
Both paths share:
Packet preparation: prepare_holistic_review() builds the same data
Dimension definitions: /Users/user_c042661f/Documents/desloppify/desloppify/languages/_framework/review_data/dimensions.json -- 20 dimensions with detailed rubrics
System prompt: ~4000 words embedded in dimensions.json covering scoring philosophy, calibration anchors, output format, and rules
Prompt sections: prompt_sections.py renderers used by both batch/prompt_template.py and external.py
Feedback contract: /Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/feedback_contract.py -- thresholds (LOW_SCORE_ISSUE_THRESHOLD=85, HIGH_SCORE_ISSUES_NOTE_THRESHOLD=85) and the global review contract text appended to all system prompts via ensure_prompt_contract()
Import pipeline: Both end up at do_import() for state ingestion
Third Path: "Prepare-only" (default)
Running desloppify review with no flags calls do_prepare() in /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/prepare.py, which builds the same holistic packet and writes it to query.json -- but does NOT invoke any LLM. It just prints the investigation batches and suggests the next command (--run-batches or --external-start). This is the preparatory step for either of the two execution paths.
Here is the full picture of what guidance the reviewer gets in the "blind packet."
What the reviewer receives
The payload assembled in prepare_holistic_review_payload (line 409-431 of /Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/prepare_holistic_flow.py) has these key sections:
1. System prompt — the methodology and scoring philosophy
From /Users/user_c042661f/Documents/desloppify/desloppify/languages/_framework/review_data/dimensions.json, the system_prompt field (starts at line 384). This is a substantial document that provides:
Role framing: "You are a code quality reviewer. Evaluate the provided codebase for subjective quality issues that linters cannot catch."
Navigation freedom: "Navigate the codebase as you see fit -- you may focus on individual files, cross-cutting patterns across modules, or both. Follow the evidence where it leads."
Scoring philosophy: Scores are "holistic judgment," not formula-driven. Findings are illustrations that support a judgment, not inputs to a calculation. A few minor issues can coexist with a high score; one deep structural problem can justify a low score.
Scoring independence: Automated signals, scan evidence, and concern hypotheses are explicitly called out as "navigation aids -- starting points for where to look. They are NOT evidence, NOT confirmed issues, and NOT inputs to your judgment."
13 detailed rules covering confidence calibration, the requirement that all findings be defects (never positive observations), evidence requirements (related_files mandatory), actionable suggestions required, etc.
Calibration examples at HIGH/MEDIUM/LOW confidence with concrete instances.
NON-FINDINGS list (things to skip).
Output format spec (JSON with assessments and findings).
Global score anchors (what 100/90/80/70/60/40/20 mean in general terms).
Per-dimension anchors for all 20 dimensions (what 100/90/80/60 means for each).
Import guard: any score below 100 requires explicit feedback; below 85 requires at least one defect finding.
2. Dimension prompts — per-dimension rubrics
The dimension_prompts dict (lines 24-382 of dimensions.json) is included in the payload under the key "dimension_prompts". Each dimension has:
description: a one-liner defining the dimension.
look_for: a list of specific patterns to hunt for.
skip: a list of things explicitly marked as non-issues.
For example, abstraction_fitness tells the reviewer to look for "pass-through wrappers that add no behavior," "single-implementation interfaces," "wide options/context bag APIs," etc., while skipping "DI abstractions required for testability" and "adapters that isolate external API volatility."
3. Investigation batches — the seed files and WHY they were chosen
From /Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/prepare_batches.py, nine thematic batches are built from the HolisticContext (a pre-computed structural analysis of the codebase):
Each batch includes a why string explaining the rationale, plus a files_to_read list. An optional 10th batch adds mechanical concern signals (from engine.concerns) with per-file evidence, summary, and a question like "Is this pattern intentional or debt?"
4. The workflow instructions
From /Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/_prepare/helpers.py (line 9-19), the HOLISTIC_WORKFLOW list is included in the payload. The key instruction is step 2:
code
"For each batch: start from listed seed files, then explore likely hotspots/unreviewed neighbors;
evaluate the batch's dimensions (batches are independent — parallelize)"
5. Additional context
The payload also includes:
holistic_context: the full structural analysis (architecture, coupling, conventions, errors, abstractions, dependencies, testing, API surface, authorization, AI debt signals, migration signals, structure, scan evidence).
review_context: serialized review context (separate from holistic).
lang_guidance: language-specific review guidance.
historical_review_issues and per-batch historical_issue_focus (if issue history is enabled).
To your question: is there a discovery methodology?
Yes, but it is layered rather than prescriptive. The system does not just say "here are seed files, go find stuff." It provides:
Structural pre-analysis as navigation aids -- the HolisticContext identifies god modules, coupling hotspots, convention outliers, etc. These become seed files, but the system prompt explicitly warns the reviewer that these signals are "NOT evidence" and "NOT confirmed issues."
Per-dimension rubrics -- each dimension has a concrete look_for checklist (e.g., "identical if/else branches," "return type annotations that don't cover all code paths") and a skip list. This is the closest thing to a methodology: it tells the reviewer exactly what patterns constitute issues and what to ignore.
Exploration directive -- the workflow step says "start from listed seed files, then explore likely hotspots/unreviewed neighbors." This is an explicit instruction to go beyond the seed files.
Scoring philosophy as methodology -- the system prompt's scoring philosophy section is actually a discovery methodology in disguise. By saying "form an impression, then place it on the scale" and providing detailed anchor descriptions (what 100/90/80/60 looks like per dimension), it tells the reviewer to read broadly and holistically rather than just grep for checklist items.
What is not present is a step-by-step investigation protocol (e.g., "first read all imports, then trace call chains, then check error paths"). The reviewer gets thematic starting points and rubrics but is trusted to navigate freely. The concern signals batch is the most directed -- it provides specific per-file questions -- but even those are framed as hypotheses, not confirmed issues.
Read /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/batch/prompt_template.py — how batch prompts are assembled.
Read /Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/external.py — how the external prompt is assembled (the _build_claude_launch_prompt function).
Read /Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/_prepare/helpers.py — the HOLISTIC_WORKFLOW.
For each of these concepts, tell me EVERY location it appears in what the reviewer sees:
exploration guidance ("start from seeds, explore beyond")
Be very thorough — read every file completely.
Now I have everything. Here is the complete redundancy inventory.
Complete Redundancy Inventory: Review Prompt System
The reviewer sees a composite prompt assembled from multiple layers. Below I trace each concept across every layer where it appears. The layers are:
Layer A = system_prompt in dimensions.json (the blind packet)
Layer B = global_prompt_contract() in feedback_contract.py (appended to system_prompt via ensure_prompt_contract())
Layer C = render_task_requirements() in prompt_sections.pyLayer D = render_scoring_frame() in prompt_sections.pyLayer E = _build_claude_launch_prompt() in external.py (external path only)
Layer F = _render_output_schema() in batch/prompt_template.py (batch path only)
Layer G = HOLISTIC_WORKFLOW in _prepare/helpers.py (shipped in the packet as workflow)
Layer H = render_scan_evidence_note() in prompt_sections.pyLayer I = render_historical_focus() / render_mechanical_concern_signals() in prompt_sections.py
Assembly:
Batch path: system_prompt (A+B) lives in the blind packet JSON; the subagent prompt is D + H + seed_files + historical/mechanical (I) + C + scope_enums + F.
External path: system_prompt (A+B) lives in the blind packet JSON; the launch prompt is header + D + H + per-batch sections (seed_files + I) + C + scope_enums + output_schema + session_requirements.
Workflow (G) is embedded in the packet JSON as packet["workflow"].
1. "Navigation aid, not scoring evidence" messaging
This phrase (or its semantic equivalent) appears in five distinct locations the reviewer sees:
"SCORING INDEPENDENCE: If automated signals, scan evidence, historical issues, or mechanical concern hypotheses are provided alongside the code, treat them as navigation aids -- starting points for where to look. They are NOT evidence, NOT confirmed issues, and NOT inputs to your judgment."
D (render_scoring_frame(), line 252-258 in prompt_sections.py)
"WHAT WE GIVE YOU AND WHY: Below you will find automated scan evidence, historical issues, and mechanical concern signals. These are navigation aids -- starting points for where to look. They are NOT evidence, NOT findings, and NOT inputs to your scores."
H (render_scan_evidence_note(), line 264 in prompt_sections.py)
"Mechanical concern signals -- navigation aid, not scoring evidence:"
That is 5 occurrences: one in the blind packet system prompt (A), one in the scoring frame preamble (D), and three as section headers (H, I, I). The A and D versions are nearly verbatim duplicates of each other.
2. "Do not default to 100" / high score guidance
Location
File
Exact text
B (global_prompt_contract(), line 42-44 in feedback_contract.py)
"Do not default to 100. Reserve 100 for genuinely exemplary code with clear positive evidence; if there is uncertainty or residual issues, score below 100."
C (render_task_requirements(), line 301 in prompt_sections.py)
"11. Ignore prior chat context and any target-threshold assumptions." (related)
The core "do not default to 100" message appears twice verbatim (B and C). The anti-anchoring variants in A (rule 11) and C (item 11) add two more related statements.
"IMPORT GUARD: any assessment score below 100 must include explicit feedback for that same dimension (finding with suggestion or dimension_notes evidence). For scores below 85, include at least one defect finding for that same dimension."
B (global_prompt_contract(), lines 46-52 in feedback_contract.py)
"Scores below 85.0 MUST include at least one issue for that same dimension." and "Scores below 100.0 MUST include explicit feedback for that same dimension (issue with suggestion or dimension_notes evidence)." and "Scores above 85.0 MUST include a non-empty 'issues_preventing_higher_score' note for that dimension."
C (render_task_requirements(), lines 302-304, 309 in prompt_sections.py)
"4. Score/issue consistency is required: broader or more severe issues MUST lower dimension scores." and "4a. Any dimension scored below 85.0 MUST include explicit feedback: add at least one issue..." and "9. If a dimension score is >85.0, include 'issues_preventing_higher_score' in dimension_notes."
F (_render_output_schema(), line 57 in batch/prompt_template.py)
'"issues_preventing_higher_score": "required when score >85.0"' (in the schema definition)
The below-85-needs-issues rule appears in 3 layers (A, B, C). The below-100-needs-feedback rule appears in 2 layers (A, B+C). The issues_preventing_higher_score rule appears in 3 layers (B, C, F).
4. "Do not edit files"
Location
File
Exact text
C (render_task_requirements(), line 313 in prompt_sections.py)
Two occurrences, and the external path sees both because _build_claude_launch_prompt calls render_task_requirements (which includes item 13) AND then appends its own session_requirements with item 4. So the external reviewer sees this instruction twice in a single prompt.
6. Confidence calibration
Location
File
Exact text
A (system_prompt, rule 5 and CALIBRATION block in dimensions.json)
Rule 5: "Calibrate confidence: high = any senior eng would agree, medium = most would agree, low = reasonable engineers might disagree." Plus the full CALIBRATION examples block with HIGH/MEDIUM/LOW confidence examples.
"5. Every issue must include 'related_files' with at least 2 files when possible." and "6. Every issue must include 'dimension', 'identifier', 'summary', 'evidence', 'suggestion', and 'confidence'."
C (render_task_requirements(), line 308)
Same file
"8. Every scored dimension MUST include dimension_notes with concrete evidence."
Note the conflict: A says "at least one entry in related_files", C says "at least 2 files when possible." Two layers with slightly different thresholds.
8. Structural / root cause thinking
Location
File
Exact text
B (global_prompt_contract(), lines 53-57 in feedback_contract.py)
"Think structurally: when individual issues form a pattern, consider what is causing them. If several issues stem from a shared root cause (missing abstraction, repeated pattern, inconsistent convention), say so in the issues -- explain the deeper issue and use root_cause_cluster to connect related symptoms."
C (render_task_requirements(), lines 287-291 in prompt_sections.py)
"1c. Think structurally: when you spot multiple individual issues that share a common root cause (missing abstraction, duplicated pattern, inconsistent convention), explain the deeper structural issue in the issue, not just the surface symptom. If the pattern is significant enough, report the structural issue as its own issue with appropriate fix_scope ('multi_file_refactor' or 'architectural_change') and use 'root_cause_cluster' to connect related symptom issues together."
Two occurrences (B and C) with essentially identical content. C is an expanded restatement of B.
9. Exploration guidance ("start from seeds, explore beyond")
Location
File
Exact text
C (render_task_requirements(), lines 292-295 in prompt_sections.py)
"Navigate the codebase as you see fit -- you may focus on individual files, cross-cutting patterns across modules, or both. Follow the evidence where it leads."
Three occurrences across A, C, and G. A gives general freedom; C gives specific seed-file-first instructions; G restates the seed-file-first pattern.
Summary: Duplication Heat Map
Concept
A (sys prompt)
B (contract)
C (task reqs)
D (scoring frame)
E (external)
F (batch schema)
G (workflow)
H (scan note)
I (hist/mech)
Total
Navigation aid, not scoring evidence
X
X
X
XX
5
Do not default to 100
X
X
X
3
Score-issue consistency (85/100)
X
X
X
X
4
Do not edit files
X
X
2
JSON only, no markdown
X
X
2 (external sees both)
Confidence calibration
X
Key observations:
"Navigation aid" is the most duplicated concept -- stated 5 times across 4 different rendering functions. Layer A (system_prompt) and Layer D (render_scoring_frame) are near-verbatim duplicates.
Score-issue consistency rules appear 4 times across 3 layers (system_prompt IMPORT GUARD, global_prompt_contract, render_task_requirements) plus the batch output schema. All say the same thing with slightly different wording.
"Do not default to 100" appears 3 times across system_prompt (anti-anchoring), global_prompt_contract, and task requirements.
Structural/root-cause thinking appears identically in the global contract (B) and then as an expanded restatement in task requirements (C). Since ensure_prompt_contract() appends B to the system_prompt, and C is in the prompt body, the reviewer sees both.
The external path has a unique double-hit on "JSON only, no markdown" -- render_task_requirements (item 13) and session_requirements (item 4) both state it.
Evidence requirements have a conflicting threshold: the system_prompt says "at least one entry in related_files" while task requirements say "at least 2 files when possible."
Confidence calibration is the only concept with zero duplication -- it lives solely in the system_prompt's CALIBRATION block.
I need a plan to clean up the review prompt system in the desloppify codebase. The user's philosophy is:
Give the reviewer a high-level understanding of the dimension they're evaluating
Provide evidence/signals as starting points for investigation
Let them freely explore the codebase from there
They form their own understanding, then score and report issues based on what THEY observed
Don't be heavy-handed — the reviewer can search the codebase themselves
The current problems are:
MASSIVE REDUNDANCY — concepts are repeated across multiple layers the reviewer sees simultaneously:
"Navigation aid, not scoring evidence" appears 5 times (system_prompt in blind packet, render_scoring_frame, render_scan_evidence_note, render_historical_focus, render_mechanical_concern_signals)
"Do not default to 100" appears 3 times
Score-issue consistency rules (below 85 needs issues) appear 4 times across system_prompt IMPORT GUARD, global_prompt_contract(), render_task_requirements()
Structural/root cause thinking appears twice (global_prompt_contract and render_task_requirements)
"JSON only, no markdown" — external path sees it TWICE in one prompt
Exploration guidance appears 3 times (system_prompt, task requirements, HOLISTIC_WORKFLOW)
CONFLICTING THRESHOLDS — system_prompt says "at least one entry in related_files", task requirements says "at least 2 files when possible"
THE PROMPT IS HARD TO READ — render_task_requirements has "13" rules but actually ~30 sub-items (1, 1a, 1b, 1c, 2, 2a, 2b, 2c, 2d, 3, 3a, 3b, 4, 4a, 5-13 plus conditionally injected 9a-9j). The numbering is chaotic.
LAYERS ARE CONFUSED — The system_prompt in the blind packet and the inline prompt both contain scoring rules, exploration guidance, and output format. The reviewer must mentally merge two sources of truth. ensure_prompt_contract() appends the global_prompt_contract to system_prompt, and then render_task_requirements repeats much of the same content.
The key insight: The system_prompt in dimensions.json already contains comprehensive rules, calibration examples, dimension anchors, and scoring philosophy. Then the inline prompt (render_task_requirements etc.) RE-STATES many of those rules. And global_prompt_contract() adds yet another copy.
Here are the files involved:
/Users/user_c042661f/Documents/desloppify/desloppify/languages/_framework/review_data/dimensions.json — system_prompt field (massive, ~4000 words of scoring rules + dimension anchors)
/Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/feedback_contract.py — global_prompt_contract() and ensure_prompt_contract()
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/prompt_sections.py — render_scoring_frame(), render_scan_evidence_note(), render_historical_focus(), render_mechanical_concern_signals(), render_task_requirements(), render_scope_enums(), and various render_*_focus() functions
Make the system_prompt in dimensions.json the single source of truth for scoring philosophy, rules, calibration, and dimension anchors (it already is mostly)
Make the inline prompt (what render_batch_prompt/external builds) focused on BATCH-SPECIFIC context: which dimensions, seed files, evidence signals, output schema
Eliminate global_prompt_contract() duplication (it just restates what's already in system_prompt)
Clean up render_task_requirements to be short batch-specific instructions, not a re-statement of the system prompt rules
Fix the conflicting related_files threshold
The section headers like "navigation aid, not scoring evidence" on scan_evidence/historical/mechanical sections are fine — those are contextual labels, not repetition of scoring philosophy
But render_scoring_frame's paragraph restating the same thing IS redundant with the system_prompt
Think about what belongs where:
In the blind packet system_prompt (read once, applies globally): scoring philosophy, rules, calibration, dimension anchors, output format, what constitutes a finding
In the inline batch prompt (per-batch): role/identity, batch metadata (dimensions, rationale), seed files, historical issues, mechanical concern signals, output JSON schema for THIS batch, and a brief pointer to "follow system_prompt in the blind packet"
NOT needed at all: global_prompt_contract (redundant with system_prompt), render_scoring_frame's philosophy paragraph (redundant), render_task_requirements rules that restate system_prompt rules
Design a concrete plan for which functions to modify, what to remove, what to consolidate.
Now I have everything I need. Let me map out the redundancy precisely and design the plan.
Here is the detailed plan for cleaning up the review prompt system.
Review Prompt System Cleanup Plan
Current Architecture (What the Reviewer Sees)
The reviewer sees content from two sources simultaneously:
Blind packet JSON (read from disk) -- contains system_prompt field (~4000 words of scoring philosophy, rules, calibration examples, dimension anchors, output format, IMPORT GUARD)
Inline batch prompt (the rendered text in the prompt file) -- assembled by render_batch_prompt() or _build_claude_launch_prompt()
Additionally, ensure_prompt_contract() appends global_prompt_contract() text to the system_prompt before it goes into the blind packet. This means the blind packet's system_prompt already contains BOTH the dimensions.json system_prompt AND the global_prompt_contract text.
Redundancy Map
Here is what is stated WHERE, showing duplications:
Concept
dimensions.json system_prompt
global_prompt_contract() (appended to system_prompt)
render_scoring_frame()
render_task_requirements()
render_scan_evidence_note()
render_historical_focus()
render_mechanical_concern_signals()
"Navigation aid, not scoring evidence"
SCORING INDEPENDENCE paragraph
--
"navigation aids -- starting points"
--
"navigation aid, not scoring evidence"
"navigation aid, not scoring evidence"
"navigation aid, not scoring evidence"
"Do not default to 100"
Rule #11
bullet point
--
Rule 3b
--
--
--
Score-issue consistency (<85 needs issue)
IMPORT GUARD
global_prompt_contract bullet
--
Rule 4a
--
--
--
Score <100 needs feedback
IMPORT GUARD
global_prompt_contract bullet
--
(implied by rule 1)
--
--
--
Score >85 needs issues_preventing_higher_score
--
global_prompt_contract bullet
--
Rule 9
--
--
--
Structural/root cause thinking
--
global_prompt_contract paragraph
--
Rule 1c
--
--
--
"JSON only, no markdown"
OUTPUT FORMAT section
--
--
Rule 13
--
--
--
related_files requirement
Rule #2: "at least one entry"
--
--
Rule 5: "at least 2 files when possible"
--
--
--
Issues must be defects only
Rules #8, #9, #10
"Issues must always describe defects"
--
--
--
--
--
Exploration guidance
system_prompt paragraph 2
--
render_scoring_frame para 2
Rule 2/2a/2b
--
--
--
Dimension boundaries guidance
--
global_prompt_contract bullet
--
Rule 2c
--
--
--
"Do not suppress valid issues"
--
global_prompt_contract bullet
--
Rule 3a
--
--
--
Conflicting Thresholds
system_prompt Rule #2: "Every finding MUST include at least one entry in related_files as evidence."
render_task_requirements Rule 5: "Every issue must include related_files with at least 2 files when possible."
These conflict. The system_prompt rule is the correct one: at least one is mandatory, more is encouraged but not required. The inline prompt's "at least 2 when possible" is a softened version that still contradicts.
The Plan
Step 1: Absorb global_prompt_contract() into dimensions.json system_prompt
The global_prompt_contract() function restates rules already in the system_prompt, with a few additions that should be folded into the system_prompt directly:
Already covered in system_prompt (just remove from global_prompt_contract):
"Do not default to 100" -- Rule #11
"Do not suppress valid issues" -- covered by Rules #8, #9
"Issues must always describe defects" -- Rules #8, #9, #10
Scores below 85 need issues -- IMPORT GUARD
Additions to absorb into system_prompt (add to dimensions.json, then delete from contract):
issues_preventing_higher_score requirement for scores >85 -- add as a new rule or extend IMPORT GUARD
root_cause_cluster guidance -- add as a new rule
Dimension boundary guidance ("if an issue spans dimensions, report under most impacted") -- add as a new rule
After this, global_prompt_contract() is deleted entirely, and ensure_prompt_contract() becomes a no-op that just returns its input.
Files to change:
/Users/user_c042661f/Documents/desloppify/desloppify/languages/_framework/review_data/dimensions.json -- add the 3 missing rules to system_prompt
/Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/feedback_contract.py -- delete global_prompt_contract(), make ensure_prompt_contract() a pass-through (or delete it and update callers)
/Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/dimensions/data.py -- remove ensure_prompt_contract calls from load_dimensions() and load_dimensions_for_lang()
Step 2: Gut render_task_requirements()
Current render_task_requirements has ~30 sub-items that heavily overlap the system_prompt. After Step 1, the system_prompt is the single source of truth. The inline prompt should only contain batch-specific instructions the reviewer cannot get from the blind packet.
Replace with a short block:
code
Task requirements:
1. Read the blind packet's `system_prompt` — it contains all scoring rules, calibration, and dimension anchors.
2. Start with the seed files above, then freely explore the repository.
3. Keep issues and scoring scoped to this batch's listed dimensions.
4. Respect scope controls in the blind packet config (exclude, suppress, zone overrides).
5. Return 0-{issues_cap} high-quality issues for this batch (empty array allowed).
{render_dimension_focus(dim_set)}
6. Return ONLY valid JSON, no markdown fences.
The dimension-specific focus items (9a-9j) stay because they are batch-specific context about which evidence fields to consult. They just lose their "9a/9b" numbering and get renumbered.
What gets removed (because it restates system_prompt):
Rule 1c (structural/root cause) -- already in system_prompt via Step 1
Rules 3a, 3b (do not suppress, do not default to 100) -- system_prompt Rules #8-#12
Current render_scoring_frame() has two paragraphs:
YOUR TASK -- tells reviewer to read code and judge dimensions (useful batch-specific framing)
WHAT WE GIVE YOU AND WHY -- restates the "navigation aids, not scoring evidence" concept
Paragraph 2 is redundant with the system_prompt's SCORING INDEPENDENCE section AND with the contextual labels on each evidence section (render_historical_focus, render_mechanical_concern_signals, render_scan_evidence_note all say "navigation aid, not scoring evidence").
Change: Keep paragraph 1 (YOUR TASK), remove paragraph 2 (WHAT WE GIVE YOU AND WHY). The contextual labels on individual sections are sufficient. The system_prompt has the full philosophy.
File to change:
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/prompt_sections.py -- trim render_scoring_frame()
Step 4: Simplify render_scan_evidence_note()
Currently says:
"Mechanical scan evidence -- navigation aid, not scoring evidence: The blind packet contains holistic_context.scan_evidence with aggregated signals from all mechanical detectors..."
This is fine as-is. The "navigation aid, not scoring evidence" label is a contextual marker on this specific section, not a restatement of philosophy. The description of what scan_evidence contains is useful operational context. Keep as-is.
Step 5: Fix the related_files conflict in dimensions.json
In the system_prompt Rule #2, change "at least one entry in related_files" to be the canonical version. Since we are deleting the "at least 2 when possible" from render_task_requirements, the conflict resolves automatically. No change needed to dimensions.json here -- Rule #2 already says "at least one entry in related_files as evidence" which is correct.
Step 6: Update the output schema in _render_output_schema (batch path)
The output schema in _render_output_schema() in prompt_template.py is batch-specific (includes batch_index, batch name) and not duplicated in the system_prompt. Keep as-is.
The output schema in _build_claude_launch_prompt() in external.py is similarly session-specific. Keep as-is.
The external path in external.py calls the same shared render functions. After Steps 2-3, it automatically gets the simplified versions. However, the external path also has its own session_requirements block which includes "Return JSON only (no markdown fences)" -- this is fine because it's session-specific context (keep session.id, keep session.token).
Review what render calls it makes:
render_scoring_frame() -- simplified in Step 3
render_scan_evidence_note() -- kept as-is
render_task_requirements() -- simplified in Step 2
render_scope_enums() -- keep (short reference)
No additional changes needed beyond what Steps 2-3 provide.
Step 8: Update tests
/Users/user_c042661f/Documents/desloppify/desloppify/tests/review/import_scoring/test_review_external.py -- assertions on lines 263-265 check that render_scoring_frame() and render_scan_evidence_note() appear in the prompt. These will still pass since those functions still exist, just with trimmed content. May need to update if the test checks exact string content.
Any tests that import global_prompt_contract or ensure_prompt_contract need updating.
Step 9: Clean up feedback_contract.py exports
After removing global_prompt_contract() and simplifying ensure_prompt_contract():
Remove from __all__
The constants (LOW_SCORE_ISSUE_THRESHOLD, HIGH_SCORE_ISSUES_NOTE_THRESHOLD, etc.) stay -- they are used by the validation/normalization code, not just prompt rendering
The threshold-checking functions (score_requires_dimension_issue, score_requires_explicit_feedback) stay -- used by import validation
Resulting Prompt Structure (After Cleanup)
Blind packet system_prompt (single source of truth for review philosophy):
Scoring philosophy
Scoring independence (navigation aids concept)
All rules (including absorbed: root_cause_cluster, dimension boundaries, issues_preventing_higher_score)
Historical issues (if any, with "navigation aid" label)
Mechanical concern signals (if any, with "navigation aid" label)
Short task requirements (6 items: read system_prompt, start with seeds, scope to batch dims, respect excludes, issue cap, JSON only)
Dimension-specific focus (which evidence fields to consult for specific dims in this batch)
Scope enums reference
Output schema (batch-specific JSON shape)
Implementation Order
Add the 3 missing rules to dimensions.json system_prompt (root_cause_cluster, dimension boundaries, issues_preventing_higher_score >85)
Delete global_prompt_contract() and simplify/delete ensure_prompt_contract() in feedback_contract.py
Remove ensure_prompt_contract wrapping from data.py loaders
Rewrite render_task_requirements() to the short 6-item version
Trim render_scoring_frame() to paragraph 1 only
Update test assertions
Run test suite to verify
Critical Files for Implementation
/Users/user_c042661f/Documents/desloppify/desloppify/languages/_framework/review_data/dimensions.json - Add 3 missing rules to system_prompt field (root_cause_cluster, dimension boundaries, issues_preventing_higher_score)
/Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/feedback_contract.py - Delete global_prompt_contract(), simplify ensure_prompt_contract(), clean up all
/Users/user_c042661f/Documents/desloppify/desloppify/app/commands/review/prompt_sections.py - Rewrite render_task_requirements() and trim render_scoring_frame()
/Users/user_c042661f/Documents/desloppify/desloppify/intelligence/review/dimensions/data.py - Remove ensure_prompt_contract wrapping from both load functions
/Users/user_c042661f/Documents/desloppify/desloppify/tests/review/import_scoring/test_review_external.py - Update test assertions for changed render functions