feat: surface model mismatch on query responses#16
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in visibility signal to /wpvdb/v1/query responses when the request’s resolved embedding model differs from the site’s currently active default model, helping diagnose “empty results after migration” scenarios without changing response bodies or status codes.
Changes:
- Wraps all successful
handle_query()return paths (cache hit w/ debug, cache hit, fresh compute) to consistently attach a model-mismatch response header. - Introduces a small
add_model_mismatch_header()helper that converts payloads toWP_REST_Responseand conditionally setsX-WPVDB-Model-Mismatch.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
An explicit "model": "" resolved to an empty model, bypassing the default fallback so text queries embedded with an empty model and vector queries filtered WHERE model = ''. Normalize like the /vectors path does. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Adds an
X-WPVDB-Model-Mismatchresponse header toPOST /wpvdb/v1/query(REST::handle_query) when the request resolves to amodelthat differs from the active default model. A smalladd_model_mismatch_header()helper wraps the response at all three success return points (cache hit with debug, cache hit, and the freshly computed response), so the signal is present regardless of cache state.Background
/queryembeds the query with the requestedmodeland filters stored rows by it. After a provider/model migration, a stale client that still pins the old model gets zero results with no indication why. The contract is internally consistent, so this is intentionally a visibility signal, not a hard failure: the request still returns200with its (likely empty) results, plus the header so operators, proxies, and curious clients can spot the misconfiguration fast.The header is added at request time (not from the cached payload), so it fires correctly even on cache hits, and the response JSON shape is unchanged.
Testing
php -lclean.phpcs --standard=phpcs.xml.distintroduces zero new violations (15 errors / 18 warnings before and after, all pre-existing baseline in this file). No change to the success/error response bodies; header is additive.🤖 Generated with Claude Code