Skip to content

docs(embed): the UI locale is documented as an attribute that no longer exists - #287

Merged
sydevs-bot merged 5 commits into
mainfrom
claude/docs-contract-locale
Oct 12, 2026
Merged

sydevs-bot merged 5 commits into
mainfrom
claude/docs-contract-locale

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The UI locale is called an element attribute in source comments, three guides and the README.
  • Three test names and an auto-loading rule file say the same. #149 removed every attribute.
  • docs/embedding.md was right all along, so this PR brings its describers into line with it.
  • Two also reversed the precedence chain and named the client record, which App.tsx never reads.

Change outline

The contract is the locale precedence chain. docs/embedding.md §Parameters publishes it and is correct; this PR brings its describers into line. Paraphrased, one rule per line:

Contract — how the widget's locale is chosen

 1. `?locale=` on the PAGE URL, when it names a published locale   # pageLocaleOverride
+   …one naming anything else is not a choice, and falls through
 2. `locale=` on the loader script URL                             # LoaderConfig.locale → defaultLocale
-   the client record's `locale`                                   # never read — types/client.ts ⚠
 3. the host page's `<html lang>`                                  # hostHtmlLang detector
 4. the browser's own preference                                   # navigator detector
 5. English

src/loader/config.ts had ordered 2 above 1, omitted 3, and listed the client record. src/config/i18n-options.ts listed the client record and omitted 3 from its own detection order.

Files — which describer said what

 src/
-├── loader/config.ts        # LoaderConfig.locale: chain reversed, client record, no <html lang>
+├── loader/config.ts        # the chain as AppShell resolves it, "published" made explicit
-├── config/i18n-options.ts  # detection order missing hostHtmlLang; attribute + client record
+├── config/i18n-options.ts  # order as written in code; record named as deliberately unread
-├── config/locale.ts        # `locale="fr"` twice — an attribute
+├── config/locale.ts        # the loader script's `locale=`
-├── config/locale.test.ts   # three `bootLocale` names say "the host attribute"
+├── config/locale.test.ts   # "the script's locale=" — a name is read in runner output,
+│                           # where no neighbouring comment corrects it
 ├── lib/shape/locale-param.test.ts  # one comment, same premise
-├── components/AGENTS.md    # points at embedding.md's "attribute table"
+├── components/AGENTS.md    # its `## Parameters` table — the heading that exists
 └── App.tsx                 # same, once. AppShell's own chain at :327 was already correct
 docs/
-├── environment.md          # <sahaj-atlas api-key="…" locale="en"> as THE embed snippet
-├── architecture.md         # same shape in the diagram; Layers row reads `props → app`
+│                           # both now the script tag docs/embedding.md publishes, and the
+│                           # Layers row names `config/embed.ts` — there are no props
 └── rules/i18n-and-state.md # loads on src/config/locale.ts — stale rule beside fixed comment
                             # also: generation counter pointed at a file that does not exist

Preview

  • Ladle playground — the branch alias, read off Cloudflare's own comment. Nothing to look at there: no component changed.
  • The app preview's Cloudflare comment has not posted for this head. Pending, never derived.

Nothing renders differently. The only source change is three it() names; every other source codeHash is unchanged.

Contract impact

None. No behaviour, parameter, origin, CSP directive or URL shape changes, so docs/embedding.md and CHANGELOG.md need no entry — the changelog's own header excludes documentation. The two in-tree consumers were checked against docs/embedding.md during the audit and both match: WeMeditateWeb/lib/atlas-embed.ts sends key + routing=path + atlas, and the WordPress plugin's includes/embed.php sends key, map=false, atlas, gestures=cooperative, routing=path. The api-key snippets remaining in docs/embedding.md:1218 and CHANGELOG.md:483 are labelled <!-- before --> in migration sections and are correct as they stand.

Test results

  • Lean gate: ✓ pnpm lint && pnpm typecheck && pnpm test:run — 138 files, 1696 tests
  • comment-fingerprint.mjs --base origin/main → 6 source files, 5 identical codeHash. src/config/locale.test.ts is the one CODE CHANGED: three it() names, no assertion touched. No displaced comment, protected census not shrunk.
  • comment-lint.mjs --base origin/main → no banned comment added
  • Build: N/A (lean gate; CI runs build + size)

Manual verification

Nothing to click. The claim to check is whether each rewritten sentence is true, which only reading can settle:

  1. src/loader/config.ts LoaderConfig.locale against AppShell's pageLocaleOverride(search) ?? defaultLocale ?? i18n.language (src/App.tsx:367).
  2. src/config/i18n-options.ts against order: ['querystring', 'hostHtmlLang', 'navigator'] (same file).
  3. That no attribute exists: src/Widget.tsx:429, "the element observes no attributes at all" — and so that docs/architecture.md's Layers row cannot say props → app.
  4. That docs/embedding.md has no attribute table: its heading is ## Parameters (:130).

Notes for reviewer

Found by the alternate-Monday contract audit (audit-contracts), checking docs/embedding.md against src/loader/. The guide passed every check — parameters, CSP origins, Permissions-Policy capabilities, sizing, routing. The drift was entirely in the code and docs that describe it, which is why no gate saw it.

The adversarial review's three findings were all adopted, as commits 3 to 5. Its shape note was right: the first census counted only the four source describers, and the two test files the diff already touched were where more of the same premise survived.

Four findings from /code-review high were all accepted and fixed — two of them defects in this PR's own first draft:

  • "The client record carries no locale" was false. SahajCloud still has the field; the widget stopped reading it (src/types/client.ts ⚠). Reworded, and pointed at that ⚠ rather than at App.tsx.
  • "A ?locale= on the PAGE outranks it" was unconditional, but pageLocaleOverride returns undefined for a tag outside availableLocales, so script locale=fr + page ?locale=de with ['en','fr'] renders French. locale-param.ts calls that "resolvable, not merely present" distinction load-bearing. Hence PUBLISHED in the rewrite.
  • The rule file and the README/guides were the other two, and are the second commit.

/simplify was not run as a separate pass: no behaviour changed, so there is nothing for it to act on. /security-review ran because securityReview.triggerPattern matches src/App.tsx and src/loader/config.ts on path; it found nothing, for the same reason.

Detail

Why five commits. docs(comments): fixes the five source comments; docs(embed): fixes the README, two guides and the rule file; the three fix(…): commits are the adversarial review's findings, one each. Same stale premise, different surfaces, each separately revertable.

Drift found and deliberately NOT fixed here, to avoid bundling unrelated contracts — docs/architecture.md:24 still reads <Mapbox> (fixed, full viewport) in the layer diagram, true only of an unsized embed since #170. That is a containment claim, not a locale one, and the review agreed it belongs in its own change.

The audit's other checks, all clean. Copied contracts: pnpm run types:cms in SahajAtlasWeb and the WordPress plugin's curl both produced no diff; WeMeditateWeb's copy is stale on main, but WeMeditateWeb#168 already carries exactly that sync and is waiting on review, so there was nothing to push. comment-rule-sync.mjs reports all four copies matching and all four symlinks resolving. CHANGELOG.md covers everything host-observable through #273; #276 is docs and #277 is an internal pagination refactor.


Generated by Claude Code

sydevs-bot and others added 2 commits October 12, 2026 08:24
…d attribute

