From df3142c881607121ca5e9a9896c44205b47cacc6 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 12:28:24 +0000 Subject: [PATCH 01/28] Add working folder for feature 453 --- specs/feature-453-dashboard-attention/log.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 specs/feature-453-dashboard-attention/log.md diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md new file mode 100644 index 00000000..89843692 --- /dev/null +++ b/specs/feature-453-dashboard-attention/log.md @@ -0,0 +1,8 @@ +# Log: feature 453-dashboard-attention + +One line per pipeline step: date and time of day (UTC), step, member, result. Lead decisions and escalations +are quoted in full. + +| Date | Step | Member | Result | +| ---- | ---- | ------ | ------ | +| 2026-11-29 12:28 | 1 Intake | Orchestrator | RESULT: DONE — issue 453 (feature, open, label enhancement, no comments); dependencies 451 and 452 merged; branch claude/magical-bohr-d8uz9o off main fada378; work folder specs/feature-453-dashboard-attention | From 23a913512787544ddcdb248c0c53aa04a50183a8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 12:32:22 +0000 Subject: [PATCH 02/28] Add spec --- specs/feature-453-dashboard-attention/spec.md | 176 ++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 specs/feature-453-dashboard-attention/spec.md diff --git a/specs/feature-453-dashboard-attention/spec.md b/specs/feature-453-dashboard-attention/spec.md new file mode 100644 index 00000000..b352ea4f --- /dev/null +++ b/specs/feature-453-dashboard-attention/spec.md @@ -0,0 +1,176 @@ +# Spec: Dashboard that lists what needs attention + +Source: Issue #453 (part of #450) +Status: Draft + +## Problem + +The dashboard (`/`) answers "how many" but not "which": a hero panel, eight metric cards, *Update pressure* and +*Coverage snapshot* repeat the same counters, and a user who reads "7 update findings" has to open another page to +learn which containers are meant. The table of the ten most recent scans takes the most room although it matters +only when a run failed. Users need to see at a glance which containers, advisories and own images need attention, +and whether a recent scan failed. + +## Scenarios + +The visual values (fonts, sizes, colors, tokens, gaps, paddings, panel widths) are those of the issue's *Scope* +(sections 1–5) and the mockups linked there; the spec does not repeat them. "Running containers" are the current +containers of [Docker instances](../../docs/areas/docker-instances.md) — the set the Runtime Containers page lists. + +- S1: Given running containers with the update state `Update available`, advisories affecting running containers + and own images with a base runtime alert, when the user opens `/`, then the page shows top to bottom: the headline + `7 updates, 2 runtime warnings and 31 vulnerabilities need attention.` (only the three parts colored), the sub + line `43 protected assets on 2 Docker instances · last activity 2026-11-14 09:42 UTC`, the vulnerability + configuration hint if one applies, the panels *Updates available*, *Vulnerabilities*, *Own base runtime warnings* + and *Last 10 scans*, and the inventory strip. The hero panel, the metric cards, *Update pressure*, *Coverage + snapshot* and the *Recent scans* table are gone. +- S2: The headline leaves out every count that is 0, keeps the order updates, runtime warnings, vulnerabilities, + joins two parts with `and`, three with a comma and `and`, and uses the singular for a count of 1 (`1 update`, + `1 runtime warning`, `1 vulnerability`); a single part of count 1 takes `needs attention.`, every other + headline `need attention.`. Without any part it reads `Everything is up to date.` in the success color. +- S3: *Updates available* shows the count and up to 5 running containers with the update state `Update available`, + ordered by container name, then instance name (letter case ignored). A row shows the container name, the instance + name, and `{current tag} → {available tag}`, the current tag followed by `({resolved version})` when the tag is an + alias, as on the Runtime Containers page. A click on the row opens `/runtime-containers/{instanceId}/{containerId}`. + The footer reads `{n} more in Runtime Containers` when more than 5 qualify, otherwise `Open Runtime Containers`; + both open `/runtime-containers`. +- S4: *Vulnerabilities* shows the count, the severity bar with its legend over the counted advisories, and up to 4 + advisories that affect at least one running container, ordered by severity (Critical, High, Medium, Low, then + an unknown severity), CVSS score descending (no score last), number of affected running containers descending, + advisory identifier (letter case ignored). A row shows the affected packages joined with `, ` (the advisory + identifier when it names none), the severity as a chip, and `Fixed in {versions joined with ", "}` or + `No fix available`, ` · `, `{n} running containers` (`1 running container`). A screen reader announces the + advisory identifier with the row. A click opens `/vulnerabilities`. The footer reads `{n} more in Vulnerabilities` + when more than 4 qualify, otherwise `Open Vulnerabilities`. +- S5: *Own base runtime warnings* shows the count and up to 5 own images (registration source *Discovery*) with a + base runtime alert, ordered by name (letter case ignored); a row shows the image name and its alert summary as My + Images shows it, and opens `/my-images/{id}`. The footer reads `{n} more in My Images` (to `/my-images`) when more + than 5 qualify; otherwise there is no footer. +- S6: *Last 10 scans* shows one segment per recorded run of the ten most recent, newest on the left, colored by + status (Succeeded, Partial, Failed, Running, Pending as the issue's *Scope* names), each with a tooltip naming + type, target, status and start time; below it one line with the counts per status above 0 in the order + succeeded, running, pending, partial, failed, joined with ` · ` (`8 succeeded · 1 partial · 1 failed`, the failed + count emphasized in the danger color). The strip is announced as an image whose name lists the same counts joined + with `, `. When one of the ten runs is `Failed` or `Partial` and has an error message, one more line names the + newest such run: `{target} · {error message}`, the message as stored. The footer `Open scan history` opens + `/scan-history`. +- S7: The inventory strip shows one cell per counter — `My Images` (only when a Docker Hub account is configured), + `Observed Images`, `Runtime Containers`, `Docker Instances`, `Base Images` (only when its count, the number of + shared base images, is above 0) — each with its figure and a link to `/my-images`, `/observed-images`, + `/runtime-containers`, `/docker-instances` and `/base-images`. +- S8: Given no update, no runtime warning and no vulnerability count, when the user opens `/`, then the headline + reads `Everything is up to date.`, and one panel titled `Nothing to do` with the text `No updates available, no + own base runtime warnings and no vulnerabilities in running containers.` replaces the three list panels; it and + *Last 10 scans* each take the full width, one above the other, as in the all-clear mockup; the inventory strip + stays. +- S9: Given a manual scan, registration or rescan finishes, when the refresh signal arrives, then the open dashboard + reloads its data without a page reload; the first interactive render reuses the prerendered data. +- S10: While the data loads, the page shows skeletons in the shape of the new layout: headline, three panels and the + strip. +- S11: On a screen narrower than three panel columns the panels stack in the order Updates available, + Vulnerabilities, Own base runtime warnings, Last 10 scans; the inventory strip wraps its cells. + +## Errors and edge cases + +- E1: No recorded scan run: the sub line ends with `last activity no scans yet`; *Last 10 scans* shows `No scans + have been recorded yet.` and neither strip nor count line, the footer link stays. +- E2: Exactly one Docker instance or one protected asset: `1 Docker instance`, `1 protected asset`. +- E3: A list panel without an entry shows no count and its empty text: `No updates available.`, `No + vulnerabilities in running containers.` (and no severity bar), `No runtime warnings.`. +- E4: No Docker Hub account configured (user name or token missing) and no runtime warning: the *Own base runtime + warnings* panel is not shown. With such warnings (own images kept from an earlier configuration) it is shown. +- E5: A container with `Update available` but no available tag: its second line shows the current tag only, without + arrow. +- E6: An advisory with findings of different severities or scores counts once, with its highest severity and + highest score, as the Vulnerabilities page shows it; an unknown severity counts as low in the bar. +- E7: The newest failed or partial run has no target (a vulnerability refresh): its line shows the error message + alone. A failed or partial run without an error message is skipped for that line; with none left, the line is + absent. +- E8: Fewer than ten runs: the strip shows only those runs. A run with a status other than the five is drawn in the + pending color and appears in neither count line nor label. +- E9: The first load fails: the error alert `Loading the dashboard failed: ` replaces the skeletons, as + today; a failed reload keeps what is shown. +- E10: Names, packages, tags and error messages come from Docker, registries and scanners: they are shown as text, + never interpreted as markup; long texts wrap inside their panel. +- E11: Update findings of observed images no container runs, and vulnerabilities of image versions no container + runs, appear on no dashboard panel and in no headline count (Observed Images, My Images and Vulnerabilities still + show them). + +## Non-functional requirements + +- N1: The dashboard loads in one service call through `IApplicationViewService`; the lists share the evaluation of + the Runtime Containers, Vulnerabilities and My Images pages instead of copying it, and the dashboard reads no + resource usage samples or histories. +- N2: The view data carries only the shown entries (at most 5, 4 and 5) plus each list's total count and the ten + most recent runs, so the persisted prerender state stays small. +- N3: Contrast, control height, reduced motion and self-hosted fonts follow the rules of #450 in both themes. +- N4: No route, action, configuration or stored data changes; which containers are running, which images own, and + how update state, severity and base runtime alerts are evaluated stays with the feature areas. + +## Acceptance criteria + +- AC1: The headline follows the composition rules for every combination of zero and non-zero counts, including the + singular forms, `needs`/`need` and `Everything is up to date.`; only the parts are colored (S1, S2, S8). +- AC2: The sub line shows protected assets (manual observed images + own images + running containers, the top + bar's figure), the Docker instance count and the start time of the most recent run as + `yyyy-MM-dd HH:mm UTC`, or `no scans yet`, with the singular forms (S1, E1, E2). +- AC3: *Updates available* lists at most 5 running containers with the state `Update available` in the stated + order, with names, current tag (and resolved version of an alias), available tag and the detail link; footer text + and target follow S3 (S3, E3, E5). +- AC4: *Vulnerabilities* shows the severity bar and at most 4 advisories affecting running containers in the + stated order, with packages or identifier, severity chip, fix text, container count, an accessible name holding + the identifier, the link and the footer of S4 (S4, E3, E6). +- AC5: *Own base runtime warnings* lists at most 5 own images with their alert summary and image link and the + footer of S5; it is hidden without a Docker Hub account and without warnings (S5, E3, E4). +- AC6: *Last 10 scans* shows the strip (order, colors, tooltips, accessible name), the count line, the line of the + newest failed or partial run with its stored message, and the scan history link; without runs its empty text + (S6, E1, E7, E8). +- AC7: The inventory strip shows its cells with the visibility rules and links of S7 (S7). +- AC8: With all three counts 0 the `Nothing to do` panel replaces the three list panels; scans and inventory stay + (S8). +- AC9: The service fills the counts as the number of running containers with `Update available`, the number of + distinct active advisories affecting at least one running container (the severity bar on the same basis), and the + number of own images with a base runtime alert; the headline and panel counts are these figures, and each "more" + figure is the count minus the shown entries (S1–S5, E6, E11, N2). +- AC10: The dashboard shows the new skeletons while loading, the existing error alert on a failed first load and + the existing vulnerability configuration hints under their existing conditions; it reloads on the refresh signal, + reuses the persisted prerender state, and reads no resource usage data; texts from Docker, registries and scanners are rendered as text (S9, S10, E9, E10, N1, N4). +- AC11: `docs/areas/web-ui.md` describes the new dashboard (Area documents). + +## Out of scope + +- The app shell and the top bar's two values (#454); the navigation in the mockups. +- A link from a vulnerability row to a filtered Vulnerabilities page; new actions on the dashboard. +- Update findings of non-running observed images on the dashboard (E11). +- S11 and N3 beyond what bUnit can assert on markup: verified on the screenshots of the pull request. + +## Open questions + +- What the counts count. Answered: what the lists list (AC9), as the issue proposes, so that the headline, the panel + count and the "more" figure agree with one figure each. Today's finding counts (all active update findings, + active vulnerability findings of running containers, active derived-runtime findings of own images) leave the + dashboard. +- Hide *Own base runtime warnings* without a Docker Hub account and without a warning? Answered: yes, as proposed + (E4); the account condition is the one My Images uses (user name and token set). +- Update findings of observed images no container runs appear nowhere on the dashboard. Answered: accepted, as + proposed (E11). Because of it the all-clear text says `No updates available` instead of the issue's `No update + findings`, which would be untrue while such findings exist. +- Last activity format. Answered: the issue's `14.11.2026 09:42` ("server format, as today") is not today's + behavior; timestamps are UTC `yyyy-MM-dd HH:mm UTC` ([decision 0058](../../docs/decisions/0058-timestamps-are-shown-in-utc-with-an-explicit-suffix.md)), as the top bar shows them. +- Configuration hints. Answered: the issue names three alerts; the code has two (scanning disabled, Docker Hub + credentials missing for Docker Scout, [Vulnerabilities](../../docs/areas/vulnerabilities.md)); both stay. +- *Base Images* cell condition. Answered: the issue's "at least one base image is resolved" is not today's rule; + the cell keeps today's condition and figure (shared base images above 0) under the series' label `Base Images`. +- Position of the `Nothing to do` panel. Answered: the issue says "in the third column's place", the all-clear + mockup shows it and the scan panel full width; the spec follows the mockup (S8). +- #278. Answered: closed; the *Recent scans* description it concerned is removed with the table, and + `docs/areas/web-ui.md` holds no gap note for it. + +## Area documents + +- `docs/areas/web-ui.md`: the dashboard row of *Pages and routes* rewritten (headline counts, the three lists, the + last ten scans, the inventory counters); a new *Dashboard* subsection with the headline rules, the list contents, + limits, orders, footers and empty texts, the all-clear state, the scan strip and the inventory visibility rules; + the *General* sentence on scan status chips without the dashboard; the font sentence naming the inventory figures + instead of the metric cards. The document has about 4,200 words: the plan measures the addition against + `AREA_MAX_WORDS` and moves the dashboard into its own area document if it would pass it. From 8155e73bc1674c91b81b6892382a0eadcf35f274 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 12:32:27 +0000 Subject: [PATCH 03/28] Add spec and log --- specs/feature-453-dashboard-attention/log.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 89843692..778ab107 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -6,3 +6,4 @@ are quoted in full. | Date | Step | Member | Result | | ---- | ---- | ------ | ------ | | 2026-11-29 12:28 | 1 Intake | Orchestrator | RESULT: DONE — issue 453 (feature, open, label enhancement, no comments); dependencies 451 and 452 merged; branch claude/magical-bohr-d8uz9o off main fada378; work folder specs/feature-453-dashboard-attention | +| 2026-11-29 12:32 | 2a Spec | Lead | RESULT: DONE — spec.md written, 11 AC; decided the 3 open questions itself (count what is listed; hide runtime-warnings panel without Docker Hub account and no warning; non-running update findings not on dashboard) (opus/medium · 70,330 tokens · 9 tool uses · 36 s · 18 in · 2,419 out · 358,640 cache read · 70,080 cache write · 235,290 weighted) | From a342e3959106dddec0b85c555ee1765dbca94e5e Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 12:35:13 +0000 Subject: [PATCH 04/28] Add spec challenge notes --- specs/feature-453-dashboard-attention/log.md | 2 ++ specs/feature-453-dashboard-attention/spec.md | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 778ab107..34b2ebb5 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -7,3 +7,5 @@ are quoted in full. | ---- | ---- | ------ | ------ | | 2026-11-29 12:28 | 1 Intake | Orchestrator | RESULT: DONE — issue 453 (feature, open, label enhancement, no comments); dependencies 451 and 452 merged; branch claude/magical-bohr-d8uz9o off main fada378; work folder specs/feature-453-dashboard-attention | | 2026-11-29 12:32 | 2a Spec | Lead | RESULT: DONE — spec.md written, 11 AC; decided the 3 open questions itself (count what is listed; hide runtime-warnings panel without Docker Hub account and no warning; non-running update findings not on dashboard) (opus/medium · 70,330 tokens · 9 tool uses · 36 s · 18 in · 2,419 out · 358,640 cache read · 70,080 cache write · 235,290 weighted) | +| 2026-11-29 12:35 | 2a Spec challenge | Devil's Advocate | VERDICT: OBJECTIONS 0 major, 4 minor — (1) E6/S4: state which findings feed packages/fixed versions/severity; (2) N1: restore issue's 'no per-image vulnerability details beyond the lists' and check in AC10; (3) all-clear shown together with ScanningDisabled hint, other update states never count; (4) scan tooltip start time via TimestampFormatter (opus/medium · 94,564 tokens · 30 tool uses · 153 s · 54 in · 13,575 out · 1,718,370 cache read · 91,147 cache write · 535,562 weighted) | +| 2026-11-29 12:35 | 2a Challenge notes | Orchestrator | minor objections appended verbatim to spec.md | diff --git a/specs/feature-453-dashboard-attention/spec.md b/specs/feature-453-dashboard-attention/spec.md index b352ea4f..550a5b31 100644 --- a/specs/feature-453-dashboard-attention/spec.md +++ b/specs/feature-453-dashboard-attention/spec.md @@ -174,3 +174,34 @@ containers of [Docker instances](../../docs/areas/docker-instances.md) — the s the *General* sentence on scan status chips without the dashboard; the font sentence naming the inventory figures instead of the metric cards. The document has about 4,200 words: the plan measures the addition against `AREA_MAX_WORDS` and moves the dashboard into its own area document if it would pass it. + +## Challenge notes + +Devil's Advocate, mode `spec`, feature #453 (parent #450). I checked /home/user/DockerUpdateGuard/specs/feature-453-dashboard-attention/spec.md against both issues, the code and the documents. + +**The Lead's deviations hold up against the code:** +- **Two config alerts, not three:** `VulnerabilityConfigurationHintKind` has only `None`, `ScanningDisabled` and `DockerHubCredentialsMissing = 3` (value 2 is gone). `VulnerabilityConfigurationHintResolver.Resolve` produces only these. docs/areas/vulnerabilities.md:200-205 lists exactly these two. +- **UTC last-activity format:** `TimestampFormatter` uses `"yyyy-MM-dd HH:mm 'UTC'"` (UI/TimestampFormatter.cs:15). The top bar formats with it (MainLayout.razor.cs, `GetLatestScanLabel`). Decision 0058 is accepted. The issue's `14.11.2026 09:42` is not today's behavior. +- **Base Images cell condition:** today's cards use `BaseImageCount > 0` (Dashboard.razor:82). That count is `GetSharedBaseImageEntriesAsync(...).Count`, which needs at least two uses (ApplicationViewService.cs:463). The issue's "at least one resolved" would change a computed value, which #450 forbids. +- **Nothing-to-do text:** `ActiveUpdateFindingCount` counts all active update findings (ApplicationViewService.cs:1817), not only those of running containers. So `No update findings` could be false under E11, and `No updates available` is the honest text. +- **Nothing-to-do position:** in docs/ui-concept/flat-refresh/mockups/dashboard-all-clear.html:43-48, both panels sit in one `flex: 1 1 300px` column, the only item in the row, so they are full width and stacked. S8 matches the mockup. +- **Other checks:** + - The `--dug-*` tokens the scope names exist in wwwroot/app.css. + - `SeverityBar` folds `OtherCount` into low, which matches E6. + - `ScanRunStatus` has exactly the five statuses plus `NotSet`, which matches E8. + - `MapScanRun` gives a null `SubjectName` when a run has neither image nor instance, which matches E7. + - docs/areas/web-ui.md has 4,178 words against `AREA_MAX_WORDS = 5000` and holds no note on #278. + +**Objections** + +1. `minor` — **E6/S4 leave open which findings feed the packages and fixed versions.** `CreateVulnerabilityOverviewItem` (ApplicationViewService.cs:1142-1180) builds severity, CVSS, `AffectedPackages` and `FixedVersions` from every active finding of the advisory. That includes findings on image versions that no current container runs. `AffectedContainerCount` alone is limited to current containers. With "as the Vulnerabilities page shows it", a dashboard row can show a package, a fixed version or a higher severity (and a severity-bar segment) that comes only from a retired image. Instruction for the Lead: state in E6 that severity, score, packages and fixed versions come from all active findings of the advisory, as the overview computes them (or limit them to the running ones, if that is wanted). Instruction for the Tester: include a fixture where the advisory also has a finding on a non-running image version, and assert the chosen behavior. Why minor: it is a clarity gap on a rare data shape, not the wrong feature. + +2. `minor` — **N1 drops a requirement from the issue.** Issue §8 says "no per-image vulnerability details beyond what the lists need". N1 and AC10 only forbid resource usage. `GetVulnerabilityOverviewCoreAsync` (ApplicationViewService.cs:1111-1134) loads every active finding with `ImageVersion.ObservedImages` and builds `AffectedImages` for every advisory. `GetRuntimeContainersCoreAsync` (ApplicationViewService.cs:413) loads resource histories. Reusing either one as is would break the issue's rule or N1. Instruction for the Lead: add the issue's sentence to N1. Instruction for the plan: reuse the per-advisory and per-container evaluation, not the full page loaders, and AC10 should check that neither the affected-image list nor resource histories are built. Why minor: N1 already demands shared evaluation; this only restores a dropped constraint. + +3. `minor` — **The all-clear state does not say what happens when nothing was evaluated.** + - With `Vulnerabilities:Enabled = false`, the page will show `Everything is up to date.` in the success color, the empty text "No vulnerabilities in running containers." and possibly the `Nothing to do` panel. + - The same happens when every container's update check is `Failed`, `No tag data` or `Manual review required` (`FormatUpdateAssessmentStatus`, ApplicationViewService.cs:212-224). Only `Update available` is counted. + + Instruction for the Lead: state in S8 (or a new E-case) that the all-clear headline and panel are shown together with the *Scanning disabled* hint, and that containers in other update states never count. Instruction for the Tester: add a render test for the all-clear state with `ScanningDisabled` that asserts both the hint and the headline. Why minor: this is the issue's design and the hint covers the case; the spec should make it explicit and tested, not change it. + +4. `minor` — **S6/AC6 do not name the format of the segment tooltip's start time.** Instruction for the Dev: format it with `TimestampFormatter.Format` (UTC, decision 0058), as the old table did (Dashboard.razor:240). AC6 should name the tooltip text. Why minor: it follows from the general rule in web-ui.md, so the Dev can apply it without a plan change. From 0911efd40d4c399c2d1b009779b9d8dda6bbc5fc Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 12:42:38 +0000 Subject: [PATCH 05/28] Add plan, tasks and decision 0080 --- ...ners-advisories-and-own-images-it-lists.md | 40 +++ docs/decisions/README.md | 1 + specs/feature-453-dashboard-attention/log.md | 1 + specs/feature-453-dashboard-attention/plan.md | 249 ++++++++++++++++++ specs/feature-453-dashboard-attention/spec.md | 74 +++--- .../feature-453-dashboard-attention/tasks.md | 18 ++ 6 files changed, 343 insertions(+), 40 deletions(-) create mode 100644 docs/decisions/0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md create mode 100644 specs/feature-453-dashboard-attention/plan.md create mode 100644 specs/feature-453-dashboard-attention/tasks.md diff --git a/docs/decisions/0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md b/docs/decisions/0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md new file mode 100644 index 00000000..e75a0001 --- /dev/null +++ b/docs/decisions/0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md @@ -0,0 +1,40 @@ +# 0080: The dashboard counts the containers, advisories and own images it lists + +- **Status:** Proposed +- **Date:** 2026-11-29 +- **Area:** Web UI +- **Source:** Issue #453 +- **Supersedes:** — + +## Context + +The dashboard of the flat refresh (#450) lists concrete items under a headline sentence: running containers with an +available update, advisories that affect running containers, and own images with a base runtime alert. Until now it +showed counts of findings: every active update finding (of all types, also of images no container runs), the active +vulnerability findings of running containers (one advisory counted once per image version), and the active +derived-runtime findings of own images. A finding count beside a list of other things cannot agree with the list's +length or with its "N more" link. The issue left the choice to the spec. + +## Options considered + +1. **Count what is listed (chosen)** — the headline, the panel count and the "more" figure are one number per list; + update findings of images no container runs and findings of image versions no container runs no longer appear on + the dashboard, only on Observed Images, My Images and Vulnerabilities. +2. **Keep the finding counts and give each list a second figure for its length** — nothing disappears from the + dashboard, but every panel shows two numbers that differ for reasons the user cannot see there, and the headline + names neither. + +## Decision + +The dashboard's counts are the number of running containers in the update state *Update available*, the number of +distinct active advisories affecting at least one running container, and the number of own images with a base +runtime alert; its lists show the first entries of the same sets, with the values the Runtime Containers, +Vulnerabilities and My Images pages compute for them. The rules are stated in [Web UI](../areas/web-ui.md). + +## Consequences + +The headline can read *Everything is up to date.* while an observed image no container runs has an update finding; +the all-clear text therefore speaks of available updates, not of update findings. An advisory row shows the severity, +packages and fixed versions of all its active findings, as the Vulnerabilities page does, also when some come from +image versions no container runs. Showing findings of non-running images on the dashboard again needs a list of its +own, not a change of these counts. diff --git a/docs/decisions/README.md b/docs/decisions/README.md index c30ec413..f421fdc1 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -140,4 +140,5 @@ once in the [area document](../areas/README.md) of the record's area, and the re | [0077](0077-the-dark-theme-tokens-apply-to-the-whole-document-while-the-layout-is-dark.md) | The dark theme's tokens apply to the whole document while the layout is dark | Accepted | 2026-11-28 | | [0078](0078-mudblazor-elevation-shadows-are-switched-off-in-the-theme.md) | MudBlazor elevation shadows are switched off in the theme | Accepted | 2026-11-28 | | [0079](0079-statuses-map-to-tones-in-one-mapping-beside-the-chip-colors-of-unconverted-pages.md) | Statuses map to tones in one mapping, beside the chip colors of unconverted pages | Accepted | 2026-11-28 | +| [0080](0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md) | The dashboard counts the containers, advisories and own images it lists | Proposed | 2026-11-29 | \ No newline at end of file diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 34b2ebb5..4d24fa01 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -9,3 +9,4 @@ are quoted in full. | 2026-11-29 12:32 | 2a Spec | Lead | RESULT: DONE — spec.md written, 11 AC; decided the 3 open questions itself (count what is listed; hide runtime-warnings panel without Docker Hub account and no warning; non-running update findings not on dashboard) (opus/medium · 70,330 tokens · 9 tool uses · 36 s · 18 in · 2,419 out · 358,640 cache read · 70,080 cache write · 235,290 weighted) | | 2026-11-29 12:35 | 2a Spec challenge | Devil's Advocate | VERDICT: OBJECTIONS 0 major, 4 minor — (1) E6/S4: state which findings feed packages/fixed versions/severity; (2) N1: restore issue's 'no per-image vulnerability details beyond the lists' and check in AC10; (3) all-clear shown together with ScanningDisabled hint, other update states never count; (4) scan tooltip start time via TimestampFormatter (opus/medium · 94,564 tokens · 30 tool uses · 153 s · 54 in · 13,575 out · 1,718,370 cache read · 91,147 cache write · 535,562 weighted) | | 2026-11-29 12:35 | 2a Challenge notes | Orchestrator | minor objections appended verbatim to spec.md | +| 2026-11-29 12:42 | 2b Plan | Lead | RESULT: DONE — tier standard, no security areas; spec closed (Approved by Lead), plan.md, tasks.md (3 groups), decision 0080 (opus/medium · 160,732 tokens · 42 tool uses · 437 s · 80 in · 48,710 out · 6,858,586 cache read · 106,804 cache write · 1,440,129 weighted · continued) | diff --git a/specs/feature-453-dashboard-attention/plan.md b/specs/feature-453-dashboard-attention/plan.md new file mode 100644 index 00000000..b0226b38 --- /dev/null +++ b/specs/feature-453-dashboard-attention/plan.md @@ -0,0 +1,249 @@ +# Plan: Dashboard that lists what needs attention + +Source: Issue #453 | [spec.md](spec.md) +Tier: standard — the dashboard's content and counts change for users; no security control is created, changed or removed. +Security areas touched: none + +## Problem / root cause + +See [spec.md](spec.md), *Problem*. + +## Verified facts + +| # | Claim | Evidence | Status | +| - | ----- | -------- | ------ | +| 1 | "Running containers" are the current snapshots, the set every page and the dashboard use | `GetLatestContainerSnapshotsAsync` (`UI/ApplicationViewService.cs:665`); `docs/areas/docker-instances.md:141-145` | confirmed | +| 2 | The update state text `Update available` comes from `UpdateAssessmentStatus.UpdateAvailable` | `FormatUpdateAssessmentStatus` (`ApplicationViewService.cs:212`) | confirmed | +| 3 | Resolved and available tags fall back to the tag candidates of the snapshot's update findings when the snapshot fields are empty | `MapRuntimeContainerListItem` (`ApplicationViewService.cs:1212`), `LoadLatestUpdateFindingsAsync` (`:1281`) | confirmed | +| 4 | `GetRuntimeContainersCoreAsync` loads resource histories, base image relationships and vulnerability summaries | `ApplicationViewService.cs:409-440` | confirmed | +| 5 | The overview builds each advisory from all its active findings, including `Include(ImageVersion.ObservedImages)` for the affected images; only `AffectedContainerCount` depends on current containers | `GetVulnerabilityOverviewCoreAsync`, `CreateVulnerabilityOverviewItem` (`:1109-1180`) | confirmed | +| 6 | An own image's base runtime alert is its newest active `DerivedBaseRuntimeUpdate` finding, else that of a current container of its repository | `LoadObservedImageListAsync` (`:1402`), `MapObservedImageListItem` (`:1350`), `CreateRuntimeAlertLookup`/`CreateObservedAlertLookup` (`:283-310`) | confirmed | +| 7 | `GetScanHistoryCoreAsync(10)` returns the newest runs first; the top bar's last activity is element 0 of the same query | `:540-552`; `MainLayout.razor.cs:380-390` | confirmed | +| 8 | Protected assets in the top bar = manual observed + own images + current containers | `MainLayout.razor.cs:368-376` | confirmed | +| 9 | Timestamps are formatted `yyyy-MM-dd HH:mm UTC` | `UI/TimestampFormatter.cs:15`; decision 0058 | confirmed | +| 10 | Two configuration hints exist | `VulnerabilityConfigurationHintKind.cs` | confirmed | +| 11 | `VulnerabilitySeverity`: `NotSet` 0 < `Low` < `Medium` < `High` < `Critical` 4 | `DockerUpdateGuard.Data/Entities/VulnerabilitySeverity.cs` | confirmed | +| 12 | `SeverityBar` takes a `VulnerabilitySeveritySummaryViewData`, folds `OtherCount` into low and renders nothing when empty | `Components/Common/SeverityBar.razor(.cs)` | confirmed | +| 13 | `SectionPanel` has `Title`, `Meta`, `HeaderContent`, `ChildContent`, `Flush` | `Components/Common/SectionPanel.razor.cs` | confirmed | +| 14 | `MetricGridSkeleton` is used only by the dashboard; the `metric-card`/`hero-panel` rules are asserted by `AppStylesheetTests` | grep over `src/` | confirmed | +| 15 | `DbContext.Set()` is virtual, and the context's `DbSet` properties call it | to verify: the Tester's `SetRecordingDbContext` overrides `Set()` and its test sees the sets `DockerUpdateGuardDbContext.cs:30-100` asks for (step 5) | unverified | +| 17 | The EF Core SQLite provider cannot translate an `ORDER BY` on a `DateTimeOffset` column, which `GetScanHistoryCoreAsync` uses | EF Core documentation, *SQLite Database Provider - Limitations* | confirmed | +| 16 | #278 is closed and `web-ui.md` has no gap note for it | `gh api …/issues/278`; grep | confirmed | + +## Tests per criterion + +| AC | Test(s) | Test file | +| -- | ------- | --------- | +| AC1 | `DashboardTextFormatterGetHeadlineSegmentsCountCombinationReturnsSentence` (DataRows: every zero/non-zero combination of the three counts, each singular, `needs` for one part of 1, (1,1,1), (0,0,0)); `DashboardTextFormatterGetHeadlineSegmentsTonesOnlyTheParts`; `DashboardWithCountsRendersHeadlineWithColoredParts` | `DashboardTextFormatterTests.cs`, `DashboardRenderTests.cs` | +| AC2 | `DashboardTextFormatterFormatSubLineWithScanReturnsAssetsInstancesAndUtcTime`; `DashboardTextFormatterFormatSubLineWithoutScanReturnsNoScansYet`; `DashboardTextFormatterFormatSubLineSingleInstanceAndAssetUsesSingular` | `DashboardTextFormatterTests.cs` | +| AC3 | `ApplicationViewServiceDashboardUpdatesListsUpdateAvailableContainersInOrderAsync` (7 qualifying, 5 listed, order with case ties, alias resolved from a tag candidate); `ApplicationViewServiceDashboardUpdatesIgnoresOtherUpdateStatesAsync` (E12); `DashboardTextFormatterFormatCurrentTagWithAliasAppendsResolvedVersion`; `DashboardTextFormatterFormatFooterLinkReturnsRemainderOrOpenText`; `DashboardUpdatesPanelRendersRowsLinksAndFooter` (DataRows 7 and 3 total); `DashboardUpdatesPanelWithoutAvailableTagRendersCurrentTagOnly`; `DashboardUpdatesPanelWithoutEntriesRendersEmptyTextWithoutCount` | `ApplicationViewServiceDashboardTests.cs`, `DashboardTextFormatterTests.cs`, `DashboardRenderTests.cs` | +| AC4 | `ApplicationViewServiceDashboardVulnerabilitiesListsRunningAdvisoriesInOrderAsync` (every sort key, no score last, `NotSet` last, limit 4); `ApplicationViewServiceDashboardVulnerabilitiesTakeValuesFromAllActiveFindingsAsync` (E6: a retired image's finding adds package, fixed version and severity; an advisory only on a retired image is not listed); `DashboardTextFormatterFormatVulnerabilityTitleWithoutPackagesReturnsAdvisoryId`; `DashboardTextFormatterFormatVulnerabilityDetailReturnsFixAndContainerCount`; `DashboardVulnerabilitiesPanelRendersBarRowsAndAccessibleIdentifier`; `DashboardVulnerabilitiesPanelWithoutEntriesRendersEmptyTextWithoutBar` | same three files | +| AC5 | `ApplicationViewServiceDashboardRuntimeWarningsListsOwnImagesWithAlertAsync` (manual image with alert excluded, runtime-derived alert included, order, limit 5); `DashboardRuntimeWarningsPanelRendersRowsAndFooter`; `DashboardRuntimeWarningsPanelWithoutAccountAndWarningsIsHidden`; `DashboardRuntimeWarningsPanelWithAccountAndNoWarningsRendersEmptyText` | `ApplicationViewServiceDashboardTests.cs`, `DashboardRenderTests.cs` | +| AC6 | `DashboardScanStripFormatterGetStatusCountsReturnsCountsAboveZeroInStatusOrder`; `DashboardScanStripFormatterFormatStripLabelJoinsCountsWithCommas`; `DashboardScanStripFormatterFormatSegmentTitleReturnsTypeTargetStatusAndUtcStart` (with and without target); `DashboardScanStripFormatterGetSegmentCssNameMapsStatus` (five statuses, `NotSet`); `DashboardScanStripFormatterFindLatestProblemScanReturnsNewestFailedOrPartialWithMessage`; `DashboardScanStripFormatterFindLatestProblemScanWithoutMessageReturnsNull`; `DashboardScanStripFormatterFormatProblemScanLineWithoutTargetReturnsMessageOnly`; `DashboardScanPanelRendersStripCountsProblemLineAndLink`; `DashboardScanPanelWithoutRunsRendersEmptyText`; `AppStylesheetDashboardScanSegmentsUseStatusTokens` | `DashboardScanStripFormatterTests.cs`, `DashboardRenderTests.cs`, `AppStylesheetDashboardTests.cs` | +| AC7 | `DashboardInventoryStripRendersCellsWithVisibilityRules` (DataRows: account yes/no × shared base images 0/2); `DashboardGetMetricNavigationTargetKnownMetricReturnsExpectedRoute` (adapted) | `DashboardRenderTests.cs`, `DashboardTests.cs` | +| AC8 | `DashboardWithoutFindingsRendersNothingToDoPanel`; `DashboardWithoutFindingsAndScanningDisabledRendersHintAndAllClear` | `DashboardRenderTests.cs` | +| AC9 | `ApplicationViewServiceDashboardCountsEqualListedSetsAsync`; `DashboardHeadlineCountsEqualPanelCounts` | `ApplicationViewServiceDashboardTests.cs`, `DashboardRenderTests.cs` | +| AC10 | `DashboardSkeletonRendersHeadlinePanelsAndStrip`; `DashboardWhileLoadingRendersDashboardSkeleton`; `DashboardRefreshSignalReloadsDashboard`; `DashboardRendersExternalTextAsText`; `DashboardWithPersistedStateDoesNotLoadAgain`; `ApplicationViewServiceDashboardRequestsNoResourceSampleSetsAsync`; kept: `DashboardLoadFailureShowsFixedErrorAndLogs`, `DashboardFailedRefreshKeepsDashboardAndLogs`, `DashboardWithDisabledVulnerabilityScanningRendersInfoBanner`, `DashboardWithConfiguredVulnerabilityProviderRendersNoBanner` | `DashboardSkeletonTests.cs`, `DashboardRenderTests.cs`, `DashboardPersistentStateTests.cs`, `ApplicationViewServiceDashboardTests.cs` | +| AC11 | check: the Reviewer reads `docs/areas/web-ui.md` against the built page in step 8 | — | + +S11 and N3 are verified on the before/after screenshots of the pull request in step 9 (spec, *Out of scope*). + +## Approach + +**Service** (`GetDashboardAsync`, inside its existing `ExecuteSerializedAsync`). It keeps the counts of the inventory, +the hint and `RecentScans`, drops the three finding counts and the per-image-version severity sum, and adds three +private steps over the already loaded current snapshots (private constants `DashboardUpdateLimit = 5`, +`DashboardVulnerabilityLimit = 4`, `DashboardRuntimeWarningLimit = 5`; the view data holds only the shown entries, N2): + +1. *Updates*: snapshots with `UpdateAssessmentStatus.UpdateAvailable`, ordered by container name, instance name + (`StringComparer.OrdinalIgnoreCase`), container id (ordinal); count = all of them. For the first five only, + `LoadLatestUpdateFindingsAsync` with their ids gives the tag candidates; the tags come from a new private static + `ResolveRuntimeContainerTags(ContainerSnapshot entity, List tagCandidates)` returning + `(string? ResolvedVersionTag, string? AvailableUpdateVersionTag)`, extracted from `MapRuntimeContainerListItem`, + which calls it too. No resource history, base image or vulnerability load. +2. *Vulnerabilities*: active `VulnerabilityFindings`, `AsNoTracking`, **without** includes; grouped by `AdvisoryId` + (`OrdinalIgnoreCase`) as the overview does; container count per group by a new private static + `CountAffectedContainers(IEnumerable advisoryFindings, Dictionary containerCountsByImageVersion)` + (sum over distinct image version ids), packages and fixed versions by new private static + `SelectAffectedPackages(IEnumerable advisoryFindings)` and + `SelectFixedVersions(IEnumerable advisoryFindings)`, all three extracted from + `CreateVulnerabilityOverviewItem`, which calls them. Groups with a count above 0 are kept; severity = max, + score = max; order severity desc, score desc (null last), count desc, advisory id `OrdinalIgnoreCase`. + `VulnerabilityAdvisorySeveritySummary` counts the kept groups per severity (`NotSet` → `OtherCount`). The + overview's own order and affected images stay unchanged. +3. *Runtime warnings*: `LoadObservedImagesAsync(RegistrationSource.Discovery)`, + `LoadDerivedBaseRuntimeFindingsAsync` and the two alert lookups as `LoadObservedImageListAsync` builds them; the + alert by a new private static + `FindBaseRuntimeAlert(ObservedImage entity, Dictionary observedAlertLookup, Dictionary runtimeAlertLookup)`, + extracted from `MapObservedImageListItem`, which calls it. Images with an alert, ordered by name + (`OrdinalIgnoreCase`), then id. + +The resource bound of N1 is observed through `DbContext.Set()`: `SetRecordingDbContext` records every +entity type asked for, and the test asserts that neither resource sample type is; the affected-image restriction +holds by signature (`DashboardVulnerabilityItemData` has no images, and the query has no include). + +**Text**: `DashboardTextFormatter` and `DashboardScanStripFormatter` (*Signatures*) compose every user-visible text, +so the page only binds. Headline connectors: two parts ` and `, three `, ` and ` and `; closing ` needs attention.` +for one part of count 1, else ` need attention.`; parts take `StatusTone.Warning` (updates, runtime warnings) or +`StatusTone.Danger`, connectors `StatusTone.Neutral`, the all-clear sentence `StatusTone.Success`. Sub line +`{assets} on {instances} · last activity {time|no scans yet}`. Footer `{total − shown} more in {page}` when total > +shown, else `Open {page}`. Scan counts in the order Succeeded, Running, Pending, Partial, Failed, text +`{n} {status lower-case}`; segment CSS names `succeeded`, `partial`, `failed`, `running`, else `pending`; segment +title `{Type} · {SubjectName} · {Status} · {TimestampFormatter.Format(StartedAtUtc)}`, the subject left out with its +separator when empty; problem run = first of the list with status `Failed` or `Partial` and a non-empty +`ErrorMessage`. + +**Layout** (the issue's *Scope* 1–7 and the mockups give sizes and tokens): `h1.dug-dashboard__headline` with +`span.dug-dashboard__headline-part--{tone}` per segment; `p.dug-dashboard__subline`; the two existing `MudAlert` +hints unchanged; `div.dug-dashboard__columns` holding `div.dug-dashboard__column` ×3 in DOM order Updates, +Vulnerabilities, (Runtime warnings, Scans) — the DOM order is the stacking order (S11); in the all-clear state one +full-width column with `Nothing to do` and Scans. Each panel is a `SectionPanel` whose `HeaderContent` is +`span.dug-dashboard__count--{warning|danger}` (absent at 0); lists are `ul.dug-dashboard__list > li > a.dug-dashboard__row` +with `.dug-dashboard__row-title`, `.dug-dashboard__row-aside` (instance name, or a `StatusChip` with +`StatusToneFormatter.GetSeverityTone`), `.dug-dashboard__row-detail` (the available tag in +`.dug-dashboard__row-target`); the advisory id in a `span.dug-visually-hidden` inside the row link; footer +`a.dug-dashboard__footer-link`; empty text `p.dug-dashboard__empty`. Scans: `div.dug-scan-strip[role=img][aria-label]` +of `span.dug-scan-strip__segment--{css}[title]`, `p.dug-dashboard__scan-counts` joined with ` · ` (failed count in +`strong.dug-dashboard__scan-failed`), `p.dug-dashboard__scan-problem`. Inventory: `section.dug-inventory` of +`a.dug-inventory__cell` with `.dug-inventory__label`, `.dug-inventory__value`; labels `My Images`, `Observed Images`, +`Runtime Containers`, `Docker Instances`, `Base Images` (`GetMetricNavigationTarget` keys renamed accordingly, its +`Vulnerabilities` case removed as unused). Skeleton: new `DashboardSkeleton` with `.dug-dashboard-skeleton__headline`, +three `.dug-dashboard-skeleton__panel`, one `.dug-dashboard-skeleton__strip`; `MetricGridSkeleton` and +`PageHeaderSkeleton`'s use on the dashboard go. New rules in `wwwroot/app.css` use only `--dug-*` tokens and include +`.dug-visually-hidden`. The old `hero-panel`, `metric-*` and `summary-*` rules stay for #459, which removes the old +styles (`AppStylesheetTests` asserts them). + +Early draft PR: no + +## Options considered + +1. Counts: count what is listed (chosen) vs. keep finding counts with a second figure per list — decision 0080. +2. Data: reuse the page loaders (`GetRuntimeContainersCoreAsync`, `GetVulnerabilityOverviewCoreAsync`, + `LoadObservedImageListAsync`) and trim their output — lost: they load resource histories, affected images, + scan statuses and vulnerability summaries the dashboard does not show (N1); extracting the per-item helpers + shares the evaluation without that cost. +3. Advisory values: from all active findings (chosen, as the Vulnerabilities page the row links to) vs. only from + running image versions — lost: the row would disagree with the page it opens (spec, *Challenge* 1). +4. Seam for N1: `SqliteTestDatabase` with a command-text interceptor — lost: SQLite cannot order by + `DateTimeOffset`, which the scan history query does; `SetRecordingDbContext` works on InMemory. + +## Affected projects and types + +| Project | Type / file | Change | +| ------- | ----------- | ------ | +| DockerUpdateGuard | `UI/DashboardViewData.cs` | members changed (*Signatures*) | +| DockerUpdateGuard | `UI/DashboardUpdateItemData.cs`, `UI/DashboardVulnerabilityItemData.cs`, `UI/DashboardRuntimeWarningItemData.cs`, `UI/DashboardHeadlineSegmentData.cs`, `UI/DashboardScanCountData.cs` | new | +| DockerUpdateGuard | `UI/DashboardTextFormatter.cs`, `UI/DashboardScanStripFormatter.cs` | new | +| DockerUpdateGuard | `UI/ApplicationViewService.cs` | `GetDashboardAsync` and the extracted helpers | +| DockerUpdateGuard | `Components/Pages/Dashboard.razor`, `Dashboard.razor.cs` | rewritten | +| DockerUpdateGuard | `Components/Common/DashboardSkeleton.razor` | new (markup only) | +| DockerUpdateGuard | `Components/Common/MetricGridSkeleton.razor(.cs)` | deleted | +| DockerUpdateGuard | `wwwroot/app.css` | new dashboard rules | + +## Signatures (for the Dev's skeleton) + +DashboardViewData keeps its five inventory counts, VulnerabilityScanningEnabled, VulnerabilityConfigurationHint and +RecentScans, and gains: + +- `DashboardViewData.UpdateCount` — public int, get/set +- `DashboardViewData.Updates` — public IReadOnlyList, get/set, = [] +- `DashboardViewData.VulnerabilityCount` — public int, get/set +- `DashboardViewData.Vulnerabilities` — public IReadOnlyList, get/set, = [] +- `DashboardViewData.VulnerabilityAdvisorySeveritySummary` — public VulnerabilitySeveritySummaryViewData, get/set, + = new() +- `DashboardViewData.RuntimeWarningCount` — public int, get/set +- `DashboardViewData.RuntimeWarnings` — public IReadOnlyList, get/set, = [] + +Deleted: its members ActiveUpdateFindingCount, OwnImageBaseRuntimeWarningCount, ActiveVulnerabilityFindingCount and +VulnerabilitySeveritySummary. + +New classes in DockerUpdateGuard.UI, one file each, auto-properties with public getters and setters (JSON +persistence), non-null strings initialized to string.Empty and lists to []: + +- `public class DashboardUpdateItemData` — Guid DockerInstanceId, string ContainerId, string ContainerName, string + DockerInstanceName, string CurrentTag, string? ResolvedVersionTag, string? AvailableUpdateVersionTag +- `public class DashboardVulnerabilityItemData` — string AdvisoryId, string Severity, decimal? CvssScore, + IReadOnlyList AffectedPackages, IReadOnlyList FixedVersions, int AffectedContainerCount +- `public class DashboardRuntimeWarningItemData` — Guid Id, string Name, string BaseRuntimeAlertSummary +- `public class DashboardHeadlineSegmentData` — string Text, StatusTone Tone +- `public class DashboardScanCountData` — string Status, int Count + +- `public static class DashboardTextFormatter` +- `public static IReadOnlyList GetHeadlineSegments(int updateCount, int runtimeWarningCount, int vulnerabilityCount)` +- `public static string FormatCount(int count, string singular, string plural)` +- `public static string FormatSubLine(DashboardViewData dashboard)` +- `public static string FormatFooterLink(int totalCount, int shownCount, string pageName)` +- `public static string FormatCurrentTag(DashboardUpdateItemData item)` +- `public static string FormatVulnerabilityTitle(DashboardVulnerabilityItemData item)` +- `public static string FormatVulnerabilityDetail(DashboardVulnerabilityItemData item)` + +- `public static class DashboardScanStripFormatter` +- `public static IReadOnlyList GetStatusCounts(IReadOnlyList scans)` +- `public static string FormatCountText(DashboardScanCountData count)` +- `public static string FormatStripLabel(IReadOnlyList counts)` +- `public static string FormatSegmentTitle(ScanHistoryItemData scan)` +- `public static string GetSegmentCssName(string status)` +- `public static ScanHistoryItemData? FindLatestProblemScan(IReadOnlyList scans)` +- `public static string FormatProblemScanLine(ScanHistoryItemData scan)` + +DashboardSkeleton is a markup-only component (no code-behind) whose skeleton is an empty file. Deleted: the +MetricGridSkeleton component, both files. Names were checked against *Writing code*: no nested type, at most three +parameters, no parameter named after a keyword. + +## Test files + +New: `src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs`, `DashboardScanStripFormatterTests.cs`, +`ApplicationViewServiceDashboardTests.cs`, `DashboardSkeletonTests.cs`, `DashboardPersistentStateTests.cs`, +`AppStylesheetDashboardTests.cs`, and the double `Data/SetRecordingDbContext.cs` (a `DockerUpdateGuardDbContext` +whose `Set()` override records the requested entity types). Adapted: `DashboardRenderTests.cs`. + +Existing test code on changed signatures, all adapted by the Tester in step 5: + +- `DashboardRenderTests.cs`: `DashboardRecentScansDescriptionNamesOnlyRecordedRunTypes` and + `DashboardRecentScanStatusChipShowsStatusColorAsync` deleted (section gone); `DashboardWithConfiguredAccountRendersMetricTiles`, + `DashboardWithSharedBaseImagesRendersSharedBaseImagesLabelsAsync` and `DashboardWithRecentScanRendersStartedInUtcAsync` + replaced by the AC7 and AC2/AC6 tests; the deleted view-data members leave its initializers. +- `ApplicationViewServiceTests.cs`: `ApplicationViewServiceDashboardReturnsAggregateCountsAsync` (asserts the new + counts of its seed) and `ApplicationViewServiceDashboardExcludesFindingsForInactiveRuntimeImageVersionsAsync` + (`VulnerabilityCount` 1, advisory summary without the retired critical one). +- `DashboardTests.cs`: DataRow `Shared Base Images` → `Base Images`. +- `MetricGridSkeletonTests.cs`: deleted. + +Files no unit test can cover: none. + +## Areas + +- `docs/areas/web-ui.md` (+480 words; about 4,178 now, so about 4,660 against `AREA_MAX_WORDS` 5000: no split): the + dashboard row of *Pages and routes*; a new *Dashboard* subsection under *Behavior* with the spec's rules (headline, + sub line, the three lists with limits, orders, row content, links, footers and empty texts, the hidden runtime + panel, the all-clear state, the scan strip and its texts, the inventory cells); *General*: the scan status chip + sentence without the dashboard; *Light and dark mode*: "the figures of the dashboard's inventory strip" instead of + "metric cards"; *Related decisions*: 0080. + +## Documentation updates + +- `docs/areas/web-ui.md` — as *Areas* (Dev). +- `docs/UNIT_TESTS.md` (Test doubles +16 words): `SetRecordingDbContext` (`Data/`) — a database that records which + entity sets the code asks for; and the bUnit example's assert message no longer says "metric tile" (Tester). +- `docs/ARCHITECTURE.md`: none (section 9 names no dashboard content). No changelog exists. + +## Architecture check + +Pages read only through `IApplicationViewService` (section 9): kept, the interface is unchanged. The dashboard keeps +`DashboardRefreshState` and its persisted state key. No guarantee of `.squad/project.md` is touched. + +## Security considerations + +- [x] No limits on parsed input. +- [x] Exceptions: a load failure keeps the existing fixed text `Loading the dashboard failed: ` + (`PageLoader`); no new path reaches the user. Texts from Docker, registries and scanners are bound as Razor text + (encoded), never as `MarkupString` (E10). + +## Decision records + +- `docs/decisions/0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md` (Proposed) + +## Out of scope / follow-ups + +- Removing the old dashboard styles and their `AppStylesheetTests`: #459. +- `docs/ui-concept/README.md` (an older concept describing metric tiles) stays as a historical concept. diff --git a/specs/feature-453-dashboard-attention/spec.md b/specs/feature-453-dashboard-attention/spec.md index 550a5b31..7041b92d 100644 --- a/specs/feature-453-dashboard-attention/spec.md +++ b/specs/feature-453-dashboard-attention/spec.md @@ -1,7 +1,7 @@ # Spec: Dashboard that lists what needs attention Source: Issue #453 (part of #450) -Status: Draft +Status: Approved by Lead ## Problem @@ -47,8 +47,9 @@ containers of [Docker instances](../../docs/areas/docker-instances.md) — the s Images shows it, and opens `/my-images/{id}`. The footer reads `{n} more in My Images` (to `/my-images`) when more than 5 qualify; otherwise there is no footer. - S6: *Last 10 scans* shows one segment per recorded run of the ten most recent, newest on the left, colored by - status (Succeeded, Partial, Failed, Running, Pending as the issue's *Scope* names), each with a tooltip naming - type, target, status and start time; below it one line with the counts per status above 0 in the order + status (Succeeded, Partial, Failed, Running, Pending as the issue's *Scope* names), each with a tooltip + `{type} · {target} · {status} · {start}` (start as `yyyy-MM-dd HH:mm UTC`, the target left out with its separator + when the run has none); below it one line with the counts per status above 0 in the order succeeded, running, pending, partial, failed, joined with ` · ` (`8 succeeded · 1 partial · 1 failed`, the failed count emphasized in the danger color). The strip is announced as an image whose name lists the same counts joined with `, `. When one of the ten runs is `Failed` or `Partial` and has an error message, one more line names the @@ -81,8 +82,10 @@ containers of [Docker instances](../../docs/areas/docker-instances.md) — the s warnings* panel is not shown. With such warnings (own images kept from an earlier configuration) it is shown. - E5: A container with `Update available` but no available tag: its second line shows the current tag only, without arrow. -- E6: An advisory with findings of different severities or scores counts once, with its highest severity and - highest score, as the Vulnerabilities page shows it; an unknown severity counts as low in the bar. +- E6: An advisory counts once. Its severity, score, packages and fixed versions come from all its active findings, + also those of image versions no container runs, as the Vulnerabilities page computes them (highest severity, + highest score); only its container count and whether it is listed depend on running containers. An unknown + severity counts as low in the bar. - E7: The newest failed or partial run has no target (a vulnerability refresh): its line shows the error message alone. A failed or partial run without an error message is skipped for that line; with none left, the line is absent. @@ -95,12 +98,17 @@ containers of [Docker instances](../../docs/areas/docker-instances.md) — the s - E11: Update findings of observed images no container runs, and vulnerabilities of image versions no container runs, appear on no dashboard panel and in no headline count (Observed Images, My Images and Vulnerabilities still show them). +- E12: Nothing was evaluated (vulnerability scanning disabled, or every container's update check `Failed`, `No tag + data`, `Manual review required` or another state than `Update available`): those containers and images count + for nothing, so the all-clear headline and panel appear, together with the *Scanning disabled* hint when it + applies. ## Non-functional requirements - N1: The dashboard loads in one service call through `IApplicationViewService`; the lists share the evaluation of the Runtime Containers, Vulnerabilities and My Images pages instead of copying it, and the dashboard reads no - resource usage samples or histories. + resource usage samples or histories and no per-image vulnerability details beyond what the lists need (no list + of affected images). - N2: The view data carries only the shown entries (at most 5, 4 and 5) plus each list's total count and the ten most recent runs, so the persisted prerender state stays small. - N3: Contrast, control height, reduced motion and self-hosted fonts follow the rules of #450 in both themes. @@ -122,19 +130,19 @@ containers of [Docker instances](../../docs/areas/docker-instances.md) — the s the identifier, the link and the footer of S4 (S4, E3, E6). - AC5: *Own base runtime warnings* lists at most 5 own images with their alert summary and image link and the footer of S5; it is hidden without a Docker Hub account and without warnings (S5, E3, E4). -- AC6: *Last 10 scans* shows the strip (order, colors, tooltips, accessible name), the count line, the line of the +- AC6: *Last 10 scans* shows the strip (order, colors, tooltip texts, accessible name), the count line, the line of the newest failed or partial run with its stored message, and the scan history link; without runs its empty text (S6, E1, E7, E8). - AC7: The inventory strip shows its cells with the visibility rules and links of S7 (S7). -- AC8: With all three counts 0 the `Nothing to do` panel replaces the three list panels; scans and inventory stay - (S8). +- AC8: With all three counts 0 the `Nothing to do` panel replaces the three list panels; scans and inventory stay, + and a configuration hint that applies is shown with them (S8, E12). - AC9: The service fills the counts as the number of running containers with `Update available`, the number of distinct active advisories affecting at least one running container (the severity bar on the same basis), and the number of own images with a base runtime alert; the headline and panel counts are these figures, and each "more" figure is the count minus the shown entries (S1–S5, E6, E11, N2). - AC10: The dashboard shows the new skeletons while loading, the existing error alert on a failed first load and the existing vulnerability configuration hints under their existing conditions; it reloads on the refresh signal, - reuses the persisted prerender state, and reads no resource usage data; texts from Docker, registries and scanners are rendered as text (S9, S10, E9, E10, N1, N4). + reuses the persisted prerender state, and builds neither resource histories nor affected-image lists; texts from Docker, registries and scanners are rendered as text (S9, S10, E9, E10, N1, N4). - AC11: `docs/areas/web-ui.md` describes the new dashboard (Area documents). ## Out of scope @@ -175,33 +183,19 @@ containers of [Docker instances](../../docs/areas/docker-instances.md) — the s instead of the metric cards. The document has about 4,200 words: the plan measures the addition against `AREA_MAX_WORDS` and moves the dashboard into its own area document if it would pass it. -## Challenge notes - -Devil's Advocate, mode `spec`, feature #453 (parent #450). I checked /home/user/DockerUpdateGuard/specs/feature-453-dashboard-attention/spec.md against both issues, the code and the documents. - -**The Lead's deviations hold up against the code:** -- **Two config alerts, not three:** `VulnerabilityConfigurationHintKind` has only `None`, `ScanningDisabled` and `DockerHubCredentialsMissing = 3` (value 2 is gone). `VulnerabilityConfigurationHintResolver.Resolve` produces only these. docs/areas/vulnerabilities.md:200-205 lists exactly these two. -- **UTC last-activity format:** `TimestampFormatter` uses `"yyyy-MM-dd HH:mm 'UTC'"` (UI/TimestampFormatter.cs:15). The top bar formats with it (MainLayout.razor.cs, `GetLatestScanLabel`). Decision 0058 is accepted. The issue's `14.11.2026 09:42` is not today's behavior. -- **Base Images cell condition:** today's cards use `BaseImageCount > 0` (Dashboard.razor:82). That count is `GetSharedBaseImageEntriesAsync(...).Count`, which needs at least two uses (ApplicationViewService.cs:463). The issue's "at least one resolved" would change a computed value, which #450 forbids. -- **Nothing-to-do text:** `ActiveUpdateFindingCount` counts all active update findings (ApplicationViewService.cs:1817), not only those of running containers. So `No update findings` could be false under E11, and `No updates available` is the honest text. -- **Nothing-to-do position:** in docs/ui-concept/flat-refresh/mockups/dashboard-all-clear.html:43-48, both panels sit in one `flex: 1 1 300px` column, the only item in the row, so they are full width and stacked. S8 matches the mockup. -- **Other checks:** - - The `--dug-*` tokens the scope names exist in wwwroot/app.css. - - `SeverityBar` folds `OtherCount` into low, which matches E6. - - `ScanRunStatus` has exactly the five statuses plus `NotSet`, which matches E8. - - `MapScanRun` gives a null `SubjectName` when a run has neither image nor instance, which matches E7. - - docs/areas/web-ui.md has 4,178 words against `AREA_MAX_WORDS = 5000` and holds no note on #278. - -**Objections** - -1. `minor` — **E6/S4 leave open which findings feed the packages and fixed versions.** `CreateVulnerabilityOverviewItem` (ApplicationViewService.cs:1142-1180) builds severity, CVSS, `AffectedPackages` and `FixedVersions` from every active finding of the advisory. That includes findings on image versions that no current container runs. `AffectedContainerCount` alone is limited to current containers. With "as the Vulnerabilities page shows it", a dashboard row can show a package, a fixed version or a higher severity (and a severity-bar segment) that comes only from a retired image. Instruction for the Lead: state in E6 that severity, score, packages and fixed versions come from all active findings of the advisory, as the overview computes them (or limit them to the running ones, if that is wanted). Instruction for the Tester: include a fixture where the advisory also has a finding on a non-running image version, and assert the chosen behavior. Why minor: it is a clarity gap on a rare data shape, not the wrong feature. - -2. `minor` — **N1 drops a requirement from the issue.** Issue §8 says "no per-image vulnerability details beyond what the lists need". N1 and AC10 only forbid resource usage. `GetVulnerabilityOverviewCoreAsync` (ApplicationViewService.cs:1111-1134) loads every active finding with `ImageVersion.ObservedImages` and builds `AffectedImages` for every advisory. `GetRuntimeContainersCoreAsync` (ApplicationViewService.cs:413) loads resource histories. Reusing either one as is would break the issue's rule or N1. Instruction for the Lead: add the issue's sentence to N1. Instruction for the plan: reuse the per-advisory and per-container evaluation, not the full page loaders, and AC10 should check that neither the affected-image list nor resource histories are built. Why minor: N1 already demands shared evaluation; this only restores a dropped constraint. - -3. `minor` — **The all-clear state does not say what happens when nothing was evaluated.** - - With `Vulnerabilities:Enabled = false`, the page will show `Everything is up to date.` in the success color, the empty text "No vulnerabilities in running containers." and possibly the `Nothing to do` panel. - - The same happens when every container's update check is `Failed`, `No tag data` or `Manual review required` (`FormatUpdateAssessmentStatus`, ApplicationViewService.cs:212-224). Only `Update available` is counted. - - Instruction for the Lead: state in S8 (or a new E-case) that the all-clear headline and panel are shown together with the *Scanning disabled* hint, and that containers in other update states never count. Instruction for the Tester: add a render test for the all-clear state with `ScanningDisabled` that asserts both the hint and the headline. Why minor: this is the issue's design and the hint covers the case; the spec should make it explicit and tested, not change it. - -4. `minor` — **S6/AC6 do not name the format of the segment tooltip's start time.** Instruction for the Dev: format it with `TimestampFormatter.Format` (UTC, decision 0058), as the old table did (Dashboard.razor:240). AC6 should name the tooltip text. Why minor: it follows from the general rule in web-ui.md, so the Dev can apply it without a plan change. +## Challenge + +Spec challenge by the Devil's Advocate (four minor objections; the confirmed deviations of the Lead are not +repeated here). + +1. Packages, fixed versions and severity of an advisory may come from findings of image versions no container runs. + Accepted: E6 states that they come from all active findings of the advisory, as the Vulnerabilities page + computes them (the row links there and must not disagree with it); only listing and container count depend on + running containers. The plan's service tests include such a finding. +2. N1 dropped the issue's "no per-image vulnerability details beyond what the lists need". Accepted: N1 names it + (no affected-image list); AC10 checks that neither resource histories nor affected-image lists are built, and + the plan reuses the per-container and per-advisory evaluation, not the page loaders. +3. The all-clear state when nothing was evaluated. Accepted: new E12, covered by AC8; the plan has a render test of + the all-clear state with the *Scanning disabled* hint and service tests with containers in other update states. +4. The tooltip's start-time format. Accepted: S6 names the tooltip text and the UTC format (decision 0058); AC6 + covers the tooltip texts. diff --git a/specs/feature-453-dashboard-attention/tasks.md b/specs/feature-453-dashboard-attention/tasks.md new file mode 100644 index 00000000..86422a38 --- /dev/null +++ b/specs/feature-453-dashboard-attention/tasks.md @@ -0,0 +1,18 @@ +# Tasks: Dashboard that lists what needs attention + +Plan: [plan.md](plan.md) + +| # | Group | Task | Files | Criteria | Depends on | Owner | Done | +| - | ----- | ---- | ----- | -------- | ---------- | ----- | ---- | +| 1 | G1 | Skeleton: DashboardViewData members UpdateCount, Updates, VulnerabilityCount, Vulnerabilities, VulnerabilityAdvisorySeveritySummary, RuntimeWarningCount, RuntimeWarnings (and the four deleted ones); classes DashboardUpdateItemData, DashboardVulnerabilityItemData, DashboardRuntimeWarningItemData | `src/DockerUpdateGuard/UI/DashboardViewData.cs`, `src/DockerUpdateGuard/UI/Dashboard{Update,Vulnerability,RuntimeWarning}ItemData.cs` | AC3, AC4, AC5, AC9 | — | Dev | [ ] | +| 2 | G1 | Tests first: service tests of the lists, counts and the resource bound, the `SetRecordingDbContext` double, and the adapted `ApplicationViewServiceTests` and `DashboardRenderTests` call sites | `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/Data/SetRecordingDbContext.cs`, `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs` | AC3, AC4, AC5, AC9, AC10 | 1 | Tester | [ ] | +| 3 | G1 | Implement `GetDashboardAsync` with the extracted helpers `ResolveRuntimeContainerTags`, `CountAffectedContainers`, `SelectAffectedPackages`, `SelectFixedVersions`, `FindBaseRuntimeAlert` | `src/DockerUpdateGuard/UI/ApplicationViewService.cs` | AC3, AC4, AC5, AC9, AC10 | 2 | Dev | [ ] | +| 4 | G2 | Skeleton: DashboardTextFormatter (GetHeadlineSegments, FormatCount, FormatSubLine, FormatFooterLink, FormatCurrentTag, FormatVulnerabilityTitle, FormatVulnerabilityDetail), DashboardScanStripFormatter (GetStatusCounts, FormatCountText, FormatStripLabel, FormatSegmentTitle, GetSegmentCssName, FindLatestProblemScan, FormatProblemScanLine), DashboardHeadlineSegmentData, DashboardScanCountData | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardHeadlineSegmentData.cs`, `src/DockerUpdateGuard/UI/DashboardScanCountData.cs` | AC1, AC2, AC3, AC4, AC6 | 3 | Dev | [ ] | +| 5 | G2 | Tests first: formatter tests | `src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardScanStripFormatterTests.cs` | AC1, AC2, AC3, AC4, AC6 | 4 | Tester | [ ] | +| 6 | G2 | Implement the formatters | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs` | AC1, AC2, AC3, AC4, AC6 | 5 | Dev | [ ] | +| 7 | G3 | Skeleton: empty `DashboardSkeleton` component; delete `MetricGridSkeleton` | `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor.cs` | AC10 | 6 | Dev | [ ] | +| 8 | G3 | Tests first: page render, persistent state, skeleton and stylesheet tests; `DashboardTests` DataRow; delete `MetricGridSkeletonTests` | `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardPersistentStateTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardSkeletonTests.cs`, `src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/MetricGridSkeletonTests.cs` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC9, AC10 | 7 | Tester | [ ] | +| 9 | G3 | Rewrite the dashboard page, the skeleton markup and the dashboard rules of the stylesheet | `src/DockerUpdateGuard/Components/Pages/Dashboard.razor`, `src/DockerUpdateGuard/Components/Pages/Dashboard.razor.cs`, `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/wwwroot/app.css` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC10 | 8 | Dev | [ ] | +| 10 | G3 | Image build check (a `.razor` content item was added and one removed) | — | AC10 | 9 | Dev | [ ] | +| 11 | G3 | Area document: dashboard row, new *Dashboard* subsection, chip and font sentences, decision 0080 link | `docs/areas/web-ui.md` | AC11 | 9 | Dev | [ ] | +| 12 | G3 | Test documentation: `SetRecordingDbContext` under *Test doubles*, the bUnit example's assert message | `docs/UNIT_TESTS.md` | AC10 | 8 | Tester | [ ] | From 7cc679a1367d5790b84f68ec1e0bfa281bb7e63f Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 12:46:41 +0000 Subject: [PATCH 06/28] Add plan challenge notes --- specs/feature-453-dashboard-attention/log.md | 2 + specs/feature-453-dashboard-attention/plan.md | 45 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 4d24fa01..3126184f 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -10,3 +10,5 @@ are quoted in full. | 2026-11-29 12:35 | 2a Spec challenge | Devil's Advocate | VERDICT: OBJECTIONS 0 major, 4 minor — (1) E6/S4: state which findings feed packages/fixed versions/severity; (2) N1: restore issue's 'no per-image vulnerability details beyond the lists' and check in AC10; (3) all-clear shown together with ScanningDisabled hint, other update states never count; (4) scan tooltip start time via TimestampFormatter (opus/medium · 94,564 tokens · 30 tool uses · 153 s · 54 in · 13,575 out · 1,718,370 cache read · 91,147 cache write · 535,562 weighted) | | 2026-11-29 12:35 | 2a Challenge notes | Orchestrator | minor objections appended verbatim to spec.md | | 2026-11-29 12:42 | 2b Plan | Lead | RESULT: DONE — tier standard, no security areas; spec closed (Approved by Lead), plan.md, tasks.md (3 groups), decision 0080 (opus/medium · 160,732 tokens · 42 tool uses · 437 s · 80 in · 48,710 out · 6,858,586 cache read · 106,804 cache write · 1,440,129 weighted · continued) | +| 2026-11-29 12:46 | 2b Plan challenge | Devil's Advocate | VERDICT: OBJECTIONS 0 major, 5 minor — fact 15 confirmed; (1) narrow vulnerability query to advisories of running image versions; (2) positive control in no-resource-data test; (3) PageHeaderSkeleton orphaned; (4) DashboardSkeleton code-behind; (5) README line 20 (opus/medium · 114,700 tokens · 37 tool uses · 235 s · 70 in · 21,931 out · 2,824,590 cache read · 111,399 cache write · 780,406 weighted) | +| 2026-11-29 12:46 | 2b Challenge notes | Orchestrator | minor objections appended verbatim to plan.md | diff --git a/specs/feature-453-dashboard-attention/plan.md b/specs/feature-453-dashboard-attention/plan.md index b0226b38..c0d3a6fd 100644 --- a/specs/feature-453-dashboard-attention/plan.md +++ b/specs/feature-453-dashboard-attention/plan.md @@ -247,3 +247,48 @@ Pages read only through `IApplicationViewService` (section 9): kept, the interfa - Removing the old dashboard styles and their `AppStylesheetTests`: #459. - `docs/ui-concept/README.md` (an older concept describing metric tiles) stays as a historical concept. + +## Challenge notes + +The plan holds up. I found no major objections and five minor ones, each written as an instruction the Dev and Tester can follow. Plan checked: /home/user/DockerUpdateGuard/specs/feature-453-dashboard-attention/plan.md (with spec.md, tasks.md and docs/decisions/0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md). + +**Fact 15 and the test seam: confirmed.** +- I loaded EF Core 11.0.0's `Microsoft.EntityFrameworkCore.dll` in a scratch console app and checked `DbContext` by reflection. `DbSet Set()` is `virtual=True final=False`, and so is `Set(string)`. +- Every `DbSet` property in `src/DockerUpdateGuard.Data/DockerUpdateGuardDbContext.cs:30-100` calls `Set()`. +- No entity has a navigation to `DockerInstanceResourceSample` or `RuntimeContainerResourceSample`. So samples can only be read through `_dbContext.RuntimeContainerResourceSamples` (`ApplicationViewService.cs:828`, `:924`) or `DockerInstanceResourceSamples` (`:850`, `:945`), and the override sees every such read. +- A subclass that takes `DbContextOptions` already works: `src/Tests/DockerUpdateGuard.Tests/Data/GatedSaveChangesDbContext.cs` does exactly that. `ApplicationViewService` takes the context directly (`ApplicationViewService.cs:83`). +- Fact 17 (SQLite cannot order by `DateTimeOffset`) stands: `SqliteTestDatabase.cs` sets up no `DateTimeOffset` converter. + +**Other facts I checked: all confirmed.** +- Fact 3: tag fallback at `:1235-1243`. +- Fact 4: resource histories are loaded at `:413`. +- Fact 5: the overview at `:1109-1180`. +- Fact 6: alert lookups at `:283-307` and `:1360-1363`. +- Fact 7: `GetScanHistoryCoreAsync` at `:540-552`. +- Fact 8: protected assets in `MainLayout.razor.cs` around line 368. +- Fact 9: `TimestampFormatter.cs:15` uses `yyyy-MM-dd HH:mm 'UTC'`. +- Facts 12 to 14: `SeverityBar.razor.cs:37` folds `OtherCount` into low; `SectionPanel` has the parameters the plan names; `AppStylesheetTests.cs:446-467` asserts the `metric-card`/`summary-card` rules. +- `StatusTone` has `Neutral`, `Warning`, `Danger` and `Success`, and `StatusToneFormatter.GetSeverityTone` exists. +- The prescribed assertion for `ApplicationViewServiceDashboardExcludesFindingsForInactiveRuntimeImageVersionsAsync` (`VulnerabilityCount` 1, summary without the retired critical finding) matches its fixture. The retired finding has its own advisory id, CVE-2026-0002, at `ApplicationViewServiceTests.cs:805`, so E6 does not merge it. +- `DashboardFailedRefreshKeepsDashboardAndLogs` still holds, because `kept-scan-subject` ends up in the new segment `title`. +- `DashboardTests.cs:32-36` has no DataRow for `Vulnerabilities`, so removing that case breaks no test. +- Tag selections (`:1621`) are read only on the detail page, so the list page and the dashboard agree on `Update available`. + +**Objections (all minor):** + +1. **The vulnerability query loads every active finding.** The *Vulnerabilities* step (plan, *Approach* step 2) loads all active `VulnerabilityFindings` across the fleet as full entities on every dashboard load and every refresh signal. Today's dashboard only runs a database-side grouped count limited to the running image versions (`ApplicationViewService.cs:753-767`). That makes the landing page's load grow with findings on images no container runs, against the spirit of N1. Instruction to the Dev: + - First query the distinct `AdvisoryId`s of active findings whose `ImageVersionId` is a running image version. + - Then load only the active findings of those advisories. + - Project to the columns the helpers need: `AdvisoryId`, `ImageVersionId`, `Severity`, `CvssScore`, `AffectedPackage`, `FixedVersion`. + - Compare advisory ids case-insensitively, as the `OrdinalIgnoreCase` grouping does. + - E6 results stay the same. + +2. **The resource test needs a positive control.** `ApplicationViewServiceDashboardRequestsNoResourceSampleSetsAsync` only asserts that something is absent, and today's `GetDashboardAsync` (`:1806-1863`) reads no samples either. So the test is green before the change and would stay green if the override recorded nothing, for example if it were declared `new` instead of `override`. Instruction to the Tester: also assert that `ContainerSnapshot` is among the recorded entity types, then assert that neither resource sample type is. + +3. **`PageHeaderSkeleton` would be left unused.** The dashboard is its only user (`Components/Pages/Dashboard.razor:14`; a grep of `src` finds no other page). The plan drops it from the dashboard and leaves the component and `src/Tests/DockerUpdateGuard.Tests/PageHeaderSkeletonTests.cs` orphaned. Instruction: delete `PageHeaderSkeleton.razor(.cs)` and its tests in the same task that deletes `MetricGridSkeleton` (tasks 7 and 8), or keep using it inside `DashboardSkeleton`. + +4. **`DashboardSkeleton` should have a code-behind.** The plan makes it markup-only, but every component under `Components/Common` has one, the skeletons included (`PageHeaderSkeleton.razor.cs:6` is `public sealed partial class PageHeaderSkeleton;`). Only `App`, `Routes`, `NotFound`, `Error` and `_Imports` have none. Instruction to the Dev: add `Components/Common/DashboardSkeleton.razor.cs` with a documented `public sealed partial class DashboardSkeleton;`, as `PageHeaderSkeleton` does. + +5. **`README.md` describes the old dashboard.** `README.md:20` says "**Dashboard**: summary view of the current inventory", which no longer describes the page. Instruction to the Dev: update that line in task 11, for example "what needs attention: containers with updates, advisories in running containers, own base runtime warnings and the last scans". + +I edited no files; the only thing I created is the reflection check project under `/tmp/claude-0/-home-user-DockerUpdateGuard/707101a9-b836-5ed5-ab6e-85e65ff789e1/scratchpad/efcheck`. From fffda2580443d3b2c27a2118cd00c56b4f4a98fc Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 12:48:08 +0000 Subject: [PATCH 07/28] Skeleton G1 --- specs/feature-453-dashboard-attention/log.md | 1 + .../feature-453-dashboard-attention/tasks.md | 2 +- .../Components/Pages/Dashboard.razor | 16 +++---- .../UI/ApplicationViewService.cs | 8 ++-- .../UI/DashboardRuntimeWarningItemData.cs | 26 +++++++++++ .../UI/DashboardUpdateItemData.cs | 46 +++++++++++++++++++ src/DockerUpdateGuard/UI/DashboardViewData.cs | 31 +++++++++---- .../UI/DashboardVulnerabilityItemData.cs | 41 +++++++++++++++++ 8 files changed, 150 insertions(+), 21 deletions(-) create mode 100644 src/DockerUpdateGuard/UI/DashboardRuntimeWarningItemData.cs create mode 100644 src/DockerUpdateGuard/UI/DashboardUpdateItemData.cs create mode 100644 src/DockerUpdateGuard/UI/DashboardVulnerabilityItemData.cs diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 3126184f..519af3c2 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -12,3 +12,4 @@ are quoted in full. | 2026-11-29 12:42 | 2b Plan | Lead | RESULT: DONE — tier standard, no security areas; spec closed (Approved by Lead), plan.md, tasks.md (3 groups), decision 0080 (opus/medium · 160,732 tokens · 42 tool uses · 437 s · 80 in · 48,710 out · 6,858,586 cache read · 106,804 cache write · 1,440,129 weighted · continued) | | 2026-11-29 12:46 | 2b Plan challenge | Devil's Advocate | VERDICT: OBJECTIONS 0 major, 5 minor — fact 15 confirmed; (1) narrow vulnerability query to advisories of running image versions; (2) positive control in no-resource-data test; (3) PageHeaderSkeleton orphaned; (4) DashboardSkeleton code-behind; (5) README line 20 (opus/medium · 114,700 tokens · 37 tool uses · 235 s · 70 in · 21,931 out · 2,824,590 cache read · 111,399 cache write · 780,406 weighted) | | 2026-11-29 12:46 | 2b Challenge notes | Orchestrator | minor objections appended verbatim to plan.md | +| 2026-11-29 12:48 | 4 Skeleton (G1) | Dev | DashboardViewData members and three item classes added, old members removed, production call sites adapted; host builds 0 warnings; no pragmas; test call sites left to Tester (sonnet/medium · 97,894 tokens · 9 tool uses · 75 s · 16 in · 4,699 out · 630,024 cache read · 96,587 cache write · 207,247 weighted) | diff --git a/specs/feature-453-dashboard-attention/tasks.md b/specs/feature-453-dashboard-attention/tasks.md index 86422a38..caa92019 100644 --- a/specs/feature-453-dashboard-attention/tasks.md +++ b/specs/feature-453-dashboard-attention/tasks.md @@ -4,7 +4,7 @@ Plan: [plan.md](plan.md) | # | Group | Task | Files | Criteria | Depends on | Owner | Done | | - | ----- | ---- | ----- | -------- | ---------- | ----- | ---- | -| 1 | G1 | Skeleton: DashboardViewData members UpdateCount, Updates, VulnerabilityCount, Vulnerabilities, VulnerabilityAdvisorySeveritySummary, RuntimeWarningCount, RuntimeWarnings (and the four deleted ones); classes DashboardUpdateItemData, DashboardVulnerabilityItemData, DashboardRuntimeWarningItemData | `src/DockerUpdateGuard/UI/DashboardViewData.cs`, `src/DockerUpdateGuard/UI/Dashboard{Update,Vulnerability,RuntimeWarning}ItemData.cs` | AC3, AC4, AC5, AC9 | — | Dev | [ ] | +| 1 | G1 | Skeleton: DashboardViewData members UpdateCount, Updates, VulnerabilityCount, Vulnerabilities, VulnerabilityAdvisorySeveritySummary, RuntimeWarningCount, RuntimeWarnings (and the four deleted ones); classes DashboardUpdateItemData, DashboardVulnerabilityItemData, DashboardRuntimeWarningItemData | `src/DockerUpdateGuard/UI/DashboardViewData.cs`, `src/DockerUpdateGuard/UI/Dashboard{Update,Vulnerability,RuntimeWarning}ItemData.cs` | AC3, AC4, AC5, AC9 | — | Dev | [x] | | 2 | G1 | Tests first: service tests of the lists, counts and the resource bound, the `SetRecordingDbContext` double, and the adapted `ApplicationViewServiceTests` and `DashboardRenderTests` call sites | `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/Data/SetRecordingDbContext.cs`, `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs` | AC3, AC4, AC5, AC9, AC10 | 1 | Tester | [ ] | | 3 | G1 | Implement `GetDashboardAsync` with the extracted helpers `ResolveRuntimeContainerTags`, `CountAffectedContainers`, `SelectAffectedPackages`, `SelectFixedVersions`, `FindBaseRuntimeAlert` | `src/DockerUpdateGuard/UI/ApplicationViewService.cs` | AC3, AC4, AC5, AC9, AC10 | 2 | Dev | [ ] | | 4 | G2 | Skeleton: DashboardTextFormatter (GetHeadlineSegments, FormatCount, FormatSubLine, FormatFooterLink, FormatCurrentTag, FormatVulnerabilityTitle, FormatVulnerabilityDetail), DashboardScanStripFormatter (GetStatusCounts, FormatCountText, FormatStripLabel, FormatSegmentTitle, GetSegmentCssName, FindLatestProblemScan, FormatProblemScanLine), DashboardHeadlineSegmentData, DashboardScanCountData | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardHeadlineSegmentData.cs`, `src/DockerUpdateGuard/UI/DashboardScanCountData.cs` | AC1, AC2, AC3, AC4, AC6 | 3 | Dev | [ ] | diff --git a/src/DockerUpdateGuard/Components/Pages/Dashboard.razor b/src/DockerUpdateGuard/Components/Pages/Dashboard.razor index c9673ace..2d5f2e46 100644 --- a/src/DockerUpdateGuard/Components/Pages/Dashboard.razor +++ b/src/DockerUpdateGuard/Components/Pages/Dashboard.razor @@ -99,7 +99,7 @@ else Update Findings - @_dashboard.ActiveUpdateFindingCount + @_dashboard.UpdateCount @@ -108,7 +108,7 @@ else Own Base Runtime Warnings - @_dashboard.OwnImageBaseRuntimeWarningCount + @_dashboard.RuntimeWarningCount @@ -118,8 +118,8 @@ else Vulnerabilities - @_dashboard.ActiveVulnerabilityFindingCount - + @_dashboard.VulnerabilityCount + @@ -148,16 +148,16 @@ else Active update findings - @_dashboard.ActiveUpdateFindingCount + @_dashboard.UpdateCount Active vulnerability findings (running containers) - @_dashboard.ActiveVulnerabilityFindingCount - + @_dashboard.VulnerabilityCount + Own base runtime warnings - @_dashboard.OwnImageBaseRuntimeWarningCount + @_dashboard.RuntimeWarningCount diff --git a/src/DockerUpdateGuard/UI/ApplicationViewService.cs b/src/DockerUpdateGuard/UI/ApplicationViewService.cs index 59713487..f5eff62f 100644 --- a/src/DockerUpdateGuard/UI/ApplicationViewService.cs +++ b/src/DockerUpdateGuard/UI/ApplicationViewService.cs @@ -1850,10 +1850,10 @@ public async Task GetDashboardAsync(CancellationToken cancell DockerInstanceCount = dockerInstanceCount, RuntimeContainerCount = latestRuntimeContainerSnapshots.Count, BaseImageCount = sharedBaseImages.Count, - ActiveUpdateFindingCount = activeUpdateFindingCount, - OwnImageBaseRuntimeWarningCount = ownImageBaseRuntimeWarningCount, - ActiveVulnerabilityFindingCount = vulnerabilitySeveritySummary.TotalCount, - VulnerabilitySeveritySummary = vulnerabilitySeveritySummary, + UpdateCount = activeUpdateFindingCount, + RuntimeWarningCount = ownImageBaseRuntimeWarningCount, + VulnerabilityCount = vulnerabilitySeveritySummary.TotalCount, + VulnerabilityAdvisorySeveritySummary = vulnerabilitySeveritySummary, VulnerabilityScanningEnabled = _optionsMonitor.CurrentValue.Vulnerabilities.Enabled, VulnerabilityConfigurationHint = vulnerabilityConfigurationHint, RecentScans = recentScans, diff --git a/src/DockerUpdateGuard/UI/DashboardRuntimeWarningItemData.cs b/src/DockerUpdateGuard/UI/DashboardRuntimeWarningItemData.cs new file mode 100644 index 00000000..44cd3bb3 --- /dev/null +++ b/src/DockerUpdateGuard/UI/DashboardRuntimeWarningItemData.cs @@ -0,0 +1,26 @@ +namespace DockerUpdateGuard.UI; + +/// +/// Dashboard list item of an own image with a base runtime warning +/// +public class DashboardRuntimeWarningItemData +{ + #region Properties + + /// + /// Observed image identifier + /// + public Guid Id { get; set; } + + /// + /// Image name + /// + public string Name { get; set; } = string.Empty; + + /// + /// Summary of the base runtime alert + /// + public string BaseRuntimeAlertSummary { get; set; } = string.Empty; + + #endregion // Properties +} \ No newline at end of file diff --git a/src/DockerUpdateGuard/UI/DashboardUpdateItemData.cs b/src/DockerUpdateGuard/UI/DashboardUpdateItemData.cs new file mode 100644 index 00000000..e7d3733c --- /dev/null +++ b/src/DockerUpdateGuard/UI/DashboardUpdateItemData.cs @@ -0,0 +1,46 @@ +namespace DockerUpdateGuard.UI; + +/// +/// Dashboard list item of a running container with an available update +/// +public class DashboardUpdateItemData +{ + #region Properties + + /// + /// Docker instance identifier + /// + public Guid DockerInstanceId { get; set; } + + /// + /// Container identifier + /// + public string ContainerId { get; set; } = string.Empty; + + /// + /// Container name + /// + public string ContainerName { get; set; } = string.Empty; + + /// + /// Docker instance name + /// + public string DockerInstanceName { get; set; } = string.Empty; + + /// + /// Tag the container currently runs + /// + public string CurrentTag { get; set; } = string.Empty; + + /// + /// Version tag the current tag resolves to + /// + public string? ResolvedVersionTag { get; set; } + + /// + /// Version tag of the available update + /// + public string? AvailableUpdateVersionTag { get; set; } + + #endregion // Properties +} \ No newline at end of file diff --git a/src/DockerUpdateGuard/UI/DashboardViewData.cs b/src/DockerUpdateGuard/UI/DashboardViewData.cs index ce8e0c3d..9b82ca28 100644 --- a/src/DockerUpdateGuard/UI/DashboardViewData.cs +++ b/src/DockerUpdateGuard/UI/DashboardViewData.cs @@ -33,24 +33,39 @@ public class DashboardViewData public int BaseImageCount { get; set; } /// - /// Active update finding count + /// Number of running containers with an available update /// - public int ActiveUpdateFindingCount { get; set; } + public int UpdateCount { get; set; } /// - /// Active derived base-runtime warnings for own images + /// Running containers with an available update, as shown on the dashboard /// - public int OwnImageBaseRuntimeWarningCount { get; set; } + public IReadOnlyList Updates { get; set; } = []; /// - /// Active vulnerability finding count for image versions currently backing a runtime container + /// Number of active advisories on running image versions /// - public int ActiveVulnerabilityFindingCount { get; set; } + public int VulnerabilityCount { get; set; } /// - /// Active vulnerability finding counts per severity for image versions currently backing a runtime container + /// Active advisories on running image versions, as shown on the dashboard /// - public VulnerabilitySeveritySummaryViewData VulnerabilitySeveritySummary { get; set; } = new(); + public IReadOnlyList Vulnerabilities { get; set; } = []; + + /// + /// Advisory counts per severity for the active advisories on running image versions + /// + public VulnerabilitySeveritySummaryViewData VulnerabilityAdvisorySeveritySummary { get; set; } = new(); + + /// + /// Number of own images with a base runtime warning + /// + public int RuntimeWarningCount { get; set; } + + /// + /// Own images with a base runtime warning, as shown on the dashboard + /// + public IReadOnlyList RuntimeWarnings { get; set; } = []; /// /// Indicates whether vulnerability scanning is enabled diff --git a/src/DockerUpdateGuard/UI/DashboardVulnerabilityItemData.cs b/src/DockerUpdateGuard/UI/DashboardVulnerabilityItemData.cs new file mode 100644 index 00000000..823ef36d --- /dev/null +++ b/src/DockerUpdateGuard/UI/DashboardVulnerabilityItemData.cs @@ -0,0 +1,41 @@ +namespace DockerUpdateGuard.UI; + +/// +/// Dashboard list item of an active advisory on running image versions +/// +public class DashboardVulnerabilityItemData +{ + #region Properties + + /// + /// Advisory identifier + /// + public string AdvisoryId { get; set; } = string.Empty; + + /// + /// Advisory severity + /// + public string Severity { get; set; } = string.Empty; + + /// + /// CVSS score + /// + public decimal? CvssScore { get; set; } + + /// + /// Affected packages + /// + public IReadOnlyList AffectedPackages { get; set; } = []; + + /// + /// Fixed versions + /// + public IReadOnlyList FixedVersions { get; set; } = []; + + /// + /// Number of running containers affected + /// + public int AffectedContainerCount { get; set; } + + #endregion // Properties +} \ No newline at end of file From 0cf9516caa3a9e61aeda09458b499bff672a8721 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 12:56:19 +0000 Subject: [PATCH 08/28] Tests first G1 --- specs/feature-453-dashboard-attention/log.md | 1 + .../feature-453-dashboard-attention/tasks.md | 2 +- .../ApplicationViewServiceDashboardTests.cs | 703 ++++++++++++++++++ .../ApplicationViewServiceTests.cs | 24 +- .../DashboardRenderTests.cs | 6 +- .../Data/SetRecordingDbContext.cs | 87 +++ 6 files changed, 807 insertions(+), 16 deletions(-) create mode 100644 src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceDashboardTests.cs create mode 100644 src/Tests/DockerUpdateGuard.Tests/Data/SetRecordingDbContext.cs diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 519af3c2..f545c6cd 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -13,3 +13,4 @@ are quoted in full. | 2026-11-29 12:46 | 2b Plan challenge | Devil's Advocate | VERDICT: OBJECTIONS 0 major, 5 minor — fact 15 confirmed; (1) narrow vulnerability query to advisories of running image versions; (2) positive control in no-resource-data test; (3) PageHeaderSkeleton orphaned; (4) DashboardSkeleton code-behind; (5) README line 20 (opus/medium · 114,700 tokens · 37 tool uses · 235 s · 70 in · 21,931 out · 2,824,590 cache read · 111,399 cache write · 780,406 weighted) | | 2026-11-29 12:46 | 2b Challenge notes | Orchestrator | minor objections appended verbatim to plan.md | | 2026-11-29 12:48 | 4 Skeleton (G1) | Dev | DashboardViewData members and three item classes added, old members removed, production call sites adapted; host builds 0 warnings; no pragmas; test call sites left to Tester (sonnet/medium · 97,894 tokens · 9 tool uses · 75 s · 16 in · 4,699 out · 630,024 cache read · 96,587 cache write · 207,247 weighted) | +| 2026-11-29 12:56 | 5 Tests first (G1) | Tester | 8 new service tests + SetRecordingDbContext; confirmed by orchestrator: compile, 9 fail on current code (8 new + adapted counts test). Deferred: none (sonnet/medium · 213,927 tokens · 40 tool uses · 458 s · 72 in · 45,073 out · 5,481,489 cache read · 159,789 cache write · 973,322 weighted) | diff --git a/specs/feature-453-dashboard-attention/tasks.md b/specs/feature-453-dashboard-attention/tasks.md index caa92019..4cbffa60 100644 --- a/specs/feature-453-dashboard-attention/tasks.md +++ b/specs/feature-453-dashboard-attention/tasks.md @@ -5,7 +5,7 @@ Plan: [plan.md](plan.md) | # | Group | Task | Files | Criteria | Depends on | Owner | Done | | - | ----- | ---- | ----- | -------- | ---------- | ----- | ---- | | 1 | G1 | Skeleton: DashboardViewData members UpdateCount, Updates, VulnerabilityCount, Vulnerabilities, VulnerabilityAdvisorySeveritySummary, RuntimeWarningCount, RuntimeWarnings (and the four deleted ones); classes DashboardUpdateItemData, DashboardVulnerabilityItemData, DashboardRuntimeWarningItemData | `src/DockerUpdateGuard/UI/DashboardViewData.cs`, `src/DockerUpdateGuard/UI/Dashboard{Update,Vulnerability,RuntimeWarning}ItemData.cs` | AC3, AC4, AC5, AC9 | — | Dev | [x] | -| 2 | G1 | Tests first: service tests of the lists, counts and the resource bound, the `SetRecordingDbContext` double, and the adapted `ApplicationViewServiceTests` and `DashboardRenderTests` call sites | `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/Data/SetRecordingDbContext.cs`, `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs` | AC3, AC4, AC5, AC9, AC10 | 1 | Tester | [ ] | +| 2 | G1 | Tests first: service tests of the lists, counts and the resource bound, the `SetRecordingDbContext` double, and the adapted `ApplicationViewServiceTests` and `DashboardRenderTests` call sites | `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/Data/SetRecordingDbContext.cs`, `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs` | AC3, AC4, AC5, AC9, AC10 | 1 | Tester | [x] | | 3 | G1 | Implement `GetDashboardAsync` with the extracted helpers `ResolveRuntimeContainerTags`, `CountAffectedContainers`, `SelectAffectedPackages`, `SelectFixedVersions`, `FindBaseRuntimeAlert` | `src/DockerUpdateGuard/UI/ApplicationViewService.cs` | AC3, AC4, AC5, AC9, AC10 | 2 | Dev | [ ] | | 4 | G2 | Skeleton: DashboardTextFormatter (GetHeadlineSegments, FormatCount, FormatSubLine, FormatFooterLink, FormatCurrentTag, FormatVulnerabilityTitle, FormatVulnerabilityDetail), DashboardScanStripFormatter (GetStatusCounts, FormatCountText, FormatStripLabel, FormatSegmentTitle, GetSegmentCssName, FindLatestProblemScan, FormatProblemScanLine), DashboardHeadlineSegmentData, DashboardScanCountData | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardHeadlineSegmentData.cs`, `src/DockerUpdateGuard/UI/DashboardScanCountData.cs` | AC1, AC2, AC3, AC4, AC6 | 3 | Dev | [ ] | | 5 | G2 | Tests first: formatter tests | `src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardScanStripFormatterTests.cs` | AC1, AC2, AC3, AC4, AC6 | 4 | Tester | [ ] | diff --git a/src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceDashboardTests.cs b/src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceDashboardTests.cs new file mode 100644 index 00000000..ca46799e --- /dev/null +++ b/src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceDashboardTests.cs @@ -0,0 +1,703 @@ +using DockerUpdateGuard.Configuration; +using DockerUpdateGuard.Data; +using DockerUpdateGuard.Data.Entities; +using DockerUpdateGuard.Data.Queries; +using DockerUpdateGuard.Data.Repositories; +using DockerUpdateGuard.Images; +using DockerUpdateGuard.Tests.Data; +using DockerUpdateGuard.UI; + +using Microsoft.EntityFrameworkCore; + +namespace DockerUpdateGuard.Tests; + +/// +/// Tests for the lists and counts of the dashboard of +/// +[TestClass] +public class ApplicationViewServiceDashboardTests +{ + #region Properties + + /// + /// Test context providing information about and functionality for the current test run + /// + public TestContext TestContext { get; set; } + + #endregion // Properties + + #region Static methods + + /// + /// Create the in-memory database options of a test + /// + /// Database context options + private static DbContextOptions CreateOptions() + { + return new DbContextOptionsBuilder().UseInMemoryDatabase(Guid.NewGuid().ToString()) + .Options; + } + + /// + /// Create the view service over a database context + /// + /// Database context + /// Application view service + private static ApplicationViewService CreateService(DockerUpdateGuardDbContext dbContext) + { + return new ApplicationViewService(dbContext, + new ImageReferenceParser(), + new TestOptionsMonitor(new DockerUpdateGuardOptions()), + new SharedBaseImageQueryService(dbContext)); + } + + /// + /// Create an image version of the Docker Hub repository + /// + /// Database context + /// Repository path + /// Image tag + /// Image digest + /// Image version + private static async Task AddImageVersionAsync(DockerUpdateGuardDbContext dbContext, + string repository, + string tag, + string digest) + { + var imageCatalogRepository = new ImageCatalogRepository(dbContext); + + return await imageCatalogRepository.GetOrCreateImageVersionAsync("docker.io", + repository, + tag, + digest, + cancellationToken: CancellationToken.None) + .ConfigureAwait(false); + } + + /// + /// Create a Docker instance + /// + /// Database context + /// Instance name + /// Docker instance + private static DockerInstance AddDockerInstance(DockerUpdateGuardDbContext dbContext, string name) + { + var dockerInstance = new DockerInstance + { + Name = name, + EndpointUri = $"https://{name.ToLowerInvariant()}.example.test", + ConnectionKind = DockerConnectionKind.Https, + }; + + dbContext.DockerInstances.Add(dockerInstance); + + return dockerInstance; + } + + /// + /// Create a running container snapshot with an update state + /// + /// Database context + /// Docker instance running the container + /// Image version the container runs + /// Container identifier and name, separated by a slash + /// Update assessment status + /// Container snapshot + private static ContainerSnapshot AddContainer(DockerUpdateGuardDbContext dbContext, + DockerInstance dockerInstance, + ImageVersion imageVersion, + string containerKey, + UpdateAssessmentStatus status) + { + var parts = containerKey.Split('/'); + var snapshot = new ContainerSnapshot + { + DockerInstance = dockerInstance, + ImageVersionId = imageVersion.Id, + ContainerId = parts[0], + Name = parts[1], + Status = ContainerRuntimeStatus.Running, + IsRunning = true, + UpdateAssessmentStatus = status, + AvailableUpdateVersionTag = status == UpdateAssessmentStatus.UpdateAvailable ? "2.0.0" : null, + }; + + dbContext.ContainerSnapshots.Add(snapshot); + + return snapshot; + } + + /// + /// Create an active vulnerability finding + /// + /// Database context + /// Affected image version + /// Advisory identifier + /// Finding severity + /// Finding score + /// Vulnerability finding + private static VulnerabilityFinding AddVulnerability(DockerUpdateGuardDbContext dbContext, + ImageVersion imageVersion, + string advisoryId, + VulnerabilitySeverity severity, + decimal? cvssScore) + { + var finding = new VulnerabilityFinding + { + ImageVersionId = imageVersion.Id, + AdvisoryId = advisoryId, + Title = $"Title of {advisoryId}", + Severity = severity, + CvssScore = cvssScore, + Source = VulnerabilitySource.Trivy, + IsActive = true, + }; + + dbContext.VulnerabilityFindings.Add(finding); + + return finding; + } + + /// + /// Create an observed image of a repository + /// + /// Database context + /// Current image version + /// Image name + /// Registration source + /// Observed image + private static ObservedImage AddObservedImage(DockerUpdateGuardDbContext dbContext, + ImageVersion imageVersion, + string name, + RegistrationSource source) + { + var observedImage = new ObservedImage + { + Name = name, + CurrentImageVersionId = imageVersion.Id, + Source = source, + }; + + dbContext.ObservedImages.Add(observedImage); + + return observedImage; + } + + /// + /// Create an active update finding of a type + /// + /// Database context + /// Scan run that recorded the finding + /// Subject image version + /// Finding type + /// Update finding + private static UpdateFinding AddUpdateFinding(DockerUpdateGuardDbContext dbContext, + ScanRun scanRun, + ImageVersion imageVersion, + UpdateFindingType type) + { + var finding = new UpdateFinding + { + ScanRun = scanRun, + SubjectImageVersionId = imageVersion.Id, + Type = type, + Summary = $"Summary of {type}", + IsActive = true, + }; + + dbContext.UpdateFindings.Add(finding); + + return finding; + } + + /// + /// Create an own image with an active base runtime alert recorded on the image itself + /// + /// Database context + /// Scan run that recorded the alert + /// Image name, also used as repository and alert summary + /// Observed image + private static async Task AddOwnImageWithAlertAsync(DockerUpdateGuardDbContext dbContext, ScanRun scanRun, string name) + { + var imageVersion = await AddImageVersionAsync(dbContext, $"company/{name.ToLowerInvariant()}", "1.0.0", $"sha256:{name.ToLowerInvariant()}").ConfigureAwait(false); + var observedImage = AddObservedImage(dbContext, imageVersion, name, RegistrationSource.Discovery); + var alert = AddUpdateFinding(dbContext, scanRun, imageVersion, UpdateFindingType.DerivedBaseRuntimeUpdate); + + alert.ObservedImage = observedImage; + alert.Summary = $"Alert of {name}"; + + return observedImage; + } + + /// + /// Create a scan run that update findings can refer to + /// + /// Database context + /// Scan run + private static ScanRun AddScanRun(DockerUpdateGuardDbContext dbContext) + { + var scanRun = new ScanRun + { + Type = ScanRunType.ObservedImage, + Status = ScanRunStatus.Succeeded, + TriggerSource = ScanTriggerSource.Manual, + }; + + dbContext.ScanRuns.Add(scanRun); + + return scanRun; + } + + /// + /// Describe the listed update entries as instance, container name and container identifier + /// + /// Dashboard view data + /// Descriptions in list order + private static List DescribeUpdates(DashboardViewData dashboard) + { + return [.. dashboard.Updates.Select(entity => $"{entity.DockerInstanceName}/{entity.ContainerName}/{entity.ContainerId}")]; + } + + #endregion // Static methods + + #region Methods + + /// + /// Verify the updates list holds the first five running containers with an available update in the stated order + /// + /// Task + [TestMethod] + [TestCategory("AC3")] + public async Task ApplicationViewServiceDashboardUpdatesListsUpdateAvailableContainersInOrderAsync() + { + var dbContext = new DockerUpdateGuardDbContext(CreateOptions()); + + await using (dbContext.ConfigureAwait(false)) + { + var plainImage = await AddImageVersionAsync(dbContext, "company/api", "1.0.0", "sha256:plain").ConfigureAwait(false); + var aliasImage = await AddImageVersionAsync(dbContext, "networlddev/f1-telemetry", "latest", "sha256:new").ConfigureAwait(false); + var alpha = AddDockerInstance(dbContext, "alpha"); + var zeta = AddDockerInstance(dbContext, "Zeta"); + var scanRun = AddScanRun(dbContext); + + AddContainer(dbContext, zeta, plainImage, "c-api-z/Api", UpdateAssessmentStatus.UpdateAvailable); + AddContainer(dbContext, alpha, plainImage, "Z-1/db", UpdateAssessmentStatus.UpdateAvailable); + AddContainer(dbContext, alpha, plainImage, "a-1/db", UpdateAssessmentStatus.UpdateAvailable); + AddContainer(dbContext, alpha, plainImage, "c-zoo/zookeeper", UpdateAssessmentStatus.UpdateAvailable); + AddContainer(dbContext, alpha, plainImage, "c-api-a/api", UpdateAssessmentStatus.UpdateAvailable); + AddContainer(dbContext, alpha, plainImage, "c-worker/worker", UpdateAssessmentStatus.UpdateAvailable); + + var aliasContainer = AddContainer(dbContext, alpha, aliasImage, "c-cache/cache", UpdateAssessmentStatus.UpdateAvailable); + + aliasContainer.AvailableUpdateVersionTag = "2.5.0"; + + var updateFinding = AddUpdateFinding(dbContext, scanRun, aliasImage, UpdateFindingType.RuntimeImageUpdate); + + updateFinding.ContainerSnapshot = aliasContainer; + updateFinding.TagCandidates.Add(new TagCandidate + { + Tag = "latest", + Digest = "sha256:new", + Rank = 1, + IsRecommended = true, + }); + updateFinding.TagCandidates.Add(new TagCandidate + { + Tag = "2.4.1", + Digest = "sha256:new", + Rank = 2, + PublishedAtUtc = new DateTimeOffset(2025, 06, 02, 12, 00, 00, TimeSpan.Zero), + }); + updateFinding.TagCandidates.Add(new TagCandidate + { + Tag = "2021.11.28", + Digest = "sha256:new", + Rank = 3, + PublishedAtUtc = new DateTimeOffset(2021, 11, 28, 12, 00, 00, TimeSpan.Zero), + }); + + await dbContext.SaveChangesAsync(TestContext.CancellationToken).ConfigureAwait(false); + + var dashboard = await CreateService(dbContext).GetDashboardAsync(TestContext.CancellationToken).ConfigureAwait(false); + + Assert.AreEqual(7, + dashboard.UpdateCount, + "The count must hold every running container with an available update"); + Assert.AreSequenceEqual(["alpha/api/c-api-a", "Zeta/Api/c-api-z", "alpha/cache/c-cache", "alpha/db/Z-1", "alpha/db/a-1"], + DescribeUpdates(dashboard), + "The list must hold the first five containers by name and instance ignoring letter case, then by ordinal container id"); + + var aliasEntry = dashboard.Updates.Single(entity => entity.ContainerId == "c-cache"); + + Assert.AreEqual("latest", aliasEntry.CurrentTag, "The current tag must be the tag of the running image version"); + Assert.AreEqual("2.4.1", aliasEntry.ResolvedVersionTag, "The alias must resolve to the version of its tag candidates"); + Assert.AreEqual("2.5.0", aliasEntry.AvailableUpdateVersionTag, "The available tag must be the stored update version"); + Assert.AreEqual(alpha.Id, aliasEntry.DockerInstanceId, "The entry must carry the Docker instance identifier for the detail link"); + + var plainEntry = dashboard.Updates.Single(entity => entity.ContainerId == "c-api-a"); + + Assert.AreEqual("1.0.0", plainEntry.CurrentTag, "The current tag of a plain version must be its tag"); + Assert.AreEqual("2.0.0", plainEntry.AvailableUpdateVersionTag, "The available tag must be the stored update version"); + } + } + + /// + /// Verify only the state Update available counts and that update findings do not + /// + /// Task + [TestMethod] + [TestCategory("AC3")] + [TestCategory("AC9")] + public async Task ApplicationViewServiceDashboardUpdatesIgnoresOtherUpdateStatesAsync() + { + var dbContext = new DockerUpdateGuardDbContext(CreateOptions()); + + await using (dbContext.ConfigureAwait(false)) + { + var imageVersion = await AddImageVersionAsync(dbContext, "company/api", "1.0.0", "sha256:api").ConfigureAwait(false); + var observedVersion = await AddImageVersionAsync(dbContext, "company/observed", "1.0.0", "sha256:observed").ConfigureAwait(false); + var dockerInstance = AddDockerInstance(dbContext, "alpha"); + var scanRun = AddScanRun(dbContext); + var observedImage = AddObservedImage(dbContext, observedVersion, "Observed", RegistrationSource.Manual); + var statuses = Enum.GetValues() + .Where(status => status != UpdateAssessmentStatus.UpdateAvailable) + .ToList(); + + foreach (var status in statuses) + { + var container = AddContainer(dbContext, dockerInstance, imageVersion, $"c-{status}/{status}", status); + + AddUpdateFinding(dbContext, scanRun, imageVersion, UpdateFindingType.RuntimeImageUpdate).ContainerSnapshot = container; + } + + AddContainer(dbContext, dockerInstance, imageVersion, "c-available/available", UpdateAssessmentStatus.UpdateAvailable); + AddUpdateFinding(dbContext, scanRun, observedVersion, UpdateFindingType.TagRecommendation).ObservedImage = observedImage; + + await dbContext.SaveChangesAsync(TestContext.CancellationToken).ConfigureAwait(false); + + var dashboard = await CreateService(dbContext).GetDashboardAsync(TestContext.CancellationToken).ConfigureAwait(false); + + Assert.AreEqual(1, + dashboard.UpdateCount, + "Only the running container with the state Update available must count, never an update finding or another state"); + Assert.AreSequenceEqual(["alpha/available/c-available"], + DescribeUpdates(dashboard), + "Only the container with the state Update available must be listed"); + } + } + + /// + /// Verify the vulnerabilities list holds four advisories of running containers in the stated order and counts all of them + /// + /// Task + [TestMethod] + [TestCategory("AC4")] + [TestCategory("AC9")] + public async Task ApplicationViewServiceDashboardVulnerabilitiesListsRunningAdvisoriesInOrderAsync() + { + var dbContext = new DockerUpdateGuardDbContext(CreateOptions()); + + await using (dbContext.ConfigureAwait(false)) + { + var single = await AddImageVersionAsync(dbContext, "company/single", "1.0.0", "sha256:single").ConfigureAwait(false); + var shared = await AddImageVersionAsync(dbContext, "company/double", "1.0.0", "sha256:double").ConfigureAwait(false); + var retired = await AddImageVersionAsync(dbContext, "company/single", "0.9.0", "sha256:retired").ConfigureAwait(false); + var dockerInstance = AddDockerInstance(dbContext, "alpha"); + + AddContainer(dbContext, dockerInstance, single, "c1/one", UpdateAssessmentStatus.UpToDate); + AddContainer(dbContext, dockerInstance, shared, "c2/two", UpdateAssessmentStatus.UpToDate); + AddContainer(dbContext, dockerInstance, shared, "c3/three", UpdateAssessmentStatus.UpToDate); + AddVulnerability(dbContext, single, "CVE-1", VulnerabilitySeverity.Critical, 3.0m); + AddVulnerability(dbContext, shared, "CVE-2", VulnerabilitySeverity.High, 9.0m); + AddVulnerability(dbContext, single, "CVE-3", VulnerabilitySeverity.High, 9.0m); + AddVulnerability(dbContext, single, "cve-4", VulnerabilitySeverity.High, 7.0m); + AddVulnerability(dbContext, single, "CVE-5", VulnerabilitySeverity.High, 7.0m); + AddVulnerability(dbContext, shared, "CVE-6", VulnerabilitySeverity.Medium, 9.9m); + AddVulnerability(dbContext, retired, "CVE-7", VulnerabilitySeverity.Critical, 10.0m); + + await dbContext.SaveChangesAsync(TestContext.CancellationToken).ConfigureAwait(false); + + var dashboard = await CreateService(dbContext).GetDashboardAsync(TestContext.CancellationToken).ConfigureAwait(false); + + Assert.AreEqual(6, + dashboard.VulnerabilityCount, + "The count must hold every advisory of a running container and no advisory of a retired image version only"); + Assert.AreSequenceEqual(["CVE-1", "CVE-2", "CVE-3", "cve-4"], + dashboard.Vulnerabilities.Select(entity => entity.AdvisoryId).ToList(), + "The list must hold four advisories by severity, score, container count and advisory identifier ignoring letter case"); + Assert.AreSequenceEqual([1, 2, 1, 1], + dashboard.Vulnerabilities.Select(entity => entity.AffectedContainerCount).ToList(), + "Each entry must carry the number of running containers it affects"); + Assert.AreSequenceEqual(["Critical", "High", "High", "High"], + dashboard.Vulnerabilities.Select(entity => entity.Severity).ToList(), + "Each entry must carry its severity"); + Assert.AreEqual(3.0m, dashboard.Vulnerabilities[0].CvssScore, "Each entry must carry its score"); + Assert.AreEqual(1, dashboard.VulnerabilityAdvisorySeveritySummary.CriticalCount, "The severity summary must count the critical advisory of a running container"); + Assert.AreEqual(4, dashboard.VulnerabilityAdvisorySeveritySummary.HighCount, "The severity summary must count the advisories, not their findings"); + Assert.AreEqual(1, dashboard.VulnerabilityAdvisorySeveritySummary.MediumCount, "The severity summary must count the medium advisory"); + Assert.AreEqual(6, dashboard.VulnerabilityAdvisorySeveritySummary.TotalCount, "The severity summary must cover exactly the counted advisories"); + } + } + + /// + /// Verify severity, score, packages and fixed versions of an advisory come from all its active findings + /// + /// Task + [TestMethod] + [TestCategory("AC4")] + public async Task ApplicationViewServiceDashboardVulnerabilitiesTakeValuesFromAllActiveFindingsAsync() + { + var dbContext = new DockerUpdateGuardDbContext(CreateOptions()); + + await using (dbContext.ConfigureAwait(false)) + { + var current = await AddImageVersionAsync(dbContext, "company/api", "2.0.0", "sha256:current").ConfigureAwait(false); + var retired = await AddImageVersionAsync(dbContext, "company/api", "1.0.0", "sha256:retired").ConfigureAwait(false); + var dockerInstance = AddDockerInstance(dbContext, "alpha"); + + AddContainer(dbContext, dockerInstance, current, "c1/api", UpdateAssessmentStatus.UpToDate); + + var runningFinding = AddVulnerability(dbContext, current, "CVE-2026-1000", VulnerabilitySeverity.Medium, 5.0m); + var retiredFinding = AddVulnerability(dbContext, retired, "CVE-2026-1000", VulnerabilitySeverity.High, 8.0m); + var inactiveFinding = AddVulnerability(dbContext, current, "CVE-2026-1000", VulnerabilitySeverity.Critical, 9.9m); + + runningFinding.AffectedPackage = "libA"; + runningFinding.FixedVersion = "1.0"; + retiredFinding.AffectedPackage = "libB"; + retiredFinding.FixedVersion = "2.0"; + inactiveFinding.AffectedPackage = "libInactive"; + inactiveFinding.FixedVersion = "9.9"; + inactiveFinding.IsActive = false; + AddVulnerability(dbContext, retired, "CVE-2026-2000", VulnerabilitySeverity.Critical, 10.0m); + + await dbContext.SaveChangesAsync(TestContext.CancellationToken).ConfigureAwait(false); + + var dashboard = await CreateService(dbContext).GetDashboardAsync(TestContext.CancellationToken).ConfigureAwait(false); + + Assert.HasCount(1, dashboard.Vulnerabilities, "Only the advisory of a running container must be listed"); + + var entry = dashboard.Vulnerabilities[0]; + + Assert.AreEqual(1, dashboard.VulnerabilityCount, "An advisory only on a retired image version must not count"); + Assert.AreEqual("CVE-2026-1000", entry.AdvisoryId, "The listed advisory must be the one running containers are affected by"); + Assert.AreEqual("High", entry.Severity, "The severity must be the highest of the active findings, also those of retired image versions"); + Assert.AreEqual(8.0m, entry.CvssScore, "The score must be the highest of the active findings, also those of retired image versions"); + Assert.AreSequenceEqual(["libA", "libB"], + entry.AffectedPackages.ToList(), + "The packages must come from all active findings and never from an inactive one"); + Assert.AreSequenceEqual(["1.0", "2.0"], + entry.FixedVersions.ToList(), + "The fixed versions must come from all active findings and never from an inactive one"); + Assert.AreEqual(1, entry.AffectedContainerCount, "Only running containers must count as affected"); + Assert.AreEqual(1, dashboard.VulnerabilityAdvisorySeveritySummary.HighCount, "The severity bar must use the same severity as the entry"); + Assert.AreEqual(0, dashboard.VulnerabilityAdvisorySeveritySummary.CriticalCount, "The critical advisory of a retired image version must not reach the bar"); + } + } + + /// + /// Verify an advisory without a score and an unknown severity sort last and the unknown severity counts as other + /// + /// Task + [TestMethod] + [TestCategory("AC4")] + public async Task ApplicationViewServiceDashboardVulnerabilitiesSortUnscoredAndUnknownSeverityLastAsync() + { + var dbContext = new DockerUpdateGuardDbContext(CreateOptions()); + + await using (dbContext.ConfigureAwait(false)) + { + var imageVersion = await AddImageVersionAsync(dbContext, "company/api", "1.0.0", "sha256:api").ConfigureAwait(false); + var dockerInstance = AddDockerInstance(dbContext, "alpha"); + + AddContainer(dbContext, dockerInstance, imageVersion, "c1/api", UpdateAssessmentStatus.UpToDate); + AddVulnerability(dbContext, imageVersion, "CVE-UNKNOWN", VulnerabilitySeverity.NotSet, 10.0m); + AddVulnerability(dbContext, imageVersion, "CVE-LOW", VulnerabilitySeverity.Low, 1.0m); + AddVulnerability(dbContext, imageVersion, "CVE-UNSCORED", VulnerabilitySeverity.High, null); + AddVulnerability(dbContext, imageVersion, "CVE-SCORED", VulnerabilitySeverity.High, 0.5m); + + await dbContext.SaveChangesAsync(TestContext.CancellationToken).ConfigureAwait(false); + + var dashboard = await CreateService(dbContext).GetDashboardAsync(TestContext.CancellationToken).ConfigureAwait(false); + + Assert.AreSequenceEqual(["CVE-SCORED", "CVE-UNSCORED", "CVE-LOW", "CVE-UNKNOWN"], + dashboard.Vulnerabilities.Select(entity => entity.AdvisoryId).ToList(), + "An advisory without a score must sort after a scored one of the same severity and an unknown severity must sort last"); + Assert.IsNull(dashboard.Vulnerabilities[1].CvssScore, "An advisory without a score must keep it empty"); + Assert.AreEqual(1, + dashboard.VulnerabilityAdvisorySeveritySummary.OtherCount, + "An advisory of unknown severity must count as other in the severity summary"); + } + } + + /// + /// Verify the runtime warnings hold own images with an alert by name, also an alert derived from a running container + /// + /// Task + [TestMethod] + [TestCategory("AC5")] + public async Task ApplicationViewServiceDashboardRuntimeWarningsListsOwnImagesWithAlertAsync() + { + var dbContext = new DockerUpdateGuardDbContext(CreateOptions()); + + await using (dbContext.ConfigureAwait(false)) + { + var scanRun = AddScanRun(dbContext); + var names = new[] { "foxtrot", "alpha", "Echo", "Golf", "Bravo", "delta" }; + var ownImages = new List(); + + foreach (var name in names) + { + ownImages.Add(await AddOwnImageWithAlertAsync(dbContext, scanRun, name).ConfigureAwait(false)); + } + + var runtimeImage = await AddImageVersionAsync(dbContext, "company/charlie", "1.0.0", "sha256:charlie").ConfigureAwait(false); + var runtimeVersion = await AddImageVersionAsync(dbContext, "company/charlie", "1.1.0", "sha256:charlie-running").ConfigureAwait(false); + var charlie = AddObservedImage(dbContext, runtimeImage, "charlie", RegistrationSource.Discovery); + var dockerInstance = AddDockerInstance(dbContext, "alpha"); + var container = AddContainer(dbContext, dockerInstance, runtimeVersion, "c1/charlie", UpdateAssessmentStatus.UpToDate); + var runtimeAlert = AddUpdateFinding(dbContext, scanRun, runtimeVersion, UpdateFindingType.DerivedBaseRuntimeUpdate); + + runtimeAlert.ContainerSnapshot = container; + runtimeAlert.Summary = "Alert of charlie"; + + var quietVersion = await AddImageVersionAsync(dbContext, "company/zulu", "1.0.0", "sha256:zulu").ConfigureAwait(false); + var manualVersion = await AddImageVersionAsync(dbContext, "company/manual", "1.0.0", "sha256:manual").ConfigureAwait(false); + var manualImage = AddObservedImage(dbContext, manualVersion, "aaa-manual", RegistrationSource.Manual); + + AddObservedImage(dbContext, quietVersion, "zulu", RegistrationSource.Discovery); + AddUpdateFinding(dbContext, scanRun, manualVersion, UpdateFindingType.DerivedBaseRuntimeUpdate).ObservedImage = manualImage; + + await dbContext.SaveChangesAsync(TestContext.CancellationToken).ConfigureAwait(false); + + var dashboard = await CreateService(dbContext).GetDashboardAsync(TestContext.CancellationToken).ConfigureAwait(false); + + Assert.AreEqual(7, + dashboard.RuntimeWarningCount, + "The count must hold every own image with an alert, also one derived from a running container, and no manual image"); + Assert.AreSequenceEqual(["alpha", "Bravo", "charlie", "delta", "Echo"], + dashboard.RuntimeWarnings.Select(entity => entity.Name).ToList(), + "The list must hold the first five own images by name ignoring letter case"); + Assert.AreEqual("Alert of charlie", + dashboard.RuntimeWarnings.Single(entity => entity.Name == "charlie").BaseRuntimeAlertSummary, + "The summary of an alert derived from a running container must be shown"); + Assert.AreEqual(ownImages.Single(entity => entity.Name == "alpha").Id, + dashboard.RuntimeWarnings[0].Id, + "The entry must carry the image identifier for the detail link"); + Assert.AreEqual("Alert of alpha", + dashboard.RuntimeWarnings[0].BaseRuntimeAlertSummary, + "The summary of the image's own alert must be shown"); + Assert.AreEqual(charlie.Id, + dashboard.RuntimeWarnings.Single(entity => entity.Name == "charlie").Id, + "The entry of the derived alert must carry the identifier of the own image"); + } + } + + /// + /// Verify each count equals the set it counts and each list is cut to its limit + /// + /// Task + [TestMethod] + [TestCategory("AC9")] + public async Task ApplicationViewServiceDashboardCountsEqualListedSetsAsync() + { + var dbContext = new DockerUpdateGuardDbContext(CreateOptions()); + + await using (dbContext.ConfigureAwait(false)) + { + var imageA = await AddImageVersionAsync(dbContext, "company/a", "1.0.0", "sha256:a").ConfigureAwait(false); + var imageB = await AddImageVersionAsync(dbContext, "company/b", "1.0.0", "sha256:b").ConfigureAwait(false); + var dockerInstance = AddDockerInstance(dbContext, "alpha"); + var scanRun = AddScanRun(dbContext); + + for (var index = 1; index <= 6; index++) + { + AddContainer(dbContext, dockerInstance, imageA, $"c{index}/container-{index}", UpdateAssessmentStatus.UpdateAvailable); + } + + AddContainer(dbContext, dockerInstance, imageB, "cb/container-b", UpdateAssessmentStatus.UpToDate); + AddVulnerability(dbContext, imageA, "CVE-1", VulnerabilitySeverity.Critical, 9.0m); + AddVulnerability(dbContext, imageB, "CVE-1", VulnerabilitySeverity.Critical, 9.0m); + AddVulnerability(dbContext, imageA, "CVE-2", VulnerabilitySeverity.High, 8.0m); + AddVulnerability(dbContext, imageA, "CVE-3", VulnerabilitySeverity.High, 7.0m); + AddVulnerability(dbContext, imageA, "CVE-4", VulnerabilitySeverity.Medium, 5.0m); + AddVulnerability(dbContext, imageA, "CVE-5", VulnerabilitySeverity.Low, 2.0m); + + foreach (var name in new[] { "one", "two", "three", "four", "five", "six" }) + { + await AddOwnImageWithAlertAsync(dbContext, scanRun, name).ConfigureAwait(false); + } + + await dbContext.SaveChangesAsync(TestContext.CancellationToken).ConfigureAwait(false); + + var dashboard = await CreateService(dbContext).GetDashboardAsync(TestContext.CancellationToken).ConfigureAwait(false); + + Assert.AreEqual(6, dashboard.UpdateCount, "The update count must be the number of containers with an available update"); + Assert.HasCount(5, dashboard.Updates, "The update list must stop at five entries"); + Assert.AreEqual(5, dashboard.VulnerabilityCount, "The vulnerability count must count an advisory once, however many findings it has"); + Assert.HasCount(4, dashboard.Vulnerabilities, "The vulnerability list must stop at four entries"); + Assert.AreEqual(5, + dashboard.VulnerabilityAdvisorySeveritySummary.TotalCount, + "The severity summary must cover the same advisories as the count"); + Assert.AreEqual(6, dashboard.RuntimeWarningCount, "The runtime warning count must be the number of own images with an alert"); + Assert.HasCount(5, dashboard.RuntimeWarnings, "The runtime warning list must stop at five entries"); + Assert.AreEqual(1, + dashboard.UpdateCount - dashboard.Updates.Count, + "The remainder of the update list must be the count minus the shown entries"); + Assert.AreEqual(1, + dashboard.VulnerabilityCount - dashboard.Vulnerabilities.Count, + "The remainder of the vulnerability list must be the count minus the shown entries"); + Assert.AreEqual(1, + dashboard.RuntimeWarningCount - dashboard.RuntimeWarnings.Count, + "The remainder of the runtime warning list must be the count minus the shown entries"); + } + } + + /// + /// Verify the dashboard builds its lists without asking for a resource sample set, and that the seam sees such a request + /// + /// Task + [TestMethod] + [TestCategory("AC10")] + public async Task ApplicationViewServiceDashboardRequestsNoResourceSampleSetsAsync() + { + var dbContext = new SetRecordingDbContext(CreateOptions()); + + await using (dbContext.ConfigureAwait(false)) + { + var imageVersion = await AddImageVersionAsync(dbContext, "company/api", "1.0.0", "sha256:api").ConfigureAwait(false); + var dockerInstance = AddDockerInstance(dbContext, "alpha"); + + AddContainer(dbContext, dockerInstance, imageVersion, "c1/api", UpdateAssessmentStatus.UpdateAvailable); + AddVulnerability(dbContext, imageVersion, "CVE-1", VulnerabilitySeverity.High, 7.0m); + + await dbContext.SaveChangesAsync(TestContext.CancellationToken).ConfigureAwait(false); + + dbContext.ResetRequestedEntityTypes(); + + var service = CreateService(dbContext); + var dashboard = await service.GetDashboardAsync(TestContext.CancellationToken).ConfigureAwait(false); + var requestedByDashboard = dbContext.RequestedEntityTypes; + + Assert.HasCount(1, dashboard.Updates, "The lists must be built while the resource bound is checked"); + Assert.Contains(typeof(ContainerSnapshot), + requestedByDashboard, + "The recording must see the container snapshots the dashboard reads"); + Assert.DoesNotContain(typeof(RuntimeContainerResourceSample), + requestedByDashboard, + "The dashboard must not read the resource samples of containers"); + Assert.DoesNotContain(typeof(DockerInstanceResourceSample), + requestedByDashboard, + "The dashboard must not read the resource samples of Docker instances"); + + dbContext.ResetRequestedEntityTypes(); + + await service.GetRuntimeContainersAsync(TestContext.CancellationToken).ConfigureAwait(false); + + Assert.Contains(typeof(RuntimeContainerResourceSample), + dbContext.RequestedEntityTypes, + "The recording must see the resource samples the Runtime Containers page reads"); + } + } + + #endregion // Methods +} \ No newline at end of file diff --git a/src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceTests.cs b/src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceTests.cs index 1e2e17db..57d8a287 100644 --- a/src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceTests.cs +++ b/src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceTests.cs @@ -723,15 +723,15 @@ public async Task ApplicationViewServiceDashboardReturnsAggregateCountsAsync() Assert.AreEqual(1, dashboard.RuntimeContainerCount, "The dashboard must report the runtime container count"); - Assert.AreEqual(3, - dashboard.ActiveUpdateFindingCount, - "The dashboard must report the active update finding count"); + Assert.AreEqual(0, + dashboard.UpdateCount, + "The dashboard must count running containers with an available update, not update findings"); Assert.AreEqual(1, - dashboard.OwnImageBaseRuntimeWarningCount, + dashboard.RuntimeWarningCount, "The dashboard must only count derived base-runtime warnings for own images"); Assert.AreEqual(1, - dashboard.ActiveVulnerabilityFindingCount, - "The dashboard must report the active vulnerability finding count"); + dashboard.VulnerabilityCount, + "The dashboard must count the active advisories of the running image versions"); Assert.HasCount(1, dashboard.RecentScans, "The dashboard must include the recent scan entry"); @@ -820,14 +820,14 @@ await dbContext.SaveChangesAsync(CancellationToken.None) .ConfigureAwait(false); Assert.AreEqual(1, - dashboard.ActiveVulnerabilityFindingCount, - "The dashboard must exclude active findings for image versions not used by current runtime containers"); + dashboard.VulnerabilityCount, + "The dashboard must exclude advisories only found on image versions not used by current runtime containers"); Assert.AreEqual(0, - dashboard.VulnerabilitySeveritySummary.CriticalCount, - "The dashboard must exclude the critical finding from the retired image version"); + dashboard.VulnerabilityAdvisorySeveritySummary.CriticalCount, + "The dashboard must exclude the critical advisory of the retired image version"); Assert.AreEqual(1, - dashboard.VulnerabilitySeveritySummary.HighCount, - "The dashboard must retain the high finding from the current runtime image version"); + dashboard.VulnerabilityAdvisorySeveritySummary.HighCount, + "The dashboard must retain the high advisory of the current runtime image version"); } } diff --git a/src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs b/src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs index 64e66493..15fb22f0 100644 --- a/src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs +++ b/src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs @@ -80,9 +80,9 @@ public async Task DashboardWithConfiguredAccountRendersMetricTiles() DockerInstanceCount = 1, RuntimeContainerCount = 5, BaseImageCount = 4, - ActiveUpdateFindingCount = 1, - OwnImageBaseRuntimeWarningCount = 0, - ActiveVulnerabilityFindingCount = 2, + UpdateCount = 1, + RuntimeWarningCount = 0, + VulnerabilityCount = 2, })); var options = Options.Create(new DockerUpdateGuardOptions diff --git a/src/Tests/DockerUpdateGuard.Tests/Data/SetRecordingDbContext.cs b/src/Tests/DockerUpdateGuard.Tests/Data/SetRecordingDbContext.cs new file mode 100644 index 00000000..3cffd979 --- /dev/null +++ b/src/Tests/DockerUpdateGuard.Tests/Data/SetRecordingDbContext.cs @@ -0,0 +1,87 @@ +using DockerUpdateGuard.Data; + +using Microsoft.EntityFrameworkCore; + +namespace DockerUpdateGuard.Tests.Data; + +/// +/// Database context that records the entity types whose sets the code under test asks for +/// +internal sealed class SetRecordingDbContext : DockerUpdateGuardDbContext +{ + #region Fields + + /// + /// Entity types whose sets were requested since the last reset + /// + private readonly HashSet _requestedEntityTypes = []; + + /// + /// Guard of the recorded entity types + /// + private readonly Lock _lock = new(); + + #endregion // Fields + + #region Constructors + + /// + /// Constructor + /// + /// Context options + public SetRecordingDbContext(DbContextOptions options) + : base(options) + { + } + + #endregion // Constructors + + #region Properties + + /// + /// Entity types whose sets were requested since the last reset + /// + public IReadOnlyCollection RequestedEntityTypes + { + get + { + lock (_lock) + { + return [.. _requestedEntityTypes]; + } + } + } + + #endregion // Properties + + #region Methods + + /// + /// Forget the entity types requested so far, for example after seeding the data + /// + public void ResetRequestedEntityTypes() + { + lock (_lock) + { + _requestedEntityTypes.Clear(); + } + } + + #endregion // Methods + + #region DbContext + + /// + public override DbSet Set() + where TEntity : class + { + lock (_lock) + { + _requestedEntityTypes.Add(typeof(TEntity)); + } + + return base.Set(); + } + + #endregion // DbContext +} \ No newline at end of file From 75feab7e3e9074a3250476435d4c0795f94ce337 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:02:42 +0000 Subject: [PATCH 09/28] Implement G1 --- specs/feature-453-dashboard-attention/log.md | 1 + .../feature-453-dashboard-attention/tasks.md | 2 +- .../UI/ApplicationViewService.cs | 340 ++++++++++++++---- 3 files changed, 281 insertions(+), 62 deletions(-) diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index f545c6cd..45f06705 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -14,3 +14,4 @@ are quoted in full. | 2026-11-29 12:46 | 2b Challenge notes | Orchestrator | minor objections appended verbatim to plan.md | | 2026-11-29 12:48 | 4 Skeleton (G1) | Dev | DashboardViewData members and three item classes added, old members removed, production call sites adapted; host builds 0 warnings; no pragmas; test call sites left to Tester (sonnet/medium · 97,894 tokens · 9 tool uses · 75 s · 16 in · 4,699 out · 630,024 cache read · 96,587 cache write · 207,247 weighted) | | 2026-11-29 12:56 | 5 Tests first (G1) | Tester | 8 new service tests + SetRecordingDbContext; confirmed by orchestrator: compile, 9 fail on current code (8 new + adapted counts test). Deferred: none (sonnet/medium · 213,927 tokens · 40 tool uses · 458 s · 72 in · 45,073 out · 5,481,489 cache read · 159,789 cache write · 973,322 weighted) | +| 2026-11-29 13:02 | 6 Implement (G1) | Dev | GetDashboardAsync implemented with extracted helpers and narrowed vulnerability query; 2642 tests pass; coverage gate PASS 100% on changed code; build 0 warnings. Notes: ApplicationViewService at RH2111 limit (1500 lines); one flaky unrelated test passed on rerun; EF projection into VulnerabilityFinding unverified on Npgsql (sonnet/medium · 146,905 tokens · 22 tool uses · 373 s · 42 in · 19,504 out · 2,480,972 cache read · 93,648 cache write · 462,719 weighted) | diff --git a/specs/feature-453-dashboard-attention/tasks.md b/specs/feature-453-dashboard-attention/tasks.md index 4cbffa60..497b392a 100644 --- a/specs/feature-453-dashboard-attention/tasks.md +++ b/specs/feature-453-dashboard-attention/tasks.md @@ -6,7 +6,7 @@ Plan: [plan.md](plan.md) | - | ----- | ---- | ----- | -------- | ---------- | ----- | ---- | | 1 | G1 | Skeleton: DashboardViewData members UpdateCount, Updates, VulnerabilityCount, Vulnerabilities, VulnerabilityAdvisorySeveritySummary, RuntimeWarningCount, RuntimeWarnings (and the four deleted ones); classes DashboardUpdateItemData, DashboardVulnerabilityItemData, DashboardRuntimeWarningItemData | `src/DockerUpdateGuard/UI/DashboardViewData.cs`, `src/DockerUpdateGuard/UI/Dashboard{Update,Vulnerability,RuntimeWarning}ItemData.cs` | AC3, AC4, AC5, AC9 | — | Dev | [x] | | 2 | G1 | Tests first: service tests of the lists, counts and the resource bound, the `SetRecordingDbContext` double, and the adapted `ApplicationViewServiceTests` and `DashboardRenderTests` call sites | `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/Data/SetRecordingDbContext.cs`, `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs` | AC3, AC4, AC5, AC9, AC10 | 1 | Tester | [x] | -| 3 | G1 | Implement `GetDashboardAsync` with the extracted helpers `ResolveRuntimeContainerTags`, `CountAffectedContainers`, `SelectAffectedPackages`, `SelectFixedVersions`, `FindBaseRuntimeAlert` | `src/DockerUpdateGuard/UI/ApplicationViewService.cs` | AC3, AC4, AC5, AC9, AC10 | 2 | Dev | [ ] | +| 3 | G1 | Implement `GetDashboardAsync` with the extracted helpers `ResolveRuntimeContainerTags`, `CountAffectedContainers`, `SelectAffectedPackages`, `SelectFixedVersions`, `FindBaseRuntimeAlert` | `src/DockerUpdateGuard/UI/ApplicationViewService.cs` | AC3, AC4, AC5, AC9, AC10 | 2 | Dev | [x] | | 4 | G2 | Skeleton: DashboardTextFormatter (GetHeadlineSegments, FormatCount, FormatSubLine, FormatFooterLink, FormatCurrentTag, FormatVulnerabilityTitle, FormatVulnerabilityDetail), DashboardScanStripFormatter (GetStatusCounts, FormatCountText, FormatStripLabel, FormatSegmentTitle, GetSegmentCssName, FindLatestProblemScan, FormatProblemScanLine), DashboardHeadlineSegmentData, DashboardScanCountData | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardHeadlineSegmentData.cs`, `src/DockerUpdateGuard/UI/DashboardScanCountData.cs` | AC1, AC2, AC3, AC4, AC6 | 3 | Dev | [ ] | | 5 | G2 | Tests first: formatter tests | `src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardScanStripFormatterTests.cs` | AC1, AC2, AC3, AC4, AC6 | 4 | Tester | [ ] | | 6 | G2 | Implement the formatters | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs` | AC1, AC2, AC3, AC4, AC6 | 5 | Dev | [ ] | diff --git a/src/DockerUpdateGuard/UI/ApplicationViewService.cs b/src/DockerUpdateGuard/UI/ApplicationViewService.cs index f5eff62f..73e8ecc6 100644 --- a/src/DockerUpdateGuard/UI/ApplicationViewService.cs +++ b/src/DockerUpdateGuard/UI/ApplicationViewService.cs @@ -34,6 +34,21 @@ public sealed class ApplicationViewService : IApplicationViewService, IDisposabl /// private const int SharedBaseImageMinimumUsageCount = 2; + /// + /// Maximum number of containers with an available update listed on the dashboard + /// + private const int DashboardUpdateLimit = 5; + + /// + /// Maximum number of advisories listed on the dashboard + /// + private const int DashboardVulnerabilityLimit = 4; + + /// + /// Maximum number of own images with a base runtime warning listed on the dashboard + /// + private const int DashboardRuntimeWarningLimit = 5; + /// /// Resource-history window /// @@ -376,6 +391,117 @@ private static void ApplyImageVulnerabilityData(RuntimeContainerDetailViewData d detail.VulnerabilityFindings = vulnerabilityAssessmentDetail.Findings; } + /// + /// Resolve the version tags of a current container snapshot, preferring the values stored on the snapshot over its tag candidates + /// + /// Current container snapshot with its image version + /// Tag candidates of the snapshot's update findings + /// Resolved version tag and available update version tag + private static (string? ResolvedVersionTag, string? AvailableUpdateVersionTag) ResolveRuntimeContainerTags(ContainerSnapshot entity, List tagCandidates) + { + var imageVersion = entity.ImageVersion; + + var resolvedVersionTag = string.IsNullOrWhiteSpace(entity.ResolvedVersionTag) == false + ? entity.ResolvedVersionTag + : TagCandidateViewHelper.ResolveResolvedVersionTag(imageVersion.Tag, + imageVersion.Digest, + tagCandidates); + var availableUpdateVersionTag = string.IsNullOrWhiteSpace(entity.AvailableUpdateVersionTag) == false + ? entity.AvailableUpdateVersionTag + : TagCandidateViewHelper.ResolveAvailableUpdateVersionTag(tagCandidates, + resolvedVersionTag ?? imageVersion.Tag); + + return (resolvedVersionTag, availableUpdateVersionTag); + } + + /// + /// Count the current containers running the image versions an advisory affects + /// + /// Active findings sharing the same advisory identifier + /// Running container counts by image version identifier + /// Number of affected containers + private static int CountAffectedContainers(IEnumerable advisoryFindings, Dictionary containerCountsByImageVersion) + { + return advisoryFindings.Select(entity => entity.ImageVersionId) + .Distinct() + .Sum(imageVersionId => GetCountOrZero(containerCountsByImageVersion, imageVersionId)); + } + + /// + /// Select the distinct affected packages of an advisory + /// + /// Active findings sharing the same advisory identifier + /// Affected packages ordered by name + private static List SelectAffectedPackages(IEnumerable advisoryFindings) + { + return [ + .. advisoryFindings.Select(entity => entity.AffectedPackage) + .Where(package => string.IsNullOrWhiteSpace(package) == false) + .Select(package => package!) + .Distinct(StringComparer.OrdinalIgnoreCase) + .OrderBy(package => package, StringComparer.OrdinalIgnoreCase) + ]; + } + + /// + /// Select the distinct fixed versions of an advisory + /// + /// Active findings sharing the same advisory identifier + /// Fixed versions ordered by value + private static List SelectFixedVersions(IEnumerable advisoryFindings) + { + return [ + .. advisoryFindings.Select(entity => entity.FixedVersion) + .Where(fixedVersion => string.IsNullOrWhiteSpace(fixedVersion) == false) + .Select(fixedVersion => fixedVersion!) + .Distinct(StringComparer.OrdinalIgnoreCase) + .OrderBy(fixedVersion => fixedVersion, StringComparer.OrdinalIgnoreCase) + ]; + } + + /// + /// Find the base runtime alert of an observed image: its own newest finding, else that of a current container of its repository + /// + /// Observed image with its current image version + /// Latest derived base runtime finding by observed image identifier + /// Latest derived base runtime finding by repository key + /// Base runtime alert or null + private static UpdateFinding? FindBaseRuntimeAlert(ObservedImage entity, + Dictionary observedAlertLookup, + Dictionary runtimeAlertLookup) + { + var repositoryKey = CreateRepositoryKey(entity.CurrentImageVersion); + + observedAlertLookup.TryGetValue(entity.Id, out var observedAlert); + runtimeAlertLookup.TryGetValue(repositoryKey, out var runtimeAlert); + + return observedAlert ?? runtimeAlert; + } + + /// + /// Create a dashboard advisory entry from the active findings of one advisory + /// + /// Active findings sharing the same advisory identifier + /// Running container counts by image version identifier + /// Dashboard advisory entry + private static DashboardVulnerabilityItemData CreateDashboardVulnerabilityItem(IGrouping advisoryGroup, + Dictionary containerCountsByImageVersion) + { + var representativeFinding = advisoryGroup.OrderByDescending(entity => entity.Severity) + .ThenByDescending(entity => entity.CvssScore ?? decimal.MinValue) + .First(); + + return new DashboardVulnerabilityItemData + { + AdvisoryId = representativeFinding.AdvisoryId, + Severity = advisoryGroup.Max(entity => entity.Severity).ToString(), + CvssScore = advisoryGroup.Max(entity => entity.CvssScore), + AffectedPackages = SelectAffectedPackages(advisoryGroup), + FixedVersions = SelectFixedVersions(advisoryGroup), + AffectedContainerCount = CountAffectedContainers(advisoryGroup, containerCountsByImageVersion), + }; + } + #endregion // Static methods #region Methods @@ -1148,7 +1274,7 @@ private VulnerabilityOverviewItemData CreateVulnerabilityOverviewItem(IGrouping< var affectedImageVersions = advisoryGroup.GroupBy(entity => entity.ImageVersionId) .Select(imageGroup => CreateAffectedImage(imageGroup.First().ImageVersion)) .ToList(); - var affectedContainerCount = affectedImageVersions.Sum(entity => GetCountOrZero(containerCountsByImageVersion, entity.ImageVersionId)); + var affectedContainerCount = CountAffectedContainers(advisoryGroup, containerCountsByImageVersion); var affectedImages = affectedImageVersions.GroupBy(entity => ImageReferenceFormatter.GetReference(entity.ImageReference), StringComparer.OrdinalIgnoreCase) .Select(referenceGroup => SelectRepresentativeAffectedImage(referenceGroup)) .OrderBy(entity => entity.ImageReference, StringComparer.OrdinalIgnoreCase) @@ -1161,20 +1287,8 @@ private VulnerabilityOverviewItemData CreateVulnerabilityOverviewItem(IGrouping< Severity = advisoryGroup.Max(entity => entity.Severity).ToString(), CvssScore = advisoryGroup.Max(entity => entity.CvssScore), ReferenceUrl = VulnerabilityViewMapper.SanitizeHttpUrl(representativeFinding.ReferenceUrl), - AffectedPackages = [ - .. advisoryGroup.Select(entity => entity.AffectedPackage) - .Where(package => string.IsNullOrWhiteSpace(package) == false) - .Select(package => package!) - .Distinct(StringComparer.OrdinalIgnoreCase) - .OrderBy(package => package, StringComparer.OrdinalIgnoreCase) - ], - FixedVersions = [ - .. advisoryGroup.Select(entity => entity.FixedVersion) - .Where(fixedVersion => string.IsNullOrWhiteSpace(fixedVersion) == false) - .Select(fixedVersion => fixedVersion!) - .Distinct(StringComparer.OrdinalIgnoreCase) - .OrderBy(fixedVersion => fixedVersion, StringComparer.OrdinalIgnoreCase) - ], + AffectedPackages = SelectAffectedPackages(advisoryGroup), + FixedVersions = SelectFixedVersions(advisoryGroup), AffectedImages = affectedImages, AffectedContainerCount = affectedContainerCount, }; @@ -1232,15 +1346,7 @@ private RuntimeContainerListItemData MapRuntimeContainerListItem(ContainerSnapsh var baseImageVulnerabilitySummary = VulnerabilityViewMapper.SummarizeBaseImageVulnerabilities(baseImageRelationships); var availableTagCandidates = tagCandidates ?? []; - var resolvedVersionTag = string.IsNullOrWhiteSpace(entity.ResolvedVersionTag) == false - ? entity.ResolvedVersionTag - : TagCandidateViewHelper.ResolveResolvedVersionTag(imageVersion.Tag, - imageVersion.Digest, - availableTagCandidates); - var availableUpdateVersionTag = string.IsNullOrWhiteSpace(entity.AvailableUpdateVersionTag) == false - ? entity.AvailableUpdateVersionTag - : TagCandidateViewHelper.ResolveAvailableUpdateVersionTag(availableTagCandidates, - resolvedVersionTag ?? imageVersion.Tag); + var (resolvedVersionTag, availableUpdateVersionTag) = ResolveRuntimeContainerTags(entity, availableTagCandidates); return new RuntimeContainerListItemData { @@ -1356,11 +1462,7 @@ private ObservedImageListItemData MapObservedImageListItem(ObservedImage entity, Dictionary runtimeLinkLookup) { var repositoryKey = CreateRepositoryKey(entity.CurrentImageVersion); - - observedAlertLookup.TryGetValue(entity.Id, out var observedAlert); - runtimeAlertLookup.TryGetValue(repositoryKey, out var runtimeAlert); - - var baseRuntimeAlert = observedAlert ?? runtimeAlert; + var baseRuntimeAlert = FindBaseRuntimeAlert(entity, observedAlertLookup, runtimeAlertLookup); baseImageRelationshipsByChildVersion.TryGetValue(entity.CurrentImageVersionId, out var baseImageRelationships); @@ -1798,6 +1900,144 @@ private RuntimeContainerDetailViewData CreateRuntimeContainerDetail(Guid dockerI }; } + /// + /// Load the dashboard's containers with an available update, limited to the first entries by container and instance name + /// + /// Current container snapshots + /// Cancellation token + /// Number of all such containers and the listed entries + private async Task<(int TotalCount, List Items)> LoadDashboardUpdatesAsync(IReadOnlyList latestSnapshots, + CancellationToken cancellationToken) + { + var updateSnapshots = latestSnapshots.Where(entity => entity.UpdateAssessmentStatus == UpdateAssessmentStatus.UpdateAvailable) + .OrderBy(entity => entity.Name, StringComparer.OrdinalIgnoreCase) + .ThenBy(entity => entity.DockerInstance.Name, StringComparer.OrdinalIgnoreCase) + .ThenBy(entity => entity.ContainerId, StringComparer.Ordinal) + .ToList(); + var shownSnapshots = updateSnapshots.Take(DashboardUpdateLimit).ToList(); + var latestFindings = await LoadLatestUpdateFindingsAsync([.. shownSnapshots.Select(entity => entity.Id)], cancellationToken).ConfigureAwait(false); + var tagCandidatesBySnapshot = GroupTagCandidatesBySnapshot(latestFindings); + var items = new List(); + + foreach (var entity in shownSnapshots) + { + tagCandidatesBySnapshot.TryGetValue(entity.Id, out var tagCandidates); + + var (resolvedVersionTag, availableUpdateVersionTag) = ResolveRuntimeContainerTags(entity, tagCandidates ?? []); + + items.Add(new DashboardUpdateItemData + { + DockerInstanceId = entity.DockerInstanceId, + ContainerId = entity.ContainerId, + ContainerName = entity.Name, + DockerInstanceName = entity.DockerInstance.Name, + CurrentTag = entity.ImageVersion.Tag, + ResolvedVersionTag = resolvedVersionTag, + AvailableUpdateVersionTag = availableUpdateVersionTag, + }); + } + + return (updateSnapshots.Count, items); + } + + /// + /// Load the dashboard's advisories of the running image versions with the values of all their active findings + /// + /// Current container snapshots + /// Cancellation token + /// Number of all such advisories, the listed entries and the severity summary of all of them + private async Task<(int TotalCount, List Items, VulnerabilitySeveritySummaryViewData SeveritySummary)> LoadDashboardVulnerabilitiesAsync(IReadOnlyList latestSnapshots, + CancellationToken cancellationToken) + { + var runtimeImageVersionIds = latestSnapshots.Select(entity => entity.ImageVersionId) + .Distinct() + .ToList(); + var runningAdvisoryIds = await _dbContext.VulnerabilityFindings.Where(entity => entity.IsActive + && runtimeImageVersionIds.Contains(entity.ImageVersionId)) + .Select(entity => entity.AdvisoryId) + .Distinct() + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + + if (runningAdvisoryIds.Count == 0) + { + return (0, [], new VulnerabilitySeveritySummaryViewData()); + } + + var lowerCaseAdvisoryIds = runningAdvisoryIds.Select(advisoryId => advisoryId.ToLowerInvariant()) + .Distinct() + .ToList(); + var advisoryFindings = await _dbContext.VulnerabilityFindings.Where(entity => entity.IsActive + && lowerCaseAdvisoryIds.Contains(entity.AdvisoryId.ToLowerInvariant())) + .AsNoTracking() + .Select(entity => new VulnerabilityFinding + { + AdvisoryId = entity.AdvisoryId, + ImageVersionId = entity.ImageVersionId, + Severity = entity.Severity, + CvssScore = entity.CvssScore, + AffectedPackage = entity.AffectedPackage, + FixedVersion = entity.FixedVersion, + }) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); + var containerCountsByImageVersion = latestSnapshots.GroupBy(entity => entity.ImageVersionId) + .ToDictionary(group => group.Key, group => group.Count()); + var advisories = advisoryFindings.GroupBy(entity => entity.AdvisoryId, StringComparer.OrdinalIgnoreCase) + .Select(group => (Severity: group.Max(entity => entity.Severity), + Item: CreateDashboardVulnerabilityItem(group, containerCountsByImageVersion))) + .OrderByDescending(entry => entry.Severity) + .ThenByDescending(entry => entry.Item.CvssScore ?? decimal.MinValue) + .ThenByDescending(entry => entry.Item.AffectedContainerCount) + .ThenBy(entry => entry.Item.AdvisoryId, StringComparer.OrdinalIgnoreCase) + .ToList(); + var severitySummary = new VulnerabilitySeveritySummaryViewData + { + CriticalCount = advisories.Count(entry => entry.Severity == VulnerabilitySeverity.Critical), + HighCount = advisories.Count(entry => entry.Severity == VulnerabilitySeverity.High), + MediumCount = advisories.Count(entry => entry.Severity == VulnerabilitySeverity.Medium), + LowCount = advisories.Count(entry => entry.Severity == VulnerabilitySeverity.Low), + }; + + severitySummary.OtherCount = advisories.Count - severitySummary.TotalCount; + + return (advisories.Count, [.. advisories.Take(DashboardVulnerabilityLimit).Select(entry => entry.Item)], severitySummary); + } + + /// + /// Load the dashboard's own images with a base runtime warning, limited to the first entries by name + /// + /// Current container snapshots + /// Cancellation token + /// Number of all such images and the listed entries + private async Task<(int TotalCount, List Items)> LoadDashboardRuntimeWarningsAsync(IReadOnlyList latestSnapshots, + CancellationToken cancellationToken) + { + var observedImages = await LoadObservedImagesAsync(RegistrationSource.Discovery, cancellationToken).ConfigureAwait(false); + var latestSnapshotIds = latestSnapshots.Select(entity => entity.Id) + .ToList(); + var repositoryKeyBySnapshotId = latestSnapshots.ToDictionary(entity => entity.Id, + CreateRepositoryKey); + var derivedBaseRuntimeFindings = await LoadDerivedBaseRuntimeFindingsAsync([.. observedImages.Select(entity => entity.Id)], latestSnapshotIds, cancellationToken).ConfigureAwait(false); + var runtimeAlertLookup = CreateRuntimeAlertLookup(derivedBaseRuntimeFindings, repositoryKeyBySnapshotId); + var observedAlertLookup = CreateObservedAlertLookup(derivedBaseRuntimeFindings); + var warnings = observedImages.Select(entity => (Image: entity, Alert: FindBaseRuntimeAlert(entity, observedAlertLookup, runtimeAlertLookup))) + .Where(entry => entry.Alert is not null) + .OrderBy(entry => entry.Image.Name, StringComparer.OrdinalIgnoreCase) + .ThenBy(entry => entry.Image.Id) + .ToList(); + + return (warnings.Count, [ + .. warnings.Take(DashboardRuntimeWarningLimit) + .Select(entry => new DashboardRuntimeWarningItemData + { + Id = entry.Image.Id, + Name = entry.Image.Name, + BaseRuntimeAlertSummary = entry.Alert!.Summary, + }) + ]); + } + #endregion // Methods #region IApplicationViewService @@ -1813,34 +2053,9 @@ public async Task GetDashboardAsync(CancellationToken cancell var dockerInstanceCount = await _dbContext.DockerInstances.CountAsync(cancellationToken).ConfigureAwait(false); var latestRuntimeContainerSnapshots = await GetLatestContainerSnapshotsAsync(cancellationToken).ConfigureAwait(false); var sharedBaseImages = await GetSharedBaseImageEntriesAsync(latestRuntimeContainerSnapshots, cancellationToken).ConfigureAwait(false); - var activeUpdateFindingCount = await _dbContext.UpdateFindings.CountAsync(entity => entity.IsActive, cancellationToken).ConfigureAwait(false); - var ownImageBaseRuntimeWarningCount = await _dbContext.UpdateFindings.Join(_dbContext.ObservedImages.Where(entity => entity.Source == RegistrationSource.Discovery), - finding => finding.ObservedImageId, - observedImage => (Guid?)observedImage.Id, - (finding, observedImage) => new - { - finding.IsActive, - finding.Type, - }) - .CountAsync(entity => entity.IsActive - && entity.Type == UpdateFindingType.DerivedBaseRuntimeUpdate, - cancellationToken) - .ConfigureAwait(false); - var runtimeImageVersionIds = latestRuntimeContainerSnapshots.Select(entity => entity.ImageVersionId) - .Distinct() - .ToList(); - - // Scoped to current runtime containers so the dashboard reflects live exposure; the fleet-wide - // vulnerability inventory (including retired image versions) remains available on /vulnerabilities. - var runtimeVulnerabilitySeveritySummaries = await LoadActiveVulnerabilitySeveritySummariesAsync(runtimeImageVersionIds, cancellationToken).ConfigureAwait(false); - var vulnerabilitySeveritySummary = new VulnerabilitySeveritySummaryViewData - { - CriticalCount = runtimeVulnerabilitySeveritySummaries.Values.Sum(summary => summary.CriticalCount), - HighCount = runtimeVulnerabilitySeveritySummaries.Values.Sum(summary => summary.HighCount), - MediumCount = runtimeVulnerabilitySeveritySummaries.Values.Sum(summary => summary.MediumCount), - LowCount = runtimeVulnerabilitySeveritySummaries.Values.Sum(summary => summary.LowCount), - OtherCount = runtimeVulnerabilitySeveritySummaries.Values.Sum(summary => summary.OtherCount), - }; + var updates = await LoadDashboardUpdatesAsync(latestRuntimeContainerSnapshots, cancellationToken).ConfigureAwait(false); + var vulnerabilities = await LoadDashboardVulnerabilitiesAsync(latestRuntimeContainerSnapshots, cancellationToken).ConfigureAwait(false); + var runtimeWarnings = await LoadDashboardRuntimeWarningsAsync(latestRuntimeContainerSnapshots, cancellationToken).ConfigureAwait(false); var vulnerabilityConfigurationHint = await GetVulnerabilityConfigurationHintCoreAsync(cancellationToken).ConfigureAwait(false); return new DashboardViewData @@ -1850,10 +2065,13 @@ public async Task GetDashboardAsync(CancellationToken cancell DockerInstanceCount = dockerInstanceCount, RuntimeContainerCount = latestRuntimeContainerSnapshots.Count, BaseImageCount = sharedBaseImages.Count, - UpdateCount = activeUpdateFindingCount, - RuntimeWarningCount = ownImageBaseRuntimeWarningCount, - VulnerabilityCount = vulnerabilitySeveritySummary.TotalCount, - VulnerabilityAdvisorySeveritySummary = vulnerabilitySeveritySummary, + UpdateCount = updates.TotalCount, + Updates = updates.Items, + VulnerabilityCount = vulnerabilities.TotalCount, + Vulnerabilities = vulnerabilities.Items, + VulnerabilityAdvisorySeveritySummary = vulnerabilities.SeveritySummary, + RuntimeWarningCount = runtimeWarnings.TotalCount, + RuntimeWarnings = runtimeWarnings.Items, VulnerabilityScanningEnabled = _optionsMonitor.CurrentValue.Vulnerabilities.Enabled, VulnerabilityConfigurationHint = vulnerabilityConfigurationHint, RecentScans = recentScans, From e2b1b99e43002def80a58427f12fa2df9d4cf84e Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:03:39 +0000 Subject: [PATCH 10/28] Log G1 coverage --- specs/feature-453-dashboard-attention/log.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 45f06705..f19df19c 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -15,3 +15,4 @@ are quoted in full. | 2026-11-29 12:48 | 4 Skeleton (G1) | Dev | DashboardViewData members and three item classes added, old members removed, production call sites adapted; host builds 0 warnings; no pragmas; test call sites left to Tester (sonnet/medium · 97,894 tokens · 9 tool uses · 75 s · 16 in · 4,699 out · 630,024 cache read · 96,587 cache write · 207,247 weighted) | | 2026-11-29 12:56 | 5 Tests first (G1) | Tester | 8 new service tests + SetRecordingDbContext; confirmed by orchestrator: compile, 9 fail on current code (8 new + adapted counts test). Deferred: none (sonnet/medium · 213,927 tokens · 40 tool uses · 458 s · 72 in · 45,073 out · 5,481,489 cache read · 159,789 cache write · 973,322 weighted) | | 2026-11-29 13:02 | 6 Implement (G1) | Dev | GetDashboardAsync implemented with extracted helpers and narrowed vulnerability query; 2642 tests pass; coverage gate PASS 100% on changed code; build 0 warnings. Notes: ApplicationViewService at RH2111 limit (1500 lines); one flaky unrelated test passed on rerun; EF projection into VulnerabilityFinding unverified on Npgsql (sonnet/medium · 146,905 tokens · 22 tool uses · 373 s · 42 in · 19,504 out · 2,480,972 cache read · 93,648 cache write · 462,719 weighted) | +| 2026-11-29 13:03 | 6 Coverage skipped (G1) | Orchestrator | skipped — gate run by orchestrator: PASS, 100% on changed code (183/183 lines, 14/14 conditions), 2642+39 tests green; no deferred test, resource bound has its test | From 68229991e900ad8b3b707832f961ccbab9617df7 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:04:39 +0000 Subject: [PATCH 11/28] Skeleton G2 --- specs/feature-453-dashboard-attention/log.md | 1 + .../feature-453-dashboard-attention/tasks.md | 2 +- .../UI/DashboardHeadlineSegmentData.cs | 21 ++++ .../UI/DashboardScanCountData.cs | 21 ++++ .../UI/DashboardScanStripFormatter.cs | 90 +++++++++++++++++ .../UI/DashboardTextFormatter.cs | 96 +++++++++++++++++++ 6 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 src/DockerUpdateGuard/UI/DashboardHeadlineSegmentData.cs create mode 100644 src/DockerUpdateGuard/UI/DashboardScanCountData.cs create mode 100644 src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs create mode 100644 src/DockerUpdateGuard/UI/DashboardTextFormatter.cs diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index f19df19c..a0988bef 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -16,3 +16,4 @@ are quoted in full. | 2026-11-29 12:56 | 5 Tests first (G1) | Tester | 8 new service tests + SetRecordingDbContext; confirmed by orchestrator: compile, 9 fail on current code (8 new + adapted counts test). Deferred: none (sonnet/medium · 213,927 tokens · 40 tool uses · 458 s · 72 in · 45,073 out · 5,481,489 cache read · 159,789 cache write · 973,322 weighted) | | 2026-11-29 13:02 | 6 Implement (G1) | Dev | GetDashboardAsync implemented with extracted helpers and narrowed vulnerability query; 2642 tests pass; coverage gate PASS 100% on changed code; build 0 warnings. Notes: ApplicationViewService at RH2111 limit (1500 lines); one flaky unrelated test passed on rerun; EF projection into VulnerabilityFinding unverified on Npgsql (sonnet/medium · 146,905 tokens · 22 tool uses · 373 s · 42 in · 19,504 out · 2,480,972 cache read · 93,648 cache write · 462,719 weighted) | | 2026-11-29 13:03 | 6 Coverage skipped (G1) | Orchestrator | skipped — gate run by orchestrator: PASS, 100% on changed code (183/183 lines, 14/14 conditions), 2642+39 tests green; no deferred test, resource bound has its test | +| 2026-11-29 13:04 | 4 Skeleton (G2) | Dev | DashboardTextFormatter, DashboardScanStripFormatter, DashboardHeadlineSegmentData, DashboardScanCountData added; host builds 0 warnings; no pragmas; deviation: private const SkeletonMessage per formatter (S1192) (sonnet/medium · 5,127 tokens · 4 tool uses · 53 s · 10 in · 3,757 out · 353,321 cache read · 47,683 cache write · 113,731 weighted · continued from 4 Skeleton (G1)) | diff --git a/specs/feature-453-dashboard-attention/tasks.md b/specs/feature-453-dashboard-attention/tasks.md index 497b392a..2377962a 100644 --- a/specs/feature-453-dashboard-attention/tasks.md +++ b/specs/feature-453-dashboard-attention/tasks.md @@ -7,7 +7,7 @@ Plan: [plan.md](plan.md) | 1 | G1 | Skeleton: DashboardViewData members UpdateCount, Updates, VulnerabilityCount, Vulnerabilities, VulnerabilityAdvisorySeveritySummary, RuntimeWarningCount, RuntimeWarnings (and the four deleted ones); classes DashboardUpdateItemData, DashboardVulnerabilityItemData, DashboardRuntimeWarningItemData | `src/DockerUpdateGuard/UI/DashboardViewData.cs`, `src/DockerUpdateGuard/UI/Dashboard{Update,Vulnerability,RuntimeWarning}ItemData.cs` | AC3, AC4, AC5, AC9 | — | Dev | [x] | | 2 | G1 | Tests first: service tests of the lists, counts and the resource bound, the `SetRecordingDbContext` double, and the adapted `ApplicationViewServiceTests` and `DashboardRenderTests` call sites | `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/Data/SetRecordingDbContext.cs`, `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs` | AC3, AC4, AC5, AC9, AC10 | 1 | Tester | [x] | | 3 | G1 | Implement `GetDashboardAsync` with the extracted helpers `ResolveRuntimeContainerTags`, `CountAffectedContainers`, `SelectAffectedPackages`, `SelectFixedVersions`, `FindBaseRuntimeAlert` | `src/DockerUpdateGuard/UI/ApplicationViewService.cs` | AC3, AC4, AC5, AC9, AC10 | 2 | Dev | [x] | -| 4 | G2 | Skeleton: DashboardTextFormatter (GetHeadlineSegments, FormatCount, FormatSubLine, FormatFooterLink, FormatCurrentTag, FormatVulnerabilityTitle, FormatVulnerabilityDetail), DashboardScanStripFormatter (GetStatusCounts, FormatCountText, FormatStripLabel, FormatSegmentTitle, GetSegmentCssName, FindLatestProblemScan, FormatProblemScanLine), DashboardHeadlineSegmentData, DashboardScanCountData | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardHeadlineSegmentData.cs`, `src/DockerUpdateGuard/UI/DashboardScanCountData.cs` | AC1, AC2, AC3, AC4, AC6 | 3 | Dev | [ ] | +| 4 | G2 | Skeleton: DashboardTextFormatter (GetHeadlineSegments, FormatCount, FormatSubLine, FormatFooterLink, FormatCurrentTag, FormatVulnerabilityTitle, FormatVulnerabilityDetail), DashboardScanStripFormatter (GetStatusCounts, FormatCountText, FormatStripLabel, FormatSegmentTitle, GetSegmentCssName, FindLatestProblemScan, FormatProblemScanLine), DashboardHeadlineSegmentData, DashboardScanCountData | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardHeadlineSegmentData.cs`, `src/DockerUpdateGuard/UI/DashboardScanCountData.cs` | AC1, AC2, AC3, AC4, AC6 | 3 | Dev | [x] | | 5 | G2 | Tests first: formatter tests | `src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardScanStripFormatterTests.cs` | AC1, AC2, AC3, AC4, AC6 | 4 | Tester | [ ] | | 6 | G2 | Implement the formatters | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs` | AC1, AC2, AC3, AC4, AC6 | 5 | Dev | [ ] | | 7 | G3 | Skeleton: empty `DashboardSkeleton` component; delete `MetricGridSkeleton` | `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor.cs` | AC10 | 6 | Dev | [ ] | diff --git a/src/DockerUpdateGuard/UI/DashboardHeadlineSegmentData.cs b/src/DockerUpdateGuard/UI/DashboardHeadlineSegmentData.cs new file mode 100644 index 00000000..56ee4ad7 --- /dev/null +++ b/src/DockerUpdateGuard/UI/DashboardHeadlineSegmentData.cs @@ -0,0 +1,21 @@ +namespace DockerUpdateGuard.UI; + +/// +/// One coloured part of the dashboard headline +/// +public class DashboardHeadlineSegmentData +{ + #region Properties + + /// + /// Segment text + /// + public string Text { get; set; } = string.Empty; + + /// + /// Segment tone + /// + public StatusTone Tone { get; set; } + + #endregion // Properties +} \ No newline at end of file diff --git a/src/DockerUpdateGuard/UI/DashboardScanCountData.cs b/src/DockerUpdateGuard/UI/DashboardScanCountData.cs new file mode 100644 index 00000000..e20e77d2 --- /dev/null +++ b/src/DockerUpdateGuard/UI/DashboardScanCountData.cs @@ -0,0 +1,21 @@ +namespace DockerUpdateGuard.UI; + +/// +/// Number of recent scans with one status +/// +public class DashboardScanCountData +{ + #region Properties + + /// + /// Scan status + /// + public string Status { get; set; } = string.Empty; + + /// + /// Number of scans with the status + /// + public int Count { get; set; } + + #endregion // Properties +} \ No newline at end of file diff --git a/src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs b/src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs new file mode 100644 index 00000000..54ee7261 --- /dev/null +++ b/src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs @@ -0,0 +1,90 @@ +namespace DockerUpdateGuard.UI; + +/// +/// Composes the texts and names of the dashboard scan strip +/// +public static class DashboardScanStripFormatter +{ + #region Constants + + /// + /// Message of the skeleton bodies + /// + private const string SkeletonMessage = "Skeleton: not implemented"; + + #endregion // Constants + + #region Methods + + /// + /// Counts the scans per status in display order + /// + /// Recent scans + /// Status counts + public static IReadOnlyList GetStatusCounts(IReadOnlyList scans) + { + throw new InvalidOperationException(SkeletonMessage); + } + + /// + /// Formats one status count + /// + /// Status count + /// Count text + public static string FormatCountText(DashboardScanCountData count) + { + throw new InvalidOperationException(SkeletonMessage); + } + + /// + /// Formats the accessible label of the strip + /// + /// Status counts + /// Label text + public static string FormatStripLabel(IReadOnlyList counts) + { + throw new InvalidOperationException(SkeletonMessage); + } + + /// + /// Formats the title of a strip segment + /// + /// Scan + /// Title text + public static string FormatSegmentTitle(ScanHistoryItemData scan) + { + throw new InvalidOperationException(SkeletonMessage); + } + + /// + /// Maps a scan status to its segment CSS name + /// + /// Scan status + /// CSS name + public static string GetSegmentCssName(string status) + { + throw new InvalidOperationException(SkeletonMessage); + } + + /// + /// Finds the first failed or partial scan with an error message + /// + /// Recent scans + /// Scan or null + public static ScanHistoryItemData? FindLatestProblemScan(IReadOnlyList scans) + { + throw new InvalidOperationException(SkeletonMessage); + } + + /// + /// Formats the line describing a problem scan + /// + /// Problem scan + /// Line text + public static string FormatProblemScanLine(ScanHistoryItemData scan) + { + throw new InvalidOperationException(SkeletonMessage); + } + + #endregion // Methods +} \ No newline at end of file diff --git a/src/DockerUpdateGuard/UI/DashboardTextFormatter.cs b/src/DockerUpdateGuard/UI/DashboardTextFormatter.cs new file mode 100644 index 00000000..2b10be69 --- /dev/null +++ b/src/DockerUpdateGuard/UI/DashboardTextFormatter.cs @@ -0,0 +1,96 @@ +namespace DockerUpdateGuard.UI; + +/// +/// Composes the user-visible texts of the dashboard +/// +public static class DashboardTextFormatter +{ + #region Constants + + /// + /// Message of the skeleton bodies + /// + private const string SkeletonMessage = "Skeleton: not implemented"; + + #endregion // Constants + + #region Methods + + /// + /// Builds the coloured parts of the headline + /// + /// Number of updates + /// Number of runtime warnings + /// Number of vulnerabilities + /// Headline segments + public static IReadOnlyList GetHeadlineSegments(int updateCount, int runtimeWarningCount, int vulnerabilityCount) + { + throw new InvalidOperationException(SkeletonMessage); + } + + /// + /// Formats a count with its singular or plural noun + /// + /// Count + /// Singular noun + /// Plural noun + /// Count text + public static string FormatCount(int count, string singular, string plural) + { + throw new InvalidOperationException(SkeletonMessage); + } + + /// + /// Formats the sub line under the headline + /// + /// Dashboard view data + /// Sub line text + public static string FormatSubLine(DashboardViewData dashboard) + { + throw new InvalidOperationException(SkeletonMessage); + } + + /// + /// Formats the footer link text of a list + /// + /// Total number of entries + /// Number of shown entries + /// Name of the target page + /// Footer link text + public static string FormatFooterLink(int totalCount, int shownCount, string pageName) + { + throw new InvalidOperationException(SkeletonMessage); + } + + /// + /// Formats the current tag of an update row + /// + /// Update item + /// Current tag text + public static string FormatCurrentTag(DashboardUpdateItemData item) + { + throw new InvalidOperationException(SkeletonMessage); + } + + /// + /// Formats the title of a vulnerability row + /// + /// Vulnerability item + /// Title text + public static string FormatVulnerabilityTitle(DashboardVulnerabilityItemData item) + { + throw new InvalidOperationException(SkeletonMessage); + } + + /// + /// Formats the detail line of a vulnerability row + /// + /// Vulnerability item + /// Detail text + public static string FormatVulnerabilityDetail(DashboardVulnerabilityItemData item) + { + throw new InvalidOperationException(SkeletonMessage); + } + + #endregion // Methods +} \ No newline at end of file From 51f82e81cc1bcd8d7aed3e50e835bea9fc2fe744 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:07:59 +0000 Subject: [PATCH 12/28] Tests first G2 --- specs/feature-453-dashboard-attention/log.md | 1 + .../feature-453-dashboard-attention/tasks.md | 2 +- .../DashboardScanStripFormatterTests.cs | 267 +++++++++++++++ .../DashboardTextFormatterTests.cs | 306 ++++++++++++++++++ 4 files changed, 575 insertions(+), 1 deletion(-) create mode 100644 src/Tests/DockerUpdateGuard.Tests/DashboardScanStripFormatterTests.cs create mode 100644 src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index a0988bef..1a4fcaf1 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -17,3 +17,4 @@ are quoted in full. | 2026-11-29 13:02 | 6 Implement (G1) | Dev | GetDashboardAsync implemented with extracted helpers and narrowed vulnerability query; 2642 tests pass; coverage gate PASS 100% on changed code; build 0 warnings. Notes: ApplicationViewService at RH2111 limit (1500 lines); one flaky unrelated test passed on rerun; EF projection into VulnerabilityFinding unverified on Npgsql (sonnet/medium · 146,905 tokens · 22 tool uses · 373 s · 42 in · 19,504 out · 2,480,972 cache read · 93,648 cache write · 462,719 weighted) | | 2026-11-29 13:03 | 6 Coverage skipped (G1) | Orchestrator | skipped — gate run by orchestrator: PASS, 100% on changed code (183/183 lines, 14/14 conditions), 2642+39 tests green; no deferred test, resource bound has its test | | 2026-11-29 13:04 | 4 Skeleton (G2) | Dev | DashboardTextFormatter, DashboardScanStripFormatter, DashboardHeadlineSegmentData, DashboardScanCountData added; host builds 0 warnings; no pragmas; deviation: private const SkeletonMessage per formatter (S1192) (sonnet/medium · 5,127 tokens · 4 tool uses · 53 s · 10 in · 3,757 out · 353,321 cache read · 47,683 cache write · 113,731 weighted · continued from 4 Skeleton (G1)) | +| 2026-11-29 13:07 | 5 Tests first (G2) | Tester | 53 formatter tests in two files; confirmed by orchestrator: compile, all 53 fail on skeleton. Deferred: none (sonnet/medium · 130,562 tokens · 17 tool uses · 170 s · 26 in · 15,623 out · 1,352,395 cache read · 76,478 cache write · 308,978 weighted) | diff --git a/specs/feature-453-dashboard-attention/tasks.md b/specs/feature-453-dashboard-attention/tasks.md index 2377962a..eec1333b 100644 --- a/specs/feature-453-dashboard-attention/tasks.md +++ b/specs/feature-453-dashboard-attention/tasks.md @@ -8,7 +8,7 @@ Plan: [plan.md](plan.md) | 2 | G1 | Tests first: service tests of the lists, counts and the resource bound, the `SetRecordingDbContext` double, and the adapted `ApplicationViewServiceTests` and `DashboardRenderTests` call sites | `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/Data/SetRecordingDbContext.cs`, `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs` | AC3, AC4, AC5, AC9, AC10 | 1 | Tester | [x] | | 3 | G1 | Implement `GetDashboardAsync` with the extracted helpers `ResolveRuntimeContainerTags`, `CountAffectedContainers`, `SelectAffectedPackages`, `SelectFixedVersions`, `FindBaseRuntimeAlert` | `src/DockerUpdateGuard/UI/ApplicationViewService.cs` | AC3, AC4, AC5, AC9, AC10 | 2 | Dev | [x] | | 4 | G2 | Skeleton: DashboardTextFormatter (GetHeadlineSegments, FormatCount, FormatSubLine, FormatFooterLink, FormatCurrentTag, FormatVulnerabilityTitle, FormatVulnerabilityDetail), DashboardScanStripFormatter (GetStatusCounts, FormatCountText, FormatStripLabel, FormatSegmentTitle, GetSegmentCssName, FindLatestProblemScan, FormatProblemScanLine), DashboardHeadlineSegmentData, DashboardScanCountData | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardHeadlineSegmentData.cs`, `src/DockerUpdateGuard/UI/DashboardScanCountData.cs` | AC1, AC2, AC3, AC4, AC6 | 3 | Dev | [x] | -| 5 | G2 | Tests first: formatter tests | `src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardScanStripFormatterTests.cs` | AC1, AC2, AC3, AC4, AC6 | 4 | Tester | [ ] | +| 5 | G2 | Tests first: formatter tests | `src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardScanStripFormatterTests.cs` | AC1, AC2, AC3, AC4, AC6 | 4 | Tester | [x] | | 6 | G2 | Implement the formatters | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs` | AC1, AC2, AC3, AC4, AC6 | 5 | Dev | [ ] | | 7 | G3 | Skeleton: empty `DashboardSkeleton` component; delete `MetricGridSkeleton` | `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor.cs` | AC10 | 6 | Dev | [ ] | | 8 | G3 | Tests first: page render, persistent state, skeleton and stylesheet tests; `DashboardTests` DataRow; delete `MetricGridSkeletonTests` | `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardPersistentStateTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardSkeletonTests.cs`, `src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/MetricGridSkeletonTests.cs` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC9, AC10 | 7 | Tester | [ ] | diff --git a/src/Tests/DockerUpdateGuard.Tests/DashboardScanStripFormatterTests.cs b/src/Tests/DockerUpdateGuard.Tests/DashboardScanStripFormatterTests.cs new file mode 100644 index 00000000..3c31cc78 --- /dev/null +++ b/src/Tests/DockerUpdateGuard.Tests/DashboardScanStripFormatterTests.cs @@ -0,0 +1,267 @@ +using DockerUpdateGuard.UI; + +namespace DockerUpdateGuard.Tests; + +/// +/// Tests for +/// +[TestClass] +public class DashboardScanStripFormatterTests +{ + #region Methods + + /// + /// Verify counts above zero are returned in the fixed status order + /// + [TestMethod] + [TestCategory("AC6")] + public void DashboardScanStripFormatterGetStatusCountsReturnsCountsAboveZeroInStatusOrder() + { + var scans = new List + { + CreateScan("Failed"), + CreateScan("Succeeded"), + CreateScan("Partial"), + CreateScan("Succeeded"), + CreateScan("Running"), + CreateScan("Succeeded"), + CreateScan("NotSet") + }; + + var counts = DashboardScanStripFormatter.GetStatusCounts(scans); + + var actual = counts.Select(count => $"{count.Status}={count.Count}") + .ToList(); + + Assert.AreSequenceEqual(new List + { + "Succeeded=3", + "Running=1", + "Partial=1", + "Failed=1" + }, + actual, + "Counts must follow the order succeeded, running, pending, partial, failed, skip zero counts and ignore other statuses"); + } + + /// + /// Verify one status count text + /// + [TestMethod] + [TestCategory("AC6")] + public void DashboardScanStripFormatterFormatCountTextReturnsCountAndLowerCaseStatus() + { + var text = DashboardScanStripFormatter.FormatCountText(new() + { + Status = "Succeeded", + Count = 8 + }); + + Assert.AreEqual("8 succeeded", + text, + "The count text must hold the count and the lower-case status"); + } + + /// + /// Verify the strip label joins the counts with commas + /// + [TestMethod] + [TestCategory("AC6")] + public void DashboardScanStripFormatterFormatStripLabelJoinsCountsWithCommas() + { + var counts = new List + { + new() + { + Status = "Succeeded", + Count = 8 + }, + new() + { + Status = "Partial", + Count = 1 + }, + new() + { + Status = "Failed", + Count = 1 + } + }; + + var label = DashboardScanStripFormatter.FormatStripLabel(counts); + + Assert.AreEqual("8 succeeded, 1 partial, 1 failed", + label, + "The strip label must list the counts joined with commas"); + } + + /// + /// Verify the segment title holds type, target, status and the UTC start + /// + [TestMethod] + [TestCategory("AC6")] + public void DashboardScanStripFormatterFormatSegmentTitleReturnsTypeTargetStatusAndUtcStart() + { + var scan = new ScanHistoryItemData + { + Type = "Registry scan", + SubjectName = "nginx:latest", + Status = "Failed", + StartedAtUtc = new DateTimeOffset(2026, 11, 14, 11, 42, 0, TimeSpan.FromHours(2)) + }; + + var title = DashboardScanStripFormatter.FormatSegmentTitle(scan); + + Assert.AreEqual("Registry scan · nginx:latest · Failed · 2026-11-14 09:42 UTC", + title, + "The segment title must hold type, target, status and the start in UTC"); + } + + /// + /// Verify the segment title leaves out a missing target with its separator + /// + /// Target + [TestMethod] + [TestCategory("AC6")] + [DataRow(null)] + [DataRow("")] + public void DashboardScanStripFormatterFormatSegmentTitleWithoutTargetLeavesOutTargetAndSeparator(string? subjectName) + { + var scan = new ScanHistoryItemData + { + Type = "Vulnerability refresh", + SubjectName = subjectName, + Status = "Succeeded", + StartedAtUtc = new DateTimeOffset(2026, 11, 14, 9, 42, 0, TimeSpan.Zero) + }; + + var title = DashboardScanStripFormatter.FormatSegmentTitle(scan); + + Assert.AreEqual("Vulnerability refresh · Succeeded · 2026-11-14 09:42 UTC", + title, + "A run without a target must not leave a doubled separator"); + } + + /// + /// Verify the status maps to its CSS name and unknown statuses to pending + /// + /// Status + /// Expected CSS name + [TestMethod] + [TestCategory("AC6")] + [DataRow("Succeeded", "succeeded")] + [DataRow("Partial", "partial")] + [DataRow("Failed", "failed")] + [DataRow("Running", "running")] + [DataRow("Pending", "pending")] + [DataRow("NotSet", "pending")] + public void DashboardScanStripFormatterGetSegmentCssNameMapsStatus(string status, string expected) + { + var cssName = DashboardScanStripFormatter.GetSegmentCssName(status); + + Assert.AreEqual(expected, + cssName, + "Each known status must map to its CSS name and any other status to pending"); + } + + /// + /// Verify the newest failed or partial run with a message is found + /// + [TestMethod] + [TestCategory("AC6")] + public void DashboardScanStripFormatterFindLatestProblemScanReturnsNewestFailedOrPartialWithMessage() + { + var newestWithoutMessage = CreateScan("Failed"); + var expected = CreateScan("Partial", "second run message"); + var older = CreateScan("Failed", "older message"); + var scans = new List + { + CreateScan("Succeeded", "ignored message"), + newestWithoutMessage, + expected, + older + }; + + var scan = DashboardScanStripFormatter.FindLatestProblemScan(scans); + + Assert.AreSame(expected, + scan, + "The first failed or partial run with an error message must be returned"); + } + + /// + /// Verify no problem run is returned when none has a message + /// + [TestMethod] + [TestCategory("AC6")] + public void DashboardScanStripFormatterFindLatestProblemScanWithoutMessageReturnsNull() + { + var scans = new List + { + CreateScan("Failed"), + CreateScan("Partial", string.Empty), + CreateScan("Succeeded", "message of a good run") + }; + + var scan = DashboardScanStripFormatter.FindLatestProblemScan(scans); + + Assert.IsNull(scan, + "Failed or partial runs without a message and other runs must not be returned"); + } + + /// + /// Verify the problem line holds target and message + /// + [TestMethod] + [TestCategory("AC6")] + public void DashboardScanStripFormatterFormatProblemScanLineWithTargetReturnsTargetAndMessage() + { + var scan = CreateScan("Failed", "registry unreachable"); + scan.SubjectName = "nginx:latest"; + + var line = DashboardScanStripFormatter.FormatProblemScanLine(scan); + + Assert.AreEqual("nginx:latest · registry unreachable", + line, + "The problem line must hold the target and the stored message"); + } + + /// + /// Verify the problem line of a run without a target is the message alone + /// + [TestMethod] + [TestCategory("AC6")] + public void DashboardScanStripFormatterFormatProblemScanLineWithoutTargetReturnsMessageOnly() + { + var scan = CreateScan("Partial", " token expired now"); + + var line = DashboardScanStripFormatter.FormatProblemScanLine(scan); + + Assert.AreEqual(" token expired now", + line, + "A run without a target must show the message as stored"); + } + + #endregion // Methods + + #region Static methods + + /// + /// Create a scan with a status and an optional message + /// + /// Status + /// Error message + /// Scan + private static ScanHistoryItemData CreateScan(string status, string? errorMessage = null) + { + return new ScanHistoryItemData + { + Id = Guid.NewGuid(), + Type = "Registry scan", + Status = status, + ErrorMessage = errorMessage + }; + } + + #endregion // Static methods +} \ No newline at end of file diff --git a/src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs b/src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs new file mode 100644 index 00000000..95b37b27 --- /dev/null +++ b/src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs @@ -0,0 +1,306 @@ +using DockerUpdateGuard.UI; + +namespace DockerUpdateGuard.Tests; + +/// +/// Tests for +/// +[TestClass] +public class DashboardTextFormatterTests +{ + #region Methods + + /// + /// Verify every combination of zero and non-zero counts composes the headline sentence + /// + /// Number of updates + /// Number of runtime warnings + /// Number of vulnerabilities + /// Expected sentence + [TestMethod] + [TestCategory("AC1")] + [DataRow(0, 0, 0, "Everything is up to date.")] + [DataRow(1, 0, 0, "1 update needs attention.")] + [DataRow(0, 1, 0, "1 runtime warning needs attention.")] + [DataRow(0, 0, 1, "1 vulnerability needs attention.")] + [DataRow(2, 0, 0, "2 updates need attention.")] + [DataRow(0, 3, 0, "3 runtime warnings need attention.")] + [DataRow(0, 0, 4, "4 vulnerabilities need attention.")] + [DataRow(1, 1, 0, "1 update and 1 runtime warning need attention.")] + [DataRow(1, 0, 1, "1 update and 1 vulnerability need attention.")] + [DataRow(0, 1, 1, "1 runtime warning and 1 vulnerability need attention.")] + [DataRow(7, 2, 0, "7 updates and 2 runtime warnings need attention.")] + [DataRow(7, 0, 31, "7 updates and 31 vulnerabilities need attention.")] + [DataRow(0, 2, 31, "2 runtime warnings and 31 vulnerabilities need attention.")] + [DataRow(1, 1, 1, "1 update, 1 runtime warning and 1 vulnerability need attention.")] + [DataRow(7, 2, 31, "7 updates, 2 runtime warnings and 31 vulnerabilities need attention.")] + public void DashboardTextFormatterGetHeadlineSegmentsCountCombinationReturnsSentence(int updateCount, int runtimeWarningCount, int vulnerabilityCount, string expectedSentence) + { + var segments = DashboardTextFormatter.GetHeadlineSegments(updateCount, runtimeWarningCount, vulnerabilityCount); + + var sentence = string.Concat(segments.Select(segment => segment.Text)); + + Assert.AreEqual(expectedSentence, + sentence, + "The headline segments must concatenate to the composed sentence"); + } + + /// + /// Verify only the counted parts are colored in the headline + /// + [TestMethod] + [TestCategory("AC1")] + public void DashboardTextFormatterGetHeadlineSegmentsTonesOnlyTheParts() + { + var segments = DashboardTextFormatter.GetHeadlineSegments(7, 2, 31); + + var updates = segments.Single(segment => segment.Text == "7 updates"); + var warnings = segments.Single(segment => segment.Text == "2 runtime warnings"); + var vulnerabilities = segments.Single(segment => segment.Text == "31 vulnerabilities"); + var connectors = segments.Where(segment => segment.Text != updates.Text && segment.Text != warnings.Text && segment.Text != vulnerabilities.Text) + .ToList(); + + Assert.AreEqual(StatusTone.Warning, + updates.Tone, + "The updates part must use the warning tone"); + Assert.AreEqual(StatusTone.Warning, + warnings.Tone, + "The runtime warnings part must use the warning tone"); + Assert.AreEqual(StatusTone.Danger, + vulnerabilities.Tone, + "The vulnerabilities part must use the danger tone"); + Assert.IsNotEmpty(connectors, + "The headline must hold connector segments between and after the parts"); + Assert.IsTrue(connectors.All(segment => segment.Tone == StatusTone.Neutral), + "Connectors and the closing words must use the neutral tone"); + } + + /// + /// Verify the all-clear sentence uses the success tone + /// + [TestMethod] + [TestCategory("AC1")] + public void DashboardTextFormatterGetHeadlineSegmentsWithoutCountsReturnsSuccessSentence() + { + var segments = DashboardTextFormatter.GetHeadlineSegments(0, 0, 0); + + Assert.HasCount(1, + segments, + "The all-clear headline must be one segment"); + Assert.AreEqual(StatusTone.Success, + segments[0].Tone, + "The all-clear sentence must use the success tone"); + } + + /// + /// Verify the count text uses the singular only for one + /// + /// Count + /// Expected text + [TestMethod] + [TestCategory("AC1")] + [DataRow(0, "0 updates")] + [DataRow(1, "1 update")] + [DataRow(2, "2 updates")] + public void DashboardTextFormatterFormatCountPicksSingularOnlyForOne(int count, string expected) + { + var text = DashboardTextFormatter.FormatCount(count, "update", "updates"); + + Assert.AreEqual(expected, + text, + "The count must be followed by the singular only for a count of 1"); + } + + /// + /// Verify the sub line names assets, instances and the UTC start of the newest run + /// + [TestMethod] + [TestCategory("AC2")] + public void DashboardTextFormatterFormatSubLineWithScanReturnsAssetsInstancesAndUtcTime() + { + var dashboard = new DashboardViewData + { + ObservedImageCount = 10, + MyImageCount = 3, + RuntimeContainerCount = 30, + DockerInstanceCount = 2, + RecentScans = [ + new ScanHistoryItemData + { + StartedAtUtc = new DateTimeOffset(2026, 11, 14, 11, 42, 0, TimeSpan.FromHours(2)) + }, + new ScanHistoryItemData + { + StartedAtUtc = new DateTimeOffset(2026, 11, 13, 8, 0, 0, TimeSpan.Zero) + } + ] + }; + + var text = DashboardTextFormatter.FormatSubLine(dashboard); + + Assert.AreEqual("43 protected assets on 2 Docker instances · last activity 2026-11-14 09:42 UTC", + text, + "The sub line must sum the assets and show the newest run's start in UTC"); + } + + /// + /// Verify the sub line without a recorded run + /// + [TestMethod] + [TestCategory("AC2")] + public void DashboardTextFormatterFormatSubLineWithoutScanReturnsNoScansYet() + { + var dashboard = new DashboardViewData + { + ObservedImageCount = 1, + MyImageCount = 1, + RuntimeContainerCount = 2, + DockerInstanceCount = 3 + }; + + var text = DashboardTextFormatter.FormatSubLine(dashboard); + + Assert.AreEqual("4 protected assets on 3 Docker instances · last activity no scans yet", + text, + "Without a recorded run the sub line must end with no scans yet"); + } + + /// + /// Verify the singular forms of the sub line + /// + [TestMethod] + [TestCategory("AC2")] + public void DashboardTextFormatterFormatSubLineSingleInstanceAndAssetUsesSingular() + { + var dashboard = new DashboardViewData + { + RuntimeContainerCount = 1, + DockerInstanceCount = 1 + }; + + var text = DashboardTextFormatter.FormatSubLine(dashboard); + + Assert.AreEqual("1 protected asset on 1 Docker instance · last activity no scans yet", + text, + "One asset and one instance must use the singular nouns"); + } + + /// + /// Verify the current tag of an alias is followed by its resolved version + /// + /// Current tag + /// Resolved version + /// Expected text + [TestMethod] + [TestCategory("AC3")] + [DataRow("latest", "1.25.3", "latest (1.25.3)")] + [DataRow("1.25.3", null, "1.25.3")] + [DataRow("1.25.3", "", "1.25.3")] + public void DashboardTextFormatterFormatCurrentTagWithAliasAppendsResolvedVersion(string currentTag, string? resolvedVersionTag, string expected) + { + var item = new DashboardUpdateItemData + { + CurrentTag = currentTag, + ResolvedVersionTag = resolvedVersionTag + }; + + var text = DashboardTextFormatter.FormatCurrentTag(item); + + Assert.AreEqual(expected, + text, + "The resolved version must follow the current tag in parentheses only when present"); + } + + /// + /// Verify the footer names the remainder or offers to open the page + /// + /// Total entries + /// Shown entries + /// Expected text + [TestMethod] + [TestCategory("AC3")] + [TestCategory("AC4")] + [DataRow(7, 5, "2 more in Runtime Containers")] + [DataRow(6, 5, "1 more in Runtime Containers")] + [DataRow(5, 5, "Open Runtime Containers")] + [DataRow(3, 3, "Open Runtime Containers")] + [DataRow(0, 0, "Open Runtime Containers")] + public void DashboardTextFormatterFormatFooterLinkReturnsRemainderOrOpenText(int totalCount, int shownCount, string expected) + { + var text = DashboardTextFormatter.FormatFooterLink(totalCount, shownCount, "Runtime Containers"); + + Assert.AreEqual(expected, + text, + "The footer must name the remainder when more entries exist than shown, else offer to open the page"); + } + + /// + /// Verify the vulnerability title joins the packages or falls back to the advisory identifier + /// + [TestMethod] + [TestCategory("AC4")] + public void DashboardTextFormatterFormatVulnerabilityTitleWithPackagesJoinsPackages() + { + var item = new DashboardVulnerabilityItemData + { + AdvisoryId = "CVE-2026-0001", + AffectedPackages = ["openssl", "libssl3"] + }; + + var text = DashboardTextFormatter.FormatVulnerabilityTitle(item); + + Assert.AreEqual("openssl, libssl3", + text, + "The title must join the affected packages with a comma"); + } + + /// + /// Verify the vulnerability title without packages is the advisory identifier + /// + [TestMethod] + [TestCategory("AC4")] + public void DashboardTextFormatterFormatVulnerabilityTitleWithoutPackagesReturnsAdvisoryId() + { + var item = new DashboardVulnerabilityItemData + { + AdvisoryId = "CVE-2026-0001", + AffectedPackages = [] + }; + + var text = DashboardTextFormatter.FormatVulnerabilityTitle(item); + + Assert.AreEqual("CVE-2026-0001", + text, + "Without packages the title must be the advisory identifier"); + } + + /// + /// Verify the vulnerability detail line for fixes and container counts + /// + /// Fixed versions joined with a semicolon + /// Affected container count + /// Expected text + [TestMethod] + [TestCategory("AC4")] + [DataRow("3.0.1;3.0.2", 2, "Fixed in 3.0.1, 3.0.2 · 2 running containers")] + [DataRow("3.0.1", 1, "Fixed in 3.0.1 · 1 running container")] + [DataRow("", 1, "No fix available · 1 running container")] + [DataRow("", 4, "No fix available · 4 running containers")] + public void DashboardTextFormatterFormatVulnerabilityDetailReturnsFixAndContainerCount(string fixedVersions, int containerCount, string expected) + { + var item = new DashboardVulnerabilityItemData + { + AdvisoryId = "CVE-2026-0001", + FixedVersions = fixedVersions.Split(';', StringSplitOptions.RemoveEmptyEntries), + AffectedContainerCount = containerCount + }; + + var text = DashboardTextFormatter.FormatVulnerabilityDetail(item); + + Assert.AreEqual(expected, + text, + "The detail must name the fixed versions or no fix and the affected running container count"); + } + + #endregion // Methods +} \ No newline at end of file From c6340f70675bb1e6657b687a144064b31453ef27 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:11:30 +0000 Subject: [PATCH 13/28] Implement G2 --- specs/feature-453-dashboard-attention/log.md | 2 + .../feature-453-dashboard-attention/tasks.md | 2 +- .../UI/DashboardScanStripFormatter.cs | 41 ++++++-- .../UI/DashboardTextFormatter.cs | 95 +++++++++++++++---- 4 files changed, 114 insertions(+), 26 deletions(-) diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 1a4fcaf1..35df1e78 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -18,3 +18,5 @@ are quoted in full. | 2026-11-29 13:03 | 6 Coverage skipped (G1) | Orchestrator | skipped — gate run by orchestrator: PASS, 100% on changed code (183/183 lines, 14/14 conditions), 2642+39 tests green; no deferred test, resource bound has its test | | 2026-11-29 13:04 | 4 Skeleton (G2) | Dev | DashboardTextFormatter, DashboardScanStripFormatter, DashboardHeadlineSegmentData, DashboardScanCountData added; host builds 0 warnings; no pragmas; deviation: private const SkeletonMessage per formatter (S1192) (sonnet/medium · 5,127 tokens · 4 tool uses · 53 s · 10 in · 3,757 out · 353,321 cache read · 47,683 cache write · 113,731 weighted · continued from 4 Skeleton (G1)) | | 2026-11-29 13:07 | 5 Tests first (G2) | Tester | 53 formatter tests in two files; confirmed by orchestrator: compile, all 53 fail on skeleton. Deferred: none (sonnet/medium · 130,562 tokens · 17 tool uses · 170 s · 26 in · 15,623 out · 1,352,395 cache read · 76,478 cache write · 308,978 weighted) | +| 2026-11-29 13:11 | 6 Implement (G2) | Dev | Both formatters implemented, 53 tests green, 2695+39 tests pass; coverage gate PASS 100% on changed code (248/248 lines, 56/56 conditions); no spec conflicts with test-fixed details (sonnet/medium · 20,081 tokens · 8 tool uses · 201 s · 16 in · 6,263 out · 999,635 cache read · 111,697 cache write · 270,916 weighted · continued) | +| 2026-11-29 13:11 | 6 Coverage skipped (G2) | Orchestrator | skipped — gate PASS 100% on changed code reported by the Dev; no deferred tests, no resource bound | diff --git a/specs/feature-453-dashboard-attention/tasks.md b/specs/feature-453-dashboard-attention/tasks.md index eec1333b..46380362 100644 --- a/specs/feature-453-dashboard-attention/tasks.md +++ b/specs/feature-453-dashboard-attention/tasks.md @@ -9,7 +9,7 @@ Plan: [plan.md](plan.md) | 3 | G1 | Implement `GetDashboardAsync` with the extracted helpers `ResolveRuntimeContainerTags`, `CountAffectedContainers`, `SelectAffectedPackages`, `SelectFixedVersions`, `FindBaseRuntimeAlert` | `src/DockerUpdateGuard/UI/ApplicationViewService.cs` | AC3, AC4, AC5, AC9, AC10 | 2 | Dev | [x] | | 4 | G2 | Skeleton: DashboardTextFormatter (GetHeadlineSegments, FormatCount, FormatSubLine, FormatFooterLink, FormatCurrentTag, FormatVulnerabilityTitle, FormatVulnerabilityDetail), DashboardScanStripFormatter (GetStatusCounts, FormatCountText, FormatStripLabel, FormatSegmentTitle, GetSegmentCssName, FindLatestProblemScan, FormatProblemScanLine), DashboardHeadlineSegmentData, DashboardScanCountData | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardHeadlineSegmentData.cs`, `src/DockerUpdateGuard/UI/DashboardScanCountData.cs` | AC1, AC2, AC3, AC4, AC6 | 3 | Dev | [x] | | 5 | G2 | Tests first: formatter tests | `src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardScanStripFormatterTests.cs` | AC1, AC2, AC3, AC4, AC6 | 4 | Tester | [x] | -| 6 | G2 | Implement the formatters | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs` | AC1, AC2, AC3, AC4, AC6 | 5 | Dev | [ ] | +| 6 | G2 | Implement the formatters | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs` | AC1, AC2, AC3, AC4, AC6 | 5 | Dev | [x] | | 7 | G3 | Skeleton: empty `DashboardSkeleton` component; delete `MetricGridSkeleton` | `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor.cs` | AC10 | 6 | Dev | [ ] | | 8 | G3 | Tests first: page render, persistent state, skeleton and stylesheet tests; `DashboardTests` DataRow; delete `MetricGridSkeletonTests` | `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardPersistentStateTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardSkeletonTests.cs`, `src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/MetricGridSkeletonTests.cs` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC9, AC10 | 7 | Tester | [ ] | | 9 | G3 | Rewrite the dashboard page, the skeleton markup and the dashboard rules of the stylesheet | `src/DockerUpdateGuard/Components/Pages/Dashboard.razor`, `src/DockerUpdateGuard/Components/Pages/Dashboard.razor.cs`, `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/wwwroot/app.css` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC10 | 8 | Dev | [ ] | diff --git a/src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs b/src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs index 54ee7261..d0800b7b 100644 --- a/src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs +++ b/src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs @@ -8,12 +8,21 @@ public static class DashboardScanStripFormatter #region Constants /// - /// Message of the skeleton bodies + /// Name of the pending status, also the CSS name of every unknown status /// - private const string SkeletonMessage = "Skeleton: not implemented"; + private const string PendingStatus = "Pending"; #endregion // Constants + #region Fields + + /// + /// Scan statuses in display order + /// + private static readonly string[] _statusOrder = ["Succeeded", "Running", PendingStatus, "Partial", "Failed"]; + + #endregion // Fields + #region Methods /// @@ -23,7 +32,14 @@ public static class DashboardScanStripFormatter /// Status counts public static IReadOnlyList GetStatusCounts(IReadOnlyList scans) { - throw new InvalidOperationException(SkeletonMessage); + return [ + .. _statusOrder.Select(status => new DashboardScanCountData + { + Status = status, + Count = scans.Count(scan => scan.Status == status), + }) + .Where(count => count.Count > 0) + ]; } /// @@ -33,7 +49,7 @@ public static IReadOnlyList GetStatusCounts(IReadOnlyLis /// Count text public static string FormatCountText(DashboardScanCountData count) { - throw new InvalidOperationException(SkeletonMessage); + return $"{count.Count} {count.Status.ToLowerInvariant()}"; } /// @@ -43,7 +59,7 @@ public static string FormatCountText(DashboardScanCountData count) /// Label text public static string FormatStripLabel(IReadOnlyList counts) { - throw new InvalidOperationException(SkeletonMessage); + return string.Join(", ", counts.Select(FormatCountText)); } /// @@ -53,7 +69,9 @@ public static string FormatStripLabel(IReadOnlyList coun /// Title text public static string FormatSegmentTitle(ScanHistoryItemData scan) { - throw new InvalidOperationException(SkeletonMessage); + var subject = string.IsNullOrEmpty(scan.SubjectName) ? string.Empty : $"{scan.SubjectName} · "; + + return $"{scan.Type} · {subject}{scan.Status} · {TimestampFormatter.Format(scan.StartedAtUtc)}"; } /// @@ -63,7 +81,9 @@ public static string FormatSegmentTitle(ScanHistoryItemData scan) /// CSS name public static string GetSegmentCssName(string status) { - throw new InvalidOperationException(SkeletonMessage); + return _statusOrder.Contains(status) && status != PendingStatus + ? status.ToLowerInvariant() + : PendingStatus.ToLowerInvariant(); } /// @@ -73,7 +93,8 @@ public static string GetSegmentCssName(string status) /// Scan or null public static ScanHistoryItemData? FindLatestProblemScan(IReadOnlyList scans) { - throw new InvalidOperationException(SkeletonMessage); + return scans.FirstOrDefault(scan => (scan.Status == "Failed" || scan.Status == "Partial") + && string.IsNullOrEmpty(scan.ErrorMessage) == false); } /// @@ -83,7 +104,9 @@ public static string GetSegmentCssName(string status) /// Line text public static string FormatProblemScanLine(ScanHistoryItemData scan) { - throw new InvalidOperationException(SkeletonMessage); + var subject = string.IsNullOrEmpty(scan.SubjectName) ? string.Empty : $"{scan.SubjectName} · "; + + return $"{subject}{scan.ErrorMessage}"; } #endregion // Methods diff --git a/src/DockerUpdateGuard/UI/DashboardTextFormatter.cs b/src/DockerUpdateGuard/UI/DashboardTextFormatter.cs index 2b10be69..ba5132ae 100644 --- a/src/DockerUpdateGuard/UI/DashboardTextFormatter.cs +++ b/src/DockerUpdateGuard/UI/DashboardTextFormatter.cs @@ -5,15 +5,6 @@ namespace DockerUpdateGuard.UI; /// public static class DashboardTextFormatter { - #region Constants - - /// - /// Message of the skeleton bodies - /// - private const string SkeletonMessage = "Skeleton: not implemented"; - - #endregion // Constants - #region Methods /// @@ -25,7 +16,45 @@ public static class DashboardTextFormatter /// Headline segments public static IReadOnlyList GetHeadlineSegments(int updateCount, int runtimeWarningCount, int vulnerabilityCount) { - throw new InvalidOperationException(SkeletonMessage); + var parts = new List(); + + if (updateCount > 0) + { + parts.Add(CreateSegment(FormatCount(updateCount, "update", "updates"), StatusTone.Warning)); + } + + if (runtimeWarningCount > 0) + { + parts.Add(CreateSegment(FormatCount(runtimeWarningCount, "runtime warning", "runtime warnings"), StatusTone.Warning)); + } + + if (vulnerabilityCount > 0) + { + parts.Add(CreateSegment(FormatCount(vulnerabilityCount, "vulnerability", "vulnerabilities"), StatusTone.Danger)); + } + + if (parts.Count == 0) + { + return [CreateSegment("Everything is up to date.", StatusTone.Success)]; + } + + var segments = new List(); + + for (var index = 0; index < parts.Count; index++) + { + if (index > 0) + { + segments.Add(CreateSegment(index == parts.Count - 1 ? " and " : ", ", StatusTone.Neutral)); + } + + segments.Add(parts[index]); + } + + var isSingleItem = parts.Count == 1 && (updateCount + runtimeWarningCount + vulnerabilityCount) == 1; + + segments.Add(CreateSegment(isSingleItem ? " needs attention." : " need attention.", StatusTone.Neutral)); + + return segments; } /// @@ -37,7 +66,7 @@ public static IReadOnlyList GetHeadlineSegments(in /// Count text public static string FormatCount(int count, string singular, string plural) { - throw new InvalidOperationException(SkeletonMessage); + return $"{count} {(count == 1 ? singular : plural)}"; } /// @@ -47,7 +76,12 @@ public static string FormatCount(int count, string singular, string plural) /// Sub line text public static string FormatSubLine(DashboardViewData dashboard) { - throw new InvalidOperationException(SkeletonMessage); + var assetCount = dashboard.ObservedImageCount + dashboard.MyImageCount + dashboard.RuntimeContainerCount; + var lastActivity = dashboard.RecentScans.Count > 0 + ? TimestampFormatter.Format(dashboard.RecentScans[0].StartedAtUtc) + : "no scans yet"; + + return $"{FormatCount(assetCount, "protected asset", "protected assets")} on {FormatCount(dashboard.DockerInstanceCount, "Docker instance", "Docker instances")} · last activity {lastActivity}"; } /// @@ -59,7 +93,9 @@ public static string FormatSubLine(DashboardViewData dashboard) /// Footer link text public static string FormatFooterLink(int totalCount, int shownCount, string pageName) { - throw new InvalidOperationException(SkeletonMessage); + return totalCount > shownCount + ? $"{totalCount - shownCount} more in {pageName}" + : $"Open {pageName}"; } /// @@ -69,7 +105,9 @@ public static string FormatFooterLink(int totalCount, int shownCount, string pag /// Current tag text public static string FormatCurrentTag(DashboardUpdateItemData item) { - throw new InvalidOperationException(SkeletonMessage); + return string.IsNullOrWhiteSpace(item.ResolvedVersionTag) + ? item.CurrentTag + : $"{item.CurrentTag} ({item.ResolvedVersionTag})"; } /// @@ -79,7 +117,9 @@ public static string FormatCurrentTag(DashboardUpdateItemData item) /// Title text public static string FormatVulnerabilityTitle(DashboardVulnerabilityItemData item) { - throw new InvalidOperationException(SkeletonMessage); + return item.AffectedPackages.Count > 0 + ? string.Join(", ", item.AffectedPackages) + : item.AdvisoryId; } /// @@ -89,8 +129,31 @@ public static string FormatVulnerabilityTitle(DashboardVulnerabilityItemData ite /// Detail text public static string FormatVulnerabilityDetail(DashboardVulnerabilityItemData item) { - throw new InvalidOperationException(SkeletonMessage); + var fix = item.FixedVersions.Count > 0 + ? $"Fixed in {string.Join(", ", item.FixedVersions)}" + : "No fix available"; + + return $"{fix} · {FormatCount(item.AffectedContainerCount, "running container", "running containers")}"; } #endregion // Methods + + #region Static methods + + /// + /// Creates a headline segment + /// + /// Segment text + /// Segment tone + /// Headline segment + private static DashboardHeadlineSegmentData CreateSegment(string text, StatusTone tone) + { + return new DashboardHeadlineSegmentData + { + Text = text, + Tone = tone, + }; + } + + #endregion // Static methods } \ No newline at end of file From ac6df5ddb04623dfe78fe6371ec27e72e02fc5bb Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:12:19 +0000 Subject: [PATCH 14/28] Skeleton G3 --- specs/feature-453-dashboard-attention/log.md | 1 + .../feature-453-dashboard-attention/tasks.md | 2 +- .../Components/Common/DashboardSkeleton.razor | 0 .../Common/DashboardSkeleton.razor.cs | 6 +++ .../Common/MetricGridSkeleton.razor | 8 --- .../Common/MetricGridSkeleton.razor.cs | 19 ------- .../Common/PageHeaderSkeleton.razor | 10 ---- .../Common/PageHeaderSkeleton.razor.cs | 6 --- .../Components/Pages/Dashboard.razor | 3 +- .../MetricGridSkeletonTests.cs | 51 ------------------- .../PageHeaderSkeletonTests.cs | 38 -------------- 11 files changed, 9 insertions(+), 135 deletions(-) create mode 100644 src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor create mode 100644 src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor.cs delete mode 100644 src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor delete mode 100644 src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor.cs delete mode 100644 src/DockerUpdateGuard/Components/Common/PageHeaderSkeleton.razor delete mode 100644 src/DockerUpdateGuard/Components/Common/PageHeaderSkeleton.razor.cs delete mode 100644 src/Tests/DockerUpdateGuard.Tests/MetricGridSkeletonTests.cs delete mode 100644 src/Tests/DockerUpdateGuard.Tests/PageHeaderSkeletonTests.cs diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 35df1e78..57acb53b 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -20,3 +20,4 @@ are quoted in full. | 2026-11-29 13:07 | 5 Tests first (G2) | Tester | 53 formatter tests in two files; confirmed by orchestrator: compile, all 53 fail on skeleton. Deferred: none (sonnet/medium · 130,562 tokens · 17 tool uses · 170 s · 26 in · 15,623 out · 1,352,395 cache read · 76,478 cache write · 308,978 weighted) | | 2026-11-29 13:11 | 6 Implement (G2) | Dev | Both formatters implemented, 53 tests green, 2695+39 tests pass; coverage gate PASS 100% on changed code (248/248 lines, 56/56 conditions); no spec conflicts with test-fixed details (sonnet/medium · 20,081 tokens · 8 tool uses · 201 s · 16 in · 6,263 out · 999,635 cache read · 111,697 cache write · 270,916 weighted · continued) | | 2026-11-29 13:11 | 6 Coverage skipped (G2) | Orchestrator | skipped — gate PASS 100% on changed code reported by the Dev; no deferred tests, no resource bound | +| 2026-11-29 13:12 | 4 Skeleton (G3) | Dev | Empty DashboardSkeleton with code-behind; MetricGridSkeleton, PageHeaderSkeleton and their tests deleted (challenge note 3); Dashboard.razor adapted to build; solution 0 warnings. Deviations: PageHeaderSkeleton deletion and MetricGridSkeletonTests deletion moved into this step (sonnet/medium · 6,363 tokens · 5 tool uses · 39 s · 12 in · 2,426 out · 479,254 cache read · 53,767 cache write · 127,276 weighted · continued from 4 Skeleton (G1)) | diff --git a/specs/feature-453-dashboard-attention/tasks.md b/specs/feature-453-dashboard-attention/tasks.md index 46380362..231e3cb4 100644 --- a/specs/feature-453-dashboard-attention/tasks.md +++ b/specs/feature-453-dashboard-attention/tasks.md @@ -10,7 +10,7 @@ Plan: [plan.md](plan.md) | 4 | G2 | Skeleton: DashboardTextFormatter (GetHeadlineSegments, FormatCount, FormatSubLine, FormatFooterLink, FormatCurrentTag, FormatVulnerabilityTitle, FormatVulnerabilityDetail), DashboardScanStripFormatter (GetStatusCounts, FormatCountText, FormatStripLabel, FormatSegmentTitle, GetSegmentCssName, FindLatestProblemScan, FormatProblemScanLine), DashboardHeadlineSegmentData, DashboardScanCountData | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardHeadlineSegmentData.cs`, `src/DockerUpdateGuard/UI/DashboardScanCountData.cs` | AC1, AC2, AC3, AC4, AC6 | 3 | Dev | [x] | | 5 | G2 | Tests first: formatter tests | `src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardScanStripFormatterTests.cs` | AC1, AC2, AC3, AC4, AC6 | 4 | Tester | [x] | | 6 | G2 | Implement the formatters | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs` | AC1, AC2, AC3, AC4, AC6 | 5 | Dev | [x] | -| 7 | G3 | Skeleton: empty `DashboardSkeleton` component; delete `MetricGridSkeleton` | `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor.cs` | AC10 | 6 | Dev | [ ] | +| 7 | G3 | Skeleton: empty `DashboardSkeleton` component; delete `MetricGridSkeleton` | `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor.cs` | AC10 | 6 | Dev | [x] | | 8 | G3 | Tests first: page render, persistent state, skeleton and stylesheet tests; `DashboardTests` DataRow; delete `MetricGridSkeletonTests` | `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardPersistentStateTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardSkeletonTests.cs`, `src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/MetricGridSkeletonTests.cs` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC9, AC10 | 7 | Tester | [ ] | | 9 | G3 | Rewrite the dashboard page, the skeleton markup and the dashboard rules of the stylesheet | `src/DockerUpdateGuard/Components/Pages/Dashboard.razor`, `src/DockerUpdateGuard/Components/Pages/Dashboard.razor.cs`, `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/wwwroot/app.css` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC10 | 8 | Dev | [ ] | | 10 | G3 | Image build check (a `.razor` content item was added and one removed) | — | AC10 | 9 | Dev | [ ] | diff --git a/src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor b/src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor new file mode 100644 index 00000000..e69de29b diff --git a/src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor.cs b/src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor.cs new file mode 100644 index 00000000..55212de4 --- /dev/null +++ b/src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor.cs @@ -0,0 +1,6 @@ +namespace DockerUpdateGuard.Components.Common; + +/// +/// Skeleton placeholder that mirrors the dashboard while data is loading +/// +public sealed partial class DashboardSkeleton; \ No newline at end of file diff --git a/src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor b/src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor deleted file mode 100644 index 59328078..00000000 --- a/src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor +++ /dev/null @@ -1,8 +0,0 @@ - - @for (var index = 0; index < Cards; index++) - { - - - - } - \ No newline at end of file diff --git a/src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor.cs b/src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor.cs deleted file mode 100644 index fece7fdd..00000000 --- a/src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.AspNetCore.Components; - -namespace DockerUpdateGuard.Components.Common; - -/// -/// Skeleton placeholder that mirrors the dashboard metric-card grid while data is loading -/// -public sealed partial class MetricGridSkeleton -{ - #region Properties - - /// - /// Number of placeholder metric cards to render - /// - [Parameter] - public int Cards { get; set; } = 6; - - #endregion // Properties -} \ No newline at end of file diff --git a/src/DockerUpdateGuard/Components/Common/PageHeaderSkeleton.razor b/src/DockerUpdateGuard/Components/Common/PageHeaderSkeleton.razor deleted file mode 100644 index 7cdac9cc..00000000 --- a/src/DockerUpdateGuard/Components/Common/PageHeaderSkeleton.razor +++ /dev/null @@ -1,10 +0,0 @@ -
-
-
- - - - -
-
-
\ No newline at end of file diff --git a/src/DockerUpdateGuard/Components/Common/PageHeaderSkeleton.razor.cs b/src/DockerUpdateGuard/Components/Common/PageHeaderSkeleton.razor.cs deleted file mode 100644 index 6caaa23b..00000000 --- a/src/DockerUpdateGuard/Components/Common/PageHeaderSkeleton.razor.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace DockerUpdateGuard.Components.Common; - -/// -/// Skeleton placeholder that mirrors the page header while data is loading -/// -public sealed partial class PageHeaderSkeleton; \ No newline at end of file diff --git a/src/DockerUpdateGuard/Components/Pages/Dashboard.razor b/src/DockerUpdateGuard/Components/Pages/Dashboard.razor index 2d5f2e46..99498b58 100644 --- a/src/DockerUpdateGuard/Components/Pages/Dashboard.razor +++ b/src/DockerUpdateGuard/Components/Pages/Dashboard.razor @@ -11,8 +11,7 @@ } else { - - + } } diff --git a/src/Tests/DockerUpdateGuard.Tests/MetricGridSkeletonTests.cs b/src/Tests/DockerUpdateGuard.Tests/MetricGridSkeletonTests.cs deleted file mode 100644 index 70c94691..00000000 --- a/src/Tests/DockerUpdateGuard.Tests/MetricGridSkeletonTests.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Bunit; - -using DockerUpdateGuard.Components.Common; -using DockerUpdateGuard.Tests.Helper; - -namespace DockerUpdateGuard.Tests; - -/// -/// Tests for -/// -[TestClass] -public class MetricGridSkeletonTests -{ - #region Methods - - /// - /// Verify the metric grid skeleton renders the requested number of card placeholders - /// - /// Task - [TestMethod] - public async Task MetricGridSkeletonRendersRequestedCardCount() - { - var testContext = BlazorTestContextFactory.Create(); - - await using (testContext) - { - var component = testContext.Render(parameters => parameters.Add(skeleton => skeleton.Cards, 4)); - - Assert.AreEqual(4, MarkupTestHelper.CountOccurrences(component.Markup, "dug-skeleton-card"), "The metric grid skeleton must render one card placeholder per requested card"); - } - } - - /// - /// Verify the metric grid skeleton defaults to six card placeholders - /// - /// Task - [TestMethod] - public async Task MetricGridSkeletonDefaultRendersSixCards() - { - var testContext = BlazorTestContextFactory.Create(); - - await using (testContext) - { - var component = testContext.Render(); - - Assert.AreEqual(6, MarkupTestHelper.CountOccurrences(component.Markup, "dug-skeleton-card"), "The metric grid skeleton must render six card placeholders by default"); - } - } - - #endregion // Methods -} \ No newline at end of file diff --git a/src/Tests/DockerUpdateGuard.Tests/PageHeaderSkeletonTests.cs b/src/Tests/DockerUpdateGuard.Tests/PageHeaderSkeletonTests.cs deleted file mode 100644 index c6a2b45d..00000000 --- a/src/Tests/DockerUpdateGuard.Tests/PageHeaderSkeletonTests.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Bunit; - -using DockerUpdateGuard.Components.Common; -using DockerUpdateGuard.Tests.Helper; - -namespace DockerUpdateGuard.Tests; - -/// -/// Tests for -/// -[TestClass] -public class PageHeaderSkeletonTests -{ - #region Methods - - /// - /// Verify the header skeleton has the shape of the page header with two placeholder bars - /// - /// Task - [TestMethod] - [TestCategory("AC6")] - public async Task PageHeaderSkeletonRendersPageHeaderShape() - { - var testContext = BlazorTestContextFactory.Create(); - - await using (testContext) - { - var component = testContext.Render(); - var markup = component.Markup; - - Assert.HasCount(1, component.FindAll("header.dug-page-header"), "The header skeleton must render the page header element"); - Assert.DoesNotContain("hero-panel", markup, "The header skeleton must no longer render the hero panel"); - Assert.AreEqual(2, MarkupTestHelper.CountSkeletons(markup), "The header skeleton must render a title and a description bar"); - } - } - - #endregion // Methods -} \ No newline at end of file From f7500b6e14b31f1e2f8616636e7bd273ba98fcbf Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:16:35 +0000 Subject: [PATCH 15/28] Tests first G3 --- specs/feature-453-dashboard-attention/log.md | 1 + .../feature-453-dashboard-attention/tasks.md | 2 +- .../AppStylesheetDashboardTests.cs | 87 ++ .../DashboardPersistentStateTests.cs | 76 ++ .../DashboardRenderTests.cs | 969 ++++++++++++++---- .../DashboardSkeletonTests.cs | 37 + .../DockerUpdateGuard.Tests/DashboardTests.cs | 2 +- 7 files changed, 998 insertions(+), 176 deletions(-) create mode 100644 src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs create mode 100644 src/Tests/DockerUpdateGuard.Tests/DashboardPersistentStateTests.cs create mode 100644 src/Tests/DockerUpdateGuard.Tests/DashboardSkeletonTests.cs diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 57acb53b..e6200fa9 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -21,3 +21,4 @@ are quoted in full. | 2026-11-29 13:11 | 6 Implement (G2) | Dev | Both formatters implemented, 53 tests green, 2695+39 tests pass; coverage gate PASS 100% on changed code (248/248 lines, 56/56 conditions); no spec conflicts with test-fixed details (sonnet/medium · 20,081 tokens · 8 tool uses · 201 s · 16 in · 6,263 out · 999,635 cache read · 111,697 cache write · 270,916 weighted · continued) | | 2026-11-29 13:11 | 6 Coverage skipped (G2) | Orchestrator | skipped — gate PASS 100% on changed code reported by the Dev; no deferred tests, no resource bound | | 2026-11-29 13:12 | 4 Skeleton (G3) | Dev | Empty DashboardSkeleton with code-behind; MetricGridSkeleton, PageHeaderSkeleton and their tests deleted (challenge note 3); Dashboard.razor adapted to build; solution 0 warnings. Deviations: PageHeaderSkeleton deletion and MetricGridSkeletonTests deletion moved into this step (sonnet/medium · 6,363 tokens · 5 tool uses · 39 s · 12 in · 2,426 out · 479,254 cache read · 53,767 cache write · 127,276 weighted · continued from 4 Skeleton (G1)) | +| 2026-11-29 13:16 | 5 Tests first (G3) | Tester | Page, skeleton, persistent-state, stylesheet and DashboardTests adapted/added; confirmed by orchestrator: 37 of 119 fail on the current page (all new/adapted), kept tests pass. Deferred: none (sonnet/medium · 55,740 tokens · 11 tool uses · 224 s · 24 in · 30,726 out · 1,677,344 cache read · 54,909 cache write · 390,025 weighted · continued) | diff --git a/specs/feature-453-dashboard-attention/tasks.md b/specs/feature-453-dashboard-attention/tasks.md index 231e3cb4..e40000ab 100644 --- a/specs/feature-453-dashboard-attention/tasks.md +++ b/specs/feature-453-dashboard-attention/tasks.md @@ -11,7 +11,7 @@ Plan: [plan.md](plan.md) | 5 | G2 | Tests first: formatter tests | `src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardScanStripFormatterTests.cs` | AC1, AC2, AC3, AC4, AC6 | 4 | Tester | [x] | | 6 | G2 | Implement the formatters | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs` | AC1, AC2, AC3, AC4, AC6 | 5 | Dev | [x] | | 7 | G3 | Skeleton: empty `DashboardSkeleton` component; delete `MetricGridSkeleton` | `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor.cs` | AC10 | 6 | Dev | [x] | -| 8 | G3 | Tests first: page render, persistent state, skeleton and stylesheet tests; `DashboardTests` DataRow; delete `MetricGridSkeletonTests` | `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardPersistentStateTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardSkeletonTests.cs`, `src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/MetricGridSkeletonTests.cs` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC9, AC10 | 7 | Tester | [ ] | +| 8 | G3 | Tests first: page render, persistent state, skeleton and stylesheet tests; `DashboardTests` DataRow; delete `MetricGridSkeletonTests` | `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardPersistentStateTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardSkeletonTests.cs`, `src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/MetricGridSkeletonTests.cs` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC9, AC10 | 7 | Tester | [x] | | 9 | G3 | Rewrite the dashboard page, the skeleton markup and the dashboard rules of the stylesheet | `src/DockerUpdateGuard/Components/Pages/Dashboard.razor`, `src/DockerUpdateGuard/Components/Pages/Dashboard.razor.cs`, `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/wwwroot/app.css` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC10 | 8 | Dev | [ ] | | 10 | G3 | Image build check (a `.razor` content item was added and one removed) | — | AC10 | 9 | Dev | [ ] | | 11 | G3 | Area document: dashboard row, new *Dashboard* subsection, chip and font sentences, decision 0080 link | `docs/areas/web-ui.md` | AC11 | 9 | Dev | [ ] | diff --git a/src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs b/src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs new file mode 100644 index 00000000..b6c9aba3 --- /dev/null +++ b/src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs @@ -0,0 +1,87 @@ +using DockerUpdateGuard.Tests.Helper; + +namespace DockerUpdateGuard.Tests; + +/// +/// Tests for the dashboard rules of the shipped stylesheet wwwroot/app.css +/// +[TestClass] +public class AppStylesheetDashboardTests +{ + #region Constants + + /// + /// Shipped stylesheet below the host project directory + /// + private const string StylesheetPath = "wwwroot/app.css"; + + #endregion // Constants + + #region Methods + + /// + /// Verify each scan strip segment takes its color from a status token + /// + /// Segment CSS name + /// Expected token, or empty when only a token is required + [TestMethod] + [TestCategory("AC6")] + [DataRow("succeeded", "var(--dug-scan-succeeded)")] + [DataRow("partial", "var(--dug-scan-partial)")] + [DataRow("failed", "var(--dug-scan-failed)")] + [DataRow("running", "")] + [DataRow("pending", "")] + public void AppStylesheetDashboardScanSegmentsUseStatusTokens(string cssName, string expectedToken) + { + var declarations = StylesheetReader.GetDeclarations(StylesheetReader.ReadHostFile(StylesheetPath), $".dug-scan-strip__segment--{cssName}"); + + var hasBackground = declarations.TryGetValue("background", out var background) || declarations.TryGetValue("background-color", out background); + + Assert.IsTrue(hasBackground, $"The {cssName} segment must set a background"); + Assert.StartsWith("var(--dug-", background!, $"The {cssName} segment must use a --dug- token"); + + if (expectedToken.Length > 0) + { + Assert.AreEqual(expectedToken, background, $"The {cssName} segment must use its status token"); + } + } + + /// + /// Verify the dashboard rules exist and use no literal colors + /// + [TestMethod] + [TestCategory("AC10")] + public void AppStylesheetDashboardRulesUseOnlyTokenColors() + { + var rules = StylesheetReader.GetRules(StylesheetReader.ReadHostFile(StylesheetPath)) + .Where(rule => rule.Selector.Contains(".dug-dashboard", StringComparison.Ordinal) + || rule.Selector.Contains(".dug-scan-strip", StringComparison.Ordinal) + || rule.Selector.Contains(".dug-inventory", StringComparison.Ordinal)) + .ToList(); + var literalColors = rules.Where(rule => System.Text.RegularExpressions.Regex.IsMatch(rule.Body, @"#[0-9a-fA-F]{3,8}\b|rgba?\(|hsla?\(")) + .Select(rule => rule.Selector) + .ToList(); + + Assert.IsNotEmpty(rules, "The stylesheet must hold the dashboard rules"); + Assert.IsEmpty(literalColors, $"Dashboard rules must use tokens only: {string.Join(", ", literalColors)}"); + } + + /// + /// Verify the visually hidden helper and the headline rules exist + /// + /// Selector + [TestMethod] + [TestCategory("AC10")] + [DataRow(".dug-visually-hidden")] + [DataRow(".dug-dashboard__headline")] + [DataRow(".dug-scan-strip")] + [DataRow(".dug-inventory")] + public void AppStylesheetDashboardRuleExists(string selector) + { + var declarations = StylesheetReader.GetDeclarations(StylesheetReader.ReadHostFile(StylesheetPath), selector); + + Assert.IsNotEmpty(declarations, $"The stylesheet must hold a rule for {selector}"); + } + + #endregion // Methods +} \ No newline at end of file diff --git a/src/Tests/DockerUpdateGuard.Tests/DashboardPersistentStateTests.cs b/src/Tests/DockerUpdateGuard.Tests/DashboardPersistentStateTests.cs new file mode 100644 index 00000000..26cd83e6 --- /dev/null +++ b/src/Tests/DockerUpdateGuard.Tests/DashboardPersistentStateTests.cs @@ -0,0 +1,76 @@ +using Bunit; + +using DockerUpdateGuard.Configuration; +using DockerUpdateGuard.Tests.Helper; +using DockerUpdateGuard.UI; + +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; + +using NSubstitute; + +using DashboardPage = DockerUpdateGuard.Components.Pages.Dashboard; + +namespace DockerUpdateGuard.Tests; + +/// +/// Persistent-state tests for +/// +[TestClass] +public class DashboardPersistentStateTests +{ + #region Constants + + /// + /// Persistent-state key used by the page + /// + private const string StateKey = "Dashboard.State"; + + #endregion // Constants + + #region Methods + + /// + /// Verify the page reuses the prerendered dashboard without loading it again + /// + /// Task + [TestMethod] + [TestCategory("AC10")] + public async Task DashboardWithPersistedStateDoesNotLoadAgain() + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var viewService = Substitute.For(); + + testContext.Services.AddSingleton(viewService); + testContext.Services.AddSingleton(new DashboardRefreshState()); + testContext.Services.AddSingleton(Options.Create(new DockerUpdateGuardOptions())); + + var persistentState = testContext.GetPersistentComponentState(); + + persistentState.Persist(StateKey, + new DashboardViewData + { + UpdateCount = 1, + Updates = [ + new DashboardUpdateItemData + { + ContainerId = "restored-id", + ContainerName = "restored-container", + DockerInstanceName = "docker-a", + CurrentTag = "1.0" + } + ] + }); + + var component = testContext.Render(); + + Assert.Contains("restored-container", component.Markup, "The page must render the dashboard restored from persistent state"); + await viewService.DidNotReceive().GetDashboardAsync(Arg.Any()).ConfigureAwait(false); + } + } + + #endregion // Methods +} \ No newline at end of file diff --git a/src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs b/src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs index 15fb22f0..7084f225 100644 --- a/src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs +++ b/src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs @@ -25,47 +25,61 @@ public class DashboardRenderTests #region Methods /// - /// Verify the recent scans description names only the run types that are recorded + /// Verify the info banner is rendered when vulnerability scanning is disabled /// /// Task [TestMethod] - [TestCategory("AC2")] - public async Task DashboardRecentScansDescriptionNamesOnlyRecordedRunTypes() + [TestCategory("AC10")] + public async Task DashboardWithDisabledVulnerabilityScanningRendersInfoBanner() { var testContext = BlazorTestContextFactory.Create(); await using (testContext) { - var viewService = Substitute.For(); + var markup = RenderDashboardMarkup(testContext, VulnerabilityConfigurationHintKind.ScanningDisabled); - viewService.GetDashboardAsync(Arg.Any()) - .Returns(Task.FromResult(new DashboardViewData())); + Assert.Contains("Vulnerability scanning is disabled", + markup, + "The dashboard must explain how to enable vulnerability scanning when it is switched off"); + Assert.Contains("DockerUpdateGuard:Vulnerabilities:Enabled", + markup, + "The disabled banner must name the configuration key that enables vulnerability scanning"); + } + } - testContext.Services.AddSingleton(viewService); - testContext.Services.AddSingleton(new DashboardRefreshState()); - testContext.Services.AddSingleton(Options.Create(new DockerUpdateGuardOptions())); + /// + /// Verify no configuration banner is rendered for a correctly configured provider + /// + /// Task + [TestMethod] + [TestCategory("AC10")] + public async Task DashboardWithConfiguredVulnerabilityProviderRendersNoBanner() + { + var testContext = BlazorTestContextFactory.Create(); - var component = testContext.Render(); - var header = component.FindAll(".section-header") - .Single(element => element.QuerySelector("h5")?.TextContent.Trim() == "Recent scans"); - var description = header.QuerySelector(".section-description")!.TextContent.Trim(); - var lowerCaseDescription = description.ToLowerInvariant(); - - Assert.AreEqual("Latest observed image scans, runtime container scans and vulnerability refreshes.", - description, - "The description must name exactly the recorded run types"); - Assert.DoesNotContain("discovery", lowerCaseDescription, "The description must not claim discovery runs"); - Assert.DoesNotContain("cleanup", lowerCaseDescription, "The description must not claim cleanup runs"); + await using (testContext) + { + var markup = RenderDashboardMarkup(testContext, VulnerabilityConfigurationHintKind.None); + + Assert.DoesNotContain("Vulnerability scanning is disabled", + markup, + "The disabled banner must not be rendered while vulnerability scanning is enabled"); + Assert.DoesNotContain("DockerUpdateGuard:Vulnerabilities:TrivyBaseUrl", + markup, + "The misconfiguration banner must not be rendered for a correctly configured provider"); } } /// - /// Verify the number metric tiles render for the phone two-up grid, including the optional My Images and Base Images tiles + /// Verify a failed first load shows the fixed error alert in place of the skeleton and logs the failure once /// /// Task [TestMethod] - public async Task DashboardWithConfiguredAccountRendersMetricTiles() + [TestCategory("AC10")] + public async Task DashboardLoadFailureShowsFixedErrorAndLogs() { + var exception = new InvalidOperationException("secret text"); + var logger = new TestLogger(); var testContext = BlazorTestContextFactory.Create(); await using (testContext) @@ -73,286 +87,893 @@ public async Task DashboardWithConfiguredAccountRendersMetricTiles() var viewService = Substitute.For(); viewService.GetDashboardAsync(Arg.Any()) - .Returns(Task.FromResult(new DashboardViewData - { - ObservedImageCount = 3, - MyImageCount = 2, - DockerInstanceCount = 1, - RuntimeContainerCount = 5, - BaseImageCount = 4, - UpdateCount = 1, - RuntimeWarningCount = 0, - VulnerabilityCount = 2, - })); - - var options = Options.Create(new DockerUpdateGuardOptions - { - DockerHub = - { - UserName = "octocat", - Pat = "token", - }, - }); + .Returns(Task.FromException(exception)); testContext.Services.AddSingleton(viewService); testContext.Services.AddSingleton(new DashboardRefreshState()); - testContext.Services.AddSingleton(options); - testContext.AddBunitPersistentComponentState(); + testContext.Services.AddSingleton(Options.Create(new DockerUpdateGuardOptions())); + testContext.Services.AddSingleton>(logger); - var component = testContext.Render(); - var markup = component.Markup; + var page = testContext.Render(); - Assert.Contains("My Images", markup, "The My Images tile must render when a Docker Hub account is configured"); - Assert.Contains("Shared Base Images", markup, "The Shared Base Images tile must render when shared base images exist"); - Assert.Contains("Observed Images", markup, "The Observed Images metric tile must render"); - Assert.Contains("metric-value", markup, "The number metric tiles must render their values"); - Assert.Contains("metric-card__icon", markup, "The metric tiles must render an icon badge"); + await DetailPageAssert.AssertLoadErrorAsync(page, "Loading the dashboard failed: unexpected error", "secret text").ConfigureAwait(false); + DetailPageAssert.AssertLoadLoggedOnce(logger, "LoadDashboard", exception); } } /// - /// Verify the dashboard names the shared base images tile and summary card and links the tile to the page + /// Verify a refresh signal whose reload fails keeps the shown dashboard, shows no alert and logs the failure once /// /// Task [TestMethod] - [TestCategory("AC7")] - public async Task DashboardWithSharedBaseImagesRendersSharedBaseImagesLabelsAsync() + [TestCategory("AC10")] + public async Task DashboardFailedRefreshKeepsDashboardAndLogs() { + var exception = new InvalidOperationException("secret text"); + var logger = new TestLogger(); + var refreshState = new DashboardRefreshState(); var testContext = BlazorTestContextFactory.Create(); await using (testContext) { var viewService = Substitute.For(); + var dashboard = new DashboardViewData + { + RecentScans = [ + new ScanHistoryItemData + { + Type = "Runtime", + Status = "Succeeded", + SubjectName = "kept-scan-subject", + StartedAtUtc = DateTimeOffset.UtcNow, + }, + ], + }; viewService.GetDashboardAsync(Arg.Any()) - .Returns(Task.FromResult(new DashboardViewData - { - BaseImageCount = 2, - })); + .Returns(Task.FromResult(dashboard), Task.FromException(exception)); testContext.Services.AddSingleton(viewService); - testContext.Services.AddSingleton(new DashboardRefreshState()); + testContext.Services.AddSingleton(refreshState); testContext.Services.AddSingleton(Options.Create(new DockerUpdateGuardOptions())); - testContext.AddBunitPersistentComponentState(); + testContext.Services.AddSingleton>(logger); - var component = testContext.Render(); - var tileLink = component.FindAll("a").SingleOrDefault(link => link.GetAttribute("href") == "/base-images"); + var page = testContext.Render(); + var alertCount = page.FindAll(".mud-alert").Count; + + Assert.Contains("kept-scan-subject", page.Markup, "The first load must show the dashboard"); + + await page.InvokeAsync(() => refreshState.NotifyChanged()).ConfigureAwait(false); + await page.WaitForAssertionAsync(() => DetailPageAssert.AssertLoadLoggedOnce(logger, "LoadDashboard", exception), TimeSpan.FromSeconds(DetailPageAssert.WaitSeconds)).ConfigureAwait(false); - Assert.IsNotNull(tileLink, "The shared base images tile must link to the base images page"); - Assert.Contains("Shared Base Images", tileLink.TextContent, "The metric tile must read Shared Base Images"); - Assert.Contains("Shared base images", component.Markup, "The summary card must read Shared base images"); + Assert.Contains("kept-scan-subject", page.Markup, "A failed reload must keep the dashboard shown"); + Assert.HasCount(alertCount, page.FindAll(".mud-alert"), "A failed reload must show no alert"); + Assert.DoesNotContain("secret text", page.Markup, "A failed reload must not show the exception's text"); } } /// - /// Verify the info banner is rendered when vulnerability scanning is disabled + /// Verify the headline shows the counted parts in their tones /// /// Task [TestMethod] - public async Task DashboardWithDisabledVulnerabilityScanningRendersInfoBanner() + [TestCategory("AC1")] + public async Task DashboardWithCountsRendersHeadlineWithColoredParts() { var testContext = BlazorTestContextFactory.Create(); await using (testContext) { - var markup = RenderDashboardMarkup(testContext, VulnerabilityConfigurationHintKind.ScanningDisabled); + var component = RenderDashboard(testContext, CreateDashboard()); + + var headline = component.Find("h1.dug-dashboard__headline"); + var warningParts = component.FindAll("h1 .dug-dashboard__headline-part--warning") + .Select(element => element.TextContent.Trim()) + .ToList(); + var dangerParts = component.FindAll("h1 .dug-dashboard__headline-part--danger") + .Select(element => element.TextContent.Trim()) + .ToList(); + + Assert.AreEqual("7 updates, 2 runtime warnings and 31 vulnerabilities need attention.", + Normalize(headline.TextContent), + "The headline must name the three counted parts"); + Assert.AreSequenceEqual(new List + { + "7 updates", + "2 runtime warnings" + }, + warningParts, + "Updates and runtime warnings must be colored with the warning tone"); + Assert.AreSequenceEqual(new List + { + "31 vulnerabilities" + }, + dangerParts, + "Vulnerabilities must be colored with the danger tone"); + } + } - Assert.Contains("Vulnerability scanning is disabled", - markup, - "The dashboard must explain how to enable vulnerability scanning when it is switched off"); - Assert.Contains("DockerUpdateGuard:Vulnerabilities:Enabled", - markup, - "The disabled banner must name the configuration key that enables vulnerability scanning"); + /// + /// Verify the headline counts equal the counts of the panels + /// + /// Task + [TestMethod] + [TestCategory("AC9")] + public async Task DashboardHeadlineCountsEqualPanelCounts() + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var component = RenderDashboard(testContext, CreateDashboard()); + + var updatesCount = FindPanel(component, "Updates available").QuerySelector(".dug-dashboard__count--warning")!.TextContent.Trim(); + var vulnerabilitiesCount = FindPanel(component, "Vulnerabilities").QuerySelector(".dug-dashboard__count--danger")!.TextContent.Trim(); + var warningsCount = FindPanel(component, "Own base runtime warnings").QuerySelector(".dug-dashboard__count--warning")!.TextContent.Trim(); + var headline = Normalize(component.Find("h1.dug-dashboard__headline").TextContent); + + Assert.AreEqual("7", updatesCount, "The updates panel must show the update count"); + Assert.AreEqual("31", vulnerabilitiesCount, "The vulnerabilities panel must show the vulnerability count"); + Assert.AreEqual("2", warningsCount, "The runtime warnings panel must show the warning count"); + Assert.Contains($"{updatesCount} updates", headline, "The headline must use the updates panel count"); + Assert.Contains($"{warningsCount} runtime warnings", headline, "The headline must use the warnings panel count"); + Assert.Contains($"{vulnerabilitiesCount} vulnerabilities", headline, "The headline must use the vulnerabilities panel count"); } } /// - /// Verify no configuration banner is rendered for a correctly configured provider + /// Verify the sub line shows assets, instances and the latest activity in UTC /// /// Task [TestMethod] - public async Task DashboardWithConfiguredVulnerabilityProviderRendersNoBanner() + [TestCategory("AC2")] + public async Task DashboardWithRecentScanRendersSubLineWithUtcActivity() { var testContext = BlazorTestContextFactory.Create(); await using (testContext) { - var markup = RenderDashboardMarkup(testContext, VulnerabilityConfigurationHintKind.None); + var dashboard = CreateDashboard(); - Assert.DoesNotContain("Vulnerability scanning is disabled", - markup, - "The disabled banner must not be rendered while vulnerability scanning is enabled"); - Assert.DoesNotContain("DockerUpdateGuard:Vulnerabilities:TrivyBaseUrl", - markup, - "The misconfiguration banner must not be rendered for a correctly configured provider"); + dashboard.ObservedImageCount = 10; + dashboard.MyImageCount = 3; + dashboard.RuntimeContainerCount = 30; + dashboard.DockerInstanceCount = 2; + dashboard.RecentScans = [CreateScan("Succeeded", "Runtime", "local", new DateTimeOffset(2026, 11, 14, 11, 42, 0, TimeSpan.FromHours(2)))]; + + var component = RenderDashboard(testContext, dashboard); + + Assert.AreEqual("43 protected assets on 2 Docker instances · last activity 2026-11-14 09:42 UTC", + Normalize(component.Find("p.dug-dashboard__subline").TextContent), + "The sub line must show the protected assets, the instances and the latest activity in UTC"); } } /// - /// Verify the recent scans table shows the scan start in UTC with the zone suffix + /// Verify the updates panel renders rows, links and the footer /// + /// Total update count + /// Number of shown entries + /// Expected footer text /// Task [TestMethod] [TestCategory("AC3")] - public async Task DashboardWithRecentScanRendersStartedInUtcAsync() + [DataRow(7, 5, "2 more in Runtime Containers")] + [DataRow(3, 3, "Open Runtime Containers")] + public async Task DashboardUpdatesPanelRendersRowsLinksAndFooter(int total, int shown, string expectedFooter) { var testContext = BlazorTestContextFactory.Create(); await using (testContext) { - var viewService = Substitute.For(); + var dashboard = CreateDashboard(); + var instanceId = Guid.NewGuid(); + + dashboard.UpdateCount = total; + dashboard.Updates = [.. Enumerable.Range(1, shown).Select(index => CreateUpdate($"web-{index}", instanceId))]; + + var component = RenderDashboard(testContext, dashboard); + + var panel = FindPanel(component, "Updates available"); + var rows = panel.QuerySelectorAll("ul.dug-dashboard__list > li > a.dug-dashboard__row"); + var firstRow = rows[0]; + var footer = panel.QuerySelector("a.dug-dashboard__footer-link")!; + + Assert.HasCount(shown, rows, "The panel must render one row per shown update"); + Assert.AreEqual($"/runtime-containers/{instanceId}/container-web-1", + firstRow.GetAttribute("href"), + "The row must link to the container detail"); + Assert.AreEqual("web-1", firstRow.QuerySelector(".dug-dashboard__row-title")!.TextContent.Trim(), "The row title must be the container name"); + Assert.AreEqual("docker-a", firstRow.QuerySelector(".dug-dashboard__row-aside")!.TextContent.Trim(), "The row aside must be the instance name"); + Assert.Contains("latest (1.25.3)", Normalize(firstRow.QuerySelector(".dug-dashboard__row-detail")!.TextContent), "The detail must show the current tag with its resolved version"); + Assert.Contains("→", firstRow.QuerySelector(".dug-dashboard__row-detail")!.TextContent, "The detail must show an arrow to the available tag"); + Assert.AreEqual("1.26.0", firstRow.QuerySelector(".dug-dashboard__row-target")!.TextContent.Trim(), "The available tag must be marked as target"); + Assert.AreEqual(expectedFooter, footer.TextContent.Trim(), "The footer must name the remainder or offer to open the page"); + Assert.AreEqual("/runtime-containers", footer.GetAttribute("href"), "The footer must open the Runtime Containers page"); + } + } - viewService.GetDashboardAsync(Arg.Any()) - .Returns(Task.FromResult(new DashboardViewData - { - RecentScans = [ - new ScanHistoryItemData - { - Type = "Runtime", - Status = "Succeeded", - SubjectName = "local", - StartedAtUtc = new DateTimeOffset(2026, 11, 23, 23, 27, 0, TimeSpan.FromHours(2)), - }, - ], - })); + /// + /// Verify an update row without an available tag shows the current tag only + /// + /// Task + [TestMethod] + [TestCategory("AC3")] + public async Task DashboardUpdatesPanelWithoutAvailableTagRendersCurrentTagOnly() + { + var testContext = BlazorTestContextFactory.Create(); - testContext.Services.AddSingleton(viewService); - testContext.Services.AddSingleton(new DashboardRefreshState()); - testContext.Services.AddSingleton(Options.Create(new DockerUpdateGuardOptions())); - testContext.AddBunitPersistentComponentState(); + await using (testContext) + { + var dashboard = CreateDashboard(); + var update = CreateUpdate("web-1", Guid.NewGuid()); - var component = testContext.Render(); + update.AvailableUpdateVersionTag = null; + update.ResolvedVersionTag = null; + update.CurrentTag = "1.25.3"; + dashboard.UpdateCount = 1; + dashboard.Updates = [update]; + + var component = RenderDashboard(testContext, dashboard); + + var detail = FindPanel(component, "Updates available").QuerySelector(".dug-dashboard__row-detail")!; - Assert.Contains("2026-11-23 21:27 UTC", component.Markup, "The recent scan start must be shown in UTC with the zone suffix"); + Assert.AreEqual("1.25.3", Normalize(detail.TextContent), "The detail must show the current tag only"); + Assert.IsNull(detail.QuerySelector(".dug-dashboard__row-target"), "No target must be rendered without an available tag"); } } /// - /// Verify a failed first load shows the fixed error alert in place of the skeleton and logs the failure once + /// Verify an updates panel without entries shows its empty text and no count /// /// Task [TestMethod] - [TestCategory("AC1")] - [TestCategory("AC2")] - public async Task DashboardLoadFailureShowsFixedErrorAndLogs() + [TestCategory("AC3")] + public async Task DashboardUpdatesPanelWithoutEntriesRendersEmptyTextWithoutCount() + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var dashboard = CreateDashboard(); + + dashboard.UpdateCount = 0; + dashboard.Updates = []; + + var component = RenderDashboard(testContext, dashboard); + + var panel = FindPanel(component, "Updates available"); + + Assert.AreEqual("No updates available.", panel.QuerySelector("p.dug-dashboard__empty")!.TextContent.Trim(), "The panel must show its empty text"); + Assert.IsNull(panel.QuerySelector("[class*='dug-dashboard__count--']"), "The panel must show no count at 0"); + Assert.IsNull(panel.QuerySelector("a.dug-dashboard__row"), "The panel must show no row"); + } + } + + /// + /// Verify the vulnerabilities panel renders the bar, rows, accessible identifier, link and footer + /// + /// Task + [TestMethod] + [TestCategory("AC4")] + public async Task DashboardVulnerabilitiesPanelRendersBarRowsAndAccessibleIdentifier() + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var dashboard = CreateDashboard(); + + dashboard.VulnerabilityCount = 5; + dashboard.VulnerabilityAdvisorySeveritySummary = new VulnerabilitySeveritySummaryViewData + { + CriticalCount = 2, + HighCount = 3 + }; + dashboard.Vulnerabilities = [ + new DashboardVulnerabilityItemData + { + AdvisoryId = "CVE-2026-0001", + Severity = "Critical", + AffectedPackages = ["openssl", "libssl3"], + FixedVersions = ["3.0.1"], + AffectedContainerCount = 2 + } + ]; + + var component = RenderDashboard(testContext, dashboard); + + var panel = FindPanel(component, "Vulnerabilities"); + var row = panel.QuerySelector("ul.dug-dashboard__list > li > a.dug-dashboard__row")!; + var footer = panel.QuerySelector("a.dug-dashboard__footer-link")!; + + Assert.IsNotNull(panel.QuerySelector(".dug-severity"), "The panel must render the severity bar"); + Assert.AreEqual("/vulnerabilities", row.GetAttribute("href"), "The row must open the Vulnerabilities page"); + Assert.Contains("openssl, libssl3", row.QuerySelector(".dug-dashboard__row-title")!.TextContent, "The title must name the affected packages"); + Assert.AreEqual("CVE-2026-0001", row.QuerySelector("span.dug-visually-hidden")!.TextContent.Trim(), "The advisory identifier must be announced with the row"); + Assert.AreEqual("Critical", row.QuerySelector(".dug-dashboard__row-aside .dug-chip")!.TextContent.Trim(), "The severity must be shown as a chip"); + Assert.AreEqual("Fixed in 3.0.1 · 2 running containers", + Normalize(row.QuerySelector(".dug-dashboard__row-detail")!.TextContent), + "The detail must show the fix and the container count"); + Assert.AreEqual("4 more in Vulnerabilities", footer.TextContent.Trim(), "The footer must name the remainder"); + Assert.AreEqual("/vulnerabilities", footer.GetAttribute("href"), "The footer must open the Vulnerabilities page"); + } + } + + /// + /// Verify a vulnerabilities panel without entries shows its empty text and no bar + /// + /// Task + [TestMethod] + [TestCategory("AC4")] + public async Task DashboardVulnerabilitiesPanelWithoutEntriesRendersEmptyTextWithoutBar() + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var dashboard = CreateDashboard(); + + dashboard.VulnerabilityCount = 0; + dashboard.Vulnerabilities = []; + dashboard.VulnerabilityAdvisorySeveritySummary = new VulnerabilitySeveritySummaryViewData(); + + var component = RenderDashboard(testContext, dashboard); + + var panel = FindPanel(component, "Vulnerabilities"); + + Assert.AreEqual("No vulnerabilities in running containers.", panel.QuerySelector("p.dug-dashboard__empty")!.TextContent.Trim(), "The panel must show its empty text"); + Assert.IsNull(panel.QuerySelector(".dug-severity"), "The panel must render no severity bar"); + Assert.IsNull(panel.QuerySelector("[class*='dug-dashboard__count--']"), "The panel must show no count at 0"); + } + } + + /// + /// Verify the runtime warnings panel renders rows, link and footer + /// + /// Task + [TestMethod] + [TestCategory("AC5")] + public async Task DashboardRuntimeWarningsPanelRendersRowsAndFooter() + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var dashboard = CreateDashboard(); + var imageId = Guid.NewGuid(); + + dashboard.RuntimeWarningCount = 7; + dashboard.RuntimeWarnings = [ + new DashboardRuntimeWarningItemData + { + Id = imageId, + Name = "company/api", + BaseRuntimeAlertSummary = "Base runtime 8.0 is outdated" + } + ]; + + var component = RenderDashboard(testContext, dashboard, true); + + var panel = FindPanel(component, "Own base runtime warnings"); + var row = panel.QuerySelector("ul.dug-dashboard__list > li > a.dug-dashboard__row")!; + var footer = panel.QuerySelector("a.dug-dashboard__footer-link")!; + + Assert.AreEqual($"/my-images/{imageId}", row.GetAttribute("href"), "The row must open the image detail"); + Assert.Contains("company/api", row.TextContent, "The row must show the image name"); + Assert.Contains("Base runtime 8.0 is outdated", row.TextContent, "The row must show the alert summary"); + Assert.AreEqual("6 more in My Images", footer.TextContent.Trim(), "The footer must name the remainder"); + Assert.AreEqual("/my-images", footer.GetAttribute("href"), "The footer must open the My Images page"); + } + } + + /// + /// Verify the runtime warnings panel has no footer when all entries are shown + /// + /// Task + [TestMethod] + [TestCategory("AC5")] + public async Task DashboardRuntimeWarningsPanelWithAllEntriesShownRendersNoFooter() + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var component = RenderDashboard(testContext, CreateDashboard(), true); + + var panel = FindPanel(component, "Own base runtime warnings"); + + Assert.AreEqual(1, + panel.QuerySelectorAll("a.dug-dashboard__row").Length, + "The panel must show the one warning"); + Assert.IsNull(panel.QuerySelector("a.dug-dashboard__footer-link"), "The panel must have no footer when nothing remains"); + } + } + + /// + /// Verify the runtime warnings panel is hidden without an account and without warnings + /// + /// Task + [TestMethod] + [TestCategory("AC5")] + public async Task DashboardRuntimeWarningsPanelWithoutAccountAndWarningsIsHidden() + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var dashboard = CreateDashboard(); + + dashboard.RuntimeWarningCount = 0; + dashboard.RuntimeWarnings = []; + + var component = RenderDashboard(testContext, dashboard); + + var titles = component.FindAll("section.dug-panel h2") + .Select(title => title.TextContent.Trim()) + .ToList(); + + Assert.DoesNotContain("Own base runtime warnings", titles, "The runtime warnings panel must not be rendered"); + Assert.Contains("Updates available", titles, "The other panels must still be rendered"); + } + } + + /// + /// Verify the runtime warnings panel with an account and without warnings shows its empty text + /// + /// Task + [TestMethod] + [TestCategory("AC5")] + public async Task DashboardRuntimeWarningsPanelWithAccountAndNoWarningsRendersEmptyText() + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var dashboard = CreateDashboard(); + + dashboard.RuntimeWarningCount = 0; + dashboard.RuntimeWarnings = []; + + var component = RenderDashboard(testContext, dashboard, true); + + var panel = FindPanel(component, "Own base runtime warnings"); + + Assert.AreEqual("No runtime warnings.", panel.QuerySelector("p.dug-dashboard__empty")!.TextContent.Trim(), "The panel must show its empty text"); + Assert.IsNull(panel.QuerySelector("[class*='dug-dashboard__count--']"), "The panel must show no count at 0"); + } + } + + /// + /// Verify the scan panel renders the strip, the count line, the problem line and the link + /// + /// Task + [TestMethod] + [TestCategory("AC6")] + public async Task DashboardScanPanelRendersStripCountsProblemLineAndLink() + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var dashboard = CreateDashboard(); + var failed = CreateScan("Failed", "Registry", "nginx:latest", new DateTimeOffset(2026, 11, 14, 9, 42, 0, TimeSpan.Zero)); + + failed.ErrorMessage = "registry unreachable"; + dashboard.RecentScans = [ + failed, + CreateScan("Succeeded", "Vulnerability refresh", null, new DateTimeOffset(2026, 11, 14, 8, 0, 0, TimeSpan.Zero)), + CreateScan("Succeeded", "Runtime", "local", new DateTimeOffset(2026, 11, 14, 7, 0, 0, TimeSpan.Zero)), + CreateScan("Running", "Runtime", "local", new DateTimeOffset(2026, 11, 14, 6, 0, 0, TimeSpan.Zero)) + ]; + + var component = RenderDashboard(testContext, dashboard); + + var panel = FindPanel(component, "Last 10 scans"); + var strip = panel.QuerySelector("div.dug-scan-strip")!; + var segments = strip.QuerySelectorAll("span[class*='dug-scan-strip__segment--']"); + var classNames = segments.Select(segment => segment.ClassName!.Split(' ').Single(name => name.StartsWith("dug-scan-strip__segment--", StringComparison.Ordinal))) + .ToList(); + var footer = panel.QuerySelector("a.dug-dashboard__footer-link")!; + + Assert.AreEqual("img", strip.GetAttribute("role"), "The strip must be announced as an image"); + Assert.AreEqual("2 succeeded, 1 running, 1 failed", strip.GetAttribute("aria-label"), "The strip must be named by the counts"); + Assert.AreSequenceEqual(new List + { + "dug-scan-strip__segment--failed", + "dug-scan-strip__segment--succeeded", + "dug-scan-strip__segment--succeeded", + "dug-scan-strip__segment--running" + }, + classNames, + "The segments must follow the run order, newest first, with one status class each"); + Assert.AreEqual("Registry · nginx:latest · Failed · 2026-11-14 09:42 UTC", segments[0].GetAttribute("title"), "The segment must carry the tooltip text"); + Assert.AreEqual("Vulnerability refresh · Succeeded · 2026-11-14 08:00 UTC", segments[1].GetAttribute("title"), "A run without a target must leave out the target"); + Assert.AreEqual("2 succeeded · 1 running · 1 failed", Normalize(panel.QuerySelector("p.dug-dashboard__scan-counts")!.TextContent), "The count line must list the counts"); + Assert.AreEqual("1 failed", panel.QuerySelector("p.dug-dashboard__scan-counts strong.dug-dashboard__scan-failed")!.TextContent.Trim(), "The failed count must be emphasized"); + Assert.AreEqual("nginx:latest · registry unreachable", Normalize(panel.QuerySelector("p.dug-dashboard__scan-problem")!.TextContent), "The problem line must name the newest failed run"); + Assert.AreEqual("Open scan history", footer.TextContent.Trim(), "The footer must offer the scan history"); + Assert.AreEqual("/scan-history", footer.GetAttribute("href"), "The footer must open the scan history"); + } + } + + /// + /// Verify the scan panel without runs shows its empty text and keeps the link + /// + /// Task + [TestMethod] + [TestCategory("AC6")] + public async Task DashboardScanPanelWithoutRunsRendersEmptyText() + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var dashboard = CreateDashboard(); + + dashboard.RecentScans = []; + + var component = RenderDashboard(testContext, dashboard); + + var panel = FindPanel(component, "Last 10 scans"); + + Assert.AreEqual("No scans have been recorded yet.", panel.QuerySelector("p.dug-dashboard__empty")!.TextContent.Trim(), "The panel must show its empty text"); + Assert.IsNull(panel.QuerySelector("div.dug-scan-strip"), "The panel must show no strip"); + Assert.IsNull(panel.QuerySelector("p.dug-dashboard__scan-counts"), "The panel must show no count line"); + Assert.IsNotNull(panel.QuerySelector("a.dug-dashboard__footer-link[href='/scan-history']"), "The scan history link must stay"); + } + } + + /// + /// Verify the inventory strip shows its cells under the visibility rules + /// + /// Whether a Docker Hub account is configured + /// Number of shared base images + /// Expected labels joined with a comma + /// Task + [TestMethod] + [TestCategory("AC7")] + [DataRow(true, 2, "My Images,Observed Images,Runtime Containers,Docker Instances,Base Images")] + [DataRow(false, 2, "Observed Images,Runtime Containers,Docker Instances,Base Images")] + [DataRow(true, 0, "My Images,Observed Images,Runtime Containers,Docker Instances")] + [DataRow(false, 0, "Observed Images,Runtime Containers,Docker Instances")] + public async Task DashboardInventoryStripRendersCellsWithVisibilityRules(bool withAccount, int baseImageCount, string expectedLabels) + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var dashboard = CreateDashboard(); + + dashboard.BaseImageCount = baseImageCount; + dashboard.ObservedImageCount = 3; + + var component = RenderDashboard(testContext, dashboard, withAccount); + + var cells = component.FindAll("section.dug-inventory a.dug-inventory__cell"); + var labels = cells.Select(cell => cell.QuerySelector(".dug-inventory__label")!.TextContent.Trim()) + .ToList(); + var observed = cells.Single(cell => cell.QuerySelector(".dug-inventory__label")!.TextContent.Trim() == "Observed Images"); + + Assert.AreEqual(expectedLabels, string.Join(",", labels), "The strip must show the cells its visibility rules allow"); + Assert.AreEqual("/observed-images", observed.GetAttribute("href"), "The cell must link to its page"); + Assert.AreEqual("3", observed.QuerySelector(".dug-inventory__value")!.TextContent.Trim(), "The cell must show its figure"); + } + } + + /// + /// Verify the all-clear state replaces the list panels by the nothing-to-do panel + /// + /// Task + [TestMethod] + [TestCategory("AC8")] + public async Task DashboardWithoutFindingsRendersNothingToDoPanel() + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var component = RenderDashboard(testContext, CreateAllClearDashboard(), true); + + var titles = component.FindAll("section.dug-panel h2") + .Select(title => title.TextContent.Trim()) + .ToList(); + var nothingToDo = FindPanel(component, "Nothing to do"); + + Assert.AreEqual("Everything is up to date.", Normalize(component.Find("h1.dug-dashboard__headline").TextContent), "The headline must be the all-clear sentence"); + Assert.AreEqual("No updates available, no own base runtime warnings and no vulnerabilities in running containers.", + Normalize(nothingToDo.TextContent), + "The panel must explain the all-clear state"); + Assert.AreSequenceEqual(new List + { + "Nothing to do", + "Last 10 scans" + }, + titles, + "Only the nothing-to-do panel and the scan panel must remain"); + Assert.IsNotNull(component.Find("section.dug-inventory"), "The inventory strip must stay"); + } + } + + /// + /// Verify the all-clear state keeps the scanning disabled hint + /// + /// Task + [TestMethod] + [TestCategory("AC8")] + public async Task DashboardWithoutFindingsAndScanningDisabledRendersHintAndAllClear() + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var dashboard = CreateAllClearDashboard(); + + dashboard.VulnerabilityScanningEnabled = false; + dashboard.VulnerabilityConfigurationHint = VulnerabilityConfigurationHintKind.ScanningDisabled; + + var component = RenderDashboard(testContext, dashboard); + + Assert.Contains("Vulnerability scanning is disabled", component.Markup, "The hint must be shown with the all-clear state"); + Assert.AreEqual("Everything is up to date.", Normalize(component.Find("h1.dug-dashboard__headline").TextContent), "The headline must be the all-clear sentence"); + Assert.IsNotNull(FindPanel(component, "Nothing to do"), "The nothing-to-do panel must be shown"); + } + } + + /// + /// Verify the dashboard shows its skeleton while loading + /// + /// Task + [TestMethod] + [TestCategory("AC10")] + public async Task DashboardWhileLoadingRendersDashboardSkeleton() { - var exception = new InvalidOperationException("secret text"); - var logger = new TestLogger(); var testContext = BlazorTestContextFactory.Create(); await using (testContext) { + var completion = new TaskCompletionSource(); var viewService = Substitute.For(); viewService.GetDashboardAsync(Arg.Any()) - .Returns(Task.FromException(exception)); + .Returns(completion.Task); testContext.Services.AddSingleton(viewService); testContext.Services.AddSingleton(new DashboardRefreshState()); testContext.Services.AddSingleton(Options.Create(new DockerUpdateGuardOptions())); - testContext.Services.AddSingleton>(logger); - var page = testContext.Render(); + var component = testContext.Render(); - await DetailPageAssert.AssertLoadErrorAsync(page, "Loading the dashboard failed: unexpected error", "secret text").ConfigureAwait(false); - DetailPageAssert.AssertLoadLoggedOnce(logger, "LoadDashboard", exception); + Assert.IsNotNull(component.Find(".dug-dashboard-skeleton__headline"), "The skeleton must be shown while loading"); + Assert.IsEmpty(component.FindAll("h1.dug-dashboard__headline"), "No headline must be shown while loading"); + + completion.SetResult(CreateDashboard()); } } /// - /// Verify a refresh signal whose reload fails keeps the shown dashboard, shows no alert and logs the failure once + /// Verify a refresh signal reloads the dashboard /// /// Task [TestMethod] - [TestCategory("AC7")] - public async Task DashboardFailedRefreshKeepsDashboardAndLogs() + [TestCategory("AC10")] + public async Task DashboardRefreshSignalReloadsDashboard() { - var exception = new InvalidOperationException("secret text"); - var logger = new TestLogger(); var refreshState = new DashboardRefreshState(); var testContext = BlazorTestContextFactory.Create(); await using (testContext) { var viewService = Substitute.For(); - var dashboard = new DashboardViewData - { - RecentScans = [ - new ScanHistoryItemData - { - Type = "Runtime", - Status = "Succeeded", - SubjectName = "kept-scan-subject", - StartedAtUtc = DateTimeOffset.UtcNow, - }, - ], - }; + var first = CreateDashboard(); + var second = CreateDashboard(); + first.Updates = [CreateUpdate("first-container", Guid.NewGuid())]; + second.Updates = [CreateUpdate("second-container", Guid.NewGuid())]; viewService.GetDashboardAsync(Arg.Any()) - .Returns(Task.FromResult(dashboard), Task.FromException(exception)); + .Returns(Task.FromResult(first), Task.FromResult(second)); testContext.Services.AddSingleton(viewService); testContext.Services.AddSingleton(refreshState); testContext.Services.AddSingleton(Options.Create(new DockerUpdateGuardOptions())); - testContext.Services.AddSingleton>(logger); - - var page = testContext.Render(); - var alertCount = page.FindAll(".mud-alert").Count; - Assert.Contains("kept-scan-subject", page.Markup, "The first load must show the dashboard"); + var component = testContext.Render(); - await page.InvokeAsync(() => refreshState.NotifyChanged()).ConfigureAwait(false); - await page.WaitForAssertionAsync(() => DetailPageAssert.AssertLoadLoggedOnce(logger, "LoadDashboard", exception), TimeSpan.FromSeconds(DetailPageAssert.WaitSeconds)).ConfigureAwait(false); + Assert.Contains("first-container", component.Markup, "The first load must show the first dashboard"); - Assert.Contains("kept-scan-subject", page.Markup, "A failed reload must keep the dashboard shown"); - Assert.HasCount(alertCount, page.FindAll(".mud-alert"), "A failed reload must show no alert"); - Assert.DoesNotContain("secret text", page.Markup, "A failed reload must not show the exception's text"); + await component.InvokeAsync(() => refreshState.NotifyChanged()).ConfigureAwait(false); + await component.WaitForAssertionAsync(() => Assert.Contains("second-container", component.Markup, "The refresh must show the reloaded dashboard"), + TimeSpan.FromSeconds(DetailPageAssert.WaitSeconds)).ConfigureAwait(false); } } /// - /// Verify the recent scans table shows the scan status in a chip of its color + /// Verify texts from outside are rendered as text and never as markup /// - /// Scan status - /// Expected chip color class /// Task [TestMethod] - [TestCategory("AC4")] - [DataRow("Succeeded", "mud-chip-color-success")] - [DataRow("Partial", "mud-chip-color-warning")] - public async Task DashboardRecentScanStatusChipShowsStatusColorAsync(string status, string expectedColorClass) + [TestCategory("AC10")] + public async Task DashboardRendersExternalTextAsText() { var testContext = BlazorTestContextFactory.Create(); await using (testContext) { - var viewService = Substitute.For(); + var dashboard = CreateDashboard(); + var update = CreateUpdate("", Guid.NewGuid()); + var failed = CreateScan("Failed", "Registry", "", DateTimeOffset.UtcNow); + + failed.ErrorMessage = "boom"; + update.AvailableUpdateVersionTag = "2"; + dashboard.Updates = [update]; + dashboard.Vulnerabilities = [ + new DashboardVulnerabilityItemData + { + AdvisoryId = "CVE", + Severity = "High", + AffectedPackages = ["pkg"] + } + ]; + dashboard.RecentScans = [failed]; + + var component = RenderDashboard(testContext, dashboard); + + Assert.IsEmpty(component.FindAll("script"), "A container name must not become a script element"); + Assert.IsEmpty(component.FindAll("img"), "A scan target must not become an image element"); + Assert.IsEmpty(component.FindAll("main b, main i, main u, main em"), "Texts must not create formatting elements"); + Assert.Contains("", FindPanel(component, "Updates available").TextContent, "The container name must be shown as text"); + Assert.Contains("boom", component.Find("p.dug-dashboard__scan-problem").TextContent, "The error message must be shown as text"); + } + } - viewService.GetDashboardAsync(Arg.Any()) - .Returns(Task.FromResult(new DashboardViewData - { - RecentScans = [ - new ScanHistoryItemData - { - Type = "Registry", - Status = status, - StartedAtUtc = DateTimeOffset.UtcNow, - } - ], - })); + #endregion // Methods - testContext.Services.AddSingleton(viewService); - testContext.Services.AddSingleton(new DashboardRefreshState()); - testContext.Services.AddSingleton(Options.Create(new DockerUpdateGuardOptions())); - testContext.AddBunitPersistentComponentState(); + #region Helper methods - var page = testContext.Render(); + /// + /// Collapse runs of whitespace and trim a text + /// + /// Text + /// Normalized text + private static string Normalize(string text) + { + return string.Join(" ", text.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries)); + } + + /// + /// Find the panel with a title + /// + /// Rendered page + /// Panel title + /// Panel element + private static AngleSharp.Dom.IElement FindPanel(IRenderedComponent component, string title) + { + return component.FindAll("section.dug-panel") + .Single(panel => panel.QuerySelector("h2")?.TextContent.Trim() == title); + } + + /// + /// Render the dashboard with the given data + /// + /// bUnit test context + /// Dashboard data + /// Whether a Docker Hub account is configured + /// Rendered page + private static IRenderedComponent RenderDashboard(BunitContext testContext, DashboardViewData dashboard, bool withAccount = false) + { + var viewService = Substitute.For(); + var options = new DockerUpdateGuardOptions(); - await ScanStatusChipAssert.AssertChipAsync(page, - root => ScanStatusChipAssert.FindSectionCellChips(root, "Recent scans", "Status"), - status, - expectedColorClass).ConfigureAwait(false); + if (withAccount) + { + options.DockerHub.UserName = "octocat"; + options.DockerHub.Pat = "token"; } + + viewService.GetDashboardAsync(Arg.Any()) + .Returns(Task.FromResult(dashboard)); + + testContext.Services.AddSingleton(viewService); + testContext.Services.AddSingleton(new DashboardRefreshState()); + testContext.Services.AddSingleton(Options.Create(options)); + testContext.AddBunitPersistentComponentState(); + + return testContext.Render(); + } + + /// + /// Create a dashboard with an entry in every list: 7 updates, 31 vulnerabilities and 2 runtime warnings, of which 1 is listed + /// + /// Dashboard data + private static DashboardViewData CreateDashboard() + { + return new DashboardViewData + { + UpdateCount = 7, + Updates = [CreateUpdate("web-1", Guid.NewGuid())], + VulnerabilityCount = 31, + Vulnerabilities = [ + new DashboardVulnerabilityItemData + { + AdvisoryId = "CVE-2026-0001", + Severity = "High", + AffectedContainerCount = 1 + } + ], + VulnerabilityAdvisorySeveritySummary = new VulnerabilitySeveritySummaryViewData + { + HighCount = 31 + }, + RuntimeWarningCount = 2, + RuntimeWarnings = [ + new DashboardRuntimeWarningItemData + { + Id = Guid.NewGuid(), + Name = "company/api", + BaseRuntimeAlertSummary = "Base runtime is outdated" + }, + new DashboardRuntimeWarningItemData + { + Id = Guid.NewGuid(), + Name = "company/worker", + BaseRuntimeAlertSummary = "Base runtime is outdated" + } + ], + VulnerabilityScanningEnabled = true + }; + } + + /// + /// Create a dashboard without any finding + /// + /// Dashboard data + private static DashboardViewData CreateAllClearDashboard() + { + return new DashboardViewData + { + VulnerabilityScanningEnabled = true, + RecentScans = [CreateScan("Succeeded", "Runtime", "local", DateTimeOffset.UtcNow)] + }; + } + + /// + /// Create an update entry with an alias tag and an available tag + /// + /// Container name + /// Docker instance identifier + /// Update entry + private static DashboardUpdateItemData CreateUpdate(string containerName, Guid instanceId) + { + return new DashboardUpdateItemData + { + DockerInstanceId = instanceId, + ContainerId = $"container-{containerName}", + ContainerName = containerName, + DockerInstanceName = "docker-a", + CurrentTag = "latest", + ResolvedVersionTag = "1.25.3", + AvailableUpdateVersionTag = "1.26.0" + }; + } + + /// + /// Create a scan + /// + /// Status + /// Type + /// Target + /// Start + /// Scan + private static ScanHistoryItemData CreateScan(string status, string type, string? subjectName, DateTimeOffset startedAtUtc) + { + return new ScanHistoryItemData + { + Id = Guid.NewGuid(), + Status = status, + Type = type, + SubjectName = subjectName, + StartedAtUtc = startedAtUtc + }; } /// @@ -381,5 +1002,5 @@ private static string RenderDashboardMarkup(BunitContext testContext, Vulnerabil return component.Markup; } - #endregion // Methods + #endregion // Helper methods } \ No newline at end of file diff --git a/src/Tests/DockerUpdateGuard.Tests/DashboardSkeletonTests.cs b/src/Tests/DockerUpdateGuard.Tests/DashboardSkeletonTests.cs new file mode 100644 index 00000000..39342107 --- /dev/null +++ b/src/Tests/DockerUpdateGuard.Tests/DashboardSkeletonTests.cs @@ -0,0 +1,37 @@ +using Bunit; + +using DockerUpdateGuard.Components.Common; +using DockerUpdateGuard.Tests.Helper; + +namespace DockerUpdateGuard.Tests; + +/// +/// Tests for +/// +[TestClass] +public class DashboardSkeletonTests +{ + #region Methods + + /// + /// Verify the skeleton has the shape of the dashboard: headline, three panels and the strip + /// + /// Task + [TestMethod] + [TestCategory("AC10")] + public async Task DashboardSkeletonRendersHeadlinePanelsAndStrip() + { + var testContext = BlazorTestContextFactory.Create(); + + await using (testContext) + { + var component = testContext.Render(); + + Assert.HasCount(1, component.FindAll(".dug-dashboard-skeleton__headline"), "The skeleton must render one headline placeholder"); + Assert.HasCount(3, component.FindAll(".dug-dashboard-skeleton__panel"), "The skeleton must render three panel placeholders"); + Assert.HasCount(1, component.FindAll(".dug-dashboard-skeleton__strip"), "The skeleton must render one strip placeholder"); + } + } + + #endregion // Methods +} \ No newline at end of file diff --git a/src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs b/src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs index f62db6e8..f9d32cf3 100644 --- a/src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs +++ b/src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs @@ -33,7 +33,7 @@ public class DashboardTests [DataRow("Observed Images", "/observed-images")] [DataRow("Docker Instances", "/docker-instances")] [DataRow("Runtime Containers", "/runtime-containers")] - [DataRow("Shared Base Images", "/base-images")] + [DataRow("Base Images", "/base-images")] public void DashboardGetMetricNavigationTargetKnownMetricReturnsExpectedRoute(string metricLabel, string expectedRoute) { var route = _getMetricNavigationTargetMethod.Invoke(null, [metricLabel]) as string; From c5eb8209627405955567e7d957d7bdf45cfb4163 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:21:28 +0000 Subject: [PATCH 16/28] Implement G3 page, styles and docs --- README.md | 2 +- docs/areas/web-ui.md | 53 ++- specs/feature-453-dashboard-attention/log.md | 1 + .../Components/Common/DashboardSkeleton.razor | 10 + .../Components/Pages/Dashboard.razor | 412 +++++++++--------- .../Components/Pages/Dashboard.razor.cs | 11 +- src/DockerUpdateGuard/wwwroot/app.css | 229 ++++++++++ 7 files changed, 504 insertions(+), 214 deletions(-) diff --git a/README.md b/README.md index 0b958a84..1a11cc92 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ It is designed for teams that want more than "a newer tag exists". The app keeps ## Main UI areas -- **Dashboard**: summary view of the current inventory +- **Dashboard**: what needs attention: containers with updates, advisories in running containers, own base runtime warnings and the last scans - **Observed Images**: repositories and tags discovered from Docker Hub account data - **Runtime Containers**: live workload inventory with update and vulnerability state - **Docker Instances**: configured engines plus usage history diff --git a/docs/areas/web-ui.md b/docs/areas/web-ui.md index a878e6be..36a3c91c 100644 --- a/docs/areas/web-ui.md +++ b/docs/areas/web-ui.md @@ -37,7 +37,7 @@ to read the state the other areas compute and to start manual scans; it computes - Timestamps are shown in UTC as `yyyy-MM-dd HH:mm UTC`, the same for every browser and independent of the time zone and culture of the server process. The resource chart labels are UTC too: the first and the last label read `MM-dd HH:mm UTC`, the visible labels between them `HH:mm`. -- The scan status chips of the dashboard, scan history, observed image, My Images, runtime container and image detail +- The scan status chips of the scan history, observed image, My Images, runtime container and image detail pages share one color mapping: `Succeeded` green, `Partial` and `Pending` orange, `Failed` red, `Running` blue; any other value, such as `NotSet` or `NotScanned`, stays neutral. The chip text is the status name. - While a page loads its data it shows placeholder skeletons; a list without data shows an explanatory empty state. A @@ -74,7 +74,7 @@ to read the state the other areas compute and to start manual scans; it computes | Route | Page | Shows | | --- | --- | --- | -| `/` | Dashboard | Counts of my images, manual observed images, Docker instances, runtime containers and shared base images; active update findings; active derived-runtime warnings of own images; active vulnerability findings of currently running containers with a per-severity breakdown; a configuration hint for vulnerability scanning; the 10 most recent scan runs (observed image scans, runtime container scans and vulnerability refreshes, [Scan runs](scan-engine.md#scan-runs)) | +| `/` | Dashboard | What needs attention: a headline sentence with the counts, the containers with an available update, the advisories of running containers, the own images with a base runtime warning, the last 10 scans and a strip of inventory counts; a configuration hint for vulnerability scanning (see [Dashboard](#dashboard)) | | `/my-images` | My Images | Images discovered from the configured Docker Hub account, with latest scan status and message, number of running containers, derived-runtime hint and vulnerability status | | `/my-images/{id}` | My Image details | One observed image: reference, latest scan, derived-runtime hint, running containers, base image chain, update findings with tag candidates, and — when there are any — vulnerability findings and its 20 most recent scan runs | | `/observed-images` | Observed Images | The registration form and the manually registered images with latest scan, active update findings, derived-runtime hint and vulnerability status | @@ -172,6 +172,51 @@ to read the state the other areas compute and to start manual scans; it computes - Scheduled background runs do not send this signal: their results become visible when a page is opened or navigated to again (the top bar also refreshes on every navigation). No page polls the server. +### Dashboard + +The page `/` opens with the headline sentence `{updates}, {runtime warnings} and {vulnerabilities} need attention.`: +only the parts with a count above 0 appear, joined with `, ` and ` and `, and `needs` stands for a single part of count +1. The parts are colored (updates and runtime warnings orange, vulnerabilities red), the rest of the sentence is not; +with no count at all the headline reads `Everything is up to date.`. Below it the sub line +`{n} protected assets on {m} Docker instances · last activity {time}` sums manual observed images, own images and current +containers, and shows the start of the newest recorded scan run in UTC (`no scans yet` without one); a single asset or +instance uses the singular. The vulnerability configuration hint follows. + +Each count is the number of the entries it counts, not of findings: + +| Panel | Counts | Listed | Order | Footer | +| ----- | ------ | ------ | ----- | ------ | +| Updates available | Current containers with the update state `Update available` | 5 | Container name, instance name, container id | `{n} more in Runtime Containers`, else `Open Runtime Containers` | +| Vulnerabilities | Distinct active advisories that affect at least one current container; the severity bar counts the same advisories | 4 | Severity, CVSS score (none last), affected containers, advisory id | `{n} more in Vulnerabilities`, else `Open Vulnerabilities` | +| Own base runtime warnings | Own images (source Discovery) with a base runtime alert | 5 | Name | `{n} more in My Images` when more exist, else none | +| Last 10 scans | The ten newest scan runs | 10 | Newest first | `Open scan history` | + +A panel without an entry shows no count and its empty text (`No updates available.`, `No vulnerabilities in running +containers.` without the bar, `No runtime warnings.`). The *Own base runtime warnings* panel is hidden when no Docker Hub +account is configured and no warning exists. An update row shows the container name, the instance name, and the current +tag (with the resolved version of an alias such as `latest (1.25.3)`) followed by `→` and the available tag when one is +known; it opens the container's detail page. A vulnerability row shows the affected packages (the advisory id when it +names none, which a screen reader announces with the row anyway), the severity chip and `Fixed in {versions}` or `No fix +available`, then `{n} running containers`; the severity, score, packages and fixed versions come from all active +findings of the advisory, as the Vulnerabilities page shows them, and a row opens `/vulnerabilities`. A warning row shows +the image name and the alert summary and opens the image's detail page. Texts from Docker, registries and scanners are +shown as text. + +With no update, no runtime warning and no vulnerability the three panels give way to one `Nothing to do` panel with +`No updates available, no own base runtime warnings and no vulnerabilities in running containers.`, followed by *Last 10 +scans*, both over the full width. Otherwise the panels stand in three columns and stack in the order Updates available, +Vulnerabilities, Own base runtime warnings, Last 10 scans on a narrow screen. + +*Last 10 scans* draws one segment per run, colored by status, with the tooltip `{type} · {target} · {status} · {start}` +(the target and its separator left out when the run has none). The strip is announced as an image named by the counts +(`8 succeeded, 1 partial, 1 failed`); below it the same counts above 0 stand in the order succeeded, running, pending, +partial, failed joined with ` · `, the failed count emphasized. When one of the runs is `Failed` or `Partial` and has an +error message, a line `{target} · {message}` names the newest such run, the message as stored. Without a run the panel +shows `No scans have been recorded yet.` and no strip. The inventory strip below shows `My Images` (only with a Docker +Hub account), `Observed Images`, `Runtime Containers`, `Docker Instances` and `Base Images` (only above 0), each with its +figure and a link to its page. While the data loads, skeletons in the shape of the headline, three panels and the strip +stand in. + ### Vulnerability configuration hint The dashboard shows at most one hint about vulnerability scanning: @@ -199,7 +244,7 @@ never their values. - Text and status labels keep a contrast of at least 4.5:1 against their background in both themes; filled buttons and MudBlazor status chips of the dark theme draw their label in the dark page color; the shared status chips take theirs from the tone's chip color pair. -- Text is set in Inter; page titles, entity names, the figures of the dashboard's metric cards and the product name +- Text is set in Inter; page titles, entity names, the figures of the dashboard's inventory strip and the product name are set in Space Grotesk. Both fonts and the styles are served by the application itself; the browser loads nothing from another host for them, and until a font has loaded the text shows in a fallback font. @@ -294,6 +339,8 @@ never their values. - [0079](../decisions/0079-statuses-map-to-tones-in-one-mapping-beside-the-chip-colors-of-unconverted-pages.md) — Statuses map to tones in one mapping, beside the chip colors of unconverted pages. +- [0080](../decisions/0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md) — The dashboard + counts the containers, advisories and own images it lists. ## Not here diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index e6200fa9..b2f2c7ae 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -22,3 +22,4 @@ are quoted in full. | 2026-11-29 13:11 | 6 Coverage skipped (G2) | Orchestrator | skipped — gate PASS 100% on changed code reported by the Dev; no deferred tests, no resource bound | | 2026-11-29 13:12 | 4 Skeleton (G3) | Dev | Empty DashboardSkeleton with code-behind; MetricGridSkeleton, PageHeaderSkeleton and their tests deleted (challenge note 3); Dashboard.razor adapted to build; solution 0 warnings. Deviations: PageHeaderSkeleton deletion and MetricGridSkeletonTests deletion moved into this step (sonnet/medium · 6,363 tokens · 5 tool uses · 39 s · 12 in · 2,426 out · 479,254 cache read · 53,767 cache write · 127,276 weighted · continued from 4 Skeleton (G1)) | | 2026-11-29 13:16 | 5 Tests first (G3) | Tester | Page, skeleton, persistent-state, stylesheet and DashboardTests adapted/added; confirmed by orchestrator: 37 of 119 fail on the current page (all new/adapted), kept tests pass. Deferred: none (sonnet/medium · 55,740 tokens · 11 tool uses · 224 s · 24 in · 30,726 out · 1,677,344 cache read · 54,909 cache write · 390,025 weighted · continued) | +| 2026-11-29 13:21 | 6 Implement (G3) | Dev | Page, skeleton, CSS, docs (web-ui.md 4881 words, README) done; image build check ok via restore reproduction; coverage 99.8% changed code (1 uncovered: unknown-label default in GetMetricNavigationTarget); host 2720 pass, 2 fail — 2 tests disputed as test bugs (DashboardWithoutFindingsRendersNothingToDoPanel text equality includes h2; DashboardRuntimeWarningsPanelWithAllEntriesShownRendersNoFooter expects 1 row with 2 in fixture); SYSLIB1045 in AppStylesheetDashboardTests (sonnet/medium · 65,125 tokens · 25 tool uses · 280 s · 50 in · 19,923 out · 4,741,936 cache read · 175,895 cache write · 793,727 weighted · continued) | diff --git a/src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor b/src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor index e69de29b..ed5a7205 100644 --- a/src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor +++ b/src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor @@ -0,0 +1,10 @@ +
+ +
+ @for (var index = 0; index < 3; index++) + { + + } +
+ +
\ No newline at end of file diff --git a/src/DockerUpdateGuard/Components/Pages/Dashboard.razor b/src/DockerUpdateGuard/Components/Pages/Dashboard.razor index 99498b58..210dc40d 100644 --- a/src/DockerUpdateGuard/Components/Pages/Dashboard.razor +++ b/src/DockerUpdateGuard/Components/Pages/Dashboard.razor @@ -17,112 +17,70 @@ } else { - - - - - - Operations cockpit - Dashboard - Track image freshness, runtime drift, and vulnerability posture from one place. - - - - + var headlineSegments = DashboardTextFormatter.GetHeadlineSegments(_dashboard.UpdateCount, _dashboard.RuntimeWarningCount, _dashboard.VulnerabilityCount); + var scanCounts = DashboardScanStripFormatter.GetStatusCounts(_dashboard.RecentScans); + var problemScan = DashboardScanStripFormatter.FindLatestProblemScan(_dashboard.RecentScans); + var isAllClear = _dashboard.UpdateCount == 0 && _dashboard.RuntimeWarningCount == 0 && _dashboard.VulnerabilityCount == 0; + var showRuntimeWarnings = _showMyImages || _dashboard.RuntimeWarningCount > 0; - - @if (_showMyImages) - { - - - -
- -
- My Images - @_dashboard.MyImageCount -
-
-
- } - - - -
- -
- Observed Images - @_dashboard.ObservedImageCount -
-
-
- - - -
- -
- Docker Instances - @_dashboard.DockerInstanceCount -
-
-
- - - -
- -
- Runtime Containers - @_dashboard.RuntimeContainerCount -
-
-
- @if (_dashboard.BaseImageCount > 0) + RenderFragment scanPanel = @ + + @if (_dashboard.RecentScans.Count == 0) + { +

No scans have been recorded yet.

+ } + else + { + +

+ @for (var index = 0; index < scanCounts.Count; index++) + { + @if (index > 0) + { + · + } + + @if (scanCounts[index].Status == "Failed") + { + @DashboardScanStripFormatter.FormatCountText(scanCounts[index]) + } + else + { + @DashboardScanStripFormatter.FormatCountText(scanCounts[index]) + } + } +

+ @if (problemScan is not null) { - - - -
- -
- Shared Base Images - @_dashboard.BaseImageCount -
-
-
+

@DashboardScanStripFormatter.FormatProblemScanLine(problemScan)

} - - -
- -
- Update Findings - @_dashboard.UpdateCount -
-
- - -
- -
- Own Base Runtime Warnings - @_dashboard.RuntimeWarningCount -
-
- - - -
- -
- Vulnerabilities - @_dashboard.VulnerabilityCount - -
-
-
-
+ } + Open scan history + +; + + +
+

+ @foreach (var segment in headlineSegments) + { + @if (segment.Tone is StatusTone.Warning or StatusTone.Danger or StatusTone.Success) + { + @segment.Text + } + else + { + @segment.Text + } + } +

+

@DashboardTextFormatter.FormatSubLine(_dashboard)

+
@if (_dashboard.VulnerabilityConfigurationHint == VulnerabilityConfigurationHintKind.ScanningDisabled) { @@ -137,111 +95,157 @@ else } - - - -
- Update pressure - Images and containers that currently need attention. -
- - - Active update findings - @_dashboard.UpdateCount - - - Active vulnerability findings (running containers) - @_dashboard.VulnerabilityCount - - - - Own base runtime warnings - @_dashboard.RuntimeWarningCount - - -
-
- - -
- Coverage snapshot - How much of the estate is currently observed. -
- - @if (_showMyImages) - { - - - My images - @_dashboard.MyImageCount - - - } - - - Observed images - @_dashboard.ObservedImageCount - - - - - Runtime containers - @_dashboard.RuntimeContainerCount - - - - - Docker instances - @_dashboard.DockerInstanceCount - - - @if (_dashboard.BaseImageCount > 0) - { - - - Shared base images - @_dashboard.BaseImageCount - - - } - -
-
-
- - -
- Recent scans - Latest observed image scans, runtime container scans and vulnerability refreshes. -
- - @if (_dashboard.RecentScans.Count == 0) +
+ @if (isAllClear) { - - No scans have been recorded yet. - +
+ +

No updates available, no own base runtime warnings and no vulnerabilities in running containers.

+
+ @scanPanel +
} else { - - - Type - Status - Target - Started - Error - - - @context.Type - - @context.Status - - @context.SubjectName - @TimestampFormatter.Format(context.StartedAtUtc) - @context.ErrorMessage - - +
+ + + @if (_dashboard.UpdateCount > 0) + { + @_dashboard.UpdateCount + } + + + @if (_dashboard.Updates.Count == 0) + { +

No updates available.

+ } + else + { + + } + @DashboardTextFormatter.FormatFooterLink(_dashboard.UpdateCount, _dashboard.Updates.Count, "Runtime Containers") +
+
+
+
+ + + @if (_dashboard.VulnerabilityCount > 0) + { + @_dashboard.VulnerabilityCount + } + + + + @if (_dashboard.Vulnerabilities.Count == 0) + { +

No vulnerabilities in running containers.

+ } + else + { + + } + @DashboardTextFormatter.FormatFooterLink(_dashboard.VulnerabilityCount, _dashboard.Vulnerabilities.Count, "Vulnerabilities") +
+
+
+
+ @if (showRuntimeWarnings) + { + + + @if (_dashboard.RuntimeWarningCount > 0) + { + @_dashboard.RuntimeWarningCount + } + + + @if (_dashboard.RuntimeWarnings.Count == 0) + { +

No runtime warnings.

+ } + else + { + + } + @if (_dashboard.RuntimeWarningCount > _dashboard.RuntimeWarnings.Count) + { + @DashboardTextFormatter.FormatFooterLink(_dashboard.RuntimeWarningCount, _dashboard.RuntimeWarnings.Count, "My Images") + } +
+
+ } + @scanPanel +
+ } +
+ +
+ @if (_showMyImages) + { + + My Images + @_dashboard.MyImageCount + + } + + Observed Images + @_dashboard.ObservedImageCount + + + Runtime Containers + @_dashboard.RuntimeContainerCount + + + Docker Instances + @_dashboard.DockerInstanceCount + + @if (_dashboard.BaseImageCount > 0) + { + + Base Images + @_dashboard.BaseImageCount + } - +
} diff --git a/src/DockerUpdateGuard/Components/Pages/Dashboard.razor.cs b/src/DockerUpdateGuard/Components/Pages/Dashboard.razor.cs index 4c551d4b..1cb19c64 100644 --- a/src/DockerUpdateGuard/Components/Pages/Dashboard.razor.cs +++ b/src/DockerUpdateGuard/Components/Pages/Dashboard.razor.cs @@ -33,7 +33,7 @@ public sealed partial class Dashboard : IDisposable private DashboardViewData? _dashboard; /// - /// Whether the My Images tile should be shown + /// Whether the My Images cell and the runtime warnings panel should be shown /// private bool _showMyImages; @@ -81,9 +81,9 @@ public sealed partial class Dashboard : IDisposable #region Static methods /// - /// Resolve the overview route for a dashboard metric card + /// Resolve the overview route for a dashboard inventory cell /// - /// Metric card label + /// Inventory cell label /// Navigation target private static string GetMetricNavigationTarget(string metricLabel) { @@ -93,9 +93,8 @@ private static string GetMetricNavigationTarget(string metricLabel) "Observed Images" => "/observed-images", "Docker Instances" => "/docker-instances", "Runtime Containers" => "/runtime-containers", - "Shared Base Images" => "/base-images", - "Vulnerabilities" => "/vulnerabilities", - _ => throw new ArgumentOutOfRangeException(nameof(metricLabel), metricLabel, "Dashboard metric cards must map to known overview routes"), + "Base Images" => "/base-images", + _ => throw new ArgumentOutOfRangeException(nameof(metricLabel), metricLabel, "Dashboard inventory cells must map to known overview routes"), }; } diff --git a/src/DockerUpdateGuard/wwwroot/app.css b/src/DockerUpdateGuard/wwwroot/app.css index 39d78656..3a139124 100644 --- a/src/DockerUpdateGuard/wwwroot/app.css +++ b/src/DockerUpdateGuard/wwwroot/app.css @@ -1252,6 +1252,235 @@ a { } } +.dug-visually-hidden { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + clip: rect(0, 0, 0, 0); + white-space: nowrap; + border: 0; +} + +.dug-dashboard__headline { + margin: 0; + font-family: var(--dug-font-display); + font-size: 34px; + font-weight: 600; + line-height: 1.25; + color: var(--dug-text); +} + +.dug-dashboard__headline-part--warning { + color: var(--dug-attention); +} + +.dug-dashboard__headline-part--danger { + color: var(--dug-danger); +} + +.dug-dashboard__headline-part--success { + color: var(--dug-success); +} + +.dug-dashboard__subline { + margin: 4px 0 0; + color: var(--dug-text-muted); + font-size: 14px; +} + +.dug-dashboard__columns { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 16px; + align-items: start; +} + +.dug-dashboard__column { + display: flex; + flex-direction: column; + gap: 16px; + min-width: 0; +} + +.dug-dashboard__column--wide { + grid-column: 1 / -1; +} + +.dug-dashboard__count--warning, +.dug-dashboard__count--danger { + font-size: 15px; + font-weight: 600; +} + +.dug-dashboard__count--warning { + color: var(--dug-attention); +} + +.dug-dashboard__count--danger { + color: var(--dug-danger); +} + +.dug-dashboard__list { + margin: 0; + padding: 0; + list-style: none; +} + +.dug-dashboard__row { + display: grid; + grid-template-columns: minmax(0, 1fr) auto; + gap: 2px 12px; + padding: 10px 0; + border-top: 1px solid var(--dug-border-inner); + color: var(--dug-text); + text-decoration: none; +} + +.dug-dashboard__row:hover, +.dug-dashboard__row:focus-visible { + background: var(--dug-surface-subtle); +} + +.dug-dashboard__row-title { + min-width: 0; + overflow-wrap: anywhere; + font-weight: 600; +} + +.dug-dashboard__row-aside { + color: var(--dug-text-muted); + font-size: 13px; +} + +.dug-dashboard__row-detail { + grid-column: 1 / -1; + color: var(--dug-text-muted); + font-size: 13px; + overflow-wrap: anywhere; +} + +.dug-dashboard__row-target { + color: var(--dug-link); + font-weight: 600; +} + +.dug-dashboard__footer-link { + display: inline-block; + margin-top: 12px; + color: var(--dug-link); + font-size: 13px; + font-weight: 600; + text-decoration: none; +} + +.dug-dashboard__footer-link:hover, +.dug-dashboard__footer-link:focus-visible { + text-decoration: underline; +} + +.dug-dashboard__empty { + margin: 0; + color: var(--dug-text-muted); +} + +.dug-dashboard__scan-counts { + margin: 12px 0 0; + color: var(--dug-text-muted); + font-size: 13px; +} + +.dug-dashboard__scan-failed { + color: var(--dug-danger); +} + +.dug-dashboard__scan-problem { + margin: 4px 0 0; + color: var(--dug-text-muted); + font-size: 13px; + overflow-wrap: anywhere; +} + +.dug-scan-strip { + display: flex; + gap: 3px; + height: 24px; +} + +.dug-scan-strip__segment { + flex: 1 1 0; + min-width: 0; + border-radius: var(--dug-radius-sm); +} + +.dug-scan-strip__segment--succeeded { + background: var(--dug-scan-succeeded); +} + +.dug-scan-strip__segment--partial { + background: var(--dug-scan-partial); +} + +.dug-scan-strip__segment--failed { + background: var(--dug-scan-failed); +} + +.dug-scan-strip__segment--running { + background: var(--dug-primary); +} + +.dug-scan-strip__segment--pending { + background: var(--dug-border-control); +} + +.dug-inventory { + display: flex; + flex-wrap: wrap; + background: var(--dug-surface); + border: 1px solid var(--dug-border); + border-radius: var(--dug-radius-lg); +} + +.dug-inventory__cell { + display: flex; + flex: 1 1 140px; + flex-direction: column; + gap: 2px; + padding: 14px 20px; + color: var(--dug-text); + text-decoration: none; +} + +.dug-inventory__cell:hover, +.dug-inventory__cell:focus-visible { + background: var(--dug-surface-subtle); +} + +.dug-inventory__label { + color: var(--dug-text-muted); + font-size: 13px; +} + +.dug-inventory__value { + font-family: var(--dug-font-display); + font-size: 22px; + font-weight: 600; +} + +.dug-dashboard-skeleton { + display: flex; + flex-direction: column; + gap: 16px; +} + +@media (max-width: 959.98px) { + .dug-dashboard__columns { + grid-template-columns: minmax(0, 1fr); + } +} + @media (prefers-reduced-motion: reduce) { *, *::before, From cb3f92e986df78883b8973957e46316ca2ee4da2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:22:25 +0000 Subject: [PATCH 17/28] Log G3 decision --- specs/feature-453-dashboard-attention/log.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index b2f2c7ae..25ea71b7 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -23,3 +23,4 @@ are quoted in full. | 2026-11-29 13:12 | 4 Skeleton (G3) | Dev | Empty DashboardSkeleton with code-behind; MetricGridSkeleton, PageHeaderSkeleton and their tests deleted (challenge note 3); Dashboard.razor adapted to build; solution 0 warnings. Deviations: PageHeaderSkeleton deletion and MetricGridSkeletonTests deletion moved into this step (sonnet/medium · 6,363 tokens · 5 tool uses · 39 s · 12 in · 2,426 out · 479,254 cache read · 53,767 cache write · 127,276 weighted · continued from 4 Skeleton (G1)) | | 2026-11-29 13:16 | 5 Tests first (G3) | Tester | Page, skeleton, persistent-state, stylesheet and DashboardTests adapted/added; confirmed by orchestrator: 37 of 119 fail on the current page (all new/adapted), kept tests pass. Deferred: none (sonnet/medium · 55,740 tokens · 11 tool uses · 224 s · 24 in · 30,726 out · 1,677,344 cache read · 54,909 cache write · 390,025 weighted · continued) | | 2026-11-29 13:21 | 6 Implement (G3) | Dev | Page, skeleton, CSS, docs (web-ui.md 4881 words, README) done; image build check ok via restore reproduction; coverage 99.8% changed code (1 uncovered: unknown-label default in GetMetricNavigationTarget); host 2720 pass, 2 fail — 2 tests disputed as test bugs (DashboardWithoutFindingsRendersNothingToDoPanel text equality includes h2; DashboardRuntimeWarningsPanelWithAllEntriesShownRendersNoFooter expects 1 row with 2 in fixture); SYSLIB1045 in AppStylesheetDashboardTests (sonnet/medium · 65,125 tokens · 25 tool uses · 280 s · 50 in · 19,923 out · 4,741,936 cache read · 175,895 cache write · 793,727 weighted · continued) | +| 2026-11-29 13:22 | 6 Decide (G3) | Lead | RESULT: DECIDED — both disputed tests are test bugs, Tester corrects them; Code Officer converts regex to GeneratedRegex (SYSLIB1045); Tester adds unknown-label throw test; production unchanged, no criterion amended (opus/medium · 45,282 tokens · 7 tool uses · 48 s · 12 in · 3,843 out · 167,820 cache read · 43,130 cache write · 163,061 weighted) | From ddda63947022e5c5770edbbb517bddc85087c55f Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:23:30 +0000 Subject: [PATCH 18/28] Coverage pass G3 --- docs/UNIT_TESTS.md | 3 ++- specs/feature-453-dashboard-attention/log.md | 1 + specs/feature-453-dashboard-attention/tasks.md | 8 ++++---- .../DockerUpdateGuard.Tests/DashboardRenderTests.cs | 6 +++--- src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs | 13 +++++++++++++ 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/docs/UNIT_TESTS.md b/docs/UNIT_TESTS.md index c9ffa60a..d46fed15 100644 --- a/docs/UNIT_TESTS.md +++ b/docs/UNIT_TESTS.md @@ -80,6 +80,7 @@ MSTest with **NSubstitute** (`Substitute.For()`) for collaborators that cross - `TestOptionsMonitor` with `ListenerRegistration` (`Data/`) — the options monitor of a reloadable configuration; `Reload` replaces `CurrentValue` and calls the `OnChange` listeners - `TestDevelopmentConfiguration` (`Data/`) — the development configuration files - `SaveChangesFailingDbContext` (`Data/`) — a database whose save fails +- `SetRecordingDbContext` (`Data/`) — a database that records which entity sets the code asks for - `GatedSaveChangesDbContext` (`Data/`, created by `SqliteTestDatabase.CreateGatedSaveChangesDbContext`) — a database whose first save of an added vulnerability finding signals `SaveEntered` and waits for `ReleaseSave` before touching the database - `ScanLockObserver` (`Helper/`) — a scan lock registry observer: `WaitUntilWaitingAsync` yields until a second reference of a key exists or the run's task has completed - `SqliteTestDatabase` (`Data/` of both test projects) — the PostgreSQL database, as SQLite @@ -307,7 +308,7 @@ await using (testContext) var component = testContext.Render(); var markup = component.Markup; - Assert.Contains("Observed Images", markup, "The Observed Images metric tile must render"); + Assert.Contains("Observed Images", markup, "The Observed Images inventory cell must render"); } ``` diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 25ea71b7..739f39a5 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -24,3 +24,4 @@ are quoted in full. | 2026-11-29 13:16 | 5 Tests first (G3) | Tester | Page, skeleton, persistent-state, stylesheet and DashboardTests adapted/added; confirmed by orchestrator: 37 of 119 fail on the current page (all new/adapted), kept tests pass. Deferred: none (sonnet/medium · 55,740 tokens · 11 tool uses · 224 s · 24 in · 30,726 out · 1,677,344 cache read · 54,909 cache write · 390,025 weighted · continued) | | 2026-11-29 13:21 | 6 Implement (G3) | Dev | Page, skeleton, CSS, docs (web-ui.md 4881 words, README) done; image build check ok via restore reproduction; coverage 99.8% changed code (1 uncovered: unknown-label default in GetMetricNavigationTarget); host 2720 pass, 2 fail — 2 tests disputed as test bugs (DashboardWithoutFindingsRendersNothingToDoPanel text equality includes h2; DashboardRuntimeWarningsPanelWithAllEntriesShownRendersNoFooter expects 1 row with 2 in fixture); SYSLIB1045 in AppStylesheetDashboardTests (sonnet/medium · 65,125 tokens · 25 tool uses · 280 s · 50 in · 19,923 out · 4,741,936 cache read · 175,895 cache write · 793,727 weighted · continued) | | 2026-11-29 13:22 | 6 Decide (G3) | Lead | RESULT: DECIDED — both disputed tests are test bugs, Tester corrects them; Code Officer converts regex to GeneratedRegex (SYSLIB1045); Tester adds unknown-label throw test; production unchanged, no criterion amended (opus/medium · 45,282 tokens · 7 tool uses · 48 s · 12 in · 3,843 out · 167,820 cache read · 43,130 cache write · 163,061 weighted) | +| 2026-11-29 13:23 | 6 Coverage (G3) | Tester | Both disputed tests corrected, unknown-metric throw test added, UNIT_TESTS.md updated (task 12); 120 Dashboard tests pass, build clean (sonnet/medium · 92,403 tokens · 18 tool uses · 57 s · 18 in · 4,514 out · 737,206 cache read · 39,798 cache write · 146,056 weighted) | diff --git a/specs/feature-453-dashboard-attention/tasks.md b/specs/feature-453-dashboard-attention/tasks.md index e40000ab..c60592b0 100644 --- a/specs/feature-453-dashboard-attention/tasks.md +++ b/specs/feature-453-dashboard-attention/tasks.md @@ -12,7 +12,7 @@ Plan: [plan.md](plan.md) | 6 | G2 | Implement the formatters | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs` | AC1, AC2, AC3, AC4, AC6 | 5 | Dev | [x] | | 7 | G3 | Skeleton: empty `DashboardSkeleton` component; delete `MetricGridSkeleton` | `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor.cs` | AC10 | 6 | Dev | [x] | | 8 | G3 | Tests first: page render, persistent state, skeleton and stylesheet tests; `DashboardTests` DataRow; delete `MetricGridSkeletonTests` | `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardPersistentStateTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardSkeletonTests.cs`, `src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/MetricGridSkeletonTests.cs` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC9, AC10 | 7 | Tester | [x] | -| 9 | G3 | Rewrite the dashboard page, the skeleton markup and the dashboard rules of the stylesheet | `src/DockerUpdateGuard/Components/Pages/Dashboard.razor`, `src/DockerUpdateGuard/Components/Pages/Dashboard.razor.cs`, `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/wwwroot/app.css` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC10 | 8 | Dev | [ ] | -| 10 | G3 | Image build check (a `.razor` content item was added and one removed) | — | AC10 | 9 | Dev | [ ] | -| 11 | G3 | Area document: dashboard row, new *Dashboard* subsection, chip and font sentences, decision 0080 link | `docs/areas/web-ui.md` | AC11 | 9 | Dev | [ ] | -| 12 | G3 | Test documentation: `SetRecordingDbContext` under *Test doubles*, the bUnit example's assert message | `docs/UNIT_TESTS.md` | AC10 | 8 | Tester | [ ] | +| 9 | G3 | Rewrite the dashboard page, the skeleton markup and the dashboard rules of the stylesheet | `src/DockerUpdateGuard/Components/Pages/Dashboard.razor`, `src/DockerUpdateGuard/Components/Pages/Dashboard.razor.cs`, `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/wwwroot/app.css` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC10 | 8 | Dev | [x] | +| 10 | G3 | Image build check (a `.razor` content item was added and one removed) | — | AC10 | 9 | Dev | [x] | +| 11 | G3 | Area document: dashboard row, new *Dashboard* subsection, chip and font sentences, decision 0080 link | `docs/areas/web-ui.md` | AC11 | 9 | Dev | [x] | +| 12 | G3 | Test documentation: `SetRecordingDbContext` under *Test doubles*, the bUnit example's assert message | `docs/UNIT_TESTS.md` | AC10 | 8 | Tester | [x] | diff --git a/src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs b/src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs index 7084f225..171c37e7 100644 --- a/src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs +++ b/src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs @@ -483,9 +483,9 @@ public async Task DashboardRuntimeWarningsPanelWithAllEntriesShownRendersNoFoote var panel = FindPanel(component, "Own base runtime warnings"); - Assert.AreEqual(1, + Assert.AreEqual(2, panel.QuerySelectorAll("a.dug-dashboard__row").Length, - "The panel must show the one warning"); + "The panel must show both warnings"); Assert.IsNull(panel.QuerySelector("a.dug-dashboard__footer-link"), "The panel must have no footer when nothing remains"); } } @@ -682,7 +682,7 @@ public async Task DashboardWithoutFindingsRendersNothingToDoPanel() Assert.AreEqual("Everything is up to date.", Normalize(component.Find("h1.dug-dashboard__headline").TextContent), "The headline must be the all-clear sentence"); Assert.AreEqual("No updates available, no own base runtime warnings and no vulnerabilities in running containers.", - Normalize(nothingToDo.TextContent), + Normalize(nothingToDo.QuerySelector("p.dug-dashboard__empty")!.TextContent), "The panel must explain the all-clear state"); Assert.AreSequenceEqual(new List { diff --git a/src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs b/src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs index f9d32cf3..0227737e 100644 --- a/src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs +++ b/src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs @@ -43,5 +43,18 @@ public void DashboardGetMetricNavigationTargetKnownMetricReturnsExpectedRoute(st $"The dashboard metric card '{metricLabel}' must navigate to '{expectedRoute}'"); } + /// + /// Verify an unknown dashboard metric label is rejected + /// + [TestMethod] + [TestCategory("AC7")] + public void DashboardGetMetricNavigationTargetUnknownMetricThrowsArgumentOutOfRange() + { + var exception = Assert.ThrowsExactly(() => _getMetricNavigationTargetMethod.Invoke(null, ["Unknown"]), + "An unknown metric label must make the route resolver throw"); + + Assert.IsInstanceOfType(exception.InnerException, "The resolver must reject an unknown metric label with an ArgumentOutOfRangeException"); + } + #endregion // Methods } \ No newline at end of file From 6fb0289bfb8ca03f6ccbc7e42eb3f50f6eedd00c Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:24:21 +0000 Subject: [PATCH 19/28] Log documentation --- specs/feature-453-dashboard-attention/log.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 739f39a5..b761268d 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -25,3 +25,4 @@ are quoted in full. | 2026-11-29 13:21 | 6 Implement (G3) | Dev | Page, skeleton, CSS, docs (web-ui.md 4881 words, README) done; image build check ok via restore reproduction; coverage 99.8% changed code (1 uncovered: unknown-label default in GetMetricNavigationTarget); host 2720 pass, 2 fail — 2 tests disputed as test bugs (DashboardWithoutFindingsRendersNothingToDoPanel text equality includes h2; DashboardRuntimeWarningsPanelWithAllEntriesShownRendersNoFooter expects 1 row with 2 in fixture); SYSLIB1045 in AppStylesheetDashboardTests (sonnet/medium · 65,125 tokens · 25 tool uses · 280 s · 50 in · 19,923 out · 4,741,936 cache read · 175,895 cache write · 793,727 weighted · continued) | | 2026-11-29 13:22 | 6 Decide (G3) | Lead | RESULT: DECIDED — both disputed tests are test bugs, Tester corrects them; Code Officer converts regex to GeneratedRegex (SYSLIB1045); Tester adds unknown-label throw test; production unchanged, no criterion amended (opus/medium · 45,282 tokens · 7 tool uses · 48 s · 12 in · 3,843 out · 167,820 cache read · 43,130 cache write · 163,061 weighted) | | 2026-11-29 13:23 | 6 Coverage (G3) | Tester | Both disputed tests corrected, unknown-metric throw test added, UNIT_TESTS.md updated (task 12); 120 Dashboard tests pass, build clean (sonnet/medium · 92,403 tokens · 18 tool uses · 57 s · 18 in · 4,514 out · 737,206 cache read · 39,798 cache write · 146,056 weighted) | +| 2026-11-29 13:23 | 6 Documentation | Orchestrator | written in 6 Implement (G3) | From 1d74b26ba3842343a63bbbe8f8e7e99999c6c549 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:25:44 +0000 Subject: [PATCH 20/28] Log gate stamp --- specs/feature-453-dashboard-attention/log.md | 2 ++ .../AppStylesheetDashboardTests.cs | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index b761268d..d5b5e4c4 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -26,3 +26,5 @@ are quoted in full. | 2026-11-29 13:22 | 6 Decide (G3) | Lead | RESULT: DECIDED — both disputed tests are test bugs, Tester corrects them; Code Officer converts regex to GeneratedRegex (SYSLIB1045); Tester adds unknown-label throw test; production unchanged, no criterion amended (opus/medium · 45,282 tokens · 7 tool uses · 48 s · 12 in · 3,843 out · 167,820 cache read · 43,130 cache write · 163,061 weighted) | | 2026-11-29 13:23 | 6 Coverage (G3) | Tester | Both disputed tests corrected, unknown-metric throw test added, UNIT_TESTS.md updated (task 12); 120 Dashboard tests pass, build clean (sonnet/medium · 92,403 tokens · 18 tool uses · 57 s · 18 in · 4,514 out · 737,206 cache read · 39,798 cache write · 146,056 weighted) | | 2026-11-29 13:23 | 6 Documentation | Orchestrator | written in 6 Implement (G3) | +| 2026-11-29 13:25 | 7 Gate stamp | Orchestrator | FAIL on 6fb0289bfb8ca03f6ccbc7e42eb3f50f6eedd00c (tier standard): Format check pass; Analyzer gate FAIL; Test with coverage pass; Coverage gate pass; decision-check.py pass; scope-check.py pass · figure-check.py 19 hit(s) | +| 2026-11-29 13:25 | 7 Code check | Orchestrator | Gate stamp FAIL on 6fb0289: Analyzer gate (SYSLIB1045 in AppStylesheetDashboardTests, plus two repo-level config lines in files this change does not touch); other gates pass; figure-check 19 hits to confirm | diff --git a/src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs b/src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs index b6c9aba3..6a9a12c3 100644 --- a/src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs +++ b/src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs @@ -1,3 +1,5 @@ +using System.Text.RegularExpressions; + using DockerUpdateGuard.Tests.Helper; namespace DockerUpdateGuard.Tests; @@ -6,7 +8,7 @@ namespace DockerUpdateGuard.Tests; /// Tests for the dashboard rules of the shipped stylesheet wwwroot/app.css ///
[TestClass] -public class AppStylesheetDashboardTests +public partial class AppStylesheetDashboardTests { #region Constants @@ -15,8 +17,24 @@ public class AppStylesheetDashboardTests ///
private const string StylesheetPath = "wwwroot/app.css"; + /// + /// Time limit of the literal color pattern in milliseconds + /// + private const int RegexTimeoutMilliseconds = 5000; + #endregion // Constants + #region Static methods + + /// + /// Match a literal color in a rule body: hex, rgb(), rgba(), hsl() or hsla() + /// + /// Regular expression + [GeneratedRegex(@"#[0-9a-fA-F]{3,8}\b|rgba?\(|hsla?\(", RegexOptions.None, RegexTimeoutMilliseconds)] + private static partial Regex CreateLiteralColorPattern(); + + #endregion // Static methods + #region Methods /// @@ -58,7 +76,7 @@ public void AppStylesheetDashboardRulesUseOnlyTokenColors() || rule.Selector.Contains(".dug-scan-strip", StringComparison.Ordinal) || rule.Selector.Contains(".dug-inventory", StringComparison.Ordinal)) .ToList(); - var literalColors = rules.Where(rule => System.Text.RegularExpressions.Regex.IsMatch(rule.Body, @"#[0-9a-fA-F]{3,8}\b|rgba?\(|hsla?\(")) + var literalColors = rules.Where(rule => CreateLiteralColorPattern().IsMatch(rule.Body)) .Select(rule => rule.Selector) .ToList(); From 68f6b8ba4a1d69fb3ccfd3b2315e9b1276a4904f Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:27:03 +0000 Subject: [PATCH 21/28] Fix SYSLIB1045 --- specs/feature-453-dashboard-attention/log.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index d5b5e4c4..ab83a1ee 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -28,3 +28,4 @@ are quoted in full. | 2026-11-29 13:23 | 6 Documentation | Orchestrator | written in 6 Implement (G3) | | 2026-11-29 13:25 | 7 Gate stamp | Orchestrator | FAIL on 6fb0289bfb8ca03f6ccbc7e42eb3f50f6eedd00c (tier standard): Format check pass; Analyzer gate FAIL; Test with coverage pass; Coverage gate pass; decision-check.py pass; scope-check.py pass · figure-check.py 19 hit(s) | | 2026-11-29 13:25 | 7 Code check | Orchestrator | Gate stamp FAIL on 6fb0289: Analyzer gate (SYSLIB1045 in AppStylesheetDashboardTests, plus two repo-level config lines in files this change does not touch); other gates pass; figure-check 19 hits to confirm | +| 2026-11-29 13:27 | 7 Code check | Code Officer | SYSLIB1045 fixed with GeneratedRegex in AppStylesheetDashboardTests; analyzer: 0 diagnostics in changed files; 259 dashboard/stylesheet tests pass (haiku/medium · 98,022 tokens · 15 tool uses · 87 s · 24 in · 6,968 out · 990,921 cache read · 96,975 cache write · 12,759 weighted) | From 475f27c2dd38160d3ddf30b9be042531e7bfa0b8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:28:58 +0000 Subject: [PATCH 22/28] Log stamp decision --- specs/feature-453-dashboard-attention/log.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index ab83a1ee..efc28a78 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -29,3 +29,5 @@ are quoted in full. | 2026-11-29 13:25 | 7 Gate stamp | Orchestrator | FAIL on 6fb0289bfb8ca03f6ccbc7e42eb3f50f6eedd00c (tier standard): Format check pass; Analyzer gate FAIL; Test with coverage pass; Coverage gate pass; decision-check.py pass; scope-check.py pass · figure-check.py 19 hit(s) | | 2026-11-29 13:25 | 7 Code check | Orchestrator | Gate stamp FAIL on 6fb0289: Analyzer gate (SYSLIB1045 in AppStylesheetDashboardTests, plus two repo-level config lines in files this change does not touch); other gates pass; figure-check 19 hits to confirm | | 2026-11-29 13:27 | 7 Code check | Code Officer | SYSLIB1045 fixed with GeneratedRegex in AppStylesheetDashboardTests; analyzer: 0 diagnostics in changed files; 259 dashboard/stylesheet tests pass (haiku/medium · 98,022 tokens · 15 tool uses · 87 s · 24 in · 6,968 out · 990,921 cache read · 96,975 cache write · 12,759 weighted) | +| 2026-11-29 13:28 | 7 Gate stamp | Orchestrator | FAIL on 68f6b8ba4a1d69fb3ccfd3b2315e9b1276a4904f (tier standard): Format check pass; Analyzer gate FAIL; Test with coverage pass; Coverage gate pass; decision-check.py pass; scope-check.py pass · figure-check.py 19 hit(s) | +| 2026-11-29 13:28 | 7 Code check | Orchestrator | Product Manager decision: proceed to review without a green stamp; remaining Analyzer FAIL is two repo-level config lines (GlobalSuppressions.cs assembly-wide SuppressMessage, .editorconfig dotnet-rules out of date) in files identical to main; 0 diagnostics in changed files | From 1c457bf229765b528c6a2de7f1e044baecb2822d Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:34:22 +0000 Subject: [PATCH 23/28] Log review round 1 --- specs/feature-453-dashboard-attention/log.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index efc28a78..72965077 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -31,3 +31,4 @@ are quoted in full. | 2026-11-29 13:27 | 7 Code check | Code Officer | SYSLIB1045 fixed with GeneratedRegex in AppStylesheetDashboardTests; analyzer: 0 diagnostics in changed files; 259 dashboard/stylesheet tests pass (haiku/medium · 98,022 tokens · 15 tool uses · 87 s · 24 in · 6,968 out · 990,921 cache read · 96,975 cache write · 12,759 weighted) | | 2026-11-29 13:28 | 7 Gate stamp | Orchestrator | FAIL on 68f6b8ba4a1d69fb3ccfd3b2315e9b1276a4904f (tier standard): Format check pass; Analyzer gate FAIL; Test with coverage pass; Coverage gate pass; decision-check.py pass; scope-check.py pass · figure-check.py 19 hit(s) | | 2026-11-29 13:28 | 7 Code check | Orchestrator | Product Manager decision: proceed to review without a green stamp; remaining Analyzer FAIL is two repo-level config lines (GlobalSuppressions.cs assembly-wide SuppressMessage, .editorconfig dotnet-rules out of date) in files identical to main; 0 diagnostics in changed files | +| 2026-11-29 13:34 | 8 Review | Reviewer | VERDICT: BLOCKING 1 \| NON-BLOCKING 0 on 475f27c — ApplicationViewService.cs:1971 filter lowerCaseAdvisoryIds.Contains(entity.AdvisoryId.ToLowerInvariant()) does not translate on Npgsql (dashboard load fails in production; InMemory tests hide it); spot checks of docs, figure-check, scope, plan challenge notes clean (opus/medium · 126,221 tokens · 42 tool uses · 310 s · 82 in · 21,092 out · 3,545,152 cache read · 124,212 cache write · 876,129 weighted) | From 433a24caebc01cdaa70874204b52f5831d086f54 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:37:28 +0000 Subject: [PATCH 24/28] Make the dashboard advisory query translate on Npgsql --- specs/feature-453-dashboard-attention/log.md | 1 + .../UI/ApplicationViewService.cs | 17 ++------ .../UI/DashboardVulnerabilityQuery.cs | 38 ++++++++++++++++++ src/GlobalSuppressions.cs | 5 ++- .../DashboardVulnerabilityQueryTests.cs | 39 +++++++++++++++++++ 5 files changed, 85 insertions(+), 15 deletions(-) create mode 100644 src/DockerUpdateGuard/UI/DashboardVulnerabilityQuery.cs create mode 100644 src/Tests/DockerUpdateGuard.Tests/DashboardVulnerabilityQueryTests.cs diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 72965077..64def0fa 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -32,3 +32,4 @@ are quoted in full. | 2026-11-29 13:28 | 7 Gate stamp | Orchestrator | FAIL on 68f6b8ba4a1d69fb3ccfd3b2315e9b1276a4904f (tier standard): Format check pass; Analyzer gate FAIL; Test with coverage pass; Coverage gate pass; decision-check.py pass; scope-check.py pass · figure-check.py 19 hit(s) | | 2026-11-29 13:28 | 7 Code check | Orchestrator | Product Manager decision: proceed to review without a green stamp; remaining Analyzer FAIL is two repo-level config lines (GlobalSuppressions.cs assembly-wide SuppressMessage, .editorconfig dotnet-rules out of date) in files identical to main; 0 diagnostics in changed files | | 2026-11-29 13:34 | 8 Review | Reviewer | VERDICT: BLOCKING 1 \| NON-BLOCKING 0 on 475f27c — ApplicationViewService.cs:1971 filter lowerCaseAdvisoryIds.Contains(entity.AdvisoryId.ToLowerInvariant()) does not translate on Npgsql (dashboard load fails in production; InMemory tests hide it); spot checks of docs, figure-check, scope, plan challenge notes clean (opus/medium · 126,221 tokens · 42 tool uses · 310 s · 82 in · 21,092 out · 3,545,152 cache read · 124,212 cache write · 876,129 weighted) | +| 2026-11-29 13:37 | 8 Fix | Dev | Advisory query moved to DashboardVulnerabilityQuery, uses ToLower() (translates to lower() on Npgsql) with member-scoped CA1304/CA1311 suppression in GlobalSuppressions; regression test compiles the query with UseNpgsql+ToQueryString; 2724+39 tests pass, analyzer 0 diagnostics (sonnet/medium · 17,139 tokens · 15 tool uses · 174 s · 30 in · 9,805 out · 3,149,659 cache read · 247,903 cache write · 673,900 weighted · continued) | diff --git a/src/DockerUpdateGuard/UI/ApplicationViewService.cs b/src/DockerUpdateGuard/UI/ApplicationViewService.cs index 73e8ecc6..5771ccf3 100644 --- a/src/DockerUpdateGuard/UI/ApplicationViewService.cs +++ b/src/DockerUpdateGuard/UI/ApplicationViewService.cs @@ -1967,20 +1967,9 @@ private RuntimeContainerDetailViewData CreateRuntimeContainerDetail(Guid dockerI var lowerCaseAdvisoryIds = runningAdvisoryIds.Select(advisoryId => advisoryId.ToLowerInvariant()) .Distinct() .ToList(); - var advisoryFindings = await _dbContext.VulnerabilityFindings.Where(entity => entity.IsActive - && lowerCaseAdvisoryIds.Contains(entity.AdvisoryId.ToLowerInvariant())) - .AsNoTracking() - .Select(entity => new VulnerabilityFinding - { - AdvisoryId = entity.AdvisoryId, - ImageVersionId = entity.ImageVersionId, - Severity = entity.Severity, - CvssScore = entity.CvssScore, - AffectedPackage = entity.AffectedPackage, - FixedVersion = entity.FixedVersion, - }) - .ToListAsync(cancellationToken) - .ConfigureAwait(false); + var advisoryFindings = await DashboardVulnerabilityQuery.CreateAdvisoryFindingsQuery(_dbContext, lowerCaseAdvisoryIds) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); var containerCountsByImageVersion = latestSnapshots.GroupBy(entity => entity.ImageVersionId) .ToDictionary(group => group.Key, group => group.Count()); var advisories = advisoryFindings.GroupBy(entity => entity.AdvisoryId, StringComparer.OrdinalIgnoreCase) diff --git a/src/DockerUpdateGuard/UI/DashboardVulnerabilityQuery.cs b/src/DockerUpdateGuard/UI/DashboardVulnerabilityQuery.cs new file mode 100644 index 00000000..5f3c76f5 --- /dev/null +++ b/src/DockerUpdateGuard/UI/DashboardVulnerabilityQuery.cs @@ -0,0 +1,38 @@ +using DockerUpdateGuard.Data; +using DockerUpdateGuard.Data.Entities; + +using Microsoft.EntityFrameworkCore; + +namespace DockerUpdateGuard.UI; + +/// +/// Database queries of the dashboard's advisory list +/// +internal static class DashboardVulnerabilityQuery +{ + #region Methods + + /// + /// Create the query of the active findings of advisories, matching the advisory identifiers ignoring letter case and loading only the columns the dashboard needs + /// + /// Database context + /// Advisory identifiers in lower case + /// Query of untracked findings projected to the needed columns + internal static IQueryable CreateAdvisoryFindingsQuery(DockerUpdateGuardDbContext dbContext, List lowerCaseAdvisoryIds) + { + return dbContext.VulnerabilityFindings.Where(entity => entity.IsActive + && lowerCaseAdvisoryIds.Contains(entity.AdvisoryId.ToLower())) + .AsNoTracking() + .Select(entity => new VulnerabilityFinding + { + AdvisoryId = entity.AdvisoryId, + ImageVersionId = entity.ImageVersionId, + Severity = entity.Severity, + CvssScore = entity.CvssScore, + AffectedPackage = entity.AffectedPackage, + FixedVersion = entity.FixedVersion, + }); + } + + #endregion // Methods +} \ No newline at end of file diff --git a/src/GlobalSuppressions.cs b/src/GlobalSuppressions.cs index b00fd35a..7475ae24 100644 --- a/src/GlobalSuppressions.cs +++ b/src/GlobalSuppressions.cs @@ -18,4 +18,7 @@ [assembly: SuppressMessage("Usage", "CA2213:Disposable fields should be disposed", Justification = "MudThemeProvider is a child Razor component captured via @ref; the Blazor render tree owns and disposes it, not the parent layout.", Scope = "member", Target = "~F:DockerUpdateGuard.Components.Layout.MainLayout._themeProvider")] -[assembly: SuppressMessage("Minor Code Smell", "S1125:Boolean literals should not be redundant", Justification = "Comparing against false is the binding code style of this repository (see .github/instructions/csharp.instructions.md).")] \ No newline at end of file +[assembly: SuppressMessage("Minor Code Smell", "S1125:Boolean literals should not be redundant", Justification = "Comparing against false is the binding code style of this repository (see .github/instructions/csharp.instructions.md).")] + +[assembly: SuppressMessage("Globalization", "CA1304:Specify CultureInfo", Justification = "EF Core translates string.ToLower() to the SQL lower() function; ToLowerInvariant and the culture overload do not translate on Npgsql, and the advisory identifiers are matched ignoring letter case in the database.", Scope = "member", Target = "~M:DockerUpdateGuard.UI.DashboardVulnerabilityQuery.CreateAdvisoryFindingsQuery(DockerUpdateGuard.Data.DockerUpdateGuardDbContext,System.Collections.Generic.List{System.String})~System.Linq.IQueryable{DockerUpdateGuard.Data.Entities.VulnerabilityFinding}")] +[assembly: SuppressMessage("Globalization", "CA1311:Specify a culture or use an invariant version", Justification = "EF Core translates string.ToLower() to the SQL lower() function; ToLowerInvariant and the culture overload do not translate on Npgsql, and the advisory identifiers are matched ignoring letter case in the database.", Scope = "member", Target = "~M:DockerUpdateGuard.UI.DashboardVulnerabilityQuery.CreateAdvisoryFindingsQuery(DockerUpdateGuard.Data.DockerUpdateGuardDbContext,System.Collections.Generic.List{System.String})~System.Linq.IQueryable{DockerUpdateGuard.Data.Entities.VulnerabilityFinding}")] \ No newline at end of file diff --git a/src/Tests/DockerUpdateGuard.Tests/DashboardVulnerabilityQueryTests.cs b/src/Tests/DockerUpdateGuard.Tests/DashboardVulnerabilityQueryTests.cs new file mode 100644 index 00000000..a1bb7f50 --- /dev/null +++ b/src/Tests/DockerUpdateGuard.Tests/DashboardVulnerabilityQueryTests.cs @@ -0,0 +1,39 @@ +using DockerUpdateGuard.Data; +using DockerUpdateGuard.UI; + +using Microsoft.EntityFrameworkCore; + +namespace DockerUpdateGuard.Tests; + +/// +/// Tests of the dashboard's advisory query against the PostgreSQL provider +/// +[TestClass] +public class DashboardVulnerabilityQueryTests +{ + #region Methods + + /// + /// Verify the query translates on the PostgreSQL provider and matches the advisory identifiers in lower case + /// + /// Task + [TestMethod] + [TestCategory("AC4")] + public async Task DashboardVulnerabilityQueryAdvisoryFindingsQueryTranslatesOnNpgsqlWithLowerCaseMatchAsync() + { + var options = new DbContextOptionsBuilder().UseNpgsql("Host=127.0.0.1;Port=1;Database=dug") + .Options; + var dbContext = new DockerUpdateGuardDbContext(options); + + await using (dbContext.ConfigureAwait(false)) + { + var sql = DashboardVulnerabilityQuery.CreateAdvisoryFindingsQuery(dbContext, ["cve-1", "cve-2"]) + .ToQueryString(); + + Assert.Contains("lower(", sql, "The advisory identifiers must be compared in lower case by the database"); + Assert.Contains("= ANY", sql, "The identifiers must be matched as a list"); + } + } + + #endregion // Methods +} \ No newline at end of file From 4f59bbbd265ae1cbef4b491028ede08392557d7a Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:38:42 +0000 Subject: [PATCH 25/28] Log gate stamp --- specs/feature-453-dashboard-attention/log.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 64def0fa..7f8e8685 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -33,3 +33,4 @@ are quoted in full. | 2026-11-29 13:28 | 7 Code check | Orchestrator | Product Manager decision: proceed to review without a green stamp; remaining Analyzer FAIL is two repo-level config lines (GlobalSuppressions.cs assembly-wide SuppressMessage, .editorconfig dotnet-rules out of date) in files identical to main; 0 diagnostics in changed files | | 2026-11-29 13:34 | 8 Review | Reviewer | VERDICT: BLOCKING 1 \| NON-BLOCKING 0 on 475f27c — ApplicationViewService.cs:1971 filter lowerCaseAdvisoryIds.Contains(entity.AdvisoryId.ToLowerInvariant()) does not translate on Npgsql (dashboard load fails in production; InMemory tests hide it); spot checks of docs, figure-check, scope, plan challenge notes clean (opus/medium · 126,221 tokens · 42 tool uses · 310 s · 82 in · 21,092 out · 3,545,152 cache read · 124,212 cache write · 876,129 weighted) | | 2026-11-29 13:37 | 8 Fix | Dev | Advisory query moved to DashboardVulnerabilityQuery, uses ToLower() (translates to lower() on Npgsql) with member-scoped CA1304/CA1311 suppression in GlobalSuppressions; regression test compiles the query with UseNpgsql+ToQueryString; 2724+39 tests pass, analyzer 0 diagnostics (sonnet/medium · 17,139 tokens · 15 tool uses · 174 s · 30 in · 9,805 out · 3,149,659 cache read · 247,903 cache write · 673,900 weighted · continued) | +| 2026-11-29 13:38 | 7 Gate stamp | Orchestrator | FAIL on 433a24caebc01cdaa70874204b52f5831d086f54 (tier standard): Format check pass; Analyzer gate FAIL; Test with coverage pass; Coverage gate pass; decision-check.py pass; scope-check.py pass · figure-check.py 19 hit(s) | From a22fed787ef298e117b02bd8394923add4142f9c Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:40:05 +0000 Subject: [PATCH 26/28] Log delta review --- specs/feature-453-dashboard-attention/log.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index 7f8e8685..f16494b8 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -34,3 +34,4 @@ are quoted in full. | 2026-11-29 13:34 | 8 Review | Reviewer | VERDICT: BLOCKING 1 \| NON-BLOCKING 0 on 475f27c — ApplicationViewService.cs:1971 filter lowerCaseAdvisoryIds.Contains(entity.AdvisoryId.ToLowerInvariant()) does not translate on Npgsql (dashboard load fails in production; InMemory tests hide it); spot checks of docs, figure-check, scope, plan challenge notes clean (opus/medium · 126,221 tokens · 42 tool uses · 310 s · 82 in · 21,092 out · 3,545,152 cache read · 124,212 cache write · 876,129 weighted) | | 2026-11-29 13:37 | 8 Fix | Dev | Advisory query moved to DashboardVulnerabilityQuery, uses ToLower() (translates to lower() on Npgsql) with member-scoped CA1304/CA1311 suppression in GlobalSuppressions; regression test compiles the query with UseNpgsql+ToQueryString; 2724+39 tests pass, analyzer 0 diagnostics (sonnet/medium · 17,139 tokens · 15 tool uses · 174 s · 30 in · 9,805 out · 3,149,659 cache read · 247,903 cache write · 673,900 weighted · continued) | | 2026-11-29 13:38 | 7 Gate stamp | Orchestrator | FAIL on 433a24caebc01cdaa70874204b52f5831d086f54 (tier standard): Format check pass; Analyzer gate FAIL; Test with coverage pass; Coverage gate pass; decision-check.py pass; scope-check.py pass · figure-check.py 19 hit(s) | +| 2026-11-29 13:40 | 8 Review (delta) | Reviewer | VERDICT: APPROVE on 433a24c — fix verified (lower() = ANY on Npgsql; test fails with old ToLowerInvariant), suppressions member-scoped, nothing regressed (opus/medium · 38,765 tokens · 7 tool uses · 88 s · 14 in · 3,489 out · 196,900 cache read · 27,289 cache write · 122,830 weighted) | From 30be4a1bcf8f10023689832399f58bb87abfb339 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:40:19 +0000 Subject: [PATCH 27/28] Accept decision 0080 --- ...-counts-the-containers-advisories-and-own-images-it-lists.md | 2 +- docs/decisions/README.md | 2 +- specs/feature-453-dashboard-attention/log.md | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/decisions/0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md b/docs/decisions/0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md index e75a0001..9bf60a5a 100644 --- a/docs/decisions/0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md +++ b/docs/decisions/0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md @@ -1,6 +1,6 @@ # 0080: The dashboard counts the containers, advisories and own images it lists -- **Status:** Proposed +- **Status:** Accepted - **Date:** 2026-11-29 - **Area:** Web UI - **Source:** Issue #453 diff --git a/docs/decisions/README.md b/docs/decisions/README.md index f421fdc1..11a43c9c 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -140,5 +140,5 @@ once in the [area document](../areas/README.md) of the record's area, and the re | [0077](0077-the-dark-theme-tokens-apply-to-the-whole-document-while-the-layout-is-dark.md) | The dark theme's tokens apply to the whole document while the layout is dark | Accepted | 2026-11-28 | | [0078](0078-mudblazor-elevation-shadows-are-switched-off-in-the-theme.md) | MudBlazor elevation shadows are switched off in the theme | Accepted | 2026-11-28 | | [0079](0079-statuses-map-to-tones-in-one-mapping-beside-the-chip-colors-of-unconverted-pages.md) | Statuses map to tones in one mapping, beside the chip colors of unconverted pages | Accepted | 2026-11-28 | -| [0080](0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md) | The dashboard counts the containers, advisories and own images it lists | Proposed | 2026-11-29 | +| [0080](0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md) | The dashboard counts the containers, advisories and own images it lists | Accepted | 2026-11-29 | \ No newline at end of file diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md index f16494b8..537c32d4 100644 --- a/specs/feature-453-dashboard-attention/log.md +++ b/specs/feature-453-dashboard-attention/log.md @@ -35,3 +35,4 @@ are quoted in full. | 2026-11-29 13:37 | 8 Fix | Dev | Advisory query moved to DashboardVulnerabilityQuery, uses ToLower() (translates to lower() on Npgsql) with member-scoped CA1304/CA1311 suppression in GlobalSuppressions; regression test compiles the query with UseNpgsql+ToQueryString; 2724+39 tests pass, analyzer 0 diagnostics (sonnet/medium · 17,139 tokens · 15 tool uses · 174 s · 30 in · 9,805 out · 3,149,659 cache read · 247,903 cache write · 673,900 weighted · continued) | | 2026-11-29 13:38 | 7 Gate stamp | Orchestrator | FAIL on 433a24caebc01cdaa70874204b52f5831d086f54 (tier standard): Format check pass; Analyzer gate FAIL; Test with coverage pass; Coverage gate pass; decision-check.py pass; scope-check.py pass · figure-check.py 19 hit(s) | | 2026-11-29 13:40 | 8 Review (delta) | Reviewer | VERDICT: APPROVE on 433a24c — fix verified (lower() = ANY on Npgsql; test fails with old ToLowerInvariant), suppressions member-scoped, nothing regressed (opus/medium · 38,765 tokens · 7 tool uses · 88 s · 14 in · 3,489 out · 196,900 cache read · 27,289 cache write · 122,830 weighted) | +| 2026-11-29 13:40 | 9 PR approval | Orchestrator | approved by checklist — latest review round APPROVE on 433a24c, docs in diff, no open decision; decision 0080 set to Accepted. Exception: gate-stamp --verify fails only on two repo-level config lines identical to main (Product Manager accepted) | From 703dc5973b7f18054b02bf73fdb056c7ea54bdf3 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 13:40:44 +0000 Subject: [PATCH 28/28] Remove squad working record --- specs/feature-453-dashboard-attention/log.md | 38 --- specs/feature-453-dashboard-attention/plan.md | 294 ------------------ specs/feature-453-dashboard-attention/spec.md | 201 ------------ .../feature-453-dashboard-attention/tasks.md | 18 -- 4 files changed, 551 deletions(-) delete mode 100644 specs/feature-453-dashboard-attention/log.md delete mode 100644 specs/feature-453-dashboard-attention/plan.md delete mode 100644 specs/feature-453-dashboard-attention/spec.md delete mode 100644 specs/feature-453-dashboard-attention/tasks.md diff --git a/specs/feature-453-dashboard-attention/log.md b/specs/feature-453-dashboard-attention/log.md deleted file mode 100644 index 537c32d4..00000000 --- a/specs/feature-453-dashboard-attention/log.md +++ /dev/null @@ -1,38 +0,0 @@ -# Log: feature 453-dashboard-attention - -One line per pipeline step: date and time of day (UTC), step, member, result. Lead decisions and escalations -are quoted in full. - -| Date | Step | Member | Result | -| ---- | ---- | ------ | ------ | -| 2026-11-29 12:28 | 1 Intake | Orchestrator | RESULT: DONE — issue 453 (feature, open, label enhancement, no comments); dependencies 451 and 452 merged; branch claude/magical-bohr-d8uz9o off main fada378; work folder specs/feature-453-dashboard-attention | -| 2026-11-29 12:32 | 2a Spec | Lead | RESULT: DONE — spec.md written, 11 AC; decided the 3 open questions itself (count what is listed; hide runtime-warnings panel without Docker Hub account and no warning; non-running update findings not on dashboard) (opus/medium · 70,330 tokens · 9 tool uses · 36 s · 18 in · 2,419 out · 358,640 cache read · 70,080 cache write · 235,290 weighted) | -| 2026-11-29 12:35 | 2a Spec challenge | Devil's Advocate | VERDICT: OBJECTIONS 0 major, 4 minor — (1) E6/S4: state which findings feed packages/fixed versions/severity; (2) N1: restore issue's 'no per-image vulnerability details beyond the lists' and check in AC10; (3) all-clear shown together with ScanningDisabled hint, other update states never count; (4) scan tooltip start time via TimestampFormatter (opus/medium · 94,564 tokens · 30 tool uses · 153 s · 54 in · 13,575 out · 1,718,370 cache read · 91,147 cache write · 535,562 weighted) | -| 2026-11-29 12:35 | 2a Challenge notes | Orchestrator | minor objections appended verbatim to spec.md | -| 2026-11-29 12:42 | 2b Plan | Lead | RESULT: DONE — tier standard, no security areas; spec closed (Approved by Lead), plan.md, tasks.md (3 groups), decision 0080 (opus/medium · 160,732 tokens · 42 tool uses · 437 s · 80 in · 48,710 out · 6,858,586 cache read · 106,804 cache write · 1,440,129 weighted · continued) | -| 2026-11-29 12:46 | 2b Plan challenge | Devil's Advocate | VERDICT: OBJECTIONS 0 major, 5 minor — fact 15 confirmed; (1) narrow vulnerability query to advisories of running image versions; (2) positive control in no-resource-data test; (3) PageHeaderSkeleton orphaned; (4) DashboardSkeleton code-behind; (5) README line 20 (opus/medium · 114,700 tokens · 37 tool uses · 235 s · 70 in · 21,931 out · 2,824,590 cache read · 111,399 cache write · 780,406 weighted) | -| 2026-11-29 12:46 | 2b Challenge notes | Orchestrator | minor objections appended verbatim to plan.md | -| 2026-11-29 12:48 | 4 Skeleton (G1) | Dev | DashboardViewData members and three item classes added, old members removed, production call sites adapted; host builds 0 warnings; no pragmas; test call sites left to Tester (sonnet/medium · 97,894 tokens · 9 tool uses · 75 s · 16 in · 4,699 out · 630,024 cache read · 96,587 cache write · 207,247 weighted) | -| 2026-11-29 12:56 | 5 Tests first (G1) | Tester | 8 new service tests + SetRecordingDbContext; confirmed by orchestrator: compile, 9 fail on current code (8 new + adapted counts test). Deferred: none (sonnet/medium · 213,927 tokens · 40 tool uses · 458 s · 72 in · 45,073 out · 5,481,489 cache read · 159,789 cache write · 973,322 weighted) | -| 2026-11-29 13:02 | 6 Implement (G1) | Dev | GetDashboardAsync implemented with extracted helpers and narrowed vulnerability query; 2642 tests pass; coverage gate PASS 100% on changed code; build 0 warnings. Notes: ApplicationViewService at RH2111 limit (1500 lines); one flaky unrelated test passed on rerun; EF projection into VulnerabilityFinding unverified on Npgsql (sonnet/medium · 146,905 tokens · 22 tool uses · 373 s · 42 in · 19,504 out · 2,480,972 cache read · 93,648 cache write · 462,719 weighted) | -| 2026-11-29 13:03 | 6 Coverage skipped (G1) | Orchestrator | skipped — gate run by orchestrator: PASS, 100% on changed code (183/183 lines, 14/14 conditions), 2642+39 tests green; no deferred test, resource bound has its test | -| 2026-11-29 13:04 | 4 Skeleton (G2) | Dev | DashboardTextFormatter, DashboardScanStripFormatter, DashboardHeadlineSegmentData, DashboardScanCountData added; host builds 0 warnings; no pragmas; deviation: private const SkeletonMessage per formatter (S1192) (sonnet/medium · 5,127 tokens · 4 tool uses · 53 s · 10 in · 3,757 out · 353,321 cache read · 47,683 cache write · 113,731 weighted · continued from 4 Skeleton (G1)) | -| 2026-11-29 13:07 | 5 Tests first (G2) | Tester | 53 formatter tests in two files; confirmed by orchestrator: compile, all 53 fail on skeleton. Deferred: none (sonnet/medium · 130,562 tokens · 17 tool uses · 170 s · 26 in · 15,623 out · 1,352,395 cache read · 76,478 cache write · 308,978 weighted) | -| 2026-11-29 13:11 | 6 Implement (G2) | Dev | Both formatters implemented, 53 tests green, 2695+39 tests pass; coverage gate PASS 100% on changed code (248/248 lines, 56/56 conditions); no spec conflicts with test-fixed details (sonnet/medium · 20,081 tokens · 8 tool uses · 201 s · 16 in · 6,263 out · 999,635 cache read · 111,697 cache write · 270,916 weighted · continued) | -| 2026-11-29 13:11 | 6 Coverage skipped (G2) | Orchestrator | skipped — gate PASS 100% on changed code reported by the Dev; no deferred tests, no resource bound | -| 2026-11-29 13:12 | 4 Skeleton (G3) | Dev | Empty DashboardSkeleton with code-behind; MetricGridSkeleton, PageHeaderSkeleton and their tests deleted (challenge note 3); Dashboard.razor adapted to build; solution 0 warnings. Deviations: PageHeaderSkeleton deletion and MetricGridSkeletonTests deletion moved into this step (sonnet/medium · 6,363 tokens · 5 tool uses · 39 s · 12 in · 2,426 out · 479,254 cache read · 53,767 cache write · 127,276 weighted · continued from 4 Skeleton (G1)) | -| 2026-11-29 13:16 | 5 Tests first (G3) | Tester | Page, skeleton, persistent-state, stylesheet and DashboardTests adapted/added; confirmed by orchestrator: 37 of 119 fail on the current page (all new/adapted), kept tests pass. Deferred: none (sonnet/medium · 55,740 tokens · 11 tool uses · 224 s · 24 in · 30,726 out · 1,677,344 cache read · 54,909 cache write · 390,025 weighted · continued) | -| 2026-11-29 13:21 | 6 Implement (G3) | Dev | Page, skeleton, CSS, docs (web-ui.md 4881 words, README) done; image build check ok via restore reproduction; coverage 99.8% changed code (1 uncovered: unknown-label default in GetMetricNavigationTarget); host 2720 pass, 2 fail — 2 tests disputed as test bugs (DashboardWithoutFindingsRendersNothingToDoPanel text equality includes h2; DashboardRuntimeWarningsPanelWithAllEntriesShownRendersNoFooter expects 1 row with 2 in fixture); SYSLIB1045 in AppStylesheetDashboardTests (sonnet/medium · 65,125 tokens · 25 tool uses · 280 s · 50 in · 19,923 out · 4,741,936 cache read · 175,895 cache write · 793,727 weighted · continued) | -| 2026-11-29 13:22 | 6 Decide (G3) | Lead | RESULT: DECIDED — both disputed tests are test bugs, Tester corrects them; Code Officer converts regex to GeneratedRegex (SYSLIB1045); Tester adds unknown-label throw test; production unchanged, no criterion amended (opus/medium · 45,282 tokens · 7 tool uses · 48 s · 12 in · 3,843 out · 167,820 cache read · 43,130 cache write · 163,061 weighted) | -| 2026-11-29 13:23 | 6 Coverage (G3) | Tester | Both disputed tests corrected, unknown-metric throw test added, UNIT_TESTS.md updated (task 12); 120 Dashboard tests pass, build clean (sonnet/medium · 92,403 tokens · 18 tool uses · 57 s · 18 in · 4,514 out · 737,206 cache read · 39,798 cache write · 146,056 weighted) | -| 2026-11-29 13:23 | 6 Documentation | Orchestrator | written in 6 Implement (G3) | -| 2026-11-29 13:25 | 7 Gate stamp | Orchestrator | FAIL on 6fb0289bfb8ca03f6ccbc7e42eb3f50f6eedd00c (tier standard): Format check pass; Analyzer gate FAIL; Test with coverage pass; Coverage gate pass; decision-check.py pass; scope-check.py pass · figure-check.py 19 hit(s) | -| 2026-11-29 13:25 | 7 Code check | Orchestrator | Gate stamp FAIL on 6fb0289: Analyzer gate (SYSLIB1045 in AppStylesheetDashboardTests, plus two repo-level config lines in files this change does not touch); other gates pass; figure-check 19 hits to confirm | -| 2026-11-29 13:27 | 7 Code check | Code Officer | SYSLIB1045 fixed with GeneratedRegex in AppStylesheetDashboardTests; analyzer: 0 diagnostics in changed files; 259 dashboard/stylesheet tests pass (haiku/medium · 98,022 tokens · 15 tool uses · 87 s · 24 in · 6,968 out · 990,921 cache read · 96,975 cache write · 12,759 weighted) | -| 2026-11-29 13:28 | 7 Gate stamp | Orchestrator | FAIL on 68f6b8ba4a1d69fb3ccfd3b2315e9b1276a4904f (tier standard): Format check pass; Analyzer gate FAIL; Test with coverage pass; Coverage gate pass; decision-check.py pass; scope-check.py pass · figure-check.py 19 hit(s) | -| 2026-11-29 13:28 | 7 Code check | Orchestrator | Product Manager decision: proceed to review without a green stamp; remaining Analyzer FAIL is two repo-level config lines (GlobalSuppressions.cs assembly-wide SuppressMessage, .editorconfig dotnet-rules out of date) in files identical to main; 0 diagnostics in changed files | -| 2026-11-29 13:34 | 8 Review | Reviewer | VERDICT: BLOCKING 1 \| NON-BLOCKING 0 on 475f27c — ApplicationViewService.cs:1971 filter lowerCaseAdvisoryIds.Contains(entity.AdvisoryId.ToLowerInvariant()) does not translate on Npgsql (dashboard load fails in production; InMemory tests hide it); spot checks of docs, figure-check, scope, plan challenge notes clean (opus/medium · 126,221 tokens · 42 tool uses · 310 s · 82 in · 21,092 out · 3,545,152 cache read · 124,212 cache write · 876,129 weighted) | -| 2026-11-29 13:37 | 8 Fix | Dev | Advisory query moved to DashboardVulnerabilityQuery, uses ToLower() (translates to lower() on Npgsql) with member-scoped CA1304/CA1311 suppression in GlobalSuppressions; regression test compiles the query with UseNpgsql+ToQueryString; 2724+39 tests pass, analyzer 0 diagnostics (sonnet/medium · 17,139 tokens · 15 tool uses · 174 s · 30 in · 9,805 out · 3,149,659 cache read · 247,903 cache write · 673,900 weighted · continued) | -| 2026-11-29 13:38 | 7 Gate stamp | Orchestrator | FAIL on 433a24caebc01cdaa70874204b52f5831d086f54 (tier standard): Format check pass; Analyzer gate FAIL; Test with coverage pass; Coverage gate pass; decision-check.py pass; scope-check.py pass · figure-check.py 19 hit(s) | -| 2026-11-29 13:40 | 8 Review (delta) | Reviewer | VERDICT: APPROVE on 433a24c — fix verified (lower() = ANY on Npgsql; test fails with old ToLowerInvariant), suppressions member-scoped, nothing regressed (opus/medium · 38,765 tokens · 7 tool uses · 88 s · 14 in · 3,489 out · 196,900 cache read · 27,289 cache write · 122,830 weighted) | -| 2026-11-29 13:40 | 9 PR approval | Orchestrator | approved by checklist — latest review round APPROVE on 433a24c, docs in diff, no open decision; decision 0080 set to Accepted. Exception: gate-stamp --verify fails only on two repo-level config lines identical to main (Product Manager accepted) | diff --git a/specs/feature-453-dashboard-attention/plan.md b/specs/feature-453-dashboard-attention/plan.md deleted file mode 100644 index c0d3a6fd..00000000 --- a/specs/feature-453-dashboard-attention/plan.md +++ /dev/null @@ -1,294 +0,0 @@ -# Plan: Dashboard that lists what needs attention - -Source: Issue #453 | [spec.md](spec.md) -Tier: standard — the dashboard's content and counts change for users; no security control is created, changed or removed. -Security areas touched: none - -## Problem / root cause - -See [spec.md](spec.md), *Problem*. - -## Verified facts - -| # | Claim | Evidence | Status | -| - | ----- | -------- | ------ | -| 1 | "Running containers" are the current snapshots, the set every page and the dashboard use | `GetLatestContainerSnapshotsAsync` (`UI/ApplicationViewService.cs:665`); `docs/areas/docker-instances.md:141-145` | confirmed | -| 2 | The update state text `Update available` comes from `UpdateAssessmentStatus.UpdateAvailable` | `FormatUpdateAssessmentStatus` (`ApplicationViewService.cs:212`) | confirmed | -| 3 | Resolved and available tags fall back to the tag candidates of the snapshot's update findings when the snapshot fields are empty | `MapRuntimeContainerListItem` (`ApplicationViewService.cs:1212`), `LoadLatestUpdateFindingsAsync` (`:1281`) | confirmed | -| 4 | `GetRuntimeContainersCoreAsync` loads resource histories, base image relationships and vulnerability summaries | `ApplicationViewService.cs:409-440` | confirmed | -| 5 | The overview builds each advisory from all its active findings, including `Include(ImageVersion.ObservedImages)` for the affected images; only `AffectedContainerCount` depends on current containers | `GetVulnerabilityOverviewCoreAsync`, `CreateVulnerabilityOverviewItem` (`:1109-1180`) | confirmed | -| 6 | An own image's base runtime alert is its newest active `DerivedBaseRuntimeUpdate` finding, else that of a current container of its repository | `LoadObservedImageListAsync` (`:1402`), `MapObservedImageListItem` (`:1350`), `CreateRuntimeAlertLookup`/`CreateObservedAlertLookup` (`:283-310`) | confirmed | -| 7 | `GetScanHistoryCoreAsync(10)` returns the newest runs first; the top bar's last activity is element 0 of the same query | `:540-552`; `MainLayout.razor.cs:380-390` | confirmed | -| 8 | Protected assets in the top bar = manual observed + own images + current containers | `MainLayout.razor.cs:368-376` | confirmed | -| 9 | Timestamps are formatted `yyyy-MM-dd HH:mm UTC` | `UI/TimestampFormatter.cs:15`; decision 0058 | confirmed | -| 10 | Two configuration hints exist | `VulnerabilityConfigurationHintKind.cs` | confirmed | -| 11 | `VulnerabilitySeverity`: `NotSet` 0 < `Low` < `Medium` < `High` < `Critical` 4 | `DockerUpdateGuard.Data/Entities/VulnerabilitySeverity.cs` | confirmed | -| 12 | `SeverityBar` takes a `VulnerabilitySeveritySummaryViewData`, folds `OtherCount` into low and renders nothing when empty | `Components/Common/SeverityBar.razor(.cs)` | confirmed | -| 13 | `SectionPanel` has `Title`, `Meta`, `HeaderContent`, `ChildContent`, `Flush` | `Components/Common/SectionPanel.razor.cs` | confirmed | -| 14 | `MetricGridSkeleton` is used only by the dashboard; the `metric-card`/`hero-panel` rules are asserted by `AppStylesheetTests` | grep over `src/` | confirmed | -| 15 | `DbContext.Set()` is virtual, and the context's `DbSet` properties call it | to verify: the Tester's `SetRecordingDbContext` overrides `Set()` and its test sees the sets `DockerUpdateGuardDbContext.cs:30-100` asks for (step 5) | unverified | -| 17 | The EF Core SQLite provider cannot translate an `ORDER BY` on a `DateTimeOffset` column, which `GetScanHistoryCoreAsync` uses | EF Core documentation, *SQLite Database Provider - Limitations* | confirmed | -| 16 | #278 is closed and `web-ui.md` has no gap note for it | `gh api …/issues/278`; grep | confirmed | - -## Tests per criterion - -| AC | Test(s) | Test file | -| -- | ------- | --------- | -| AC1 | `DashboardTextFormatterGetHeadlineSegmentsCountCombinationReturnsSentence` (DataRows: every zero/non-zero combination of the three counts, each singular, `needs` for one part of 1, (1,1,1), (0,0,0)); `DashboardTextFormatterGetHeadlineSegmentsTonesOnlyTheParts`; `DashboardWithCountsRendersHeadlineWithColoredParts` | `DashboardTextFormatterTests.cs`, `DashboardRenderTests.cs` | -| AC2 | `DashboardTextFormatterFormatSubLineWithScanReturnsAssetsInstancesAndUtcTime`; `DashboardTextFormatterFormatSubLineWithoutScanReturnsNoScansYet`; `DashboardTextFormatterFormatSubLineSingleInstanceAndAssetUsesSingular` | `DashboardTextFormatterTests.cs` | -| AC3 | `ApplicationViewServiceDashboardUpdatesListsUpdateAvailableContainersInOrderAsync` (7 qualifying, 5 listed, order with case ties, alias resolved from a tag candidate); `ApplicationViewServiceDashboardUpdatesIgnoresOtherUpdateStatesAsync` (E12); `DashboardTextFormatterFormatCurrentTagWithAliasAppendsResolvedVersion`; `DashboardTextFormatterFormatFooterLinkReturnsRemainderOrOpenText`; `DashboardUpdatesPanelRendersRowsLinksAndFooter` (DataRows 7 and 3 total); `DashboardUpdatesPanelWithoutAvailableTagRendersCurrentTagOnly`; `DashboardUpdatesPanelWithoutEntriesRendersEmptyTextWithoutCount` | `ApplicationViewServiceDashboardTests.cs`, `DashboardTextFormatterTests.cs`, `DashboardRenderTests.cs` | -| AC4 | `ApplicationViewServiceDashboardVulnerabilitiesListsRunningAdvisoriesInOrderAsync` (every sort key, no score last, `NotSet` last, limit 4); `ApplicationViewServiceDashboardVulnerabilitiesTakeValuesFromAllActiveFindingsAsync` (E6: a retired image's finding adds package, fixed version and severity; an advisory only on a retired image is not listed); `DashboardTextFormatterFormatVulnerabilityTitleWithoutPackagesReturnsAdvisoryId`; `DashboardTextFormatterFormatVulnerabilityDetailReturnsFixAndContainerCount`; `DashboardVulnerabilitiesPanelRendersBarRowsAndAccessibleIdentifier`; `DashboardVulnerabilitiesPanelWithoutEntriesRendersEmptyTextWithoutBar` | same three files | -| AC5 | `ApplicationViewServiceDashboardRuntimeWarningsListsOwnImagesWithAlertAsync` (manual image with alert excluded, runtime-derived alert included, order, limit 5); `DashboardRuntimeWarningsPanelRendersRowsAndFooter`; `DashboardRuntimeWarningsPanelWithoutAccountAndWarningsIsHidden`; `DashboardRuntimeWarningsPanelWithAccountAndNoWarningsRendersEmptyText` | `ApplicationViewServiceDashboardTests.cs`, `DashboardRenderTests.cs` | -| AC6 | `DashboardScanStripFormatterGetStatusCountsReturnsCountsAboveZeroInStatusOrder`; `DashboardScanStripFormatterFormatStripLabelJoinsCountsWithCommas`; `DashboardScanStripFormatterFormatSegmentTitleReturnsTypeTargetStatusAndUtcStart` (with and without target); `DashboardScanStripFormatterGetSegmentCssNameMapsStatus` (five statuses, `NotSet`); `DashboardScanStripFormatterFindLatestProblemScanReturnsNewestFailedOrPartialWithMessage`; `DashboardScanStripFormatterFindLatestProblemScanWithoutMessageReturnsNull`; `DashboardScanStripFormatterFormatProblemScanLineWithoutTargetReturnsMessageOnly`; `DashboardScanPanelRendersStripCountsProblemLineAndLink`; `DashboardScanPanelWithoutRunsRendersEmptyText`; `AppStylesheetDashboardScanSegmentsUseStatusTokens` | `DashboardScanStripFormatterTests.cs`, `DashboardRenderTests.cs`, `AppStylesheetDashboardTests.cs` | -| AC7 | `DashboardInventoryStripRendersCellsWithVisibilityRules` (DataRows: account yes/no × shared base images 0/2); `DashboardGetMetricNavigationTargetKnownMetricReturnsExpectedRoute` (adapted) | `DashboardRenderTests.cs`, `DashboardTests.cs` | -| AC8 | `DashboardWithoutFindingsRendersNothingToDoPanel`; `DashboardWithoutFindingsAndScanningDisabledRendersHintAndAllClear` | `DashboardRenderTests.cs` | -| AC9 | `ApplicationViewServiceDashboardCountsEqualListedSetsAsync`; `DashboardHeadlineCountsEqualPanelCounts` | `ApplicationViewServiceDashboardTests.cs`, `DashboardRenderTests.cs` | -| AC10 | `DashboardSkeletonRendersHeadlinePanelsAndStrip`; `DashboardWhileLoadingRendersDashboardSkeleton`; `DashboardRefreshSignalReloadsDashboard`; `DashboardRendersExternalTextAsText`; `DashboardWithPersistedStateDoesNotLoadAgain`; `ApplicationViewServiceDashboardRequestsNoResourceSampleSetsAsync`; kept: `DashboardLoadFailureShowsFixedErrorAndLogs`, `DashboardFailedRefreshKeepsDashboardAndLogs`, `DashboardWithDisabledVulnerabilityScanningRendersInfoBanner`, `DashboardWithConfiguredVulnerabilityProviderRendersNoBanner` | `DashboardSkeletonTests.cs`, `DashboardRenderTests.cs`, `DashboardPersistentStateTests.cs`, `ApplicationViewServiceDashboardTests.cs` | -| AC11 | check: the Reviewer reads `docs/areas/web-ui.md` against the built page in step 8 | — | - -S11 and N3 are verified on the before/after screenshots of the pull request in step 9 (spec, *Out of scope*). - -## Approach - -**Service** (`GetDashboardAsync`, inside its existing `ExecuteSerializedAsync`). It keeps the counts of the inventory, -the hint and `RecentScans`, drops the three finding counts and the per-image-version severity sum, and adds three -private steps over the already loaded current snapshots (private constants `DashboardUpdateLimit = 5`, -`DashboardVulnerabilityLimit = 4`, `DashboardRuntimeWarningLimit = 5`; the view data holds only the shown entries, N2): - -1. *Updates*: snapshots with `UpdateAssessmentStatus.UpdateAvailable`, ordered by container name, instance name - (`StringComparer.OrdinalIgnoreCase`), container id (ordinal); count = all of them. For the first five only, - `LoadLatestUpdateFindingsAsync` with their ids gives the tag candidates; the tags come from a new private static - `ResolveRuntimeContainerTags(ContainerSnapshot entity, List tagCandidates)` returning - `(string? ResolvedVersionTag, string? AvailableUpdateVersionTag)`, extracted from `MapRuntimeContainerListItem`, - which calls it too. No resource history, base image or vulnerability load. -2. *Vulnerabilities*: active `VulnerabilityFindings`, `AsNoTracking`, **without** includes; grouped by `AdvisoryId` - (`OrdinalIgnoreCase`) as the overview does; container count per group by a new private static - `CountAffectedContainers(IEnumerable advisoryFindings, Dictionary containerCountsByImageVersion)` - (sum over distinct image version ids), packages and fixed versions by new private static - `SelectAffectedPackages(IEnumerable advisoryFindings)` and - `SelectFixedVersions(IEnumerable advisoryFindings)`, all three extracted from - `CreateVulnerabilityOverviewItem`, which calls them. Groups with a count above 0 are kept; severity = max, - score = max; order severity desc, score desc (null last), count desc, advisory id `OrdinalIgnoreCase`. - `VulnerabilityAdvisorySeveritySummary` counts the kept groups per severity (`NotSet` → `OtherCount`). The - overview's own order and affected images stay unchanged. -3. *Runtime warnings*: `LoadObservedImagesAsync(RegistrationSource.Discovery)`, - `LoadDerivedBaseRuntimeFindingsAsync` and the two alert lookups as `LoadObservedImageListAsync` builds them; the - alert by a new private static - `FindBaseRuntimeAlert(ObservedImage entity, Dictionary observedAlertLookup, Dictionary runtimeAlertLookup)`, - extracted from `MapObservedImageListItem`, which calls it. Images with an alert, ordered by name - (`OrdinalIgnoreCase`), then id. - -The resource bound of N1 is observed through `DbContext.Set()`: `SetRecordingDbContext` records every -entity type asked for, and the test asserts that neither resource sample type is; the affected-image restriction -holds by signature (`DashboardVulnerabilityItemData` has no images, and the query has no include). - -**Text**: `DashboardTextFormatter` and `DashboardScanStripFormatter` (*Signatures*) compose every user-visible text, -so the page only binds. Headline connectors: two parts ` and `, three `, ` and ` and `; closing ` needs attention.` -for one part of count 1, else ` need attention.`; parts take `StatusTone.Warning` (updates, runtime warnings) or -`StatusTone.Danger`, connectors `StatusTone.Neutral`, the all-clear sentence `StatusTone.Success`. Sub line -`{assets} on {instances} · last activity {time|no scans yet}`. Footer `{total − shown} more in {page}` when total > -shown, else `Open {page}`. Scan counts in the order Succeeded, Running, Pending, Partial, Failed, text -`{n} {status lower-case}`; segment CSS names `succeeded`, `partial`, `failed`, `running`, else `pending`; segment -title `{Type} · {SubjectName} · {Status} · {TimestampFormatter.Format(StartedAtUtc)}`, the subject left out with its -separator when empty; problem run = first of the list with status `Failed` or `Partial` and a non-empty -`ErrorMessage`. - -**Layout** (the issue's *Scope* 1–7 and the mockups give sizes and tokens): `h1.dug-dashboard__headline` with -`span.dug-dashboard__headline-part--{tone}` per segment; `p.dug-dashboard__subline`; the two existing `MudAlert` -hints unchanged; `div.dug-dashboard__columns` holding `div.dug-dashboard__column` ×3 in DOM order Updates, -Vulnerabilities, (Runtime warnings, Scans) — the DOM order is the stacking order (S11); in the all-clear state one -full-width column with `Nothing to do` and Scans. Each panel is a `SectionPanel` whose `HeaderContent` is -`span.dug-dashboard__count--{warning|danger}` (absent at 0); lists are `ul.dug-dashboard__list > li > a.dug-dashboard__row` -with `.dug-dashboard__row-title`, `.dug-dashboard__row-aside` (instance name, or a `StatusChip` with -`StatusToneFormatter.GetSeverityTone`), `.dug-dashboard__row-detail` (the available tag in -`.dug-dashboard__row-target`); the advisory id in a `span.dug-visually-hidden` inside the row link; footer -`a.dug-dashboard__footer-link`; empty text `p.dug-dashboard__empty`. Scans: `div.dug-scan-strip[role=img][aria-label]` -of `span.dug-scan-strip__segment--{css}[title]`, `p.dug-dashboard__scan-counts` joined with ` · ` (failed count in -`strong.dug-dashboard__scan-failed`), `p.dug-dashboard__scan-problem`. Inventory: `section.dug-inventory` of -`a.dug-inventory__cell` with `.dug-inventory__label`, `.dug-inventory__value`; labels `My Images`, `Observed Images`, -`Runtime Containers`, `Docker Instances`, `Base Images` (`GetMetricNavigationTarget` keys renamed accordingly, its -`Vulnerabilities` case removed as unused). Skeleton: new `DashboardSkeleton` with `.dug-dashboard-skeleton__headline`, -three `.dug-dashboard-skeleton__panel`, one `.dug-dashboard-skeleton__strip`; `MetricGridSkeleton` and -`PageHeaderSkeleton`'s use on the dashboard go. New rules in `wwwroot/app.css` use only `--dug-*` tokens and include -`.dug-visually-hidden`. The old `hero-panel`, `metric-*` and `summary-*` rules stay for #459, which removes the old -styles (`AppStylesheetTests` asserts them). - -Early draft PR: no - -## Options considered - -1. Counts: count what is listed (chosen) vs. keep finding counts with a second figure per list — decision 0080. -2. Data: reuse the page loaders (`GetRuntimeContainersCoreAsync`, `GetVulnerabilityOverviewCoreAsync`, - `LoadObservedImageListAsync`) and trim their output — lost: they load resource histories, affected images, - scan statuses and vulnerability summaries the dashboard does not show (N1); extracting the per-item helpers - shares the evaluation without that cost. -3. Advisory values: from all active findings (chosen, as the Vulnerabilities page the row links to) vs. only from - running image versions — lost: the row would disagree with the page it opens (spec, *Challenge* 1). -4. Seam for N1: `SqliteTestDatabase` with a command-text interceptor — lost: SQLite cannot order by - `DateTimeOffset`, which the scan history query does; `SetRecordingDbContext` works on InMemory. - -## Affected projects and types - -| Project | Type / file | Change | -| ------- | ----------- | ------ | -| DockerUpdateGuard | `UI/DashboardViewData.cs` | members changed (*Signatures*) | -| DockerUpdateGuard | `UI/DashboardUpdateItemData.cs`, `UI/DashboardVulnerabilityItemData.cs`, `UI/DashboardRuntimeWarningItemData.cs`, `UI/DashboardHeadlineSegmentData.cs`, `UI/DashboardScanCountData.cs` | new | -| DockerUpdateGuard | `UI/DashboardTextFormatter.cs`, `UI/DashboardScanStripFormatter.cs` | new | -| DockerUpdateGuard | `UI/ApplicationViewService.cs` | `GetDashboardAsync` and the extracted helpers | -| DockerUpdateGuard | `Components/Pages/Dashboard.razor`, `Dashboard.razor.cs` | rewritten | -| DockerUpdateGuard | `Components/Common/DashboardSkeleton.razor` | new (markup only) | -| DockerUpdateGuard | `Components/Common/MetricGridSkeleton.razor(.cs)` | deleted | -| DockerUpdateGuard | `wwwroot/app.css` | new dashboard rules | - -## Signatures (for the Dev's skeleton) - -DashboardViewData keeps its five inventory counts, VulnerabilityScanningEnabled, VulnerabilityConfigurationHint and -RecentScans, and gains: - -- `DashboardViewData.UpdateCount` — public int, get/set -- `DashboardViewData.Updates` — public IReadOnlyList, get/set, = [] -- `DashboardViewData.VulnerabilityCount` — public int, get/set -- `DashboardViewData.Vulnerabilities` — public IReadOnlyList, get/set, = [] -- `DashboardViewData.VulnerabilityAdvisorySeveritySummary` — public VulnerabilitySeveritySummaryViewData, get/set, - = new() -- `DashboardViewData.RuntimeWarningCount` — public int, get/set -- `DashboardViewData.RuntimeWarnings` — public IReadOnlyList, get/set, = [] - -Deleted: its members ActiveUpdateFindingCount, OwnImageBaseRuntimeWarningCount, ActiveVulnerabilityFindingCount and -VulnerabilitySeveritySummary. - -New classes in DockerUpdateGuard.UI, one file each, auto-properties with public getters and setters (JSON -persistence), non-null strings initialized to string.Empty and lists to []: - -- `public class DashboardUpdateItemData` — Guid DockerInstanceId, string ContainerId, string ContainerName, string - DockerInstanceName, string CurrentTag, string? ResolvedVersionTag, string? AvailableUpdateVersionTag -- `public class DashboardVulnerabilityItemData` — string AdvisoryId, string Severity, decimal? CvssScore, - IReadOnlyList AffectedPackages, IReadOnlyList FixedVersions, int AffectedContainerCount -- `public class DashboardRuntimeWarningItemData` — Guid Id, string Name, string BaseRuntimeAlertSummary -- `public class DashboardHeadlineSegmentData` — string Text, StatusTone Tone -- `public class DashboardScanCountData` — string Status, int Count - -- `public static class DashboardTextFormatter` -- `public static IReadOnlyList GetHeadlineSegments(int updateCount, int runtimeWarningCount, int vulnerabilityCount)` -- `public static string FormatCount(int count, string singular, string plural)` -- `public static string FormatSubLine(DashboardViewData dashboard)` -- `public static string FormatFooterLink(int totalCount, int shownCount, string pageName)` -- `public static string FormatCurrentTag(DashboardUpdateItemData item)` -- `public static string FormatVulnerabilityTitle(DashboardVulnerabilityItemData item)` -- `public static string FormatVulnerabilityDetail(DashboardVulnerabilityItemData item)` - -- `public static class DashboardScanStripFormatter` -- `public static IReadOnlyList GetStatusCounts(IReadOnlyList scans)` -- `public static string FormatCountText(DashboardScanCountData count)` -- `public static string FormatStripLabel(IReadOnlyList counts)` -- `public static string FormatSegmentTitle(ScanHistoryItemData scan)` -- `public static string GetSegmentCssName(string status)` -- `public static ScanHistoryItemData? FindLatestProblemScan(IReadOnlyList scans)` -- `public static string FormatProblemScanLine(ScanHistoryItemData scan)` - -DashboardSkeleton is a markup-only component (no code-behind) whose skeleton is an empty file. Deleted: the -MetricGridSkeleton component, both files. Names were checked against *Writing code*: no nested type, at most three -parameters, no parameter named after a keyword. - -## Test files - -New: `src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs`, `DashboardScanStripFormatterTests.cs`, -`ApplicationViewServiceDashboardTests.cs`, `DashboardSkeletonTests.cs`, `DashboardPersistentStateTests.cs`, -`AppStylesheetDashboardTests.cs`, and the double `Data/SetRecordingDbContext.cs` (a `DockerUpdateGuardDbContext` -whose `Set()` override records the requested entity types). Adapted: `DashboardRenderTests.cs`. - -Existing test code on changed signatures, all adapted by the Tester in step 5: - -- `DashboardRenderTests.cs`: `DashboardRecentScansDescriptionNamesOnlyRecordedRunTypes` and - `DashboardRecentScanStatusChipShowsStatusColorAsync` deleted (section gone); `DashboardWithConfiguredAccountRendersMetricTiles`, - `DashboardWithSharedBaseImagesRendersSharedBaseImagesLabelsAsync` and `DashboardWithRecentScanRendersStartedInUtcAsync` - replaced by the AC7 and AC2/AC6 tests; the deleted view-data members leave its initializers. -- `ApplicationViewServiceTests.cs`: `ApplicationViewServiceDashboardReturnsAggregateCountsAsync` (asserts the new - counts of its seed) and `ApplicationViewServiceDashboardExcludesFindingsForInactiveRuntimeImageVersionsAsync` - (`VulnerabilityCount` 1, advisory summary without the retired critical one). -- `DashboardTests.cs`: DataRow `Shared Base Images` → `Base Images`. -- `MetricGridSkeletonTests.cs`: deleted. - -Files no unit test can cover: none. - -## Areas - -- `docs/areas/web-ui.md` (+480 words; about 4,178 now, so about 4,660 against `AREA_MAX_WORDS` 5000: no split): the - dashboard row of *Pages and routes*; a new *Dashboard* subsection under *Behavior* with the spec's rules (headline, - sub line, the three lists with limits, orders, row content, links, footers and empty texts, the hidden runtime - panel, the all-clear state, the scan strip and its texts, the inventory cells); *General*: the scan status chip - sentence without the dashboard; *Light and dark mode*: "the figures of the dashboard's inventory strip" instead of - "metric cards"; *Related decisions*: 0080. - -## Documentation updates - -- `docs/areas/web-ui.md` — as *Areas* (Dev). -- `docs/UNIT_TESTS.md` (Test doubles +16 words): `SetRecordingDbContext` (`Data/`) — a database that records which - entity sets the code asks for; and the bUnit example's assert message no longer says "metric tile" (Tester). -- `docs/ARCHITECTURE.md`: none (section 9 names no dashboard content). No changelog exists. - -## Architecture check - -Pages read only through `IApplicationViewService` (section 9): kept, the interface is unchanged. The dashboard keeps -`DashboardRefreshState` and its persisted state key. No guarantee of `.squad/project.md` is touched. - -## Security considerations - -- [x] No limits on parsed input. -- [x] Exceptions: a load failure keeps the existing fixed text `Loading the dashboard failed: ` - (`PageLoader`); no new path reaches the user. Texts from Docker, registries and scanners are bound as Razor text - (encoded), never as `MarkupString` (E10). - -## Decision records - -- `docs/decisions/0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md` (Proposed) - -## Out of scope / follow-ups - -- Removing the old dashboard styles and their `AppStylesheetTests`: #459. -- `docs/ui-concept/README.md` (an older concept describing metric tiles) stays as a historical concept. - -## Challenge notes - -The plan holds up. I found no major objections and five minor ones, each written as an instruction the Dev and Tester can follow. Plan checked: /home/user/DockerUpdateGuard/specs/feature-453-dashboard-attention/plan.md (with spec.md, tasks.md and docs/decisions/0080-the-dashboard-counts-the-containers-advisories-and-own-images-it-lists.md). - -**Fact 15 and the test seam: confirmed.** -- I loaded EF Core 11.0.0's `Microsoft.EntityFrameworkCore.dll` in a scratch console app and checked `DbContext` by reflection. `DbSet Set()` is `virtual=True final=False`, and so is `Set(string)`. -- Every `DbSet` property in `src/DockerUpdateGuard.Data/DockerUpdateGuardDbContext.cs:30-100` calls `Set()`. -- No entity has a navigation to `DockerInstanceResourceSample` or `RuntimeContainerResourceSample`. So samples can only be read through `_dbContext.RuntimeContainerResourceSamples` (`ApplicationViewService.cs:828`, `:924`) or `DockerInstanceResourceSamples` (`:850`, `:945`), and the override sees every such read. -- A subclass that takes `DbContextOptions` already works: `src/Tests/DockerUpdateGuard.Tests/Data/GatedSaveChangesDbContext.cs` does exactly that. `ApplicationViewService` takes the context directly (`ApplicationViewService.cs:83`). -- Fact 17 (SQLite cannot order by `DateTimeOffset`) stands: `SqliteTestDatabase.cs` sets up no `DateTimeOffset` converter. - -**Other facts I checked: all confirmed.** -- Fact 3: tag fallback at `:1235-1243`. -- Fact 4: resource histories are loaded at `:413`. -- Fact 5: the overview at `:1109-1180`. -- Fact 6: alert lookups at `:283-307` and `:1360-1363`. -- Fact 7: `GetScanHistoryCoreAsync` at `:540-552`. -- Fact 8: protected assets in `MainLayout.razor.cs` around line 368. -- Fact 9: `TimestampFormatter.cs:15` uses `yyyy-MM-dd HH:mm 'UTC'`. -- Facts 12 to 14: `SeverityBar.razor.cs:37` folds `OtherCount` into low; `SectionPanel` has the parameters the plan names; `AppStylesheetTests.cs:446-467` asserts the `metric-card`/`summary-card` rules. -- `StatusTone` has `Neutral`, `Warning`, `Danger` and `Success`, and `StatusToneFormatter.GetSeverityTone` exists. -- The prescribed assertion for `ApplicationViewServiceDashboardExcludesFindingsForInactiveRuntimeImageVersionsAsync` (`VulnerabilityCount` 1, summary without the retired critical finding) matches its fixture. The retired finding has its own advisory id, CVE-2026-0002, at `ApplicationViewServiceTests.cs:805`, so E6 does not merge it. -- `DashboardFailedRefreshKeepsDashboardAndLogs` still holds, because `kept-scan-subject` ends up in the new segment `title`. -- `DashboardTests.cs:32-36` has no DataRow for `Vulnerabilities`, so removing that case breaks no test. -- Tag selections (`:1621`) are read only on the detail page, so the list page and the dashboard agree on `Update available`. - -**Objections (all minor):** - -1. **The vulnerability query loads every active finding.** The *Vulnerabilities* step (plan, *Approach* step 2) loads all active `VulnerabilityFindings` across the fleet as full entities on every dashboard load and every refresh signal. Today's dashboard only runs a database-side grouped count limited to the running image versions (`ApplicationViewService.cs:753-767`). That makes the landing page's load grow with findings on images no container runs, against the spirit of N1. Instruction to the Dev: - - First query the distinct `AdvisoryId`s of active findings whose `ImageVersionId` is a running image version. - - Then load only the active findings of those advisories. - - Project to the columns the helpers need: `AdvisoryId`, `ImageVersionId`, `Severity`, `CvssScore`, `AffectedPackage`, `FixedVersion`. - - Compare advisory ids case-insensitively, as the `OrdinalIgnoreCase` grouping does. - - E6 results stay the same. - -2. **The resource test needs a positive control.** `ApplicationViewServiceDashboardRequestsNoResourceSampleSetsAsync` only asserts that something is absent, and today's `GetDashboardAsync` (`:1806-1863`) reads no samples either. So the test is green before the change and would stay green if the override recorded nothing, for example if it were declared `new` instead of `override`. Instruction to the Tester: also assert that `ContainerSnapshot` is among the recorded entity types, then assert that neither resource sample type is. - -3. **`PageHeaderSkeleton` would be left unused.** The dashboard is its only user (`Components/Pages/Dashboard.razor:14`; a grep of `src` finds no other page). The plan drops it from the dashboard and leaves the component and `src/Tests/DockerUpdateGuard.Tests/PageHeaderSkeletonTests.cs` orphaned. Instruction: delete `PageHeaderSkeleton.razor(.cs)` and its tests in the same task that deletes `MetricGridSkeleton` (tasks 7 and 8), or keep using it inside `DashboardSkeleton`. - -4. **`DashboardSkeleton` should have a code-behind.** The plan makes it markup-only, but every component under `Components/Common` has one, the skeletons included (`PageHeaderSkeleton.razor.cs:6` is `public sealed partial class PageHeaderSkeleton;`). Only `App`, `Routes`, `NotFound`, `Error` and `_Imports` have none. Instruction to the Dev: add `Components/Common/DashboardSkeleton.razor.cs` with a documented `public sealed partial class DashboardSkeleton;`, as `PageHeaderSkeleton` does. - -5. **`README.md` describes the old dashboard.** `README.md:20` says "**Dashboard**: summary view of the current inventory", which no longer describes the page. Instruction to the Dev: update that line in task 11, for example "what needs attention: containers with updates, advisories in running containers, own base runtime warnings and the last scans". - -I edited no files; the only thing I created is the reflection check project under `/tmp/claude-0/-home-user-DockerUpdateGuard/707101a9-b836-5ed5-ab6e-85e65ff789e1/scratchpad/efcheck`. diff --git a/specs/feature-453-dashboard-attention/spec.md b/specs/feature-453-dashboard-attention/spec.md deleted file mode 100644 index 7041b92d..00000000 --- a/specs/feature-453-dashboard-attention/spec.md +++ /dev/null @@ -1,201 +0,0 @@ -# Spec: Dashboard that lists what needs attention - -Source: Issue #453 (part of #450) -Status: Approved by Lead - -## Problem - -The dashboard (`/`) answers "how many" but not "which": a hero panel, eight metric cards, *Update pressure* and -*Coverage snapshot* repeat the same counters, and a user who reads "7 update findings" has to open another page to -learn which containers are meant. The table of the ten most recent scans takes the most room although it matters -only when a run failed. Users need to see at a glance which containers, advisories and own images need attention, -and whether a recent scan failed. - -## Scenarios - -The visual values (fonts, sizes, colors, tokens, gaps, paddings, panel widths) are those of the issue's *Scope* -(sections 1–5) and the mockups linked there; the spec does not repeat them. "Running containers" are the current -containers of [Docker instances](../../docs/areas/docker-instances.md) — the set the Runtime Containers page lists. - -- S1: Given running containers with the update state `Update available`, advisories affecting running containers - and own images with a base runtime alert, when the user opens `/`, then the page shows top to bottom: the headline - `7 updates, 2 runtime warnings and 31 vulnerabilities need attention.` (only the three parts colored), the sub - line `43 protected assets on 2 Docker instances · last activity 2026-11-14 09:42 UTC`, the vulnerability - configuration hint if one applies, the panels *Updates available*, *Vulnerabilities*, *Own base runtime warnings* - and *Last 10 scans*, and the inventory strip. The hero panel, the metric cards, *Update pressure*, *Coverage - snapshot* and the *Recent scans* table are gone. -- S2: The headline leaves out every count that is 0, keeps the order updates, runtime warnings, vulnerabilities, - joins two parts with `and`, three with a comma and `and`, and uses the singular for a count of 1 (`1 update`, - `1 runtime warning`, `1 vulnerability`); a single part of count 1 takes `needs attention.`, every other - headline `need attention.`. Without any part it reads `Everything is up to date.` in the success color. -- S3: *Updates available* shows the count and up to 5 running containers with the update state `Update available`, - ordered by container name, then instance name (letter case ignored). A row shows the container name, the instance - name, and `{current tag} → {available tag}`, the current tag followed by `({resolved version})` when the tag is an - alias, as on the Runtime Containers page. A click on the row opens `/runtime-containers/{instanceId}/{containerId}`. - The footer reads `{n} more in Runtime Containers` when more than 5 qualify, otherwise `Open Runtime Containers`; - both open `/runtime-containers`. -- S4: *Vulnerabilities* shows the count, the severity bar with its legend over the counted advisories, and up to 4 - advisories that affect at least one running container, ordered by severity (Critical, High, Medium, Low, then - an unknown severity), CVSS score descending (no score last), number of affected running containers descending, - advisory identifier (letter case ignored). A row shows the affected packages joined with `, ` (the advisory - identifier when it names none), the severity as a chip, and `Fixed in {versions joined with ", "}` or - `No fix available`, ` · `, `{n} running containers` (`1 running container`). A screen reader announces the - advisory identifier with the row. A click opens `/vulnerabilities`. The footer reads `{n} more in Vulnerabilities` - when more than 4 qualify, otherwise `Open Vulnerabilities`. -- S5: *Own base runtime warnings* shows the count and up to 5 own images (registration source *Discovery*) with a - base runtime alert, ordered by name (letter case ignored); a row shows the image name and its alert summary as My - Images shows it, and opens `/my-images/{id}`. The footer reads `{n} more in My Images` (to `/my-images`) when more - than 5 qualify; otherwise there is no footer. -- S6: *Last 10 scans* shows one segment per recorded run of the ten most recent, newest on the left, colored by - status (Succeeded, Partial, Failed, Running, Pending as the issue's *Scope* names), each with a tooltip - `{type} · {target} · {status} · {start}` (start as `yyyy-MM-dd HH:mm UTC`, the target left out with its separator - when the run has none); below it one line with the counts per status above 0 in the order - succeeded, running, pending, partial, failed, joined with ` · ` (`8 succeeded · 1 partial · 1 failed`, the failed - count emphasized in the danger color). The strip is announced as an image whose name lists the same counts joined - with `, `. When one of the ten runs is `Failed` or `Partial` and has an error message, one more line names the - newest such run: `{target} · {error message}`, the message as stored. The footer `Open scan history` opens - `/scan-history`. -- S7: The inventory strip shows one cell per counter — `My Images` (only when a Docker Hub account is configured), - `Observed Images`, `Runtime Containers`, `Docker Instances`, `Base Images` (only when its count, the number of - shared base images, is above 0) — each with its figure and a link to `/my-images`, `/observed-images`, - `/runtime-containers`, `/docker-instances` and `/base-images`. -- S8: Given no update, no runtime warning and no vulnerability count, when the user opens `/`, then the headline - reads `Everything is up to date.`, and one panel titled `Nothing to do` with the text `No updates available, no - own base runtime warnings and no vulnerabilities in running containers.` replaces the three list panels; it and - *Last 10 scans* each take the full width, one above the other, as in the all-clear mockup; the inventory strip - stays. -- S9: Given a manual scan, registration or rescan finishes, when the refresh signal arrives, then the open dashboard - reloads its data without a page reload; the first interactive render reuses the prerendered data. -- S10: While the data loads, the page shows skeletons in the shape of the new layout: headline, three panels and the - strip. -- S11: On a screen narrower than three panel columns the panels stack in the order Updates available, - Vulnerabilities, Own base runtime warnings, Last 10 scans; the inventory strip wraps its cells. - -## Errors and edge cases - -- E1: No recorded scan run: the sub line ends with `last activity no scans yet`; *Last 10 scans* shows `No scans - have been recorded yet.` and neither strip nor count line, the footer link stays. -- E2: Exactly one Docker instance or one protected asset: `1 Docker instance`, `1 protected asset`. -- E3: A list panel without an entry shows no count and its empty text: `No updates available.`, `No - vulnerabilities in running containers.` (and no severity bar), `No runtime warnings.`. -- E4: No Docker Hub account configured (user name or token missing) and no runtime warning: the *Own base runtime - warnings* panel is not shown. With such warnings (own images kept from an earlier configuration) it is shown. -- E5: A container with `Update available` but no available tag: its second line shows the current tag only, without - arrow. -- E6: An advisory counts once. Its severity, score, packages and fixed versions come from all its active findings, - also those of image versions no container runs, as the Vulnerabilities page computes them (highest severity, - highest score); only its container count and whether it is listed depend on running containers. An unknown - severity counts as low in the bar. -- E7: The newest failed or partial run has no target (a vulnerability refresh): its line shows the error message - alone. A failed or partial run without an error message is skipped for that line; with none left, the line is - absent. -- E8: Fewer than ten runs: the strip shows only those runs. A run with a status other than the five is drawn in the - pending color and appears in neither count line nor label. -- E9: The first load fails: the error alert `Loading the dashboard failed: ` replaces the skeletons, as - today; a failed reload keeps what is shown. -- E10: Names, packages, tags and error messages come from Docker, registries and scanners: they are shown as text, - never interpreted as markup; long texts wrap inside their panel. -- E11: Update findings of observed images no container runs, and vulnerabilities of image versions no container - runs, appear on no dashboard panel and in no headline count (Observed Images, My Images and Vulnerabilities still - show them). -- E12: Nothing was evaluated (vulnerability scanning disabled, or every container's update check `Failed`, `No tag - data`, `Manual review required` or another state than `Update available`): those containers and images count - for nothing, so the all-clear headline and panel appear, together with the *Scanning disabled* hint when it - applies. - -## Non-functional requirements - -- N1: The dashboard loads in one service call through `IApplicationViewService`; the lists share the evaluation of - the Runtime Containers, Vulnerabilities and My Images pages instead of copying it, and the dashboard reads no - resource usage samples or histories and no per-image vulnerability details beyond what the lists need (no list - of affected images). -- N2: The view data carries only the shown entries (at most 5, 4 and 5) plus each list's total count and the ten - most recent runs, so the persisted prerender state stays small. -- N3: Contrast, control height, reduced motion and self-hosted fonts follow the rules of #450 in both themes. -- N4: No route, action, configuration or stored data changes; which containers are running, which images own, and - how update state, severity and base runtime alerts are evaluated stays with the feature areas. - -## Acceptance criteria - -- AC1: The headline follows the composition rules for every combination of zero and non-zero counts, including the - singular forms, `needs`/`need` and `Everything is up to date.`; only the parts are colored (S1, S2, S8). -- AC2: The sub line shows protected assets (manual observed images + own images + running containers, the top - bar's figure), the Docker instance count and the start time of the most recent run as - `yyyy-MM-dd HH:mm UTC`, or `no scans yet`, with the singular forms (S1, E1, E2). -- AC3: *Updates available* lists at most 5 running containers with the state `Update available` in the stated - order, with names, current tag (and resolved version of an alias), available tag and the detail link; footer text - and target follow S3 (S3, E3, E5). -- AC4: *Vulnerabilities* shows the severity bar and at most 4 advisories affecting running containers in the - stated order, with packages or identifier, severity chip, fix text, container count, an accessible name holding - the identifier, the link and the footer of S4 (S4, E3, E6). -- AC5: *Own base runtime warnings* lists at most 5 own images with their alert summary and image link and the - footer of S5; it is hidden without a Docker Hub account and without warnings (S5, E3, E4). -- AC6: *Last 10 scans* shows the strip (order, colors, tooltip texts, accessible name), the count line, the line of the - newest failed or partial run with its stored message, and the scan history link; without runs its empty text - (S6, E1, E7, E8). -- AC7: The inventory strip shows its cells with the visibility rules and links of S7 (S7). -- AC8: With all three counts 0 the `Nothing to do` panel replaces the three list panels; scans and inventory stay, - and a configuration hint that applies is shown with them (S8, E12). -- AC9: The service fills the counts as the number of running containers with `Update available`, the number of - distinct active advisories affecting at least one running container (the severity bar on the same basis), and the - number of own images with a base runtime alert; the headline and panel counts are these figures, and each "more" - figure is the count minus the shown entries (S1–S5, E6, E11, N2). -- AC10: The dashboard shows the new skeletons while loading, the existing error alert on a failed first load and - the existing vulnerability configuration hints under their existing conditions; it reloads on the refresh signal, - reuses the persisted prerender state, and builds neither resource histories nor affected-image lists; texts from Docker, registries and scanners are rendered as text (S9, S10, E9, E10, N1, N4). -- AC11: `docs/areas/web-ui.md` describes the new dashboard (Area documents). - -## Out of scope - -- The app shell and the top bar's two values (#454); the navigation in the mockups. -- A link from a vulnerability row to a filtered Vulnerabilities page; new actions on the dashboard. -- Update findings of non-running observed images on the dashboard (E11). -- S11 and N3 beyond what bUnit can assert on markup: verified on the screenshots of the pull request. - -## Open questions - -- What the counts count. Answered: what the lists list (AC9), as the issue proposes, so that the headline, the panel - count and the "more" figure agree with one figure each. Today's finding counts (all active update findings, - active vulnerability findings of running containers, active derived-runtime findings of own images) leave the - dashboard. -- Hide *Own base runtime warnings* without a Docker Hub account and without a warning? Answered: yes, as proposed - (E4); the account condition is the one My Images uses (user name and token set). -- Update findings of observed images no container runs appear nowhere on the dashboard. Answered: accepted, as - proposed (E11). Because of it the all-clear text says `No updates available` instead of the issue's `No update - findings`, which would be untrue while such findings exist. -- Last activity format. Answered: the issue's `14.11.2026 09:42` ("server format, as today") is not today's - behavior; timestamps are UTC `yyyy-MM-dd HH:mm UTC` ([decision 0058](../../docs/decisions/0058-timestamps-are-shown-in-utc-with-an-explicit-suffix.md)), as the top bar shows them. -- Configuration hints. Answered: the issue names three alerts; the code has two (scanning disabled, Docker Hub - credentials missing for Docker Scout, [Vulnerabilities](../../docs/areas/vulnerabilities.md)); both stay. -- *Base Images* cell condition. Answered: the issue's "at least one base image is resolved" is not today's rule; - the cell keeps today's condition and figure (shared base images above 0) under the series' label `Base Images`. -- Position of the `Nothing to do` panel. Answered: the issue says "in the third column's place", the all-clear - mockup shows it and the scan panel full width; the spec follows the mockup (S8). -- #278. Answered: closed; the *Recent scans* description it concerned is removed with the table, and - `docs/areas/web-ui.md` holds no gap note for it. - -## Area documents - -- `docs/areas/web-ui.md`: the dashboard row of *Pages and routes* rewritten (headline counts, the three lists, the - last ten scans, the inventory counters); a new *Dashboard* subsection with the headline rules, the list contents, - limits, orders, footers and empty texts, the all-clear state, the scan strip and the inventory visibility rules; - the *General* sentence on scan status chips without the dashboard; the font sentence naming the inventory figures - instead of the metric cards. The document has about 4,200 words: the plan measures the addition against - `AREA_MAX_WORDS` and moves the dashboard into its own area document if it would pass it. - -## Challenge - -Spec challenge by the Devil's Advocate (four minor objections; the confirmed deviations of the Lead are not -repeated here). - -1. Packages, fixed versions and severity of an advisory may come from findings of image versions no container runs. - Accepted: E6 states that they come from all active findings of the advisory, as the Vulnerabilities page - computes them (the row links there and must not disagree with it); only listing and container count depend on - running containers. The plan's service tests include such a finding. -2. N1 dropped the issue's "no per-image vulnerability details beyond what the lists need". Accepted: N1 names it - (no affected-image list); AC10 checks that neither resource histories nor affected-image lists are built, and - the plan reuses the per-container and per-advisory evaluation, not the page loaders. -3. The all-clear state when nothing was evaluated. Accepted: new E12, covered by AC8; the plan has a render test of - the all-clear state with the *Scanning disabled* hint and service tests with containers in other update states. -4. The tooltip's start-time format. Accepted: S6 names the tooltip text and the UTC format (decision 0058); AC6 - covers the tooltip texts. diff --git a/specs/feature-453-dashboard-attention/tasks.md b/specs/feature-453-dashboard-attention/tasks.md deleted file mode 100644 index c60592b0..00000000 --- a/specs/feature-453-dashboard-attention/tasks.md +++ /dev/null @@ -1,18 +0,0 @@ -# Tasks: Dashboard that lists what needs attention - -Plan: [plan.md](plan.md) - -| # | Group | Task | Files | Criteria | Depends on | Owner | Done | -| - | ----- | ---- | ----- | -------- | ---------- | ----- | ---- | -| 1 | G1 | Skeleton: DashboardViewData members UpdateCount, Updates, VulnerabilityCount, Vulnerabilities, VulnerabilityAdvisorySeveritySummary, RuntimeWarningCount, RuntimeWarnings (and the four deleted ones); classes DashboardUpdateItemData, DashboardVulnerabilityItemData, DashboardRuntimeWarningItemData | `src/DockerUpdateGuard/UI/DashboardViewData.cs`, `src/DockerUpdateGuard/UI/Dashboard{Update,Vulnerability,RuntimeWarning}ItemData.cs` | AC3, AC4, AC5, AC9 | — | Dev | [x] | -| 2 | G1 | Tests first: service tests of the lists, counts and the resource bound, the `SetRecordingDbContext` double, and the adapted `ApplicationViewServiceTests` and `DashboardRenderTests` call sites | `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/Data/SetRecordingDbContext.cs`, `src/Tests/DockerUpdateGuard.Tests/ApplicationViewServiceTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs` | AC3, AC4, AC5, AC9, AC10 | 1 | Tester | [x] | -| 3 | G1 | Implement `GetDashboardAsync` with the extracted helpers `ResolveRuntimeContainerTags`, `CountAffectedContainers`, `SelectAffectedPackages`, `SelectFixedVersions`, `FindBaseRuntimeAlert` | `src/DockerUpdateGuard/UI/ApplicationViewService.cs` | AC3, AC4, AC5, AC9, AC10 | 2 | Dev | [x] | -| 4 | G2 | Skeleton: DashboardTextFormatter (GetHeadlineSegments, FormatCount, FormatSubLine, FormatFooterLink, FormatCurrentTag, FormatVulnerabilityTitle, FormatVulnerabilityDetail), DashboardScanStripFormatter (GetStatusCounts, FormatCountText, FormatStripLabel, FormatSegmentTitle, GetSegmentCssName, FindLatestProblemScan, FormatProblemScanLine), DashboardHeadlineSegmentData, DashboardScanCountData | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardHeadlineSegmentData.cs`, `src/DockerUpdateGuard/UI/DashboardScanCountData.cs` | AC1, AC2, AC3, AC4, AC6 | 3 | Dev | [x] | -| 5 | G2 | Tests first: formatter tests | `src/Tests/DockerUpdateGuard.Tests/DashboardTextFormatterTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardScanStripFormatterTests.cs` | AC1, AC2, AC3, AC4, AC6 | 4 | Tester | [x] | -| 6 | G2 | Implement the formatters | `src/DockerUpdateGuard/UI/DashboardTextFormatter.cs`, `src/DockerUpdateGuard/UI/DashboardScanStripFormatter.cs` | AC1, AC2, AC3, AC4, AC6 | 5 | Dev | [x] | -| 7 | G3 | Skeleton: empty `DashboardSkeleton` component; delete `MetricGridSkeleton` | `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor`, `src/DockerUpdateGuard/Components/Common/MetricGridSkeleton.razor.cs` | AC10 | 6 | Dev | [x] | -| 8 | G3 | Tests first: page render, persistent state, skeleton and stylesheet tests; `DashboardTests` DataRow; delete `MetricGridSkeletonTests` | `src/Tests/DockerUpdateGuard.Tests/DashboardRenderTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardPersistentStateTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardSkeletonTests.cs`, `src/Tests/DockerUpdateGuard.Tests/AppStylesheetDashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/DashboardTests.cs`, `src/Tests/DockerUpdateGuard.Tests/MetricGridSkeletonTests.cs` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC9, AC10 | 7 | Tester | [x] | -| 9 | G3 | Rewrite the dashboard page, the skeleton markup and the dashboard rules of the stylesheet | `src/DockerUpdateGuard/Components/Pages/Dashboard.razor`, `src/DockerUpdateGuard/Components/Pages/Dashboard.razor.cs`, `src/DockerUpdateGuard/Components/Common/DashboardSkeleton.razor`, `src/DockerUpdateGuard/wwwroot/app.css` | AC1, AC3, AC4, AC5, AC6, AC7, AC8, AC10 | 8 | Dev | [x] | -| 10 | G3 | Image build check (a `.razor` content item was added and one removed) | — | AC10 | 9 | Dev | [x] | -| 11 | G3 | Area document: dashboard row, new *Dashboard* subsection, chip and font sentences, decision 0080 link | `docs/areas/web-ui.md` | AC11 | 9 | Dev | [x] | -| 12 | G3 | Test documentation: `SetRecordingDbContext` under *Test doubles*, the bUnit example's assert message | `docs/UNIT_TESTS.md` | AC10 | 8 | Tester | [x] |