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
+26 -1
View File
@@ -45,10 +45,13 @@ async def _seed_profile(locked: bool = False, triad: str = "gut") -> str:
class FakeCheckinCoach:
body = 'You said you want to "run a pilot welding cohort." Does that still feel true?'
last_work_patterns = "unset"
def __init__(self, api_key=None, model=None):
pass
async def generate(self, profile, prefs):
async def generate(self, profile, prefs, work_patterns=None):
FakeCheckinCoach.last_work_patterns = work_patterns
return FakeCheckinCoach.body
@@ -181,6 +184,28 @@ async def test_run_batch_skips_unlocked_profile(app_client):
assert r["considered"] == 0
async def test_checkin_receives_recent_work_patterns(app_client):
"""Phase 4 wiring: a generated check-in is fed the recent work-pattern
summary so the coach can reflect where time has gone."""
await _seed_profile()
await app_client.post(
"/discovery/integration/task-mappings",
headers=API_KEY,
json={"external_task_id": "t1", "foundation": "short_term", "minutes": 90},
)
FakeCheckinCoach.last_work_patterns = "unset"
await app_client.post("/discovery/coaching/checkins", headers=API_KEY)
assert FakeCheckinCoach.last_work_patterns is not None
assert "last 14 days" in FakeCheckinCoach.last_work_patterns
async def test_checkin_without_work_patterns_passes_none(app_client):
await _seed_profile()
FakeCheckinCoach.last_work_patterns = "unset"
await app_client.post("/discovery/coaching/checkins", headers=API_KEY)
assert FakeCheckinCoach.last_work_patterns is None
async def test_due_logic_unit():
from app.routers.coaching import _is_due