yesno — Daily Habit Prediction Pipeline

A yes/no device endpoint that walks through a daily pipeline of habits, each with a predict → confirm pair integrated with Fatebook for calibration tracking.

Flow

Each day the pipeline resets at 2am PST (7am São Paulo) and presents habits sequentially:

  1. yoga? (80%) → creates Fatebook prediction (80% if yes, 20% if no)
  2. did you yoga? → resolves prediction (auto-advances if Atom Matrix detected yoga)
  3. 18 burpees? (80%) → creates Fatebook prediction with today's goal
  4. did 18 burpees? → resolves prediction
  5. all done!

Device Endpoints

EndpointDescription
GET /questionCurrent question text (plain text, ≤30 chars)
GET /yesAnswer yes, advance pipeline
GET /noAnswer no, advance pipeline
GET /resetReset to step 0
GET /statusFull pipeline state (JSON)
GET /responsesAll logged answers (JSON)

Architecture

habits.ts     — Habit definitions (add new habits here)
pipeline.ts   — Generic state machine, auto-advance, auto-resolve
fatebook.ts   — Fatebook API client (graceful skip if no key)
main.ts       — HTTP handler (backward compatible)
cron.ts       — 2:15am PST auto-resolve unconfirmed predictions as NO

Adding a New Habit

Add an entry to the HABITS array in habits.ts. Each habit needs:

  • id, label, forecast, tags
  • getPredictText() — predict question (≤30 chars)
  • getConfirmText() — confirm question (≤30 chars)
  • getFatebookTitle() — full Fatebook question title
  • checkAutoComplete() — optional auto-detection from external source

Setup

Add FATEBOOK_API_KEY to this val's environment variables. Get your key at https://fatebook.io/api-setup