Commit graph

1454 commits

Author SHA1 Message Date
Ullrich Schäfer
c3454641df
security: validate Planner callback URL to close an SSRF sink
The session callbackUrl becomes a server-side fetch target in
api.save-to-journal (POSTed with the callback bearer token, and the
journal's response is reflected to the caller). The /new query-param
loader already validated it, but the programmatic POST /api/sessions
entry point — anonymous, since the Planner is stateless — stored it
unvalidated. An attacker could make the Planner backend POST to
arbitrary hosts, including 169.254.169.254 and other internal targets.

- validateFetchUrl now blocks private / loopback / link-local /
  CGNAT / cloud-metadata hosts (IPv4, IPv6, IPv4-mapped) when an
  explicit allowlist isn't set. Gated on NODE_ENV=production && !E2E
  (the requireSecret idiom) so the dev/e2e journal-on-localhost save
  flow is unaffected. An explicit PLANNER_CALLBACK_ALLOWED_HOSTS still
  takes precedence and remains the full-closure control (it also stops
  DNS-name-to-private rebinding, which literal blocking does not).
- POST /api/sessions now validates callbackUrl exactly as /new does.
- api.save-to-journal re-validates immediately before the fetch
  (defense in depth: covers sessions persisted before this change and
  narrows the create→save rebinding window).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 22:18:18 +02:00
Ullrich Schäfer
0d2593a0c4
Merge pull request #508 from trails-cool/dependabot/npm_and_yarn/development-a6ed03596f
chore(deps-dev): Bump the development group across 1 directory with 4 updates
2026-06-10 08:03:55 +02:00
dependabot[bot]
04e86d4308 [github-actions] pnpm dedupe 2026-06-10 05:59:38 +00:00
dependabot[bot]
26c0a2d059
chore(deps-dev): Bump the development group across 1 directory with 4 updates
Bumps the development group with 4 updates in the / directory: [prettier](https://github.com/prettier/prettier), [turbo](https://github.com/vercel/turborepo), [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint) and [@testing-library/react-native](https://github.com/callstack/react-native-testing-library).


Updates `prettier` from 3.8.3 to 3.8.4
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.8.3...3.8.4)

Updates `turbo` from 2.9.16 to 2.9.17
- [Release notes](https://github.com/vercel/turborepo/releases)
- [Changelog](https://github.com/vercel/turborepo/blob/main/RELEASE.md)
- [Commits](https://github.com/vercel/turborepo/compare/v2.9.16...v2.9.17)

Updates `typescript-eslint` from 8.60.1 to 8.61.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.61.0/packages/typescript-eslint)

Updates `@testing-library/react-native` from 13.3.3 to 14.0.0
- [Release notes](https://github.com/callstack/react-native-testing-library/releases)
- [Changelog](https://github.com/callstack/react-native-testing-library/blob/main/CHANGELOG.md)
- [Commits](https://github.com/callstack/react-native-testing-library/compare/v13.3.3...v14.0.0)

---
updated-dependencies:
- dependency-name: "@testing-library/react-native"
  dependency-version: 14.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: development
- dependency-name: prettier
  dependency-version: 3.8.4
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: development
- dependency-name: turbo
  dependency-version: 2.9.17
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: development
- dependency-name: typescript-eslint
  dependency-version: 8.61.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: development
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-10 05:58:57 +00:00
Ullrich Schäfer
e64155b490
Merge pull request #517 from trails-cool/package-shims
Remove the map and ui shim packages
2026-06-10 07:53:57 +02:00
Ullrich Schäfer
f684272eb5
Merge branch 'main' into package-shims 2026-06-10 07:50:17 +02:00
Ullrich Schäfer
5e54f35227
Merge pull request #516 from trails-cool/oauth-flow-module
journal: OAuth connect→callback→resume lifecycle as one module
2026-06-10 07:49:42 +02:00
Ullrich Schäfer
765c9f49a8
remove the map and ui shim packages
Both failed the deletion test in the telling direction:

- @trails-cool/ui: Button/Input/Card had zero consumers — both apps
  roll their own elements inline. The only live part was a 6-line
  styles.css (the Tailwind entry + one keyframe), which now lives in
  each app as app/styles.css.
- @trails-cool/map: MapView and RouteLayer had zero consumers; the
  package was otherwise a re-export of two map-core constants, and the
  two import sites now use @trails-cool/map-core directly. The
  "map components go in @trails-cool/map" convention had drifted long
  ago — the real map components live in apps/planner/app/components.

CLAUDE.md's repository structure and conventions updated to match
reality (including pointing shared-type guidance at the post-#515
sources: db row types, api contracts, Waypoint in types). Dockerfiles
no longer COPY the deleted package manifests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 07:47:59 +02:00
Ullrich Schäfer
bed9362004
Merge branch 'main' into oauth-flow-module 2026-06-10 07:45:35 +02:00
Ullrich Schäfer
5d6749618e
Merge pull request #511 from trails-cool/rntl-v14-async-render
mobile: await render() in smoke test for RNTL v14 compatibility
2026-06-10 07:45:25 +02:00
Ullrich Schäfer
f52de808f5
Merge branch 'main' into rntl-v14-async-render 2026-06-10 07:44:46 +02:00
Ullrich Schäfer
5e70aff9fa
Merge branch 'main' into oauth-flow-module 2026-06-10 07:44:29 +02:00
Ullrich Schäfer
6f366293c9
journal: OAuth connect→callback→resume lifecycle as one module
The PKCE verifier cookie, state encoding, redirect-URI construction,
and code exchange were coordinated across three route handlers that
each knew part of the protocol. Two latent bugs lived in the gaps: a
push-initiated re-authorization skipped PKCE entirely (harmless today
only because the sole pusher, Wahoo, is not a PKCE provider), and the
push-resume callback path never cleared the spent verifier cookie.

oauth-flow.server.ts now owns the lifecycle: initiateOAuthFlow builds
the provider redirect (state + verifier cookie, on every entry path),
and completeOAuthFlow consumes the callback — state decode, verifier
recovery, code exchange, connection linking — returning a
discriminated result the route maps to redirects. The three routes are
thin adapters; the next OAuth provider reuses the flow, not the
pattern.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 07:44:04 +02:00
Ullrich Schäfer
7435353612
Merge pull request #515 from trails-cool/domain-type-unification
One source of truth for Route/Activity shapes; enforce api contracts at the seam
2026-06-10 07:44:01 +02:00
Ullrich Schäfer
06545c8e28
Merge branch 'main' into rntl-v14-async-render 2026-06-10 07:43:16 +02:00
Ullrich Schäfer
362fa11a88
Merge branch 'main' into domain-type-unification 2026-06-10 07:40:07 +02:00
Ullrich Schäfer
61a2d0085b
one source of truth for Route/Activity shapes; enforce api contracts
Route and Activity existed three times: hand-written interfaces in
packages/types, Zod contracts in packages/api, and Drizzle columns in
packages/db — each with different fields and nullability. The
hand-written ones had drifted so far they had zero importers; the Zod
contracts were advisory because v1 handlers hand-rolled Response.json
shapes nothing validated.

- packages/types keeps only what both apps actually share (Waypoint,
  WaypointPoiTags) and documents where row types and wire contracts
  live; the dead Route/RouteMetadata/RouteVersion/Activity interfaces
  are gone
- packages/db exports canonical inferred row types (RouteRow,
  ActivityRow, RouteVersionRow, UserRow)
- packages/api contracts are reconciled with the real wire format
  (RouteVersionSchema gains the id and createdBy fields the endpoint
  has always returned) and gain Create*ResponseSchemas
- apiJson(schema, payload) in api-guard parses every v1 response
  through its contract: drift is now a thrown ZodError in tests/CI,
  unknown keys are stripped, and payloads are compile-checked as
  z.input of the schema

Enforcement immediately caught two real drifts: nullable DB
descriptions could ship null where the contract promises string (now
coalesced at the boundary), and GET /api/v1/activities/:id was missing
the routeName and photos fields its contract declares.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 07:39:50 +02:00
Ullrich Schäfer
ec87445550
Merge pull request #514 from trails-cool/e2e-fixtures
e2e: shared auth + journal seed helpers; flag unregistered specs
2026-06-10 07:36:39 +02:00
Ullrich Schäfer
bcd082dd37
Merge branch 'main' into e2e-fixtures 2026-06-10 07:32:19 +02:00
Ullrich Schäfer
0e267afac7
e2e: shared auth + journal seed helpers; flag unregistered specs
The virtual-authenticator setup and registerUser were copy-pasted into
six spec files and had drifted: the auth spec's copy lost the final
URL assertion, and the settings spec's variant skipped hydration and
the Terms checkbox entirely. Seed-route boilerplate and hardcoded
localhost URLs were repeated across three more files.

- helpers/auth.ts: setup/removeVirtualAuthenticator,
  submitRegistration (no outcome assertion, for expected-failure
  attempts), registerUser (asserts the signed-in redirect),
  registerFreshUser, logout
- helpers/journal.ts: JOURNAL/PLANNER base URLs, seedRoute,
  routeHasGeom, seedKomootConnection
- nine spec files now import the helpers instead of re-deriving them

Found while consolidating: settings.test.ts, explore.test.ts, and
social.test.ts are not matched by any playwright project and have
never run — which is how the settings spec's broken register helper
survived. Registering them (and fixing whatever has rotted) is a
follow-up; the config now carries a warning so the trap is at least
documented.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 07:31:51 +02:00
Ullrich Schäfer
5b2c5d53b5
Merge pull request #510 from trails-cool/gpx-save-stats
journal: gpx-save owns the validate-and-derive step (processGpx)
2026-06-10 07:27:25 +02:00
Ullrich Schäfer
00b61d1ebe
Merge branch 'main' into gpx-save-stats 2026-06-10 07:23:42 +02:00
Ullrich Schäfer
67e976f7cc
mobile: await render() in smoke test for RNTL v14 compatibility
RNTL v14 makes render() async; awaiting it is a no-op on v13, so this
works on both and unblocks the dependabot v14 bump (#508).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 03:29:07 +02:00
Ullrich Schäfer
9a0dae068b
journal: gpx-save owns the validate-and-derive step (processGpx)
createRoute, updateRoute, createActivity, createRouteFromActivity, and
the demo-bot each re-implemented the same choreography after
validateGpx: flatten tracks into [lon, lat] coords for writeGeom and
derive distance / elevation / dayBreaks / description / start time.
The stat derivation lived in a private computeRouteStats in
routes.server.ts that activities couldn't reach, so the two sides had
drifted (activities re-derived inline, with its own start-time logic).

processGpx() in gpx-save.server.ts now owns the whole step: parse +
validate (GpxValidationError as before), coords extraction, and stat
derivation, returning the parsed GpxData so nothing re-parses.
Callers keep their own precedence rules between derived and
caller-supplied stats — routes let explicit input win wholesale, the
activities importer prefers GPX distance unless it is zero. Extends
ADR-0006: the gpx-save module remains the only place that understands
GPX-to-database derivation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 03:28:13 +02:00
Ullrich Schäfer
b901d2710f
Merge pull request #509 from trails-cool/fix-expo-sdk56-version-alignment
mobile: realign native deps with Expo SDK 56 expectations
2026-06-10 03:27:38 +02:00
Ullrich Schäfer
ba64b2cd57
mobile: realign native deps with Expo SDK 56 expectations
Dependabot bumped react-native-reanimated (4.4.1), react-native-
safe-area-context (5.8.0), and react-native-worklets (0.9.1) past the
versions Expo SDK 56 pins, which broke the native iOS build: expo's
Swift macro API drifted between expo-modules-core patches and
expo-crypto stopped compiling (OptimizedFunction macro mismatch).
CI never caught it because nothing compiles native code; the first
EAS build since the SDK 56 upgrade (d627b3c1) failed with it.

Applied `npx expo install --fix` (expo ~56.0.9, reanimated 4.3.1,
safe-area-context ~5.7.0, worklets 0.8.3) + pnpm dedupe, and added
the SDK-pinned native packages to the dependabot ignore list so they
only move via SDK bumps.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 03:24:00 +02:00
Ullrich Schäfer
1a65b40d18
Merge pull request #507 from trails-cool/owned-entity-loading
journal: branded ownership loading for routes and activities
2026-06-10 02:48:21 +02:00
Ullrich Schäfer
e4958419dd
Merge branch 'main' into owned-entity-loading 2026-06-10 02:44:24 +02:00
Ullrich Schäfer
7a1dca378f
journal: branded ownership loading for routes and activities
Ownership was checked ad hoc: some handlers loaded-and-compared
ownerId, some lib mutators enforced it in WHERE clauses and silently
no-op'd for non-owners, and nothing tied the two together. Two real
authorization bugs hid in the gaps: linkActivityToRoute ignored its
ownerId parameter entirely (any logged-in user could relink any
activity), and createRouteFromActivity loaded any activity without an
ownership check (a non-owner could copy a private activity's GPX into
their own route). PUT /api/v1/routes/:id also returned ok:true for
non-owners without updating anything.

ownership.server.ts is now the single enforcement point:

- loadOwnedRoute / loadOwnedActivity (non-throwing, for callers with
  their own error vocabulary) and requireOwnedRoute /
  requireOwnedActivity (throwing data() 404/403 for web handlers; 404
  by default so guessed ids don't leak existence)
- the returned entities carry an Owned<> brand; mutators (updateRoute,
  deleteRoute, deleteActivity, updateActivityVisibility,
  linkActivityToRoute, createRouteFromActivity) now require an
  OwnedRef, so skipping the check is a compile error
- vouchOwnership is the explicit, greppable escape hatch for the one
  non-session authorization path (the Planner JWT callback)
- WHERE ownerId clauses stay in the mutators as defense in depth

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 02:35:00 +02:00
Ullrich Schäfer
d060f7890a
Merge pull request #505 from trails-cool/remove-stray-root-deps
Remove stray root dependencies block
2026-06-10 02:25:03 +02:00
Ullrich Schäfer
45d61082f2
Merge branch 'main' into remove-stray-root-deps 2026-06-10 02:21:48 +02:00
Ullrich Schäfer
1443a82f2b
Merge pull request #506 from trails-cool/jobs-typed-seam
journal: typed job seam + Komoot credentials through the manager
2026-06-10 02:09:26 +02:00
Ullrich Schäfer
855244747c
journal: typed job seam + Komoot credentials through the manager
Two related fixes from the architecture review:

Typed job seam. Job payloads were `unknown` end-to-end: every handler
opened with `job.data as SomePayload`, every enqueue site passed a bare
string queue name and an unchecked object, and a typo meant a runtime
failure in a background worker. packages/jobs gains defineJob(), which
keeps the payload typed inside the handler and performs the
contravariance cast once inside the package. The journal declares all
14 queues and their payload shapes in app/jobs/payloads.ts; enqueue()/
enqueueOptional() and defineJournalJob() key off that map, so enqueue
sites and handlers cannot drift and queue names are compile-checked.

Komoot credential bypass. The bulk-import route enqueued the raw
credentials JSONB in the pg-boss payload, skipping withFreshCredentials
entirely: credentials sat at rest in the job table, were never
refreshed if stale, and markNeedsRelink never fired. The payload now
carries only the serviceId; the handler resolves fresh credentials
through the ConnectedServiceManager at execution time, and marks the
import batch failed (instead of leaving it pending forever) when
credential resolution itself fails.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 02:05:24 +02:00
Ullrich Schäfer
e94e7ac19a
Merge pull request #504 from trails-cool/planner-route-data-seam
planner: typed schema seam for the Yjs document + shared GPX assembly
2026-06-10 01:51:49 +02:00
Ullrich Schäfer
bf0f7f8d9f
Merge branch 'main' into planner-route-data-seam 2026-06-10 01:48:18 +02:00
Ullrich Schäfer
d13abe80d6
Merge pull request #455 from trails-cool/dependabot/docker/apps/journal/node-26-slim
chore(deps): Bump node from 25-slim to 26-slim in /apps/journal
2026-06-10 01:44:39 +02:00
dependabot[bot]
ce5fd6da0f
chore(deps): Bump node from 25-slim to 26-slim in /apps/journal
Bumps node from 25-slim to 26-slim.

---
updated-dependencies:
- dependency-name: node
  dependency-version: 26-slim
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-09 23:41:11 +00:00
Ullrich Schäfer
50ce4e69a0
Merge pull request #456 from trails-cool/dependabot/docker/apps/planner/node-26-slim
chore(deps): Bump node from 25-slim to 26-slim in /apps/planner
2026-06-10 01:39:45 +02:00
Ullrich Schäfer
a2735edd1c
Remove stray root dependencies block
The root package.json carried expo/react/react-native pins since
310f20e (added incidentally while debugging the Android dev server).
apps/mobile pins its own expo, and react/react-dom are governed by
the workspace catalog + overrides, so the block only forced a
parallel Expo 55 / react-native 0.83 tree into the lockfile
(-1569 lines) and pinned react at 19.2.0 next to the catalog's
19.2.7 — the likely cause of the react/react-dom version-mismatch
failures on the @testing-library/react-native bump (#480).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 01:38:27 +02:00
dependabot[bot]
154dccf312
chore(deps): Bump node from 25-slim to 26-slim in /apps/planner
Bumps node from 25-slim to 26-slim.

---
updated-dependencies:
- dependency-name: node
  dependency-version: 26-slim
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-09 23:36:01 +00:00
Ullrich Schäfer
3b9672e0ff
planner: give the Yjs document a typed schema seam
The routeData Y.Map's ~15 string keys (geojson, coordinates,
segmentBoundaries, road metadata, profile, colorMode, baseLayer,
overlays, poiCategories) were read and written raw at ~30 call sites,
each with its own JSON parsing and casts; parseJsonArray existed twice
and waypoint extraction four times. GPX assembly was duplicated between
SaveToJournalButton and ExportButton, so the saved plan and the
exported file could silently diverge.

- new lib/route-data.ts owns the routeData (+ noGoAreas) schema:
  typed read/write, JSON encoding internal, ColorMode moves here
  (re-exported from ColoredRoute for existing importers)
- new lib/gpx-export.ts owns GPX assembly: buildRouteGpx /
  buildPlanGpx / buildDayGpxFiles / hasDayBreaks; multi-day splitting
  becomes a pure, tested function
- waypoint-ymap.ts gains extractWaypoints / extractWaypointData; the
  four hand-rolled copies (use-routing, use-waypoint-manager,
  WaypointSidebar, use-days) now share it, and WaypointSidebar's
  moveWaypoint reuses the round-trip helpers instead of re-listing
  every waypoint field
- all hooks/components consume the seam; no raw routeData key strings
  remain outside route-data.ts

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 01:35:04 +02:00
Ullrich Schäfer
3ce7bf0991
Merge pull request #484 from trails-cool/dependabot/npm_and_yarn/production-e9efbc881e
chore(deps): bump the production group across 1 directory with 30 updates
2026-06-10 01:32:22 +02:00
Ullrich Schäfer
8eeb775f54
Merge branch 'main' into dependabot/npm_and_yarn/production-e9efbc881e 2026-06-10 01:28:40 +02:00
Ullrich Schäfer
06c385f6ac
Merge pull request #503 from trails-cool/fix/prometheus-hup-race
cd-infra: fix Prometheus 3.10 SIGHUP startup kill + add readiness gate
2026-06-09 16:03:37 +02:00
Ullrich Schäfer
92468a7f90
Merge branch 'main' into fix/prometheus-hup-race 2026-06-09 15:59:52 +02:00
Ullrich Schäfer
c9e5166106
Merge pull request #502 from trails-cool/skills-to-agents
Move skills to .agents/skills for cross-agent compatibility
2026-06-09 15:47:15 +02:00
Ullrich Schäfer
e4366d626b
Merge branch 'main' into skills-to-agents 2026-06-09 15:47:04 +02:00
Ullrich Schäfer
59bbbcd520 cd-infra: fix Prometheus 3.10 SIGHUP startup kill + add readiness gate
- Capture container ID before/after 'docker compose up -d' and only
  send SIGHUP when the same container persisted (config-only change).
  A recreated container already loaded the fresh config; sending HUP
  immediately after startup kills Prometheus 3.10 with exit code 2.
- Add Prometheus /-/ready gate alongside the postgres/journal health
  check to fail the deploy if monitoring stack never comes up.
- Observed 2026-06-09: infra deploy left trails-cool-prometheus-1
  Exited (2) for ~2h, causing a Grafana alert storm.
2026-06-09 15:44:50 +02:00
Ullrich Schäfer
19f2275b73 Move skills to .agents/skills for cross-agent compatibility
Skills now live in .agents/skills/ — the standard convention
aligned with Pi, OpenAI Codex, and the Agent Skills spec.

.claude/skills is a symlink back to .agents/skills/ so Claude
Code still discovers them.

Updated CLAUDE.md to document the setup.
2026-06-09 13:31:20 +02:00
Ullrich Schäfer
16375f8050
Merge pull request #501 from trails-cool/refactor/config-directory-mounts
refactor(infra): directory-mount configs so deploys actually apply them
2026-06-09 13:16:29 +02:00