feat(validation): oneOf near-miss hints on VALIDATION_ERROR issues#468
Closed
feat(validation): oneOf near-miss hints on VALIDATION_ERROR issues#468
Conversation
Adds an optional `hint` field to `ValidationIssue` and the wire `VALIDATION_ERROR` envelope. When a `oneOf`/discriminated-union check fails, a heuristic picks the closest variant (highest required-fields- present score) and emits a hint naming the variant and discriminator. Hint text is built exclusively from schema-declared strings — variant titles, discriminator field names, and `const` values — so it never echoes user-supplied keys or values into logs or LLM contexts. Refs #460 https://claude.ai/code/session_0147Kbe9nML1irSFSxMBxtWi
Contributor
Author
|
Superseded by #476 (feat(validation): oneOf near-miss validator hints + issues[].hint on every VALIDATION_ERROR), already merged to main. |
Contributor
Author
|
Acknowledged — superseded by #476 (merged). No further action on this PR. Generated by Claude Code |
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.
Closes #460
Ports the JS SDK
e7f8e228oneOf near-miss hint feature to Python. When aoneOf/discriminated-union check fails (e.g.,pricing_options[0]submitted withtypeinstead ofpricing_model), an optionalhintfield now appears on the failing issue in theVALIDATION_ERRORenvelope, naming the closest-matching variant and its required discriminator field. Hint text is built exclusively from schema-declared strings — variant titles, discriminator field names, andconstvalues — so it never echoes user-supplied keys or values into logs or LLM contexts. Clients that ignore the field are unaffected.Changes:
src/adcp/validation/schema_validator.py: addshint: str | None = NonetoValidationIssue; adds_infer_oneof_hint()(scores each branch by required-field-presence count, extracts discriminator from requiredconstproperties, caps at 20 branches); updates_format_error()to call it; updatesSchemaValidationError.detailsserialization to includehintwhen presentsrc/adcp/validation/schema_errors.py: updatesbuild_adcp_validation_error_payloadto includehintwhen present (omits the key whenNone, consistent with all other optional fields in AdCP error objects)tests/test_schema_validation.py: 8 new tests inTestOneOfNearMissHintscovering thepricing_optionsregression class, no-hint on non-oneOf failures, hostile key-name sanitization, and wire serialization in both pathsWhat was tested:
pytest tests/test_schema_validation.py— 32 passed (24 existing + 8 new)mypy src/adcp/validation/— no errors in changed files (pre-existing errors in other modules unrelated to this change)ruff check src/adcp/validation/— all checks passedPre-PR review:
if i.hint is not Noneserialization avoids falsy-filter concern; no blockers remainadditionalProperties: trueissues array is non-breaking; omit-when-None is correct per AdCP optional-field convention; nit: a futurevalidation-issue.jsonschema type would makehintspec-visible (pre-existing gap, out of scope for this PR)Nits noted (not fixed):
validation-issue.jsonschema type to makehintdiscoverable from the spec (protocol expert nit, pre-existing schema gap)e7f8e228output exactly (protocol expert nit)_MAX_ONEOF_BRANCHES = 20cap not directly testedSession: https://claude.ai/code/session_0147Kbe9nML1irSFSxMBxtWi
Generated by Claude Code