The loader's `locale` JSDoc stated the precedence backwards and named a source
the widget does not read: "use the client record, then `?locale=`, then the
browser." The real chain is `pageLocaleOverride(search) ?? defaultLocale ??
i18n.language` (`App.tsx` `AppShell`), so a PAGE `?locale=` outranks the script
parameter, `<html lang>` sits below it, and the client record's locale is
deliberately not read at all (`App.tsx`, "The client record's `locale` is
deliberately NOT read"). `docs/embedding.md` publishes the correct chain to
hosts, so the loader's own type contradicted the host-facing contract.

`i18n-options.ts` named the same dead client record, omitted `hostHtmlLang`
from a detection order that reads `['querystring', 'hostHtmlLang',
'navigator']`, and offered a `locale` attribute as a configuration path. There
is no attribute: `Widget.tsx` registers r2wc with no `props` — "the element
observes no attributes at all" — since #149 moved every setting onto the
loader's query string. Three more comments, in `locale.ts`, `locale.test.ts`
and `locale-param.test.ts`, spell that parameter `locale="fr"` and send the
next reader looking for an attribute that cannot exist.

Found by the alternate-Monday contract audit, checking `docs/embedding.md`
against `src/loader/`. The guide was right; these five were not.

Comment-only, proven: `comment-fingerprint.mjs --base origin/main` reports
6 files, 6 identical codeHashes, no displaced comment, protected census frozen.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013veXg5dRSpjwiC1ZuWVeUR
… shape

The same stale premise as the commit before, in the places a reader meets
first. #149 moved every setting onto the loader script's query string, and
`Widget.tsx` registers r2wc with no `props` — "the element observes no
attributes at all" — so these four were describing an element that cannot be
configured:

- `README.md` sourced the language from "the `locale` attribute, the API client's
  configured locale, or a `?locale=`", naming two sources the widget does not
  read and omitting `<html lang>` and the script's own `locale=`.
- `docs/environment.md` and `docs/architecture.md` both printed
  `<sahaj-atlas api-key="…" locale="…">` as the embed snippet. `docs/embedding.md`
  publishes the script tag, so a host following either guide gets a widget with
  no key.
- `docs/rules/i18n-and-state.md` loads automatically on `src/config/locale.ts`,
  so an agent editing that file got the corrected comment and the stale rule in
  one context. It also pointed the #168 generation counter at
  `src/config/language.ts`, a file that does not exist; the counter is in
  `locale.ts`.

Found by the alternate-Monday contract audit, checking `docs/embedding.md`
against `src/loader/`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013veXg5dRSpjwiC1ZuWVeUR
@cloudflare-workers-and-pages

Copy link
Copy Markdown

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

sydevs-bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 08:39Z address-review · attempt 1 · session · done
  • 08:39Z address-review · attempt 1 · session
  • 08:32Z review-pr · attempt 1 · session · done
  • 08:32Z review-pr · 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

Right change, right size: comments and prose only, each rewrite checked against code rather than the guide. docs/embedding.md:138 is the authority, the PR correctly leaves it alone, and the two agree. Nothing host-observable moves, so the embed contract and its two consumers are untouched.

One shape-level note. This is a census-driven sweep, and the census missed. The body's ### Files block names four source describers and omits the two test files the diff also edits — and those two are where more stale statements survive. A grep attribut src/ finds them.

Findings

  • should-fix — three stale test names in src/config/locale.test.ts (157, 165, 171). See thread.
  • should-fix — docs/architecture.md:60 still reads Host-page embedding, props → app. There are no props (#149). Same premise, same file the PR already edits. Deferring the diagram is right for line 24's full viewport (#170 — a genuinely different contract), not for this one word.
  • consider — src/components/AGENTS.md:190 sends readers to "the attribute table" in docs/embedding.md. That table is now ## Parameters.

What was checked

Read whole: the six source files, types/client.ts, Widget.tsx, and all four guides. Confirmed no observed attributes (Widget.tsx:429), order: ['querystring','hostHtmlLang','navigator'] (i18n-options.ts:61), pageLocaleOverride(…) ?? initialLocale.current ?? i18n.language (App.tsx:367), the ⚠ at types/client.ts:8, and generation in locale.ts:71 (no language.ts exists — that rule fix is right). Swept api-key= and <sahaj-atlas repo-wide: only embedding.md:1218 and CHANGELOG.md:483, both inside <!-- before -->. Comment-only holds by eye; comment-fingerprint.mjs could not run here (no node_modules).

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


Generated by Claude Code

Comment thread src/config/locale.test.ts 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 Oct 12, 2026
`bootLocale`'s second argument is the loader script's `locale=`; #149 removed
every element attribute. A test name is read in runner output, where no
neighbouring comment corrects it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019b6e5ZiSLX5MBRYKfgSPPh
`Widget.tsx` registers r2wc with no `props` — "the element observes no
attributes at all" — so nothing reaches the app that way. The loader parses the
script URL into `config/embed.ts`, which the element reads.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019b6e5ZiSLX5MBRYKfgSPPh
`docs/embedding.md` has no attribute table — #149 made it `## Parameters`.
An agent following the pointer looks for a heading that is not there.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019b6e5ZiSLX5MBRYKfgSPPh
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

Latest commit: 39d3674
Status: ✅  Deploy successful!
Preview URL: https://ad2d6483.sahajatlas.pages.dev
Branch Preview URL: https://claude-docs-contract-locale.sahajatlas.pages.dev

View logs

@sydevs-bot sydevs-bot changed the title docs(embed): nine statements route the UI locale through an attribute that no longer exists docs(embed): the UI locale is documented as an attribute that no longer exists Oct 12, 2026
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Three findings, three adopted. Pushed 39d3674.

  • Three stale test names → 01c87f1. bootLocale's second argument is the loader script's locale=.
  • "docs/architecture.md:60 still reads Host-page embedding, props → app" → 3d49ca8. The row now names config/embed.ts; Widget.tsx:429 registers no props.
  • "src/components/AGENTS.md:190 sends readers to 'the attribute table'" → 39d3674. It now names ## Parameters.

Nothing rebutted, nothing asked. The shape note was right: the census named four source describers and skipped the two test files the diff already touched.

Title and body refreshed — "nine statements" and the comment-only claim were both made false by this push. locale.test.ts is now the one changed codeHash, three it() names, no assertion touched.

Lean gate green: 138 files, 1696 tests.

🤖 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 Oct 12, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 12, 2026 08:51
@sydevs-bot
sydevs-bot requested a review from Ardnived October 12, 2026 08:51
@sydevs-bot
sydevs-bot enabled auto-merge October 12, 2026 08:51
@sydevs-bot
sydevs-bot added this pull request to the merge queue Oct 12, 2026
Merged via the queue into main with commit 83dea2e Oct 12, 2026
41 checks passed
@sydevs-bot
sydevs-bot deleted the claude/docs-contract-locale branch October 12, 2026 16:41
@sydevs-bot sydevs-bot moved this from Revising to Done in SYDevelopers Technical Roadmap Oct 12, 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.

3 participants