Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
377 changes: 377 additions & 0 deletions .devspark.work/pr-review/pr-8.md

Large diffs are not rendered by default.

100 changes: 100 additions & 0 deletions .devspark.work/specs/002-work-ps-022-unified-operator/work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Work: ps-022 Unified operator experience

**Status**: Complete
**Branch**: 002-work-ps-022-unified-operator (from main 54a09ef)
**Source**: roadmap item ps-022 (`.devspark.work/roadmap/specs/ps-022-unified-operator-experience.md`)

## Intended outcome

One consistent self-hosted app: a single scope selector (portfolio → client → source → repository, plus
domain filters) that every view honours, fixed sections, shared page building blocks, one source per
number, and views that link to each other. The public GitHub Pages dashboard is unchanged. The whole
item ships in one PR (developer decision, 2026-11-22, chose this over splitting).

## Acceptance evidence

- Choosing a client, source, or repository changes every view, Security included, with no page reload,
and the URL restores it. The old `?user=<slug>` links and the existing hashes keep working.
- Health, the drawer, and the fix-score prompt show the same open-alert count as Security for a
repository with more than 100 alerts. All three read the ps-006 store in self-hosted mode.
- A Security row opens the repository drawer, and the drawer has a Security panel with that repository's
alerts.
- Every table exports through `ExportButton`. Security drops its own CSV code.
- One shared coverage/state component shows zero, unavailable, unauthorized, unsupported, and stale
distinctly, and every view uses it.
- There is one shared page header, filter bar (including domain filters), and data table.
- Sections: Overview, Health, Security, Sites, Delivery, Presence, Admin. A section appears only when it
has data. The mobile tab bar holds the primary sections and puts the rest behind an overflow.
- No unused component remains. `EmptyState`, `GestureHandler`, `TouchTarget`, `SafeArea`, and the mobile
`LoadingState` are each either adopted or removed, and the two `LoadingState`s become one.
- The refresh actions are labelled "Reload data" (browser cache) and "Collect now" (worker).
- The public Pages build renders Overview, Insights, Health, and the drawer unchanged.
- vitest covers scope switching, cross-links, the shared components, and accessibility. Existing tests
pass, and `./run-validation.ps1` exits 0.

## Material exclusions

- No content for undelivered sections: Sites, Delivery, and Presence stay hidden.
- No rebranding.
- No per-client access control.
- No change to the attention-score model beyond its data source.

## Operating assumptions

- Self-hosted mode is detected by the existing data files. `portfolio.json` and
`security/dependabot.json` are present only on the self-hosted server. The admin API is optional.
- The decision owner is the developer, a single administrator.

## Facts verified at start (main 54a09ef)

- `useDependabot.js` always loads the portfolio-wide `data/security/dependabot.json`. Security ignores
`?user=`.
- `dataService.js` loads `data/users/<slug>/repositories.json` for the `?user=` source. Choosing a source
calls `window.location.reload()`.
- `FixScorePromptSection.jsx` reads `security.dependabot.total_open`, the fetcher's first-page summary.
- The per-source `repositories.json` is written by `worker/loop.py` without reading the registry, so it
has no classifications. Client, project, application, and domain values exist only in `portfolio.json`.
- The unused mobile/layout components listed in the spec exist under `components/Mobile` and
`components/Layout`.

## Open design point (decide during implementation, from evidence)

- **Portfolio and client scope span several sources**, but repository data is stored per source.
- Option A: the frontend loads the needed per-source files and de-duplicates them by `full_name`.
- Option B: the worker writes one portfolio-wide repositories file.
- Prefer A unless loading many sources is measurably slow.
- Classifications are joined from `portfolio.json` by `full_name`, which fills the per-source gap
recorded at ps-023 closeout.

## Invariants

- Domain invariant: a repository is identified by its case-insensitive `full_name` in every scope and
view, so the same repository shows the same counts everywhere.
- Architectural constraint: public mode never requests the admin API or self-hosted-only files in a way
that breaks or changes the Pages build.

## Verification expectations

- Public Pages build: `verify:snapshot-neutral`. The Overview, Insights, Health, and drawer output must be
unchanged in public mode.
- If the worker export changes (Option B, or added fields): `verify:end-to-end` against a real worker
run. Checking it on the server after deploy is a `stage: post-deploy` item, not pre-merge proof.

