Skip to content

Commit cd507ae

Browse files
Merge remote-tracking branch 'origin/master'
2 parents b5d2b95 + d7260a9 commit cd507ae

1 file changed

Lines changed: 38 additions & 15 deletions

File tree

  • plugins/codebase-audit-suite/skills/ln-624-code-maintainability-hotspot-auditor

plugins/codebase-audit-suite/skills/ln-624-code-maintainability-hotspot-auditor/SKILL.md

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: ln-624-code-maintainability-hotspot-auditor
3-
description: "Checks local maintainability hotspots: complexity, long methods, god modules, signatures, algorithms, and constants. Use when auditing code hotspots."
3+
description: "Checks local maintainability hotspots: complexity, long methods, god modules, signatures, algorithms, and constants. Also flags identifier drift across API/DTO/DB layers. Use when auditing code hotspots."
44
allowed-tools: Read, Grep, Glob, Bash, mcp__hex-graph__audit_workspace, mcp__hex-graph__analyze_architecture, mcp__hex-line__read_file, mcp__hex-line__grep_search, mcp__hex-line__outline
55
license: MIT
66
---
@@ -15,9 +15,9 @@ Specialized worker auditing local code hotspots that are hard to read, change, o
1515

1616
## Purpose & Scope
1717

18-
- Audit **code maintainability hotspots** (Categories 5+6+NEW: Medium Priority)
19-
- Check complexity metrics, method signature quality, local algorithmic efficiency, constants management
20-
- Emit `REFACTOR_HOTSPOT`, `SIMPLIFY_SIGNATURE`, or `EXTRACT_CONSTANT`
18+
- Audit **code maintainability hotspots** (priority: medium)
19+
- Check complexity metrics, method signature quality, local algorithmic efficiency, constants management, identifier consistency across layers
20+
- Emit `REFACTOR_HOTSPOT`, `SIMPLIFY_SIGNATURE`, `EXTRACT_CONSTANT`, or `UNIFY_IDENTIFIER`
2121
- Return structured findings with severity, location, effort, recommendations
2222
- Calculate compliance score (X/10) for Code Quality category
2323

@@ -30,8 +30,6 @@ Receives `contextStore` with: `tech_stack`, `best_practices`, `principles`, `cod
3030

3131
**Domain-aware:** Supports `domain_mode` + `current_domain` (see `audit_output_schema.md#domain-aware-worker-output`).
3232

33-
Use `hex-graph` first when hotspots, architecture coupling, or semantic relationships materially improve the audit. Use `hex-line` first for local code reads when available. If MCP is unavailable, unsupported, or not indexed, continue with built-in `Read/Grep/Glob/Bash` and state the fallback in the report.
34-
3533
## Workflow
3634

