Repository navigation
feat(seo): supply the atlas root view's metadata by default, with an opt-out - #23
Conversation
`GET /api/atlas/seo` 404'd the atlas root, so the one page a host links from its own nav — the page the settings-screen button creates — was the only atlas page with no metadata of its own. SahajCloud#739 answers it, and this consumes it: the root view is requested as `/`, and its title, description, canonical, hreflang, Open Graph and JSON-LD are emitted exactly as a region route's are. A bare view route (`/search`, `/calendar`, …) needs no code here. It is already sent verbatim, and the endpoint answers it with the root document. The opt-out is a second site setting, and principle 4 argues against one. It has the use case principle 4 asks for: a host that wrote its own description for the Atlas page had no way to keep it, and a silent takeover is what turns that into a support request the local volunteer cannot answer. It governs the root view alone — every other atlas route is an address the host's SEO plugin has never seen, so there is no host-written description to preserve there. Two guards, not one. The route is checked before the request, so an opted-out host pays no round trip on their busiest page. `type` is checked after it, because only the answer names which bare view routes resolve to the root — a copy of that segment list here would drift the day a view is added upstream. Trap 16 is untouched: suppression still happens only after a successful fetch, so a 404 or an unreachable endpoint leaves the host's own metadata in place, opt-out or not. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014G2kncmnvzARd9KDsXo6CT
45 assertions across two lanes. Every one was watched fail first, against the defect it exists to catch — the old root exclusion restored, the opt-out ignored, the opt-out widened to every route, suppression moved ahead of the fetch, the root branch dropped from the children dispatch, the JSON-LD re-escaped, the cache slot stripped of its route, locale and key, and the checkbox sanitizer let loose. The behaviour suite stubs the endpoint through `pre_http_request` and drives `sahaj_atlas_seo_boot()` on a real Atlas page, so it asserts the suppression as well as the emission. That pairing is the point: every way of inverting trap 16 looks identical from outside — a page with no description either way — and an emission assertion alone passes against all of them. The render lane seeds the answer in both blueprints and asserts the head block and the crawlable children on a real request, per theme kind, the same shape the sitemap checks already use. Two assertions in the trap 16 group — that nothing is emitted, and that the theme keeps its title — could not be made to fail on their own. The emitter guards its own null, so they ride on the suppression assertion beside them, which did fail. The fixture is an `AtlasSeoResponse` of `type: root`, verified against `src/endpoints/responseTypes.ts` and `buildRootSeo()` in `src/endpoints/atlas/seo/seoDocument.ts` in sydevs/SahajCloud at 70f12c6. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014G2kncmnvzARd9KDsXo6CT
The guide said the plugin exposes one setting, in four places. It now exposes two, so those four lines were about to teach the next agent something false about a file they were reading. Principle 4 keeps its bar and gains the worked example: #16 is the shape that qualifies, and a third setting still needs its own use case. Trap 17 is new, and it is the one a reader cannot recover from the code alone: a bare view route resolves to the atlas root upstream, and the plugin learns which routes those are from `type` in the answer. A copy of that segment list here would look correct and drift silently the day a view is added to the widget. readme.txt gains the FAQ entry a volunteer will actually arrive at — "my SEO plugin's description stopped showing" — with the checkbox as the answer and the reason the deep pages stay ours. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014G2kncmnvzARd9KDsXo6CT
`main` moved under this branch with #21, which rewrote the same two files: `sahaj_atlas_current_route()` now answers for `?atlas=` as well as the path route, and `tests/seo.php` arrived there first, covering the query-routed shape. Both halves are kept; four resolutions were needed. - `sahaj_atlas_seo_cache_key()` is dropped for `sahaj_atlas_seo_slot()`. They are the same helper, written twice. #21's own /simplify pass removed the locale parameter on purpose — a caller free to name a locale writes a transient nothing reads — so the version without it wins, and the slot assertions drive the locale through `determine_locale` instead. - `tests/seo.php` is one file again: #21's routing groups, then this branch's root, opt-out and trap-16 groups. The group asserting the root is *excluded* is now the group asserting it is described, which is the behaviour change this ticket is. - A refused `?atlas=` now falls back to the root view rather than to nothing, since the page is the root view either way. The assertion that matters is the one that survives: the crafted value reaches neither the endpoint nor the canonical. - `tests/fixtures/seo-answer.php` carries the root answer beside the region one, so both render blueprints seed from the one copy. It is seeded under `/search` as well as `/`, because the endpoint answers them alike but the cache is keyed on the route as asked. `pnpm test:all` passes: 220 assertions, and 112 render assertions across both theme kinds. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CyxoefN47eov1tQxCQ4Y7Z
Four cleanup agents and a security review read the whole branch. The security review cleared the diff — the new sinks escape, the option rides core's own `options.php` capability and nonce, and a crafted `?atlas=` reaches neither the endpoint nor the canonical. It named one pre-existing defect outside this diff, filed as #22 rather than fixed here. Applied: - The root is decided before the `content` guard in `sahaj_atlas_seo_children()`. Its heading is the top-level title, so it renders with no content at all — which is exactly what a locale nobody has written copy for answers. The shared guard would have dropped the one element a crawler reads on the page this ticket is about. - `sahaj_atlas_seo_paragraphs()` replaces the same escaped loop in two renderers, so the escaping rule has one home. - `sahaj_atlas_seo_host_describes_root()` is read once into `$their_seo` and consulted twice, so it reads as one decision rather than two rules. - The pre-fetch gate's comment now states its real scope: the root spelled as `/` saves the round trip, a bare view route still asks because only the answer names which routes resolve to the root. The suite pins both halves instead of implying the saving covers all six. - `sahaj_atlas_check_idle()` replaces the verbatim "the API key has to work first" row in two checks. - The diagnostics docblock no longer claims the panel and the front end share a cache slot. They share one only when the admin's language matches the site's, because the slot is keyed per locale. - `includes/routing.php` said a refused `?atlas=` falls back to the host's own metadata. After this branch it falls back to the root view. The comment was about to teach the next reader the opposite of what ships. - One wording for the opt-out label, not two `.pot` entries for one sentence. Render assertions on the root page live in one block. Skipped, with reasons: serving a stale answer while refreshing, and aliasing a bare view route's cache slot onto the root's — both change caching for every route, not just this ticket's, and belong in their own ticket. The fixture's `rootRoute`/`rootCanonical` keys stay, matching the `route`/`canonical` pair already beside them. The new no-content assertion was watched failing against the shared guard. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CyxoefN47eov1tQxCQ4Y7Z
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is the ticket's size: two behaviour files, one setting, the rest tests and docs. Deciding the root from type, not a local segment list, is right — SahajCloud's RESERVED_SEGMENTS also holds register and preview, which seo.php:80's comment omits. Both open questions: keep the <h1> early return, per the ticket; the second setting is justified. #22 now covers the Atlas page itself; its one-line esc_html may belong here.
Findings
blockerseo.php:91 — a root canonical this site does not own is emitted, after core'srel_canonicalis removed. Trap 15's guard is not applied.considerseo.php:69 — the pre-fetch gate may not pay rent.
Checked
- #16 criterion by criterion against tests/seo.php. Its fixture's root half matches
buildRootSeofield for field. - SahajCloud
main:buildRootSeo,rootStrings,atlasRoute,rootCanonical,canonicalTargetFor. Plugin: the four touched files andsitemap.php, whole. Lanes not re-run; CI green.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The endpoint answers what the client owns, and an owned subtree is not necessarily served from the domain asking: an unverified canonical target is answered with the We Meditate surface, and a shared key or a mis-set `canonical.domain` does the same. On the Atlas page that arrived as a foreign `<link rel="canonical">`, printed after core's own `rel_canonical` had been removed — the host's most-linked page handing its indexing away. Trap 15's guard, reused rather than re-derived, and applied trap 16's way: a root answer naming another host is treated as a failed fetch, so the page keeps the metadata it had. Dropping only the tag would be worse, since `rel_canonical` is gone by then. The rule is the root view's alone — a region may consolidate onto another surface, and that is the endpoint's decision to make. The fifth diagnostics row reports the refusal, so the panel cannot say "Sahaj Atlas describes it" about a page the takeover just declined. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FP7QibCu2wv5vEEHWGZjRw
|
Two threads from the branch review, one push — 2a8d0bc. Adopted — the root canonical. An answer naming another domain is now a failed fetch, refused before suppression, reusing the sitemap's own Rebutted — the pre-fetch opt-out gate. Kept, and left open for you. Without it an opted-out host waits on a five-second-timeout request, once per five minutes per locale, on the page their nav links to, for an answer the next gate discards. Gate: 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
#23 edited the shipped `= 0.1.0 =` changelog entry, adding "and which side describes the Atlas page" to the status-panel bullet. That row did not exist at v0.1.0 — `git show v0.1.0:readme.txt` has the panel covering four things, not five. Plugin Update Checker merges readme.txt's sections into the WordPress update modal, so a volunteer on 0.1.0 deciding whether to update reads the fifth row credited to the version they already run. The 0.2.0 entry announcing that same row then reads as a repeat, and the release that actually ships it loses the credit. A shipped release's entry describes what that release shipped. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jg5XawkJdwdSyhgVGdkvQu
* chore(release): v0.2.0 Three merged changes ship in the plugin zip since v0.1.0, and a volunteer sees none of them until a tag builds one: #21, #23 and #24. Everything else merged since c1fec89 is CI, docs or tests, all of which `.distignore` keeps out of the zip, and #10 and #13 touched shipping files in comments only. Minor, not patch, and pre-1.0 either way: #23 adds a capability and a second site setting, so the version has to move more than a fix would. Four declarations, not two. `release.yml` compares the tag against the plugin header alone, so it would have passed with `SAHAJ_ATLAS_VERSION` left at 0.1.0 — and that constant is the cache-buster on `atlas-page.css`, `atlas-page.js` and the editor assets. Every updated site would have kept serving the 0.1.0 copies. `blocks/embed/block.json` declares the same version to the editor. `package.json` declares none: it is dev tooling, and `.distignore` excludes it. The changelog is written for the one non-technical volunteer who runs each site, so it names what they will see rather than what changed in the code. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QNEAgEV5tDoLsB9nyLUv26 * fix(readme): the 0.1.0 entry claimed a 0.2.0 row #23 edited the shipped `= 0.1.0 =` changelog entry, adding "and which side describes the Atlas page" to the status-panel bullet. That row did not exist at v0.1.0 — `git show v0.1.0:readme.txt` has the panel covering four things, not five. Plugin Update Checker merges readme.txt's sections into the WordPress update modal, so a volunteer on 0.1.0 deciding whether to update reads the fifth row credited to the version they already run. The 0.2.0 entry announcing that same row then reads as a repeat, and the release that actually ships it loses the credit. A shipped release's entry describes what that release shipped. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Jg5XawkJdwdSyhgVGdkvQu --------- Co-authored-by: Claude <[email protected]>
Summary
GET /api/atlas/seo(feat(api):/api/atlas/seoanswers the atlas root and bare view routes SahajCloud#739)./search,/calendar,/filters,/online,/share) gets the same document, decided fromtypein the answer rather than a local copy of that segment list.Changes
includes/seo.php— an empty route on the Atlas page is its root view, asked about as/. Two opt-out gates, one read: before the request for the root spelling, after it on the answer'stype. The root renders from its top-leveltitle, so it is decided before thecontentguard the other two renderers need.sahaj_atlas_seo_root_points_elsewhere()then refuses a root answer whose canonical is not this host's, before suppression.includes/settings.php— the second option, its checkbox, and a hidden0so unticking arrives at all.includes/diagnostics.php— a fifth row naming the side that owns the page description, warning when a root answer names another site, andstrongadded to the renderer'swp_ksesallowlist so the title it shows is not silently stripped.includes/sitemap.php— a docblock line only:sahaj_atlas_is_local_url()is now shared with the SEO takeover, and a second copy there would be free to disagree with this one.tests/fixtures/seo-answer.php— the root answer beside the region one, seeded by the PHP suite and both render blueprints.Test results
pnpm test:all— 12 files syntax-clean, 230 behaviour assertions, 112 render assertions across both theme kinds, 0 failures.tests/atlas-url-contract.jsonbyte-identical to SahajCloud's copy onmain.typegate dropped, suppression moved ahead of the fetch, the slot stripped of its locale, the root branch put back behind the sharedcontentguard, the canonical guard removed, that same guard widened past the root, and the diagnostics row that reports it deleted.Manual verification
Notes for reviewer
Three judgement calls worth your eye:
<h1>and paragraphs inside<sahaj-atlas>, because the early return skips the children filter too. That matches the ticket's criterion ("the plugin emits none of it"), and no SEO plugin supplies body content, so nothing replaces it. Say if you would rather the children stayed./, which is the route their nav points at. The suite pins both halves. The branch review asked whether that gate earns its place; the thread carries the answer and stays open for you.Filed on the way: #22 —
sahaj_atlas_seo_title()returns the endpoint's title intopre_get_document_titleunescaped, and core echoes that raw. Pre-existing, found by this branch's security review, not fixed here.Detail
A root canonical this site does not own is a failed fetch. The endpoint answers what the client owns, and an owned subtree is not necessarily served from the domain asking: an unverified canonical target is answered with the We Meditate surface, and a shared key or a mis-set
canonical.domaindoes the same. Printed on the Atlas page, after core's ownrel_canonicalhas been removed, that hands the host's most-linked page to another domain. Dropping only the tag would be worse, sincerel_canonicalis gone by then. The rule is the root view's alone — a region may consolidate onto another surface, and that is the endpoint's decision to make. The suite pins both halves, andtests/fixtures/seo-answer.phpkeeps its localrootCanonical, so the default path is unchanged.This branch was rebuilt on
mainafter #21 landed. #21 rewrote the same two files:sahaj_atlas_current_route()now answers for?atlas=as well as the path route, and it added atests/seo.phpof its own. The merge commit carries the four resolutions. The load-bearing one: #21'ssahaj_atlas_seo_slot()won over this branch's duplicatesahaj_atlas_seo_cache_key(), because #21's own simplify pass had deliberately removed the locale parameter that duplicate reintroduced.A refused
?atlas=now falls back to the root view, since the page is the root view either way. The assertion that matters survives the change: the crafted value reaches neither the endpoint nor the canonical.includes/routing.phpsaid the opposite and now says this.Rejected, with reasons. Serving a stale answer while refreshing, and aliasing a bare view route's cache slot onto the root's: both change caching for every route rather than this ticket's, and belong in their own ticket. The fixture's
rootRoute/rootCanonicalkeys stay, matching theroute/canonicalpair already beside them.Fixture pre-mortem. The root half assumes
buildRootSeo()insrc/endpoints/atlas/seo/seoDocument.tson SahajCloudmain:id: null,routenormalized to/whichever bare view route was asked for, emptybreadcrumbs, aWebSiteJSON-LD node, andcontentcarryingparagraphsalone — so the heading has to come fromtitle. Verified against that file, not against this plugin's reader.Preview: SahajAtlasWordpress deploys none.
Closes #16
🤖 Generated with Claude Code
https://claude.ai/code/session_01CyxoefN47eov1tQxCQ4Y7Z
Generated by Claude Code