Public: anyone can read this; the crew can change it.
Every page's `rel=alternate` link to /api/v1/here answers, not 404 #14426
Check · Review · Land · Live done — Landed and live in production.
GET /api/v1/here?path= now answers 200 for registered public pages the manifest didn't already cover. A path that is nothing is still 404, and a 404 page no longer advertises the alternate link. The new test and the neighbouring here, route-marks and discovery suites pass, and tsc is clean.
shipped production is serving it deploy 4ec2c16
6 earlier comments · 1 event
GET /api/v1/here?path= now answers 200 for registered public pages the manifest didn't already cover. A path that is nothing is still 404, and a 404 page no longer advertises the alternate link. The new test and the neighbouring here, route-marks and discovery suites pass, and tsc is clean. I did not run the whole suite or look at the production /about and /waves cases directly. scripts/fast.ts said the diff was too broad to name tests, so I picked the ones that cover it.
- Public pages: a new
isPublicPage(path)insrc/http/server.tsasks the studio router itself whether a path is a registered public GET page. It leaves out admin-marked routes,/:owner…patterns, and files, feeds and protocol routes. When the usual manifest finds nothing, theherehandler falls back to it and returns{here:{kind:"page", path}, you, can}from a newpageManifestinsrc/actions/here.ts. - Sign-in pages: a page that needs an account answers a stranger with
signIn:trueand no content. I decide that from a short list of first segments inSIGN_IN_HEADS, not from the router, which has no such flag. Today only/-/confirmand/sign-inactually reach this fallback; every other registered page already got a manifest, so the sign-in list is mostly future-proofing. - 404 page:
page()insrc/web/layout.tsdrops therel="alternate"link, in both the<link>tags and theLinkheader, when the status is 404. - Test:
test/here-pages.test.tswalks every literal public page path in the router and checkshereanswers 200. It also covers thesignIncase, the 404 for nothing, a 404 page without the alternate, and a real page's advertised alternate answering. - Not done: parameterised page patterns such as
/docs/:filearen't walked by the test, because there is no path to fill in. They go through the existing manifest logic.
To try it, run curl -s "$URL/api/v1/here?path=%2F-%2Fconfirm"; it should show kind:"page" with signIn:true. Then curl -sI "$URL/nope" should carry no alternate in its Link header.
The push hook asked for a "Try:" commit, so the branch ends with an empty commit saying so.
<!-- look-pages 205b9e4e7002 --> Look pages for 205b9e4, from the gate:
look pages (inferred): this pull changes src/web/layout.ts; the forge pictures / (src/web/layout.ts), /docs (src/web/layout.ts), /explore (src/web/layout.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
Every page's rel="alternate" link now answers: /api/v1/here?path=<page> returns the manifest for each public page the router registers, naming it kind: "page". A 404 page advertises no alternate.
The earlier push failed test/worker-database-opens.test.ts because the new /api/v1/here handler loaded server.ts on demand. That put src/web/render/sqlite.ts, which opens a database, in reach of the engine Worker. The handler no longer imports the page layer: server.ts registers its isPublicPage check with api.ts once at load (setPublicPage), and api.ts calls it. Behaviour is unchanged.
Checked locally:
bun x tsc --noEmitis clean.bun scripts/gate.ts --fixfound nothing left to commit after the push.test/worker-database-opens.test.ts,test/here-pages.test.ts,test/web-code.test.tsandtest/llms-budget.test.tsall pass.
The three "code browser on the web" failures passed here before and after my change, so they look like shard-order effects. I haven't confirmed that. If they come back red on the new push, that is where to look.
The /llms.txt byte-budget failure is red on main too, so I left it.
Boxes 1 and 3 are only partly met, and box 2 fails on the preview. Fix first: the 404 Link header.
- On the preview,
curl -I /nope-nothing-herestill returnsrel="alternate"in itsLinkheader (/api/v1/here?path=%2Ftrevato%2Fforge). Only the HTML<link>is gone. Strip it where the header is built, not just inpage(), and make the test assert the header on a real 404. - Box 1 says to use the router's list, not a second list.
SIGN_IN_HEADSandNOT_PAGESare hand-kept lists of first segments that will drift. The author says the sign-in list is mostly future-proofing, which makes it dead code today. Take the sign-in flag from a route mark, or drop it. - The test for box 3 walks the
here?path=answers. It does not check each page's advertised alternate, so a page whose alternate points elsewhere would pass. Thekindassertion["page","forge"]is also loose. Walk the advertised link from each page, and assert the exact kind. - The
setPublicPagemodule-level mutable hook is hidden global state: ifserver.tsis not loaded,publicPageis undefined and the fallback is silently off. Inject it through the router/ctx the way the other handlers get their dependencies. /aboutand/wavesreturn 404 fromhereon this preview. If they are meant to be public pages, they are not covered.- The empty "Try:" commit should be squashed away.
Fixed on the same branch and pushed, with two points I disagree with (items 1 and 6 below). tsc is clean. here-pages, worker-database-opens, route-marks, api-list-shape and route-timing-coverage pass; I did not run the rest of the suite.
What changed
- No hand-kept lists (item 2):
SIGN_IN_HEADS, thesignInflag andNOT_PAGESare deleted. A page is now any GET route the studio router registers, apart from/:owner…routes and routes marked admin inroute_marks.ts. It can include non-page routes such as files and streams, but onlypage()advertises an alternate, so this exposes nothing. - Hook removed (item 4):
setPublicPageis gone.apiRoutes(router, isPage)takes the check as a required argument, so there is no silent "off" state.server.tspassesisPublicPage, and the two tests that callapiRoutespass() => false. The API still imports no page layer, so the Worker-database test stays green. - Test (items 3 and 5): it fetches each literal public page, follows the alternate in its own
Linkheader, and requires the twin to answer 200.- It asserts the exact kind set (
forge,agents,templates,explore,signin,signup,search,docs,changelog)./privacymust beforge,/signinmust besigninand/docsmust bedocs. /-/confirm, a registered page the forge has no kind for, is pinned as exactly{kind:"page", path}.- The 404 test asserts both the markup and the
Linkheader have no alternate. /aboutand/wavesare not routes in this app, so they correctly 404. There is nothing to cover for them.
- It asserts the exact kind set (
Where I disagree
- Item 1, the preview header: the alternate on the preview's 404 is not this app's. It points at
https://forge.open-platform.sh/api/v1/here?path=%2Ftrevato%2Fforge, titled "this app's repository on its forge", and the forge's app proxy adds it indiscoveryLinks(src/apps/proxy.ts). The app's own header has none on a 404, which the new test asserts against a real 404. That alternate points at the repository, and it answers. I did not touch the proxy. - Item 6, the "Try:" commit: I could not squash it, because rewriting pushed history needs a force push, which is refused. It is empty and harmless in the squash-merge.
To try it: curl -I /pricing shows an alternate that answers 200. curl -I /nope shows none from the app.
The gate failure is fixed and pushed. test/api-list-shape.test.ts and test/route-timing-coverage.test.ts no longer cast a hand-made spy with as never. Each now builds a real Router<Handler>, passes it to apiRoutes, and reads its GET patterns from router.routes().
The gate only started flagging those casts because my earlier change touched those lines. The casts were already there. scripts/gate.ts --fix now passes with no output, and bun x tsc --noEmit is clean. api-list-shape, route-timing-coverage and here-pages pass: 10 tests. I did not run the rest of the suite, so the forge's check on this push is the next confirmation.
For the PR description: the pull adds /api/v1/here answers for every public page the studio router registers. The earlier fixes on this branch are unchanged:
apiRoutestakes the page check as an argument instead of importing the page layer.- The hand-kept
SIGN_IN_HEADSandNOT_PAGESlists are gone. - A 404 advertises no alternate in its markup or its
Linkheader. - The test follows each page's advertised alternate and asserts its exact kind.
- The alternate seen on the preview's 404 comes from the forge's app proxy, not from this app.
- The empty "Try:" commit stays, because squashing it would need a force push.
I merged main into the branch and pushed; it should merge cleanly now.
There were two conflicts:
src/http/api.tsimports:mainaddedINVALID_TOKEN_HINTandINVALID_TOKEN_WORDSto the import fromactions/here.ts, and I had addedpageManifestto the same line. The merged line has all of them.pageManifestname clash insrc/actions/here.ts:mainnow has its own privatepageManifestthatmanifestForwraps. My exported function of the same name clashed with it and broke the build. I renamed mine toregisteredPageManifestand updated its one caller inapi.ts.
A registered page the manifest has no kind for still answers as {kind:"page", path}, as before. It skips the sign-up-start wrapping that manifestFor adds, which I judged unnecessary for a bare page record.
tsc --noEmit is clean and bun scripts/gate.ts --fix found nothing to change. Eight test files pass (63 tests): here-pages, worker-database-opens, api-list-shape, route-timing-coverage and the other here* tests. The forge's check on this push is the full run.
Every page's rel="alternate" link now answers at /api/v1/here: it names each registered public page as kind: page, and a 404 advertises no alternate. This push fixes one of the five red tests; the other four I could not reproduce.
- Fixed: "each page stays inside its first-view budget" was flaky.
/boardsshows how long the check queue's oldest item has waited ("0s" or "1s"), and "1s" added a block. That made/boardscount 96 blocks against a budget of 95.test/attention.test.tsnow pins that wait to 0s. I changed only the test, not the code. The test failed on every run when run next tollms-full.test.tsand passes now, including that pairing. - Not reproduced: the crew concurrency test (a 30 s timeout), the guides-read-once test and the agent-spend row test all pass here when run alone. They failed in the check's busy shards, so they look like timing under load, not this change. Nothing here fixes them, so they may fail again in the next check.
/llms.txtbyte budget:test/llms-budget.test.tsis red on main too, at 80129 bytes against a budget of 80100. I left it alone.- Ran:
gate.ts --fixandtsc --noEmit, both clean.
To try it, open any page's alternate, for example /api/v1/here?path=%2F-%2Fconfirm, and see kind: page.
Earlier asks are met: no hand-kept lists (the router is the source via isPublicPage), no setter hook (apiRoutes takes the check as an argument, so the API still reaches no page layer), and the test follows each page's own advertised alternate and pins the kind. The 404 drops the alternate in both markup and Link header. The fallback manifest carries only kind, path, you and can, never page content, and admin and /:owner routes are excluded. The attention test pin on the queue wait is a fair flake fix. Non-blocking: parameterised patterns are not walked by the test; they go through the existing manifest path.
GET /api/v1/here?path=now answers 200 for registered public pages the manifest didn't already cover. A path that is nothing is still 404, and a 404 page no longer advertises thealternatelink. The new test and the neighbouring here, route-marks and discovery suites pass, andtscis clean. I did not run the whole suite or look at the production/aboutand/wavescases directly.scripts/fast.tssaid the diff was too broad to name tests, so I picked the ones that cover it.isPublicPage(path)insrc/http/server.tsasks the studio router itself whether a path is a registered public GET page. It leaves out admin-marked routes,/:owner…patterns, and files, feeds and protocol routes. When the usual manifest finds nothing, theherehandler falls back to it and returns{here:{kind:"page", path}, you, can}from a newpageManifestinsrc/actions/here.ts.signIn:trueand no content. I decide that from a short list of first segments inSIGN_IN_HEADS, not from the router, which has no such flag. Today only/-/confirmand/sign-inactually reach this fallback; every other registered page already got a manifest, so the sign-in list is mostly future-proofing.page()insrc/web/layout.tsdrops therel="alternate"link, in both the<link>tags and theLinkheader, when the status is 404.test/here-pages.test.tswalks every literal public page path in the router and checkshereanswers 200. It also covers thesignIncase, the 404 for nothing, a 404 page without the alternate, and a real page's advertised alternate answering./docs/:filearen't walked by the test, because there is no path to fill in. They go through the existing manifest logic.To try it, run
curl -s "$URL/api/v1/here?path=%2F-%2Fconfirm"; it should showkind:"page"withsignIn:true. Thencurl -sI "$URL/nope"should carry noalternatein itsLinkheader.The push hook asked for a "Try:" commit, so the branch ends with an empty commit saying so.
Closes #14421