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>
This commit is contained in:
Joel Salmon
2026-06-16 21:24:58 -05:00
parent 50453901b3
commit c4fc1cccd7
16 changed files with 857 additions and 5 deletions
+24
View File
@@ -246,3 +246,27 @@ class CoachingCheckin(Base):
acknowledged_at: Mapped[Optional[datetime]] = mapped_column(
DateTime, nullable=True
)
class TaskMapping(Base):
"""Phase 4: a logged unit of work from the ImpactFlow core time-tracker,
mapped to the profile foundation it builds toward. One row per time entry;
the work-pattern aggregation rolls these up per foundation."""
__tablename__ = "task_mapping"
id: Mapped[str] = mapped_column(String, primary_key=True)
user_id: Mapped[str] = mapped_column(
String, ForeignKey("users.id"), nullable=False, index=True
)
# Opaque id of the task in the core tracker (not an FK; external system).
external_task_id: Mapped[str] = mapped_column(String, nullable=False)
task_label: Mapped[Optional[str]] = mapped_column(String, nullable=True)
# One of foundations.FOUNDATIONS: love | strength | mission | vocation |
# short_term | long_term.
foundation: Mapped[str] = mapped_column(String, nullable=False, index=True)
minutes: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
occurred_at: Mapped[datetime] = mapped_column(
DateTime, nullable=False, index=True
)
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)