3735
Detection policy: use two-layer detection (candidate scan, then context verification); load `references/two_layer_detection.md` only when the verification method is ambiguous.
@@ -50,6 +48,7 @@ Detection policy: use two-layer detection (candidate scan, then context verifica
5048
- Cyclomatic complexity: is complexity from switch/case on enum (valid) or deeply nested conditions (bad)? Enum dispatch -> downgrade to LOW or skip
5149
- O(n^2): read context -- what's n? If bounded (n < 100), downgrade severity
5250
- God class: is it a config/schema/builder class? -> downgrade
51+
- Identifier drift: is the rename mediated by an explicit serializer alias (`@JsonProperty`, `alias_generator`, `@SerializedName`) or an ORM column mapping (`@Column(name=...)`)? If yes -> downgrade or skip
5352
4) **Collect findings with severity, location, effort, recommendation**
5453
- Tag each finding with `domain: domain_name` (if domain-aware)
5554
5) **Calculate score using penalty algorithm**
@@ -211,6 +210,34 @@ Detection policy: use two-layer detection (candidate scan, then context verifica
211210

212211
**Effort:** S-M (refactor signatures + callers)
213212

213+
### 9. Identifier Consistency Across Layers
214+
**What:** Same concept uses different identifiers across API contracts, DTOs, services, repositories, DB columns, or internal modules
215+
216+
**Detection:**
217+
218+
| Issue | Pattern | Example |
219+
|-------|---------|---------|
220+
| External contract drift | API/OpenAPI/external-schema field name differs from DTO/service/repo/DB column | `user_id` in OpenAPI but `uid` in DTO, `userId` in service, `user` column in DB |
221+
| Synonym drift (internal) | Same entity referenced by competing names across modules | `customer` vs `client` vs `account` vs `user` for one concept |
222+
| Unmediated casing/translation | snake/camel/kebab swap without an explicit serializer alias | `created_at` API field assigned to `creationTime` with no alias declared |
223+
| Abbreviation drift | Full and abbreviated forms coexist for one concept | `organization` vs `org` vs `orgId` vs `organizationId` |
224+
225+
**Severity:**
226+
- **HIGH:** External-contract field renamed inside code without an explicit serializer alias -- silent breakage risk when the upstream contract changes
227+
- **MEDIUM:** Synonym drift for one entity across 3+ modules (`customer` / `client` / `account`)
228+
- **MEDIUM:** Casing translation without an explicit alias mapping
229+
- **LOW:** Two-variant drift in one bounded module; abbreviation drift in internal-only code
230+
- **Downgrade when:** ORM-mediated mapping with explicit column alias, framework-required transforms (e.g. GraphQL camelCase via codegen), generated DTOs from contract, language-keyword collision forcing rename -> downgrade or skip
231+
232+
**Layer 2 requirement:** Synonym drift detection relies on a curated project glossary or on reading usage context. Grep alone is insufficient -- always confirm the two identifiers refer to the same concept before reporting.
233+
234+
**Recommendation:**
235+
- **External-contract case:** carry the external API name as-is through DTO / service / repository / DB column. If casing or language conventions conflict, configure a serializer alias once at the boundary (`@JsonProperty`, `alias_generator`, `@SerializedName`) rather than renaming the field inside the code
236+
- **Internal-only case:** pick the most semantically precise variant, apply find/replace across the modules, record the canonical term in a shared glossary or shared constants/enum module. Add a lint rule or codegen step where possible to prevent reintroduction
237+
- For verb naming within a single module, see Rule #8 (Method Signature Quality)
238+
239+
**Effort:** S-M (rename + serializer config). L when a DB column rename plus migration is required
240+
214241
## Scoring Algorithm
215242

216243
**MANDATORY READ:** Load `references/audit_scoring.md`.
@@ -221,9 +248,7 @@ Detection policy: use two-layer detection (candidate scan, then context verifica
221248

222249
Write JSON summary per `references/audit_summary_contract.md`. In managed mode the caller passes both `runId` and `summaryArtifactPath`; in standalone mode the worker generates its own run-scoped artifact path per shared contract.
223250

224-
Write report to `{output_dir}/ln-624--{domain}.md` (or `624-quality.md` in global mode) with `category: "Code Maintainability Hotspots"` and checks: cyclomatic_complexity, deep_nesting, long_methods, god_classes, too_many_params, quadratic_algorithms, magic_numbers, method_signatures.
225-
226-
Return summary per `references/audit_summary_contract.md`.
251+
Write report to `{output_dir}/ln-624--{domain}.md` (or `624-quality.md` in global mode) with `category: "Code Maintainability Hotspots"` and checks: cyclomatic_complexity, deep_nesting, long_methods, god_classes, too_many_params, quadratic_algorithms, magic_numbers, method_signatures, identifier_consistency.
227252

228253
When `summaryArtifactPath` is absent, write the standalone runtime summary under `.hex-skills/runtime-artifacts/runs/{run_id}/evaluation-worker/{worker}--{identifier}.json` and optionally echo the same summary in structured output.
229254
```
@@ -238,20 +263,18 @@ Apply the already-loaded `references/audit_worker_core_contract.md`.
238263
- **Do not auto-fix:** Report only
239264
- **Domain-aware scanning:** If `domain_mode="domain-aware"`, scan ONLY `scan_path` (not entire codebase)
240265
- **Tag findings:** Include `domain` field in each finding when domain-aware
241-
- **Context-aware:** Small functions (n < 100) with O(n^2) may be acceptable
242-
- **Constants detection:** Exclude test files, configs, examples
243266
- **Metrics tools:** Use existing tools when available (ESLint complexity plugin, radon, gocyclo)
244-
- **Unique angle:** Audit local maintainability hotspots only. Do not audit duplication, package health, architecture boundaries, N+1 persistence behavior, or orchestration ownership.
245-
- **Action required:** Every finding uses `REFACTOR_HOTSPOT`, `SIMPLIFY_SIGNATURE`, or `EXTRACT_CONSTANT`.
267+
- **Unique angle:** Audit local maintainability hotspots only. Do not audit duplication, package health, architecture boundaries, N+1 persistence behavior, or orchestration ownership. Identifier-consistency findings cover naming continuity of one concept across layers; this is distinct from ln-623 (code duplication) and ln-643 (DTO presence / layer leakage in signatures).
268+
- **Action required:** Every finding uses `REFACTOR_HOTSPOT`, `SIMPLIFY_SIGNATURE`, `EXTRACT_CONSTANT`, or `UNIFY_IDENTIFIER`.
246269

247270
## Definition of Done
248271

249272
Apply the already-loaded `references/audit_worker_core_contract.md`.
250273

251274
- [ ] contextStore parsed (including domain_mode, current_domain, output_dir)
252275
- [ ] scan_path determined (domain path or codebase root)
253-
- [ ] All 10 checks completed (scoped to scan_path):
254-
- complexity, nesting, length, god classes, parameters, O(n^2), N+1, constants, method signatures, cascade depth
276+
- [ ] All 9 checks completed (scoped to scan_path):
277+
- complexity, nesting, length, god classes, parameters, O(n^2), constants, method signatures, identifier consistency
255278
- [ ] Findings collected with severity, location, effort, recommendation, domain
256279
- [ ] Score calculated
257280
- [ ] Report written to `{output_dir}/ln-624--{domain}.md` (atomic single Write call)

0 commit comments

Comments
 (0)