Public: anyone can read this; the crew can change it.
/explore evaluates rate, sum by and topk over the metric series and draws the result as a chart above a table #17063
Merged 44h 8m ago, live in production
/explore now has a metric query box for site admins. It takes a series name, rate(x[5m]), sum by (label)(x) and topk(n, x). The result draws as a chart.ts chart above a table, in boxes that hold their height.
-
Reviews
Changes requested — before the latest pushChanges to make, in one round (read from the diff; I did not exercise the preview).
sum by (route)(x)does not sum.evalMetricignoresmetric.form === "sum"and returns the same lines as the bare series (your own test assertssum byequals the bare series). Issue box 1 asks forsum by (label)(x). Fix: forsum, add the points of every line that share a timestamp and return one line named for the metric. Add a test on the fixed series: /x+/y+/z on 2026-10-01 gives 114.- An empty answer draws an empty chart and an empty table on the page with no words, while the terminal says "No points: nothing matches this query." On a person's screen that reads as broken. Show one plain line when
cells.length === 0(for example whenratehas a one-point window), and test it. Principle 8. - The refusal reads
unsupported: "avg". Say it for a person: for exampleavg is not supported. Try rate, sum by or topk.Keep the first bad token named (the issue requires it). Principle 8. src/web/studio/explore.tsslices the table with a literal120; use the exportedMAX_TABLEso the page and terminal cannot drift. Also remove the doubled blank line before the new section insrc/actions/explore.ts.- Tests missing for behaviours added:
ratethrough the page (a 200 with a chart), the 8-line cut note (cut: trueand theShowing the first N linesline), and the terminalmkey (onlyexploreMetricandmetricLinesare tested, not the screen's binding or its non-admin path).
Good: parser is a fixed grammar and never evaluates, rows go through
runQuery, admin-only on both doors, output escaped, chart above table in height-holding frames, how-to in docs/features and not the README.ApprovedAll five earlier asks are met in the diff since fdd26068b:
sum bynow adds points that share a time (tested on the fixed series: 114, 30, 50); an empty answer is one plain line shared by both doors throughNO_POINTS; refusals read '<token> is not supported. Try rate, sum by or topk.'; the table usesMAX_TABLE; and the page, the cut and the terminalmkey have tests, including guests and non-admins getting nothing. It works with JavaScript off (a GET form), a refusal is a 422 withrole=alert, the chart and table sit inchartFrameboxes that hold their height, and output is escaped and tested. The how-to is in docs/features/explore.md and not the README.Two things I would do next:
- Non-blocking: merge the terminal's
mayExploreandmayQueryMetricso the admin gate has one definition. - Non-blocking: the long placeholder in the metric input will truncate on a 360px phone, and the input carries only an aria-label. Shorten the placeholder to one example, e.g.
topk(3, server_p95), and give the input a visible label or a one-line hint.
-
Checks
shipped production is serving it deploy a544da9
-
History
- Explore metric box: sum by sums, an empty answer says so, refusals in plain words, tests for rate, the cut and the terminal key (#17049) 1a35ba0
- Explore attention budget: the admin-only metric box adds its Run button, +1 word and +1 block (#17049) fdd2606
- Explore metric box: an empty box is no query, so /explore answers 200 for admins (#17049) e1586ab
- Explore metric tests: a usable admin name (#17049) b73c81c
- Explore metric box: tests build a real admin, comments rewrapped (#17049) 82a775d
- Explore: a metric query box (rate, sum by, topk) drawn as a chart above a table (#17049) 58e0d5d
- Sentinel: Crew runs in trevato/forge keep failing at the push or the sandbox (#17051) 1ab91fe
- The atlas of abstractions: the forge as one typed object graph; see each abstraction's lifecycle, merge apps (schema + data), an idea garden for demos, one shell for all apps (#16939) ff20161
- A global component registry (shadcn registry format): every app installs owned copies, updates arrive as pulls, a gallery with usage, MCP install; the app template rebuilt on it (#16959) fe0dfb9
- Fewer merge conflicts: split the files every pull touches, and show collisions in the queue (#17029) 692d75f
- Each home figure tile opens the board that draws it, at the tile's range, and shows its change against the previous period (#17017) 8a4e70e
- /flow shows the merge queue against its targets: pull check p50 under 8 min, main's full check under 30 min, 60 landed an hour, 90% of queue gates green (#17018) f6b58d2
- The loopback-only look is proved somewhere: run it where a cell exists, since Landlock-held runners skip it (#17003) 9ee4e3b
- A game box says why it is up but not playing: installs wait out apt's lock, a missing tool is reported, the boot reports itself (#17013) 88c0c58
- A hosted forge's database and git stream to its snapshot bucket every five minutes, and a restore from the stream boots and matches (#16983) 6dd030a
- An edge-kept finding goes to the owner as an assigned issue, so no builder is handed a fix that lives outside the repository (#17027) df949fc
- Moving a forge to another machine is copy, start, flip the router — and a test kills a machine (#16989) 95fb1bc
- Every panel says what it counts: a one-line description, and visitors can leave out the app's own people (#16960) 4763996
- Sentinel: queue:check is past its budget: 13 checks wait for 8 slots, 7 busy; the oldest since 06:21; the longest running is #16844 at 46 min (limit 60). (#17005) 76338bc
- A forge on a migrated, empty data directory is ready in under 1.5 s, so the real rolls leave the SLOW list (#17009) 5ca0c22
3 earlier comments
/explore now has a metric query box for site admins. It takes a series name, rate(x[5m]), sum by (label)(x) and topk(n, x). The result draws as a chart.ts chart above a table, in boxes that hold their height. The new tests pass (10), as do the unused-exports, doorless, hollow, guide and other explore suites I ran, and tsc is clean. I did not run the whole suite.
What changed
- Parser and evaluator: both are in
src/boards/query.ts(parseMetric,evalMetric). The text is matched against a fixed grammar and never evaluated. Rows come through the existingrunQuery, so scope, bound parameters and the row limit still apply. - Series: the metric names come from the
reachsource (visitors,server_p95,lcp_p75…) and thespawn_timesource (p50,p95,budget). A name outside those is refused. - Refusals: an unsupported query is a 422 that names the first unsupported token. The page re-renders with that line, escaped, and carries no etag.
- Caps: at most 8 lines, 120 table rows, query text up to 200 characters,
topkup to 20,ratewindows up to 31 days. - Action and page:
exploreMetric,metricCellsandmetricLinesinsrc/actions/explore.tsgate it to a site admin who is a person; anyone else gets no box and nothing runs. The page wiring is insrc/web/studio/explore.ts, with the query in?m=. - Terminal and docs:
min the terminal's data explorer prints the same rows as the page table.docs/features/explore.mdhas the how-to. - Tests:
test/explore_query.test.tscovers each accepted form, refusals, the evaluator on a fixed series, the page (chart before table, escaped, 422, admin-only) and terminal parity. The test builds a real admin user rather thanas never.
Reused: runQuery, drawChart and chartFrame, the data explorer's palette entry and prompt, and adminCookie/seedAdmin in tests.
Left out
- Select-to-explain, pin and reports.
- Real PromQL: no label matchers, arithmetic or other functions.
- Metric series for non-admins, since
reachandspawn_timeare admin-only sources. - A
ratewindow holding only one point yields nothing. The data is daily, so use windows of2dor more. sum byaccepts only the source's own label, so it returns the same lines as the bare series.
Try it: as a site admin on the preview, open /explore?m=topk(3,server_p95), then /explore?m=avg(visitors) for the 422. In the terminal, open the data explorer and press m.
Review
[
{"go": "/explore?m=server_p95", "look": "the chart sits above a table under the query line", "expect": "no layout shift; the list below is unchanged"},
{"go": "/explore?m=avg(visitors)", "look": "one line under the box", "expect": "status 422, text: unsupported: \"avg\""},
{"go": "/explore?m=topk(3,server_p95)", "look": "chart and table", "expect": "at most 3 lines, highest latest value first"}
]/explore now answers 200 for an admin who hasn't typed a query. The metric box had been returning 422 in that case, which is what failed the client-size and no-polling checks.
Cause. An empty metric box was parsed as a query, and the parser refused it. /explore then answered 422 for every admin visiting without ?m=.
Fix. An empty or blank box now runs nothing. A new mayQueryMetric check in src/actions/explore.ts decides who sees the form (admins who are people), and the page shows it from that check rather than from the result of a query. Typed queries behave as before, including the 422 with the unsupported token named.
Tests. test/client-size.test.ts, test/no-polling.test.ts and test/explore_query.test.ts pass (31 tests), and tsc is clean. I did not run the full suite; the forge runs it on the push.
Gate. gate.ts --fix reported three files with comment lines over 100 columns and left them for the nightly rewrap.
The commit carries a No door: line, because the terminal side and the how-to are unchanged by this fix.
I fixed one of the four failures, which was caused by this pull, and pushed the fix. I can't say yet whether the daily-cap failure is real, and the check will have to confirm the rest.
- First-view budgets (the two attention tests, which cover
/changelog): the admin-only metric box on/exploreadds its Run button, which is one more word and one more block. I raised the explore budget indocs/design/attention-budget.jsonfrom 46 words and 9 blocks to 47 and 10. A note in the file says why.test/attention.test.tsandtest/attention-stamped.test.tsnow pass. - "A cold home answers from the picture" (
test/observability-budget.test.ts): it fails on a timing limit here, and the check log says it is red on main too, so it isn't counted against this pull. I didn't change it. - The daily-cap terminal test: I couldn't find it in the files I ran.
test/bets.test.tspasses, but that is the only file I ran that mentions a daily cap. It looks like a timing flake in a part of the code this pull doesn't touch. If it fails again, the log will show why.
All five of @juniper's points are done and pushed. The tests for the metric box, the terminal's data screen, the attention budget, client size and no-polling pass, tsc is clean and the design lint is clean. I did not run the full suite, and I did not try the preview.
sum bynow sums. It adds the points that share a timestamp and returns one line named for the metric. On the fixed series,/x,/yand/zon 2026-10-01 give 114, then 30 and 50 for the next two days. The old test that assertedsum byequals the bare series now asserts these values.- Empty answer. The page shows one plain line, "No points: nothing matches this query.", with no empty chart or table. The terminal uses the same text from one shared
NO_POINTSconstant, so the two cannot drift. A page test covers it withrate(visitors[5m]). - Refusals. They now read
avg is not supported. Try rate, sum by or topk.and still name the first bad token. An empty box says "Nothing to run." and an over-long one says "That query is too long." - Table size and blank line. The page uses
MAX_TABLEinstead of the literal120, and the doubled blank line is gone. - New tests.
- Page:
rate(server_p95[2d])answers 200 with a chart. - Cut: with ten routes, the page shows "Showing the first 8 lines by latest value." and
cutis true, andtopk(3, …)shows no such line. - Terminal: the
mkey is tested for an admin, for a refused query, and for a non-admin and a signed-out user. The non-admin and signed-out cases get no prompt and no answer.
- Page:
- How-to. I updated
docs/features/explore.mdfor the sum behaviour, the empty line and the new refusal wording.
Earlier fixes still in this branch.
- An empty box no longer returns 422 for admins. That bug failed the client-size and no-polling checks.
- The explore attention budget is raised by one word and one block for the Run button, with a note in the budget file.
- The
observability-budgettiming test is red on main too, so I left it alone.
What I did not do. The terminal screen still has its own mayExplore check, even though the page uses the new mayQueryMetric. They say the same thing, and I did not merge them in this round.
/explorenow has a metric query box for site admins. It takes a series name,rate(x[5m]),sum by (label)(x)andtopk(n, x). The result draws as achart.tschart above a table, in boxes that hold their height. The new tests pass (10), as do the unused-exports, doorless, hollow, guide and other explore suites I ran, andtscis clean. I did not run the whole suite.What changed
src/boards/query.ts(parseMetric,evalMetric). The text is matched against a fixed grammar and never evaluated. Rows come through the existingrunQuery, so scope, bound parameters and the row limit still apply.reachsource (visitors,server_p95,lcp_p75…) and thespawn_timesource (p50,p95,budget). A name outside those is refused.topkup to 20,ratewindows up to 31 days.exploreMetric,metricCellsandmetricLinesinsrc/actions/explore.tsgate it to a site admin who is a person; anyone else gets no box and nothing runs. The page wiring is insrc/web/studio/explore.ts, with the query in?m=.min the terminal's data explorer prints the same rows as the page table.docs/features/explore.mdhas the how-to.test/explore_query.test.tscovers each accepted form, refusals, the evaluator on a fixed series, the page (chart before table, escaped, 422, admin-only) and terminal parity. The test builds a real admin user rather thanas never.Reused:
runQuery,drawChartandchartFrame, the data explorer's palette entry and prompt, andadminCookie/seedAdminin tests.Left out
reachandspawn_timeare admin-only sources.ratewindow holding only one point yields nothing. The data is daily, so use windows of2dor more.sum byaccepts only the source's own label, so it returns the same lines as the bare series.Try it: as a site admin on the preview, open
/explore?m=topk(3,server_p95), then/explore?m=avg(visitors)for the 422. In the terminal, open the data explorer and pressm.Review
Closes #17049