Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Metric Ontology

Reforge separates the quality property being discussed from the mechanism observed in source code. This prevents convenient measurements such as line count from being treated as maintainability itself and prevents correlated signals from receiving multiple votes merely because several detectors can describe them.

The ontology is scoped to maintainability signals that Reforge can observe statically. It is not a claim that source analysis completely measures maintainability.

Quality Constructs

Findings use one primary maintainability construct, aligned with ISO/IEC 25010:

ConstructQuestion answered
modularityWill a change to one component propagate into others?
reusabilityIs a concept represented once in a reusable form?
analysabilityCan a maintainer locate, understand, and diagnose the change point?
modifiabilityCan the code be changed locally without unnecessary work or regression risk?
testabilityCan maintainers establish and execute effective verification criteria?

Every finding has exactly one primary construct. A detector may provide evidence relevant to other constructs, but those secondary interpretations do not increase its score.

Signal Mechanisms

Mechanisms describe how the observed evidence may create maintenance pressure:

MechanismRepresentative evidenceCommon confounders
cognitive_loadfunction length, branching, nesting, parametersgenerated dispatch, parsers
dependency_propagationfan-in/out, cycles, imports, boundary bypassesincomplete module resolution
responsibility_dispersionoversized files/types/directories, mixed conceptsgenerated registries, declarative tables
duplication_divergencesimilar implementations, repeated shapes or setupintentional protocol symmetry
change_pressuredebt markers, compatibility paths, churnmigrations with explicit exit plans
verification_difficultymissing negative or boundary evidencetests stored outside the scan root
knowledge_driftnaming inconsistency, missing or stale documentationproject-specific conventions

Mechanisms are mutually exclusive as primary classifications. They are not assumed to be statistically independent. Correlated raw measurements remain separate evidence facets and are not added together automatically.

Goal and Measurement Layers

Reforge’s measurement goal is to prioritize reviewable, behavior-preserving refactoring opportunities from source trees and optional repository history. The model follows a goal-question-metric direction: measurements are admitted only when they answer a declared maintenance question and support a review or refactoring decision.

Reforge uses five layers:

  1. Raw metrics record observations such as LOC, complexity, fan-out, and churn.
  2. Findings interpret observations through one detector.
  3. Constructs and mechanisms explain the maintenance capability and causal pressure represented by the evidence.
  4. Issue clusters join related findings that describe the same entity and typed refactoring action.
  5. Priority ranks the resulting evidence for review; it is not a quality score or defect probability.

For example, a function that exceeds complexity and nesting thresholds retains both atomic findings for filtering, baselines, and auditability. The report also emits one cognitive_load issue cluster and human-facing output displays the highest-priority member as the primary issue.

Detector Manifest Contract

Every finding kind has an entry in the report-level detector_manifest with:

  • its primary construct and mechanism;
  • its typed refactoring action and entity_scope;
  • detection approach;
  • supported languages or repository scope;
  • qualitative precision_risk;
  • canonical input_metrics, dual reliability, impact, and actionability policy values;
  • issue_family, evidence_role, and constituent_kinds for composition.

Adding a detector requires adding its manifest entry. Tests enforce one entry per finding kind. Unsupported languages mean “not observed,” not “no issue.”

Orthogonality Rules

  • One finding has one primary construct and one primary mechanism.
  • Human-facing uniqueness is defined by refactoring action and evidence identity, not by requiring raw metrics to be statistically independent.
  • One raw observation may appear as evidence in multiple atomic findings, but issue clustering prevents it from becoming multiple human-facing issues.
  • Parent and child findings remain traceable; they are not summed.
  • Detector confidence represents interpretation uncertainty. It does not compensate for missing language coverage.
  • Threshold and percentile evidence are normalized within a finding by taking the strongest facet rather than summing correlated facets.
  • A detector cannot emit a metric outside its manifest-declared input set.
  • Metric IDs are canonical and entity-qualified, so aliases cannot make one observation appear to be independent evidence.
  • Clusters use complete-link compatibility: every member must be related to every other member. A chain of shared files cannot merge unrelated endpoint findings.
  • Findings carry stable EvidenceIds. Clustering sorts by EvidenceId before grouping, and each IssueKey is derived from the sorted member EvidenceIds, so detector emission order cannot change cluster membership or identity.

Raw Metric Contract

The report-level raw_metric_manifest defines the canonical metric ID, entity scope, unit, scale, direction, and meaning of every raw metric family. Directory observations are stored once per directory instead of being repeated on every contained file. Boolean context fields are not treated as numeric pressure. Counts remain ratio-scale observations, but their thresholds are contextual policy rather than universal quality grades.

Coverage Boundary

Completeness is relative to evidence Reforge declares observable: discovered source paths, supported parsed syntax, the resolved dependency graph, repository documentation, and optional Git history. Unsupported languages, disabled history, excluded paths, and unresolvable dependencies mean “not observed,” never “no maintenance pressure.” Detector manifest language scope and raw metric definitions make this boundary machine-readable.

Evidence surfaceCoverage stateExplicit non-coverage
Source paths and physical LOCLanguage-neutral for discovered source filesExcluded, hidden, generated, and dependency paths follow scan configuration.
Parsed functions, types, structure, and similarityRust, JavaScript, TypeScript/TSX, Python, Go, Java, C#, Kotlin, PHP, and Ruby as declared per detectorParse failures and unsupported grammars are not observations.
Unused-function analysisRust, JavaScript, TypeScript/TSX, Python, and GoDynamic and unresolved references can reduce recall.
Dependency graphRust, JavaScript, TypeScript/TSX, Python, Ruby, C, and C++Unresolved external or framework-specific edges are omitted.
Repository documentation contractReforge repository scopeThis is not a universal documentation policy for arbitrary projects.
Change historyGit history when churn is enabled and availableDisabled, unavailable, binary, out-of-root, and oversized commits are omitted.

Theoretical Basis

Validation Expectations

The ontology establishes completeness relative to declared constructs, not to all possible maintenance work. Calibration should separately test detector precision, recall on seeded and reviewed examples, ranking agreement with maintainers, language coverage, and correlations among raw metrics.