Apply demo-activity-bot: Bruno, the synthetic public-walk generator

Adds a background demo user (`bruno`) plus two pg-boss jobs that generate
public trekking routes and activities in inner Berlin and prune them
after 14 days. Disabled by default everywhere; flip `DEMO_BOT_ENABLED`
only in prod.

- Schema: `synthetic` boolean on routes + activities
- `ensureDemoUser()` idempotent insert + badge on /users/bruno
- Generation gate: 07-21 Berlin local, p=0.12, 40-route cap in 14d
- Initial 4-walk backfill on first enable; retention via daily prune
- Prometheus gauges `demo_bot_synthetic_routes_total` / `_activities_total`
- Unit + DB-gated integration + E2E tests

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-04-19 10:14:58 +02:00
parent 7304a9e904
commit ba4c4e1b4f
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
16 changed files with 1003 additions and 43 deletions

View file

@ -108,8 +108,21 @@ server.listen(port, async () => {
const { seedOAuthClient } = await import("./app/lib/oauth.server.ts");
await seedOAuthClient("trails-cool-mobile", "trailscool://auth/callback", true);
// Start background job worker (no jobs yet — placeholder for Komoot import and federation)
// Start background job worker
const { demoBotGenerateJob } = await import("./app/jobs/demo-bot-generate.ts");
const { demoBotPruneJob } = await import("./app/jobs/demo-bot-prune.ts");
const boss = createBoss(process.env.DATABASE_URL ?? "postgres://trails:trails@localhost:5432/trails");
await startWorker(boss, []);
await startWorker(boss, [demoBotGenerateJob, demoBotPruneJob]);
logger.info("Background job worker started");
// Bootstrap the demo user when the bot is enabled; cheap idempotent insert.
if (process.env.DEMO_BOT_ENABLED === "true") {
const { ensureDemoUser } = await import("./app/lib/demo-bot.server.ts");
try {
const id = await ensureDemoUser();
logger.info({ id }, "demo-bot user ensured");
} catch (err) {
logger.error({ err }, "demo-bot ensureDemoUser failed");
}
}
});