Browse documentation

How the implementation unification audit works

See how Enji Guard finds independently maintained rules that could share an implementation.

Audit page Implementation unification audit 

What this audit answers

Where would sharing an implementation make a product easier and safer to change? The audit looks for decisions maintained in more than one place. Two notification channels, for example, may need different delivery code while applying the same recipient eligibility rule.

What Enji Guard inspects

Enji Guard follows product rules, validation, transformations, and workflows through the components that implement them and the consumers that depend on them. It compares inputs, outputs, failure behavior, state, and reasons to change. Contracts, tests, and available change history can show whether the same rule is implemented independently, even across languages or providers.

The audit compares keeping the existing implementations with reusing an existing owner, extracting a shared component, or isolating real provider or protocol differences behind adapters. It checks whether the proposed owner can serve each consumer while preserving meaningful exceptions and avoiding extra dependencies.

Diagnostic criteria

The report rates applicable criteria from 0 to 5. An inapplicable criterion or one with insufficient evidence has an explanation in place of a rating.

  • Equivalent capabilities. Identify independently implemented behavior with the same purpose.
  • Common behavior and legitimate variation. Determine which decisions should change together and which channel, provider, or policy differences are intentional.
  • Shared boundary. Find a justified place to implement the common behavior.
  • Consumer reuse. Check that each consumer can use the shared behavior while keeping necessary exceptions.
  • Ownership. Check that the proposed owner fits the dependencies, state, and lifecycle of the behavior.
  • Cost of consolidation. Weigh divergence and coordinated edits against migration work and the checks needed to preserve behavior.

How evidence becomes findings

A finding shows where one established rule is maintained independently and what that costs. The cost can be inconsistent behavior, repeated coordinated edits, or a supported maintenance burden. The structured report includes a summary, findings with code references and confidence, diagnostic criteria, recommendations, scope limits, and a score when evidence supports one. A useful recommendation identifies the shared owner, the exceptions to preserve, and acceptance checks for affected consumers.

Low covers a small local cost. Medium covers a meaningful but bounded defect or duplication burden. High requires substantial loss of correctness or change safety, or broad costly divergence on important paths. Critical requires independent evidence of exceptional product harm caused by the duplicated behavior. Speculative opportunities can appear as Info.

How the score works

Enji Guard calculates scores the same way across audits. The calculation starts at 100 and deducts 25 points per Critical finding, 14 per High, 7 per Medium, and 3 per Low. Info findings deduct zero. The calculation counts each independent root cause once when the evidence supports medium or high confidence. One Critical or at least two High findings cap the result at 69. The final score stays within 0–100. Diagnostic criterion ratings do not enter the calculation.

Limitations and boundaries

The audit is read-only and uses the selected repository revision. Similar code is a lead that needs a common rule and a common reason to change. Generated or vendored copies are traced to their owned source where relevant. Missing tests, history, or a preferred design pattern are neutral on their own. Optional verification uses an isolated setup with synthetic data.

Review and rerun

Check whether a proposed shared owner reduces the number of decisions maintainers must update, then verify the consumers and exceptions that the report identifies. After a change, rerun against the new commit and check whether the independently maintained decision remains.