Documentation / Quality and governance

Measuring against N−1

How Yuli measures quality, always compares it with the previous version and makes the agent improve before testing.

On this page

Yuli measures code quality continuously and always compares it with the previous version, N−1. The rule is simple: never backwards, always forwards.

Everything is measured automatically: when you open the project, after every build, test or verification, with every new commit and in the editor as you type.

The Quality panel

Open it from the status bar indicator (for example, A · σ 4.5 ▲) or from the bottom panel.

TabWhat it's for
SummaryOverall grade, sigma, debt, clean code, the agent's latest measurement, upcoming improvements and comparison with N−1.
PracticesThe 14 clean code practices, their benefits and where to act first.
MeasurementThe agent's Measurement phase: verdict, checks, before → after and rounds.
DecisionRefactor or evolve? Criteria, matrix and economic criterion.
MaintainabilityMaintainability index, cognitive complexity, duplication, coupling and debt.
PreventionSecurity, performance, robustness and accessibility findings.
ArchitectureThe project's architecture rules.
Test healthThe state of the test suite.
QualityCyclomatic complexity, defect Pareto, coverage and tests.
SizeLines, languages, components and function points.
PerformancePer-method cost from the latest profile and REST client latency.
StatisticsProbabilities, distributions and trends.
Six SigmaDMAIC, DPMO, sigma level, FPY/RTY, Cpk and control chart.
HistorySeries for every metric and changes against N−1.
GuideEverything explained in plain words, with search.

Every section has a “?” button that explains it without jargon. “No data” is never a made-up zero: it tells you what is missing to measure.

Toolbar buttons

  • Refresh: measures again.
  • Record version: saves the measurement as the current version. The previous one becomes N−1.
  • Open report: writes docs/quality/reporte-calidad.md and opens it in the editor.

What N−1 is

Yuli keeps only two versions: the current one and the previous one. With Git, every new commit with a clean working tree is a version. A new version is also created when you click Record version and when the agent measures.

Each metric is shown with ▲ (improved), ▼ (got worse) or = (unchanged). A single worse metric is enough for the “Got worse” verdict.

The grade

The overall grade goes from A to E and combines ten ISO/IEC 25010 attributes: functionality, efficiency, reliability, robustness, security, maintainability, understandability, usability, portability and compatibility.

GradeScoreReading
A≥ 80Excellent
B≥ 65Good
C≥ 50Acceptable
D≥ 35Poor
E< 35Critical

A critical vulnerability caps security at 59 (D) and a high one at 79 (B). A serious problem never shows green.

The 14 clean code practices

Each practice is a number with its target, measured in any language.

PracticeHow it's measuredTarget
DescriptiveDescriptive names and magic numbers per KLOC≥ 95 %
Small functionsMethods of 60 lines or fewer≥ 95 %
Avoid duplicationLines in repeated blocks of 6 or more≤ 3 %
Readable codeMethods with cognitive complexity ≤ 15≥ 95 %
Error handlingRobustness findings per KLOC0
Simple structuresCyclomatic ≤ 10 and nesting ≤ 4≥ 95 %
Consistent styleIndentation, line length and naming convention≥ 90
Meaningful namesVariables that aren't noise (tmp, aux, data2)≥ 98 %
Few parametersMethods with 5 parameters or fewer100 %
Composition over inheritanceInheritance depth ≤ 3100 %
Small classes≤ 300 lines and ≤ 20 methods100 %
No dead codeCommented-out, unreachable or unused code0
Write testsFiles with logic and their own test100 %
Refactor continuouslyRegressions against N−10

The clean code score is the average of the practices that have data. 80 or more is on target.

Six Sigma and defect density

MetricWhat it is
Defect densityDefects per thousand lines (KLOC), with its 95 % confidence interval.
DPMODefects per million opportunities (each line is an opportunity).
Sigma level (σ)DPMO on the classic scale: 6σ = 3.4 DPMO; 4σ ≈ 6,210. Green from 4.5σ.
CpkCapability to keep cyclomatic complexity ≤ 10: ≥ 1.33 is capable.
FPY / RTYBuilds, tests and verifications that succeed on the first try.

A finding of medium severity or higher counts as a defect.

The agent's Measurement phase

It is the fifth of the 8 phases, between Implementation and Testing. It measures only the code the task touched against the starting version.

The three moments

PhaseWhenWhat it does
baselineBefore changing codeRecords the task's starting version (N−1).
measureAfter implementingCompares the touched code against N−1 and gives a verdict.
afterWith tests greenCompares with N−1 and rewrites the report.

When it passes

All of these checks must hold:

  1. Nothing got worse against N−1.
  2. At least one defect fixed (or none present). Density staying the same is not enough.
  3. Clean code improved in files that were below the acceptance level.
  4. New code is clean from the start.
  5. The logic has tests.

A file is accepted if it has 0 defects and a clean code score of 90 or more. An accepted file only has to not get worse.

The verdicts

VerdictWhat happens
PassedThe mission moves to Testing on its own.
IterateIt goes back to Implementation with the exact list of what to fix, with file and line.
Round limitThe rounds ran out: it moves on to Testing and anything pending stays in the mission.
No code to measureThe task didn't touch code.

Measurement can't be skipped. If the agent tries to move to Testing, Review or Delivery with unmeasured code, Yuli rejects it. The same applies to Claude Code, Kiro, Codex and Antigravity.

Improving never changes what the software does: same use cases, same inputs and outputs.

Where you see the result

Never in the chat. The agent gives a single line with the verdict and the before → after. The details are in the Measurement tab and in the mission bar, with the See in Quality button.

Settings

In the Measurement tab or in .ai/quality.json:

SettingDefaultRange
The measurement is mandatory before testingYes—
Maximum implementation ↔ measurement rounds31 to 10
Acceptance level (clean code)9050 to 100

If there is a quality contract, its acceptance and rounds values take precedence.

In the editor

  • Above each method: CC · CoG · MI · lines · coverage · cost.
  • On the first line: the file's grade, its clean code score and its change against N−1.
  • Hints: meaningless names, magic numbers or dead code, on the exact line.

The report

A single document, docs/quality/reporte-calidad.md, rewritten with every recorded version. It includes the “Agent measurement” section. Working data lives in .ai/state/quality/ and is never pushed to the repository.

Honest limits

  • Complexity and preventive rules are computed with text patterns. They can produce false positives. Java and JSP also use syntax trees.
  • Estimates (Time-to-Market, costs) use recognized models with editable assumptions. They are meant for decision-making, not as a contractual budget.