Phase 5: iteration & polish (visualizations, goal history, smart tagging)

Final roadmap phase. No DB migration — it reads data already captured.

- Goal-evolution history: GET /discovery/profile/me/goal-history derives a
  per-goal timeline from the profile_revision snapshots (pure aggregator in
  app/services/profile_history.py).
- Smart tagging: POST /discovery/integration/suggest-foundation suggests which
  foundation a task builds toward + rationale/confidence (FoundationTagger,
  app/services/tagging.py). Suggestion only; the person confirms by posting the
  task mapping.
- Deeper goal-refinement: the reflect loop accepts an optional focus ("goals")
  that steers the coach toward sharpening goals — still mirror, not compass.
- Visualizations: visuals.html renders an Ikigai Venn and an Enneagram diagram
  (plain-language callouts, not the raw type number) plus the goal-evolution
  timeline; linked from profile.html.

Tests: 99 passing (added pure goal-history tests, goal-history + suggest
endpoint tests, reflect-focus passthrough; run in-container). README updated.

This completes the ImpactFlow Vision roadmap (Phases 1-5) on the Discovery side.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joel Salmon
2026-06-16 21:37:33 -05:00
parent c4fc1cccd7
commit b9d7b0e22b
14 changed files with 798 additions and 9 deletions
+37 -1
View File
@@ -50,6 +50,10 @@ If you need to explain this app in detail, use this mental model:
profile foundation via `POST /discovery/integration/task-mappings`. The
rolled-up work patterns drive `/static/dashboard.html` and are fed into the
coaching check-ins so they can reflect where time has actually gone.
15. (Phase 5) `/static/visuals.html` shows the Ikigai/Enneagram visuals and the
goal-evolution timeline; the tracker can call `suggest-foundation` for
smart tagging, and the reflect loop accepts a `focus` for deeper
goal-refinement.
Machine-to-machine callers (e.g. the MCP server) skip the OAuth dance and
authenticate with `X-API-Key: $IMPACTFLOW_API_KEY` instead. That header
@@ -152,13 +156,16 @@ Important files:
| `app/static/reflect.html` | Phase 2 AI-coach reflection chat (mirror loop, applies revisions, affirm) |
| `app/static/coaching.html` | Phase 3 coaching preferences form + check-in feed |
| `app/static/dashboard.html` | Phase 4 goal dashboard: time per foundation + neglected ones |
| `app/static/visuals.html` | Phase 5 visualizations: Ikigai Venn, Enneagram diagram, goal-evolution timeline |
| `app/static/auth.js` | Shared `authedFetch` helper: sends session cookies, silently refreshes on `401`, redirects to login |
| `app/static/style.css` | Shared UI styling |
| `app/services/reflector.py` | `ReflectionCoach`: Anthropic-backed mirror loop, JSON parsing, revision filtering |
| `app/services/coaching.py` | Deterministic preference generator + `CheckinCoach` (Anthropic check-in text) |
| `app/services/foundations.py` | The six foundations + pure work-pattern aggregator (Phase 4) |
| `app/services/profile_history.py` | Pure goal-evolution aggregator over profile revisions (Phase 5) |
| `app/services/tagging.py` | `FoundationTagger`: Anthropic smart-tagging suggestion (Phase 5) |
| `app/routers/coaching.py` | Phase 3 coaching routes: preferences, check-ins, weekly batch `/run` |
| `app/routers/integration.py` | Phase 4 task-to-goal integration: foundations, task-mappings, work-patterns |
| `app/routers/integration.py` | Phase 4/5 integration: foundations, task-mappings, work-patterns, suggest-foundation |
| `alembic/versions/001_initial.py` | Initial database schema migration |
| `alembic/versions/002_add_auth.py` | Adds `users`, `refresh_tokens`, and `activity_log` tables |
| `alembic/versions/003_add_goals.py` | Adds the goal columns to `discovery_conversation` and `discovery_profile` |
@@ -172,6 +179,8 @@ Important files:
| `tests/test_coaching.py` | Tests for coaching endpoints (preferences, check-ins, due-logic batch, work-pattern wiring) |
| `tests/test_foundations.py` | Unit tests for the pure work-pattern aggregator |
| `tests/test_integration.py` | Tests for the task-to-goal integration endpoints |
| `tests/test_profile_history.py` | Unit tests for the pure goal-evolution aggregator |
| `tests/test_phase5.py` | Tests for goal-history and smart-tagging endpoints |
| `tests/test_auth.py` | Tests for the dual-auth dependency (JWT + cookie + API key), token refresh/logout, admin enforcement, and domain allow-list |
| `tests/test_profile_edit.py` | Tests for `PATCH /discovery/profile/me` (edit, partial update, lock/`409`) |
| `tests/test_reflection.py` | Tests for the reflection endpoints (turns, applied revisions, lock/`409`, history) |
@@ -461,6 +470,23 @@ the user (forwarded session/JWT) or service-to-service with `X-API-Key`.
time has and hasn't gone — as an observation to check against the person's
own words, never a verdict (mirror, not compass).
### 11. Iteration & Polish (Phase 5)
- **Goal-evolution history:** `GET /discovery/profile/me/goal-history` derives a
per-goal timeline (near- and long-term) from the `profile_revision` snapshots
captured since Phase 2 — one entry per actual change, with `source` and `at`.
No new storage; it reads existing revisions.
- **Smart tagging:** `POST /discovery/integration/suggest-foundation`
(`{task_label}`) returns a suggested `foundation` + `rationale` + `confidence`.
It only suggests — the person confirms by posting the task mapping. The core
tracker uses this to pre-fill "which goal does this build toward?".
- **Deeper goal-refinement:** the reflect loop (Phase 2) accepts an optional
`focus` (e.g. `"goals"`) that steers the coach toward sharpening the
near/long-term goals — still a mirror.
- **Visualizations:** `visuals.html` renders an Ikigai four-circle Venn and an
Enneagram diagram from the profile (plain-language callouts — it does not
headline the raw type number), plus the goal-evolution timeline.
## API Reference
All `/discovery/*`, `/api/me*`, `/api/activity*`, and `/api/admin/*` routes
@@ -507,6 +533,8 @@ clients.) `/api/auth/login`, `/api/auth/callback`, `/health`, `/`, and
| `POST` | `/discovery/integration/task-mappings` | yes | Record a logged unit of work mapped to a foundation |
| `GET` | `/discovery/integration/task-mappings` | yes | List the user's task mappings in a window |
| `GET` | `/discovery/integration/work-patterns` | yes | Per-foundation work-pattern rollup over a window |
| `POST` | `/discovery/integration/suggest-foundation` | yes | Smart tagging: suggest a foundation for a task (person confirms) |
| `GET` | `/discovery/profile/me/goal-history` | yes | Timeline of how the person's goals evolved |
## Data Model
@@ -780,6 +808,14 @@ callback), so the pages hold no tokens of their own.
the person wants their energy — it observes, it does not prescribe
- linked from `profile.html` ("Where your time goes")
`visuals.html` (Phase 5 visualizations):
- reads `GET /discovery/profile/me` and renders an Ikigai four-circle Venn and
an Enneagram diagram in SVG (callouts stay in plain language)
- reads `GET /discovery/profile/me/goal-history` and shows how the near- and
long-term goals have changed over time
- linked from `profile.html` ("See your profile visualized")
## Configuration
Populate `.env` with at minimum the Anthropic key and the auth-related