Skip to content

feat(micropub): implement q=geo Location/Venue extension - #372

Merged
davidwkeith merged 2 commits into
mainfrom
feat/micropub-q-geo
Jul 23, 2026
Merged

feat(micropub): implement q=geo Location/Venue extension#372
davidwkeith merged 2 commits into
mainfrom
feat/micropub-q-geo

Conversation

@davidwkeith

@davidwkeith davidwkeith commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

Implements the proposed, default-off Location/Venue (q=geo) extension per the design in #359/#366, closing #354's last open roadmap item. q=geo is a read-only proximity search over an injected, strongly-consistent venue store (createMicropubVenueStore, D1-backed), independent from post storage. Accepts a Geo URI or discrete lat/lon + optional u radius, returns venues ordered by great-circle distance with limit/offset pagination. The geo location suggestion is currently a placeholder that echoes the query coordinates back — no real reverse-geocoding service is wired in.

Follow-up fixes on top of the original commit, addressing review feedback:

  • q=geo is now actually routed from handleQuery (previously advertised in q=config but unreachable — every real request 400ed).
  • Fixed CI lint failures (unnecessary import escape, duplicated union member, three as any casts replaced with a typed distance tuple).
  • Fixed the longitude bounding-box prefilter to correct for cos(latitude), which could otherwise silently exclude in-radius venues at higher latitudes.
  • Replaced the hardcoded example.com venue URL with a real url column (venue URL is immutable identity, per spec).
  • Added colocated unit + HTTP-level test coverage, a changeset, and doc updates.

Packages affected

  • @dwk/micropub

Checklist

  • Read the relevant spec(s) under spec/packages/ and updated them if behaviour changed
  • Added/updated colocated tests (src/*.test.ts)
  • Ran the local CI gate: pnpm lint && pnpm format:check && pnpm typecheck && pnpm build && pnpm test
  • Added a changeset (pnpm changeset) if this touches a publishable package
  • Updated catalog.json / conformance/status.json if this adds a new mountable worker or changes conformance status — not applicable, no new worker and no conformance-status change

Implement read-only proximity search for the Location/Venue feature.

- Add VenueStore with D1 storage for geospatial venue queries
- Implement haversineDistance for proximity calculation
- Parse Geo URIs (geo:lat,lon;u=radius) and lat/lon/u parameters
- Return venues ordered by distance with pagination
- Add venues config option to enable the extension when proposed group is enabled
- Update README with usage examples

Closes #354

@davidwkeith davidwkeith left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling q=geo — the store design (D1 schema, independent from post storage, haversine proximity) is a reasonable shape and matches the spec's intent. However, this isn't mergeable as-is:

  • The feature isn't actually wired up. q=geo is advertised in q=config but handleQuery has no q === "geo" branch, so every real request 400s with unsupported query. See inline comment on handler.ts.
  • CI is red. build-test fails at pnpm lint: an unnecessary escape in the venues.js import path in config.ts, and three @typescript-eslint/no-explicit-any errors in venues.ts.
  • No tests. venues.ts (D1 schema, Geo URI parsing, haversine search, pagination) has no colocated src/*.test.ts coverage, which CONTRIBUTING.md requires for every behaviour change.
  • No changeset for this @dwk/micropub user-visible change.
  • PR body doesn't follow .github/PULL_REQUEST_TEMPLATE.md — missing the Packages affected and Checklist sections CONTRIBUTING.md asks PRs to keep verbatim.
  • A couple of correctness/placeholder issues worth fixing before this ships: the longitude bounding-box prefilter doesn't correct for cos(latitude) (see inline), and venue url is hardcoded to https://example.com/venues/....

Happy to re-review once q=geo is actually reachable from the handler, lint is clean, and tests + changeset are added.


Generated by Claude Code

Comment thread packages/micropub/src/handler.ts Outdated
Comment thread packages/micropub/src/config.ts Outdated
Comment thread packages/micropub/src/venues.ts Outdated
Comment thread packages/micropub/src/venues.ts Outdated
Comment thread packages/micropub/src/venues.ts Outdated
Comment thread packages/micropub/README.md
Comment thread packages/micropub/src/venues.ts
Addresses review feedback on the q=geo Location/Venue extension:

- Actually route `q=geo` from handleQuery (it was advertised in q=config
  but never dispatched, so every real request 400ed).
- Fix CI lint failures: unnecessary escape in the venues.js import path,
  duplicated MicropubVenueStore union member, and three `as any` casts
  replaced with a typed distance-carrying tuple.
- Fix the longitude bounding-box prefilter to correct for cos(latitude)
  convergence, which previously could exclude in-radius venues at higher
  latitudes before the haversine filter even ran.
- Replace the hardcoded example.com venue URL with a real `url` column
  populated by whatever writes venue rows (the composing app's own venue
  system), matching "a venue URL is immutable identity" in the spec.
- Add colocated unit and HTTP-level test coverage (parsing, validation,
  radius/bbox correction, pagination, advertisement gating).
- Add a changeset and clarify in the README/spec that the `geo` suggestion
  is a coordinate-echoing placeholder, not real reverse-geocoding.

@davidwkeith davidwkeith left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review per CONTRIBUTING.md.

Template/title conformance: looks good. PR title (feat(micropub): implement q=geo Location/Venue extension) follows the required Conventional Commits format, the body keeps the Summary / Packages affected / Checklist headings verbatim, and unchecked items carry a one-line reason rather than being deleted — all per CONTRIBUTING.md §6/§7.

One thing to resolve before merge: #373 (fix(micropub): wire up q=geo, fix lint, add tests and changeset) explicitly supersedes this PR — it carries this branch's commit forward plus fixes for exactly the issues a review here would flag (q=geo never actually wired into handleQuery, lint failures, the duplicated MicropubVenueStore | MicropubVenueStore union type, the flat /111000 lat/lon prefilter, the hardcoded example.com venue URL, alphabetic vs. spec-required tie-breaker). Both PRs target main and both close #354, so having them open simultaneously invites a redundant merge or a conflict. Recommend closing this one in favor of #373 (or, if #373 turns out to need more work, closing #373 instead) rather than reviewing/landing both independently.


Generated by Claude Code

Copy link
Copy Markdown
Owner Author

Closed #373 in favor of this PR — both were independent fixes for the same review feedback, and this one's thread is already resolved with CI green. This PR is the one to merge for #354.


Generated by Claude Code

@davidwkeith
davidwkeith merged commit 31f95fd into main Jul 23, 2026
8 of 9 checks passed
@davidwkeith
davidwkeith deleted the feat/micropub-q-geo branch July 23, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants