Skip to content

fix(map): let a geocoder mount ask Mapbox for a storable answer - #407

Merged
sydevs-bot merged 5 commits into
mainfrom
claude/fix-404-permanent-geocoding
Nov 14, 2026
Merged

sydevs-bot merged 5 commits into
mainfrom
claude/fix-404-permanent-geocoding

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • MapSearch takes a permanent prop, so a geocoder mount whose answer is submitted to SahajCloud can ask Mapbox for a result its terms allow storing (fix(mapbox): move every stored geocode to Geocoding v6 permanent SahajCloud#893).
  • Absent by default: the header search field and reverseGeocode stay temporary, and nothing visible changes today.
  • Joined: docs/rules/mapbox.md gains the rule, so a future second geocoder mount reads it without opening MapSearch.
  • Joined: country, spread the same way, gains the spec case it never had.

Change outline

The prop is the whole change. Permanence belongs to the caller because one component serves both plain map browsing and the submit flow, and only the second may keep what it gets back.

 MapSearch                                     src/components/organisms/Mapbox/MapSearch.tsx
   props: onSelect, label
+        permanent?                            # absent by default
   <Geocoder options={…}>
     language, country?, proximity, types
+    permanent?                                # spread only when the prop is set
+      permanent: false would serialize        # so absent, never `false`

 SearchField                                   src/views/shared.tsx
   <MapSearch label onSelect />                # passes none — unchanged, and now pinned

 reverseGeocode                                src/lib/geocode.ts
   language, limit, types                      # unchanged; docblock says why it stays temporary

Preview

Preview pending — the CI smoke job publishes the pr-<n> Workers alias, and the Cloudflare branch alias appears on this PR once it deploys.

This change is not visible on a preview, and that is not a gap. The one mount a preview can reach is the header search field, whose request is byte-identical to main — worth confirming it still carries no permanent, but it is the unchanged direction. The mount that does ask for permanence lives on #318's branch (see Notes), so nothing on this branch issues a permanent lookup for a preview to show. No wait for the deploy was taken for that reason.

Test results

  • Lean gate: ✓ lint, typecheck, 169 files / 2070 tests
  • New spec: 4 cases, each watched failing against its own reintroduced defect
    • spread removed → expected undefined to be true
    • permanent: permanent ?? true → both absence cases red
    • SearchField given permanent → the header case red
    • country spread removed, and the key written countryy → the country case red both ways, while pnpm typecheck stays green
  • Build / pnpm size: left to CI (no bundle-shape change — one branch and a ≤1-key object copy)

Manual verification

  1. On the preview, type a place in the header search field and confirm its api.mapbox.com/search/geocode/v6/forward request carries no permanent parameter.
  2. Use "Find my location" and confirm the reverse request carries no permanent either.
  3. The positive direction cannot be walked here — it needs feat(widget): submit or correct a class, and opt into a mailing list #318's add-a-class address step. Its checklist line is in fix(map): ask Mapbox for a permanent answer where the id is stored #404.

Notes for reviewer

Detail

Review passes. /simplify (4 angles) and /code-review high; pr-review-toolkit is not installed here. /security-review skipped — the diff matches neither securityReview.triggerPattern nor contentPattern. comment-lint.mjs: no banned comment added.

Applied. Three of four /simplify angles independently found the same thing: "permanent means storable, and bills separately" was stated four times across three files. The prop docblock keeps it; the spec preamble, the spec's inline note and the reverseGeocode paragraph shrank to the clause a reader cannot re-derive (0cb8993). The docs/rules/mapbox.md section was the altitude angle's own finding before it found it already written (4025c80). The adversarial review then took the same line one step further: the section's two ⚠ paragraphs restated the call-site comment, and one keeps the policy (54a4246).

Dismissed, with reasons.

  • /code-review: add satisfies Partial<GeocodingOptions> to the options literal to restore the excess-property check. Verified not to work — with satisfies, the misspelled key inside the conditional spread still compiles; without it, likewise. The finding's diagnosis is right and its fix is not, so the hole is documented instead (see Notes).
  • /simplify ×3: drop the SearchField case; the type already forbids SearchField passing permanent. It does not — Pick<MapSearchProps, 'label'> constrains what callers hand SearchField, not what SearchField hands MapSearch. Reintroducing that defect turned the case red, and it is acceptance criterion 4's second half. Its measured cost is +1.1s on this spec and src/config/i18n.ts's per-edit selection 13 → 14 specs (5.88s → 6.65s against a 12s budget). The pinned widest selection (src/test-support/repo-source.ts) stays 21/21 — the spec names neither walker.
  • /simplify: replace optionsOf's hoisted array with vi.fn() + toHaveBeenCalledOnce(). A wash on lines, and mock.calls[0][0] needs its own annotation. Declined.
  • Altitude: extract a pure geocoderOptions({ locale, scope, permanent, … }) builder beside searchBias. It would move the mount → options coupling out of the component, so the spec could no longer assert what the mount sends, which is what criterion 4 asks for. Declined; the angle offered it as decline-able.

Verified against the installed source, not inferred. @mapbox/[email protected]'s geocode query builder lists permanent: e.permanent among the forward and reverse parameters, and its serializer skips only null / undefined — so permanent: false would reach the request as a parameter, which is why both it and country are spread conditionally. permanent?: boolean is at GeocodingCore.d.ts:86 and options?: Partial<GeocodingOptions> at Geocoder.d.ts:43, so no cast is involved.

Fixture pre-mortem. The spec's one assumption is that <Geocoder>'s options prop is the only place permanent is observable from a mount. Checked against node_modules/@mapbox/search-js-react/dist/components/Geocoder.d.ts (options?: Partial<GeocodingOptions>) and the core query builder above. The mock stubs Geocoder alone; every other vi.mock in the file exists to keep the node lane off mapbox-gl, react-map-gl and i18next's boot, and each has precedent in a sibling spec.

Non-vacuity. optionsOf throws unless exactly one geocoder mounted, so neither not.toHaveProperty assertion can pass for want of a render — the trap docs/testing.md records for absence assertions. The country case reaches searchCountryScope through the harness's own MemoryRouter, by the route it is given, so both of its directions come from the component rather than the fixture.

Part of #404


Generated by Claude Code

SahajCloud stores the Mapbox feature ids a client sends with a proposal, and
its client contract now requires those ids to come from a `permanent=true`
Geocoding v6 lookup (sydevs/SahajCloud#893). Mapbox's terms allow keeping an id
only from such a lookup, and bills it separately — so permanence belongs to the
caller, not to the control: one component serves both plain map browsing and the
submit flow, and only the second may store what it gets back.

`permanent` is therefore a `MapSearchProps` prop, absent by default, spread into
the `<Geocoder options>` block the same way `country` is — left out rather than
passed as `undefined`, since the geocoder serializes whatever it is handed.
`options` is `Partial<GeocodingOptions>`, which declares `permanent`, so no cast
is involved and a renamed option fails to compile.

`reverseGeocode` stays temporary: its answer fills the search field and `?cc`,
never a row SahajCloud keeps.

Refs #404

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

Three review passes found the same thing: "permanent means storable, and bills
separately" was stated four times over three files. The prop docblock keeps it;
the rest shrink to the clause a reader cannot re-derive.

A conditionally spread option also turns out not to be checked for its name.
TypeScript applies the excess-property check to a literal's own keys, never to
one spread into it, so a misspelled `permanent` compiles clean — and `satisfies
Partial<GeocodingOptions>` on the literal does not close it either, measured
both ways. A plainly written key does fail (TS2561). So the spec, not the type,
is what holds this option, and the comment says so where someone would
otherwise trust the compiler.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWJYfynaSBQf48tfqn
Two docblocks inside `MapSearch` and `reverseGeocode` are only read by someone
who opens those two files. `docs/rules/mapbox.md` loads for anyone editing the
Mapbox directory, which is where a second geocoder mount gets added.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWJYfynaSBQf48tfqn
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 13, 2026
@sydevs-bot

sydevs-bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 23:03Z address-review · attempt 1 · session · done
  • 23:03Z address-review · attempt 1 · session
  • 22:55Z review-pr · attempt 1 · session · done
  • 22:55Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 13, 2026

@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

The functional change is two lines, and that is the right size. Decision 1A made permanence a prop, and #404's Notes route the mounts to #318, so a prop with no mount here is not an unused knob.

One gap outranks the code. Closes #404 closes a ticket meeting 3 of its 5 criteria, and criterion 1 is the storage-terms breach the ticket exists to fix. Nothing open records the remainder — neither #147 nor #318 mentions permanent. Merge this and #318's PlaceField ships without the prop, with nothing left saying it should not.

The other 90 added lines are prose about one option, in five places.

Findings

  • should-fix — Closes #404 should read Part of #404. It sits in the body, so no thread.
  • should-fix — MapSearch.tsx:182 claims more coverage than the spec holds.
  • consider — docs/rules/mapbox.md:372-382 restates the call-site comment.

What was checked

Read whole on the branch: MapSearch.tsx, SearchField (views/shared.tsx:258), geocode.ts, the new spec, the mapbox.md section and its paths:.

Verified against installed @mapbox/[email protected], not the body: permanent?: boolean at GeocodingCore.d.ts:86, options?: Partial<GeocodingOptions> at Geocoder.d.ts:43, and the query serializer pushes every non-null value. So permanent: false would reach the request, and the conditional spread is right.

Ladder on the one new file: 20 sibling specs render with renderToStaticMarkup, and nothing on main mocks search-js-react, so no harness was duplicated. The SearchField case is non-vacuous — Pick<MapSearchProps, 'label'> binds callers, never the body.

docs/embedding.md needs nothing — no origin or CSP changes.

Searched open items naming permanent: #404, #407, #258 alone. No preview link was posted, and this repo seeds none.

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


Generated by Claude Code

Comment thread docs/rules/mapbox.md Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Nov 13, 2026
`country` is spread the same way `permanent` is, so the excess-property
check misses its name too — but only `permanent` had a case, while the
call-site comment and `docs/rules/mapbox.md` both claimed the spec held
whatever is spread there.

The new case pins both directions through the route, since `country`
comes from the pathname. Watched red twice: with the spread removed, and
with the key written `countryy`, which `pnpm typecheck` accepts.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYQRgweYgmyXPxYWBF
The two ⚠ paragraphs restated `MapSearch.tsx`'s own comment, and this
file's `paths:` loads it beside that file — so both reached one reader at
one moment. What a future mount needs is the policy: spread an optional
option, and give it a case. The `permanentt` demonstration and the TS2561
citation justified the call-site comment, which stands without them.

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

Copy link
Copy Markdown
Contributor Author

Addressed the adversarial review. Base was already current, so nothing was merged.

Adopted.

Lean gate: ✓ lint, typecheck, 169 files / 2070 tests. PR body refreshed: 4 spec cases, and why the ticket stays open.

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


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 13, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review November 13, 2026 23:14
@sydevs-bot
sydevs-bot requested a review from Ardnived November 13, 2026 23:14
@sydevs-bot
sydevs-bot enabled auto-merge November 13, 2026 23:14
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 13, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 14, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 14, 2026
Merged via the queue into main with commit d8ce3c0 Nov 14, 2026
52 of 56 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-404-permanent-geocoding branch November 14, 2026 17:32
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 14, 2026
Ardnived added a commit that referenced this pull request Nov 16, 2026
main now threads `permanent` through `MapSearch` (#407), and SahajCloud's
client contract requires the Mapbox ids a proposal sends to come from a
permanent lookup (sydevs/SahajCloud#893). `PlaceField` is the flow's only
geocoder, behind both the address and the online city, so the option goes
on its one mount, as #404 decision 1A set out. The header field stays
temporary; `MapSearch.permanent.test.tsx` holds that half.

Watched the new case fail with the prop removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

3 participants