Skip to main content

M09: AI Study Assistant

Phase: P2: Scholar Features Target: Weeks 28–32 Sprints: S13 (Weeks 27–28, shared with M08), S14 (Weeks 29–30) Release: web/v0.9.0-alpha, ai/v0.1.0-alpha


Phase Context

Goal: The three paid pillars that justify $79.99/year — interlinear Hebrew/Greek + JST, constellation view, and constrained AI. Ref: MVP.md § Paid Tier.

Key constraint: Founding users enter during this phase (~Week 22). Ship incrementally; don't wait for "complete."


ZenHub Configuration

FieldValue
MilestoneM09: AI Study Assistant
Due Date2026-10-18
Default PipelineProduct Backlog
Primary Epic(s)AI Study Assistant

Prerequisites

PrerequisiteSourceWhy Needed
M02: Content API servingP0AI needs passage context to generate explanations and study questions
M03: Scripture ReaderP1AI panel lives in the web app reader interface
M05: Staging environmentP1Founding users are already using staging during P2

⚠️ Important: AI ships without Scholar entitlement gating. Entitlement enforcement is added in M10 (Billing & Subscriptions epic) when billing goes live. During M09, AI endpoints are auth-required but not plan-gated.


Epic: AI Study Assistant

9 story areas. Constrained AI Q&A about the current passage with scripture and lexicon citations.

Story AreaScopeSpec Reference
LLM client ABCAbstract LLMClient with Anthropic (primary) + OpenAI (fallback)TECH-SPEC.md § AI Service
Prompt templatesJinja2 .j2 files for explain, questions, "what does original language reveal"MVP.md § Priority #3
Caching decoratorRedis semantic caching by prompt hashTECH-SPEC.md § AI Service
AI routesPOST /ai/explain, POST /ai/questionsTECH-SPEC.md § API Endpoints
Session limiting10 sessions/month on Scholar tier (counter in Redis)MVP.md § Priority #3
Citation linkingAI responses reference passages + lexicon entries as tappable linksMVP.md § Priority #3
AI UIStudyAssistant panel, prompt template buttons, response displayDESIGN-SYSTEM.md § P4 Components
Gateway AI routingRoute /api/v1/ai/* → AI service; auth-required but Scholar entitlement gating deferred to M10 (Billing & Subscriptions)TECH-SPEC.md § Gateway
AI iconai-assistant spark/four-pointed star iconDESIGN-SYSTEM.md § Navigation Icons

Document References

DocContainsUse When Writing Stories For
MVP.mdFeature scope, tier breakdown, success criteria, budgetAcceptance criteria, scope boundaries
TECH-SPEC.mdArchitecture, service boundaries, data stores, API catalogTechnical implementation details
GOSPELIB-SCHEMAS.mdAll 7 schema families, node/edge types, validation rulesData models, Pydantic models, graph schema
GOSPELIB-INGEST-SPEC.md7-stage pipeline, Cypher templates, batch strategy, CLIIngest pipeline stories
DESIGN-SYSTEM.mdVisual identity, component catalog, reader modes, tokensUI component stories
DESIGN-SYSTEM.md §§ 13, 21–23Footnotes (§13), subscription boundaries (§21), sharing (§22), onboarding (§23)UX flow stories
Deployment & OperationsEnvironments, K8s, CI/CD, migrations, secrets, DRInfrastructure and deployment stories
REPO-MAP.mdDirectory structure, naming conventions, dependency rulesAll stories (coding standards)

Additional Spec References for M09


Sprint Mapping

SprintWeeksPrimary Focus
S1327–28Constellation polish (M08 overlap), AI LLM client + prompts
S1429–30AI routes + caching + UI, session limiting, gateway AI routing

Note: S13 is shared with M08 (Knowledge Graph). The first half finishes constellation polish; the second half begins AI work. S14 overlaps with the start of M10 (P3).


Sprint Load Warnings

No specific sprint load warnings from the plan target S13–S14 directly. However:

  • S14 (Weeks 29–30) is the P2→P3 transition sprint. AI work must finish alongside the start of billing work (M10).
  • Founding users are active and providing feedback throughout this period — budget capacity for bug fixes and user-reported issues.

Release Info

ReleaseTagTriggerContains
v0.9.0-alphaweb/v0.9.0-alpha, ai/v0.1.0-alphaM09 completeAI study assistant (Scholar)

Tags follow <component>/v<semver> per release-please-config.json.

Note: This is the first release of the AI service (ai/v0.1.0-alpha).


Relevant Risks

RiskImpactMitigation
AI cost overrunsMonthly API costs exceed budgetSession limiting, prompt caching, Anthropic's caching API, cost monitoring
Solo founder velocity38-week plan too aggressiveFounding users at Week 22 provide feedback before full scope; cut P3 scope if needed

Cross-Cutting Concerns

Testing

LayerFrameworkWhenSpec Reference
Python unit/integrationpytest + testcontainersEvery PRGOSPELIB-INGEST-SPEC.md § Testing
Go unitgo test -race + table-drivenEvery PR (gateway AI routing)TECH-SPEC.md § Testing
TypeScript unitVitestEvery PRTECH-SPEC.md § Testing
Component visualStorybook or playgroundP1+DESIGN-SYSTEM.md § Governance
Visual regressionPlaywright + pixelmatchP1+ (any packages/ui/ or apps/*/src/ change)DESIGN-SYSTEM.md § Visual Regression CI

Documentation

DocUpdate Trigger
API OpenAPI specsAI service endpoints added (auto-generated by FastAPI)
ADRsLLM provider selection rationale, caching strategy decisions

CI/CD

Staging CD pipeline and Sentry should be live (activated in M05). AI service needs to be added to the staging deployment pipeline. Python test containers in CI should already be configured (from P0).


M09→M10 Entitlement Gating Note

During M09, the AI service endpoints are auth-required (user must be logged in) but not plan-gated (any authenticated user can access). This is intentional:

  • M09 ships AI functionality without billing infrastructure
  • M10 (Billing & Subscriptions) adds the entitlement middleware to the gateway
  • Once M10 is complete, AI endpoints (along with interlinear, constellation, etc.) will require an active Scholar subscription

This means during the window between M09 and M10 completion, all authenticated users have Scholar-level access to AI features.


Dependencies

Upstream (what M09 needs)

DependencyMilestoneDetail
Content API with passage dataM02AI needs passage context for explain/questions prompts
Reader shell with panelsM03StudyAssistant panel UI lives in the reader
Staging environmentM05AI service deployed to staging for founding user testing

Downstream (what depends on M09)

DependentMilestoneDetail
M10 entitlement gatingM10Scholar entitlement middleware gates AI endpoints
M11 performance auditM11AI response times included in performance audit
M11 analyticsM11AI session usage tracking for leading indicators

Epic: AI Study Assistant — Issues

IssueTitleStatusNotes
M09-001Implement Abstract LLMClient ABC with Anthropic and OpenAI Providers✅ DoneLLMClient ABC, AnthropicClient, OpenAIClient, create_llm_client factory + unit tests
M09-002Create Jinja2 Prompt Templates for AI Study Actions✅ Doneexplain_passage.j2, study_questions.j2, original_language.j2, PromptRenderer + unit tests
M09-003Implement Redis Semantic Caching Decorator for LLM Responses✅ DoneCachingLLMClient decorator + db/redis.py factory + unit tests
M09-004Implement AI Routes — POST /ai/explain and POST /ai/study-questions✅ DoneAIService, routes/ai.py, models/ai.py, dependencies.py, integration tests
M09-005Implement Session Limiting — 10 AI Sessions per Month✅ DoneSessionLimiter, GET /ai/sessions/remaining, wired into explain/study-questions
M09-006Implement Citation Linking in AI Responses✅ DoneCitationParser, CitationValidator, integrated into AIService
M09-007Build AI StudyAssistant Panel UI✅ DoneAIStudyPanel, AIResponseCard, AIStudyPanelContainer, SDK AiResource, web AppShell integration
M09-008Add Gateway AI Route Proxy — /api/v1/ai/* → AI Service✅ DoneAIServiceURL config, RateLimitAI, /api/v1/ai/* proxy mount, config_test.go, router_test.go AI cases
M09-009Design and Export ai-assistant Icon✅ DoneGlAiAssistantIcon (line + filled) already present in GlIcons.tsx
M09-010services/ai FastAPI Scaffold (Provider-Abstracted LLM Endpoint, Corpus Filter, OTel)❌ To DoAuthored W0.1 R3 (2026-04-17) — closes the gap where M25-003 / M21-006 / M21-008 all referenced services/ai but no issue owned the provider-abstracted scaffold, citation extraction, and per-tenant rate limiting

Progress: 9 Done · 0 Partial · 1 To Do (90%)

W0.1 R3 (2026-04-17): M09-010 authored. The milestone's original 9 issues target the entitlement-gated services/ai v1 endpoints (/ai/explain, /ai/study-questions) built against the LLMClient ABC. M09-010 extends that service into a production scaffold with /v1/assistant/query + /v1/assistant/stream, a formal AIProvider Protocol (replacing the ad-hoc LLMClient ABC), corpus-filter injection, citation extraction, and OpenTelemetry cost/latency attributes — consumed by M21-006/008 and M25-003 downstream.

Issues


Issue Dependency Graph

M09-001 ──► M09-002 ──► M09-004 ──► M09-005 ──► M09-007
M09-001 ──► M09-003 ──► M09-004 ──► M09-006 ──► M09-007
M09-001 ──► M09-004
M09-008 ──► M09-007
M09-009 ──► M09-007
M10-001 ─┐
M15-013 ─┴──► M09-010 ──► M21-006, M21-008, M25-003

Legend: A ──► B means A blocks B (B is blocked by A)


Summary

MetricCount
Total Issues10
Sub-Issues0
Total Estimate (pts)42
SprintsS13–S14
Dependencies (blocking)11
Dependencies (blocked by)11