## Material decisions (implementation)

- Open design point resolved as Option A. The browser loads the per-source files the scope needs and
joins classifications from `portfolio.json`; no worker change.
- Insights is kept as a section (the public view requires it), alongside the listed sections.
- Stored alert counts replace the collected counts everywhere they are shown. The attention score is
still computed at collection time; recomputing it would change the score model, which is out of scope.

## Known differences (not defects of this change)

- On server data (2026-11-22), the per-source files hold 38 repositories while the portfolio and
Security list 45. The collector writes fewer records than discovery finds, so Overview and Security
can list different repository sets.

## Next action

Commit, then `/devspark-create-pr`. After deploy: pick a client and a domain filter on the server,
and confirm that Security and Health follow the choice and show the same alert counts.
24 changes: 21 additions & 3 deletions .documentation/guides/DOCKER_DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ keeps private data out of this release). Prefer a secret file over `GITHUB_TOKEN
2. Stack variables: `SPARK_USER`, `GITHUB_TOKEN` (or the secret-file approach), `BIND_ADDRESS=192.168.1.197`,
`WEB_PORT=8086`.
3. Deploy. Both containers become healthy; the worker collects on start and then every interval.
4. Refresh now: restart the `worker` container in Portainer.
4. To collect immediately, use **Collect now** in Admin, or restart the `worker` container in Portainer.
5. Browse to `http://192.168.1.197:8086` from the LAN.

The default bind is `127.0.0.1`; the app has no authentication yet, so keep it on the trusted LAN and do
Expand Down Expand Up @@ -134,7 +134,25 @@ dashboard shows a **Sources** page only when the API answers; on GitHub Pages it
encrypted at rest. A token's expiry is tracked: the page warns when one is within 14 days, and a
source whose token has expired reports `connection_unusable` instead of silently using another.
Sources without a token use the stack's `GITHUB_TOKEN`.
- **Refresh now:** asks the worker to collect; it starts within seconds.
- **Collect now:** asks the worker to collect; it starts within seconds.

**Scope and sections**
- **Scope:** the bar under the header chooses what every section shows: the whole portfolio, a
client (repositories with no client are **Internal**), a source, or one repository, filtered by
any domain value. Each list offers only choices within the levels above it. The scope is part of
the URL (`?client=Acme&source=acme&repo=Acme/web&d.tier=core`), so a link or reload restores it;
older `?user=<source>` links still work. Overview, Insights, Health and Security all follow it.
- **Sections:** Overview, Insights, Health, Security and Admin. Sites, Delivery and Presence appear
only once those capabilities collect data. Old `#sources` links open Admin. On a phone, sections
that do not fit in the bottom bar are under **More**.
- **One number per fact:** wherever an open Dependabot alert count appears (Health, the repository
drawer, the fix-score prompt, exports), it comes from the stored alerts behind Security, not the
first-page summary taken during collection. The attention score itself is still computed at
collection time. A repository whose alerts could not be read shows why, never zero.
- **Links:** a repository name in Security opens that repository's details; the details drawer has a
Security panel listing its open alerts.
- **Reload data** (footer) re-reads the published files in the browser. **Collect now** (Admin) asks
the worker to collect from GitHub.

**Security notes**
- Passwords are stored as Argon2id hashes; session cookies are `HttpOnly`, `SameSite=Strict`, and only
Expand Down Expand Up @@ -163,7 +181,7 @@ After the first collection, and then every `SPARK_SECURITY_INTERVAL` (default `6
`off` disables it), the worker reads every Dependabot alert (open, dismissed and fixed, all pages) for
each **public** repository an enabled source reaches. Alerts are kept in the database, one observation
of the counts is added per read, and `/data/security/dependabot.json` is rewritten for the **Security**
view. "Refresh now" also triggers it. The result appears in `/data/status.json` under `security`.
view. "Collect now" also triggers it. The result appears in `/data/status.json` under `security`.

The token needs read access to Dependabot alerts: for a fine-grained token, the **Dependabot alerts**
repository permission set to read. A repository that cannot be read is listed in the view's Coverage
Expand Down
Loading
Loading