Repository navigation
get_events: filter rows by column value and project columns - #1501
Merged
Merged
Conversation
Adds the where and columns inputs and the columns_summary output to the wire contract and its zod 4 mirror (#1500). A returned row may now omit store_path and group_name when columns projects them away; onset_s and sample_index stay required. Tested: bun test backend/test/mcp-schema-parity.test.ts (129 pass), with accept and reject cases at each new bound.
where keeps rows whose named columns hold a listed value, compared as strings, and total_count and truncated count the rows kept. columns returns onset_s, sample_index and the columns named. columns_summary, computed before where, lists each column's values so a caller can build a filter from one small call. A column the recording lacks is refused with the columns it has. Closes #1500. Tested: bun test on the four MCP suites (229 pass) and the contract unit test (75 pass); 13 single-line mutations of the new guards, each killed by a test.
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1501Version: 🤖 Updated on each push. |
columns_summary leaves out store_path and group_name, which the request already names; where and columns still accept them. The unknown-column refusal now runs before the summary, so a refused call does not pay for a pass over every value. The descriptions say values are listed only for a column with few. Adds tests for where on a group with no events (the before > 0 guard) and for filtering on the store and group. Review findings on #1501. Tested: bun test on the four MCP suites (231 pass); removing the before > 0 guard, or summarizing the store and group again, each fails a test.
Section 5.4 lists where, columns and columns_summary, and notes the row-group read #1498 added for files over the whole-file bounds. Tested: docs only.
Contributor
Author
Review responseTwo Sonnet reviews: code and error handling, and tests with documentation. Code and error handling
Tests and documentation
Gates: the four MCP suites pass (231 tests), plus typecheck and biome. |
This was referenced Sep 24, 2026
This was referenced Sep 24, 2026
Merged
This branch was previously deployed
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.
Closes #1500.
What changed
get_eventsgains two optional inputs and one output field, so a model can ask for the events it needs instead of reading every column of every event.where: column name to allowed values, for example{"event_type": ["face", "scrambled_face"]}. A row is kept when every named column holds, compared as a string, one of the values listed; a null never matches.total_countandtruncatedcount the rows kept.columns: the columns to return.onset_sandsample_indexalways come back, so a projected row may now omitstore_pathandgroup_name; the output row schema says so (eventRowOutputSchema), while the parquet read and the cache still validate every row against the fulleventRowSchema.columns_summary, on every answer: each column except the two times, with its distinct and null counts, and its values when there are at most 50, each at most 100 characters. It is computed beforewhere, so a filter that keeps nothing still says what it could have asked for.whereorcolumnsname the recording's events do not have is refused with the columns they do have, never answered with an empty list.columns_summarywithlimit: 1first, then narrow.Filtering runs on the rows already read and cached, so a filtered call after an unfiltered one reads nothing new.
Why
The chat assistant reads a tool result into its context. For ERP CORE (nm000132), one N170 recording is 640 events and 220,341 bytes of JSON. An ERP image of faces against scrambled faces needs 160 of those rows and three columns, about 14 KB. #1499 made the file readable; this makes the answer usable.
Tests
backend/test/mcp-schema-parity.test.ts: accept and reject cases at each new bound, for both zod copies (129 pass).backend/test/mcp-recording-tools.test.ts: against the real nm000329 fixture parquet, whose first store is 36left_handand 36right_handevents, so every count is exact. Covers paging a filtered set, string comparison of a number, AND across columns with its note, nulls, projection, refusals, the summary's pre-filter view, the cache, the events.tsv fallback, and the summary's bounds at and past each limit.bun run typecheck,bun run lint, and the fullbun test(7540 pass, 223 skip, 0 fail).