Skip to content

feat(atlas): give the unowned remainder a sitemap via a canonical fallback client - #676

Merged
sydevs-bot merged 5 commits into
mainfrom
claude/feat-canonical-fallback-client
Sep 3, 2026
Merged

sydevs-bot merged 5 commits into
mainfrom
claude/feat-canonical-fallback-client

Conversation

@sydevs-bot

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

Copy link
Copy Markdown
Contributor

Closes #652.

Regions nobody claims now have a sitemap, and a canonical URL somebody verified. A region with no owning ancestor falls back to the We Meditate surface asserted by WEMEDITATE_WEB_URL + WEMEDITATE_ATLAS_BASE_PATH — the one canonical target nothing checks, and one that appears in no client's sitemap because no client owns it. sy-atlas-config gains a canonicalFallbackClient relationship; naming a client there puts the remainder through the same pipeline as every other owner, and GET /api/atlas/sitemap answers that client the complement of the ownership map.

An override, never a replacement. Unset, unpublished, not canonically enabled, or with no verified host, every caller keeps the behaviour it had before the field existed.

⏳ Two questions are back with @Ardnived

The third item from your review is done; the other two are questions I have answered rather than guessed at, and both threads are open on purpose.

Thread State
Reword the endpoint description Done — ~470 words to ~200 in four paragraphs (a3d04c1). Resolved
Built-in or library instead of the hand-written memo Researched, nothing changed. React.cache is Server-Components-only and would silently not memoize in a Payload hook; req.context is Payload's own documented mechanism for this, which is what the 15 lines are. No change recommended
Full replacement rather than a fallback Needs one word from you. "Replacement" has two readings — retire the env-var rung (a two-step migration, worth doing) or displace per-region owners (a cross-site canonical on 13 sites, which I'd argue against). Scoped both
The one departure from the ticket, and the migration run

Requiring canonical.enabled, not just verified. verified is deliberately not cleared when verification fails — it is the last thing we observed — and the job switches canonical.enabled off after repeated failures. Reading verified alone would let a client the job has just given up on keep speaking for every unclaimed page in the atlas, which is worse than the env-var surface it replaces. Both readers now apply one CANONICAL_ELIGIBLE constant, so a third condition cannot reach one and not the other.

The migration, run from empty rather than inspected. A fresh database, pnpm payload migrate → 55 migrations applied, 20260902_224424_add_atlas_canonical_fallback_client in 3ms, Done. \d sy_atlas_config then shows the column, the btree index, and FOREIGN KEY (canonical_fallback_client_id) REFERENCES clients(id) ON DELETE SET NULL — which is the right cascade: deleting the fallback client reverts the remainder to the env vars, matching the unset path rather than orphaning a reference. Reversible: migrate:down removed the column cleanly.

⚠ One thing that run turned up, and it is not this PR's. Rolling the whole batch back on a fresh database fails later, inside the already-merged 20260826_214829_add_user_messages down: constraint "payload_locked_documents_rels_user_messages_fk" of relation "payload_locked_documents_rels" does not exist. Ours had already rolled back by then. Filed as #682 rather than fixed here.

The first review round (7 threads), all resolved

The two should-fix ones changed the code: canonicalTargetFor's second parameter was redundant on its own signature and structurally unusable, so it is gone and precedence is asserted in the integration lane instead; and both published contract surfaces (the OpenAPI description, AtlasSitemapResponse) now describe the fallback client, with the "no pagination" claim re-justified against the corpus rather than a subtree.

The new integration assertion was watched failing. Hoisting await getCanonicalFallbackOwner(req) above the early return in getCanonicalUrlBase — the shape the deleted parameter invited — gives AssertionError: expected 2 to be 1 on the query count, then restored.

Test results

  • Lean gate on this head (a3d04c1): ✓ pnpm lint, ✓ pnpm typecheck, ✓ pnpm typecheck:tests, ✓ pnpm test:unit — 120 files / 1560 specs, all exit 0
  • Integration lane (previous head): region-canonical-url, atlas-sitemap, atlas-seo — 82 specs, all green. Unchanged by the doc-only commit
  • origin/main merged in at a3d04c1's parent, so this is tested against fix(api): map a Postgres 22P02 cast failure to 400, on Payload's routes and in geojson #685's databaseErrors plugin

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


🤖 Generated with Claude Code

https://claude.ai/code/session_01W3bncHkCBKywbTiJSniKh8

@sydevs-bot
sydevs-bot requested a review from Ardnived September 2, 2026 17:25
@railway-app

railway-app Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-676 environment in sahajcloud

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Sep 3, 2026 at 4:20 pm UTC
1 service not affected by this PR
  • mailpit

@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-676 September 2, 2026 17:26 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

CI is green on 6597b6d — but the smoke lane did not run, and the migration warning above still stands.

Lint, Test & Smoke succeeded in 20m 15s. The part that matters ran in full: step 10 (pnpm test — the whole unit + integration suite against the postgres service container) passed in 6m 30s, after lint and both typecheck passes.

Step 13 is skipped. Preview discovery ran 12m 12s and found nothing, so step 12's warning fired instead — the shape tests/AGENTS.md documents as "Lint, Test & Smoke: pass" can mean smoke never ran. Railway's own commit status is success, so the preview built; nothing here proves it answers requests.

Worth knowing given the missing migration: had the smoke lane reached a preview, it would have been a preview whose database has no canonical_fallback_client_id column. Its specs cover auth, meditations, songs and lectures rather than the atlas, so a pass there would not have been evidence either way.

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


Generated by Claude Code

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Base updated — the head is now edb0ad8, not 6597b6d. #675 merged after this PR was opened, so I merged the new main in (no conflicts) and CI re-ran: Lint, Test & Smoke green on edb0ad8, 20m 43s.

Flagging it because the PR body's test results name 6597b6d, and AGENTS.md § "A green run can be stale" says to check the run's head_sha against the branch head before trusting it. Both are green; this is so you don't have to go and check.

Nothing else changed, and the blocker has not moved: this still needs the migration whose command is in the PR body. Merging without it is a boot crash, not a slow degradation.

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


Generated by Claude Code

@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

This is the right shape and roughly the right size — the gap is on the contract side, not the code side. The production logic is ~60 lines for a ticket whose acceptance list has six items, the sparse map the ticket warned about is genuinely kept (and pinned by a test that fails if it is materialized), and no new endpoint surface appeared. The one deliberate departure — requiring canonical.enabled, not just verified — is argued from a state production reaches on its own (VerifyEmbeds switches enabled off while buildVerificationState keeps the snapshot) and I would keep it: without it, a client the job has given up on speaks for every unclaimed page in the atlas.

What is missing is the consumer half of a contract change. /api/atlas/sitemap now answers one caller something it has never answered, and both surfaces a consumer reads — the OpenAPI description in customEndpoints.ts and AtlasSitemapResponse in responseTypes.ts — still say "every entry is a URL this client owns", still say a document nothing in its ancestry owns is omitted, and still justify having no pagination with "a client owns a subtree". The fallback client's answer is the complement of the corpus, so all three statements now have an exception nothing documents. Only the internal handler docblock was updated.

One layer does not pay rent: canonicalTargetFor's new second parameter computes exactly what its first parameter already computed, and the only caller passes undefined to the first — see the thread on line 299.

Not merging, as the body says. The missing migration for canonical_fallback_client_id is a boot crash rather than a degradation, and payload-types.ts shipping the field without it is what makes the gap invisible on a green CI run; nothing else here changes that verdict.

Findings

Rank Finding
should-fix The OpenAPI description (customEndpoints.ts:588-615) and AtlasSitemapResponse (responseTypes.ts:200-203) still describe the pre-#652 contract, including the unpaginated justification that the fallback client breaks — src/endpoints/atlas/sitemap/index.ts:120
should-fix canonicalTargetFor's second parameter duplicates its first rung and is unreachable from production; the laziness requirement means the caller that holds both can never use it — src/lib/atlas/regionOwners.ts:299
consider getRegionTree is awaited for every caller though only the fallback branch reads it, and nothing is "already in flight" on the empty-answer path — src/endpoints/atlas/sitemap/index.ts:173
consider The (config as { canonicalFallbackClient?: unknown }) cast discards the generated type this PR just added — src/lib/atlas/regionOwners.ts:188
consider Client eligibility (enabled + published) is now stated in two query shapes; the set is already loaded in both call paths — src/lib/atlas/regionOwners.ts:192
consider The admin description gives the preconditions but not the consequence: setting this moves the canonical URL of most of the tree — src/globals/SahajAtlasConfig/SahajAtlasConfig.ts:72
consider The same rationale is written out in three places (JSDoc, docs/architecture.md, the field comment) — src/lib/atlas/regionOwners.ts:160
What was checked

Ticket vs diff. Read #652 in full (including the two settled decisions and the ⚠ sparse-map warning) before the diff. All six acceptance boxes are addressed: the field exists; the complement is published; unset/unverified reads as before (integration cases "reverts to the env-var surface…" and "ignores a client the verification job switched off…"); the map stays sparse (tests/unit/atlas-sitemap.spec.ts → resolveOwnersByRegion asserted .has(3) === false); the per-request cost is pinned by countFinds at N=1 and N=3; docs/architecture.md replaces the note rather than deleting it. The canonical.enabled clause is the only thing here the ticket did not ask for, and it is declared as such in the body.

Files read whole (branch edb0ad8, git diff origin/main...FETCH_HEAD): src/lib/atlas/regionOwners.ts, src/lib/atlas/regionTree.ts, src/lib/atlas/canonicalUrl.ts (signatures), src/lib/utilities/relationId.ts, src/endpoints/atlas/sitemap/index.ts, src/endpoints/atlas/sitemap/sitemapUrls.ts, src/globals/SahajAtlasConfig/SahajAtlasConfig.ts, plus the four spec files and the payload-types.ts hunk.

Consumer sides followed. src/endpoints/responseTypes.ts:179-213 and src/plugins/openapi/customEndpoints.ts:585-642 — the two in-tree contract statements, neither in this diff; that is finding 1. Cross-repo: SahajAtlasWordpress/includes/sitemap.php is the only consumer of this endpoint in the workspace (grep -rn "atlas/sitemap" across SahajAtlasWordpress, WeMeditateWeb, SahajAtlasWeb — one hit, plus its AGENTS.md reference). It reads loc verbatim, filters to URLs on its own host, caches for 6h and 404s an empty set, so a larger answer needs no change there — but it fetches with 'timeout' => 15, which is why the pagination sentence is worth re-justifying rather than just reworded. WeMeditateWeb does not consume the endpoint yet, so the remainder only reaches a crawler once it does.

Claims checked rather than taken. canonicalTargetFor(undefined, F) ≡ canonicalTargetFor(F) by reading both rungs (lines 307-311) — they call the identical canonicalTargetForHost. git grep -n canonicalTargetFor over FETCH_HEAD -- src returns one definition and one call, which passes undefined first. GeneratedTypes extends Config is declared at payload-types.ts:7157, so the global read is typed and the cast is optional. loadDirectOwners's where-clause compared line by line with loadCanonicalFallbackOwner's. The refactor of loadDirectOwners (extracting canonicalOwnerFrom) is behaviour-preserving: regionId == null still short-circuits before the domain check, and owners.has(regionId) still wins for the lowest id.

Things that looked like defects and are not. The complement is taken over chainById.keys(), which is every region row including unpublished ones — but ownedDocuments reads with overrideAccess: false, so access rules drop them before they can reach a sitemap. A region whose owner's host later becomes unpublishable falls into the complement and is published on the fallback host — which matches what webUrl answers for it, so the sitemap//seo byte-identity holds. The two halves of fallbackRegionIds are disjoint by construction, as its docblock claims.

Not checked. Nothing was run: no build, no test execution, no admin. CI is reported green on this head by the PR's own comment; the migration gap is not something CI can see.

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


Generated by Claude Code

Comment thread src/endpoints/atlas/sitemap/index.ts Resolved
Comment thread src/lib/atlas/regionOwners.ts Resolved
Comment thread src/endpoints/atlas/sitemap/index.ts Resolved
Comment thread src/lib/atlas/regionOwners.ts Resolved
Comment thread src/lib/atlas/regionOwners.ts Resolved
Comment thread src/lib/atlas/regionOwners.ts Resolved
@sydevs-bot sydevs-bot self-assigned this Sep 2, 2026
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-676 September 2, 2026 22:45 Destroyed
@Ardnived

Ardnived commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

@sydevs-bot I've generated the needed migration

sydevs-bot pushed a commit that referenced this pull request Sep 2, 2026
…contract change

Adversarial review on #676 raised seven threads; all seven are addressed.

The two should-fix ones first.

`canonicalTargetFor`'s second parameter was redundant on its own signature:
`canonicalTargetFor(undefined, F)` and `canonicalTargetFor(F)` return the same
value, and the only production caller passed `undefined` first. Worse, the
parameter existed to express "an owner beats the fallback" — a precedence the
one caller holding both can never ask for, because not resolving the fallback
when the region is owned IS the laziness the design rests on. Dropped. The
unit case asserting that precedence went with it and is replaced by an
integration case at the site precedence actually lives: an owned region read
with a fallback configured resolves on its owner's host AND leaves the
`clients` query count at 1. Watched failing — eagerly awaiting the fallback in
`getCanonicalUrlBase` gives `expected 2 to be 1`.

The consumer half of the contract change was missing. `/api/atlas/sitemap`
now answers one caller the complement of the ownership map, while both
published surfaces — the OpenAPI description and `AtlasSitemapResponse`, which
SahajAtlasWordpress reads by raw URL — still said every entry is a URL the
client owns and that documents nothing owns are omitted. Both now describe the
fallback client, and the "no pagination" claim is re-justified: it rested on a
client owning a subtree, which this client does not, so consumers are told to
size the fetch against the corpus.

The five `consider` threads: the client-eligibility predicate is now one
`CANONICAL_ELIGIBLE` constant rather than two query shapes that could drift;
the structural cast on `canonicalFallbackClient` is gone, since the field is in
`payload-types.ts` and `relationId` takes `unknown`; `getRegionTree` moved
inside the branch that takes a complement, so every other client (the empty
answer included) stops paying for a `regions` read it never looks at; the admin
description now says what setting the field DOES, not only its preconditions;
and the 18 lines of JSDoc restating `docs/architecture.md` are down to the two
imperatives a reader cannot re-derive.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013zCsUruFTxhvz66CEANoAE
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-676 September 2, 2026 23:16 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Thanks — migration confirmed, and the review's 7 threads are all addressed. This is ready for you.

I ran your migration rather than reading it: fresh database, pnpm payload migrate → 55 applied, 20260902_224424_add_atlas_canonical_fallback_client in 3ms. \d sy_atlas_config shows the column, the index, and ON DELETE SET NULL — the right cascade, since deleting the fallback client should revert the remainder to the env vars rather than orphan a reference. migrate:down removes it cleanly.

The code changed in two ways worth knowing before you read the diff. canonicalTargetFor lost its second parameter — it was redundant on its own signature and structurally unusable, so precedence is now asserted in the integration lane (an owned region read with a fallback configured resolves on its owner's host and never queries the fallback), watched failing before it was kept. And both published contract surfaces now describe the fallback client, since /api/atlas/sitemap was answering one caller something the OpenAPI description and AtlasSitemapResponse still denied.

The integration lane ran locally for the first time — #679's ensure-test-db.sh fix is what unblocked it. 82 specs across region-canonical-url, atlas-sitemap, atlas-seo, all green.

One thing the migration run turned up, which is not this PR's

Rolling the whole batch back on a fresh database fails inside the already-merged 20260826_214829_add_user_messages down:

constraint "payload_locked_documents_rels_user_messages_fk" of relation
"payload_locked_documents_rels" does not exist

Ours had already rolled back cleanly by then, and production rolls forward, so nothing here is urgent. Filed as its own ticket rather than widened into this PR.

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


Generated by Claude Code

sydevs-bot and others added 3 commits September 3, 2026 05:09
…lback client

`GET /api/atlas/sitemap` answers the routes a *client* owns, and the We
Meditate fallback is not a client — it is two env vars in
`canonicalTargetFor()`. So every region no client declares, and every class
inside one, was in nobody's sitemap: the larger share of a ~595-region tree
against ~31 declaring clients, all of it with real, canonical, indexable URLs
that `/api/atlas/seo` was happily serving metadata for.

`sy-atlas-config.canonicalFallbackClient` names the client that owns that
remainder. Ownership becomes total, so the endpoint needs no new surface — no
`?scope=`, no second endpoint, and none of the auth question that came with
one: the pages belong to somebody, and that somebody asks for its own sitemap
through the call that already exists.

Three decisions carry the implementation.

**The map stays sparse.** The naive reading of "ownership becomes total" is an
entry per unclaimed region, but `resolveOwnersByRegion`'s precedence rule is
expressed by *absence* — it is what makes a nearer client's subtree drop out of
an ancestor's sitemap. So the fallback is resolved where the fallback already
is, in `canonicalTargetFor`, and the endpoint branches once: for the fallback
client the answer is the complement of the map rather than a lookup in it.

**The predicate requires `canonical.enabled`, not just a verified host.**
`verified` is deliberately not cleared when verification fails — it is the last
thing we observed — while the job switches `canonical.enabled` off after
repeated failures. Reading `verified` alone would therefore let a client the job
has just given up on keep speaking for every unclaimed page in the atlas, which
is worse than the env-var surface it replaced. The fallback is an ordinary
canonical owner that additionally covers the remainder.

**The read is lazy.** `sy-atlas-config` backs no other read on the `webUrl`
path, which resolves on the afterRead of every region and every event, so this
adds queries where there were none. An owned region short-circuits before
asking; an unowned one pays two, memoized on the request.

Unset, or naming a client that cannot publish a canonical, everything reads
exactly as it did before the field existed.

Closes #652

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

Adversarial review on #676 raised seven threads; all seven are addressed.

The two should-fix ones first.

`canonicalTargetFor`'s second parameter was redundant on its own signature:
`canonicalTargetFor(undefined, F)` and `canonicalTargetFor(F)` return the same
value, and the only production caller passed `undefined` first. Worse, the
parameter existed to express "an owner beats the fallback" — a precedence the
one caller holding both can never ask for, because not resolving the fallback
when the region is owned IS the laziness the design rests on. Dropped. The
unit case asserting that precedence went with it and is replaced by an
integration case at the site precedence actually lives: an owned region read
with a fallback configured resolves on its owner's host AND leaves the
`clients` query count at 1. Watched failing — eagerly awaiting the fallback in
`getCanonicalUrlBase` gives `expected 2 to be 1`.

The consumer half of the contract change was missing. `/api/atlas/sitemap`
now answers one caller the complement of the ownership map, while both
published surfaces — the OpenAPI description and `AtlasSitemapResponse`, which
SahajAtlasWordpress reads by raw URL — still said every entry is a URL the
client owns and that documents nothing owns are omitted. Both now describe the
fallback client, and the "no pagination" claim is re-justified: it rested on a
client owning a subtree, which this client does not, so consumers are told to
size the fetch against the corpus.

The five `consider` threads: the client-eligibility predicate is now one
`CANONICAL_ELIGIBLE` constant rather than two query shapes that could drift;
the structural cast on `canonicalFallbackClient` is gone, since the field is in
`payload-types.ts` and `relationId` takes `unknown`; `getRegionTree` moved
inside the branch that takes a complement, so every other client (the empty
answer included) stops paying for a `regions` read it never looks at; the admin
description now says what setting the field DOES, not only its preconditions;
and the 18 lines of JSDoc restating `docs/architecture.md` are down to the two
imperatives a reader cannot re-derive.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013zCsUruFTxhvz66CEANoAE
@sydevs-bot
sydevs-bot force-pushed the claude/feat-canonical-fallback-client branch from 8dc6ddd to 8669441 Compare September 3, 2026 05:09
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-676 September 3, 2026 05:09 Destroyed
Comment thread src/lib/atlas/regionOwners.ts Resolved
Comment thread src/plugins/openapi/customEndpoints.ts Resolved
@Ardnived Ardnived assigned sydevs-bot and unassigned Ardnived Sep 3, 2026
…must act on

Review asked for the whole `/api/atlas/sitemap` description to be reworded
more concisely. It had grown to ~470 words of unbroken prose because each
review round appended its own justification rather than replacing one.

Every contract fact survives — the `loc`/`canonical` byte-identity, the
don't-recompose warning, nearest-owner subtree semantics, empty-is-200,
omitted-not-null, empty regions in and finished classes out, the fallback
client, no pagination, `lastmod`, sorting, `generated`, per-client caching.
What went is the *argument* for each: a consumer acts on the rule, not on
why we chose it. ~200 words in four paragraphs, matching the paragraph
style `/api/events/geojson` already uses in this file.

`tests/unit/openapi-custom-endpoints.spec.ts` pins four phrases from this
description; "Finished classes are excluded" is kept verbatim rather than
loosening the assertion to match new prose — an assertion that tracks
whatever the text happens to say stops being a guard.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01W3bncHkCBKywbTiJSniKh8
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-676 September 3, 2026 16:17 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

One of your three is done; the other two are questions I've answered and left open for you. a3d04c1, plus origin/main merged in so this is now tested against #685.

  • 🔧 Reword the endpoint description — done and resolved. ~470 words to ~200, four paragraphs, every contract fact kept and every justification for one dropped.
  • 🔬 A built-in or a library instead of the hand-written memo — researched, nothing changed, and the reason is worth the click: React.cache is the built-in you'd reach for and it is Server-Components-only, so in a Payload hook it evaluates and silently does not memoize. Payload's documented mechanism for this is req.context, which is what those 15 lines wrap. dataloader is the one library with real extra value and it solves batching, which we don't have.
  • ❓ Full replacement rather than a fallback — needs one word from you. "Replacement" reads two ways: retire the env-var rung so the named client is the only source (a two-step migration, worth doing, own ticket), or let the fallback displace per-region owners (a cross-site canonical pointed at 13 self-hosted WordPress sites, which I'd argue against). Both scoped in the thread.

Nothing here changes behaviour — the only commit is the description reword. Lean gate green on this head: lint, typecheck, typecheck:tests, test:unit (120 files / 1560 specs).

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


Generated by Claude Code

@sydevs-bot
sydevs-bot merged commit e92f4e0 into main Sep 3, 2026
2 checks passed
Ardnived pushed a commit that referenced this pull request Nov 5, 2026
…contract change

Adversarial review on #676 raised seven threads; all seven are addressed.

The two should-fix ones first.

`canonicalTargetFor`'s second parameter was redundant on its own signature:
`canonicalTargetFor(undefined, F)` and `canonicalTargetFor(F)` return the same
value, and the only production caller passed `undefined` first. Worse, the
parameter existed to express "an owner beats the fallback" — a precedence the
one caller holding both can never ask for, because not resolving the fallback
when the region is owned IS the laziness the design rests on. Dropped. The
unit case asserting that precedence went with it and is replaced by an
integration case at the site precedence actually lives: an owned region read
with a fallback configured resolves on its owner's host AND leaves the
`clients` query count at 1. Watched failing — eagerly awaiting the fallback in
`getCanonicalUrlBase` gives `expected 2 to be 1`.

The consumer half of the contract change was missing. `/api/atlas/sitemap`
now answers one caller the complement of the ownership map, while both
published surfaces — the OpenAPI description and `AtlasSitemapResponse`, which
SahajAtlasWordpress reads by raw URL — still said every entry is a URL the
client owns and that documents nothing owns are omitted. Both now describe the
fallback client, and the "no pagination" claim is re-justified: it rested on a
client owning a subtree, which this client does not, so consumers are told to
size the fetch against the corpus.

The five `consider` threads: the client-eligibility predicate is now one
`CANONICAL_ELIGIBLE` constant rather than two query shapes that could drift;
the structural cast on `canonicalFallbackClient` is gone, since the field is in
`payload-types.ts` and `relationId` takes `unknown`; `getRegionTree` moved
inside the branch that takes a complement, so every other client (the empty
answer included) stops paying for a `regions` read it never looks at; the admin
description now says what setting the field DOES, not only its preconditions;
and the 18 lines of JSDoc restating `docs/architecture.md` are down to the two
imperatives a reader cannot re-derive.

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

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-676 — a3d04c10 Deployed Sep 3, 2026 by railway-app[bot]
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.

Atlas: unowned regions are in nobody's sitemap (the We Meditate fallback)

3 participants