Skip to content

feat(scope): add query --follow and search-fields commands - #28

Merged
rylero merged 1 commit into
mainfrom
worktree-scope-live-stream-field-search
Jul 6, 2026
Merged

rylero merged 1 commit into
mainfrom
worktree-scope-live-stream-field-search

Conversation

@rylero

@rylero rylero commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • query --follow true [--interval-ms <n>] polls the whole live range on an interval and streams one NDJSON line per changed result to stdout, so a Python/pandas consumer can tail a live NT session instead of re-invoking query in a loop. Client-side only (no daemon change): rejects log sessions since their end is fixed, and resolves the default/ambiguous session the same way the daemon's own resolution does.
  • search-fields <substr> [--session <id>] filters a session's field list (pulled from the existing /info endpoint) by case-insensitive substring, for writing SPL queries against logs with hundreds of NT keys. Also client-side, no new daemon endpoint.

Both were scoped in handoff-claudescope-live-streaming-and-field-search.md as independent, previously-unstarted features. Neither depends on the in-flight --format csv/parquet work in #26 or the planned Python wrapper.

Test plan

  • go build ./... and go test ./... pass
  • Added unit tests for search-fields (case-insensitivity, no-match, missing-arg)
  • Added unit tests for --follow's session resolution (rejects log sessions, defaults to sole session, ambiguous-session error, no-session error)
  • Added a test that drives the actual follow loop against a fake daemon and asserts NDJSON output (one line per distinct result, none on unchanged polls)
  • Not exercised against a real live NT session (no such session available in this environment) — flagged in the handoff as needing that kind of verification before merge

🤖 Generated with Claude Code

- query --follow true polls the whole live range on an interval and
  streams one NDJSON line per changed result to stdout, so a Python
  consumer can tail a live NT session instead of re-running query in a
  loop. Rejects log sessions (fixed end, would repeat forever) and
  resolves the default/ambiguous session the same way the daemon does.
  No daemon changes needed: it's a client-side polling loop over the
  existing /query endpoint.
- search-fields <substr> filters a session's field list (from /info)
  by case-insensitive substring, for writing SPL queries against logs
  with hundreds of NT keys. Also client-side, no new daemon endpoint.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@rylero
rylero marked this pull request as ready for review July 6, 2026 06:56
@rylero
rylero merged commit c52aeef into main Jul 6, 2026
1 check passed
@rylero
rylero deleted the worktree-scope-live-stream-field-search branch July 6, 2026 06:56
rylero added a commit that referenced this pull request Jul 6, 2026
…python client

SKILL.md hadn't been updated for #27 (claudescope-py) or #28
(--follow/search-fields), and this branch adds --format csv/parquet
on top -- the agent-facing guide was missing all four. Documents:
- search-fields command
- --format csv/parquet output for query/query-multi --union true
- query --follow true live streaming (NDJSON, incompatible with
  --format/--out)
- the claudescope-py Python client, recommended over --format for
  Python consumers since it builds a DataFrame directly

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
rylero added a commit that referenced this pull request Jul 6, 2026
* feat(scope): add --format csv to query/query-multi

CSV output lets query results feed pandas.read_csv() directly
without a JSON parsing round-trip. Columns are the union of all
row keys, sorted alphabetically with Timestamp pinned first for
determinism across heterogeneous rows (e.g. stats/timechart by
group). query-multi requires --union true since comparison mode
isn't row-shaped.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* feat(scope): add --format parquet, fix CSV bool dtype

Parquet preserves native bool/float64/string types and true nulls
for missing columns, unlike CSV which must stringify everything.
Column type per field is inferred from non-nil values (bool/float64/
string), falling back to a stringified UTF8 column on any mix so
the writer never errors on unexpected value shapes.

Also fix CSV output to write bools as "True"/"False" instead of
Go's lowercase "true"/"false" -- pandas.read_csv's C parser only
recognizes the capitalized form as boolean, otherwise the column
comes back as object dtype.

Adds github.com/parquet-go/parquet-go as a new dependency.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(scope): update SKILL.md for csv/parquet, follow, search-fields, python client

SKILL.md hadn't been updated for #27 (claudescope-py) or #28
(--follow/search-fields), and this branch adds --format csv/parquet
on top -- the agent-facing guide was missing all four. Documents:
- search-fields command
- --format csv/parquet output for query/query-multi --union true
- query --follow true live streaming (NDJSON, incompatible with
  --format/--out)
- the claudescope-py Python client, recommended over --format for
  Python consumers since it builds a DataFrame directly

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(scope): stop parquet writer from nulling falsy values

Found via end-to-end testing against a real .wpilog and pandas
(not just Go-side round-trip tests): rowsToParquet wrote rows via
GenericWriter's map/reflect path (w.Write([]map[string]any{...})),
whose isNullValue check (parquet-go's column_buffer_reflect.go)
treats any Go zero value -- false, 0.0, "" -- as equivalent to an
absent key for Optional columns. A real Enabled=false or a sensor
reading of exactly 0.0 was silently coming back as a Parquet null
(NaN/None in pandas), which is a correctness bug that would corrupt
real telemetry data on release.

Fix: build parquet.Row values manually with explicit definition
levels (1 = present, 0 = null) via schema.Lookup for each column's
index, bypassing the reflect path entirely. Verified against real
pandas: false/0.0/"" now round-trip as themselves, while genuinely
missing columns (e.g. an unmatched lookup join) still round-trip as
null. Added a regression test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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