Skip to content

Implement constraint semantic validation in validate_constraints #152

Description

@coderabbitai

Background

PR #147 (branch issue-114-remove-serde_json_value_from_core_domain_model) introduced a dedicated validate_constraints pass in crates/sempai/src/semantic_check.rs and a PendingConstraintValidation enum whose three variants carry explicit /// TODO: doc-comments marking where semantic checks must attach:

  • RegexSyntax — validate regex syntax once diagnostics can point at the normalised where-clause source span.
  • PatternCompatibility — validate pattern compatibility when matcher-language context is available.
  • UnsupportedConstraint — emit diagnostics for unknown/unsupported constraints once unknown constraints are no longer intentionally preserved.

The pass currently returns Ok(()) for all inputs; the result of pending_constraint_validation is intentionally discarded.

Work required

  1. MetavariableRegex / RegexSyntax — compile the regex string using the crate already used at execution time and emit a span-aware diagnostic when compilation fails. Span should point at the normalised where-clause location.
  2. MetavariablePattern / PatternCompatibility — validate pattern compatibility against the available matcher-language context; emit a diagnostic when the pattern is incompatible.
  3. Constraint::Other / UnsupportedConstraint — once unknown constraints are no longer intentionally preserved, emit a diagnostic for unrecognised constraint kinds.
  4. Tests — add unit tests for each rejection case (invalid regex, incompatible pattern, unsupported constraint) and update the existing validate_constraints_* tests to assert on diagnostic codes once validation is active.

Acceptance criteria

  • validate_constraints returns a Diagnostic error for a MetavariableRegex constraint whose regex string does not compile.
  • validate_constraints returns a Diagnostic error for a MetavariablePattern constraint that is incompatible with the available matcher context.
  • _pending_check / PendingConstraintValidation scaffolding is removed or replaced with real logic once all three variants are handled.
  • All existing tests continue to pass.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions