Skip to content

Latest commit

 

History

History
525 lines (433 loc) · 27.7 KB

discovery.md

File metadata and controls

525 lines (433 loc) · 27.7 KB

Search & AI discovery

This document explains how purview.dev is made discoverable — by search engines, AI search crawlers, and tooling that reads machine-readable content — and the one-time steps that remain manual.

Everything below is generated at build time from the site's existing sources of truth (the project catalogue, the aggregated documentation manifest and the release cache). There is no hand-maintained list of URLs.

Three layers, deliberately kept apart

Layer Examples Status
Established standards sitemap XML, robots.txt, canonical URLs, Schema.org JSON-LD, IndexNow Implemented as specified
Emerging convention llms.txt / llms-full.txt (root and per project) Useful, but not a search-engine protocol
Purview-specific discover.json, the internal deployment state Our own tooling, not an industry standard

What is generated, and where

Artifact Path Produced by
Sitemap index /sitemap-index.xml purview-discovery Astro integration
Child sitemaps /sitemaps/pages.xml, /sitemaps/projects.xml, /sitemaps/llms.xml integration
Crawler policy + Content Signals /robots.txt integration (lib/discovery/robots.ts)
Site map (JSON) /discover.json integration (lib/discovery/manifest.ts)
Root LLM content /llms.txt, /llms-small.txt, /llms-full.txt starlight-llms-txt
Per-project LLM content /projects/<slug>/llms.txt, /projects/<slug>/llms-full.txt integration (lib/discovery/project-llms.ts)
Per-version LLM content /projects/<slug>/<channel>/llms.txt, /projects/<slug>/<channel>/llms-full.txt integration (lib/discovery/project-llms.ts)
Per-page Markdown /docs/<slug>/…/index.md (a sibling of each documentation page) integration (lib/discovery/emit.ts)
API catalog /.well-known/api-catalog (RFC 9727 linkset) integration (lib/discovery/api-catalog.ts)
Agent registration /auth.md (Auth.md; states there is no login or registration) integration (lib/discovery/auth-md.ts)
A2A Agent Card /.well-known/agent-card.json (A2A; the read-only documentation surface) integration (lib/discovery/agent-card.ts)
OAuth authorization-server metadata /.well-known/oauth-authorization-server (RFC 8414; a no-auth stub) integration (lib/discovery/oauth.ts)
OAuth protected-resource metadata /.well-known/oauth-protected-resource (RFC 9728; a no-auth stub) integration (lib/discovery/oauth.ts)
ACP discovery /.well-known/acp.json (Agentic Commerce Protocol; a non-commerce stub) integration (lib/discovery/acp.ts)
Agent Skills index /.well-known/agent-skills/index.json (and each skill under /.well-known/agent-skills/<name>/) integration (lib/discovery/agent-skills.ts)
MCP Server Card /.well-known/mcp/server-card.json (SEP-1649) integration (lib/discovery/mcp-server-card.ts)
Read-only MCP server /mcp (JSON-RPC 2.0 over Streamable HTTP) edge Worker (worker/src/mcp.ts)
Web Bot Auth directory /.well-known/http-message-signatures-directory (a JWKS) integration (lib/discovery/web-bot-auth.ts)
WebMCP tools registered on page load (document.modelContext) site layout + Starlight (src/src/scripts/webmcp.ts)
IndexNow key file /<INDEXNOW_KEY>.txt (written from the secret) deploy workflow via bun run discovery:key
Internal deployment state src/.cache/discovery/state.json (never published) integration

The integration lives in src/config/discovery-integration.ts; the shared model is in src/src/lib/discovery/.

A project that publishes more than one documentation version (ADR 0009) gets one bundle pair per version. The default channel keeps the historical /projects/<slug>/llms*.txt paths; every other channel adds its id as a path segment, mirroring its /docs/<slug>/<channel>/ URLs. Each bundle names the version it documents and links the other versions' bundles, and no corpus contains two versions of the same page. discover.json exposes every version under docsChannels (schemaVersion 2).

Sitemap partitioning

  • pages.xml — hand-authored pages (/, /about/, /docs/, /projects/, /releases/, /use-cases/) and the generated browse hubs (/topics/, /topics/<topic>/, /categories/, /categories/<category>/, /packages/). See ADR 0015: the hubs are ordinary Astro pages derived from the catalogue's GitHub topics and category, so they enter the sitemap through the same model as every other page.
  • projects.xml — every project landing page (/projects/<id>/) and all of its aggregated documentation (/docs/<id>/…), derived from the catalogue and the docs manifest.
  • llms.xml — the machine-readable resources (root and per project).

Error pages (404, 500), non-canonical aliases and non-indexable pages are excluded.

Titles, canonicals and structured data

Being findable is not only about being crawled. ADR 0015 derives every <title> and meta description from the catalogue (src/src/lib/seo.ts, composed into the page by the Head override), publishes the browse hubs above, and keeps the page's own title as its visible H1 while the search-result title names the product. Every derived title is budgeted to the ~70 characters a result shows, with the folder trail and the word "documentation" dropped before anything that identifies the page. That is enforced against the built output by bun run check:seo (src/scripts/check-seo.ts), which is part of just validate: one <h1> per page, unique non-empty titles, self-referencing canonicals, a documentation title that names its project, and valid JSON-LD. Length guidance is reported as an advisory and never fails the build.

The one signal this repository cannot create for itself is an inbound link from another site: NuGet renders its project-URL and README links rel="nofollow", so the followed links come from each product repository's README and GitHub Website field. The consumer skills (purview-site-integration, purview-site-docs) require them, and purview-site-assessment reports when one is missing.

Meaningful lastmod

lastmod is never the build time. Each resource is dated from the source that produced it (src/src/lib/discovery/last-modified.ts):

  1. the last commit that touched the source file — one bulk git log per build, indexed in memory (a change to one project does not touch other pages);
  2. the project's latest release date, for project pages;
  3. the documentation page's own lastReviewed date, for docs pages;
  4. the release-cache retrievedAt as a coarse fallback when .git is absent.

The deploy workflow checks out full history (fetch-depth: 0) so (1) is accurate in CI.

Content Signals

robots.txt declares a Content Signals policy (draft-romm-aipref-contentsignals) so consumers never have to guess a default:

User-agent: *
Allow: /
Content-Signal: search=yes, ai-input=yes, ai-train=yes

Purview's policy is fully open — the three categories (search, ai-input, ai-train) are all yes — so the content may be indexed for search, used as input to AI models (RAG/grounding) and used to train models. This matches the crawler policy above (AI search crawlers are explicitly welcome) and the machine-readable documentation the site already publishes (llms.txt, the per-project llms*.txt bundles). The signal is emitted once, in the site-wide User-agent: * group. discovery:validate fails the build if the declaration is missing or omits any of the three categories.

To change the policy, edit src/src/lib/discovery/robots.ts — the generated file is never hand-edited.

Commands

bun run discovery:validate                     # validate the built artifacts in dist/
bun run discovery:validate --require-indexnow-key  # also require /<INDEXNOW_KEY>.txt
bun run discovery:manifest                     # regenerate artifacts in dist/ from current caches
bun run discovery:key                          # write /<INDEXNOW_KEY>.txt from the secret
bun run discovery:indexnow --dry-run           # show what would be submitted (no network, no key)
bun run discovery:indexnow --dry-run --verbose # include the URL lists

just equivalents: just discovery-validate, just discovery-manifest, just discovery-key, just discovery-indexnow --dry-run.

discovery:validate runs as part of just validate and bun run ci:build, and fails the build on: missing/malformed sitemaps, non-absolute or off-origin URLs, duplicate canonicals, a robots.txt that does not advertise the sitemap or declare a Content-Signal policy for search, ai-input and ai-train, a discover.json that references unknown projects, an API catalog that is missing or off-origin, missing per-project LLM resources, and development URLs in production output.

The IndexNow key file is a deploy-time artifact: the build never sees the key, so the build pipeline does not require it. The deploy workflow runs bun run discovery:key and then bun run discovery:validate --require-indexnow-key, which additionally fails when INDEXNOW_KEY is configured but the key file is missing, or when the file does not contain the configured key. Run bun run discovery:validate locally without the flag and a configured key is simply ignored.

