feat(testing): Add Semantic Assertion Matchers for Intent-Level Validation#1608
Open
Mustafa11300 wants to merge 4 commits intomofa-org:mainfrom
Open
feat(testing): Add Semantic Assertion Matchers for Intent-Level Validation#1608Mustafa11300 wants to merge 4 commits intomofa-org:mainfrom
Mustafa11300 wants to merge 4 commits intomofa-org:mainfrom
Conversation
Implements parameterized scenario expansion for the mofa-testing crate.
One scenario template can now expand into many concrete test cases by
substituting {{variable}} placeholders with values from parameter sets.
New components:
- ParameterSet: named variable bindings for one test variant
- ParameterMatrix: Cartesian product expansion with safety limits
- ParameterizedScenario: template + parameter sets -> expanded scenarios
- ParameterizedScenarioFile: YAML/TOML/JSON file-backed loading
Includes:
- 30+ comprehensive tests covering expansion, substitution, file
loading, execution, edge cases, and error handling
- Example scenarios in examples/parameterized_test/ with YAML, TOML,
and matrix expansion demonstrations
- README with usage guide and code samples
Closes #<ISSUE_NUMBER>
Implements golden response (snapshot) testing for the mofa-testing crate. Agent outputs are recorded as baselines, then future runs are compared against them to detect regressions automatically. New components: - GoldenSnapshot: serializable record of turn outputs (JSON/YAML) - GoldenStore: filesystem-backed snapshot persistence - GoldenTestConfig: strict (validate) vs. update (record) modes - GoldenDiff: structured per-field diff reporting - Normalizer trait + WhitespaceNormalizer, RegexNormalizer, NormalizerChain - run_golden_test: end-to-end golden test runner integrated with TestReport - compare_golden: standalone comparison engine Includes: - 30+ comprehensive tests covering serialization, store operations, diff detection, normalizers, update/strict mode, multi-turn, and tool call verification - Example golden snapshots and README in examples/golden_response_test/ - tempfile added as dev-dependency for test isolation Closes #<ISSUE_NUMBER>
…ation Implements semantic assertion matchers for the mofa-testing crate. These validate meaning and intent rather than exact text, making tests resilient to harmless wording changes while maintaining strict policy checks. New components: - SemanticMatcher trait: extensible base for all assertion types - ContainsAllFactsMatcher: validates required facts are present - ExcludesContentMatcher: validates prohibited content is absent - IntentMatcher: keyword-based intent classification (any/all modes) - SimilarityMatcher: Jaccard token-overlap with configurable threshold - RegexIntentMatcher: structural pattern validation via regex - SemanticAssertionSet: composable bundle with aggregated reporting - SemanticExpectation: YAML/JSON file-backed assertion definitions - SemanticMatchResult: per-matcher outcome with confidence score - SemanticReport: aggregated pass/fail with average confidence All matchers are deterministic and require no external API calls, making them safe for offline environments and CI pipelines. Includes: - 35+ comprehensive tests covering all matchers, assertion sets, file loading, error handling, and real-world composite scenarios - Example assertion files in examples/semantic_assertions/ - README with builder API and file-backed usage guide Closes #<ISSUE_NUMBER>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔍 Description
Adds semantic assertion matchers to the
mofa-testingcrate. These validate meaning and intent rather than exact text, making tests resilient to harmless wording changes while maintaining strict policy and safety checks.This is Issue 5 from the testing platform roadmap (Assertion Layer, Phase 3).
Closes #1605
Depends on #1599
📌 Changes
New:
tests/src/semantic.rsCore semantic assertion module with the following public components:
SemanticMatchertraitContainsAllFactsMatcherExcludesContentMatcherIntentMatcherSimilarityMatcherRegexIntentMatcherSemanticAssertionSetSemanticExpectationSemanticMatchResultSemanticReportSemanticAssertionErrorKey design decisions:
SemanticAssertionSetModified:
tests/src/lib.rspub mod semanticmodule registrationNew:
tests/tests/semantic_tests.rs35+ comprehensive tests covering:
into_matcherconversions, invalid pattern errorNew:
examples/semantic_assertions/README.mdweather_assertions.yamlsafety_assertions.yaml🧪 Testing
All new functionality is covered by
tests/tests/semantic_tests.rswith 35+ test cases.Key test categories:
💡 Usage Example
Rust Builder API
File-backed (YAML)
Policy Compliance Check
✅ Checklist
lib.rswith public re-exportssemantic_tests.rs)examples/semantic_assertions/)SemanticAssertionError