Move runtime artifacts out of the source tree to ~/trips

The dev directory now holds source code + compiled binaries only:
  ~/trips/osm/          OSM PBF extracts (was osm/, 1.4 GB)
  ~/trips/tilecache/    mock tile cache (was mock/.tilecache)
  ~/trips/store/mock/   per-trip uploads + chat logs (was mock/store, PII)
  ~/trips/logs/         server.log
  ~/trips/stale-osm-build/  stale source/tarball dup of ~/osm-build
                           (repo osm/build had no binaries; the live OSRM
                           toolchain + graphs already lived in ~/osm-build)

Code now points at the new locations, all overridable via env:
- mock/server.js: TRIPS_HOME (default ~/trips) for tile cache + store
- setup-osrm.sh / setup-osrm-colombia.sh: OSM_DIR (default ~/trips/osm)
- spatial/compose+import.sh: OSM_DIR (default ~/trips/osm)
- .gitignore: rewritten — no artifact paths remain in-tree
This commit is contained in:
Greg Pomerantz 2026-09-10 10:03:04 -04:00
parent c367eba5cb
commit 3da04c111e
9 changed files with 40 additions and 30 deletions

21
.gitignore vendored
View File

@ -1,16 +1,13 @@
# map tile cache + server runtime
mock/.tilecache/
mock/server.log
# OSM data (downloaded by router/scripts/setup-osrm.sh)
osm/*.osm.pbf
osm/build/
# Go
# Compiled binaries (built in place, not committed)
router/router
spatial/spatiald
router/bench
spatial/spatiald
router/scripts/__pycache__/
# per-trip uploaded documents + chat logs (PII — never commit)
mock/store/
# Runtime artifacts live OUTSIDE this source tree, in ~/trips:
# ~/trips/osm/ OSM PBF extracts (setup-osrm*.sh, spatial/import.sh)
# ~/trips/tilecache/ mock tile cache (mock/server.js)
# ~/trips/store/mock/ per-trip docs + chats (mock/server.js, PII)
# ~/trips/logs/ server logs
# and the OSRM toolchain + routing graphs live in ~/osm-build (W in the
# setup scripts). Nothing here should be re-added under those names.

View File

@ -1925,9 +1925,9 @@ let version = 0;
let history = []; // [{v, label, at, days, stays}]
let hIdx = -1; // pointer into history
let tripDocs = {}; // name → {name,kind,chars,text,truncated,at} — attached documents
// (authoritative copy lives on the server: mock/store/<trip>/docs/)
// (authoritative copy lives on the server: ~/trips/store/mock/<trip>/docs/)
let chatLog = []; // [{role:'user'|'assistant', text}] — conversation turns, persisted
// per trip on the server (mock/store/<trip>/chat.jsonl) so a
// per trip on the server (~/trips/store/mock/<trip>/chat.jsonl) so a
// follow-up ("yes, do it") can see what the model said earlier,
// even after a reload
let storeReady = Promise.resolve(); // resolve when this trip's server store has loaded
@ -2407,7 +2407,7 @@ let persistT = 0;
function persistTrip(force = false) {
clearTimeout(persistT);
const hist = history.slice(0, hIdx + 1).slice(-25); // drop the redo tail, cap at 25
// docs + chat live on the server now (mock/store/<trip>/) — localStorage
// docs + chat live on the server now (~/trips/store/mock/<trip>/) — localStorage
// only carries the plan state. force: skip the debounce — the re-anchoring
// of the whole trip around booked flights is the one edit we must never lose
const save = () => tripStore.save(tripId, { days, stays, version, hIdx: hist.length - 1, history: hist, bookings: M.trip.bookings, title: M.trip.title });

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Pre-cache OSM tiles for the trip's map extent through the local proxy
# (which stores them in mock/.tilecache). Usage:
# (the proxy stores them in ~/trips/tilecache). Usage:
# pre-cache-tiles.sh # all trips
# pre-cache-tiles.sh colombia z16 # one trip, one zoom
set -euo pipefail
@ -60,4 +60,5 @@ for trip in "${TRIPS[@]}"; do
fetch "$trip" "$z" | xargs -P 8 -n 1 curl -s -o /dev/null -m 20 --retry 2 > /dev/null
done
done
echo "done. cache size: $(du -sh .tilecache | cut -f1)"
CACHE_DIR="${TRIPS_HOME:-$HOME/trips}/tilecache"
echo "done. cache size: $(du -sh "$CACHE_DIR" 2>/dev/null | cut -f1)"

View File

@ -44,9 +44,13 @@ const SEARXNG = { base: process.env.SEARXNG_BASE || 'http://192.168.3.4:30053' }
const SPATIAL = { url: process.env.SPATIAL_URL || 'http://localhost:5005' };
const routerFor = (u) => ROUTERS[u.searchParams.get('router') || 'northeast'] || ROUTERS.northeast;
const PROFILE = { foot: 'walking', walk: 'walking', bike: 'cycling', cycle: 'cycling', car: 'driving', drive: 'driving', transit: 'driving' };
const CACHE = path.join(__dirname, '.tilecache');
// Runtime artifacts live OUTSIDE the source tree — the repo holds code +
// built binaries only. Home: ~/trips (override with TRIPS_HOME).
const TRIPS_HOME = process.env.TRIPS_HOME || path.join(os.homedir(), 'trips');
const CACHE = path.join(TRIPS_HOME, 'tilecache');
fs.mkdirSync(CACHE, { recursive: true });
const STORE = path.join(__dirname, 'store'); // per-trip uploads (originals + parsed) + chat logs
// per-trip uploads (originals + parsed) + chat logs: ~/trips/store/mock/<trip>/
const STORE = path.join(TRIPS_HOME, 'store', 'mock');
fs.mkdirSync(STORE, { recursive: true });
const mime = {

View File

@ -15,7 +15,8 @@ set -euo pipefail
cd "$(dirname "$0")"
W="${W:-$HOME/osm-build}"
OSM_DIR="$(cd ../.. && pwd)/osm"
OSM_DIR="${OSM_DIR:-$HOME/trips/osm}" # raw PBFs live outside the dev tree
mkdir -p "$OSM_DIR"
DATA_DIR="$W/data/colombia"
OSRM_BIN="$W/build"
OSRM_SRC="$W/osrm-backend-26.4.1"

View File

@ -8,13 +8,15 @@
# scripts/setup-osrm.sh --no-serve # build + extract, don't serve
#
# Artifacts live in $W (default: $HOME/osm-build — durable; the extract
# is ~8 GB under $W/data). PBFs are in ../../osm/ (~1.1 GB, gitignored).
# is ~8 GB under $W/data). Raw PBFs live in ~/trips/osm (~1.1 GB; the dev
# tree holds source only — override with OSM_DIR).
set -euo pipefail
cd "$(dirname "$0")"
W="${W:-$HOME/osm-build}"
P="$W/prefix"
OSM_DIR="$(cd ../.. && pwd)/osm"
OSM_DIR="${OSM_DIR:-$HOME/trips/osm}" # raw PBFs live outside the dev tree
mkdir -p "$OSM_DIR"
DATA_DIR="${DATA_DIR:-$W/data}"
OSRM_SRC="$W/osrm-backend-26.4.1"
OSRM_BIN="$W/build"

View File

@ -18,15 +18,15 @@ nearest, bbox)"). Replaces the flat-file/Overpass approximations.
* Docker with the current user in the `docker` group (on this box:
one-time `sudo usermod -aG docker $USER`, then re-login).
* PBF extracts in `../osm/` (already present: `nh.osm.pbf`,
`colombia.osm.pbf`, US state extracts).
* PBF extracts in `~/trips/osm` (already present: `nh.osm.pbf`,
`colombia.osm.pbf`, US state extracts; override with `OSM_DIR`).
## Usage
```bash
docker compose up -d postgis # first: runs schema.sql
./import.sh ../osm/nh.osm.pbf nh # load New England (default)
./import.sh ../osm/colombia.osm.pbf colombia
./import.sh ~/trips/osm/nh.osm.pbf nh # load New England (default)
./import.sh ~/trips/osm/colombia.osm.pbf colombia
docker compose up -d spatiald # query service on :5005
```

View File

@ -1,7 +1,10 @@
# PostGIS spatial stack for the trip planner.
#
# docker compose up -d postgis # start the DB (schema.sql runs on first boot)
# ./import.sh ../osm/nh.osm.pbf # import an OSM extract (one-shot osm2pgsql)
# ./import.sh # import ~/trips/osm/nh.osm.pbf (one-shot osm2pgsql)
#
# OSM_DIR (default ~/trips/osm) is where the PBF extracts live — outside the
# dev tree. Export it to override.
# docker compose run --rm spatiald # start the query service on :5005
#
# The PBF extracts live in ../osm (gitignored). osm2pgsql runs as a one-shot
@ -43,7 +46,7 @@ services:
--flat-nodes=/tmp/flat.nodes --disable-operations
--import-strips=10
volumes:
- ../osm:/data:ro
- ${OSM_DIR:-$HOME/trips/osm}:/data:ro
spatiald:
build: .

View File

@ -3,7 +3,8 @@
#
# ./import.sh [file.osm.pbf] [extract-name]
#
# file.osm.pbf default: ../osm/nh.osm.pbf (path may be absolute)
# file.osm.pbf default: $OSM_DIR/nh.osm.pbf (OSM_DIR defaults to
# ~/trips/osm — the PBFs live outside the dev tree)
# extract-name default: basename without extension
#
# The PBF must be readable by uid 1001 (the osm2pgsql image user) — the
@ -12,7 +13,8 @@
set -euo pipefail
cd "$(dirname "$0")"
PBF=${1:-../osm/nh.osm.pbf}
OSM_DIR="${OSM_DIR:-$HOME/trips/osm}"
PBF=${1:-$OSM_DIR/nh.osm.pbf}
NAME=${2:-$(basename "${PBF%.osm.pbf}")}
ABS=$(realpath "$PBF")
[[ -f $ABS ]] || { echo "no such PBF: $ABS" >&2; exit 1; }