WFDASH-WEBAPP/docs
Dave 6fd11f4af0 feat(rep-visits): FleetAI tracker adapter, nearby-customer matching, stop detection
Groundwork for the rep visit check-in feature: a rep taps "I'm on site",
the vehicle's tracker position surfaces which customers are there, and
the visit is logged against them.

Pure/unit-testable layers only — no PocketBase writes and no UI yet,
both of which are blocked on schema that has to be added in the PB
admin first. Design doc: docs/superpowers/specs/2026-09-05-rep-visit-check-in-design.md

- lib/visit-matching.ts   rankNearbyCustomers: radius match around a
                          point, rep's own customers first
- lib/visit-stops.ts      detectStops: breadcrumb trail -> stops.
                          Anchor-based clustering rather than a running
                          centroid, which would let a slow crawl chain
                          into one bogus stationary stop
- lib/tracker-parsing.ts  Netstar FleetAI response decoding
- lib/server/tracker-service.ts
                          FleetAiAdapter + FakeTrackerAdapter behind a
                          TrackerAdapter seam. The fake is auto-selected
                          when no credentials are configured, so the rest
                          of the feature builds and tests without vendor
                          access.
- lib/geo.ts              isRealGeoPoint, lifting the Null-Island guard
                          that was inlined identically in customers/[id]
                          and companies/[id]

Three FleetAI conventions drive real code here and are each pinned by a
test: errors arrive as HTTP 200 with a failure envelope; "--" means
"unavailable" and is not null (and for IGN, not false); timestamps are
platform-local UTC+2 with no offset marker, so parsing them naively puts
every fresh fix two hours in the past.

FleetAI has no position-history endpoint, so the design polls
getTokenBaseLiveData (whole fleet in one call) and keeps its own trail.
scripts/fleetai-probe.mjs is a throwaway read-only probe to confirm the
three account-shaped assumptions before more is built on top.

102 tests pass. The 9 pre-existing failing test files elsewhere in the
suite were verified identical on a stashed tree and are unrelated.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 14:22:28 +02:00
..
agents docs(hermes): bump tool count + add 'three quote-creation tools' callout 2026-08-27 07:50:17 +02:00
api-reference feat(quotes): add person_hint for customer resolution in forwarded emails 2026-08-27 11:11:44 +02:00
audit feat(quotes): enhance search functionality and user experience 2026-08-28 20:13:44 +02:00
bugs docs(bugs): add post-mortem for MCP initialize handshake bug 2026-08-05 01:53:02 +02:00
example-quotes feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
pocketbase feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
sops refactor(sops): streamline SOP documents for roles, consolidating content into quickstart guides for easier reference 2026-09-03 17:57:49 +02:00
superpowers feat(rep-visits): FleetAI tracker adapter, nearby-customer matching, stop detection 2026-09-06 14:22:28 +02:00
theme-preview feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
0136daf3-3ebd-4bca-876e-316271a40303.jsonl feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
AGENT_INSTRUCTIONS.md feat: add split-invoice stock PO workflow and supporting tooling 2026-08-07 00:53:29 +02:00
api-mcp-layer.md feat(orders): enhance order retrieval and statistics functionality 2026-08-16 00:51:24 +02:00
core-recheck-matrix.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
counter-pwa.md feat(counter): add standalone counter order PWA 2026-08-13 09:27:20 +02:00
deliveries-n8n-workflow.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
dev-guide.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
django-nextjs-parity-backlog.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
driver-app-data-source.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
migration-audit.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
n8n-ai-insights-prompt.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
n8n-mcp-setup.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
order-items-schema-standard.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
order-workflow-rules.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
orders-first-rollout.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
pricelist-extraction.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
qa-review.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
qa-review.verify.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
quotes-email-monitor.md feat(quotes): resolve customer from person_hint when rep forwards email 2026-08-27 10:45:51 +02:00
SHIPPED.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00
tv-dashboard.md feat(tv-dashboard): enhance TV dashboard with driver stops and performance metrics 2026-08-19 10:16:49 +02:00
wfdash-v5-deployment.md feat(item-history): add getItemHistory service with 5 PB queries 2026-07-29 14:51:58 +02:00