Skip to content

Add AI retrospective feature#7

Merged
thomasluizon merged 1 commit into
mainfrom
feature/ai-retrospective
Mar 21, 2026
Merged

Add AI retrospective feature#7
thomasluizon merged 1 commit into
mainfrom
feature/ai-retrospective

Conversation

@thomasluizon

Copy link
Copy Markdown
Owner

Summary

  • Pro-only GET /api/habits/retrospective?period=week&language=en endpoint
  • CanUseRetrospective PayGate check (config-gated via RetrospectiveProOnly)
  • GeminiRetrospectiveService builds detailed prompt with per-habit completion rates, bad habit slips, sub-habit stats
  • GetRetrospectiveQuery with 1-hour memory cache keyed by retro:{userId}:{period}:{dateFrom}:{language}
  • DI registration following existing ISummaryService pattern

Frontend PR

Companion: https://github.com/thomasluizon/orbit-ui/pull/11

Test plan

  • Free user GET /api/habits/retrospective returns 403 PAY_GATE
  • Pro user with period=week returns AI-generated retrospective
  • Second call with same period returns fromCache: true
  • Different period generates fresh retrospective
  • Invalid period defaults to 7 days

🤖 Generated with Claude Code

Pro-only feature that generates AI-powered habit analysis over
configurable time periods (week, month, quarter, semester, year).

- PayGate: CanUseRetrospective (Pro-only, config-gated)
- IRetrospectiveService interface + GeminiRetrospectiveService
  - Per-habit stats: completion rate, scheduled vs completed, bad habit slips
  - Structured prompt with Highlights/Missed/Trends/Suggestion sections
  - Retry with exponential backoff (same as summary service)
- GetRetrospectiveQuery with 1-hour memory cache
- GET /api/habits/retrospective?period=week&language=en endpoint
- DI registration in Program.cs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@thomasluizon
thomasluizon merged commit edb0ff3 into main Mar 21, 2026
1 check passed
@thomasluizon
thomasluizon deleted the feature/ai-retrospective branch March 21, 2026 02:40
thomasluizon added a commit that referenced this pull request Apr 15, 2026
ValidateOrbitSecuritySettings (Production only) now also:
- Rejects any Cors:AllowedOrigins containing 'localhost' or 'http://' so a
  misconfigured prod deploy fails fast instead of silently allowing local
  origins to send credentialed requests.
- Requires Jwt:SecretKey to be configured (not REPLACE-placeholder) and at
  least 64 characters long to match HS256 security assumptions.

Covers backend plan F1 (P0 #7) and F9 JWT hardening.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
thomasluizon added a commit that referenced this pull request Apr 15, 2026
ValidateOrbitSecuritySettings (Production only) now also:
- Rejects any Cors:AllowedOrigins containing 'localhost' or 'http://' so a
  misconfigured prod deploy fails fast instead of silently allowing local
  origins to send credentialed requests.
- Requires Jwt:SecretKey to be configured (not REPLACE-placeholder) and at
  least 64 characters long to match HS256 security assumptions.

Covers backend plan F1 (P0 #7) and F9 JWT hardening.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant