Documentation
Consciousness
Quality Gates

Quality Gates

Nity's quality_gates tool validates output across 7 dimensions. Every task result passes through quality gates before being accepted.

The 7 Dimensions

1. Functional Correctness

Does the output do what it's supposed to do?

CheckMethod
Tests passRun test suite, verify green
Build succeedsCompile/build without errors
Output matches intentSemantic comparison against task description

2. Determinism & Reproducibility

Can this result be reproduced?

CheckMethod
No random dependenciesScan for Math.random(), Date.now(), etc.
Seed-based behaviorVerify seeded randomness where applicable
Consistent outputSame input produces same output

3. Observability

Can you see what's happening?

CheckMethod
Logging presentVerify meaningful log statements
Error messages clearCheck error output quality
Events emittedVerify progress/status events

4. Security & Access Control

Is it safe?

CheckMethod
No hardcoded secretsScan for API keys, passwords, tokens
Input validationCheck for unvalidated user input
Dependency auditVerify no known vulnerabilities

5. Documentation & Handoff

Can someone else understand this?

CheckMethod
README updatedVerify docs reflect changes
Code commentsCheck complex sections are explained
Interface documentedVerify public API is typed/documented

6. Regression Protection

Does this break anything?

CheckMethod
Existing tests passRun full test suite, not just new tests
No breaking changesVerify API compatibility
Integration testsCheck cross-component interactions

7. Property-Based Validation

Are the invariants maintained?

CheckMethod
Type safetyVerify TypeScript strictness
Data integrityCheck state consistency
Boundary conditionsTest edge cases

Scoring

Each dimension scores 0–100. The overall quality gate result is the minimum dimension score — the weakest link determines quality.

interface QualityGateResult {
  overall: number                    // min of all dimensions
  dimensions: {
    functionalCorrectness: number
    determinism: number
    observability: number
    security: number
    documentation: number
    regressionProtection: number
    propertyBasedValidation: number
  }
  passed: boolean                    // overall >= 70
  blockers: string[]                 // dimensions below 50
  warnings: string[]                 // dimensions 50-69
}

Thresholds:

ScoreStatusAction
70–100PassAccept output
50–69WarningAccept with warning, log for review
0–49FailReject, send back to loop
⚠️

The quality gate pass threshold is 70, not 0. An output that scores 65 is not "almost passing" — it's failing. The threshold exists because low-quality outputs create technical debt that compounds over time.

Integration

Quality gates run after execution and before episode recording:

execution complete
  → quality_gates.validate(output)
  → pass → episode.record(success) → bridge.stream(result)
  → fail → loop continues (or circuit breaker opens)

The quality gate result is included in the episode recording for Ralph's effectiveness tracking — adapters that consistently produce lower quality outputs get downgraded in recommendations.