Explore the scorecard rendering and dimension naming in the desloppify codebase. I need to understand:
How _scorecard_draw.py renders dimensions — find the column width, layout logic, and how dimension names are displayed
How scoring.py handles dimension names — find _SHORT_NAMES, the replace("_", " ").title() logic, and how review/holistic dimensions get their display names
What review/holistic dimensions exist — find where these are defined or configured for both Python and TypeScript
How the Python review dimensions are curated/defined vs TypeScript ones
Be very thorough — read the full contents of _scorecard_draw.py, the relevant parts of scoring.py, and any review dimension configuration files.
Assistant
I'll help you explore the scorecard rendering and dimension naming in the desloppify codebase. Let me start by locating these key files and examining their contents.
Assistant
Good, I found the key files. Let me read them now to understand the scorecard rendering and dimension naming.
Assistant
Perfect! I now have all the key files. Let me search for any additional related configuration or dimension handling to complete the exploration.
Assistant
Now let me check the review/init.py to see how DEFAULT_DIMENSIONS is exported:
Assistant
Let me check the scoring.py more carefully for the _SHORT_NAMES usage and also look at how dimensions are displayed in visualize/scorecard:
Assistant
Let me check the scorecard.py file to understand the _s() function and overall setup:
Assistant
Perfect! Now let me check for any Python/TypeScript specific dimension definitions:
Assistant
Now let me check the base.py to understand phase_subjective_review:
Assistant
Let me read the phase_subjective_review function:
Assistant
User
I need to understand how review dimensions get selected/curated for display in the scorecard. Specifically:
In scoring.py, read the _append_subjective_dimensions() function fully — how does it decide which dimensions to include? Is there any filtering/curating?
In scoring.py, read compute_dimension_scores() fully — what's the full pipeline from raw data to final dimension list?
Look at how the review and subjective commands work — how are dimensions selected for assessment? Is there a budget system?
Check if there's any per-language dimension filtering or if all assessed dimensions always appear in the scorecard
Look at _show_post_scan_analysis or similar to see what drives the scorecard rendering call
Read the full files: scoring.py, review/__init__.py, and output/scorecard.py (or wherever the scorecard rendering entry point is).
Assistant
I'll help you understand the review dimensions selection and curation system. Let me start by reading the key files you mentioned.
Assistant
Let me correct that and search for the review directory contents:
Assistant
Now let me read the review module and other key files:
Assistant
Now let me read more about the scorecard rendering and check how dimensions are curated in the output:
Assistant
Now let me search for where the scorecard is called and how the dimension_scores are computed in the main flow:
Assistant
Let me read the state.py file to see where compute_dimension_scores is called:
Assistant
Perfect! Now let me read more of state.py to see the full context, and then look at scan.py to see how it all comes together:
Assistant
Great! Now let me check the review preparation to see how dimensions are selected for assessment:
Assistant
User
Assistant
I'll start by thoroughly exploring the relevant files to understand the current architecture before designing the plan.
Assistant
Let me find and read the scorecard drawing file and the test files.
Assistant
Now let me read the _scorecard_draw.py file, which is the main rendering code.
Assistant
Now let me check how prepare_holistic_review uses HOLISTIC_DIMENSIONS and what other consumers exist.
Assistant
Now let me check how import_holistic_findings validates dimension names against HOLISTIC_DIMENSIONS.
Assistant
Now let me look at how the show and plan commands render dimension names to see if there are other display name consumers.
Assistant
Good -- _SHORT_NAMES in scoring.py line 263 is the single place display names are computed. Let me check how dimension names appear in plan.py and next.py output to see if there are other formatting consumers.
Assistant
Now I can see the full picture. The dimension names that appear in dimension_scores are already the display-formatted names (from _append_subjective_dimensions), and the mechanical dimension names come from the Dimension.name field in DIMENSIONS list. Let me check one more thing -- the _show_dimension_table in status.py to see how it renders names.
Assistant
Now let me look at the review/__init__.py to understand re-exports, and check if there are other test files that assert dimension lists.
Assistant
Now let me look at what dimension names currently look like in the scorecard PNG (the actual rendered output) by checking the generate_scorecard function and how active_dims gets its names.
Assistant
I now have a thorough understanding of the codebase. Let me also check the test_review_submodules.py for any dimension-count assertions.
Assistant
Let me also check test_utils.py:285 for context.
Assistant
Good -- that len(h) == 12 is about compute_tool_hash, not dimensions. Let me also check the test at test_review.py:381.
Assistant
I now have a complete picture of the codebase. Let me now verify the font metrics assumption -- I need to understand what "120px at 11pt mono" actually fits.
Assistant
Excellent! Now I have all the information I need. Let me compile a comprehensive report of my findings.
Comprehensive Exploration Report: Scorecard Rendering and Dimension Naming
I've thoroughly explored the desloppify codebase and mapped out how scorecard rendering and dimension naming work. Here are the detailed findings:
phase_subjective_review() shared by both languages
review/__init__.py
89
Re-exports all dimension definitions and review functions
All review dimensions are shared across both Python and TypeScript — no language-specific curation exists.
Perfect! Now I have enough context. Let me create a comprehensive summary document for the user.
Summary: Review Dimensions Selection and Curation System
Based on my thorough exploration of the codebase, here's how review dimensions get selected, curated, and displayed in the scorecard:
1. _append_subjective_dimensions() in scoring.py (lines 243-288)
This function appends subjective review dimensions to the final dimension scores. Here's the full logic:
python
def _append_subjective_dimensions(
results: dict, findings: dict,
assessments: dict | None, failure_set: set,
) -> None:
"""Append subjective review dimensions to results dict (mutates results)."""
from .review import DEFAULT_DIMENSIONS
assessed = assessments or {}
existing_lower = {k.lower() for k in results}
# Build list of dimensions to include
all_dims = list(DEFAULT_DIMENSIONS) # Start with defaults
for dim_name in assessed:
if dim_name not in DEFAULT_DIMENSIONS:
all_dims.append(dim_name) # Add any assessed non-defaults
# Process each dimension
for dim_name in all_dims:
is_default = dim_name in DEFAULT_DIMENSIONS
assessment = assessed.get(dim_name)
if not is_default and not assessment:
continue # Skip non-defaults with no assessment
# ... creates dimension score entry
Key findings:
Starts with DEFAULT_DIMENSIONS from review/dimensions.py (7 dimensions: naming_quality, error_consistency, abstraction_fitness, logic_clarity, ai_generated_debt, type_safety, contract_coherence)
Adds any assessed dimensions not in the defaults (custom dimensions created by agents)
Skips non-default dimensions that have zero assessment (no score)
All included dimensions get a synthetic SUBJECTIVE_CHECKS=10 potential for scoring consistency
Score comes directly from assessment (0-100), not from findings count
2. compute_dimension_scores() in scoring.py (lines 173-233)
The full pipeline from raw data to final dimension list:
python
def compute_dimension_scores(
findings: dict,
potentials: dict[str, int],
*,
strict: bool = False,
subjective_assessments: dict | None = None,
review_assessments: dict | None = None,
) -> dict[str, dict]:
"""Returns {dimension_name: {"score": float, "checks": int, "issues": int, "detectors": dict}}
Dimensions with no active detectors (all potentials = 0 or missing) are excluded.
"""
# Phase 1: Process OBJECTIVE dimensions (from DIMENSIONS constant)
for dim in DIMENSIONS: # 5 predefined dimensions
for det in dim.detectors:
pot = potentials.get(det, 0)
if pot <= 0:
continue # Skip detectors with zero potential
# Compute pass rate from findings
# Accumulate into dimension score
if total_checks <= 0:
continue # FILTER: Skip dimensions with no active detectors
results[dim.name] = {score, tier, checks, issues, detectors}
# Phase 2: Append SUBJECTIVE dimensions (from assessments)
_append_subjective_dimensions(results, findings, subjective_assessments, failure_set)
return results
Key findings:
Objective dimensions are filtered out entirely if all their detectors have zero potential (line 218)
Subjective dimensions appear regardless of potential (they use synthetic checks)
Subjective dimensions with score=0 and issues=0 are shown in dimension_scores but filtered out of the scorecard display (see below)
This is where the critical filtering/curation happens:
python
def generate_scorecard(state: dict, output_path: str | Path) -> Path:
dim_scores = state.get("dimension_scores", {})
# CURATION: Exclude unassessed subjective dimensions
active_dims = [
(name, data) for name, data in dim_scores.items()
if data.get("checks", 0) > 0
and not (
"subjective_assessment" in data.get("detectors", {})
and data.get("score", 0) == 0
and data.get("issues", 0) == 0
)
]
# Sort: File health first, then alphabetical
active_dims.sort(key=lambda x: (0 if x[0] == "File health" else 1, x[0]))
# Layout: 2-column table, rows_per_col = (row_count + 1) // 2
# If >10 dimensions, they're all displayed (no hard cap in drawing code)
Key findings:
Filters out placeholder subjective dimensions (score=0, issues=0) — these are defaults that weren't assessed
No hard cap on dimension display (code scales to 2-column grid for any count)
Assumes scorecard will typically show ~5-10 dimensions in a reasonable 2-column layout
Previous commit message mentions "curate to 10 dims" but the actual code has no enforcement of a 10-dimension limit
5. Dimension Scoring & Budget System (scoring.py, lines 57-69)
There IS a budget system, but it's global, not per-dimension:
python
# Budget: subjective dimensions get this fraction of the overall score.
# Mechanical dimensions get the remainder.
SUBJECTIVE_WEIGHT_FRACTION = 0.25 # Subjective gets 25% of total weight
# Synthetic check count for subjective dimensions
SUBJECTIVE_CHECKS = 10 # Used only for display consistency
Key findings:
Subjective dimensions collectively get 25% of the objective score weight
No per-language filtering — all assessed dimensions are included regardless of language
Mechanical dimensions are dampened by sample size (MIN_SAMPLE=200), subjective dimensions are not
6. Full Integration Flow (state.py → scan.py)
code
state.py:159-180 (_update_objective_health)
├─ Calls compute_dimension_scores(findings, merged, subjective_assessments=...)
├─ Creates dimension_scores dict with ALL dimensions (objective + subjective)
├─ Computes objective_score via compute_objective_score(dimension_scores)
└─ Stores in state["dimension_scores"]
scan.py:200+ (_show_post_scan_analysis)
└─ Calls generate_scorecard(state, badge_path) # Uses state["dimension_scores"]
Key Architecture Insights
1. Dimension Inclusion Rules:
Objective dimensions: appear only if ANY detector has positive potential (file count > 0)
Subjective dimensions: appear if assessed (score != 0), or if it's a DEFAULT_DIMENSION (shown as placeholder with score=0)
Scorecard filters out placeholder subjective dimensions (DEFAULT but never assessed)
2. No Hard Dimension Limit:
Memory: no hardcoded cap in compute_dimension_scores() or generate_scorecard()
Scorecard rendering scales to 2-column layout for any count (rows_per_col = ⌈count/2⌉)
If user assesses 20 dimensions, all 20 appear (in 2x10 grid)
3. Budget System (Subtle):
Global, not per-dimension: subjective dimensions collectively capped at 25% of overall score
Adding more subjective dimensions redistributes weight within that 25% budget, not outside it
Mechanical dimensions use tier-weights dampened by sample size
4. Per-Language Behavior:
No per-language filtering in _append_subjective_dimensions() or scorecard rendering
Language is only used for:
Selecting files for review (zone filtering)
Providing review context and guidance
Dimension prompts are language-agnostic
Answer to Each Question
_append_subjective_dimensions() filtering: Includes DEFAULT_DIMENSIONS + any custom assessed dimensions; filters out placeholders (non-default with zero score/issues)
Full pipeline: Objective dimensions (from DIMENSIONS) → filter by potential → Subjective dimensions (from assessments) → append to results
Dimension selection for review: Defaults to 7 dimensions; can override via CLI or config; agents can assess custom dimensions beyond defaults
Per-language filtering: None — all assessed dimensions appear regardless of language
Scorecard rendering: Filters placeholder subjective dimensions; scales 2-column layout for any count (no hard cap visible in code)
Design an implementation plan for fixing GitHub issue #91 (scorecard dimension name overflow) and curating per-language holistic dimensions in the desloppify codebase.
Problem
Holistic review dimension names like "Cross Module Architecture" (25 chars) overflow the 120px scorecard column (~18 monospace chars max)
TypeScript needs curated holistic dimensions like Python has curated defaults
_SHORT_NAMES in scoring.py only has 3 entries — needs to be comprehensive and canonical
Current Architecture
review/dimensions.py:
HOLISTIC_DIMENSIONS = 12 dimensions (shared, no per-language filtering)
DEFAULT_DIMENSIONS = 7 per-file review dimensions (shared, work fine for both languages)
HOLISTIC_DIMENSION_PROMPTS and DIMENSION_PROMPTS = detailed prompt dicts per dimension
LANG_GUIDANCE = per-language review guidance (already exists, keyed by language name)
ALL dimension names must fit within scorecard column (target ≤17 chars)
Curate per-language holistic dimension lists (6-8 dims each for TS and Python)
Display name mapping should be canonical and centralized (not duplicated)
Safety net: truncate names exceeding column width in the renderer
Streamlined — single source of truth for dimension metadata
Design the approach considering:
Where should the canonical display name mapping live? (options: review/dimensions.py alongside dimension definitions, or keep in scoring.py)
How to make holistic dimensions per-language? (HOLISTIC_DIMENSIONS_BY_LANG dict? Per-language lists? Method on LangConfig?)
Which holistic dimensions are best for TypeScript/React vs Python?
How to update tests (test_holistic_review.py asserts len(HOLISTIC_DIMENSIONS) == 12)
Now I have everything I need. Let me build the complete implementation plan.
Implementation Plan: Scorecard Dimension Name Overflow and Per-Language Holistic Dimensions
Problem Summary
Three interconnected issues:
Holistic review dimension names (e.g., "Cross Module Architecture" at 25 chars) overflow the 120px scorecard column (~17-18 monospace chars at _s(120) with 11pt mono font at 2x scale).
All 12 holistic dimensions are used regardless of language -- TypeScript needs curated defaults like Python.
_SHORT_NAMES in scoring.py only maps 3 of the 19 total dimension names (12 holistic + 7 per-file).
Architecture Analysis
Display name flow:
_append_subjective_dimensions() in /Users/user_c042661f/Documents/desloppify/desloppify/scoring.py (line 263) is the single point where dim_name (snake_case) is converted to a display name via _SHORT_NAMES.get(dim_name, dim_name.replace("_", " ").title()).
This display name becomes the key in dimension_scores, which then flows to:
Scorecard PNG renderer (_scorecard_draw.py line 264: draw.text(... name ...))
Terminal dimension table (status.py line 178 and 202)
Agent-facing markdown table (scan.py line 480 and 488)
Mechanical dimensions (File health, Code quality, etc.) use Dimension.name directly, which are already short enough.
Holistic dimension flow:
HOLISTIC_DIMENSIONS list in /Users/user_c042661f/Documents/desloppify/desloppify/review/dimensions.py (line 8-14) is the master list.
prepare_holistic_review() in prepare.py (line 153): dims = dimensions or HOLISTIC_DIMENSIONS -- no language filtering.
import_holistic_findings() in import_findings.py (line 214): validates against HOLISTIC_DIMENSION_PROMPTS keys (all 12).
Dimension prompts are already language-neutral in content (they mention both Python and TS patterns).
Design Decisions
Decision 1: Where should the canonical display name mapping live?
Keep _SHORT_NAMES in scoring.py and expand it to a comprehensive DISPLAY_NAMES dict. Rationale:
scoring.py is already the single consumer and single point of display name computation (line 263).
Moving it to review/dimensions.py would create a cross-concern (review module should not own scoring display logic).
The dict should be renamed from _SHORT_NAMES to DISPLAY_NAMES (public, not private) since it is now the canonical mapping and may be useful for tests or other display consumers.
Decision 2: How to make holistic dimensions per-language?
Add HOLISTIC_DIMENSIONS_BY_LANG dict in review/dimensions.py alongside the existing HOLISTIC_DIMENSIONS (which stays as the superset). Rationale:
The prompts (HOLISTIC_DIMENSION_PROMPTS) already exist for all 12 dimensions -- they are language-neutral.
Language guidance (LANG_GUIDANCE) already exists per-language in the same file.
LangConfig should not own dimension selection -- it is a review policy decision, not a language plugin concern.
prepare_holistic_review() already receives lang -- it just needs HOLISTIC_DIMENSIONS_BY_LANG.get(lang.name, HOLISTIC_DIMENSIONS) as the fallback default.
Validation in import_holistic_findings() should continue to accept ALL 12 dimensions (a finding for a non-default dimension could come from --dimensions override).
Decision 3: Which holistic dimensions for each language?
Python (8 dimensions, dropping 4 less relevant ones):
Dropped for Python: initialization_coupling (less common in Python vs Java/TS), api_surface_coherence (more relevant to TS/React), authorization_consistency (framework-specific, only matters for Django/FastAPI), incomplete_migration (less common in Python)
TypeScript (8 dimensions, dropping 4 less relevant ones):
Dropped for TypeScript: initialization_coupling (less common with ES modules), dependency_health (npm audit covers this better), test_strategy (less critical signal for TS), package_organization (less relevant with flat src/ structures)
Implementation Steps
Step 1: Expand DISPLAY_NAMES in scoring.py
Replace _SHORT_NAMES (line 236-240) with a comprehensive public DISPLAY_NAMES dict covering all dimension names that could appear in dimension_scores. Every holistic and per-file dimension that exceeds ~17 chars needs a short name. Here is the complete mapping:
Note: dimensions whose auto-generated name is already acceptable (e.g., "Error Consistency" at 17 chars) should still be in the dict for casing correctness -- "Ai Generated Debt".title() produces wrong casing on "AI".
Step 2: Add truncation safety net in _scorecard_draw.py
In the _draw_right_panel function, after line 264 where name is drawn, add a truncation check. Before drawing, measure the text width and truncate with ellipsis if it exceeds col_name_w:
At approximately line 264 in _scorecard_draw.py:
python
# Truncate names that exceed column width
name_w = draw.textlength(name, font=font_row)
if name_w > col_name_w:
while name and draw.textlength(name + "...", font=font_row) > col_name_w:
name = name[:-1]
name = name.rstrip() + "..."
draw.text((col_name, text_y), name, fill=_TEXT, font=font_row)
This is a safety net -- with proper DISPLAY_NAMES, truncation should rarely trigger. But it prevents any future dimension additions from silently overflowing.
Step 3: Add per-language holistic dimension lists in review/dimensions.py
Keep HOLISTIC_DIMENSIONS as the full superset (it is used as validation whitelist in import_holistic_findings).
Step 4: Wire per-language defaults into prepare_holistic_review()
In /Users/user_c042661f/Documents/desloppify/desloppify/review/prepare.py, line 153:
Change from:
python
dims = dimensions or HOLISTIC_DIMENSIONS
To:
python
from .dimensions import HOLISTIC_DIMENSIONS_BY_LANG
dims = dimensions or HOLISTIC_DIMENSIONS_BY_LANG.get(lang.name, HOLISTIC_DIMENSIONS)
The import of HOLISTIC_DIMENSIONS_BY_LANG should be added at line 19 alongside the existing HOLISTIC_DIMENSIONS import.
Step 5: Update review/__init__.py exports
Add HOLISTIC_DIMENSIONS_BY_LANG to:
The import from .dimensions (line 11)
The __all__ list (line 67)
Step 6: Update tests
Six test assertions need updates:
tests/test_holistic_review.py:71 -- assert len(HOLISTIC_DIMENSIONS) == 12 -- This remains correct (superset stays at 12).
tests/test_holistic_review.py:160 -- assert len(data["dimensions"]) == 12 -- This test uses lang = _mock_lang([f1]) where lang.name = "python". After the change, Python gets 8 dims. Change to:
python
assert len(data["dimensions"]) == 8
Add new test class TestHolisticDimensionsByLang in test_holistic_review.py:
python
class TestHolisticDimensionsByLang:
def test_python_curated_count(self):
from desloppify.review import HOLISTIC_DIMENSIONS_BY_LANG
assert len(HOLISTIC_DIMENSIONS_BY_LANG["python"]) == 8
def test_typescript_curated_count(self):
from desloppify.review import HOLISTIC_DIMENSIONS_BY_LANG
assert len(HOLISTIC_DIMENSIONS_BY_LANG["typescript"]) == 8
def test_all_curated_dims_in_superset(self):
from desloppify.review import HOLISTIC_DIMENSIONS, HOLISTIC_DIMENSIONS_BY_LANG
for lang, dims in HOLISTIC_DIMENSIONS_BY_LANG.items():
for dim in dims:
assert dim in HOLISTIC_DIMENSIONS, f"{dim} not in superset"
def test_all_curated_dims_have_prompts(self):
from desloppify.review import HOLISTIC_DIMENSIONS_BY_LANG, HOLISTIC_DIMENSION_PROMPTS
for lang, dims in HOLISTIC_DIMENSIONS_BY_LANG.items():
for dim in dims:
assert dim in HOLISTIC_DIMENSION_PROMPTS, f"{dim} missing prompt"
def test_unknown_lang_falls_back_to_superset(self, tmp_path):
f1 = _make_file(str(tmp_path), "module.go", lines=50)
lang = _mock_lang([f1])
lang.name = "go"
state = _empty_state()
data = prepare_holistic_review(tmp_path, lang, state, files=[f1])
assert len(data["dimensions"]) == 12 # full superset
Step 7: Update test_review_split.py
Add HOLISTIC_DIMENSIONS_BY_LANG to the test_key_public_names import block (line 24).
Potential Challenges
State compatibility: Existing dimension_scores in persisted state files may have old display names (e.g., "Abstraction Fitness" instead of "Abstraction Fit"). The _append_subjective_dimensions function always regenerates display names from scratch on each scan, so old state keys are overwritten naturally. No migration needed.
Scorecard column width vs font metrics: The exact character limit depends on the font loaded. SFNSMono at 11pt*2=22px might fit slightly more or fewer chars than DejaVuSansMono. The truncation safety net (Step 2) handles this regardless.
CLI --dimensions override: Users can pass --dimensions cross_module_architecture,... to override defaults. The import validation in import_holistic_findings validates against HOLISTIC_DIMENSION_PROMPTS (all 12), not the per-language subset. This is correct -- overrides should work for any valid dimension.
Investigation batches: _build_investigation_batches() generates batches based on context data, not the dimension list. Dropping a dimension from the curated list means fewer dimension assessments are collected, but findings for dropped dimensions can still be imported via --dimensions override. No code change needed in batch logic.
File Change Summary
File
Change
desloppify/scoring.py
Replace _SHORT_NAMES with comprehensive DISPLAY_NAMES dict
desloppify/output/_scorecard_draw.py
Add truncation safety net before drawing dimension names
desloppify/review/dimensions.py
Add HOLISTIC_DIMENSIONS_BY_LANG dict
desloppify/review/prepare.py
Use per-language defaults in prepare_holistic_review()
Add test for display name completeness in test_scoring.py:
python
def test_display_names_fit_scorecard():
from desloppify.scoring import DISPLAY_NAMES
for dim_name, display in DISPLAY_NAMES.items():
assert len(display) <= 18, f"{dim_name} display name '{display}' is {len(display)} chars, exceeds 18"
Add test for display name coverage:
python
def test_display_names_cover_all_review_dimensions():
from desloppify.scoring import DISPLAY_NAMES
from desloppify.review import HOLISTIC_DIMENSIONS, DEFAULT_DIMENSIONS
for dim in HOLISTIC_DIMENSIONS + DEFAULT_DIMENSIONS:
assert dim in DISPLAY_NAMES, f"Missing display name for {dim}"
The test at test_review.py:381 asserts data["dimensions"] matches DEFAULT_DIMENSIONS -- this is about per-file review, not holistic, so it is unaffected.