feat(server): add result-side tripwires for query_sql and /sql - #104
Merged
Merged
Conversation
Contributor
Author
|
draft for now, sitting on top of #102, I had to get this off my machine |
adds a notices[] to the results so we can provide warnings when detecting problematic queries that an agent might need an education about
rvagg
force-pushed
the
rvagg/tripwires
branch
from
September 10, 2026 07:28
3b7be05 to
a5941c4
Compare
rvagg
marked this pull request as ready for review
September 10, 2026 07:29
There was a problem hiding this comment.
🟡 Changes recommended
The current /1e18 heuristic can emit misleading per-token warnings for legitimate non-fp queries (e.g., tx_meta gas calculations), and the system-context wording has a concrete self-contradiction.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds result-side “tripwire” notices for query_sql (MCP) and /sql (REST) responses to help surface common correctness traps in analytical SQL, especially around FilecoinPay totals and per-token decimals.
Changes:
- Introduces
sqlNotices(sql, result)heuristics to generate warning strings based on SQL text + result shape. - Returns
noticesfrom both/sqland MCPquery_sqlwhen warnings are detected. - Expands system context guidance and adds Vitest coverage for the new tripwires.
File summaries
| File | Description |
|---|---|
| shared/system-context.ts | Updates SQL guidance for FilecoinPay metrics (two-channel totals, per-token scaling). |
| server/src/tripwires.ts | Adds sqlNotices implementation that inspects SQL text/results to emit warnings. |
| server/src/routes.ts | Attaches notices to REST /sql responses. |
| server/src/mcp-handler.ts | Attaches notices to MCP query_sql tool results and updates tool description text. |
| server/test/tripwires.test.ts | Adds new Vitest suite covering the tripwire heuristics. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
adds a notices[] to the results so we can provide warnings when detecting problematic queries that an agent might need an education about