Phase 3: coaching preferences + weekly check-in engine

Add coaching preferences (auto-derived from the profile, user-overridable) and
a periodic check-in engine that quotes the person's own words and asks whether
their direction still feels valid — mirror, not compass.

- Preferences are deterministic: a documented triad mapping (gut → direct/
  higher-friction, heart → warm/drift-sensitive, head → reflective/question-led)
  produces defaults for the six fields (coaching_frequency, coaching_style,
  misalignment_threshold, friction_tolerance, prefer_questions_over_directives,
  time_of_day_preference). PUT overrides; regenerate re-derives.
- CheckinCoach (app/services/coaching.py): Anthropic-backed; writes a check-in
  that quotes the person's goals back and asks if the direction still holds.
- Endpoints (app/routers/coaching.py): GET/PUT/regenerate preferences;
  GET/POST checkins; respond (records still_valid); admin POST /run is the
  weekly batch (due = cadence elapsed + locked profile), intended for a cron.
- Models + migration 005: coaching_preferences (per user) and coaching_checkin.
- Frontend: coaching.html (preferences form + check-in feed); linked from
  profile.html.

Tests: 68 passing (added deterministic-preference unit tests and coaching
endpoint/batch tests; run in-container). README updated for Phase 3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joel Salmon
2026-06-16 21:10:54 -05:00
parent b4d8d17aed
commit 50453901b3
13 changed files with 1317 additions and 1 deletions
+42
View File
@@ -108,6 +108,48 @@ class ProfileRevisionOut(BaseModel):
created_at: datetime
# -- Phase 3: coaching preferences + check-ins -------------------------------
class CoachingPreferencesOut(BaseModel):
coaching_frequency: str
coaching_style: str
misalignment_threshold: str
friction_tolerance: str
prefer_questions_over_directives: bool
time_of_day_preference: str
auto_generated: bool
updated_at: datetime
class CoachingPreferencesUpdate(BaseModel):
coaching_frequency: Optional[str] = None
coaching_style: Optional[str] = None
misalignment_threshold: Optional[str] = None
friction_tolerance: Optional[str] = None
prefer_questions_over_directives: Optional[bool] = None
time_of_day_preference: Optional[str] = None
class CheckinOut(BaseModel):
id: str
body: str
created_at: datetime
still_valid: Optional[bool] = None
response_note: Optional[str] = None
acknowledged_at: Optional[datetime] = None
class CheckinRespondRequest(BaseModel):
still_valid: bool
note: str = ""
class RunCheckinsResponse(BaseModel):
considered: int
generated: int
class ConversationResponse(BaseModel):
id: str
user_id: str