R-Think

Validation

Validation in R-Think operates at three levels: input validation, step validation, and output validation. Each level ensures data integrity and reasoning correctness before a mission transitions forward.

Validation Levels

Validation is not a single check. It is a layered system that catches errors early and provides context-rich feedback through reason codes.

  1. Input Validation — Validates observations and claims before they enter the cognitive process.
  2. Step Validation — Validates the output of each step before passing to the next.
  3. Output Validation — Validates the final decided result against the mission rules before returning to the caller.

Input Validation

Input validation ensures observations and claims meet the required schema. This prevents invalid data from propagating through the reasoning chain.

input-validation.ts typescript
import { Runtime, Protocol, Rule } from '@r-think/core';

const mission = Runtime.create({
  protocol,
  rules: [
    Rule.required('observation'),
    Rule.type('observation', 'string'),
    Rule.type('claims', 'object'),
    Rule.required('claims.id')
  ]
});

// This will fail before the protocol executes
await mission.execute({}); // RuleViolation: observation is required

Step Validation

After each step completes, the runtime validates the step output against step-specific rules. This ensures data quality is maintained throughout the cognitive chain.

Output Validation

Before the runtime returns a result, it validates the final output. This is the last line of defense against invalid reasoning results.

Mandatory Enforcement

Validation cannot be disabled for missions at L1, L2, or L3. Skipping validation is not permitted. Missions at L0 may run with minimal artifact capture, but required fields still enforce presence.