Skip to content

feat: System Health as a SeQL dashboard — CASE/scoring sugar, score-bar viz, dashboard templates - #17

Merged
Qard merged 6 commits into
mainfrom
feat/health-dashboard
Jul 29, 2026
Merged

Qard merged 6 commits into
mainfrom
feat/health-dashboard

Conversation

@Qard

@Qard Qard commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Makes the Health tab reproducible as an ordinary dashboard built entirely from SeQL, by adding the expression surface it needs (CASE + scoring sugar), a score-bar visualization, a dashboard template catalog, and by finishing the separable-time-range work through the view (live table) path so template queries carry no baked-in time scope.

Stacked on #16 (feat/seql-analytics), which is stacked on #15 (feat/assistant-visualizations). Until those land, this PR's diff also shows the four assistant commits that #15 gained after #16 branched off it — we plan to rebase the stack next.

SeQL: CASE + scoring sugar (c906577)

Everything lowers to standard SQL — no bespoke stages.

  • ast — Expr::Case { branches, otherwise } (+ CaseBranch), scalar fns exp, coalesce, least, greatest, float, int.
  • parser — case when <pred> then <expr> … [else <expr>] end, parenthesised arithmetic grouping, generic scalar-function calls, and score(v, warn, err) / grade(v, warn, err) sugar desugaring to Expr::Case — the exact HealthAnalyzer piecewise (linear 1.0→0.7→0.3, then greatest(0, 0.3·exp(…))).
  • compiler — Case via DataFusion when().otherwise(), new scalar fns via session built-in UDFs / cast. Verified through the full Substrait produce→consume round-trip the backend actually executes.
  • grounding — teaches the optional time scope, compute, CASE, and score()/grade().

Separable time range through the view path (9dadeeb, dee7544)

