Repository navigation
fix(mapbox): move every stored geocode to Geocoding v6 permanent - #1150
Conversation
Search Box publishes no `permanent` parameter, so nothing it answers may be stored — and `Regions.mapboxId`, the admin picker's value and the Atlas import's centroids all are. Every lookup whose answer is persisted now runs against Geocoding v6 with `permanent=true`. v6 carries no POI layer, so a venue is placed by its postal address through the structured lookup the bulk event import already uses, and keeps its legacy Atlas coordinates when the match is coarser than a door. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjUwvQcsEv52DC14hSY
`AddressSearchField` is a `'use client'` module, so every export of it reaches a server module as a client reference and nothing in it can be unit-tested. The response mapping — the part that moved when the picker left Search Box — now lives beside it as plain data. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjUwvQcsEv52DC14hSY
`regions.mapboxId` is now written by Geocoding v6, so a client picking through Search Box matches nothing — and a venue carries its address's id, because v6 holds no POI layer. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjUwvQcsEv52DC14hSY
|
🚅 Deployed to the SahajCloud-pr-1150 environment in sahajcloud
1 service not affected by this PR
|
Both query builders now start from `baseParams`, so a lookup that does not carry `permanent` is one that cannot be built — the file's headline claim was otherwise enforced by two copies of a string literal. `doorMapboxId` does the same for the rule that only a `feature_type` of `address` may be stored, which the bulk importer spelled separately. A shared venue was geocoded twice with what is now a byte-identical query: the region pass never seeded `venueMapbox`, so the events pass paid for it again, once per shared venue, each a billable permanent geocode. A source-reading spec holds `permanent: true` on the admin picker. Nothing type-checks it — `@mapbox/search-js-web` owns the props and is not a direct dependency, so the mount is a hand-written interface behind a dynamic cast. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjUwvQcsEv52DC14hSY
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is the size of #893 and no larger. Four Search Box writers move to v6 permanent, the venue behaviour change is the one the ticket predicted, and the three joined pieces — the double geocode, the contract line, the migration plan — are joins the rule allows. Record<GeocodableLevel, string> and the single baseParams are the right shape: the invariant is structural, not a literal spelled twice. Two things do not hold. The browser path's permanence is guaranteed by a hand-written interface and a source grep, when the library's own types would check it. And the Events picker quietly gained place, which #893 did not ask for and which the importer next door refuses.
Findings
should-fix—AddressSearchField.tsx:43: the props cast is whypermanent: trueis unverifiable;@mapbox/search-js-reacttypes it.should-fix—addressFields.ts:87:placeis new scope, and stores an iddoorMapboxIdrejects.consider—api-clients.md:94: the client obligation has no consumer-side ticket.
What was checked. Read whole on the branch: geocoder.ts, AddressSearchField.tsx, pickedPlace.ts, addressFields.ts, Regions.ts, import.ts, and the three specs. Ladder — pickedPlace.ts follows tests/AGENTS.md and src/components/admin/helpers/; venueAddress and doorMapboxId have two callers each; baseParams removes a duplicate. Unpacked @mapbox/[email protected] and @mapbox/[email protected] to confirm Geocoder's props and GeocodingOptions.permanent. Consumer side: SahajAtlasWeb MapSearch.tsx and lib/geocode.ts. Confirmed no types value still names poi, and venueMapbox is keyed on legacyId in both passes. Previews unreachable: seedsPreviews is false and both Access halves are unset here, as the body says.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`permanent: true` is this PR's whole effect in the browser, and a hand-written props interface behind the `next/dynamic` cast meant the compiler never saw it: a renamed or dropped option shipped green. `@mapbox/search-js-react` types the props already, so take them from there. A renamed option now fails to compile. A dropped one still does not — `permanent` is optional — and no type says which component was mounted, so `mapbox-permanent-mounts.spec.ts` stays and its docblock now states which half it still owns. `MapboxGeocodingFeature` keeps its own shape so a spec can build one, but the mount now checks it against the library's `GeocodingFeature`, which carries GeoJSON's `number[]` position. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVkLvnvWuKip4Mp4Xj
#893 asked for `poi` to go; `place` arrived in its stead, and it is new scope. `readPickedPlace` has no street above the `address` context layer, so it falls back to the feature's own name — picking a town wrote that town into `street`. The CSV importer fills the same column for a door alone (`doorMapboxId`), so a town's id there is one column carrying two identities. The picker now offers `address,street`, matching the Regions venue row, and the component's own fallback default follows. A new unit spec reads the offered layers off the built group, so the next widening fails. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVkLvnvWuKip4Mp4Xj
|
Three critic threads, all settled.
Gate: lint, format, both typechecks, 280 unit files / 3846 tests. Body refreshed: the Summary names the picker's narrowed scope as a second behaviour change. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
The server geocoder and the admin picker each hand-wrote a subset of the same Geocoding v6 feature, in two trees, under two names. One lives in src/lib/mapbox/feature.ts now, beside the code that asks Mapbox for it. The library's own GeocodingFeature cannot replace it, and the new file says why: @mapbox/search-js-core is not a dependency here and search-js-react re-exports none of its geocoding types; its GeocodingFeatureContextComponent declares neither region_code nor country_code, which the picker reads; and it declares every field required, which a raw fetch body is not. What keeps ours compatible with theirs is the picker's own mount, where onRetrieve is typed (feature: GeocodingFeature) => void. Verified by narrowing coordinates to [number, number]: tsc then refuses the mount, naming GeocodingFeature as the shape it no longer accepts. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVxY9Yi88gS5oyFRYu
doorMapboxId said "door" for what Mapbox calls an `address` feature, and "door" already means an entry point in a dozen comments across this repo — so the name read as being about a seam rather than about a street number. It is addressFeatureMapboxId now, after the `feature_type` it is the whole test for, and the same metaphor is gone from the prose that explains the rule at the picker, the Events field and the two specs. No behaviour changes: the guard still returns the id for an `address` match and null for every coarser one. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVxY9Yi88gS5oyFRYu
geocoder.ts spelled the `manual` string itself and said in prose that it "matches AddressSearchField", while manualLocation.ts next door declared the same literal as MANUAL_PREFIX and owns the two spellings that count as hand-entered. seeds/atlas/import.ts already imported one name from each file. MANUAL_LOCATION now derives from MANUAL_PREFIX, so the resolver's answer and the detector cannot drift apart. The name stays: the resolver answers the bare sentinel and its caller makes it unique, which is a distinction worth keeping at the call sites. typeof MANUAL_LOCATION is still the 'manual' literal, so RegionLocation is unchanged. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVxY9Yi88gS5oyFRYu
|
Your four threads, all answered.
Three stay open on one fact each, yours to settle: Gate: lint, format, both typechecks, 281 unit files / 3855 tests. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Approved, but this thread still waits on you, and the ruleset will not merge until it is resolved: #1150 (comment). Reply there, or resolve it. 🤖 sydevs dispatcher |
Summary
permanent=true. Search Box publishes no such parameter, so nothing it answered could legally be stored.venuehas no v6 layer of its own, so it is placed by its postal address and keeps its legacy Atlas coordinates when the match is coarser than anaddressfeature.address,streetwhere it offeredaddress,poi. A manager can no longer pick a town there:populateAddresswrote that town into the siblingstreet, and the CSV importer fills the same column only for anaddressmatch.manualsentinel once for both modules, anddoorMapboxIdis namedaddressFeatureMapboxId.Change outline
Flow — how a region node reaches an id
The endpoint moves, and
venueleaves the name-based path entirely.Behaviour — where permanence is decided
Both builders target one endpoint now, so the invariant is structural rather than two copies of a literal: a lookup that does not start from
baseParamscannot be built.Types — the level vocabulary
v6 has no POI layer, so
venueis no longer a level thetypestable can answer for. The type says so rather than a comment, and a newRegion.levelfails to compile here.Types — one v6 feature shape, beside the Mapbox code
Both readers of a v6 answer hand-wrote their own subset of the same feature, in two trees under two names. One declaration now, where the code that asks Mapbox for it lives.
The library's own
GeocodingFeaturecannot stand in, andfeature.tssays why:@mapbox/search-js-coreis not a dependency here and@mapbox/search-js-reactre-exports none of its geocoding types; itsGeocodingFeatureContextComponentdeclares neitherregion_code/region_code_fullnorcountry_code, which the picker reads; and it declares every field required, which a rawfetchbody is not. The picker's mount is what keeps the two compatible —onRetrieveis typed(res: GeocodingFeature) => void, so a shapeMapboxFeaturestops accepting fails to compile there.Components — the admin location picker
<SearchBox>cannot be asked for a permanent answer, and<Geocoder>hands back one feature rather than a{ features }envelope. Its props come from the library, sopermanentis type-checked rather than declared locally.Types — what the Events picker may offer
readPickedPlacehas no street above theaddresscontext layer, so it falls back to the feature's own name. Anything coarser than a street therefore lands in the siblingstreet.Flow — one geocode per shared venue, not two
Both venue paths now build the same URL, so the events pass can be handed the region pass's answer. Before this branch they asked different questions and neither could reuse the other.
importSharedVenues(venue) seeds/atlas/import.ts resolveRegionLocation({ level: 'venue', address: venueAddress(venue) }) + venueMapbox.set(venueId, …) # the events pass reads this importEvent(event) resolveVenueMapbox(venue) - geocodeVenue(…) # same query, paid for twice + venueMapbox hit → no requestContract — what a client's proposal ids must be
regions.mapboxIdchanges id space, whichresolveProposalRegionmatches against. Nothing in the hook changes; what a client may send does.docs/rules/api-clients.md § proposal placement proposed.address.mapboxId + location.{placeId,regionId,countryId} → regions.mapboxId +a Search Box id matches nothing +a venue carries the id of its address, so a POI id falls through to the city +those ids are stored here, so the client owes a permanent lookup for them tooNo client writes those ids today (SahajAtlasWeb's form submits no
proposedpatch), so nothing regresses now.Preview
level: venue, now offering addresses rather than POIsData: CI fills every preview from
seeds/preview-fixture/data.json. This session holds neither half of the Cloudflare Access service token (PREVIEW_ACCESS_CLIENT_IDandPREVIEW_ACCESS_CLIENT_SECRETare both unset), so it could not open the preview to confirm the fill or the row ids each link names.Test results
event-imports.int.spec.ts+regions.int.spec.ts, 47 passed, re-run afterorigin/mainwas merged in againEvery new assertion was watched failing against its own defect first: the endpoint reverted to Search Box (2 cases), the
featureType === 'address'rule dropped, the street guard dropped, the venue branch sent back through the name lookup (3 cases), the street read restored to Search Box'sproperties.addresskey,permanent: trueremoved from the picker's mount, andplacerestored to the Events picker'ssearchTypes.The shared feature type carries no assertion of its own, so the coupling it claims was confirmed the same way: narrowing
MapboxFeature'scoordinatesto[number, number]makestscrefuse the picker's mount, namingGeocodingFeatureas the shape it no longer accepts.Manual verification
pnpm seed atlas --dry-runagainst a local target, withseeds/atlas/data/built. Confirm acountry, aregionand acityreach a real id, and read what eachvenuereports — a venue whose address Mapbox does not hold now goes manual with its legacy coordinates instead of matching on the building's name.cityregion in the admin: results appear, the siblingnamefills, and the savedmapboxIdis not amanual-id. Then an Events address: street, city, region, country, postCode, latitude and longitude all fill — and the search offers no town.GET /api/regions?where[mapboxId][not_like]=manual&limit=0against production, against the region count the last refresh seeded (seeds/atlas/data/manifest.json), to decide whether a refresh is enough or a re-pick is owed for rows a manager picked by hand since.Notes for reviewer
manualsentinel, not amanual-<key>one, when a single-use venue's address misses.Events.address.mapboxIdcarries no unique constraint andisManualMapboxIdrecognises both; onlyRegions.mapboxIdneeds a unique value. The venue's own coordinates reach the event throughvenueToEventAddresseither way.venuesearchesaddress,streetin the admin while the importer stores only afeature_typeofaddress. A manager picking a street deliberately stores a coarser identity; the importer never guesses one. The Events address picker now offers the same two layers, for the same reason.@mapbox/search-js-react, sopermanentis type-checked and a renamed option fails to compile.tests/unit/mapbox-permanent-mounts.spec.tsstays regardless: the option is optional, so a dropped line still compiles, and no type says which component was mounted.GeocodingCoreships in@mapbox/search-js-core, and itsforwardtakes free text only —forward(searchText: string, …), carrying its own// TODO: enable structured input alternative arguments. The structured query is the whole point of this branch, so the library's client cannot send it.user-submissions.locationholds Mapbox ids the Atlas widget resolves and this repo stores, so the permanence rule binds them too. The code fix is SahajAtlasWeb's; the contract is stated here, on the field and indocs/rules/api-clients.md. Now tracked as fix(map): ask Mapbox for a permanent answer where the id is stored SahajAtlasWeb#404 — the widget's<Geocoder>andreverseGeocodeboth run withoutpermanent, and so does the branch of feat(widget): submit or correct a class, and opt into a mailing list SahajAtlasWeb#318, the PR that starts sending those ids.Review findings dismissed, with reasons
Four quality lenses ran (
/simplify's reuse, simplification, efficiency and altitude passes). Most findings were applied — the sharedbaseParams,addressFeatureMapboxId,venueAddress, the venue-geocode cache, the export surface, and several over-long comments. These were not:args.level === 'venue'branch with an exhaustiveRecord<RegionLevel, Lookup>. The stated motive was that a newRegion.levelwould slip silently intogeocodeRegion. It would not:TYPES_BY_LEVELisRecord<Exclude<RegionLevel,'venue'>, string>, so a new level fails to compile there. The table would trade one two-line branch for an abstraction over two differently-shaped lookups.types=address. It currently sendsLOOKUP_TYPES.address, whose coarse layers are what let the caller tell "no such street number" from "no such town". Narrowing it would change the bulk event importer, which reads the coarse answer deliberately.SEARCH_TYPES_BY_LEVELshared by the geocoder,Regions.tsandaddressFields.ts. A real option —admin.customships the value, not the module, so no client import is involved — but it is a refactor of three files' public shape that this ticket did not ask for. TheRegions.tscomment now names the importer's table and says where the venue row went instead.GeocodeVenueArgsintoGeocodeLocationArgs. They are deliberately in different vocabularies: the venue type uses the Payload field names its callers hold (street,postCode), the location type the CSV import's (address,postcode).readPickedPlacemaps the address even in the Regions picker's id-only mode. One array scan per click, and only on the branch where Mapbox returned neitherregion_codenorregion_code_full.tests/unit/mapbox-permanent-mounts.spec.tsnow that the props are typed. The type closes the renamed-option half only. Withpermanent: truedeleted from the mount,tscstill exits 0 and that spec goes red; its Search Box case is not a typing question at all.Detail
Why the endpoint is the assertion, not the parameter. Mapbox ignores
permanenton Search Box, so a spec that pinned the parameter alone would be green against an API that never honoured it.expectPermanentV6pins both at every stored call path.Why the centroid fallback moved too. Step 3 of
resolveRegionLocationwrites the coordinates it finds onto the region row, so it is a persisted answer like any other.FALLBACK_TYPESwas already v6 vocabulary, so it carried over unchanged.Why the mapping left the component. Every export of a
'use client'module reaches a server module as a client reference, so nothing declared inAddressSearchField.tsxcan be read by a spec.tests/AGENTS.mdsays to extract the pure part before reaching for jsdom, sopickedPlace.tsis that part and there is no mounted-component spec. The v6 feature shape it reads isMapboxFeature(src/lib/mapbox/feature.ts), which the mount checks against the library'sGeocodingFeature.Why
MANUAL_LOCATIONkeeps its name. The resolver answers the bare sentinel and its caller makes it unique withmakeManualMapboxId, which is a distinction worth keeping at the call sites. Only the literal is shared now, so the answer andisManualMapboxIdcannot drift apart.typeof MANUAL_LOCATIONis still'manual', soRegionLocationis unchanged.No migration. Only
admin.customvalues changed; no column, no enum, no field shape.Closes #893
🤖 Generated with Claude Code
https://claude.ai/code/session_01Mg9rjUwvQcsEv52DC14hSY