feagi_evolutionary/genome/validators/v3.rs
1// Copyright 2025 Neuraville Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Latest-version genome validator.
5//!
6//! `V3Validator` is the **blocking** validator at `CURRENT_SCHEMA_VERSION`.
7//! Step 2 of the schema-versioning rollout lands it as a placeholder that
8//! returns a clean report. The real rules currently live in
9//! `crate::validator::validate_genome` (which operates on `RuntimeGenome`)
10//! and will be relocated here once the chain runner is wired into the
11//! loader (step 4 of the plan in `docs/GENOME_SCHEMA_VERSIONING.md`).
12//!
13//! This placeholder is intentionally a no-op: the loader still uses the
14//! existing `validate_genome`/`auto_fix_genome` path. Wiring up `V3Validator`
15//! prematurely would either double-validate (subtly different rule sets) or
16//! silently override existing behavior. Both are worse than a stub.
17
18use serde_json::Value;
19
20use super::{ValidationReport, Validator};
21use crate::genome::schema::{GenomeSchemaVersion, CURRENT_SCHEMA_VERSION};
22
23/// Validator for the latest schema version.
24///
25/// Currently a placeholder; see module docs.
26#[derive(Debug, Default, Clone, Copy)]
27pub struct V3Validator;
28
29impl V3Validator {
30 pub const fn new() -> Self {
31 Self
32 }
33}
34
35impl Validator for V3Validator {
36 fn schema_version(&self) -> GenomeSchemaVersion {
37 CURRENT_SCHEMA_VERSION
38 }
39
40 fn validate(&self, _genome: &Value) -> ValidationReport {
41 ValidationReport::new(CURRENT_SCHEMA_VERSION)
42 }
43}
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48 use serde_json::json;
49
50 #[test]
51 fn reports_current_schema_version() {
52 let v = V3Validator::new();
53 assert_eq!(v.schema_version(), CURRENT_SCHEMA_VERSION);
54 }
55
56 #[test]
57 fn placeholder_returns_clean_report() {
58 // Until step 4 plugs in the real rules, V3Validator must accept
59 // any input. This test pins that contract so a future change that
60 // adds rules is forced to update both the rules and the wiring at
61 // the same time.
62 let v = V3Validator::new();
63 let report = v.validate(&json!({ "anything": "goes" }));
64 assert!(report.is_clean());
65 assert_eq!(report.schema_version, Some(CURRENT_SCHEMA_VERSION));
66 }
67}