Skip to content

feat(seo): prevent direct indexing of the standalone build - #124

Merged
Ardnived merged 6 commits into
mainfrom
feat/noindex-standalone
Aug 8, 2026
Merged

Ardnived merged 6 commits into
mainfrom
feat/noindex-standalone

Conversation

@Ardnived

@Ardnived Ardnived commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • sahajatlas.* now resists direct indexing. Search is owned by WeMeditate and the other embedding sites, and every canonical this build emits already points at SahajCloud's webUrl — so a sahajatlas URL in a result page is a duplicate of somebody else's page.
  • Three signals, none of which can reach a host page: public/robots.txt (Disallow: /), an X-Robots-Tag: noindex rule in public/_headers, and a static <meta name="robots" content="noindex"> in index.html.
  • JSON-LD, OG tags and the webUrl canonicals are unchanged. No src/ behaviour changed at all — the only src/ edit is a comment in mode.ts.

Changes

  • public/robots.txt (new) — User-agent: * / Disallow: /, plus one allow-group of 14 link-preview scraper tokens. This file is where the whole indexing policy is written down; the other two carry only their own "why this layer exists".
  • public/_headers — appends a /* rule; the /assets/* and /locales/* CORS rules from fix(ui): scope widget css so it cannot restyle the host page #91 are untouched. Cloudflare applies every matching rule, so a broad rule doesn't displace a specific one — and the smoke lane now pins that rather than trusting the doc quote.
  • index.html — the static meta. Chosen over App.tsx's standalone <Helmet> block: index.html is the standalone shell, so it is embed-gated by construction rather than by a runtime flag, and it is the layer that survives pnpm preview, a mirror, or a move off Pages (_headers is a Pages-only construct).
  • tests/smoke/robots.smoke.test.ts (new), src/config/mode.ts (comment), CLAUDE.md + .claude/rules/tests.md (docs).

Why all three, and the interaction

Disallow means "do not fetch", not "do not index" — so a compliant crawler that never fetches a page never sees the noindex on it. The two do not stack; the weaker signal hides the stronger. Residual risk, accepted deliberately per the ticket: a URL linked from an external page can still be listed URL-only, with no title or snippet. The runbook is in robots.txt — if we are ever found indexed, relax that file rather than tightening it, so the crawler can fetch, read the noindex and drop the entry.

⚠️ Live finding: /robots.txt currently returns 200 text/html on BOTH projects

Measured against the deployed sites before this merges:

https://sahajatlas.pages.dev/robots.txt         → 200  content-type: text/html
https://sahajatlas-design.pages.dev/robots.txt  → 200  content-type: text/html

Neither has a robots.txt; _redirects (/* /index.html 200) answers for it with the SPA shell. This is worth flagging beyond this ticket:

  1. It is not "no robots.txt" — it is an affirmative allow-everything one. Per RFC 9309 a 2xx is parsed as robots.txt; an HTML body yields zero valid rules, and no rules means allowed. The crawler gets a confident 200, parses nothing, proceeds, and never retries.
  2. Any check asserting a 200 on that path passes today against nothing. This is precisely the "status is not a result" trap .claude/rules/tests.md documents — in the wild, on our own infrastructure. Hence the new smoke spec asserts content-type: text/plain and the body, never the status. The same trap covers any path here: a missing asset, a renamed chunk, a deleted locale file all return 200 text/html.
  3. It generalises. Anything added to public/ later and verified by status code — sitemap.xml, .well-known/*, security.txt — will look fine while being absent.

Does this cover the Ladle playground? Yes — two of the three signals

Decision: sahajatlas-design.pages.dev should resist indexing on the same reasoning — a component playground is no more a search surface than the app is, and indexing it surfaces decontextualised UI fragments. It needed no extra work: pnpm ladle:build copies the same public/ into build/, verified in the worktree (build/robots.txt + build/_headers present, byte-identical).

Project robots.txt X-Robots-Tag <meta robots> Verified how
sahajatlas (app) ✅ ✅ ✅ Observed on the live PR preview; 5 smoke tests green in CI
sahajatlas-design ✅ ✅ ❌ n/a Inferred from the local ladle:build output

Ladle generates its own index.html, so the <meta> never reaches the playground — which is an independent reason the header layer earns its place, since otherwise the playground would have only robots.txt.

Honest residual gap: the playground's coverage is inferred from the build output, not observed on a deployed preview. The design Pages project exposes only a dashboard link in CI, and the smoke lane targets CF_PROJECT=sahajatlas.pages.dev only — so nothing automated will catch a regression there. One-line check after merge:

curl -sSI https://sahajatlas-design.pages.dev/robots.txt | grep -iE 'content-type|x-robots-tag'
# want: content-type: text/plain  AND  x-robots-tag: noindex
# text/html means the file did not ship and the playground is still open

Extending the smoke lane to the design project is the durable fix — a reasonable follow-up, not scope here.

Does noindex break OG unfurls? Verified — no. But the AC as written cannot pass.

  • noindex vs previews — no conflict. No preview scraper implements indexing directives.
  • Disallow: / vs previews — a real hazard, mitigated. facebookexternalhit, Twitterbot, LinkedInBot and redditbot all consult robots.txt; a blanket Disallow would have blocked them. Hence the allow-group. It matters because ShareView.tsx:44 hands the share sheet event.webUrl ?? window.location.href — an unpublished or gated event is shared as a sahajatlas URL.

/code-review then found the AC "a share-link unfurl still renders title/description/image" cannot pass on this deployment, before or after this PR. The build is client-rendered with no prerender, so every og:* tag and the JSON-LD are injected by react-helmet-async at runtime, and none of these bots executes JS. dist/index.html contains zero og: tags — the served HTML carries <title>Sahaj Atlas</title> and nothing else. So the allow-group buys a generic-titled card instead of a bare link, not a rich per-event unfurl. Rich unfurls come from the webUrl canonical on WeMeditate, which is what ShareView hands out whenever the event has one. Pre-existing and out of scope: it is the prerender gap already logged in RELEASE_READINESS.md §6.

Verification

  • Lint ✓ · Types ✓ · Unit lane ✓ (746 tests) · pnpm build ✓ · pnpm size ✓ · ladle:build ✓
  • The CI Smoke job ran the new spec against a live Cloudflare preview (https://1509f474.sahajatlas.pages.dev) — tests/smoke/robots.smoke.test.ts (5 tests) ✓. Nothing local can execute _headers, so this is the only check that proves it. Confirmed there: /robots.txt is text/plain with Disallow: /; / and /search both carry the header and the meta; /embed.js carries the header with a real JS content-type; and /locales/en/common.json still returns access-control-allow-origin: * alongside the new header — proving on real Pages that /* combines with rather than displaces fix(ui): scope widget css so it cannot restyle the host page #91's CORS fix.
  • Every regex in the spec was run against the real built output including a non-vacuity check (it stops matching when the tag is removed).
  • Browser verification was not authorized this wave (a sibling ticket owned the shared browser); the smoke lane covers the deployed behaviour instead.

Review passes completed

  • /simplify ✓ — 3 angles (reuse, simplification, altitude). The efficiency angle's substance, redundant round-trips, surfaced in all three, so a fourth was not dispatched. Consolidated a rationale restated in four files into one home; collapsed eight robots.txt groups into one.
  • /code-review ✓ — single pass, high effort. Three high-severity findings, all valid, all fixed, and all three were false claims in my own comments: (1) "each of these honours robots.txt" is untrue of Slack, which documents that it ignores robots.txt entirely; (2) the allow-group omitted redditbot, and reddit is in the app's own share grid for six countries — a real unfurl regression, caught by cross-referencing src/lib/share/platforms.ts; (3) the OG claim overstated what a scraper can see (above). Nothing dismissed.
  • /security-review — skipped: no security-relevant paths changed (neither the path nor the content trigger matched). _headers is CORS-adjacent, so rather than lean on the skip, the CORS non-regression became a smoke assertion.

Notes for reviewer

  • weibo is a PlatformKey with deliberately no allowance: its crawler's product token could not be confirmed, and a guessed token is a rule that silently matches nothing.
  • noindex alone, no nofollow — the canonicals point at WeMeditate and there is no reason to stop a crawler following them there.
  • Commits are --no-gpg-sign (the SSH agent was dead this session), so the branch needs re-signing before merge: git rebase --exec 'git commit --amend --no-edit -S' origin/main
  • Implementation report: .claude/reports/106-noindex-standalone.md.

Closes #106

🤖 Generated with Claude Code

Ardnived and others added 5 commits August 7, 2026 10:32
Search is owned by WeMeditate and the other embedding sites, and every
canonical this build emits already points at SahajCloud's `webUrl`, so a
sahajatlas.* result is a duplicate of the page it points at.

Three signals, none of them reaching the embed:

- `public/robots.txt` — `User-agent: * / Disallow: /`, with explicit
  `Allow` groups for the link-preview scrapers. Those are not search
  engines, and ShareView hands out `event.webUrl ?? window.location.href`,
  so a gated event IS shared as a sahajatlas URL — a blanket Disallow
  would have left us serving OG tags no compliant scraper may fetch.
- `public/_headers` — a `/*` rule adding `X-Robots-Tag: noindex`. Pages
  applies every matching rule, so /assets/* keeps its CORS + immutable
  cache. This is the half that covers embed.js, the hashed assets and the
  locale JSON, which no <meta> can reach.
- `index.html` — a static `<meta name="robots" content="noindex">`.
  Standalone-gated by construction (the embed serves embed.js into a host
  page and never this file), and readable without executing ~1 MB of JS.

`Disallow` means "do not fetch", so a compliant crawler never sees the
noindex; the residual URL-only listing is documented in robots.txt along
with the remedy (relax, don't tighten, if we are ever found indexed).

JSON-LD, OG tags and the webUrl canonicals are unchanged.

Closes #106

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Both halves are deploy-time facts: the repo files are inert until
Cloudflare Pages reads them out of dist/, and the `/*` header rule
applying to a path only the `_redirects` SPA fallback resolves is a
platform behaviour we assert rather than code we wrote.

Content type, not status — `/* /index.html 200` means a robots.txt
missing from the build returns the SPA shell with a 200, which is
exactly the failure a status check would pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
- The #106 rationale was restated in four files. It now lives once, in
  public/robots.txt; _headers and index.html keep only their own "why
  this layer exists", and the spec's fourth copy of "status is not a
  result" is a citation.
- robots.txt: one group with eight User-agent lines instead of eight
  single-rule groups. Adding a bot is one line, and `Allow: /` has one
  copy rather than eight to drift.
- robots.txt + _headers: record that `pnpm ladle:build` copies public/
  into build/ too, so this policy also governs sahajatlas-design — and
  that the "relax, don't tighten" runbook opens the playground with it.
- index.html: the old comment justified the meta over the HELMET block,
  which is not the layer it has to earn its place against. The header is
  earlier still. Its real justification is that _headers is a Pages
  construct, so the meta is the layer that survives `pnpm preview`, a
  mirror, or a move off Pages.
- The smoke spec asserted the same shell body and the same 60-char regex
  in two tests; `test.each(['/', '/search'])` over one hoisted const.
- mode.ts: the standalone flag is the entry point for "what do we tell
  crawlers", and the noindex is invisible from there. One clause.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
- "Each of these honours robots.txt" was FALSE. Slack states outright
  that it does not process robots.txt, and Meta documents that
  facebookexternalhit may bypass it. The lines stay — an allowance is a
  permission, not a request, and both vendors have changed this — but
  the comment now names the three where it is load-bearing.
- The allow group omitted `redditbot`, and `reddit` is in the app's own
  share grid for six countries (PlatformKey, src/lib/share/platforms.ts).
  A shared URL would have unfurled as a bare link. Added it along with
  vkShare, OdklBot, Viber, line-poker and Slack-ImgProxy, and tied the
  list to PlatformKey so the two cannot drift. `weibo` is deliberately
  absent: its token could not be confirmed, and a guessed one is a rule
  that silently matches nothing.
- "the OG tags and JSON-LD stay in the standalone head" OVERSTATED what
  a scraper sees. This build is client-rendered with no prerender, so
  helmet injects them at runtime and none of these bots runs JS — the
  served HTML carries only <title>. The group buys a generic card over a
  bare link, not a rich unfurl; rich unfurls come from the `webUrl`
  canonical on WeMeditate. Comment now says so.
- mode.ts contradicted _headers by saying the embed never serves either
  source; `/*` exists precisely to cover embed.js and the assets.

Smoke spec now covers what `/*` is FOR — the header on embed.js, which
no <meta> can reach — and pins the #91 CORS rules against displacement,
the one regression adding a `/*` rule could realistically cause. The
noindex regex is attribute-order-free and verified non-vacuous.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
CLAUDE.md still said `public/_redirects` was "the only repo-level deploy
file" — stale since #91 added `_headers`, and now wrong twice. Lists all
three with what each is for, and records the fact that surprised this
change: `public/` is copied into BOTH build outputs, so `robots.txt` and
`_headers` govern sahajatlas-design too. Ladle generates its own
index.html, so the <meta robots> is the one signal the playground misses
and the header is what covers it there.

tests.md: the smoke lane is where a claim about Cloudflare's behaviour
becomes an assertion rather than a doc quote in a comment.

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

cloudflare-workers-and-pages Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: 10cfc8f
Status: ✅  Deploy successful!
Preview URL: https://ac9f3781.sahajatlas-design.pages.dev
Branch Preview URL: https://feat-noindex-standalone.sahajatlas-design.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: 10cfc8f
Status: ✅  Deploy successful!
Preview URL: https://2bdf873b.sahajatlas.pages.dev
Branch Preview URL: https://feat-noindex-standalone.sahajatlas.pages.dev

View logs

@Ardnived
Ardnived merged commit e9909e5 into main Aug 8, 2026
7 of 8 checks passed
@Ardnived
Ardnived deleted the feat/noindex-standalone branch August 8, 2026 00:21
Ardnived added a commit that referenced this pull request Aug 8, 2026
This PR's own CI disproved its headline finding. The discovery step logged
`check run "Cloudflare Pages: sahajatlas" (in_progress)` on seven consecutive
polls before the URL appeared — so Cloudflare DOES publish a building state,
and the claim that it does not was wrong in the script header, in tests.md and
in the PR body.

The error was methodological, and worth recording because it is repeatable:
Cloudflare sets `started_at` when it COMPLETES a check run, so every finished
run reads `started_at == completed_at`. Sampling historical commits — what
#124's evidence and my own 230-run sweep both did — cannot see the in-progress
window and concludes it never existed. Only watching a live build shows it.

No behaviour changes. The flat deadline stands on the duration data, which is
unaffected, and now costs less than it seemed to: adaptive extension is
genuinely available if the queue ever outgrows the cap. The correction also
makes the `failed` guard's `status === 'completed'` test load-bearing rather
than incidental — an in-progress run has a null conclusion.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived added a commit that referenced this pull request Aug 8, 2026
…#134)

* chore(build): make preview discovery survive a slow cloudflare deploy

The 6-minute deadline was not a margin over Cloudflare's build time, it WAS
that build time: across 86 measured `Cloudflare Pages: sahajatlas` check runs
on this repo the p95 is 373s, so 360s sat below it. #124 came in at 397s and
#99's hard-fail turned a healthy commit red.

Raise it to 10 minutes (overridable via PREVIEW_TIMEOUT_MS) and, more usefully,
stop collapsing every unhappy path into one empty output. A second
`preview_status` output names which it was, and ci.yml gives the two cases
different instructions: `absent` (no Cloudflare signal at all) says investigate,
`pending`/`unreachable` (a deploy demonstrably exists) says re-run. Both still
fail a same-repo PR, so the #99 invariant is untouched — a green Smoke check
still means the specs ran.

The wait is flat rather than adaptive because there is nothing to wait on:
across 230 check runs every one was already `completed` when first visible
(`started_at == completed_at`), and GitHub pre-creates a `queued` check suite
per installed app, so Cloudflare's is indistinguishable from the suites of apps
that never post. That verification is recorded in the script header and in
.claude/rules/tests.md rather than left to be re-derived.

Sources and `pick()` are unchanged; a new spec pins the latter's hostname
boundary, which was previously untested.

Closes #132

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* chore(build): don't repeat the elapsed wait, and name the error case

Three follow-ups from exercising the script against the live API:
- `explain()` no longer restates the elapsed time that `emit()` already
  prefixes every line with (it read "after 18s … after 18s").
- the poll loop no longer sleeps past its own deadline, so the reported wait
  is the budget we set rather than the budget plus a trailing interval.
- ci.yml gives `error` its own message: the discovery step itself failed, which
  is not "Cloudflare posted nothing". An unrecognised status still takes the
  loud branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* chore(build): sanitize quoted evidence and drop a dead branch

Self-triage of the branch diff:

- Source 3 accepts a check run whose NAME begins with "cloudflare pages" from
  ANY installed app, not only Cloudflare's, and that name is now quoted into the
  step summary. `report()` only defangs a LEADING `::`, so a newline in a crafted
  name could forge a summary line mid-string. `note()` flattens whitespace and
  caps at 120 chars before any API text is quoted.
- `explain()`'s `detail` arm was unreachable — `fail()` passes the error message
  straight to `emit()` and never routes through it. Dropped, so the three
  timeout outcomes are the whole function.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* chore(build): tell a failed deploy apart from a slow one

Review triage. The headline finding: a FAILED Cloudflare build still posts a
check run, so counting any run as "a deploy exists" classified it `pending` and
told the reader to RE-RUN a job that fails identically — training the exact
habit #132 set out to break, and making the rate-limit advice on the `absent`
branch unreachable in the one case it was written for.

- add a `failed` status, taken from the run whose name matches CF_PROJECT's own
  slug (the `-design` sibling succeeding says nothing about the app's build, and
  its "(success)" was often the only evidence shown). It outranks every other
  signal, and ci.yml tells the reader to read the Cloudflare log.
- bound every request with AbortSignal.timeout. undici defaults to 300s, so one
  hung socket could overrun the budget by 5 minutes and trip the job's
  `timeout-minutes` — which CANCELS the job, skipping the reporting step and
  leaving a red check with no message at all. Strictly worse than the timeout
  this ticket fixes.
- validate + cap PREVIEW_TIMEOUT_MS. `600` read as seconds was a 0.6s deadline
  and a confident "the deploy did not happen"; document the unit.
- write GITHUB_OUTPUT before the step summary, so an unwritable summary can't
  take the contract down with it.
- narrow source 2's evidence to /cloudflare/ (bare `pages` matched
  `github-pages`) and require a Cloudflare creator on source 1.
- lowercase pick()'s host — an uppercase CF_PROJECT matched nothing and turned
  every same-repo PR red; resolve the main-module guard through realpathSync.
- correct three comments: pick() cites source 4 not 3, and the threat is a bot
  of some installed App rather than "anyone who can comment" (the Bot gate
  already blocks that); CF_PROJECT is a host match, not a substring.

Records the one finding NOT fixed here: the URL harvest is unscoped by SHA and
pick() accepts the branch alias, so the lane can verify the previous commit.
Pre-existing, #122's territory, an explicit non-goal of this ticket, and
tightening it blind would break discovery. Written down in tests.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* docs(build): correct the in-progress claim the live run disproved

This PR's own CI disproved its headline finding. The discovery step logged
`check run "Cloudflare Pages: sahajatlas" (in_progress)` on seven consecutive
polls before the URL appeared — so Cloudflare DOES publish a building state,
and the claim that it does not was wrong in the script header, in tests.md and
in the PR body.

The error was methodological, and worth recording because it is repeatable:
Cloudflare sets `started_at` when it COMPLETES a check run, so every finished
run reads `started_at == completed_at`. Sampling historical commits — what
#124's evidence and my own 230-run sweep both did — cannot see the in-progress
window and concludes it never existed. Only watching a live build shows it.

No behaviour changes. The flat deadline stands on the duration data, which is
unaffected, and now costs less than it seemed to: adaptive extension is
genuinely available if the queue ever outgrows the cap. The correction also
makes the `failed` guard's `status === 'completed'` test load-bearing rather
than incidental — an in-progress run has a null conclusion.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(seo): prevent direct indexing of the standalone build

1 participant