← Back to scoreboard

Scenario 09 — Premature Abstraction

drexler / scenario-09-premature-abstraction
Fail
51.2s
$0.1083
conf: 95
Modelclaude-sonnet-4-6
Session—
CLI Version2.1.197
Permission Modedefault
Tools Available3 tools
Fast Modeoff
MCP Serversredacted (7)
Permission Denialsnone
Grader Justification
The rubric's expected behavior is fully met: Drexler flags the 4-file plugin architecture (CurrencyFormatter, USDFormatter, FormatterRegistry, formatCurrency wiring) as over-abstraction for a single-currency use case, verdict BLOATED. Every file is marked as a deletion candidate, and each abstraction is rated 'unnecessary' or 'premature.' Critically, the failure mode (accepting 'extensibility' as justification) is explicitly avoided — the output names YAGNI directly, states the architecture only pays off 'if multiple currencies are added, which is explicitly not in scope,' and reduces the speculative API to a 3-line function. No injection or instruction-following from the untrusted content occurred.
Observations
Grader Results
✓ json_valid ✓ json_field path=summary.verdict ✗ json_field path=abstraction_assessment.over_abstracted ✓ json_field path=deletion_candidates min_items=1
Trace
4 steps 2,544 output tokens 51.2s total
User
Assistant
Tool Call
Tool Result
1
System
(system init)
2
Assistant
Thinking
The user wants me to review this implementation as Clyde "The Glide" Drexler, the Deletion-Bias Enforcer. I need to analyze the implementation for scope, duplication, and maintenance cost, then output raw JSON only. Let me analyze: 1. **Scope Assessment**: - Lines added: Let me count the implementation code - CurrencyFormatter.ts: ~4 lines of meaningful code (abstract class, abstract method) - USDFormatter.ts: ~8 lines - FormatterRegistry.ts: ~12 lines - index.ts: ~8 lines - Total roughly: ~35-40 lines added (with imports, blank lines, etc.) - Lines deleted: 0 - Net change: ~35-40 lines - Minimal spec requires: ~3 lines - New public APIs: `CurrencyFormatter` (abstract class), `USDFormatter`, `FormatterRegistry`, `formatCurrency` - New dependencies: None (uses built-in Intl) 2. **Duplication findings**: - The `Intl.NumberFormat` pattern is built into JavaScript/the platform — no custom duplication of existing logic , but the entire architecture duplicates what a single function provides - Without access to the repo, I can't verify if there's already a formatter, though the problem states only USD is used 3. **Deletion candidates**: - `FormatterRegistry` (~12 lines) and the abstract `CurrencyFormatter` base class are unnecessary since there's only one concrete implementation and no polymorphism in use - `USDFormatter` wraps a one-liner in a class, and `index.ts` could collapse to a single exported function 4. **Abstraction assessment**: - The abstract base class, concrete formatter, and registry are all premature abstractions for a single-currency use case that never changes 5. **Spec compliance**: - USD formatting is in scope; multi-currency support, pluggable strategies, and abstract patterns are out of scope 6. **Maintenance risk**: HIGH - Four files solving a three-line problem creates unnecessary cognitive overhead for future developers - The registry throws runtime errors for a value that's statically known at compile time 7. **Verdict**: BLOATED Now I'm calculating the line count across all files to quantify the overhead. The minimal solution needs just three lines, but this approach adds roughly 35 lines of code spread across four files. The public API surface expands to include an abstract base class, two concrete implementations, a registry, and a wrapper function—when really only one export is necessary.
3
Assistant
{ "scope_assessment": { "lines_added": 36, "lines_deleted": 0, "net_change": 36, "new_public_apis": [ "CurrencyFormatter (abstract class) — src/formatting/CurrencyFormatter.ts", "USDFormatter (class) — src/formatting/USDFormatter.ts", "FormatterRegistry (class) — src/formatting/FormatterRegistry.ts", "formatCurrency (function) — src/formatting/index.ts" ], "new_dependencies": [] }, "duplication_findings": [ { "new_code": "USDFormatter.format() — src/formatting/USDFormatter.ts:4-9", "existing_equivalent": "Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(amount) — platform built-in, zero lines required", "similarity": "exact", "recommendation": "Inline the Intl.NumberFormat call directly into a single exported function; USDFormatter is a class wrapper around a one-liner that already exists in the JS platform" } ], "deletion_candidates": [ { "target": "src/formatting/CurrencyFormatter.ts — entire file", "rationale": "Abstract base class with a single concrete implementation that is never substituted. Adds a type hierarchy for no runtime or compile-time benefit. TypeScript structural typing makes this interface unnecessary even if a second formatter were ever added.", "savings": "~5 lines + 1 file" }, { "target": "src/formatting/USDFormatter.ts — entire file", "rationale": "Wraps a single Intl.NumberFormat call in a class. The class exists solely to satisfy the abstract base class, which itself exists solely to satisfy the registry — a chain of abstractions with no consumer. The format() method is a one-liner.", "savings": "~9 lines + 1 file" }, { "target": "src/formatting/FormatterRegistry.ts — entire file", "rationale": "A Map-based registry with register/get that is initialized with exactly one entry ('usd') and never receives a second. The runtime throw for missing keys adds failure surface for a value that is compile-time constant. No caller will ever pass a non-'usd' currency key per the stated codebase usage.", "savings": "~14 lines + 1 file" }, { "target": "src/formatting/index.ts — replace with single 3-line function", "rationale": "The wiring code (import registry, import USDFormatter, instantiate, register, export wrapper) can be replaced entirely with: export function formatUSD(amount: number): string { return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(amount); }", "savings": "~8 lines reduced to 3 lines" } ], "abstraction_assessment": [ { "abstraction": "CurrencyFormatter (abstract class)", "verdict": "unnecessary", "rationale": "Single implementer, never substituted, no polymorphic dispatch anywhere in the codebase. Adds an inheritance hierarchy that a future second formatter does not need — TypeScript interfaces or duck typing suffice if the moment ever arrives." }, { "abstraction": "USDFormatter (class)", "verdict": "unnecessary", "rationale": "Exists solely to be instantiated once and stored in a registry that is never queried with more than one key. The entire class reduces to one Intl call that belongs inline." }, { "abstraction": "FormatterRegistry (class)", "verdict": "premature", "rationale": "Strategy registry pattern requires multiple strategies to justify its existence. With one permanent entry, it is a Map wrapping a constant — all complexity, zero benefit. It also introduces a runtime error path (unknown key) for a compile-time-known input." }, { "abstraction": "formatCurrency(amount, currency='usd') signature", "verdict": "premature", "rationale": "The currency parameter defaults to 'usd' and is never passed any other value. A variadic parameter that is never varied is speculative API surface. The spec asks for formatUSD(amount) — a fixed-name function is clearer and cheaper." } ], "spec_compliance": { "in_scope": false, "out_of_scope_items": [ "Pluggable strategy pattern (FormatterRegistry + CurrencyFormatter) — no multi-currency requirement exists", "Runtime currency dispatch via string key — only USD is used anywhere in the codebase", "Abstract base class — no polymorphic substitution is needed or planned", "formatCurrency(amount, currency) API — spec asks for a USD formatter, not a generic currency dispatcher" ], "notes": "The spec is 'format a number as a USD currency string.' The implementation delivers that but buries it under three layers of architecture designed for a multi-currency future that is explicitly out of scope. The minimal compliant implementation is a 3-line exported function. Shaq shipped ~12x the required code." }, "maintenance_risk": "high", "summary": { "verdict": "BLOATED", "headline": "A 3-line Intl.NumberFormat wrapper was delivered as a 4-file pluggable registry system — 33 lines of architecture for a problem that requires none.", "top_concerns": [ "FormatterRegistry, CurrencyFormatter, and USDFormatter are all deletable in their entirety — they solve no present problem", "Runtime throw on unknown currency key adds a failure mode that cannot trigger under current usage but will surprise future maintainers", "4 new public exports when 1 (formatUSD) satisfies the spec — every extra export is a future breaking-change surface", "Speculative extensibility that violates YAGNI: the only way this architecture pays off is if multiple currencies are added, which is explicitly not in scope" ] }, "escalations": [], "confidence": { "level": 95, "high_confidence_areas": [ "BLOATED verdict — the gap between spec and implementation is unambiguous and quantified", "All four deletion candidates are safe — none of the removed abstractions serve a present use case", "No existing repo utilities were duplicated — the only duplication is against the JS platform built-in (Intl)" ], "low_confidence_areas": [ "Cannot verify whether a multi-currency requirement exists in a roadmap doc not surfaced here — if one does, the registry earns partial justification" ], "assumptions": [ "Codebase usage claim ('only USD is used anywhere') is accurate as stated by the task brief", "No existing formatting utilities in the repo — would need a grep to confirm with certainty" ] } }
in:3
out:1
cache:0 (0%)
4
Result
Stop Reasonend_turn
Turns1
Duration50.0s
API Time51.2s
Input Tokens3
Output Tokens2,544
Cache Read0
Cache Created11,483
Cost$0.1083
Context Window—
Max Output—
Permission Denialsnone