Documentation / Quality and governance

Quality contract

Quality rules live in a versioned file in the repository, not in the prompt, and apply equally to people and agents.

On this page

The quality contract is your project's .ai/contract.json file. It defines how much rigor the team requires: measurement thresholds, coverage, complexity, change size, protected paths and waivers.

It is applied by the engine gate, Git hooks, CI and agents. The result doesn't depend on who writes the code: a person, Yuli, Claude Code, Codex, Kiro or Antigravity.

If the file doesn't exist or isn't valid, Yuli uses the defaults (Business criticality). Every field is optional, so a partial contract also works.

Where to edit it

Open the Governance Center (right rail → More tools, or the command palette with Open the Governance Center) and go to the Contract tab.

When you save with Save and sign, Yuli records the change with your git config user.name. You can see every change in Contract history.

Criticality

Criticality selects a complete threshold profile. There are four levels:

Value in the fileLabel in YuliWhen to use it
lowLowPrototypes, internal tools, experiments.
businessBusinessBusiness applications. This is the default.
regulatedRegulatedSystems subject to audit or regulation.
safetySafety-criticalSoftware where a failure has serious consequences.

Profiles

ThresholdLowBusinessRegulatedSafety-critical
Acceptance score80909295
Measurement rounds2345
Minimum coverage50 %70 %80 %90 %
Max. cognitive complexity20151510
Max. cyclomatic complexity1510108
Minimum mutation score0 %0 %60 %75 %
Files per change60402515
Lines per change20001000600400
Independent reviewNoNoYesYes
Block test tamperingNoYesYesYes
Strict enforcementNoNoYesYes

You can override a specific threshold in gates. Only that field changes; the rest still comes from the profile. Block test tampering and Strict enforcement depend only on criticality and can't be overridden.

The contract's acceptance score and rounds override the local settings of the Measurement phase.

File structure

json
{
  "schemaVersion": 1,
  "criticality": "business",
  "gates": { "minCoverage": 75, "maxCyclomatic": null },
  "changeLimits": { "maxFiles": 40, "maxLines": 1000 },
  "protectedPaths": ["db/migrations/**"],
  "waivers": []
}
FieldWhat it defines
criticalitylow, business, regulated or safety.
gatesacceptanceScore, maxMeasureRounds, minCoverage, maxCognitive, maxCyclomatic, requireIndependentReview, minMutationScore. null takes the profile value.
changeLimitsmaxFiles and maxLines per change.
protectedPathsExtra globs, added to the default protected paths.
waiversWaivers with an expiry date.
architectureLayers (layers with name, paths, mayDependOn) and forbidCycles.
slosService objectives: latencyP95Ms, availability or errorRate.
licensePolicyAllowed (allow) and forbidden (deny) licenses, by SPDX or by family, such as strong-copyleft.
reviewerIndependent reviewer: requireOtherFamily, provider, model.
dataClassificationData patterns with their level: public, internal, confidential or restricted.
finopsMonthly budget per service and its owner.

Change limits

The size of a change is measured with git diff --numstat. Lock files (package-lock.json, yarn.lock, Cargo.lock, go.sum and similar) count as files, but their lines don't.

Exceeding the limit blocks with strict enforcement (Regulated and Safety-critical). In the other profiles it's a warning.

Protected paths

An agent can't edit these files, even if asked to:

  • .ai/contract.json, .ai/quality.json and .ai/state/**
  • .claude/settings.json and .claude/settings.local.json
  • .githooks/**
  • .github/workflows/**, .gitlab-ci.yml and Jenkinsfile
  • CODEOWNERS and .github/CODEOWNERS

Matching is case-insensitive. Add your own paths in protectedPaths. A change to the contract saved from Yuli is recorded in the audit log and counts as approved.

Waivers

A waiver lets you skip a rule temporarily and with justification.

FieldContents
idWaiver identifier.
ruleRule being waived: secrets, protectedPaths, testIntegrity, a specific cheating type or *.
pathGlob it applies to. Empty means any path.
reasonReason.
approvedByWho approved it.
expiresExpiry date, YYYY-MM-DD.
ticketOptional reference.

A waiver is valid through the expires date, inclusive. A missing or malformed date counts as expired. Once it expires, the rule applies again and the gate warns you.

In the interface, each waiver shows its status: Active, Expires soon, Expired or Invalid date.

testIntegrity waives every test-cheating detection at once. Use it with a narrow path and a near date.

Audit

Every save appends a line to .ai/state/contract-audit.jsonl with the date, the author, the SHA-256 hash and a summary (for example, “criticality business→regulated; waivers +1”).

The author is always a person: the name provided or your git config user.name. “Yuli” and “Yuli Code” are rejected as authors.

Next step