feat(mcp): validate_expression tool — validate CEL against a schema before authoring (#1928)#3203
Merged
Merged
Conversation
…efore authoring (#1928) Adds an agent-callable MCP tool that runs the same build-time expression checks as objectstack build, so an AI can validate a formula / predicate / flow condition while authoring instead of shipping one that silently evaluates to null. Given { objectName, expression, site? } it resolves the object's real schema (field names + types via the principal-bound describeObject bridge) and returns errors (bare refs, unknown fields/functions), warnings (text/boolean in arithmetic, date-equality), the fields/functions/roots in scope for self-correction, and an inferred type for formula sites. site (formula | validation | flow_condition | template, default formula) maps to the validator's role + scope. Read-only, data:read-gated, fail-closed on sys_*. mcp gains a @objectstack/formula dependency (acyclic; formula is a leaf). Tests: mcp 80 (+8 tool cases; updated the 3 tool-surface assertions + SKILL.md drift guard). Build/DTS clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hnji7EEYR2mGt6pY53a8Bm
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 9 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-zhuang
marked this pull request as ready for review
July 18, 2026 11:06
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.
What
An agent-callable
validate_expressionMCP tool — the authoring-time surface the #1928 guardrail series always pointed at. It runs the same build-time checks asobjectstack build, so an AI can validate a formula / predicate / flow condition while writing it instead of shipping one that silently evaluates tonull.Earlier PRs added the checks (tiers 1–4, #3178) and brought
registerFlowto parity (#3190). This exposes them as a tool an agent can call directly. (The originally-floatedvalidate_expressionwas scoped to the cloudservice-aipackage, which isn't in this repo; the MCP tool surface is the right in-repo home, and it reuses every primitive@objectstack/formulaalready exports.)The tool
validate_expression({ objectName, expression, site? })→ resolves the object's real schema (field names + types) via the principal-bounddescribeObjectbridge and returns:amount→record.amount), unknown fields (did-you-mean), unknown functionsformulasitesite(formula|validation|flow_condition|template, defaultformula) maps to the validator's role + scope:flow_conditionbinds fields bare, the others bindrecord.<field>.Security
Read-only (
readOnlyHint), gated by thedata:readOAuth scope, and fail-closed onsys_*objects — identical posture todescribe_object. Runs entirely through the injected principal-bound bridge; no direct engine access.@objectstack/mcpgains a@objectstack/formuladependency (acyclic — formula's only dep is@objectstack/spec).Testing
@objectstack/mcp— 80 green (+8 tool cases: sound formula + inScope/inferredType; bare-ref error; unknown-field error; tier-4 text-in-arithmetic warning; flattened flow condition; object-not-found;sys_*refusal).src/skill.ts) to include the new tool.Refs: #1928 (closed), #3178, #3190.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Hnji7EEYR2mGt6pY53a8Bm
Generated by Claude Code