Repository navigation
Add a read-only dashboard - #16
Merged
Merged
Conversation
/ lists the models and /models/{name} shows one in detail: the traffic split,
per-version request and failure counts, mean batch size, and drift readings.
Server-rendered HTML with no JavaScript at all, which is a decision rather than
a shortcut. html/template does contextual auto-escaping, and that is the XSS
defence — it matters more now than it would have before, because this server
hands out session cookies and a script injected into one of these pages would
run with somebody's session. Having no JavaScript is also what makes the
Content-Security-Policy meaningful: default-src 'none' with no script-src means
no script can run at all, which turns "everything is escaped correctly" from a
claim into something the browser enforces. A test asserts the pages contain no
script tags and no inline handlers, so a future addition fails loudly rather
than being silently blocked.
It also means no bundler and no node in CI for a Go serving platform, and the
binary stays the single self-contained artifact the rest of the design assumes.
Templates are embedded and parsed at startup, so a broken one fails the build
rather than the first request.
A browser gets a redirect to sign in where an API client gets a 401. That split
is the one place the HTML surface should differ: a browser handed a bare 401 has
nowhere to go and no way to know a sign-in exists, while an API client handed a
redirect follows it and tries to parse a login page as JSON. The redirect
preserves the destination and re-validates it through the same open-redirect
check.
Read-only, deliberately. Changing what serves production traffic is an audited
act that already has a tested CLI, and putting it behind a button would widen
the CSRF surface to reach a mutation nobody asked to make from a browser. The
pages sit behind the read scope like any other read, so a predict-only
credential gets 403.
Coverage across internal/ is 89.1%.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
The patch coverage check flagged the new code. These reach the paths the page-level tests do not: the severity mapping that drives the colour and the index rollup, the weight arithmetic behind the traffic bar, the shared open-redirect guard, and a version with enough traffic to actually report drift rather than only the not-enough-data branch.
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.
/lists the models;/models/{name}shows one in detail. Real output from a running server with a 90/10 canary and a drifting feature:The split lands where the policy says, and the mean batch sizes differ for a reason worth noticing: the 10% canary fills batches more slowly, so the same window gives it 3.1 rows a call against 26.3.
Server-rendered HTML, no JavaScript — a decision, not a shortcut
html/templatedoes contextual auto-escaping, and that is the XSS defence. It matters more here than it would have a week ago: this server hands out session cookies now, so a script injected into one of these pages would run with somebody's session. There's a test that puts<script>alert(1)</script>in a model description and asserts it comes back escaped.Having no JavaScript is what makes the CSP meaningful:
default-src 'none'with noscript-srcmeans no script can run at all — which turns "everything is escaped correctly" from a claim into something the browser enforces independently. A separate test asserts the pages contain no<script>and no inline handlers, so a future addition fails loudly rather than being silently blocked by the policy, which is a confusing way to find out.It also means no bundler and no node in CI for a Go serving platform, and the binary stays the single self-contained artifact everything else here assumes. Templates are
go:embed-ed and parsed at startup, so a broken one fails the build rather than the first request.A browser gets a redirect; an API client gets a 401
The one place the HTML surface should behave differently. A browser handed a bare 401 has nowhere to go and no way to know a sign-in exists; an API client handed a redirect follows it and tries to parse a login page as JSON. The redirect preserves where you were heading and re-validates the destination through the same open-redirect check as the login flow.
Tested both ways:
/models/anythingredirects to/login?next=...,/v1/modelsstill returns 401.Read-only, deliberately
Changing what serves production traffic is an audited act that already has a tested CLI. Putting it behind a button would widen the CSRF surface to reach a mutation nobody asked to make from a browser. There's a test asserting the pages contain no
<form>.The pages sit behind the
readscope like any other read — apredict-only credential gets 403, so the UI is not a way around authorisation.Smaller things
<meta http-equiv="refresh">rather than a script, so the no-JavaScript policy holds.Coverage
89.1% across
internal/.