Skip to content

docs(embedding): document the head metadata a host writes per atlas route - #207

Merged
Ardnived merged 5 commits into
mainfrom
claude/docs-173-embed-head-metadata
Sep 14, 2026
Merged

Ardnived merged 5 commits into
mainfrom
claude/docs-173-embed-head-metadata

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • docs/embedding.md gains Metadata for your page's <head> — the rule that a page's metadata describes the atlas route the widget mounted with, and the endpoint that supplies it.
  • Three worked examples pasted from live responses: a region route, the root, and a bare view route, with the origin elided as …. Caching, the canonical, the null description, the accepted locale codes, and the 400/404 split each get a rule.
  • Nothing under src/ changes. CHANGELOG.md carries the host-visible entry.

Changes

  • docs/embedding.md — new ## section between The URL and Content-Security-Policy, plus a Contents entry and a "what do you want" row.
  • CHANGELOG.md — ### Added entry under ## [Unreleased].

Contract impact

This is the host-facing contract. GET /api/atlas/seo shipped in sydevs/SahajCloud#769 (closing sydevs/SahajCloud#739); this documents it for the sites that embed us.

Review round (2026-09-14)

Three threads from the adversarial review, all adopted, one commit each:

  • 680bc3e — locale is refined against nineteen exact codes (isValidLocale, SahajCloud src/lib/locales/index.ts:14-33) and parseQuery answers 400 on a miss. "Send the language your page declares in <html lang>" therefore broke any host declaring en-GB, en-US or pt, and the refusal table blamed route for that 400. The doc now names the set, gives the mapping rule, and names locale in the 400 row.
  • 151d201 — the eight printed wemeditate-web.contact-c66.workers.dev occurrences are elided to …/map…, matching the abridgement alternates and breadcrumbs already use. They contradicted line 495's wemeditate.com/map and are the subject of feat(pages): place pages in each service by its configuration SahajCloud#783, so printing them would have baked a possibly-transient host into a permanent contract.
  • 2771557 — Free Meditation Classes is ROOT_TITLE_FALLBACK (rootStrings.ts:48), reached only because no operator root copy exists in any locale. A ⚠ under the root example says so, rather than letting the example read as the root's settled title.

Test results

  • Lean gate: ✓ lint + typecheck + test:run — 1467 tests in 115 files, 46s (re-run after the three commits above).
  • Targeted specs: none. Prose-only diff, no code under test.
  • Build: N/A locally; CI runs it.

Manual verification

  1. Read the new section end to end — it is 200 lines of prose and the gate cannot judge it.
  2. Check the Contents anchor resolves: #metadata-for-your-pages-head.
  3. Confirm the elided …/map… examples still read as real responses rather than invented ones. See Notes for reviewer.

Preview

Docs-only — no rendered change to preview.

Notes for reviewer

⚠ The live endpoint returns a workers.dev canonical; the examples no longer print it. Every call against production came back with https://wemeditate-web.contact-c66.workers.dev/map… as canonical, for the root and for /gb/london alike. It reaches every canonical and webUrl SahajCloud publishes for a region no client owns, not just this endpoint. Filed as sydevs/SahajCloud#783 — it needs someone who can read Railway's env to say whether it is a misconfiguration or a deliberate mid-migration state, so that ticket asks the question before it asserts the fix. The examples now elide that origin to …, and a line says what the ellipsis stands for. If you would rather the real host appear, say so and I will restore it.

⚠ The German root title is the English constant today, not Kostenlose Meditationskurse as the ticket expected: ?route=/&locale=de returns "title": "Free Meditation Classes". So common.chrome.widget_label is empty in German too, not only seo.root_title. The doc states the fallback chain, which is true either way, and now says the example title is the built-in constant — but sydevs/SahajCloud#778 may be wider than it looks.

README.md line 23 summarises what the integrator guide covers and does not mention the new section. Left alone deliberately — the ticket pins the diff to two files, and the README merely points at the guide. (Separately, that same sentence says "all six script-URL parameters" while the guide says five. Pre-existing.)

Detail

Every claim was checked against the shipped code, then against a live call. The SahajCloud checkout at 0a65797 supplied atlasRoute.ts, rootStrings.ts, seoDocument.ts, index.ts and jsonLd.ts; the live endpoint supplied the responses. Both agreed, with the two exceptions above.

Verified live, with a published client key:

Call Result
?route=/&locale=en 200, "type":"root", "id":null, "route":"/"
?route=/search&locale=en 200, byte-identical to the root
?route=/events/areas 200, the root — every segment reserved
?route=/gb/london&locale=en 200, "route":"/gb/south-east/london" — normalized
?route= 400
?route=/gb/london?x=1 404 That is not a valid atlas route.
?route=/no-such-city 404 That route does not name a region or an event.
response headers Cache-Control: public, max-age=300, s-maxage=300, Vary: Authorization

Two facts the ticket did not carry, added from the source:

  • route comes back normalized — /gb/london answers /gb/south-east/london. A host comparing its own URL against the returned route needs to know. Called out with a ⚠ under the region example.
  • A server-to-server call sends no Origin or Referer, and the allowed-domains gate permits exactly that (assertClientOriginAllowed, src/plugins/usage/hooks.ts:288-290). Without this line, "fetch it from your server" reads like advice that will hit a 403.

Two claims tightened in the second commit, after re-reading the source: jsonLd's escaping now names what is escaped (<, >, &, U+2028/2029), and canonical is documented as nullable for a region or event, which the first draft implied always resolved.

The 400 envelope differs from the two 404s. A schema refusal returns zod issues (parseQuery, Response.json({ errors: parsed.error.issues }, { status: 400 })), not the { errors: [{ message }] } envelope the 404s use. The refusal table describes what the 400 means rather than quoting a sentence, for that reason.

Skipped, with reasons. /simplify and the six review lenses read code; this diff is prose in two files and contains none. In their place: the fact-check above, re-run against the source. The security review is skipped by the gate — securityReview.triggerPattern matches no path in the diff, and contentPattern scans src, which is untouched.

Prettier was not run. Both files already fail prettier --check on origin/main, so markdown is not gate-enforced here; formatting them would have buried the content in a whole-file reflow.

Closes #173

🤖 Written by the sydevs autonomous loop — see what this is

…oute

`docs/embedding.md` is the host-facing contract, and it never said what a host
should put in its `<head>`. Every region and class page under an embed was
described correctly by the sites that bothered; the entry point was not. #62 on
WeMeditateWeb mounts `/map` with `atlas=/` and presents to a crawler as a
duplicate of the site's homepage, because the page inherits the global title and
description and emits no canonical.

The rule is finally writable: sydevs/SahajCloud#769 made `GET /api/atlas/seo`
answer **every** route the widget can mount with, the atlas root included. So
the new section states the rule — a page's metadata describes the atlas route
the widget mounted with — and names the endpoint that supplies it.

What it covers, each verified against the shipped code and a live call:

- Three worked examples, pasted from real responses: a region route, the root,
  and a bare view route. The region example also shows that `route` comes back
  normalized (`/gb/london` answers `/gb/south-east/london`), which a host
  comparing its canonical needs to know.
- Which routes answer as the root, as a RULE rather than a list of five: eleven
  reserved segments are dropped wherever they appear, so `/events/areas`
  reduces to the root too.
- Fetch server-side at render time, and cache for up to 300s per route and
  locale. `Vary: Authorization` splits that cache per SITE, not per visitor,
  because the credential is the host's own published client key — the header
  otherwise reads as "do not cache". A server-to-server call also sends no
  Origin, which the allowed-domains gate deliberately permits.
- `canonical` for the root is the caller's own verified mount page, and so is
  per-API-key; a caller publishing none gets the We Meditate surface.
- `description` is `null` in a locale with no operator copy, stated as a rule
  rather than as today's snapshot — sydevs/SahajCloud#778 fills that copy and
  would make a snapshot sentence false the day it merges. The host writes its
  own line and a self-referencing canonical.
- The 400 and the two 404s, which say different things on purpose.
- That the CSP table does not change, and why: the host's server makes the
  request, and `cloud.sydevelopers.com` is already in `connect-src`.

`CHANGELOG.md` carries the host-visible entry, per the rule that it and
`docs/embedding.md` move together. Nothing under `src/` changes.

