Repository navigation
Description
Context
core#2148 (#2156) added `schema_named_in_query` in `packages/core/src/ops/skill_ops.rs`: when a request's query text names exactly one non-core schema by id or display name (a purely mechanical, word-boundary string match), `find_skills`' unscoped fallback scopes `schema_metadata` to just that one type instead of the previous top-5 list.
The risk, flagged in review of #2156
The old unscoped fallback was imprecise but safe-by-breadth: it always included every plausible non-core type (up to 5), so the correct type was very likely present even when the fallback couldn't narrow further.
The new mechanism can be confidently wrong instead: if a user-defined schema's id or display name happens to also be a common English word or phrase — e.g. a schema literally named `Note` — a query like "please note that the meeting moved to 3pm" would lexically match that schema and narrow `schema_metadata` to it alone, potentially excluding the type the request actually concerns. Confidently-wrong-and-narrow is a different, arguably worse, failure mode than vaguely-broad.
This is a known, accepted tradeoff for #2156 (bounded blast radius — see that PR's discussion: it only affects one prompt-assist channel's precision, not write-path validation, which still enforces the real schema server-side), not a regression that blocked merge. Filed as a deliberate follow-up rather than fixed ad hoc, since a fix requires either:
- measurement-backed guardrails (e.g. excluding common English words/stopwords from lexical matching — needs testing against real usage to avoid suppressing true positives), or
- switching to (or blending with) the embedding-based semantic search infrastructure already used for skill matching (`semantic_search_nodes` over `node_type = "schema"`, structurally available per Scope find_skills' unscoped schema_metadata fallback to a query-named type #2156's PR description but deliberately not used to keep that PR minimal and measurement-free)
Both directions need their own measurement per ADR-038/064 methodology, which is why this is a separate, unblocked-from-#2156 issue rather than scope creep on it.
What's needed
- Decide whether to add a lightweight, defensible guard (e.g. a minimum-length or common-word exclusion list) to `mentions_phrase`/`schema_named_in_query`, or move the narrowing pass to embedding-based schema search (reusing the same infra `find_skills` already uses for skill matching), or leave as-is with the tradeoff formally documented (already partially done in Scope find_skills' unscoped schema_metadata fallback to a query-named type #2156's code comments) if the practical risk is judged low enough (schema names are typically domain-specific nouns, not common verbs/phrases).
- If pursuing a guard or embedding-based approach, measure using representative dev-domain schema names/queries (per the corpus's existing golden methodology) rather than guessing at a threshold or word list.
- No behavior change is required to close this issue if the deliberate decision is "leave as documented" — but that decision should be made explicitly, not by default neglect.
Not in scope
Redesigning `find_skills`' retrieval pipeline wholesale, or building new embedding infrastructure beyond what already exists for skill/schema-type search.
Activity
mstomar125 commentedon Aug 20, 2026
Closed via #2177 (squash-merged d20ee3b). No production behavior changed — this was a measurement-then-decide issue, same shape as #2159's negative result for #2147.
What was measured
Built two corpora and ran them against the real
mentions_phrase/schema_named_in_querycode (now pinned as Rust tests inpackages/core/src/ops/skill_ops.rs, not an ad hoc script):ticket,adr,release,release_plan,venue,invoice,equipment— drawn frompackages/agent/goldens/*.toml, this module's own tests, and theVenue/Invoiceexamples in ADR-063/schema-management.md).note,meeting,idea,goal,plan,record,item,event,contact,order,review,report,request,log,entry,message,post,draft,file,link,alert,reminder,question,answer,update,change,book,recipe,habit).Both checked against a 52-query corpus (verbatim
user = "..."turns frompackages/agent/goldens/*.tomlplus a hand-built everyday-PKM-assistant corpus).Results (pinned by Rust test assertions, verified independently by the adversarial reviewer via a fresh checkout + toolchain):
Note).Decision: (a) leave as-is, formally documented
No lexical guard (length floor, stopword list) was added, because none survives the measurement: every one of the 29 risky words is also the exact word a genuine true-positive query for that same type would use (verified — a
Logschema is correctly found by "add a log for today's workout" using the identical token that falsely matches "log me out of this session"). There's no lexical signal available tomentions_phrasethat separates the two cases, so a guard would suppress true positives at the same rate as false ones — exactly the failure mode the issue warned against, now confirmed rather than assumed.The narrowing is left as-is because the failure mode is bounded even in the worst case:
with_declared_field_valuesnever setsadditionalProperties: falseonfield_values, and the tool's own description instructs the model to add any key the user supplied that the declared list doesn't cover — so a wrong narrow degrades to "no typed hint for the correct type this turn, plus some irrelevant ones," never to "the model cannot express the correct write." Write validation still enforces the real schema at the write boundary regardless of what this function returns (already documented in #2156). Outcome (c), embedding-based semantic matching, is reserved for when (a)/(b) both prove inadequate — (a) is not inadequate once the harm is bounded like this, so (c) was not pursued.The doc comment on
schema_named_in_querynow records the measured rates, corpora, and this reasoning directly, and two Rust tests pin the aggregate results as durable regression checks — a future change to the matcher has to deliberately update this record rather than silently drift from it.