Skip to content

validation: add MustTracer for must-statement evaluation tracing - #566

Draft
steiler wants to merge 2 commits into
mainfrom
feat/must-trace
Draft

steiler wants to merge 2 commits into
mainfrom
feat/must-trace

Conversation

@steiler

@steiler steiler commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds a validation.WithMustTracer option that records every must-statement evaluation during validation: the program listing, each adapter call (Navigate, GetValue, BreadthSearch, FollowLeafRef) and the VM instruction stream, interleaved in order. This is intended for diagnosing unexpected must failures, and is wired into sdc-lite config validate --trace-must in the companion PR.

  • pkg/tree/ops/validation/must_tracer.go: MustTracer / MustEvalTracer interfaces, MustTraceMeta (path, keyless path, schema kind, owner, value, statement, error message), MustTraceOutcome / MustTraceStatus (passed, failed, compile_error, runtime_error, stack_underflow_ignored, skipped), and ValidateOption.
  • Tracer is threaded via ValidateOption into ValidateProcessorParameters. Validate's ctx is not seen by the SharedTaskPool workers, so context-based threading would not reach them.
  • Adapter events and skipped-evaluation records (disabled validator, deleted entries, inactive choice cases, trailing must statements after a compile error, swallowed Stack underflow) are emitted only when a tracer is set.
  • Navigate swallowed errors are reported with fallback: "empty_nodeset".

No behaviour change when no tracer is passed.

Cross-references

Merge order and CI

This PR uses the Tracer API that exists only in the yang-parser PR. go.mod therefore pins github.com/sdcio/yang-parser to the pseudo-version of that PR's branch commit (v0.0.13-0.20261125102718-a0faee863f27) so CI can build.

Before merging: replace the pseudo-version with the released yang-parser tag, once the yang-parser PR is merged and released.

Testing

  • go test -race ./pkg/tree/ops/validation/...
  • go test ./data-server/... (against a local go.work that points at the yang-parser branch)

Signed-off-by: Markus Vahlenkamp <markus.vahlenkamp@nokia.com>
steiler added a commit to sdcio/sdc-lite that referenced this pull request Nov 26, 2026
Pseudo-versions track sdcio/data-server#566 and sdcio/yang-parser#41 until
those changes are released; released tags lack MustTracer and xpath.Tracer.

Signed-off-by: Markus Vahlenkamp <markus.vahlenkamp@nokia.com>
Temporary pseudo-version so this branch builds against the unreleased xpath.Tracer API. Replace with the released yang-parser tag once it is cut.

Signed-off-by: Markus Vahlenkamp <markus.vahlenkamp@nokia.com>
@codecov

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.45946% with 135 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/tree/ops/validation/yang-parser-adapter.go 50.00% 83 Missing and 4 partials ⚠️
pkg/tree/ops/validation/must_tracer.go 69.33% 15 Missing and 8 partials ⚠️
pkg/tree/ops/validation/validation_entry_must.go 67.79% 17 Missing and 2 partials ⚠️
pkg/tree/ops/validation/validation_dispatch.go 63.63% 3 Missing and 1 partial ⚠️
pkg/tree/ops/validation/processor_validate.go 83.33% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant