You're viewing the readable version of this site. The interactive extras (search, diagrams, read-aloud) need JavaScript and a current browser. Enable JavaScript; if it is already enabled, update your browser.

Learn · Hidden Machines · Part VIII

budding

The Smell Is Evidence

Advisory structure recognition and a complete recovery.

static-analysis, linting, structure-recovery, developer-tools, learn

You will turn one recovery into an advisory detector, separate broad and narrow phases, and evaluate precision against confirmed, tempting, and ordinary code.

From one tangle to a signal

Mutually exclusive booleans guarded by repeated conditions suggest a sum type or machine. Increasing identifiers compared after await suggest a generation fence. Allocation sites sharing one lexical lifetime suggest a region. None of these patterns proves intent.

Detector policy — choose the honest report.

Use a cheap broad phase to find candidates and a narrow phase to reject common false positives. Report the observed evidence, candidate structure, confidence limits, and next inspection—not a verdict. A corpus needs confirmed examples, tempting false positives, and ordinary code that should produce no finding.

Run the complete recovery on an autocomplete controller: flags reveal alternatives; callbacks reveal a machine; generations define publication authority; abort handles belong to the request scope; effect requests move to an interpreter; trace tests preserve visible results. The detector can point to the shared flags and post-await comparison. Only review can decide whether the local code is worth refactoring.

Measure precision and usefulness before rule count. A noisy detector teaches teams to ignore the rare valuable finding. Keep recognition advisory until intent becomes a mechanically checkable local contract.

Where the model stops

Static syntax cannot see every owner, external guarantee, or pending deletion. Do not infer certainty from a suggestive name. Do not train on only confirmed examples. A recommendation that cannot show its evidence is a style opinion in machine clothing.

Lessons

  • Recurring syntax is evidence, not proof of architecture.
  • Broad-phase candidates need conservative rejection.
  • Findings should expose evidence and uncertainty.
  • Precision and usefulness matter more than rule count.

Practice

  1. Write a signal and false positive for generation fences.
  2. Design a narrow rejection for genuinely independent booleans.
  3. Transfer the recognizer to protocol guards or mixed coordinate frames.

One question remains: what if recognition is correct and refactoring is still the wrong decision?

References

  1. Patrick and Radhia Cousot, “Abstract Interpretation”.” — sound approximation as a foundation for static analysis.
  2. Clang-Tidy documentation, “Contributing New Checks”.” — production guidance for diagnostics, false positives, and check scope.