Files
impactflow_discovery/alembic/versions/006_add_task_mapping.py
Joel Salmon c4fc1cccd7 Phase 4: task-to-goal integration (Vision side)
Build the boundary the ImpactFlow core time-tracker plugs into. A task maps to
a foundation — one of the six stable profile elements (love, strength, mission,
vocation, short_term, long_term) — so the tracker can ask "which goal does this
build toward?" and post the answer back to Vision.

- Models + migration 006: task_mapping (one row per logged time entry).
- app/services/foundations.py: the six foundations + a pure, testable
  work-pattern aggregator (rollup) and a plain-language summary.
- app/routers/integration.py (user-scoped; tracker calls as the user or via
  X-API-Key): GET /foundations, POST/GET /task-mappings,
  GET /work-patterns?days=N (per-foundation minutes/share/neglected).
- Reminder engine now pulls from real work patterns: CheckinCoach takes an
  optional work-pattern summary (last 14 days) and reflects where time has gone
  against the person's own words — an observation, never a verdict.
- Frontend: dashboard.html (time per foundation + neglected); linked from
  profile.html.

Documented the core-tracker integration contract in the README. Phase 4
completes the Vision module's roadmap on the Discovery side; the core tracker
integrates by calling these endpoints.

Tests: 86 passing (added pure-aggregator, integration-endpoint, and
work-pattern-into-check-in tests; run in-container).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 21:24:58 -05:00

53 lines
1.8 KiB
Python

"""add task_mapping (Phase 4 task-to-goal integration)
Revision ID: 006
Revises: 005
Create Date: 2026-06-16
Phase 4: the ImpactFlow core time-tracker posts each logged unit of work here,
mapped to the profile foundation it builds toward. The work-pattern aggregation
rolls these up to feed the coaching reminder engine and the goal dashboard.
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
revision: str = "006"
down_revision: Union[str, None] = "005"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"task_mapping",
sa.Column("id", sa.String(), primary_key=True),
sa.Column(
"user_id",
sa.String(),
sa.ForeignKey("users.id"),
nullable=False,
),
sa.Column("external_task_id", sa.String(), nullable=False),
sa.Column("task_label", sa.String(), nullable=True),
sa.Column("foundation", sa.String(), nullable=False),
sa.Column("minutes", sa.Integer(), nullable=False, server_default="0"),
sa.Column("occurred_at", sa.DateTime(), nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=False),
)
op.create_index("ix_task_mapping_user_id", "task_mapping", ["user_id"])
op.create_index(
"ix_task_mapping_foundation", "task_mapping", ["foundation"]
)
op.create_index(
"ix_task_mapping_occurred_at", "task_mapping", ["occurred_at"]
)
def downgrade() -> None:
op.drop_index("ix_task_mapping_occurred_at", table_name="task_mapping")
op.drop_index("ix_task_mapping_foundation", table_name="task_mapping")
op.drop_index("ix_task_mapping_user_id", table_name="task_mapping")
op.drop_table("task_mapping")