The snapshot/live SeQL paths already took a structured range (#16); the reactive-view path did not.

  • ffi — sequins_view_create gains the (range_kind, range_a_ns, range_b_ns) triple → Option<TimeRange> overriding any inline scope; the view builder calls query_live_with_range. Header regenerated.
  • swift — DataSource.executeView and ReactiveTableView.start/startSnapshot take an optional timeRange:, passed structurally.
  • Every signal surface converted to scope-less template queries + structural ranges — Health, Logs, Traces, Metrics (outer metrics scan), Profiles, resources live stream. No more spans last <dur> baked into query strings.
  • Retires the dead TimeRange.applied(to:) / seqlTimeScope / dropTimeScope string-rewrite machinery and its obsolete tests.

Score-bar visualization (5553752)

VizType.scoreBar + ScoreBarView — horizontal factor bars filled to a 0..1 score, colored by band (≥0.7 green, ≥0.3 yellow, else red), matching the Health tab's factor rows. Renders either shape the query may produce: a wide single row (each numeric column a factor, <name>__value companion for the raw value, overall/score emphasized as a summary header) or a tall [label, score] result. Wired into VizRenderer; picker lists it via allCases.

Dashboard templates + seeded System Health (2edf33d)

  • metadata — templates.rs: DashboardTemplate, builtin_templates(), system_health(). Its panels are scope-less SeQL (range comes from the control bar): a scoreBar of per-factor scores plus a weighted overall via score() with thresholds mirroring HealthThresholdConfig, metric stat cards, trend lines, and an HTTP status-class stacked bar. AppStateStore::{instantiate_template, seed_builtin_dashboards} — seeds only a fresh store, so the dashboard stays deletable.
  • ffi — sequins_dashboard_templates_list / _instantiate_template; the local data-source constructor seeds on first run.
  • swift — DataSource.{listDashboardTemplates,instantiateTemplate}, DashboardTemplateInfo, TemplateGallerySheet, and a "New from Template…" menu item in the dashboard sidebar.

The Health tab stays in place for side-by-side verification against the templated dashboard.

Testing

Test coverage added by these commits: parser expansion/arity/parens on score()/grade(), and compiler compile + Substrait consume of a health-style scoring query; the System Health template's panel queries are guarded by the same compile+consume tests.

  • cargo fmt --all — one formatting drift in seql-substrait/src/compiler.rs test code (introduced by 2edf33d) fixed here in e59ae6e.
  • cargo test -p seql-ast -p seql-parser -p seql-substrait -p sequins-metadata — not completed locally before opening this PR (cut short); relying on CI for the authoritative run.

Known CI failure, inherited from #15: clippy explicit_counter_loop at crates/sequins-metadata/src/store.rs:152, which fails the Rust job under -D warnings. It is being fixed on feat/assistant-visualizations and will flow up when the stack rebases — not fixed here, to avoid a rebase conflict with that fix.

Not re-verified in this PR: the macOS app build and the daemon container image. The Swift changes were built during development, but if remote mode is used, the daemon image needs rebuilding for the new grounding (grounding is compiled into the daemon), same caveat as #16.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@Qard
Qard force-pushed the feat/seql-analytics branch from 10f4939 to c20190a Compare July 28, 2026 14:24
@Qard
Qard force-pushed the feat/health-dashboard branch 2 times, most recently from fd79952 to 3770504 Compare July 28, 2026 16:31
Base automatically changed from feat/seql-analytics to main July 28, 2026 16:31
Qard and others added 5 commits July 29, 2026 00:33
Extend the reactive-view path with a structured time range so scope-less
"template" SeQL queries can be executed with a range supplied by the control
bars, matching the SeQL snapshot/live paths:

- ffi: `sequins_view_create` gains the (range_kind, range_a_ns, range_b_ns)
  triple → Option<TimeRange> that overrides any inline scope; the view builder
  now calls `query_live_with_range`. Header regenerated.
- swift: `DataSource.executeView` and `ReactiveTableView.start`/`startSnapshot`
  take an optional `timeRange:`, passed structurally.

Convert every signal surface to scope-less template queries + structural
ranges (no more `spans last <dur>` baked into strings): Health, Logs, Traces,
Metrics (outer `metrics` scan only), Profiles, and the resources live stream.
Retire the now-dead `TimeRange.applied(to:)`/`seqlTimeScope`/`dropTimeScope`
string-rewrite machinery and its obsolete tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… fns

Add the expression surface needed to compute thresholded health/ranking
scores as plain queries (all lowering to standard SQL):

- ast: `Expr::Case { branches, otherwise }` (+ `CaseBranch`), and scalar fns
  `exp, coalesce, least, greatest, float, int`.
- parser: `case when <pred> then <expr> … [else <expr>] end`; parenthesised
  arithmetic grouping; generic scalar-function calls; and `score(v, warn, err)`
  / `grade(v, warn, err)` sugar that desugars to `Expr::Case` — the exact
  HealthAnalyzer piecewise (linear 1.0→0.7→0.3 then `greatest(0, 0.3·exp(...))`).
- compiler: lower `Case` via DataFusion `when().otherwise()`, and the new scalar
  fns via the session's built-in UDFs / `cast`. Verified through the full
  Substrait produce→consume round-trip the backend executes.
- grounding: teach the optional time scope (templates), `compute`, CASE, and
  score()/grade().

Tests: parser expansion/arity/paren, compiler compile + Substrait consume of a
health-style scoring query.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add `VizType.scoreBar` + `ScoreBarView` — horizontal factor bars filled to a
0..1 score and colored by band (≥0.7 green, ≥0.3 yellow, else red), matching the
Health tab's factor rows. Renders whatever the query produces: a wide single row
(each numeric column a factor, `<name>__value` companion for the raw value, an
`overall`/`score` column emphasized as a summary header) or a tall [label, score]
result. Wired into VizRenderer; the picker lists it via allCases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a built-in dashboard template catalog and a "New from Template" gallery,
with System Health as the first entry — reproducing the Health tab as an
ordinary dashboard built entirely from SeQL.

- metadata: `templates.rs` — `DashboardTemplate` + `builtin_templates()` +
  `system_health()`, whose panels are scope-less SeQL (range from the control
  bar): a `scoreBar` of per-factor scores + weighted overall (via `score()`,
  thresholds mirroring HealthThresholdConfig), metric stat cards, trend lines,
  and an HTTP status-class stacked bar. `AppStateStore::{instantiate_template,
  seed_builtin_dashboards}` (seeds only a fresh store, so it stays deletable).
- ffi: `sequins_dashboard_templates_list` / `_instantiate_template`; the local
  data-source constructor seeds on first run.
- swift: `DataSource.{listDashboardTemplates,instantiateTemplate}`,
  `DashboardTemplateInfo`, a `TemplateGallerySheet`, and a "New from Template…"
  menu item in the dashboard sidebar.

The Health tab stays for side-by-side verification. Template panel queries are
guarded by seql-substrait compile+consume tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Qard
Qard force-pushed the feat/health-dashboard branch from 3770504 to 8d7e9eb Compare July 28, 2026 20:59
Same flake class as the vortex-indexed-layout pruning test, in the crate that
owns BloomFilterSet. The test's comment — "use 1000+ items to avoid false
positives" — has it backwards: scaling the item count makes the nominal 1% rate
*accurate*, not zero. Two cross-field negative assertions at ~1% each fail
1.90% of runs (measured over 3000 trials against random keys).

Pin both filters to a seed verified to prune both cross-field values, and state
the actual reason in the comment.

Also widen the gate on `build_with_seed` to `any(test, feature = "test-util")`.
The bare feature gate is not active when compiling the owning crate's own unit
tests, so it was unavailable exactly where it is needed here.

Swept the rest of the workspace for the same pattern: the remaining negative
assertions query fields with no filter built, where `check` returns false
deterministically.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Qard
Qard merged commit 18316bc into main Jul 29, 2026
3 checks passed
@Qard
Qard deleted the feat/health-dashboard branch July 29, 2026 18:08
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