Repository navigation
Description
The goal
Every visitor sees the whole atlas — every country, every place, every class — and it keeps loading at today's speed as the atlas grows. The atlas is small enough today that this works. The goal is that it keeps working once there are many more classes, and once the system behind the atlas stops allowing it to ask for all of the data in one request.
Why it matters
The atlas runs inside other people's websites, which we do not deploy. If it ever loads only part of the data, nothing on screen says so: a visitor in a city with twelve classes would see none, and conclude there are none. We have already decided to stop letting the atlas ask for everything in one request — and asking for everything in one request is the only way it reads data today. So the atlas has to learn to read the data in pieces before that restriction arrives, or it quietly goes half-empty everywhere at once.
What success looks like
- The map shows every class, and the place list shows every country that has one. Today that is 452 classes and 25 countries.
- Opening the largest country shows all of its classes. Today that is Brazil, with 81.
- If the atlas cannot be loaded in full, the visitor sees a clear message with a way to try again — never a map that looks complete but is not.
- On a first visit, the map's pins appear within 5 seconds. On a repeat visit within five minutes, within 2 seconds.
- After the restriction above goes live, the two counts in the first line still match, checked on a real client site.
Not included
- Changing what the map shows. This goal is about loading it.
- Fetching only one region's data instead of the whole atlas. Downloading the whole atlas once is what makes every region equally fast and lets one download serve many visitors. Changing that is much larger, separate work.
- Making the atlas faster than it is today. This goal protects today's speed as the atlas grows. It does not promise an improvement.
Decisions
- May the atlas ask for a whole set of data in one request? → No. It must read the data in pieces, and that change must be live before the restriction ships. (Ardnived, 2026-10-06, on fix(api): unbounded client limit and page reach SQL and return 500 SahajCloud#887)
- How much may one request ask for? → 2,000 rows. Today's 646 places and 452 classes each fit in a single request, so this costs nothing until the atlas is roughly four times its present size. (Ardnived, 2026-10-06)
- What does this goal promise — that the atlas is never shown incomplete, or that it gets faster? → Close this goal. Its work is written up as refactor(api): paginate the three
pagination: falseSahajCloud reads #253 (merged) and feat(api): refuse an unbounded client read, once the Atlas widget paginates SahajCloud#889, and the answers below are carried there. (Ardnived, 2026-10-21) - If the atlas cannot be loaded in full, what should a visitor see? → A clear error, with a way to try again. Nobody is told a city has no classes when it has twelve. (Ardnived, 2026-10-21)
- How much growth should this be built to survive? → Today's size plus about four times headroom, as the 2,000-row page already gives. Revisit if bulk importing (Managers can import a whole region's classes at once #258) multiplies the classes. (Ardnived, 2026-10-21)
- Should the restriction be announced for one release before it is enforced? → No. Enforce it straight away: a refused request gets a clear error naming the limit, and every refusal is recorded where we already watch. (Ardnived, 2026-10-21)
Open questions
None.
Notes
Related: #253, sydevs/SahajCloud#887, sydevs/SahajCloud#889
Measured in production on 2026-10-08: 452 classes, 646 places, 25 of 34 countries have at least one class, largest country Brazil with 81. Nothing is slow or failing today because a region is large. The technical findings, the measurements and the order the pieces must ship in are in the notes comment on this ticket.
Sub-issues
Collapse Sub-issuesSub-issues
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsNo status
Activity
sydevs-bot commentedon Oct 8, 2026
🤖 no session running
recent dispatches
Written by the sydevs dispatcher. Sessions never edit this comment.
[-]Large regions load reliably[/-][+]The whole atlas loads, and keeps loading as it grows[/+]sydevs-bot commentedon Oct 8, 2026
Technical notes
Intake review, 2026-10-08. Three lenses plus read-only production measurement. Edited in place on later runs — not a conversation.
What exists today
There is no region-scoped read.
grep -n "where:" src/config/api/fetch.tsreturns nothing. The widget makes exactly three global reads at boot, allpagination: false:fetch.tsgetRegions:172-182getGeojson→GET /events/geojson:208-216getEventTitles:242-246Every region view is derived from those three cached objects in memory —
getRegion(:420-426),getCountries(:390),getEvents(:540),getCalendarEvents(:574) issue zero requests of their own (indexedFeed,countUnder,boundsUnder,partitionUnderinsrc/lib/shape). So opening Brazil and opening a one-class city cost identical requests and identical bytes. The recorded position behind this isdocs/rules/data-layer.md:104— "Treat paging as a render budget, not a network one."The feed is also edge-cached:
cache-control: public, max-age=300, s-maxage=300,vary: Authorization,Cache-Tag: events,regionswith purge-on-write (SahajCloud src/plugins/cache/). Unmentioned by #253, SahajCloud#887 and SahajCloud#889. Any new feed shape must keep it.Measured in production, 2026-10-08
Read-only
GET https://cloud.sydevelopers.com/api/...with the routine'sSAHAJCLOUD_API_KEY. This settles the open question #253 and SahajCloud#889 both carry.totalDocsregionsevents(titles)GET /events/geojsonHierarchy: 34 country, 100 region, 460 city, 52 venue. 25 of the 34 countries have at least one class (
CountriesViewhides the empty nine). Largest country Brazil 81, then United Kingdom 48, Australia 46, France 35, Canada 34. Largest region South East (GB) 25; largest city London 18. All 452 events resolve to a country — no orphans.Cold vs warm, measured: geojson 2.12 s cold (
cf-cache-status: MISS) against 0.18 s warm; regions 0.48 s / 0.16 s; titles 0.34 s / 0.33 s. ~87 KB compressed for all three.Consequence: at
MAX_CLIENT_LIMIT = 2000, #253's page loop fetches exactly one page per read. Zero extra requests, zero latency change, no user-visible improvement. The corpus must grow ~3.1× (regions) or ~4.4× (events) before a second page is ever fetched. #253 is a compatibility change, not a performance change.Neither cap exists in production yet —
limit=2000and a 646-rowlimit=0both return 200. SahajCloud PR #890 is open, unmerged,mergeable_state: blocked, review requested from Ardnived.⚠
pagination=falsewith an explicitlimitreports pagination metadata that liesVerified against production twice, on
regions:With pagination off, the envelope reports
totalDocsequal to the page size andhasNextPage: false. A page loop using that shape would be told, forever, that it already has the whole atlas — the silent-partial-atlas failure, reached by the shape that looks safest.This matters to two open tickets and is recorded on neither:
pagination: falseSahajCloud reads #253 must sendpaginationon and pay the per-pageCOUNT. Its own note thatpagination: falseskips theCOUNTreads as an invitation to keep it off.pagination=falsewith a non-zerolimitis unaffected" blesses exactly this shape. It is defensible for SahajCloud's own internal reads, which never page — but it must not be the shape the widget adopts, and the trap belongs in that ticket's body.⚠ The second blocker, and a cost nobody has written down
SahajCloud#889 already records that #253 alone does not unblock the refusal:
loadRegionTree(SahajCloud src/lib/atlas/regionTree.ts:122-137) is itself a whole-tableregionsread withpagination: false, on the caller's ownreq, triggered by the virtualwebPath/webUrlfields.FEED_SELECTselectswebPath(fetch.ts:119) andREGIONS_SELECTselectswebPath+webUrl(:138-139), so the widget triggers it on every feed read. Fix isasTrustedReq(req)at three sites, inside SahajCloud.The cost consequence is not recorded anywhere. That read is memoised per request (
regionTree.ts:171,memoizeOnRequest). So splitting the feed into N pages means N whole-table region scans server-side where there is one today. A goal whose first line is about loading should not be approved over a change that multiplies the server's work by the page count. It does not bind at one page, but it is the reason a precomputed feed (below) is the better server-side answer if the corpus grows.Build vs buy, weighed
infiniteQuery(already a dependency,@tanstack/[email protected]): gives the bounded walk and early break for free, but the walk is strictly sequential, and the cache entry becomesInfiniteData<T>.['geojson']has six direct call sites (Map.tsx:254,SearchFilters.tsx:177,use-country-site.ts:42,FilterView.tsx:49,CountriesView.tsx:53,views/shared.tsx:424) that all consumeGeojson. No — but steal itspages-with-early-break semantics as the cap's shape.@payloadcms/sdk/ Payload core: nofindAll, andpagination.maxLimitdoes not exist in[email protected](established on SahajCloud#887). Nothing to buy.[email protected]wraps rawfetchand reads Link headers — cannot wrapsdk.find, and SahajCloud returns pagination as JSON foreign members.payload-rest-clientis a competing SDK, last published 2025-02. Build the ~20-line loop, as refactor(api): paginate the threepagination: falseSahajCloud reads #253 specifies.Map.tsx:473-483,cluster: true). Load-bearing detail:Map.tsx:326-339filters in JS before clustering so bubble counts match the list. Nothing to do, and a layer-levelfilterwould break that.countUnder,boundsUnder, the uncapped distance ranking (feat(widget): instrument event surfaces + evaluate TelemetryDeck #51), calendar expansion andbuildRegionMatcherall read the whole feed, andmatchesFiltersreads recurrence against today's date, which is not expressible as a Mapbox filter. Plus a publish pipeline and loss of theCache-Tagpurge path. No — recorded so it is not re-proposed.GET /events/geojsonalready forwardswhere(SahajCloud .../geojson.ts:93-104), so the fetch needs no server change. What blocks it is the aggregates: per-region counts and bounding boxes are derived from the global feed, and SahajCloud has no count or aggregate endpoint. This is the named successor if growth demands it, not this goal.GET /api/atlas/feed, rebuilt on write, same purge tag): the best server-side lever if one is ever needed — one cheap bounded request, and it retires the virtual-field cost above. Hold; no measurement says the cold read is a problem./countper region: 595+ requests. No.Risks
Map.tsx:252usesuseQuery, and{filtered && <Source>}at:472-483gates the layer), while the drawer shows the error panel (CountriesView.tsx:37isuseSuspenseQuery→ boundary atApp.tsx:89→classifyError5xx →server→ "Our servers are having trouble right now." with Try again and Report,Fallbacks.tsx:191-201). So "broken or empty map" was accurate, for a reason unrelated to region size.grep -rn "AbortSignal\|AbortController\|signal:\|timeout" src/config/api/ src/config/query-client.tsreturns nothing. WithMAX_QUERY_RETRIES = 1the spinner window on a slow-but-not-down origin is two full origin waits. Unmeasured — settling it needs a deliberately stalled origin against a preview, not production. This is the one fact this run could not settle.(client, IP)at the edge, against ~6 requests for a cold boot.cloud.sydevelopers.comis already indocs/embedding.md'sconnect-src(:794),EventFeatureCollectionalready types the pagination members (src/types/payload/response-types.ts:39-51), and nothing is host-observable — so noCHANGELOG.mdentry and nodocs/embedding.mdedit.Children, and the order they must ship in
Three sub-issues are attached: #253 (Task, Priority High — the widget-side child, implementation-ready apart from the
pagination-on correction above), sydevs/SahajCloud#889 (Feature,blocked— the refusal plus the three internal reads #253 cannot reach), and sydevs/SahajCloud#887 (Bug, with PR #890 open).⚠ Two cautions on that set. #887's 500 comes from a hand-crafted out-of-range
limit/page, a shape the widget never sends, so counting it as part of this goal overstates what region size has to do with it. And #253 isHighwhile this goal isMedium: its deadline is API compatibility with a breaking change shipping to a widget on host domains we do not deploy, which is not a performance concern.Rollout order, from SahajCloud#889 — not optional, and step 3 is SahajCloud's:
pagination: falseSahajCloud reads #253 merges and deploys.pagination: falsereads getasTrustedReq.This run attached nothing and requested no replan. The children were attached outside it, between two reads of the ticket. No replan was asked for because open question 1 may close or re-aim this goal, and planning against a shape still in question would churn three tickets, two of them in another repo. Answer the questions first.
Where the lenses disagreed
Scope modelled 653 events / 595 regions from the committed seed extract (
SahajCloud seeds/atlas/data/); the production measurement above says 452 events / 646 regions. Production holds — the seed is a 2026-08 legacy extract, and a client read is filtered to published and not-finished, which is exactly what a visitor sees. Regions have grown past the seed; events read lower because of that filtering. The conclusion is unchanged either way: both numbers sit far under 2000.Sketch of a split, if question 1 answers A
The three children already cover the mechanical work. The only piece not covered by an open ticket is the never-silently-partial guarantee, and it needs a child of its own only if question 2 answers A and the current behaviour does not already satisfy it.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
pagination: falseSahajCloud reads #253sydevs-bot commentedon Oct 8, 2026
Reviewed from the code and measured against production. The premise does not hold: there is no region-scoped request. The widget fetches the whole atlas once and derives every region from it in memory, so a large region and a one-class city cost identical requests. All three original success lines were unverifiable.
Settled the row count #253 and sydevs/SahajCloud#889 both have open: 452 classes, 646 places, largest country Brazil with 81. Each read fits one page of the agreed 2,000, so that work adds zero requests. It is a compatibility change, not a performance one.
Retitled, and rewrote the body around the real risk: never showing a half-empty atlas once whole-table reads are refused. Your 2026-10-06 decision is recorded under
## Decisions. Measurements, two hazards neither ticket records, and the rollout order are in the notes comment.Three decisions need you — see
## Open questions. Reply@sydevs-bot revise 1A 2A 3A, or in your own words.Then
@sydevs-bot implementplans the implementation tickets.🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
sydevs-bot commentedon Oct 11, 2026
A page walk is not immune to the matching set changing between pages. Found while implementing #253, recorded here because it only bites past one page.
#253's walk reads page 1, then pages 2…N by
OFFSET.walkSortgives the order a unique tiebreaker, which fixes ties, not mutation. Above 2000 rows:schedule.lastDatebetween two page reads shifts the offset, and one event vanishes from the feed.Neither raises an error. Keyset paging (
where[id][greater_than]) is immune and suits the twoid-sorted reads, but it is sequential, andgetRegionscannot use it while it sorts bynamefor display.At 646 regions and 452 events the second page never executes, so nothing is wrong today. It becomes real at roughly 4× growth, which is this goal's subject.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
sydevs-bot commentedon Oct 11, 2026
A decision came up while working on sydevs/SahajCloud#889. It is in Open questions above, with options and a recommendation.
🤖 sydevs dispatcher
Ardnived commentedon Oct 21, 2026
Answered in the terminal by @Ardnived:
pagination: falseSahajCloud reads #253 (merged) and feat(api): refuse an unbounded client read, once the Atlas widget paginates SahajCloud#889, and the answers below are carried there.Closing this goal: its work is #253 (merged) and sydevs/SahajCloud#889, which now carries these answers.