Repository navigation
Phase D1: Compute access request and approval - #2071
Merged
neuromechanist merged 14 commits intoNov 7, 2026
Merged
neuromechanist merged 14 commits into
neuromechanist merged 14 commits into
Conversation
3 tasks
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR2071Version: 🤖 Updated on each push. |
neuromechanist
merged commit Nov 7, 2026
3a86990
into
feature/issue-2021-epic-compute-users
29 of 31 checks passed
2 tasks
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase D1 of Epic D (#2021), closes #2022. A verified person with a proven ORCID iD can ask for compute access once, an administrator can grant, deny, suspend or revoke it from the CLI, a grant opens the owner's default allocation, and every path that ends the person's compute standing freezes their pools and live jobs through Epic A's release statements. Compute access is its own grant: nothing here reads or writes
service_access.What changed
0131_compute_access.sql(the issue said 0125; the owner moved it to 0131, and 0125 to 0129 stay unused):users.compute_access(none, requested, active, suspended, denied, revoked) plus requested, notified and granted stamps, the granter, the purpose (20 to 1000 characters), the terms version and time, and a partial index on open requests. Existing rows readnone. The ADR 0118 addendum says 0131.shared/compute-access-state.ts(states, edges,canTransition,canUseCompute),shared/contract/compute-terms.ts(COMPUTE_TERMS_VERSION = "2026-11-draft",COMPUTE_TERMS_PUBLISHED = false),shared/contract/compute-access.ts(request body, error codes, responses).POST /users/me/compute-access/request: 409already_activeandaccess_closed(also forsuspended), the already-requested short circuit that re-mails whilecompute_access_notified_atis NULL, then purpose, terms version, inbox, ORCID proof (anoauth_identitiesrow, not theorcid_verifiedflag; service and test kinds exempt), profile gaps; a conditionalUPDATE ... WHERE compute_access = 'none'decides who mails. In the exact production environment it is 503terms_unpublishedwhile the terms are unpublished.GET /admin/compute/accessandPOST /admin/compute/access/{grant|deny|suspend|revoke}/:usernameand/by-id/:id. Each decision is one batch (flip with from-states, audit only if the flip landed, the rest guarded on the state the flip leaves). A grant writes Epic A'sGRANT_INSERT_SQLper pool word from the policy'sdefaultGrantMilliunder the keycompute_access_grant:<id>:<pool>(a re-grant adds nothing; a zero default grants nothing and sayspolicy_default_zero) and unfreezes the pools. Suspend and revoke runendComputeStatements:computeReleaseStatementsplusoidcEndStatements(..., "compute_suspended", { scopePrefix: "compute." }), no network call in the batch.finalizeRevocationsets every compute state butnonetorevoked(anoneaccount staysnone: nothing was asked, nothing to close); the tombstone mask setsrevokedand erasescompute_purpose; the test-account sweep takes only accounts atnone. Role demotion and key revocation still end none of it.GapBlockgainscompute_access,GapFieldgainsaffiliation(blocks onlycompute_access),profileGapFields(account, block?)filters by block,checkUploadAccessRequestpassesupload_accessso itsmissinglist is unchanged.affiliationreachesprofileGapsForRowfrom every SELECT (/users/me,/auth/meviapublicUser, the web session, code verify, the profile PATCH echo).compute_access,compute_access_requested_atandcompute_access_granted_aton/users/meand/auth/me, optional and never defaulted; the notified stamp is on no wire.compute_requestscategory (default on) inEmailPreferences, the parse, the PUT schema andnemar admin email-preferences;sendComputeAccessRequestEmail(links to<APP_BASE_URL>/admin/compute) andsendComputeAccessDecisionEmail.nemar compute request-accessandnemar admin compute access list|grant|deny|suspend|revoke(all take--json),nemar auth profile set-affiliation,requestComputeAccessinsrc/lib/api/compute.ts,src/lib/api/compute-access-admin.ts, both pinned intest/api-export-surface.unit.test.ts.COMPUTE_END_CALLERSnow three,OIDC_END_CALLERSnow seven),implementation-notes.mdsection 3.Decisions and departures from the issue text
compute-source-scan.test.tsstill pins its one reader, andcompute-access-source-scan.test.tspins that none of these files reads it). Request, grant, deny, suspend and revoke are bookkeeping and work with compute off, tested with the switch unset,0and1.endComputeStatementsinservices/compute-access.ts, not inline in the routes, so the caller lists name one function. Both lists and their docblock counts are updated and the scans pass.account_not_in_good_standing, enforced in the flip's WHERE as well) unless the account is not deleted and isverifiedorapproved.backend/test/helpers/compute-app.tsalready existed from Epic A (it mounts the realadminRoutes, which now carries the new routes); it now also mounts the realuserRoutes.src/lib/api/compute.tsalso existed (Epic A's admin client), sorequestComputeAccessis added there.nemar auth profile set-affiliationis not in the issue. The newaffiliationgap would otherwise name a command that does not exist (the ADR 0040 failure), andPATCH /auth/profilealready takes the field./users/meand/auth/mefor every account without an affiliation. One existing test fixture that expected an empty gap list (cli-self-service-routes.test.ts) now seeds an affiliation. No website test was read as objecting; the escalation trigger did not fire.next_after), not by request time.suspendedanswers a new request with the codeaccess_closedand its own words (compute_access.suspended.body, "paused"), not the denied/revoked wording.USER_COLUMN_ROLES) classifies the state and terms version asflag(returned, not searched), the dates astext, the granter asrefand the purpose asomit; the admin user detail contract carries the state, dates, granter and terms version.For website#494 (phase E1) to transcribe
Copy keys added to
shared/contract/account-copy.ts(27 non-cli.keys are mirrored, plus onecli.key the website ignores):compute_access.section.title,compute_access.section.lede,compute_access.state.none,.requested,.active,.suspended,.denied,.revoked,compute_access.request.cta,compute_access.request.form_body,compute_access.request.purpose_label,compute_access.request.purpose_hint(written-out bounds 20-1000, pinned toCOMPUTE_PURPOSE_*_CHARSbyaccount-copy-parity.test.ts),compute_access.request.terms_label,compute_access.requested.title,.requested.lede,.requested.lede_dated,.requested.body,compute_access.granted.body,compute_access.closed.body,compute_access.suspended.body,compute_access.terms_unpublished.body,compute_access.docs_link,gap.blocks.compute_access,gap.blocks.noun.compute_access,gap.field.affiliation.label,gap.field.affiliation.set_on.web,gap.field.affiliation.set_on.cli; CLI-only:cli.compute_access.cta.Gap matrix changes in
shared/contract/profile-gaps.ts: new blockcompute_access(afterupload_access, beforepublication);email_verifiedblocks["verified","upload_access","compute_access"];given_nameandfamily_name["upload_access","compute_access","publication"];cityandcountry["upload_access","compute_access"]; new fieldaffiliation(aftercountry, beforewhy) with blocks["compute_access"], label "Affiliation", web "Settings", CLInemar auth profile set-affiliation, missing when blank;computeProfileGaps(account, block?)andprofileGapFields(account, block?)filter by block; the wireblockscarrycompute_access.test/profile-gaps-matrix.test.tsis extended (512 combinations, the block filter, the compute list). Wire:userSchemaandwebUserSchemagain optionalcompute_access,compute_access_requested_at,compute_access_granted_at. The admin page the request mail links to is/admin/computeand the person's/compute.test/account-copy-parity.test.tscompares against the website checkout; those keys are absent there until #494 lands, so that test fails where a website checkout is present (it skips otherwise). On the siblingstagingcheckout here it already fails before this change for 26oidc.*keys and 3upload_access.*bodies, so the 27 keys of this phase add to a drift that exists.Tests
Targeted only, run from this worktree on the final head; the full suite is the epic gate and was not run (not run, would check: full
bun testbecause it is the epic ->devgate).bun run lint,bun run typecheck(both tsc passes) andbun run migrations:d1-check(128 migrations through real D1, catalog matches bun:sqlite): clean.bun test test/<file>: profile-gaps-matrix 52, admin-route-inventory.unit 6 (256 admin handlers, was 247), api-export-surface.unit 14, help-tiers.unit 12, compute-access-cli 26, compute-access-state.unit 9, email-preferences 19, identifier-sweep-cli 3, contract-schemas 63, auth-gaps-cli 30; account-copy-parity 8 pass and 2 fail (the website drift above).backend/: compute-access-migration 13 (bun:sqlite and Miniflare D1), compute-access-request-route 33, compute-access-decision-routes 53, compute-access-cascade 16, compute-access-oidc 5, compute-access-source-scan 10, upload-access-request-route 30, profile-gaps-route 26, auth-me-payload-route 12, cli-self-service-routes 39, admin-user-search-route 66, compute-end-callers 15, oidc-cascade-callers 24, compute-release-cascade 20, admin-credential-cascade 13, test-account-sweep 72, test-account-sweep-d1 3, admin-revoke-route 10, compute-source-scan 4, mail-admin-routes 70, migrations 22, oidc-cascade-filters 17, oidc-cascade-d1 11, oidc-cascade-nonmembership 6, compute-pool-routes 39, compute-status-route 24, compute-policy-routes 21, compute-jobs-admin-routes 7. All pass.Mutations
Each applied to the production line, the named test file run, then restored (
git statusclean); a mutation that survived was fixed (two did, and the race tests incompute-access-decision-routes.test.tswere added).compute-access-migration.test.ts): widen the state CHECK with'granted'2 fail; purpose minimum 19 1; drop the terms-version GLOB 1; drop the partial index WHERE 1.compute-access-state.unit.test.ts):active -> requested2;revoked -> requested3;canUseComputeacceptssuspended1.compute_accessfrom city's blocks 7; affiliation never missing 4; drop the block argument incheckUploadAccessRequest23 (upload-access-request-route.test.ts); dropaffiliationfrom the/users/meSELECT 13 and null it in the web session SELECT 12 (profile-gaps-route.test.ts); change the purpose hint bounds in the copy 1 more fail (parity).orcid_verifiedinstead of the identity row 3; dropcompute_access = 'none'from the request UPDATE 1 (the concurrent test);COMPUTE_TERMS_PUBLISHED = true1; count the purpose in UTF-16 units 1; drop the notified stamp 3.nonereachactive1; drop the unfreeze 4; drop the state guard from the release and OIDC statements 1 (and 1 incompute-access-oidc.test.ts); drop the audit statement 4.compute-access-cascade.test.ts): omitendComputeStatementsfrom the route 4; omit the compute flip fromfinalizeRevocation5; alwaysrevokedthere 1; omit the compute columns from the tombstone mask 2; omit the release statements fromtombstoneUserCascade1. Sweep predicate dropped: 1 (test-account-sweep.test.ts). OIDC: omitoidcEndStatements4; use the whole-account ending instead of thecompute.filter 3.compute-access-cli.test.ts): drop the compute block override from the gap rendering 2; drop the client's compute arm ofprefersMessage2; stdout noise under--json1 (request) and 4 (admin). Other: dropcompute_accessfrompublicUser3 (auth-me-payload-route.test.ts);compute_requests === truein the parse 9 (email-preferences.test.ts); drop the route registration 2 (inventory); putservice_accessinto the request route orcomputeEnabledinto a decision 1 each (compute-access-source-scan.test.ts).Not done
COMPUTE_TERMS_VERSION, which this phase creates), balances and usage (Phase D2: Compute user API and read commands #2023), submission (Phase D3: User job submission and nemar compute submit #2024) and partner routes (Phase D4: Partner reservation and report contract #2025).admin/design/compute-gatewaypage in nemarOrg/docs (I did not read the gated page; the transitions here are the issue's, so it needs a check against section 4 when this merges).Review round (Sonnet review of this PR)
stale_state(tests: revoke racing grant on a suspended account in both orders, grant after deny, suspend racing revoke). The observed-state term is redundant for deny and suspend (their allowed list is one state), so only grant and revoke have a killable mutation.cookieOriginGuard(after the router'sauthMiddleware, before the body is read): a cookie with a foreign,nullor missing Origin is 403origin_not_allowed, a NEMAR Origin works, a bearer key is unaffected.purpose_required; the migration test records thatlength()stops at a NUL on bun:sqlite and Miniflare D1.admingranting their own account is 409self_decision(new word in the admin codes and status table; also enforced in the flip), anownermay; deny, suspend and revoke of oneself stay allowed.nemar auth profilelists Affiliation and Compute access under "Where to change each";nemar auth signup,signupandregistertake--affiliation, offered (a flag, or a terminal prompt that Enter skips) and never required, so a non-interactive signup is not failed by a gap that stops compute access only.canUseComputeas well aspool.frozen, also posted on Phase D3: User job submission and nemar compute submit #2024), the tombstone-versus-revocation difference, purpose retention, the at-most-one-duplicate admin mail, and, as an open product question, thatunlinkOrciddoes not end compute standing.nemar computebefore D3 exists: accepted within this epic.@example.orgfixture addresses come from Epic A's shared helper, not from files this PR added, so they were left.