Skip to content

fix(tools): report truncation in query_transactions; add unit tests - #3

Merged
IBJunior merged 4 commits into
mainfrom
test/tool-contracts-truncation
Aug 2, 2026
Merged

fix(tools): report truncation in query_transactions; add unit tests#3
IBJunior merged 4 commits into
mainfrom
test/tool-contracts-truncation

Conversation

@IBJunior

@IBJunior IBJunior commented Aug 2, 2026

Copy link
Copy Markdown
Member

What

query_transactions returned count: items.length while 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 + a hint, and transactionRepository.list returns { rows, total }.

Tests

Adds Vitest (unit-only, offline — no DB, model, or API key) and 66 tests:

  • pure layer: sqlGuard, csv
  • tool response payloads, repositories stubbed

The truncation test was written and observed failing before the fix.

Also

  • run_sql says how to get a complete answer when capped
  • unknown category reported as unknown, not "no transactions"
  • log_expense echoes resolved occurredAt / currency / category
  • date param examples; inspect_csv structured errors

Rationale 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

IBJunior and others added 4 commits August 2, 2026 13:22
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>
@IBJunior
IBJunior merged commit 193cc37 into main Aug 2, 2026
1 check passed
@IBJunior
IBJunior deleted the test/tool-contracts-truncation branch August 2, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant