fix(tools): report truncation in query_transactions; add unit tests - #3
Merged
Conversation
query_transactions returned `count: items.length` while the repository
capped rows at 50/200, so a partial page was indistinguishable from a
complete result. It now returns `returned` / `matched` / `truncated` plus
a hint, and `transactionRepository.list` returns `{ rows, total }`.
Adds Vitest (unit-only, offline) and 66 tests covering the pure layer
(sqlGuard, csv) and tool response payloads. The truncation test was
written failing first.
Also: run_sql truncation note, unknown-category disambiguation,
log_expense echoes resolved values, date param examples, inspect_csv
structured errors. See docs/TESTING.md.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Adds ci.yml (test + typecheck on PRs and pushes to main) and release.yml (same checks on v* tags; publishes the GitHub Release only if green). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
checkout v4->v7, setup-node v4->v7, pnpm/action-setup v4->v6. Silences the Node 20 deprecation warning on the runners. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
inspectCsv derived headers from the first record, so a valid CSV with a header row but no data reported no_columns_found — indistinguishable from "this isn't a CSV", which needs a different answer. Headers now come from Papa's meta.fields, and inspect_csv returns no_data_rows for the empty case. Also documents two load-bearing invariants: TransactionPage.total must stay exact in both branches (truncated is derived from it), and callTool's `any` return trades type safety for test ergonomics. Co-Authored-By: Claude Opus 5 <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.
What
query_transactionsreturnedcount: items.lengthwhile the repository capped rows at 50/200 — a partial page was indistinguishable from a complete result, so the agent could state a wrong total.It now returns
returned/matched/truncated+ ahint, andtransactionRepository.listreturns{ rows, total }.Tests
Adds Vitest (unit-only, offline — no DB, model, or API key) and 66 tests:
sqlGuard,csvThe truncation test was written and observed failing before the fix.
Also
run_sqlsays how to get a complete answer when cappedlog_expenseechoes resolvedoccurredAt/currency/categoryinspect_csvstructured errorsRationale in
docs/TESTING.md.Verified
pnpm test(66 pass),tsc --noEmit,pnpm build. Live-tested against a sandbox DB: agent correctly reports 262 matched rather than the 50 returned.🤖 Generated with Claude Code