Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bfaa680
Mirror the compute read vocabulary
neuromechanist Nov 7, 2026
255e90e
Capture compute read fixtures
neuromechanist Nov 7, 2026
7123b95
Add SU and time formatters
neuromechanist Nov 7, 2026
c83a108
Add usage chart geometry
neuromechanist Nov 7, 2026
5c0684e
Add compute job state badges
neuromechanist Nov 7, 2026
6cceca2
Add the compute read client
neuromechanist Nov 7, 2026
b032c51
Add compute page copy keys and Settings link
neuromechanist Nov 7, 2026
d57477d
Add compute view models and labels
neuromechanist Nov 7, 2026
59f02eb
Add chart color tokens
neuromechanist Nov 7, 2026
512308a
Route /compute to the app host
neuromechanist Nov 7, 2026
6d9089c
Add compute badge, panel and notice components
neuromechanist Nov 7, 2026
bae6fec
Add access, balances and queue panels
neuromechanist Nov 7, 2026
dde271a
Add the usage chart panel
neuromechanist Nov 7, 2026
5e885f5
Add the jobs table with Load more
neuromechanist Nov 7, 2026
5083b07
Add the compute page
neuromechanist Nov 7, 2026
05553e0
Link compute from the user menu
neuromechanist Nov 7, 2026
5571dc6
Guard the compute page wiring
neuromechanist Nov 7, 2026
e69585a
Offer one way back after a bad cursor
neuromechanist Nov 7, 2026
2d6b198
Seed compute data in the local backend
neuromechanist Nov 7, 2026
d86c937
Record the compute dashboard phase
neuromechanist Nov 7, 2026
ca9b78e
Fix the notice prop type
neuromechanist Nov 7, 2026
2ef9510
Rename SU formats, share contract extractors
neuromechanist Nov 7, 2026
53589db
Separate the chart series by lightness too
neuromechanist Nov 7, 2026
7530733
Keep a chart stack inside the plot
neuromechanist Nov 7, 2026
098a838
Use American spelling in compute text
neuromechanist Nov 7, 2026
9c740e5
Leave modified clicks on Load more alone
neuromechanist Nov 7, 2026
748171c
Tighten usage states, caption unit and labels
neuromechanist Nov 7, 2026
e57ac3a
Mirror the reworded compute copy
neuromechanist Nov 7, 2026
39cc3fb
Soften the compute access lede
neuromechanist Nov 7, 2026
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
14 changes: 13 additions & 1 deletion .context/decisions/0030-compute-pages-follow-adr-0010-phase-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,19 @@ The captured fixtures in `test/fixtures/compute/` gain a `GET /compute/me` captu
- **Read the terms version server-side in the page frontmatter now.** Not available until D2 serves `GET /compute/me`; the transcription and its drift test are the bridge.
- **Show the backend's sentence for the profile refusals.** Rejected: it lists raw field names (`given_name, affiliation`); the linked, worded list is what the CLI prints.

## Addendum: the dashboard (phase E2, website#495, 2026-11-07)

`/compute` reads nemar-cli's `GET /compute/me`, `/compute/me/usage` and `/compute/me/jobs` (Epic D, phase D2). The decisions that are expensive to reverse:

- **Independent panels.** The account read comes first because it names the state; usage and the first page of jobs then run in parallel, each in its own `try/catch`. A failed read degrades one panel with a notice that says the figures are missing, which is not zero. A guard that rejects a body is a `shape` error, never an empty list or zeros. A 404 on the account read is the release gate (an API without the compute routes) and shows one notice; a 401 redirects to sign-in; a 403 is the backend's "not approved" for an unverified account, never a compute-access answer.
- **One chart per pool.** CPU and GPU service units are different currencies, so the usage chart is drawn once per pool (daily net charge, stacked by partition, at most three offered partitions plus "other") and the two are never added. Usage rows reach a pool only through `limits.partitions[].pool`; a correction that names no job, or a partition no longer offered, is shown as a separate "Adjustments and other partitions" line rather than guessed into a pool (nemar-cli#2078 asks for `pool` as a usage group).
- **Three-decimal parity with the CLI.** `suFixed` is the CLI's own function of that name (integer milli-SU in, `12.500` out, no thousands separator, a negative stays negative), and sums go through an exact adder; nothing printed passes through a float. A finished job with no charge prints `0.000`; a live one reads "Not charged yet" (the CLI prints `-` for both).
- **No synthesized figures.** Only `pools.cpu` and `pools.gpu` are read, by name, so a pool or platform figure the Worker adds later cannot reach the markup. A partner job's front door is the plain label "Partner site". The frozen sentence shows for an ACTIVE account only (the CLI's rule). A state outside the closed six shows its escaped raw word and nothing else. "New jobs are paused" is not shown because no read serves it (nemar-cli#2080).
- **Untrusted text is inert.** Every backend string (an app, a partition, a state) is escaped through `displaySafeLine` and rendered as a text node, in the template and in the "Load more" script (`createElement` and `textContent` only; a test forbids every markup-writing API in the Compute files). A job id reaches an `href` only if it is `job_` and 24 hex digits.
- **Shared copy.** Seven keys were added to nemar-cli's contract and transcribed (`compute_page.*`, `compute_access.granted.link`), and `compute_access.granted.body` no longer promises submission from the website: jobs are submitted with the command line.
- **Still open from the hand-off above:** replacing `compute-terms.ts` and `COMPUTE_REQUESTS_ENABLED` with `access.current_terms_version` and `access.requests_open` is a follow-up; `/compute` already reads `requests_open` (falling back to `terms_published`) for its own "request" link.

## Receipts

- website#493 (epic), website#494 (phase E1); nemar-cli#2021 (Epic D), #2071 (phase D1, commit 3a869903).
- website#493 (epic), website#494 (phase E1), website#495 (phase E2); nemar-cli#2021 (Epic D), #2071 (phase D1, commit 3a869903).
- ADRs 0006, 0007, 0010, 0014, 0015, 0029; nemar-cli ADRs 0040, 0042, 0118.
12 changes: 11 additions & 1 deletion .context/handoff.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Handoff — nemar.org website

**Last session:** 2026-11-06.
**Last session:** 2026-11-07.

## 2026-11-07: The compute dashboard (website#495, epic website#493 phase E2)

Branch `feature/issue-495-compute-dashboard`, PR into the epic branch. ADR 0030 addendum. Depends on nemar-cli's Epic D branch (phase D2 routes) and its copy PR #2082 (seven keys, reworded `compute_access.granted.body`).

- **Recipe:** `NEMAR_CLI_DIR=<Epic D checkout> PORT=8791 bun scripts/local-backend.mjs --seed-compute`, then `PUBLIC_API_BASE_URL=http://localhost:8791 bun run dev`; cookies for `rich`, `frozen`, `overrun`, `granted` print with the others (`.context/local-backend.md`).
- **Fixtures** (`test/fixtures/compute/*.json`, 13 new files) are captured by `scripts/capture-compute-read-fixtures.mjs` from the real router; a rerun writes the same bytes.
- **Drift gates:** `test/compute-user-contract-drift.test.ts` (`NEMAR_CLI_COMPUTE_STATE`, `_USER_CONTRACT`, `_CONTRACT`) and the account-copy drift test are red in CI until the compute epic and #2082 reach nemar-cli `dev`. Never put them on `staging` earlier.
- **Release gate:** do not promote until the production API serves `GET /compute/me`; a site talking to an API without it shows one "not available" notice.
- **Follow-ups:** a usage window selector, a `?state=` filter, the ADR 0030 hand-off (drop `compute-terms.ts` and `COMPUTE_REQUESTS_ENABLED`), the job page (E3). Backend gaps: nemar-cli#2078 (pool as a usage group), #2079 (job name), #2080 (are new jobs accepted).

## 2026-11-06: Compute access card in Settings (website#494, epic website#493 phase E1)

Expand Down
12 changes: 12 additions & 0 deletions .context/local-backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ got is not `127.0.0.1`. `test/local-backend-guard.test.ts` runs the refusals.
http://localhost:8787/admin/compute/access/grant/localrequested
```

## Seeding the compute dashboard (`--seed-compute`)

```bash
NEMAR_CLI_DIR=/path/to/nemar-cli-checkout bun scripts/local-backend.mjs --seed-compute
```

Adds, with the backend's own test helpers and ledger services (never a stand-in): `localrich` (active; a CPU and a GPU grant, charges on several days of the last 30 on both pools, one administrator's correction naming no job, an open hold, 40 jobs over the ten states and four front doors with enough finished ones for a second page, and queue samples with figures, a real zero and a thin sample), `localfrozen` (a frozen pool), `localoverrun` (a negative available) and `localgranted` (granted through the REAL admin routes, access then a pool grant: no jobs, no charges). Their cookies print with the others. `PORT=<n>` moves the backend (and `PUBLIC_API_BASE_URL` with it). The loopback guards are unchanged.

There is no unverified persona: signing in by emailed code verifies the email. `bun run dev` without `PUBLIC_API_BASE_URL` has the `@nemar.cpending` mock for that screen. The database refuses a markup-bearing `app_id` (a CHECK on `compute_jobs`), so the "hostile text" case is covered by unit tests, not by a seeded row.

A second browser profile on the same host shares cookies; use `http://127.0.0.1:4321` beside `http://localhost:4321` to keep two sessions apart.

## What differs from production

- `ENVIRONMENT` is `test`: the backend takes compute requests whether or not the terms are
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,20 @@ jobs:
# the compute terms version a request must name (website ADR 0030, interim until phase D2's
# GET /compute/me serves it). Same `dev` pairing, strict, and red until the compute epic
# reaches nemar-cli `dev`; the ref stays `dev`.
# test/compute-user-contract-drift.test.ts is a NINTH, against shared/compute-state.ts and
# shared/contract/compute-user.ts and compute.ts: the job states, front doors, usage groups,
# page bounds and read-refusal words the /compute page branches on (phase E2). Same `dev`
# pairing, strict, and red until the compute epic reaches nemar-cli `dev`.
- uses: actions/checkout@v4
with:
repository: nemarOrg/nemar-cli
path: nemar-cli-contract
sparse-checkout: |
/shared/compute-state.ts
/shared/contract/account-copy.ts
/shared/contract/compute-terms.ts
/shared/contract/compute-user.ts
/shared/contract/compute.ts
/shared/contract/docs-auth.ts
/shared/contract/mail-admin.ts
/shared/contract/oidc-authorize.ts
Expand All @@ -145,6 +152,9 @@ jobs:
env:
NEMAR_CLI_ACCOUNT_COPY: nemar-cli-contract/shared/contract/account-copy.ts
NEMAR_CLI_COMPUTE_ACCESS_CONTRACT: nemar-cli-contract/shared/contract/compute-terms.ts
NEMAR_CLI_COMPUTE_CONTRACT: nemar-cli-contract/shared/contract/compute.ts
NEMAR_CLI_COMPUTE_STATE: nemar-cli-contract/shared/compute-state.ts
NEMAR_CLI_COMPUTE_USER_CONTRACT: nemar-cli-contract/shared/contract/compute-user.ts
NEMAR_CLI_DOCS_CONTRACT: nemar-cli-contract/shared/contract/docs-auth.ts
NEMAR_CLI_MAIL_ADMIN_CONTRACT: nemar-cli-contract/shared/contract/mail-admin.ts
NEMAR_CLI_OIDC_AUTHORIZE_CONTRACT: nemar-cli-contract/shared/contract/oidc-authorize.ts
Expand Down
8 changes: 7 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ src/
api/v1/[...path].ts generic authenticated API proxy
dashboard.astro my-datasets list + publish status (app host)
upload.astro upload/success.astro upload flow (dropzone + BIDS pre-check + full BIDS validation in a worker + direct-to-storage PUTs)
settings.astro account: name/email/ORCID/GitHub/profile self-service; CLI keys card
settings.astro account: name/email/ORCID/GitHub/profile self-service; CLI keys card; compute access card
compute/index.astro compute dashboard (app host, ADR 0030): access, balances, usage chart per pool, jobs with Load more, queue waits; each read and panel fails alone
admin/publication-requests.astro admin-only (role=admin; 404s for others)
admin/mail.astro admin/mail/{[id],queues,away}.astro admin Mail tab: tickets, queues, away windows (ADR 0029); email is escaped text only
about.astro support.astro community.astro
Expand All @@ -91,6 +92,10 @@ src/
dashboard-api.ts admin-api.ts collaborators-api.ts upload-client.ts authenticated API clients
mail-admin-api.ts admin Mail client (browser-safe): tickets, queues, away window, reply failure classes, badge count, staff directory
mail-admin-contract.ts hand copy of nemar-cli shared/contract/mail-admin.ts (drift-tested, test/mail-admin-contract-drift.test.ts)
compute-api.ts compute-contract.ts browser-safe client for GET /compute/me, /me/usage, /me/jobs (guards copy out only the keys read; a rejected body is a `shape` error, never zeros) and the hand copy of the vocabulary it needs, the one place the job-state and front-door words live here (drift-tested, test/compute-user-contract-drift.test.ts; extractors in test/compute-contract-drift.ts)
compute-view.ts compute-labels.ts compute-badges.ts pure view models (panelsFor, access, balances, queue, jobRowView, usage), the page's short labels (sentences live in account-copy.ts), job-state badges
compute-format.ts compute-chart.ts integer milli-SU formatting (`suFixed`: the CLI's three-decimal digits; `formatSu`: the shortest exact decimal, the same rule as nemar-cli's `formatSu`) and the usage chart geometry (nice ceiling from the stacked total, hand-rolled SVG, ADR 0007)
compute-jobs-dom.ts builds appended job rows with createElement/textContent only
mail-display.ts escape set for ticket text, thread order, reply draft state machine and its sessionStorage form
device-auth-api.ts device-authorization grant client: lookup/confirm/deny, list keys
device-authorize.ts pure view model for /cli/authorize (no mirrored refusal vocabulary)
Expand All @@ -117,6 +122,7 @@ src/
eeg-viewer.css global signal-viewer styles (runtime-built DOM), imported by BidsTree and the embed
test/
fixtures/ qa-aggregates, qa-file-dataqual, qa-hed-summary (Phase 3)
fixtures/compute/ captured from the real nemar-cli routes, never hand-written: `NEMAR_CLI_DIR=<Epic D checkout> bun scripts/capture-compute-fixtures.mjs` (access, E1) and `bun scripts/capture-compute-read-fixtures.mjs` (me, usage, jobs, errors; E2)
public/ static logos + brain hero assets (og/ cards are generated, gitignored)
public/brand/ GENERATED press logo kit (SVG, PDF, transparent PNG; color, reverse, black, white); rebuild with `bun scripts/generate-brand-kit.mjs`, never hand-edit
public/vendor/bids-validator/<ver>/ GENERATED worker bundle of the BIDS validator + SHA256SUMS + provenance + licenses (ADR 0028); never hand-edited
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ The release pull request from `staging` to `main` moves those entries under the

### Added

- **The `/compute` dashboard** (website#495, epic website#493 phase E2; nemar-cli epic #2021 phase D2, website ADR 0030 addendum).
A signed-in person sees their compute access, CPU and GPU balances (granted, held, charged, available, in the same three-decimal service units `nemar compute balance` prints), a daily usage chart per pool stacked by partition (hand-rolled SVG, themed by new `--chart-*` tokens, with the numbers in a table beside it), their jobs from every front door with "Load more", and the platform's recent queue waits ("Not enough data" with the count when fewer than five jobs started).
A person without active access sees why and how to ask, not an error; a suspended or ended account keeps its history read-only; one failed read shows one notice that says the figures are missing, not zero.
`/compute` is an app-host route, linked from the user menu for active, suspended and ended accounts and from the active Compute card in Settings.
Seven shared copy keys were added (`compute_page.*`, `compute_access.granted.link`) and `compute_access.granted.body` now says jobs are submitted with the command line; they come with nemar-cli's phase PR, so the account-copy drift test is red until it reaches `dev`.
`scripts/local-backend.mjs --seed-compute` seeds the dashboard's data through the real backend helpers.

- **A compute access card in Settings** (website#494, epic website#493 phase E1; nemar-cli epic #2021 phase D1, ADR 0030).
Beside the upload-access card, `#compute-access` shows the account's compute-access state (not requested, requested, active, suspended, not granted, ended) and, for a verified account that has never asked, a request form: a purpose of 20 to 1,000 characters, a required checkbox for the compute terms (with the version, linking the terms page), and the refusal list a refused request returns, as links to the fields to fix.
Every sentence is a transcribed copy key, the same words the CLI prints.
Expand Down
Loading
Loading