Closes #173.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`jsonLd`'s escaping names what is actually escaped — `<`, `>`, `&` and the two
Unicode line separators (`jsonLdEscape` in SahajCloud's `seo/jsonLd.ts`) — so a
host reading "already escaped" knows what re-stringifying would lose.

`canonical` can be `null` for a region or an event, where no site publishes one
(`seo/index.ts` reads `region.webUrl ?? null`). The section said it resolves,
full stop. It now says what a `null` means and what to write instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2771557
Status: ✅  Deploy successful!
Preview URL: https://519b5c2b.sahajatlas.pages.dev
Branch Preview URL: https://claude-docs-173-embed-head-m.sahajatlas.pages.dev

View logs

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 14, 2026
@sydevs-bot

sydevs-bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 17:10Z address-review · attempt 1 · session · done
  • 17:10Z address-review · attempt 1 · session
  • 17:03Z adversarial-review · attempt 1 · session · done
  • 17:03Z adversarial-review · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The diff is the two files the ticket pins, and every subsection maps to an acceptance criterion. Nothing extra.

One shape, two findings: all three examples came from a key owning no canonical and a database with no root copy, so their headline values are fallbacks — the "snapshot, not rule" trap the ticket flagged for description. Separately, the locale row advises a call that 400s.

Findings

  • blocker — :559 "send your <html lang>" 400s for en-GB, en-US or pt. The refusal table omits it.
  • should-fix — :583 the workers.dev host, printed 8 times, contradicts line 495.
  • consider — :616 the example root title is the fallback constant.

Checked against SahajCloud 0a65797: atlasRoute.ts (11 segments, case-insensitive, [?#\s] and the 12-cap → 404), index.ts (schema, both 404 strings, headers), rootStrings.ts, jsonLd.ts, seoDocument.ts (locale-free canonical), locales/index.ts (19 exact codes), usage/hooks.ts:288 (no Origin → allowed). Here: path.ts:238-250 has the same 11.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread docs/embedding.md Resolved
Comment thread docs/embedding.md Resolved
Comment thread docs/embedding.md Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 14, 2026
`locale` is refined with `isValidLocale` against nineteen exact codes
(SahajCloud `src/lib/locales/index.ts:14-33`), and `parseQuery` answers
400 on a miss. "Send the language your page declares in `<html lang>`"
therefore breaks any host declaring `en-GB`, `en-US` or `pt`, and the
refusal table blamed `route` for the 400 it got.

Names the set, gives the mapping rule, and adds `locale` to the 400 row.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FKvtzMtoVcN1VjWqbdHZaA
The examples printed `wemeditate-web.contact-c66.workers.dev` eight
times, while the compact-card section names `wemeditate.com/map` as the
same fallback surface — two answers to one question. sydevs/SahajCloud#783
asks whether that host is a misconfiguration at all, so baking it into
the host-facing contract risks documenting a transient state.

`…/map…` matches how `alternates` and `breadcrumbs` already abridge, so
the responses stay pasted rather than hand-written, and a new paragraph
says what the ellipsis stands for.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FKvtzMtoVcN1VjWqbdHZaA
`Free Meditation Classes` is `ROOT_TITLE_FALLBACK` (SahajCloud
`src/endpoints/atlas/seo/rootStrings.ts:48`), the bottom of the chain,
reached only because no operator root copy exists in any locale yet —
`locale=de` returns the same English string. Printed bare, the example
read as the root's real title and would date the day the copy lands.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FKvtzMtoVcN1VjWqbdHZaA
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Three review threads adopted, one commit each. Pushed to claude/docs-173-embed-head-metadata.

  • Locale codes — 680bc3e. The doc names the nineteen accepted codes, says an unknown one is a 400, and tells a host to map en-GB down to en. The refusal table's 400 row names locale too.
  • Canonical host — 151d201. All eight workers.dev occurrences elide to …/map…, with a line saying what the ellipsis stands for.
  • Root title — 2771557. A ⚠ names ROOT_TITLE_FALLBACK and says no operator root copy exists in any locale yet.

Nothing rebutted, nothing asked. Lean gate green — 1467 tests in 115 files. PR body refreshed with the round.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 14, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review September 14, 2026 17:18
@sydevs-bot
sydevs-bot requested a review from Ardnived September 14, 2026 17:18
@Ardnived
Ardnived merged commit 2c26075 into main Sep 14, 2026
38 of 41 checks passed
@Ardnived
Ardnived deleted the claude/docs-173-embed-head-metadata branch September 14, 2026 17:18
@sydevs-bot sydevs-bot moved this from Revising to Done in SYDevelopers Technical Roadmap Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

docs(embedding): document the head metadata a host writes per atlas route

3 participants