Integrate console navigation with performance and safety checks
Register navigation index performance targets, preserve metrics leak assertions while excluding static shared CSS, and follow the approved Protection label to its shared source. Add the independently reviewed record-write census entries without changing scanner policy.
6 files changed,
+106
−7
docs/superpowers/plans/2026-10-30-console-protection-tab-copy.md+1 −1internal/console/perfwalk_test.go+3 −0internal/console/remotemetrics_test.go+1 −1internal/console/server_test.go+36 −4internal/provision/console_fiesta_census_test.go+64 −0internal/provision/plan9_b8_census_test.go+1 −1
CI passed — run details
diff --git a/docs/superpowers/plans/2026-10-30-console-protection-tab-copy.md b/docs/superpowers/plans/2026-10-30-console-protection-tab-copy.md| index 09737a4d8..4c75b3884 100644 |
| --- a/docs/superpowers/plans/2026-10-30-console-protection-tab-copy.md |
| +++ b/docs/superpowers/plans/2026-10-30-console-protection-tab-copy.md |
| @@ -38,7 +38,7 @@ The rules (the same as the analytics on-ramp deck, |
| | id | where | old | new | checked by | status | |
| | --- | --- | --- | --- | --- | --- | |
| -| PT-C01 | templates/appnav.html (tab) | (new) | Protection | gate | approved | |
| +| PT-C01 | mobilenav.go (shared tab and mobile navigation label) | (new) | Protection | gate | approved | |
| | PT-C02 | templates/app_protection.html (watching headline) | (new) | In the last {days} days, {caught} requests to this app looked like attacks. Protection is recording them and letting them through while we check it never stops a real visitor. | TestProtectionTabRendersHeadline | approved | |
| | PT-C03 | templates/app_protection.html (blocking headline) | (new) | In the last {days} days, protection blocked {blocked} requests to this app. | TestProtectionTabBlockingHeadline | approved | |
| | PT-C04 | templates/app_protection.html (mixed headline) | (new) | In the last {days} days, protection blocked {blocked} requests to this app and recorded {watched} more. | TestProtectionTabMixedHeadline | approved | |
diff --git a/internal/console/perfwalk_test.go b/internal/console/perfwalk_test.go| index 03a4c8fbd..b21f5b291 100644 |
| --- a/internal/console/perfwalk_test.go |
| +++ b/internal/console/perfwalk_test.go |
| @@ -493,6 +493,7 @@ func perfTargets(fx *consoleFixture) map[string][]perfTarget { |
| "/fleet/architecture": ok("/fleet/architecture"), |
| "GET /invite/{token}": ok("/invite/" + seeds.invite), |
| "GET /a/{sqid}/{$}": ok(fx.path("/")), |
| + "GET /a/{sqid}/index": ok(fx.path("/index")), |
| "GET /a/{sqid}/apps/new": ok(fx.path("/apps/new")), |
| "GET /a/{sqid}/fleet": ok(fx.path("/fleet")), |
| "GET /a/{sqid}/fleet/byo": ok(fx.path("/fleet/byo")), |
| @@ -501,6 +502,8 @@ func perfTargets(fx *consoleFixture) map[string][]perfTarget { |
| "GET /a/{sqid}/team": ok(fx.path("/team")), |
| "GET /a/{sqid}/trash": ok(fx.path("/trash")), |
| "GET /a/{sqid}/apps/{app}": ok(app), |
| + "GET /a/{sqid}/apps/{app}/index": ok(app + "/index"), |
| + "GET /a/{sqid}/apps/{app}/settings/index": ok(app + "/settings/index"), |
| "GET /a/{sqid}/apps/{app}/instances/{host}": ok(app + "/instances/kass.carlosapp.dev"), |
| "GET /a/{sqid}/plan/keep": ok("/a/" + seeds.lapsed + "/plan/keep"), |
| } |
diff --git a/internal/console/remotemetrics_test.go b/internal/console/remotemetrics_test.go| index ff2cdc166..26cf6a6f5 100644 |
| --- a/internal/console/remotemetrics_test.go |
| +++ b/internal/console/remotemetrics_test.go |
| @@ -93,7 +93,7 @@ func (tb *twoBoxes) noRemoteReadings(t *testing.T, bad ...string) { |
| t.Fatalf("the remote row carries a reading: %+v", m) |
| } |
| for _, path := range []string{"/apps/shop", "/apps/shop/instances", "/apps/shop/instances/" + remoteHost} { |
| - body := tb.page(t, path) |
| + body := stripSharedStyle(t, tb.page(t, path)) |
| for _, b := range bad { |
| if strings.Contains(body, b) { |
| t.Fatalf("%s shows %q:\n%s", path, b, body) |
diff --git a/internal/console/server_test.go b/internal/console/server_test.go| index 0bbd95682..60db93aa7 100644 |
| --- a/internal/console/server_test.go |
| +++ b/internal/console/server_test.go |
| @@ -2210,13 +2210,17 @@ func TestAppPageOwnerMetricsBoundary(t *testing.T) { |
| t.Fatalf("unmetered.example.com's own row did not read No readings / no data:\n%s", row) |
| } |
| // The boundary: nothing about the other tenant, the host, or the box. |
| + // Scoped past stripSharedStyle, not the raw page: the shared layout's |
| + // inline CSS legitimately carries "55%" of its own (a box-shadow |
| + // color-mix), which would otherwise read as this leaking. |
| + delivered := stripSharedStyle(t, body) |
| for _, forbidden := range []string{ |
| "other-tenant", "box-secret-a", // other tenant's unit, the box's name |
| "55%", "4.0 KB", // the other tenant's readings |
| "77.7", "78%", "89%", "44%", // host CPU/mem/disk totals |
| } { |
| - if strings.Contains(body, forbidden) { |
| - t.Fatalf("app page leaked %q in:\n%s", forbidden, body) |
| + if strings.Contains(delivered, forbidden) { |
| + t.Fatalf("app page leaked %q in:\n%s", forbidden, delivered) |
| } |
| } |
| } |
| @@ -2317,6 +2321,30 @@ func TestAppPageOwnerMetricsCrossAccountAppName(t *testing.T) { |
| } |
| } |
| +// stripSharedStyle returns page with its one <style>...</style> block (the |
| +// shared layout's inline CSS, which also carries the vendored Fiesta CSS |
| +// via its own "fiesta_day" sub-template) removed. Everything else is kept |
| +// intact — the rest of <head> (the dynamic Title), the whole body, its |
| +// attributes and scripts — so a leak anywhere else in the response still |
| +// fails. Metrics-leak checks scope to this because that one block |
| +// legitimately spells out plain percentages (box-shadow and color-mix |
| +// values) that would otherwise collide with a forbidden tenant reading. A |
| +// page missing either delimiter fails the test rather than silently |
| +// checking the whole thing. |
| +func stripSharedStyle(t *testing.T, page string) string { |
| + t.Helper() |
| + i := strings.Index(page, "<style>") |
| + if i < 0 { |
| + t.Fatalf("no <style> in page:\n%s", page) |
| + } |
| + j := strings.Index(page[i:], "</style>") |
| + if j < 0 { |
| + t.Fatalf("<style> never closed in page:\n%s", page) |
| + } |
| + j += i + len("</style>") |
| + return page[:i] + page[j:] |
| +} |
| + |
| // resourcesSection returns just the app page's Resources block. |
| // resourcesSection used to cut out a dedicated "Resources" section; CPU/Mem |
| // readings now live as columns on the Instances table itself, so this cuts |
| @@ -2398,10 +2426,14 @@ func TestAppPageOwnerMetricsStaleBoxIsNotCurrent(t *testing.T) { |
| if !strings.Contains(row, "Not responding") || !strings.Contains(row, "no data") { |
| t.Fatalf("stale box did not render as not responding with no data:\n%s", row) |
| } |
| + // Scoped past stripSharedStyle, not the raw page: the vendored Fiesta |
| + // CSS it carries legitimately has "23%" of its own (a rim color-mix), |
| + // which would otherwise read as this reading having stayed current. |
| + delivered := stripSharedStyle(t, body) |
| for _, forbidden := range []string{"23%", "2.0 KB"} { |
| - if strings.Contains(body, forbidden) { |
| + if strings.Contains(delivered, forbidden) { |
| t.Fatalf("app page rendered a %v-old reading as current (%q):\n%s", |
| - time.Since(at).Truncate(time.Hour), forbidden, resourcesSection(t, body)) |
| + time.Since(at).Truncate(time.Hour), forbidden, resourcesSection(t, delivered)) |
| } |
| } |
| } |
diff --git a/internal/provision/console_fiesta_census_test.go b/internal/provision/console_fiesta_census_test.go| new file mode 100644 |
| index 000000000..77ca96326 |
| --- /dev/null |
| +++ b/internal/provision/console_fiesta_census_test.go |
| @@ -0,0 +1,64 @@ |
| +package provision |
| + |
| +// Record-write census entries for the console's Fiesta styling and phone |
| +// navigation (branch console-fiesta-depth, UI commit d54fda7e), layered on |
| +// probeBurstLimitWriteCensusInventory (main's newest at b7802fd8). Reviewed |
| +// independently against the source; no write site, record key or storage |
| +// change is added. |
| +// |
| +// One re-pin, no class or kinds change: |
| +// - internal/console/server.go NewServer (key-site): registers four GET |
| +// index pages, /accounts (handleAccountsIndex, behind the session), |
| +// /a/{sqid}/index (handleAccountIndex, behind account), |
| +// /a/{sqid}/apps/{app}/index and /a/{sqid}/apps/{app}/settings/index |
| +// (handleAppIndex, handleAppSettingsIndex, behind accountApp). Each only |
| +// renders links; none writes. The instances route literal is unchanged. |
| +// |
| +// Three new units in internal/console/mobilenav.go, each key-site for the |
| +// "instances" literal, as the console's other route-literal sites are: |
| +// - page.AppLinks: the app's tab links; "instances" is the Running tab's |
| +// key and URL path segment. |
| +// - page.MobileBack: the phone's back link; "instances" names the Running |
| +// tab to label the instance detail page's back link. |
| +// - page.MobileTitle: an app page's phone heading; "instances" looks up |
| +// the Running tab's label for the instance detail page. |
| +// |
| +// All three are pure methods on page that build navigation links from the |
| +// page's fields. They read no store and write nothing. |
| +func consoleFiestaWriteCensusInventory() []censusEntry { |
| + entries := append([]censusEntry(nil), probeBurstLimitWriteCensusInventory()...) |
| + repins := []censusEntry{ |
| + // console fiesta: the four GET index routes; the same literal. |
| + {"internal/console/server.go", "NewServer", "key-site", "lit:instances", "d3c7f7518b10b470526d97862a58219a21db26fbeb64aae4aea06044fe8f196e"}, |
| + } |
| + for _, r := range repins { |
| + found := false |
| + for i, e := range entries { |
| + if e.File == r.File && e.Unit == r.Unit { |
| + if e.Class != r.Class || e.Kinds != r.Kinds { |
| + panic("console-fiesta re-pin changes the class or kinds of " + r.File + ":" + r.Unit) |
| + } |
| + entries[i], found = r, true |
| + } |
| + } |
| + if !found { |
| + panic("console-fiesta re-pin of an unlisted unit " + r.File + ":" + r.Unit) |
| + } |
| + } |
| + additions := []censusEntry{ |
| + // console fiesta: the app's tab links, the Running tab's key and path. |
| + {"internal/console/mobilenav.go", "page.AppLinks", "key-site", "lit:instances", "2b6d244a05d37ad29a551026a6dcd29d00772ed89273f1c3ff8a67a7d3af1fb5"}, |
| + // console fiesta: the phone back link, labelled from the Running tab. |
| + {"internal/console/mobilenav.go", "page.MobileBack", "key-site", "lit:instances", "541ff03e4343f63f55e394032bc00733e54aa37af7584655f155ca1f67e9677e"}, |
| + // console fiesta: the phone heading, labelled from the Running tab. |
| + {"internal/console/mobilenav.go", "page.MobileTitle", "key-site", "lit:instances", "87f0b265943fa52a83295b7f0bacd8e92545dbeda749e655c742877619303b00"}, |
| + } |
| + for _, a := range additions { |
| + for _, e := range entries { |
| + if e.File == a.File && e.Unit == a.Unit { |
| + panic("console-fiesta addition of an already listed unit " + a.File + ":" + a.Unit) |
| + } |
| + } |
| + } |
| + return append(entries, additions...) |
| +} |
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go| index e24ec464a..5fd42a764 100644 |
| --- a/internal/provision/plan9_b8_census_test.go |
| +++ b/internal/provision/plan9_b8_census_test.go |
| @@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) { |
| if len(got) < 100 { |
| t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root) |
| } |
| - inventory := probeBurstLimitWriteCensusInventory() |
| + inventory := consoleFiestaWriteCensusInventory() |
| problems := append(censusDiff(inventory, got), censusPolicy(inventory)...) |
| if len(problems) > 0 { |
| t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n ")) |