Repository navigation
Phase 1: AI crawler tokens in robots.txt and a real-lastmod sitemap - #290
Conversation
Deploying nemar-website with
|
| Latest commit: |
3c8e7fe
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://337fa33d.nemar-website.pages.dev |
| Branch Preview URL: | https://feature-issue-285-phase1-rob.nemar-website.pages.dev |
|
Review addressed. All findings acted on; nothing carried forward. Moderate, the crawler-block contiguity test. Fixed in c383e51. The old assertion checked only that the last token was followed by Suggestion, the duplicated managed-id regex. Fixed in 852a400. Suggestion, Nice-to-have, no host gate on the sitemap route. Fixed in 3c8e7fe, gated on Nice-to-have, the ~10s worst-case timeout when a slow first page stacks on a slow parallel page. Accepted as-is, deliberately. The response is edge-cacheable and confirmed to pass Out-of-scope note acknowledged: the "never canonicalize to openneuro.org" requirement is a policy this PR does not touch, satisfied by Gates after the fixes: lint clean, typecheck 0 errors, 1549 tests green across 64 files (up from 1546, the three new host-parameterized cases), and |
8be4174
into
feature/issue-284-epic-agent-readiness
…lms.txt (#294) * Phase 1: AI crawler tokens in robots.txt and a real-lastmod sitemap (#290) * Allow AI crawlers in robots.txt * Add real-lastmod sitemap.xml route * Add tests and fixture for robots/sitemap * Move escapeXml to a neutral xml module * Assert the crawler block stays contiguous * Reuse isManagedDatasetId in the sitemap filter * Skip the sitemap on noindex hosts * Phase 2: server-rendered Use-this-data section and .md mirror (#291) * lib: export license helpers from jsonld * types: add zarr status fields to Dataset * lib: add use-this-data model and tests * add UseThisData section component * layout: add generic headLinks to Base * dataset: render Use this data section * dataset: add markdown mirror endpoint * fix: render Use this data outside unpublished ternary * fix: make page unpublished flag authoritative * fix: mark up commands and URLs, not sentences * Phase 6: nemar.org llms.txt and a footer link (#293) * Add /llms.txt endpoint with tests * Link llms.txt from the footer * Fix llms.txt license claim, was off by 10x * Give llms.txt search link a working q example * Require v prefix on llms.txt version placeholder * Un-link llms.txt dataset-page placeholder * Phase 3: Signposting Link headers and link elements (#292) * lib: add signposting link model and tests * dataset: emit Signposting Link header and tags * Rewrite Zarr recipe to be index-agnostic * Correct the download facts and add a cd step * Check value/note discipline in every section * Cite the published version, not the selected one * Number both references; soften sparse access * Escape interpolated text in the .md mirror * Validate ORCIDs and reject unsafe Link hrefs * Strip a trailing slash from the .md alternate * Split Applebot out and pin robots groups * Cache robots and llms.txt; noindex the mirror * Add route tests for the four new routes * Cite sources for the routing and ORCID notes
Summary
Adds a pure
src/lib/robots.tsbuilder that allow-lists twelve named AI crawler tokens (GPTBot, OAI-SearchBot, ChatGPT-User, ClaudeBot, Claude-SearchBot, Claude-User, PerplexityBot, Google-Extended, Applebot, Applebot-Extended, meta-externalagent, CCBot) on production hosts, sharing a singleAllow: /rule group, followed by the existingUser-agent: *allow and aSitemap:line.src/pages/robots.txt.tsis now a thin route over that builder. Non-production hosts keep the exact byte-identical disallow-all body they always served.Adds a pure
src/lib/sitemap.tswithsitemapLastmod(parses the catalog's space-separated UTC timestamp into a W3C datetime, returning null rather than guessing when it does not parse), an entry builder that keeps only active/public rows with a managednm*/on*id, a small fixed list of marketing routes with no lastmod, andbuildSitemapXmlwhich XML-escapes every value.Adds
src/pages/sitemap.xml.ts, an SSR route that pages the live catalog through the existinglistAllDatasetsclient, builds the XML on every request solastmodtracks each dataset's ownupdated_at, and responds withContent-Type: application/xml; charset=utf-8and apublic, max-age=300, s-maxage=3600, stale-while-revalidate=86400cache policy. A catalog fetch failure returns 503 withCache-Control: no-storeand a logged error, never an empty urlset.This is an SSR route rather than
@astrojs/sitemapby design: the plugin freezes every lastmod at build time, and both routes are API-driven with no new dependency added.Test plan
bun run lint-- clean, no findingsbun run typecheck-- 0 errors (242 files; pre-existing unrelated hints only)bun run test-- 1546/1546 passed, including 28 new robots.txt tests and 17 new sitemap testsNEMAR_SKIP_OG_GENERATE=1 bun run build-- completed; both OG-generation scripts already honorNEMAR_SKIP_OG_GENERATE=1(no change needed there)Test coverage includes: every AI crawler token present exactly once and in the prescribed order; the wildcard
Allow: /still present on production; the exact non-production disallow-all body string; the Sitemap line present on app.nemar.org/nemar.org/ww2.nemar.org and absent on test.nemar.org, a*.pages.devhost, and localhost; sitemap lastmod matching a row's ownupdated_at; exclusion of a private row, a non-active row, and ads-prefixed row; XML escaping of&/<; no output containingopenneuro.org; and a row with an unparseable timestamp yielding an entry with no<lastmod>.The sitemap test fixture (
test/fixtures/sitemap-catalog.json) is a real capture fromcurl -s "https://api.nemar.org/datasets?limit=5", following the precedent of the existingjsonld-catalog-*fixtures. All five captured rows are active/public managed datasets, so the private/non-active/ds-prefixed exclusion tests clone a real row and override only the field under test.Closes #285
Part of epic #284