Repository navigation
docs(embed): the UI locale is documented as an attribute that no longer exists - #287
Conversation
…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
Deploying sahajatlas-design with
|
| Latest commit: |
9876215
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ed3862e6.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://claude-docs-contract-locale.sahajatlas-design.pages.dev |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 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:60still readsHost-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'sfull viewport(#170 — a genuinely different contract), not for this one word. - consider —
src/components/AGENTS.md:190sends readers to "the attribute table" indocs/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
`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
Deploying sahajatlas with
|
| Latest commit: |
39d3674
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ad2d6483.sahajatlas.pages.dev |
| Branch Preview URL: | https://claude-docs-contract-locale.sahajatlas.pages.dev |
|
Three findings, three adopted. Pushed
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. Lean gate green: 138 files, 1696 tests. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
#149removed every attribute.docs/embedding.mdwas right all along, so this PR brings its describers into line with it.App.tsxnever 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
src/loader/config.tshad ordered 2 above 1, omitted 3, and listed the client record.src/config/i18n-options.tslisted the client record and omitted 3 from its own detection order.Files — which describer said what
Preview
Nothing renders differently. The only source change is three
it()names; every other sourcecodeHashis unchanged.Contract impact
None. No behaviour, parameter, origin, CSP directive or URL shape changes, so
docs/embedding.mdandCHANGELOG.mdneed no entry — the changelog's own header excludes documentation. The two in-tree consumers were checked againstdocs/embedding.mdduring the audit and both match:WeMeditateWeb/lib/atlas-embed.tssendskey+routing=path+atlas, and the WordPress plugin'sincludes/embed.phpsendskey,map=false,atlas,gestures=cooperative,routing=path. Theapi-keysnippets remaining indocs/embedding.md:1218andCHANGELOG.md:483are labelled<!-- before -->in migration sections and are correct as they stand.Test results
pnpm lint && pnpm typecheck && pnpm test:run— 138 files, 1696 testscomment-fingerprint.mjs --base origin/main→ 6 source files, 5 identicalcodeHash.src/config/locale.test.tsis the oneCODE CHANGED: threeit()names, no assertion touched. No displaced comment, protected census not shrunk.comment-lint.mjs --base origin/main→ no banned comment addedManual verification
Nothing to click. The claim to check is whether each rewritten sentence is true, which only reading can settle:
src/loader/config.tsLoaderConfig.localeagainstAppShell'spageLocaleOverride(search) ?? defaultLocale ?? i18n.language(src/App.tsx:367).src/config/i18n-options.tsagainstorder: ['querystring', 'hostHtmlLang', 'navigator'](same file).src/Widget.tsx:429, "the element observes no attributes at all" — and so thatdocs/architecture.md's Layers row cannot sayprops → app.docs/embedding.mdhas no attribute table: its heading is## Parameters(:130).Notes for reviewer
Found by the alternate-Monday contract audit (
audit-contracts), checkingdocs/embedding.mdagainstsrc/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 highwere all accepted and fixed — two of them defects in this PR's own first draft:src/types/client.ts⚠). Reworded, and pointed at that ⚠ rather than atApp.tsx.?locale=on the PAGE outranks it" was unconditional, butpageLocaleOverridereturnsundefinedfor a tag outsideavailableLocales, so scriptlocale=fr+ page?locale=dewith['en','fr']renders French.locale-param.tscalls that "resolvable, not merely present" distinction load-bearing. HencePUBLISHEDin the rewrite./simplifywas not run as a separate pass: no behaviour changed, so there is nothing for it to act on./security-reviewran becausesecurityReview.triggerPatternmatchessrc/App.tsxandsrc/loader/config.tson 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 threefix(…):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:24still 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:cmsin SahajAtlasWeb and the WordPress plugin'scurlboth produced no diff; WeMeditateWeb's copy is stale onmain, butWeMeditateWeb#168already carries exactly that sync and is waiting on review, so there was nothing to push.comment-rule-sync.mjsreports all four copies matching and all four symlinks resolving.CHANGELOG.mdcovers everything host-observable through#273;#276is docs and#277is an internal pagination refactor.Generated by Claude Code