Skip to content

feat(server): add result-side tripwires for query_sql and /sql - #104

Merged
rvagg merged 2 commits into
masterfrom
rvagg/tripwires
Sep 10, 2026
Merged

rvagg merged 2 commits into
masterfrom
rvagg/tripwires

Conversation

@rvagg

@rvagg rvagg commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

adds a notices[] to the results so we can provide warnings when detecting problematic queries that an agent might need an education about

@FilOzzy FilOzzy added this to FOC Aug 25, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Aug 25, 2026
@rvagg

rvagg commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

draft for now, sitting on top of #102, I had to get this off my machine

@FilOzzy FilOzzy moved this from 📌 Triage to ⌨️ In Progress in FOC Aug 25, 2026
adds a notices[] to the results so we can provide warnings when detecting
problematic queries that an agent might need an education about
@rvagg
rvagg marked this pull request as ready for review September 10, 2026 07:29
@rvagg
rvagg changed the base branch from rvagg/porep to master September 10, 2026 07:29
@rvagg
rvagg requested a lite review from Copilot September 10, 2026 07:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 notices from both /sql and MCP query_sql when 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.

Comment thread server/src/tripwires.ts Outdated
Comment thread server/test/tripwires.test.ts
Comment thread shared/system-context.ts Outdated
@rvagg
rvagg merged commit c27dce9 into master Sep 10, 2026
3 checks passed
@rvagg
rvagg deleted the rvagg/tripwires branch September 10, 2026 07:42
@github-project-automation github-project-automation Bot moved this from ⌨️ In Progress to 🎉 Done in FOC Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

3 participants