feat(tools): analyze_records answers grouped questions through the data-analysis pivot #96

Merged
james.maes merged 3 commits from feat/analyze-records into develop 2026-11-11 13:34:00 +00:00
Owner

What

A new read tool, analyze_records: group a table by one or two fields (a date field optionally by year, quarter, month, week, day or hour) and compute one number per group: a count, or a sum, average, minimum, maximum or distinct count of a field, with the usual filter (relative dates included). 'How many documents were printed in the last day, by format?' becomes one tool call; the groups carry links that open their records, and the model presents them with present_results.

How it stays inside the user's access

  • It is one call of the data-analysis qbit's pivot operation (POST /qbit/data-analysis/tables/{table}/pivot, UI API extension data-analysis) through the same gateway and with the signed-in user's session as every other data tool. Table read, the table's analyze permission, field access and record locks decide exactly as on the Analyses screens; a refusal reaches the model with the same status and message (test: the UI's own request and the tool call side by side).
  • The assistant only narrows it: data access READ on the table; group-by, measure and filter fields must be fields whose values the assistant may see (a hidden field is refused as an unknown one, before any request); the policy's allowed tools and row cap hold.
  • Offered only where the data-analysis extension is registered. OPERATIONS stays core operations; the tool lives in EXTENSION_OPERATIONS. No production dependency on the data-analysis qbit (test scope only).

Tests

AnalysisToolsTest runs against the released data-analysis qbit (0.3.0-RC.2) served by the real UI API on the fixture app: counts by one field, a relative-date filter, a sum, two group-by fields with a date bucket, the same denial as the Analyses screen, the narrowing rules, and a whole turn. UiApiToolsSecurityTest.extensionToolsNeedTheirExtension pins that the tool is neither offered nor invocable without the extension.

Local: ./mvnw -B verify (whole reactor, no skip flags): BUILD SUCCESS; qbit-assistant 399 tests, 0 failures.

Note: relative dates in an analysis filter need qbit-data-analysis 0.3.0-RC.2 (QRun-IO/qbit-data-analysis#44); earlier versions answer HTTP 500 for them.

🤖 Generated with Claude Code

## What A new read tool, `analyze_records`: group a table by one or two fields (a date field optionally by year, quarter, month, week, day or hour) and compute one number per group: a count, or a sum, average, minimum, maximum or distinct count of a field, with the usual filter (relative dates included). 'How many documents were printed in the last day, by format?' becomes one tool call; the groups carry links that open their records, and the model presents them with `present_results`. ## How it stays inside the user's access - It is one call of the data-analysis qbit's pivot operation (`POST /qbit/data-analysis/tables/{table}/pivot`, UI API extension `data-analysis`) through the same gateway and with the signed-in user's session as every other data tool. Table read, the table's analyze permission, field access and record locks decide exactly as on the Analyses screens; a refusal reaches the model with the same status and message (test: the UI's own request and the tool call side by side). - The assistant only narrows it: data access READ on the table; group-by, measure and filter fields must be fields whose values the assistant may see (a hidden field is refused as an unknown one, before any request); the policy's allowed tools and row cap hold. - Offered only where the `data-analysis` extension is registered. `OPERATIONS` stays core operations; the tool lives in `EXTENSION_OPERATIONS`. No production dependency on the data-analysis qbit (test scope only). ## Tests `AnalysisToolsTest` runs against the released data-analysis qbit (0.3.0-RC.2) served by the real UI API on the fixture app: counts by one field, a relative-date filter, a sum, two group-by fields with a date bucket, the same denial as the Analyses screen, the narrowing rules, and a whole turn. `UiApiToolsSecurityTest.extensionToolsNeedTheirExtension` pins that the tool is neither offered nor invocable without the extension. Local: `./mvnw -B verify` (whole reactor, no skip flags): BUILD SUCCESS; qbit-assistant 399 tests, 0 failures. Note: relative dates in an analysis filter need qbit-data-analysis 0.3.0-RC.2 (QRun-IO/qbit-data-analysis#44); earlier versions answer HTTP 500 for them. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
james.maes added 3 commits 2026-11-11 13:27:36 +00:00
A new read tool: group a table by one or two fields (a date field optionally by a calendar
unit) and compute a count, sum, average, minimum, maximum or distinct count per group, with
the usual filter. It is one call of the data-analysis qbit's pivot operation
(POST /qbit/data-analysis/tables/{table}/pivot) through the same gateway and with the
signed-in user's session, so table read, the table's analyze permission, field access and
record locks decide as on the Analyses screens. The assistant only narrows it: data access
READ on the table, fields whose values it may see, the policy's row cap. Offered only where
the data-analysis extension is registered; no production dependency on that qbit.

Tests run against the released data-analysis qbit served by the real UI API.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
OPERATIONS stays the list of core /qqq/v1 operations (every one is invocable on any
instance); analyze_records moves to EXTENSION_OPERATIONS, offered and invocable only where
the data-analysis extension is registered. A test pins that it is neither offered nor
invocable without the extension.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
test(tools): run the analysis tests against data-analysis 0.3.0-RC.2 (relative dates in filters)
maven / build (push) Successful in 5m17s
build / maven (push) Successful in 5m17s
10d80f6bcf
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
james.maes merged commit 87bf129279 into develop 2026-11-11 13:34:00 +00:00
Sign in to join this conversation.