KYA report design
Design rules for the OSS report (the HTML rendered by kya receipt, kya start,
and kya certify --open). The hosted console has its own direction doc
(docs/product/frontend-design-direction.md); this file covers the local
report.
The dashboard is the documentation
The report must be self-explanatory and self-service at all times. A user never has to read CLI help, repo docs, or a changelog to learn what the install can do. Two rules follow:
-
Every capability is indexed, always. The Capabilities panel (
capabilitiesPanelinsrc/receipt/render-receipt.ts) renders on every report, including a fresh install with zero events. Each row names the capability, says what it does, shows live (green) vs available (neutral) status, and gives the exact command or config key that turns it on. When a new capability ships, its row is added here in the same change. -
Feature panels render empty states, not nothing. A panel for a supported feature never returns an empty string because its data is absent. It renders an empty state that says what the feature does and the command to activate it (see the OpenShell, Alerts, OTel export, Import, and Discovery panels). Hiding a feature until it has data makes it undiscoverable: users do not search docs to find features, they scroll the dashboard. The one exception is purely derived detail (per-session filters, paginated feeds), which has nothing meaningful to say until the parent dataset exists.
Rules that follow for anyone changing this report:
- Adding an integration, backend, exporter, or detector: add the Capabilities
row, give the feature panel an always-on empty state with the activation
command, and cover both in tests (
test/report-capabilities-panel.test.tsand the feature’s own panel test). - Status on the Capabilities panel is derived from fields already on
ReceiptModel. The panel never runs its own probes or IO: loaders probe, panels render. - Empty states name a concrete next action (“Import an export with
kya import --from openshell FILE”), never a dead end (“No data”). - A self-test button must work with zero configuration. When nothing is configured yet, the action runs against an ephemeral loopback sink (the notify test delivers through the real sender to a temporary receiver; the OTel test exports to a temporary collector), records the outcome where the panel reads it, and names the config key that makes it real. Erroring with “not configured” is a dead end and is not allowed.
- Expensive boards run themselves. A report that is produced by a CLI command
the user has to discover (ORR is the precedent) is generated automatically
when the live report starts and refreshes on a fixed cadence while it runs,
so the menu item is populated on first open. The underlying CLI command
stays the escape hatch, and a “run now” action covers the impatient case.
Exception: the report server that
kya startspawns runs withKYA_ORR_AUTO=off. It refreshes anorr-report/that exists, but it does not create one in your project (kya startwrites only config;kya orr runor the “Run ORR now” action creates the board). - A “run now” action must report what changed, not repeat the screen. The ORR re-run confirmation compares the new board against the previous one and says what moved (“red → green · 2 findings resolved”) or states plainly “no change · still red · no go” with a timestamp, so an identical board is understood as the correct result, never as a broken button.
- Findings must be falsifiable (a reader must be able to check them). Every finding rendered in the report names its evidence (file:line, never the secret value), and heuristic probes exclude their own output directory, docs, tests, fixtures, and .example/.sample files (the ORR secrets probe is the contract: a “rotate credentials” finding nobody can check is worse than no finding).
- Conditional rendering on data inside a panel (hide a table with zero rows, show counts only when non-zero) stays fine; conditional rendering of the feature itself does not.
Copy contract (ASD-STE100)
- All user-facing text follows Simplified Technical English: short sentences, one idea per sentence, active voice, simple approved words.
- No jargon without a plain explanation in place: “spending limit”, not “cost budget gate”; “warning, not a block”, not “soft gate”; “record” for trail, “decision” for verdict (ALLOW/DENY/REQUIRE_APPROVE stay, they are product terms).
- Every finding or status answers three questions in plain words: what is wrong, why it matters, what to do.
- This rule also covers README, docs, npmjs/GitHub descriptions, and the hosted website. The persisted owner rule lives in ~/dev/.remember/kya-public-style.md.
Layout contract
- Sidebar nav lists zones and major panels; every
id-ed panel is reachable by anchor. - Zone switching is pure CSS in
receipt-css.ts(:target+body:has()). Adding a zone or nav item means wiring all four rule groups: the defaultdisplay: nonehide list, the#id:targetdisplay rule, thebody:has(#id:target) #overviewoverride, and the nav highlight rule. A nav link without CSS wiring clicks to a no-op.test/receipt-nav-css.test.tsenforces this for every rendered nav link and zone, so the suite fails loudly when wiring is missed. - Tabs: the left menu shows Blocked, Activity and Connected tools. A native
<details>element named More holds Changes, Certify, ORR, Map, Showback, the Gateway pages and System. Its open or closed state is kept inlocalStorage(keykya-nav-more, every access in try/catch, so the page works without it), and a link to a tab inside it (for example#certify) opens it. The Connected tools zone (#connected) holds the wired-hosts panel; the Showback zone (#showback, only with a showback report) holds the token and cost card. - Blocked tab (zone id
overview, nav count is the number of blocked calls): the Blocked panel first (count and the last five blocked calls by outcome; the three demo calls, labelled demo, when none was blocked), then KPI tiles and analytics. Certify is its own zone and tab: it never appears on the first screen and its nav item shows no count. The control-plane address line shows only when a plane is configured (API key, saved login, or a base URL other than thekya initdefault). System zone: Capabilities first, then gateway, sandboxes, OpenShell, ORR, alerts, OTel export, tools. - Zones never render as bare whitespace: with no panels a zone shows a hint that names the activation path (the Capabilities panel normally guarantees the System zone is never empty).
Live-update contract
- The report never reloads the page on record (trail) activity. SSE
(server-sent events) announces typed
changes (
{"source":"trail"|"orr"|"action"}); the client then refreshes in place:POST /feedswaps the feed + pagination for the current filter/page/search state,POST /fragmentsswaps only the containers whose HTML changed (buildLiveFragmentsinrender-receipt.tsrenders both the initial page and the refresh, so they cannot drift apart). - Every live-updated container needs a stable id listed in the client’s
FRAG_TARGETSmap. A new panel that renders live data must be added tobuildLiveFragmentsandFRAG_TARGETS, or it will go stale until the next user action. - Interactive elements inside swapped containers must not rely on per-element bindings: chip clicks are delegated on document, the pagination bar already delegates. After a swap the client reapplies pressed state from the query-param filter state.
- Updates are throttled (one
/fragmentsper 2s), debounced (300ms), and deferred while the tab is hidden. A 401 stops auto-refresh and shows a restart banner: a dead token must never turn into a reload loop.
Counts and labels follow the outcome
The report says what happened to each call, not only what policy thought. The trail field outcome (ran, blocked, held, error; see the README, “Outcome of each call”) drives the counts, the row labels and the sort:
- The headline counts rows by outcome:
Ran 11, Blocked 5, Held 0. Error shows only when it is above 0.Neverstays a separate policy overlay. - A row with
outcome: ranandverdict: REQUIRE_APPROVEis labelled RAN with the note “would hold in strict mode”. One line under the headline explains how to turn strict mode on. It shows only when such a row exists. - Blocked rows sort above all other rows. Identical consecutive rows (same tool, outcome, verdict, reason, summary, target and arguments hash) collapse into one row with a count. Blocked rows, rows with a change preview and rows without an outcome never collapse. A search keeps its ranking and never collapses.
- The count cards (Decisions, Activity bar, Outcome mix, Markdown headline) always use the current labels: Ran, Blocked, Held, Never. An empty record shows zeros. Rows without
outcome(written before the field existed) keep their stored verdict. Their feed rows show ALLOW, DENY or REVIEW. Their counts are on a separate “Earlier: Allow / Deny / Review” line, and in Markdown on “Earlier calls (no outcome recorded)”. - The share summary (
stats.ran,stats.blocked,stats.held,stats.erroralways present, zeros when empty, next to the old keys) and the hosted shared page (Ran, Blocked, Held and Never tiles; rows with no outcome, and summaries from an older CLI, on one “Earlier (no outcome recorded): Allow / Deny / Review” line) and thekya certifytrail line read the same counts. The signed evidence bundle keeps itsverdictMix; it is a policy count and its schema does not change.
Tests: test/honest-verdicts.test.ts, test/honest-verdicts-e2e.test.ts and test/report-labels-e2e.test.ts.