mirror of
https://github.com/computerim/impactflow-discovery.git
synced 2026-08-27 09:10:36 +00:00
50453901b3
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>
107 lines
3.2 KiB
Python
107 lines
3.2 KiB
Python
"""add coaching_preferences and coaching_checkin (Phase 3)
|
|
|
|
Revision ID: 005
|
|
Revises: 004
|
|
Create Date: 2026-06-16
|
|
|
|
Phase 3: coaching preferences (auto-generated from the profile, user-overridable)
|
|
and periodic coaching check-ins that quote the person's own words and ask
|
|
whether their direction still feels valid.
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "005"
|
|
down_revision: Union[str, None] = "004"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"coaching_preferences",
|
|
sa.Column("id", sa.String(), primary_key=True),
|
|
sa.Column(
|
|
"user_id",
|
|
sa.String(),
|
|
sa.ForeignKey("users.id"),
|
|
nullable=False,
|
|
unique=True,
|
|
),
|
|
sa.Column(
|
|
"profile_id",
|
|
sa.String(),
|
|
sa.ForeignKey("discovery_profile.id"),
|
|
nullable=True,
|
|
),
|
|
sa.Column("coaching_frequency", sa.String(), nullable=False),
|
|
sa.Column("coaching_style", sa.String(), nullable=False),
|
|
sa.Column("misalignment_threshold", sa.String(), nullable=False),
|
|
sa.Column("friction_tolerance", sa.String(), nullable=False),
|
|
sa.Column(
|
|
"prefer_questions_over_directives",
|
|
sa.Boolean(),
|
|
nullable=False,
|
|
server_default=sa.text("1"),
|
|
),
|
|
sa.Column("time_of_day_preference", sa.String(), nullable=False),
|
|
sa.Column(
|
|
"auto_generated",
|
|
sa.Boolean(),
|
|
nullable=False,
|
|
server_default=sa.text("1"),
|
|
),
|
|
sa.Column("created_at", sa.DateTime(), nullable=False),
|
|
sa.Column("updated_at", sa.DateTime(), nullable=False),
|
|
)
|
|
op.create_index(
|
|
"ix_coaching_preferences_user_id",
|
|
"coaching_preferences",
|
|
["user_id"],
|
|
)
|
|
|
|
op.create_table(
|
|
"coaching_checkin",
|
|
sa.Column("id", sa.String(), primary_key=True),
|
|
sa.Column(
|
|
"user_id",
|
|
sa.String(),
|
|
sa.ForeignKey("users.id"),
|
|
nullable=False,
|
|
),
|
|
sa.Column(
|
|
"profile_id",
|
|
sa.String(),
|
|
sa.ForeignKey("discovery_profile.id"),
|
|
nullable=False,
|
|
),
|
|
sa.Column("body", sa.Text(), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(), nullable=False),
|
|
sa.Column("still_valid", sa.Boolean(), nullable=True),
|
|
sa.Column("response_note", sa.Text(), nullable=True),
|
|
sa.Column("acknowledged_at", sa.DateTime(), nullable=True),
|
|
)
|
|
op.create_index(
|
|
"ix_coaching_checkin_user_id", "coaching_checkin", ["user_id"]
|
|
)
|
|
op.create_index(
|
|
"ix_coaching_checkin_created_at", "coaching_checkin", ["created_at"]
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index(
|
|
"ix_coaching_checkin_created_at", table_name="coaching_checkin"
|
|
)
|
|
op.drop_index(
|
|
"ix_coaching_checkin_user_id", table_name="coaching_checkin"
|
|
)
|
|
op.drop_table("coaching_checkin")
|
|
|
|
op.drop_index(
|
|
"ix_coaching_preferences_user_id", table_name="coaching_preferences"
|
|
)
|
|
op.drop_table("coaching_preferences")
|