Repository navigation
Phase 8: CLI and web parity for account tiers - #1270
neuromechanist merged 26 commits into
Conversation
Every user-facing sentence about tiers, upload access and missing profile fields moves into shared/contract/account-copy.ts, and the matrix behind them into shared/contract/profile-gaps.ts with the pure computeProfileGaps the backend will compute profile_gaps from. The website (nemarOrg/website#310) transcribes both files; the parity test reads its copy module as text and fails on any shared key that drifted, skipping with a note when no website checkout sits beside this one. The matrix test pins every field against a fixture copied from the website's table and walks all 2^7 combinations of the derivable fields. Sandbox training is deliberately outside the shared matrix: it exists in the terminal and nowhere else, so a mirrored row would be a claim about both surfaces that is false on one.
users.username_auto_assigned records that a handle was derived from the name rather than chosen, by the ADR 0042 backfill sweep or at a web sign-in. Onboarding and Settings offer to change it once, an offer that would be nonsense to someone who typed their own at CLI signup and that the users table had no other way to tell apart. Cleared, not sticky: PATCH /auth/profile sets it back to 0 on a real username change. DEFAULT 0 is honest for the back catalogue -- every existing row either typed its username or still holds NULL.
GET /users/me and GET /auth/me now carry profile_gaps and username_auto_assigned, and checkUploadAccessRequest builds its `missing` array from the same computeProfileGaps -- so a refusal, a status command and a dashboard nudge cannot name three different sets of fields. The route test asks all three about one row and compares. A web account that signs in with username NULL and a usable name is given the ADR 0042 suggestion, collision-suffixed: inside the sign-in transaction at /auth/code/verify, and chained behind the ORCID name refresh on the callback and finalize paths, where the name itself only arrives after the response. No name leaves the column NULL; nothing is invented from the email local part. The sweep stays the batch path and shares the claim statement, so both mark what they did. identity-conflict-still-usable replays the migrations after 0077 as well as before it: it stopped at 0077, so /users/me 500'd the moment it selected a column a later migration adds.
`nemar auth status` and `nemar auth profile` print a Profile block: one sentence per gap, from the shared copy table, with the exact command that fixes each. status reads the backend's list from the config cache so it still works offline, with the same three-state honesty the upload-access line has -- a refresh that was asked for and failed reports not-checked rather than presenting yesterday's list as today's. `nemar dataset upload` gains an upload-access preflight before anything expensive runs. A missing grant ends the run; --dry-run continues, since it uploads nothing; a grant that cannot be READ warns and continues, because the server enforces the gate regardless. Sandbox training stays the CLI-only gate, now stated in the same sentence shape. request-upload-access renders `missing` through those sentences too, so the refusal and the nudge read alike. The ad hoc UPLOAD_ACCESS_FIX table and the support-page hint are gone.
One matrix, one copy table, one gap function shared by /users/me, /auth/me and the upload-access preconditions; the website transcribes the copy module and derives identically. Records the sweep-versus-sign-in split for usernames, the one-time change the mark buys, and what stays CLI-only. AGENTS.md points at the two contract files as the parity source.
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1270Version: 🤖 Updated on each push. |
|
Review findings addressed, one commit per numbered item. All 16 are fixed; none was a false positive.
Verification from the worktree: The 50th is real, and it is not from these commits. The same test fails identically on the parent commit, so item 13 did not cause it; it is the first thing the newly-enforced check found. Landing the contract half here is a feature, not a review fix: it needs a new |
|
Closed the three residual review findings from this thread.
Verification: |
6bd0e75
into
feature/issue-1250-epic-account-tiers
Closes #1268
Part of #1250
Before this epic reaches
dev, the CLI and the web have to present one account model in one set of words. They did not: an upload-access request was refused by six hand-writtenblank()checks inservices/upload-access.ts,nemar auth statussaid nothing about the fields it named,request-upload-accessrendered them through a privateUPLOAD_ACCESS_FIXtable, and the dashboard derived a third list client-side. Three implementations of one rule, in two repositories, none of which failed when another changed — and the drift was already visible: the website said "Set it in Settings or runnemar auth profile set-github" where the CLI said "run 'nemar auth profile set-github '".What landed
One matrix, one copy table, one gap function (ADR 0045).
shared/contract/account-copy.ts— the 81 keys the website shipped in Profile gaps: what each missing field blocks website#310, string for string, plus 12cli.-prefixed keys the website has no surface for (sandbox, the terminal headings, the preflight). This contract is the source of truth; the website'ssrc/lib/account-copy.tsis its transcription.shared/contract/profile-gaps.ts— the matrix as data (blocks, where each field is set on each surface, whether it is derivable) plus the purecomputeProfileGaps, and the rendering both surfaces print through.GET /users/meandGET /auth/mereport its output asprofile_gaps;checkUploadAccessRequestbuilds itsmissingarray from it. They cannot disagree because there is one answer.Username assignment at web sign-in. The ADR 0042 sweep closes the 19 accounts that exist and nothing after them. An account signing in with
username IS NULLand a usable name now gets the same suggestion, collision-suffixed: inside the sign-in transaction at/auth/code/verify, and chained behind the ORCID name refresh on the callback and finalize paths, where the name only arrives after the response. No name leaves the column NULL and onboarding asks; nothing is invented from the email local part. Migration 0079 addsusername_auto_assigned, written by both paths and cleared when the person changes the username.The CLI says it out loud. A "Profile" block under
nemar auth statusandnemar auth profile; an upload-access preflight onnemar dataset uploadthat runs before validation and stops a run that cannot succeed;request-upload-accessrenderingmissingthrough the same sentences. Sandbox training stays the CLI-only gate.Two decisions taken from the website half and matched here: ORCID is not a gap (a CLI account cannot exist without one and a web account holds every tier without one — what an iD changes is where the NAME is set), and the
email_verifiedgap blocks["verified", "upload_access"]with a sentence that leads on activating the account.Files
shared/contract/{account-copy,profile-gaps,index,user}.tsservices/{profile-gaps,username-assignment,upload-access,email-verification,web-session}.ts,routes/{users,auth-web,auth-orcid,admin/user-usernames}.ts, migration0079lib/{account-gaps,config}.ts,lib/upload/preflight.ts,commands/{auth,dataset}.tsHow it was tested
Real tests only, no mocks. New:
test/profile-gaps-matrix.test.ts(every field pinned against a fixture transcribed from the website's table, and all 2^7 combinations of the derivable fields, withblocksandset_on),test/account-copy-parity.test.ts(reads the website's copy module as text and fails on any shared key that drifted; skips with a note when no checkout sits beside this one),backend/test/profile-gaps-route.test.ts(asks/users/me,/auth/meand the refusal about one row and compares),backend/test/username-auto-assign-route.test.ts(all three sign-in paths through real routes: assigned, collision-suffixed, no name, a name that folds to nothing, the audit row, and the flag cleared on a real change but not on a re-save),test/auth-gaps-cli.test.ts(auth status,auth profileand the upload preflight through the real CLI against a local server, asserting the sentences verbatim).Every new assertion was mutation-checked once — dropping the sandbox line, making the preflight never fail, printing a stale gap list after a failed refresh, narrowing a field's
blocks, droppingprofile_gapsfrom/users/me, droppingusername_auto_assigned = 1from the claim, dropping the flag clear from the PATCH, and cuttingmissingloose from the gap function each turn a test red.bun run lint,bun run typecheckandbun run migrations:d1-checkare clean.bun test: 5159 pass, 97 skip, 50 fail, and every failure is in a file this PR does not touch — the live-tier suites that needtest/.env.testcredentials this worktree has no copy of (test/api.test.ts35,test/cli.test.ts13,backend/test/publication-recorder.test.ts3, plus one each intest/iam-removal.test.ts,test/email-preferences.test.ts,test/e2e-upload.test.ts, the last confirmed pre-existing by re-running it with the new preflight disabled).One pre-existing fixture needed a fix:
backend/test/identity-conflict-still-usable.test.tsreplayed only the migrations up to 0077, so/users/me500'd the moment it selected a column a later migration adds. It now replays the ones after 0077 too, keeping the seed-then-flag split that is the point of the file.