Skip to content

Phase E1: Compute access card #494

Closed

Description

@neuromechanist

Goal

After this phase a signed-in person can see their compute access state and request access from Settings, in the same words the CLI prints, and the repository has one documented way to run the website against a local backend with a real session.
The decision that compute pages are Phase 3 of website ADR 0010 is recorded.

Routing

Scope

In: the #compute-access card beside #upload-access in src/pages/settings.astro; transcribing the new copy keys and gap rules; the session-user fields and state derivation; the request client; the Affiliation field label; the local-backend recipe; the ADR.
Out: the dashboard (#495), job pages (#496), the admin tab (#497), the dataset dialog (#498); any change to who may request (the backend decides).

Design references

Design section 4 (the request preconditions, states, "compute access and upload access are separate grants"); website ADR 0010 (Phase 3), ADR 0014 (account tier surfaces), ADR 0015 (profile gaps and mirrored copy).
Closest code: src/pages/settings.astro (#upload-access card, the "Upload access request" script block), src/lib/account-tier.ts (deriveUploadAccessState, validateWhy, uploadAccessErrorMessage), src/lib/account-api.ts (requestUploadAccess, AccountApiError), src/lib/account-copy.ts, src/lib/profile-gaps.ts, src/lib/docs-base.ts.

Changes

  • Create the ADR .context/decisions/<next>-compute-pages-follow-adr-0010-phase-3.md from 0000-template.md and add it to the README index: compute pages are ADR 0010's Phase 3; access is the separate compute_access grant (nemar-cli ADR 0040 keeps service_access for upload); the pages are a front end that decides nothing; compute pages live on the app host only; charts are hand-rolled (ADR 0007); untrusted job text renders inert (ADR 0029).
  • Transcribe, do not import: new compute_access.* keys and the gap.blocks.compute_access, gap.blocks.noun.compute_access and gap.field.affiliation.* keys into src/lib/account-copy.ts; the "compute_access" block, the block order and the affiliation row into src/lib/profile-gaps.ts (its derivation and the nemar-cli one are the same rules). Run nemar-cli's test/account-copy-parity.test.ts and test/profile-gaps-matrix.test.ts with both checkouts side by side and record the result in the PR.
  • src/lib/auth.ts and src/lib/account-tier.ts: compute_access, compute_access_requested_at and compute_access_granted_at as optional fields, never defaulted (absent means the backend cannot say, and the card says nothing about state rather than "not requested"); deriveComputeAccessState returning none | requested | active | suspended | denied | revoked with the stamp. Extend the dev mock users in src/lib/auth-dev.ts the way @nemar.asked was added, so astro dev renders each state.
  • src/lib/compute-api.ts (new; Phase E2: Compute dashboard #495 extends it): getComputeMe over dashboardApiBase, SSR with cookieHeader, browser through /api/v1, with the deadline helpers the other clients use. src/lib/account-api.ts: requestComputeAccess({ purpose, acceptTermsVersion }) and computeAccessErrorMessage(status, code, detail) covering purpose_required, terms_not_accepted, email_not_verified, orcid_not_proven, profile_incomplete, access_closed, already_active, terms_unpublished, and an unknown code.
  • src/pages/settings.astro: a card card--wide with id="compute-access" after the upload-access card, same markup shape: a Status row (badge per state with the date), the state body from copy, and for state none on a verified account a form with the purpose textarea (20 to 1,000 characters with a counter), a required checkbox "I accept the compute terms" showing the current version and linking the terms page (DOCS_COMPUTE_PATH in src/lib/docs-base.ts), the refusal list from missing (reuse the upload card's renderer), and an alert line. terms_published false shows the terms_unpublished copy and no form. orcid_not_proven points at the ORCID card. Use [hidden] with :not([hidden]) display rules, the known Astro gotcha. Duplicate the card CSS with a sync comment; do not hoist it.
  • The Affiliation input: its "optional" tag becomes the copy key's "needed for compute access". Check that ProfileNudge and the dashboard nudge do not now nag every account about affiliation beyond what the gap copy says; if they do, say so in the plan.
  • .context/handoff.md (or a new .context/local-backend.md): the recipe for running bun run dev against a local nemar-cli backend (PUBLIC_API_BASE_URL, the seeded @nemar.test fixture accounts whose sign-in codes the dev backend echoes, how the session cookie is obtained on localhost, and what to do if it cannot be). If no working recipe exists, stop and escalate: the later phases and the epic check depend on it.

Tests (write these first)

  1. deriveComputeAccessState for all six states and for absent fields. Fails if absent maps to none.
  2. account-copy.test.ts and profile-gaps.test.ts extended: every transcribed key exists, the block order is verified, upload_access, compute_access, publication, affiliation blocks only compute access, and the nemar-cli parity test passes with both checkouts.
  3. computeAccessErrorMessage for each code, using response bodies captured from the merged backend (a refusal for each code, fixture provenance in the test file). Fails if a code falls through to the generic message.
  4. parseAccountErrorBody keeps missing for a compute refusal.
  5. A getComputeMe test with a captured GET /compute/me body, including terms_published: false.
  6. Browser check, not Vitest: each state of the card in astro dev with the mock users, then against the local backend with a real request, in light and dark and at phone width; confirm no horizontal scroll and the hidden-attribute behaviour.

Acceptance criteria

  • A request from the card reaches the backend and the card re-renders as requested; a refusal lists its missing fields as links.
  • No sentence about compute access is typed at a call site; all come from ACCOUNT_COPY.
  • The local sign-in recipe works from a clean checkout and is written down.
  • The ADR is in the index.

Gates

bun run typecheck && bun run lint && bun run test && bun run build, plus nemar-cli bun test test/account-copy-parity.test.ts test/profile-gaps-matrix.test.ts with the checkouts adjacent.

Rules that bite here

  • ADR 0015: copy and gap rules are transcribed and pinned by a drift test on each side; a retyped sentence is drift.
  • Absent is unknown, not "no": showing "Not requested" to an account the old backend could not describe invites a request that will be refused.
  • Scoped styles do not cross components; duplicate and comment.
  • Never use mocks: fixtures are captured from the real backend.
  • Closes #N does not close issues here; close by hand.

Escalate to the owner if

  • The merged backend differs from the design in a way that changes who may request or what the card may promise.
  • No local session recipe can be made to work.
  • The compute terms page is not yet published and the owner wants the form open anyway.

When merged

Note in the epic issue which keys and rules were transcribed and from which nemar-cli commit; tell the nemarOrg/nemar-cli#2022 driver if the drift test needed a change on the nemar-cli side.

Activity

  1. neuromechanist commented on Nov 7, 2026

    @neuromechanist
    ContributorAuthor

    Merged into the epic branch (PR 502, c06ccd5). Expected CI reds until the compute epic reaches nemar-cli dev: account-copy-drift (27 keys) and compute-terms-contract-drift.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions