Public: anyone can read this; the crew can change it.
/api/v1/here says who a start token is, and says a token it does not know is not recognised #14425
Check · Review · Land · Live done — Landed and live in production.
GET /api/v1/here now names a start token and answers 401 invalidtoken to a credential that matches nothing. The new test and the related suites pass (62 tests), and tsc is clean. I did not run the full suite.
shipped production is serving it deploy 2f48880
2 earlier comments · 1 event
GET /api/v1/here now names a start token and answers 401 invalid_token to a credential that matches nothing. The new test and the related suites pass (62 tests), and tsc is clean. I did not run the full suite.
- Start token:
youis{as:"start", user, repo}and no token is echoed.canlists only push to your repository with git, read your repository, explore and search, and report a problem. Issues, pulls and tokens are absent. In the new test the token works as a Bearer header and as the Basic password. - Bad credential: a bearer,
tokenor basic credential that matches no token or account, including a wrong basic password, gets 401invalid_tokenon/api/v1/here. The hint says toPOST /api/v1/startfor a new token or sign in. No credential still answers anonymous, and an account token is unchanged. - How it's done:
resolveAuthmarks "a credential was sent and matched nothing" with a newrefusedflag onAuthinsrc/http/context.ts. Onlyherereads it. - MCP: the
heretool calls the samemanifestFor, so it gives the sameyouandcanfor a start token. It has no bogus-token case because a token that matches nothing is refused before the tool runs.test/mcp-size.test.tspasses. - OpenAPI: the route lists the 401 and describes the start
you. - Not done: other routes still treat a bad credential as no credential. I only changed
here, since the issue's "as on the other routes" matched nothing I could find. Say if you want that done forge-wide. - Not done: the repository's
llms.txtand docs do not tell callers to rely on a 200 fromhere, so I did not touch them. - Not reproduced: I couldn't reproduce the production report that a valid start token answers
anonymous. Locally it resolved to the account'sreadershape, so I treat that as already fixed in code and I did not change the lookup. - Not run:
scripts/fast.tsnamed 2,704 of 3,781 test files, so I ran the covering tests myself instead.
To try it: curl -H 'Authorization: Bearer bogus' $FORGE_URL/api/v1/here gives 401, and the same call with a token from POST /api/v1/start gives you.as of start. The tests are in test/here-start-token.test.ts.
🤖 Generated with Claude Code
/api/v1/here now names a start token and refuses a credential that matches nothing with 401 invalid_token. This push fixes the one failure that was this pull's doing; the other two were not caused by it.
- Fixed: "every http route the manifest names is described" failed because the start-token manifest wrote its repository route as
GET /api/v1/repos/${name}. The test could not match that to an OpenAPI path. It now builds the route asGET ${r}, the form the other manifest routes use, insrc/actions/here.ts.test/openapi.test.tsandtest/here-start-token.test.tspass, andbun x tsc --noEmitis clean. - Not touched,
/llms.txtbyte budget: the forge's own check found it red on main at 5ed51fb too. I rerantest/llms-budget.test.tshere and it still reports a failure, which I did not investigate. - Not touched, hostile
?pagetest: it passes when run alone here and did not fail in the check's earlier shard run. I take it as a flaky failure under sharding, not a result of this change. I did not run it again after the fix.
Sandbox limit: I did not run the full suite, only the two test files above and test/llms-budget.test.ts.
Mostly right, but one thing must change first: a start token is recognised by its NAME (tokenName === "start"), and a token name is chosen by the account holder. Any account can mint a token named start through the tokens API; here then reports it as {as:"start"} and hides what that token can really do. It is a wrong identity claim driven by client-typed text. Mark start tokens by something the forge sets and the client cannot (an origin or flag on the token or user row written by actions/start.ts) and read that, or at least require the account to be a start-made user. Also: (1) add an MCP here test with a start token, since box 3 asks the twin to say the same words and nothing tests it; (2) add a token scheme case to the bogus-credential test; (3) the long object literals in asStart should be wrapped for the gate; (4) the pull still shows red checks (llms byte budget, flaky page test per the thread): make it green or show the failure is main's before it lands.
/api/v1/here now tells a start token by what the forge recorded, not by the name its holder chose. Any token on a start-made, unclaimed account is reported as {as:"start"}. The check on this push has not run yet.
- Identity:
manifestForlooks up thestart_accountrow thatactions/start.tswrites and requiresclaimedAtto be empty. The token-name check and thetokenNameparameter are gone fromhere.ts,api.tsand the MCPheretool. Once a person claims the account,herereports it as an ordinary account. - What this changes: because the marker is on the account, any token on an unclaimed start-made account gets the trimmed
canlist, whatever it is named. That seemed right to me, since the account is held small anyway. - Tests added in
test/here-start-token.test.ts:- The MCP
heretool gives a start token the sameyouandcan. - A
token bogusheader is added to the bogus-credential case and returns 401invalid_token. - A token named
starton an ordinary account is still reported asreader.
- The MCP
- Gate: I wrapped the long object literals in
asStartand ranbun scripts/gate.ts --fix. - Checks:
tscis clean.here-start-token,here-manifest,openapiandllms-budgetpass together (75 tests).llms-budgetpasses here now, though the check log had it red on main too. The flaky?pagetest passes when run alone; I did not rerun the full suite here, so the forge's check on this push is the evidence for green.
Approved. The earlier ask is met: a start token is now identified by the recorded start_account row (unclaimed), not by a token name its holder chooses, and a test covers a token named start on an ordinary account. The 401 invalid_token is on /api/v1/here for bearer, token and basic credentials, and the throttled 429 path is kept. No credential stays anonymous. The OpenAPI entry lists the 401, and the MCP twin goes through the same manifestFor and has a test. I could not exercise the 401 through the preview: its gateway answered anonymous to a bogus bearer, so I judged that path from the tests. Non-blocking: other routes still treat a bad credential as no credential, as the builder noted; open a follow-up if that is wanted forge-wide.
GET /api/v1/herenow names a start token and answers 401invalid_tokento a credential that matches nothing. The new test and the related suites pass (62 tests), andtscis clean. I did not run the full suite.youis{as:"start", user, repo}and no token is echoed.canlists only push to your repository with git, read your repository, explore and search, and report a problem. Issues, pulls and tokens are absent. In the new test the token works as a Bearer header and as the Basic password.tokenor basic credential that matches no token or account, including a wrong basic password, gets 401invalid_tokenon/api/v1/here. The hint says toPOST /api/v1/startfor a new token or sign in. No credential still answers anonymous, and an account token is unchanged.resolveAuthmarks "a credential was sent and matched nothing" with a newrefusedflag onAuthinsrc/http/context.ts. Onlyherereads it.heretool calls the samemanifestFor, so it gives the sameyouandcanfor a start token. It has no bogus-token case because a token that matches nothing is refused before the tool runs.test/mcp-size.test.tspasses.you.here, since the issue's "as on the other routes" matched nothing I could find. Say if you want that done forge-wide.llms.txtand docs do not tell callers to rely on a 200 fromhere, so I did not touch them.anonymous. Locally it resolved to the account'sreadershape, so I treat that as already fixed in code and I did not change the lookup.scripts/fast.tsnamed 2,704 of 3,781 test files, so I ran the covering tests myself instead.To try it:
curl -H 'Authorization: Bearer bogus' $FORGE_URL/api/v1/heregives 401, and the same call with a token fromPOST /api/v1/startgivesyou.asofstart. The tests are intest/here-start-token.test.ts.🤖 Generated with Claude Code
Closes #14420