IndexNow

IndexNow is the active post-deployment notification mechanism for Bing and other participating engines. It notifies the protocol-wide endpoint https://api.indexnow.org/indexnow — never a single engine.

  • Key. The key is a public verification value (8–128 chars of [A-Za-z0-9-]). It is supplied only by the GitHub repository secret INDEXNOW_KEY and is never part of the build. After the build, the deploy workflow runs bun run discovery:key, which writes the required verification file to https://purview.dev/<key>.txt from the secret. The build environment and build logs never see the key.
  • Changed URLs only. discovery:indexnow compares the previous deployment's discover.json with the new one and submits only added and modified URLs. Deletions are reported but not submitted (IndexNow has no delete semantics). The very first deployment submits everything, which is correct.
  • Dry run. --dry-run performs no network call and needs no key.
  • Safety. Every URL is checked against the configured canonical origin before submission, and the key is never logged.

How change detection works on GitHub Pages

The build job captures the currently deployed discover.json before building and re-publishes it as /_discovery/previous.json inside the new deployment. After a successful deploy, the indexnow job fetches that previous manifest and the new /discover.json, diffs them, and submits the changes. No cross-job artifact or persistent cache is required.

Failure semantics

The indexnow job runs only after the deploy job succeeds (needs: deploy), so a failed deployment never announces new URLs. A notification failure is reported by the indexnow job but does not roll back or invalidate the successful deployment: the site is live and correct either way. Retryable responses (HTTP 429/5xx) are retried with backoff before a batch is reported as failed.

One-time manual configuration

These steps are performed once by an operator; routine updates are automatic.

Google

  1. Register https://purview.dev/ as a Domain property in Google Search Console, preferably using DNS verification (the domain is controlled separately from the site).
  2. Submit https://purview.dev/sitemap-index.xml.

No Google Indexing API is used: it is not the mechanism for ordinary documentation pages. Google updates through crawlable links, canonical URLs, the sitemap and meaningful lastmod.

Bing

  1. Register/import purview.dev in Bing Webmaster Tools.
  2. Verify the sitemap: https://purview.dev/sitemap-index.xml.
  3. Set the INDEXNOW_KEY repository secret (see above). All routine updates are then automated via IndexNow.

Qwant

No routine submission is required. QwantBot is explicitly permitted in robots.txt and discovers content through the sitemap and crawlable links.

Startpage

No Purview-specific implementation. Startpage depends on upstream search indexes, so its visibility follows the Google/Bing strategy.

OpenAI / ChatGPT

OAI-SearchBot is explicitly permitted in robots.txt. HTML documentation and the LLM resources are reachable through ordinary links. There is no supported "LLM submission API", so none is invented; llms.txt is an additional representation, not a guarantee of indexing. The Content Signals policy is fully open (search, ai-input and ai-train are all yes), so AI systems may also use the content as model input and for training.

Markdown for Agents (content negotiation)

An agent can ask for any page in Markdown with Accept: text/markdown and get Content-Type: text/markdown; charset=utf-8 (with Vary: accept), while a browser keeps getting HTML. Two pieces make that work (ADR 0016):

  1. Per-page Markdown, built. Every aggregated documentation page is also published as <page-url>index.md (for example /docs/zodsharp/core-concepts/index.md) from the same mirror file the HTML is rendered from (lib/discovery/page-markdown.ts, emit.ts), and each docs page links it with <link rel="alternate" type="text/markdown">. The llms-full.txt bundles above remain the corpus view — the concatenation of a project's documentation, not one page.
  2. An edge Worker negotiates. The origin is GitHub Pages (a file host cannot vary a response by request header) and Cloudflare's managed Markdown for Agents is Pro/Business/Enterprise only, so neither can negotiate on the Free plan. worker/ is a dependency-free Cloudflare Worker on the purview.dev/* route: on Accept: text/markdown it serves the page's Markdown sibling (falling back to /llms-full.txt), and passes every other request straight through to the origin untouched. It reports a rough x-markdown-tokens count. It also sets the RFC 9727 media type on /.well-known/api-catalog (below), which a static host cannot set for an extension-less file.

The Worker is deployed as part of the main deployment (.github/workflows/deploy.yml, the worker job) from the CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID secrets; the deploy is skipped when they are unset, so the site and its CI work without it. Verify:

curl -sI -H "Accept: text/markdown" https://purview.dev/docs/zodsharp/core-concepts/
# expect `content-type: text/markdown; charset=utf-8` and `vary: accept`

If the zone ever moves to a paid plan, the managed Markdown for Agents feature can replace the Worker; the per-page Markdown siblings stay useful either way.

API catalog (RFC 9727)

/.well-known/api-catalog is an RFC 9727 linkset — a machine-readable index of the resources an origin publishes. Despite the name it is not limited to REST APIs: the Purview products are .NET libraries, not hosted services, so the catalogue indexes what this origin serves and can describe mechanically. lib/discovery/api-catalog.ts builds it from the catalogue:

  • one entry for the origin (https://purview.dev/): service-desc → /discover.json, service-doc → /docs/, describedby → /llms.txt, sitemap → /sitemap-index.xml;
  • one entry per documented product: service-desc → the product's llms-full.txt (its machine-readable documentation), service-doc → /docs/<id>/.

Every URL is on the canonical origin, and discovery:validate fails the build if the file is missing or points anywhere off-origin (ADR 0017). The document must be served as application/linkset+json, which a static host cannot set for an extension-less file — the edge Worker sets it.

.well-known/ is a dot-directory, and actions/upload-pages-artifact drops hidden files and directories by default. The deploy workflow therefore sets include-hidden-files: true (.github/workflows/deploy.yml); without it the catalog is built and validated in dist/ but never reaches GitHub Pages, so the Worker faithfully 404s the request.

Discovery Link headers (RFC 8288 / RFC 9727 §3)

The homepage response advertises the machine-readable surface above in HTTP Link headers, so an agent can discover it with HEAD / and without parsing a body:

Link: </.well-known/api-catalog>; rel="api-catalog"; type="application/linkset+json"
Link: </discover.json>; rel="service-desc"; type="application/json"
Link: </docs/>; rel="service-doc"; type="text/html"
Link: </llms.txt>; rel="describedby"; type="text/markdown"
Link: </sitemap-index.xml>; rel="sitemap"; type="application/xml"

A static file host cannot set a response header, so the edge Worker adds them (worker/src/links.ts, ADR 0018). Only IANA-registered relation types are used, the targets are root-relative, and they mirror the origin entry of the RFC 9727 catalog above, so the header and the catalog describe the same surface. The header rides on both the HTML homepage and its negotiated Markdown; every other path is passed through untouched. Verify:

curl -sI https://purview.dev/ | grep -i '^link:'

Agent registration (auth.md)

/auth.md is the Auth.md agent-registration document. purview.dev is a public static site with no login, so the document is deliberately self-contained: it names the agent audience and states that there is no registration or provisioning endpoint, no OAuth Protected Resource Metadata or authorization-server metadata, no agent_auth block and no credentials — the only supported method is anonymous. It also points agents at the machine-readable surface they can use without a credential (llms.txt, discover.json, the API catalog, per-page Markdown, the sitemaps).

It is generated (lib/discovery/auth-md.ts, ADR 0019), served as text/markdown by the edge Worker (a static host may type a .md file as text/plain), and discovery:validate fails the build when it is missing or its H1 does not name auth.md. Verify:

curl -s https://purview.dev/auth.md | head -n 1   # expect: # auth.md

Agent, OAuth and commerce discovery (ADR 0020)

Agent tooling also probes four further standard paths. purview.dev has no agent task server, no login and no commerce, so each document is generated to state that plainly — an explicit stub beats a 404 an agent cannot interpret (ADR 0020):

  • /.well-known/agent-card.json — an A2A Agent Card. supportedInterfaces points at the origin over HTTP+JSON, and a single skill describes the read-only documentation surface. It names no task endpoint.
  • /.well-known/oauth-authorization-server (RFC 8414) and /.well-known/oauth-protected-resource (RFC 9728) — OAuth discovery metadata for a site with nothing to protect. The protected-resource document names the origin as its own authorization server and points resource_documentation at /auth.md; the endpoints the authorization-server document lists (/oauth/authorize, /oauth/token, /.well-known/jwks.json) are reserved and serve nothing.
  • /.well-known/acp.json — an Agentic Commerce Protocol discovery document, shaped to the spec so the (absent) commerce surface is discoverable; it states that the origin sells nothing.

Every document carries a top-level _comment that says what it is: a public, no-credential origin with no task server and no commerce. This is the "explicit rather than implied" rule of /auth.md (ADR 0019) applied to the paths an agent probes. The .json paths are typed application/json by the host; the edge Worker sets that type on the two extension-less OAuth paths, which a static host would otherwise serve as application/octet-stream (ADR 0020). discovery:validate fails the build when any of the four is missing or malformed. Verify:

curl -s https://purview.dev/.well-known/agent-card.json
curl -s https://purview.dev/.well-known/oauth-protected-resource
curl -s https://purview.dev/.well-known/acp.json

Skills, MCP, WebMCP and Web Bot Auth (ADR 0021)

Four further surfaces an agent probes are generated the same way — and, where the origin can genuinely serve them, made real rather than stubbed:

  • /.well-known/agent-skills/index.json — the Agent Skills Discovery index (RFC v0.2.0). It lists every skill this origin publishes: the repository's own skills (purview-site-integration, …), copied by the build under /.well-known/agent-skills/<name>/, and the mirrored project skills at /skills/<id>/<name>/. Each entry carries a sha256: digest of the SKILL.md so a client can verify what it fetched.
  • /.well-known/mcp/server-card.json — an MCP Server Card (SEP-1649) for the read-only MCP server at /mcp (worker/src/mcp.ts). serverInfo, a streamable-http transport whose endpoint is https://purview.dev/mcp, and capabilities (tools and resources true, prompts false).
  • /mcp — a dependency-free, read-only MCP server (Streamable HTTP). It answers JSON-RPC initialize, tools/list, tools/call (search_projects, list_projects, get_project), resources/list, resources/read and prompts/list; it writes nothing and requires no credential. It is served by the edge Worker, so it is deployed only when the Cloudflare secrets are set.
  • /.well-known/http-message-signatures-directory — a Web Bot Auth JWKS. It publishes the origin's Ed25519 public key so a receiving site can verify the site's own outbound bot request. discovery:indexnow signs its request with Signature-Agent / Signature-Input / Signature; the private key is the WEB_BOT_AUTH_PRIVATE_JWK secret, generated with bun run web-bot-auth:key.
  • WebMCP — src/src/scripts/webmcp.ts registers read-only page tools (search-projects, list-projects, open-page) on document.modelContext (falling back to navigator.modelContext) on page load, under one AbortController. It is a no-op on a browser without the API.

discovery:validate fails the build when the index, the card or the JWKS directory is missing or malformed. Verify:

curl -s https://purview.dev/.well-known/agent-skills/index.json
curl -s https://purview.dev/.well-known/mcp/server-card.json
curl -s https://purview.dev/.well-known/http-message-signatures-directory
curl -s -X POST https://purview.dev/mcp -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

DNS for AI Discovery (DNS-AID)

DNS-AID publishes agent endpoints in DNS under the _agents namespace. The zone is controlled separately from this repository, so this is a one-time operator step — the build cannot create it. Publish SVCB (or HTTPS) records that name each endpoint with its alpn and port, and sign the zone with DNSSEC:

_index._agents.purview.dev. 3600 IN HTTPS 1 purview.dev. alpn="h2" port=443 mandatory=alpn,port
_a2a._agents.purview.dev.   3600 IN SVCB  1 purview.dev. alpn="a2a" port=443 mandatory=alpn,port
_mcp._agents.purview.dev.   3600 IN SVCB  1 purview.dev. alpn="mcp" port=443 mandatory=alpn,port

The scanner resolves these over DNS-over-HTTPS; a validating resolver must return authenticated data, so DNSSEC signing is required for the check to pass.

Local development

IndexNow never runs during normal local development: it requires an explicit production command, and --dry-run needs no key and makes no network call.

bun run build
bun run discovery:validate
bun run discovery:indexnow --dry-run

Operational checklist

Automated (nothing to do per deploy):

  • Sitemap index + child sitemaps generated
  • robots.txt generated, references the sitemap, and declares the Content-Signal policy
  • /.well-known/api-catalog generated (RFC 9727 linkset)
  • Root llms.txt / llms-full.txt generated
  • Per-project llms.txt / llms-full.txt generated
  • Per-version llms.txt / llms-full.txt generated for every published channel
  • discover.json generated
  • IndexNow key file written from the secret by the deploy workflow
  • IndexNow notifies changed URLs after a successful deploy
  • discovery:validate enforced in CI
  • check:seo enforced in CI (titles, canonicals, one H1, project-named docs titles, valid JSON-LD) — ADR 0015
  • Homepage discovery Link headers emitted by the edge Worker (RFC 8288 / RFC 9727 §3) — ADR 0018
  • /auth.md generated for a no-login site (Auth.md; states there is nothing to register) — ADR 0019
  • A2A Agent Card, OAuth and ACP discovery documents generated for a no-login, non-commerce site — ADR 0020
  • Agent Skills index, MCP Server Card and Web Bot Auth JWKS directory generated — ADR 0021
  • Read-only MCP server at /mcp (edge Worker) — ADR 0021
  • WebMCP page tools registered on page load — ADR 0021

One-time (operator):

  • Deploy the discovery implementation
  • Verify https://purview.dev/robots.txt
  • Verify https://purview.dev/sitemap-index.xml
  • Verify https://purview.dev/llms.txt
  • Verify https://purview.dev/llms-full.txt
  • Verify https://purview.dev/discover.json
  • Verify the IndexNow key endpoint https://purview.dev/<key>.txt
  • Register the Google Search Console Domain property (DNS verification)
  • Submit the sitemap to Google
  • Register/import the domain in Bing Webmaster Tools
  • Submit the sitemap to Bing
  • Set the INDEXNOW_KEY repository secret
  • Verify the first IndexNow deployment
  • Verify a representative project LLM resource (https://purview.dev/projects/zodsharp/llms.txt)
  • Verify a representative versioned LLM resource while a second channel is published (https://purview.dev/projects/zodsharp/prerelease/llms.txt)
  • Set CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID so the Markdown for Agents Worker deploys (ADR 0016)
  • Verify Accept: text/markdown negotiation on a live page
  • Verify https://purview.dev/.well-known/api-catalog returns application/linkset+json (the Worker sets the type; ADR 0017)
  • Verify the homepage Link headers (curl -sI https://purview.dev/; the Worker adds them; ADR 0018)
  • Verify /auth.md (curl -s https://purview.dev/auth.md | head -n 1; the Worker serves it as Markdown; ADR 0019)
  • Verify https://purview.dev/.well-known/agent-card.json and https://purview.dev/.well-known/acp.json (the host types them application/json)
  • Verify https://purview.dev/.well-known/oauth-protected-resource and https://purview.dev/.well-known/oauth-authorization-server return application/json (the Worker sets the type; ADR 0020)
  • Set WEB_BOT_AUTH_PRIVATE_JWK (from bun run web-bot-auth:key) so the IndexNow request is signed (ADR 0021)
  • Verify https://purview.dev/.well-known/agent-skills/index.json, https://purview.dev/.well-known/mcp/server-card.json and https://purview.dev/.well-known/http-message-signatures-directory
  • Verify the read-only MCP endpoint (curl -s -X POST https://purview.dev/mcp -H 'content-type: application/json' -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}')
  • Publish the DNS-AID _agents SVCB/HTTPS records and sign the zone with DNSSEC (ADR 0021)

Security

  • The IndexNow key is supplied only through the INDEXNOW_KEY secret and is written into the built site by the deploy workflow (bun run discovery:key), never by the build itself; it is never committed and never logged.
  • discovery:indexnow refuses to submit any URL outside the configured canonical origin.
  • The build's secret/local-path scan (check-generated) also covers the discovery artifacts.