Consumer Platform Rework: retire Streamlit, build advisory front-end - #56
Merged
Conversation
…ory front-end) Strategic plan to streamline HRP for non-technical users: retire the 21-page Streamlit dashboard in favor of a Next.js consumer app over a new HTTP/JSON API, with a moderate scope cut (keep the engine, trim the surface). Includes a competitive teardown of The Assembly (assemblyprivate.com): module taxonomy, the recommendation output contract, the 5-view consumer app spec, and a phased roadmap (Phase 0 cleanup -> HTTP API -> Next.js app -> retire Streamlit -> reliability polish -> research modules). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
…(Phase 0) Unified front door for service management, wrapping scripts/startup.sh and scripts/setup.sh. Non-destructive: existing launcher scripts remain in place (they retire in Phase 3 alongside Streamlit). New subcommands sit beside the existing job commands (run-now, list-jobs, job-status, clear-history); the new `status` reports running services while `job-status` keeps reporting ingestion history. - hrp start [--full|--dashboard-only|--mlflow-only] -> startup.sh start - hrp stop / restart / status -> startup.sh ... - hrp doctor -> setup.sh --check - README: document the unified commands Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
New `hrp/api/http/` FastAPI layer exposing the advisory surface as JSON for the
consumer front-end. Implements the Recommendation Output Contract from the
rework plan (thesis / entry-target-stop / risks / provenance).
Endpoints (under /api, bearer-token optional via HRP_API_TOKEN):
- GET /api/health
- GET /api/recommendations (conviction list; status/symbol/limit)
- GET /api/recommendations/history
- GET /api/recommendations/{id} (full contract + provenance; 404 if absent)
- POST /api/recommendations/{id}/approve|reject
- POST /api/recommendations/approve-all
- GET /api/portfolio (live positions + NAV)
- GET /api/track-record (win rate, returns, alpha by period)
- create_app() factory mirrors hrp.ops.server; run via `python -m hrp.api.http`
- Local-first auth: no token required unless HRP_API_TOKEN is set
- 17 tests via TestClient + dependency_overrides stub (DB-free)
- README + CLAUDE.md document the new service
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
…orts Addresses the Phase 1 caveats. Caveat 1 — column-drift bugs (grounded in real schema): - portfolio: map live_positions.entry_price -> avg_cost (+ unrealized_pnl_pct) - track-record: rebuild on real columns (profitable/unprofitable); derive win_rate and closed_recommendations Caveat 2 — previously-deferred endpoints: - GET/PUT /api/settings backed by the active user_profiles row (defaults when none; CSV-encodes excluded_symbols/sectors for the VARCHAR columns) - POST /api/assistant/query: Claude grounded on the user's recommendations/ portfolio/track-record; daily RateLimiter; 503 when ANTHROPIC_API_KEY unset, 429 when the daily cap is hit Caveat 3 — CLI import-heaviness: - hrp/agents/__init__.py now exports lazily (PEP 562 __getattr__); importing the package no longer pulls the full ML/data stack - cli.py imports heavy job/scheduler/platform modules inside handlers - result: `hrp --help` and `hrp status/doctor` emit 0 DB-init lines - CLI tests repointed to patch the source modules (where names now resolve) 23 HTTP API tests + all CLI tests pass; ruff/black clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
claude-sonnet-4-20250514 reached end-of-life (2026-06-15) and now 404s. Verified end-to-end: POST /api/assistant/query returns a grounded answer with the daily rate limit decrementing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
Dark editorial "members terminal" SPA (Next.js 16 + TS + Tailwind) consuming the /api HTTP layer. Mirrors The Assembly's UX with HRP's validation provenance as the differentiator. Views: Conviction List, Recommendation dossier (thesis / entry-target-stop / risks / validated provenance / approve-reject), My Portfolio (live NAV + allocation + P/L), Track Record (win-rate/avg/excess), Vault Assistant (chat, remaining_today, graceful 503/429), Settings (user_profiles-backed form). - Typed API client (lib/api.ts) against the final contract; bearer token via NEXT_PUBLIC_API_TOKEN; base via NEXT_PUBLIC_API_BASE - Live UTC clock, // NOT INVESTMENT ADVICE footer, loading/error/empty states - fix: confidence is a categorical string (HIGH/MEDIUM/LOW), not a percentage - `npm run build` passes clean Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
The Next.js app runs on a different origin (:3000) than the API (:8090), so browser fetches require CORS. Adds CORSMiddleware (origins via HRP_API_CORS_ORIGINS, default http://localhost:3000) + a regression test. Verified end-to-end in a live browser walkthrough of all views. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
Don't leak raw Anthropic error text (billing message, request_id) to the consumer. Log full detail server-side; return a generic 502 message. Adds a test asserting the raw upstream text never reaches the response body. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
…Phase 3)
Removes the 21-page Streamlit dashboard now that the HTTP API (hrp/api/http)
and the Next.js consumer app (web/) cover the consumer surface.
Deleted (self-contained — zero production importers):
- hrp/dashboard/ (42 files, ~15.9k LOC)
- tests/test_dashboard/, tests/dashboard/, tests/test_e2e/test_dashboard_workflow.py
Dependencies:
- drop streamlit, plotly, streamlit-authenticator from pyproject (dashboard-only)
Rewire (dashboard service -> API server):
- scripts/startup.sh: replace start/stop_dashboard with start/stop_api
(python -m hrp.api.http on :8090); --dashboard-only -> --api-only
- hrp/agents/cli.py: hrp start --dashboard-only -> --api-only
- scripts/open_hrp.sh ("Open HRP"): now starts the API + builds/serves the
Next.js app and opens http://localhost:3000
- scripts/setup.sh: drop streamlit from verify; dashboard-auth phase -> API-access
note (HRP_API_TOKEN); go_live/run_full_cycle/start_monitoring echoes updated
- README/CLAUDE.md/docs: dashboard/8501 -> API (:8090) + web app (:3000)
Test isolation fix (pre-existing, surfaced by the new API tests):
- tests/test_ops/conftest.py clears ambient HRP_THRESHOLD_* env (leaked from .env
via hrp.utils.config load_dotenv) so threshold tests are order-independent
Verified: hrp start --api-only -> health 200 -> status -> stop; advisory+api+ops
sweep green; collection clean (3237 tests).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
CI (no .env) surfaced 3 order-dependent failures: - test_smoke patched hrp.agents.cli.IngestionScheduler, which is now a lazy import inside the handler -> repoint to hrp.agents.scheduler.IngestionScheduler - test_factory polygon tests set POLYGON_API_KEY via monkeypatch but the source reads get_config() (a cached singleton); when an earlier test cached it as None (CI has no .env), the patch was ignored -> reset_config() after setenv Verified: all 3 pass without .env locally. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Umbrella PR for the consumer platform rework — streamlining HRP into a product a non-technical owner can trust and use daily.
Locked direction:
This PR starts with the plan doc; subsequent commits land Phase 0 (cleanup & consolidation) on this branch.
What's here so far
docs/plans/2026-06-27-hrp-consumer-platform-plan.md— full plan including:hrp/advisory/modulesPlatformAPImethods, onlyops/server.pyserves HTTP)Roadmap (this branch)
hrp start/status/stop/doctor, fix/doctorpermission rule🤖 Generated with Claude Code
https://claude.ai/code/session_011BFeBAuxWTFRayNGMD7VDn
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.