Skip to main content

Module validate

Module validate 

Source
Expand description

AST validation per ADR-008 §Validation Rules.

validate normalises an AST in place and rejects queries that violate the closed edge ontology or attempt to subvert namespace scoping:

  1. Edge relations must parse to one of the 13 canonical EdgeRelation variants (ADR-002). Aliases and case differences are normalised to the canonical snake_case form stored in the database. Applies to edge patterns and WHERE e.relation = '…' constraints.
  2. Node kinds pass through unchanged — the query layer is pack-agnostic (ADR-025). Kind validation is the responsibility of the service boundary, not the query compiler.
  3. Namespace scoping is a trusted parameter only. Queries must not name namespace in node property maps or WHERE conditions — the only valid source of namespace filtering is CompileOptions::scopes. This matches ADR-008 §Validation: “never trust query strings to set namespaces.”
  4. Traversal depth is capped at MAX_DEPTH (10 hops). Requests above the cap are clamped, not rejected — this matches the cap the compiler applies when generating recursive CTEs.

Constants§

MAX_DEPTH
Maximum traversal depth allowed by the query layer (ADR-008 §Validation).

Functions§

validate
Validate and normalise an AST in place.
validate_with_warnings
Validate and normalise an AST in place, returning any warnings generated.