# Validation Pipeline

> Foundry's validation is designed to be highly deterministic and cheap, falling back to AI only when necessary.

Source: https://bifrost5.com/foundry/docs/validation/

# Tiered Validation Pipeline

Information

See the finished result in a secure preview before you merge, not only a passing check, with Production-Grade.

[See editions](/foundry/docs/editions)

Foundry's validation is designed to be highly deterministic and cheap, falling back to AI only when necessary.

## 1. Deterministic Pre-Validation

Fast, local, non-AI checks.

- **Rules:** Strict rules including catastrophic regex guards, file/byte caps (MAX_FILES_SCANNED: 2000), semver matching, and safe extension filtering.

- **Outcome:** If HIGH confidence, the pipeline stops here and marks the task as complete.

## 2. Interrogation Phase

If deterministic checks yield MEDIUM or UNCERTAIN confidence, a cached helper AI session is invoked. It generates shell commands (`grep`, `cat`) to gather actual evidence from the disk.

## 3. AST Validation

Deep structural analysis checking for:

- Classes, Functions, Exports, Imports, Interfaces, Decorators.

## 4. Result Caching

To improve performance, validation results are cached in Redis.

- **Key:** Hash of Project ID + Criterion + File Content (SHA-256).

- If file content hasn't changed, the previous validation result is reused instantly.

## Confidence Levels

| Level | Action |
| --- | --- |
| **HIGH** | Explicit evidence found. Done. |
| **MEDIUM** | Evidence inferred. Invoke helper. |
| **UNCERTAIN** | Evidence weak. Trigger Interrogation. |
| **LOW** | Interrogation failed. Trigger Retry. |
