Skip to content

feat(scope): cross-session query correlation — PR D - #23

Merged
rylero merged 1 commit into
mainfrom
feat/scope-query-cross-session
Jul 6, 2026
Merged

rylero merged 1 commit into
mainfrom
feat/scope-query-cross-session

Conversation

@rylero

@rylero rylero commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Fourth (final) of the themed PRs building Tier-2 query features on the merged MVP (#19) + prior PRs (#20, #21, #22). Theme: correlating across multiple sessions, the most architecturally distinct piece — it fans out beyond a single EventTable.

Closes #16.

What it adds

query.RunAcross(sessions map[string]session.DataSession, queryStr string, start, end int64) ([]SessionResult, error):

  • Parses the query once so a typo doesn't produce N identical parse errors.
  • Runs the pipeline against each session independently; a session's own execution error (e.g. a field missing from that particular log) is captured in its SessionResult, not raised — one bad log in a folder of match logs shouldn't blank out the rest.

query.UnionResults(results) (rows, errored, error):

  • Flattens successful per-session rows/ranges into one table tagged with session_id.
  • Errored sessions come back separately in errored — never silently dropped.

Wiring

  • Registry.All() / Registry.Labels() (daemon/registry.go) — fan out to every active session, and annotate results with human-readable labels.
  • POST /query-multi (daemon/handlers.go) — comparison mode (default, one entry per session) or union=true (flattened table).
  • CLI: query-multi "<query>" (--sessions id1,id2,... | --all true) [--union true].

Note on --all/--union: spelled out (--all true), not bare --all. parseFlags (cli/commands.go) always consumes the token after --flag as that flag's value, so a bare boolean flag would eat the next flag as its value. Added a flagBool helper rather than changing parseFlags itself, to avoid touching behavior every other command relies on.

Verified live, not just unit tests

Generated two .wpilog fixtures (BatteryVoltage, one scaled 2x the other), ran a real daemon + CLI round trip:

  • Comparison mode: session 2's avg/min came back exactly double session 1's — confirms per-session isolation, not cross-contamination.
  • Union mode on where BatteryVoltage < 7 | ranges: only the session with an actual brownout produced a row (correctly tagged with its session_id); the other session correctly contributed zero rows rather than an error.

Test plan

  • go build ./..., go vet ./..., gofmt clean, go test ./... -race all pass
  • query package: RunAcross per-session isolation (good session succeeds, bad session's own error surfaces), parse-error fail-fast, UnionResults tagging + error separation
  • daemon package: HandleQueryMulti missing-query/no-sessions/all-with-nothing-active/unknown-id error paths, comparison mode with labels, union mode
  • Live end-to-end smoke test against a real daemon (see above)
  • CI green on this PR

This is the last of the 4 planned PRs — closes out issues #12–#18.

🤖 Generated with Claude Code

Closes #16.

Adds query.RunAcross(sessions, queryStr, start, end) ([]SessionResult, error)
and query.UnionResults, so a query can run against every loaded session at
once (e.g. every qualification match log from an event) instead of looping
`query` manually per session.

- RunAcross parses the query once (so a typo doesn't repeat N times) then
  executes the pipeline per session, capturing each session's own execution
  error (e.g. a field missing from that particular log) in its
  SessionResult rather than aborting the batch.
- UnionResults flattens successful table/stats or ranges results into one
  session_id-tagged table; errored sessions are reported separately, not
  silently dropped.

daemon: new POST /query-multi (registry.All()/Labels() added for the "run
against every active session" and label-enrichment paths). New CLI verb
`query-multi --sessions id1,id2,... | --all true [--union true]`. Booleans
are spelled out (--all true) rather than bare (--all) since parseFlags
always consumes the next token as a flag's value — this needed a
flagBool helper rather than extending parseFlags itself.

Verified end-to-end against a live daemon with two generated .wpilog
fixtures (scaled 1x/2x): comparison mode returned correctly-scaled
per-session stats with labels; union mode correctly found a brownout
interval in only the session that actually had one, with the other
contributing zero rows (not an error).

Docs: query-multi added to `help` and skills/scope/SKILL.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@rylero
rylero merged commit 012e62a into main Jul 6, 2026
1 check passed
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.

query: cross-session join/correlation (run one pipeline over N sessions/matches)

1 participant