Repository navigation
Closed
Labels
wayfinder:grillingWayfinder ticket: grilling
Description
Question
patchy login is decided at the product level; this locks the protocol and the token, with the RFC 8628 research in hand.
- Routes.
POST /api/login/deviceunauthenticated — the guard admits it as it admitted the mint, per-address limited — answering the device code, the user code, the verification URL (with and without the code), the interval and the expiry;POST /api/login/device/tokenpolled with the device code, answering pending, slow down, expired, denied, or the machine token once. The browser:GET /login/device?code=…behind the session shows the code, a name field on a first login, confirm and deny;POSTcompletes it. ➡️ That shape; names are the spec's. - The user code. Eight characters from a confusable-free alphabet in two groups, ten-minute expiry, five-second interval, the code shown for confirmation rather than typed. ➡️ That.
- Naming and re-login. The CLI keeps the machine token's id beside the token in
credentials.json; a re-login sends it, the new token inherits the name and the old is revoked in the same act. Consequences: "re-authenticating keeps the name" without a machine identity of its own. ➡️ That. - Expiry enforcement.
expires_atat 90 days andlast_used_atfor the 30 idle;last_used_atstamped at most once an hour so a publish stays one read; expired answers the same 401 as revoked. ➡️ That. - Identity on the wire.
/api/mebecomes the user (id, email, name), the company (id, handle, name), the role, and the machine (token id, name). Scopes go: the operator's bootstrap token is the one non-user credential and carries anoperatorscope, or is a distinct kind. ➡️ Drop scopes; oneoperatorflag on the bootstrap token. - Your machines. The page (list, revoke one, revoke all) plus
patchy logout; or apatchy machinescommand instead of the page. Consequences: revoking a lost laptop needs a browser. ➡️ The page andlogout; nomachinescommand yet. - CI.
PATCHY_API_TOKENandauth setstay for a token minted on Your machines; the operator path in the skill is rewritten around it. ➡️ That; thepatchy-mint-tokenskill is rewritten or deleted by the build. - Limits. Start per address per minute; poll per device code at the interval, with slow-down; a denied or expired code is gone.
From the prototype (#119, resolved 2026-09-03)
GET /login/device?code=… behind the session works as shaped in question 1: the code survives the door, the Account Portal and both handshakes, and the page can name the company and the person from the session's email and name claims. Two facts change the POST half:
- A POST is neither refresh- nor handshake-eligible in
@clerk/backend: Confirm pressed more than ~65 s after the page loaded arrives assigned-out, gets the door, and the door page's Sign in link has lost the code. ➡️ A signed-out POST answers 303 toGET /login/device?code=<code from the body>so the person re-enters through the door with the code intact. - The 401 for non-document clients (The login door on a tier 0 page #120 item 12) is where the CLI's own instruction belongs: what
patchyprints when a page refuses it, and whether/d/*ever accepts the machine token is Write the auth spec and file the build tickets #125's call.
From the door (The login door on a tier 0 page, resolved 2026-09-03)
- Item 10 is answered:
/d/*never accepts the machine token. A machine token builds and manages patches; reading a company patch is the user's signed-in browser. So the 401 carries noWWW-Authenticate, and whatpatchyprints when a page refuses it is "sign in in your browser; only public patches fetch by URL". The skill text is the spec's. - Sign-out is a POST on Your machines (question 6) that revokes the Clerk session and clears Clerk's cookies;
patchy logoutstays the CLI's own act on the machine token.
From company and user (Company and user: the minimum that ships, and where the company lives, resolved 2026-09-03)
- Question 5 confirmed from the company side:
/api/mecarries the user, the company (id, handle, name) and the role; no CLI company commands exist, so this is how an agent learns where its user is. - Deactivation revokes every machine token of the user in the same act, and the door refuses a deactivated user's session without a Clerk call; the bearer middleware refuses the same way, by the user row.
Metadata
Metadata
Assignees
Labels
wayfinder:grillingWayfinder ticket: grilling
Activity
allisonmahmood commentedon Sep 3, 2026
Grilling, round one (2026-09-03)
Decided, pending the two tickets below:
os.hostname(), sent with the start request) on a first one. Required, 1–64 characters. A re-login is the rename path; Your machines gets none.patchy login./api/meis a union of two kinds, not one shape with nullable fields:{ kind: "user", user: { id, email, name }, company: { id, handle, name }, role, machine: { id, name } }and{ kind: "operator", machine: { id, name } }. Themachinefield's id is the token's id; there is no machine entity, a machine is known only through its token.POST /api/tokensgoes (the bootstrap token comes from the environment);POST /api/tokens/:id/revokestays as the operator's last step in moderation.patchy whoamiprints user, company, role and machine, or "Operator".expires_atis a real column set at confirm (so item 9's 303 dance never eats a token's life),last_used_atstarts equal tocreated_atand is stamped at most hourly on a successful bearer lookup; Your machines lists live tokens only, dead rows stay for provenance and name inheritance.POST /api/login/deviceas it admits the mint; the poll is per device code withslow_down; the confirm page's lookup is limited per user; finisheddevice_loginsrows are deleted by the poll that reports them and never-polled rows go with the retention sweep.uploadwith no token (Q10): exit 1local, "Run: patchy login". It never starts a login. The first run is login then upload; one product line adjusts.XXXX-XXXX, 10 min, 5 s), the signed-out POST answering 303 to the GET with the code (item 9), expired answering the same 401 as revoked, item 10 as the door answered it.Still open, now blocking this ticket:
patchy loginblock (an agent's shell tool waits for exit, so a blocking login never gets its URL to the human) and Q2, what the URL carries: How agent-driven CLIs hand off a device login then patchy login end to end: the handoff, the confirm page, the token.patchy logoutwhen the instance is unreachable and Q7, where a CI token comes from once minting is gone: round two.allisonmahmood commentedon Sep 3, 2026
Grilling, round two (2026-09-03)
patchy logout(Q6): deletes the local credential first, then asks the instance to revoke the token as a courtesy. A 401 is success; unreachable is still exit 0 with a warning ("Logged out on this machine. The token could not be revoked; it expires on its own after 30 idle days, or revoke it now on Your machines"). ADR-0004 gains one line: a command whose local act succeeded reports a failed courtesy call as a warning, never as an exit code. The route is the bearer revoking itself, name to the spec.patchy login; Your machines is list, revoke one, revoke all, with no create. CI joins the map's Out of scope list beside the company-owned token, and thedocs/product.mdline "CI holds a token from the same page" moves to future tense with the spec.PATCHY_API_TOKENandauth setstay because the dev loop and the packed-CLI e2e run on the seeded token. Thepatchy-mint-tokenskill is deleted.Nothing else is open on this ticket but Q1 (does
patchy loginblock) and Q2 (what the URL carries), which resolve through How agent-driven CLIs hand off a device login and patchy login end to end: the handoff, the confirm page, the token. The session that closes this ticket after the prototype writes the resolution comment from these two rounds plus that answer.allisonmahmood commentedon Sep 3, 2026
From the research (How agent-driven CLIs hand off a device login, resolved 2026-09-04)
Q1 narrows to two shapes for the prototype: Stripe's (block for a human at a TTY; one JSON document and
patchy login --complete <code>under--json, non-TTY or a detected agent) or the always-two-step shape from round one. Either way one JSON document per run names the next command, the bare code prints beside the URL, and the device code persists in the state dir between runs. Q2's confirm-not-type has RFC 8628 §5.4 and Vercel, Wrangler and Heroku behind it; nothing in the survey argues for a bare verification page.allisonmahmood commentedon Sep 3, 2026
Resolution (2026-09-04)
Two grilling rounds (above) plus the research on How agent-driven CLIs hand off a device login and the prototype on patchy login end to end: the handoff, the confirm page, the token, which settled Q1 and Q2. Everything the spec needs on device login and the machine token, in one place:
Routes (1).
POST /api/login/deviceunauthenticated, admitted by the guard beside the mint, per-address limited like it; takes the CLI's hostname as a machine-name hint and, on a re-login, the stored key's id; answers the device code, the user code, the confirm URL with and without the code, the interval (5 s) and the expiry (10 min).POST /api/login/device/tokenpolled with the device code:pending/slow_down,completewith the machine token exactly once, or a 410 sayingexpired,deniedorunknown; the poll that reports a finished login deletes its row, never-polled rows go with the retention sweep. Browser:GET /login/device?code=…behind the session;POSTconfirms or denies.The user code (2). Eight characters from
BCDFGHJKLMNPQRSTVWXZasXXXX-XXXX, ten-minute expiry, five-second interval, shown for confirmation and never typed. The URL carries it (/login/device?code=XXXX-XXXX, the user code as the lookup key), and the CLI prints the bare code beside the URL (RFC 8628 §3.3.1). A bare/login/deviceexists only as a message page with no input.Does
patchy loginblock (Q1). Only for a human at a TTY: stdin a terminal, no--json, none of the agent environment variables set (Stripe's gate;isattyalone is wrong because an agent's shell tool has a TTY and still sees nothing before exit, measured on #131). Otherwise one JSON document on stdout and exit 0, namingnextandagentNextSteps;patchy loginagain while a live login is pending resumes it,patchy login --complete [code]is the explicit form, waiting up to--waitseconds (default 60) before answeringpending. Denied, expired and unknown are the server's answers and exit 2rejected; the CLI polls even when its own record has expired, so the server deletes the row. The pending login persists in the state dir.Naming and re-login (3, round one Q3/Q4). The name field is always on the confirm page, prefilled and editable: the old key's name on a re-login, the CLI's hostname on a first login; required, 1–64 characters. A re-login is the rename path. The CLI sends the stored key's id; confirm revokes it in the same transaction and the new token inherits the name; an expired or revoked old token still lends its name; an old token belonging to another user is ignored and the login is a first one, never an error. The confirm page is #131's variant A, copy and reverse states quoted there.
Expiry (4, round one Q8).
expires_atset at confirm to 90 days;last_used_atstarts equal tocreated_atand is stamped at most hourly on a successful bearer lookup, 30 idle days; expired answers the same 401 as revoked. Your machines lists live tokens only; dead rows stay for provenance and name inheritance.Identity on the wire (5).
/api/meis a union of two kinds:{ kind: "user", user: { id, email, name }, company: { id, handle, name }, role, machine: { id, name } }and{ kind: "operator", machine: { id, name } }. The machine's id is the token's id; there is no machine entity. Scopes go: the bootstrap token is the one non-user credential, with oneoperatorflag.POST /api/tokensgoes;POST /api/tokens/:id/revokestays as the operator's last step in moderation.patchy whoamiprints user, company, role and machine, orOperator.Your machines (6) and logout. The page (list, revoke one, revoke all, sign-out) plus
patchy logout; nopatchy machinescommand.logoutdeletes the local credential first, then asks the instance to revoke the token as a courtesy: a 401 is success, unreachable is exit 0 with a warning naming the 30-day idle expiry and Your machines; ADR-0004 gains the line that a command whose local act succeeded reports a failed courtesy call as a warning, never as an exit code. The route is the bearer revoking itself.CI (7). Not this slice: the only way to a machine token is
patchy login, Your machines has no create;PATCHY_API_TOKENandauth setstay for the dev loop and the packed-CLI e2e; thepatchy-mint-tokenskill is deleted;docs/product.md's CI line moves to future tense.Limits (8, round one Q9). Start per address per minute as the mint; the poll per device code with
slow_down; the confirm page's lookup limited per user; a denied or expired code is gone.Items 9 and 10. A signed-out POST answers 303 to
GET /login/device?code=<code from the body>; the door refreshes the session and the page returns with a "press Confirm again" notice (proven on #131)./d/*never accepts the machine token; the 401 for non-document clients carries noWWW-Authenticate, andpatchysays "sign in in your browser; only public patches fetch by URL" (from #120).uploadwith no token (round one Q10). Exit 1local,Run: patchy login; it never starts a login.allisonmahmood commentedon Sep 3, 2026
Resolved above: every question closed, Q1 and Q2 through #131.
allisonmahmood commentedon Sep 4, 2026
Addendum (2026-09-04, from Data model, packages and migration). Minting moves from confirm to the poll: confirm records the user, the machine name and the old key's id and sets the login
confirmed; the poll that finds that state mints the token, revokes the old key and deletes the row in one transaction, returning the plaintext from memory. Sodevice_loginshas no token column, no plaintext ever sits in a row, and an abandoned confirm mints nothing. The "confirm revokes it in the same transaction" line under Naming and re-login reads "the poll's transaction" from here on; everything else in the resolution stands. Stale rows are deleted on the next start, not by the retention sweep.allisonmahmood commentedon Sep 4, 2026
Addendum, 2026-09-04. The operator-as-token parts of this resolution (the
operatorkind of/api/me, thetok_operatorrow withuser_id NULLand theoperatorflag,PATCHY_OPERATOR_TOKENin the dev loop) are reopened on The operator is a company, not a token. Read that ticket's resolution over these lines; the rest of this resolution stands.allisonmahmood commentedon Sep 4, 2026
Addendum, 2026-09-04. Resolved on The operator is Patchy, not a token: the operator is Patchy with its own later login and dashboards, so every operator-as-token part of this resolution is gone — the
operatorkind of/api/me(one shape now),tok_operator, the nullableuser_idandoperatorflag (user_id NOT NULL),PATCHY_BOOTSTRAP_API_TOKENandPATCHY_OPERATOR_TOKEN, theadminscope, and the moderation and pin routes.revokestays only as the bearer revoking itself. The rest stands.