Skip to content

Onboarding personalization, chat cold-start fix, Lexi chat UX, and backend hardening - #392

Merged
InfinityZero3000 merged 3 commits into
devfrom
codex/product-expansion-dev-ready
Aug 7, 2026
Merged

Onboarding personalization, chat cold-start fix, Lexi chat UX, and backend hardening#392
InfinityZero3000 merged 3 commits into
devfrom
codex/product-expansion-dev-ready

Conversation

@InfinityZero3000

Copy link
Copy Markdown
Owner

Summary

Two commits on top of the already-merged product-expansion work (#391):

7e152307 — feat(lexi-chat): onboarding personalization, cold-start latency fix, and chat UX improvements

  • Persist onboarding goal/interest (previously silently dropped) and thread into ai-service's learner_profile via the existing internal batch-get pull + LearnerStateProfile.state_epoch cache-invalidation.
  • Fix TraceCAG cache/KG version drift and add content-hash KG mutation detection.
  • Fix a measured 169.5–478s cold-start chat latency: RetrievalServiceV3 (graph analytics + concept embeddings) and the JIT GLiNER model now warm as a non-blocking background task at boot instead of on whichever live request hits them first.
  • Cap betweenness-centrality/community-detection cost on the real production KG size.
  • Fix diagnose_node's broken Groq-fallback path and truncated-JSON max_tokens.
  • Lexi chat: TTS defaults to the app-wide Sound setting until overridden; corrections highlight inline on the user's own message bubble; one-tap practice suggestion tied to the specific mistake; fixed a real data-loss bug where "already saved" vocabulary state reset after every app restart; new sessions can reference a short recap of the learner's last conversation.

cf90bdab — fix(backend): wallet cache consistency, streak race condition, SSRF hardening

  • Wallet cache only invalidates when a transaction actually commits.
  • claim_daily_reward now also invalidates the wallet cache.
  • Row-level lock on streak read-modify-write to close a concurrency race.
  • safe_http.resolve_pinned_ip: excludes multicast ranges that is_global alone let through (DNS-rebinding hardening gap).
  • Scheduled Celery tasks for periodic news/YouTube/podcast content prefetch.
  • Test coverage for PDF-based bulk-import endpoints.

Both commits were independently code-reviewed (3 separate reviews covering ai-service/backend-service/flutter-app) and every finding was fixed before commit.

Test plan

  • Backend: full pytest suite (1363 passed, excluding the real-Postgres-only integration file which was run separately and passed)
  • ai-service: pytest tests/trace_cag/ + related chat integration suites (404 passed)
  • Flutter: flutter test across lexi_chat/vocabulary/youtube/books/core-services (175 passed)
  • dart analyze / backend lint clean (only one pre-existing, unrelated info-level lint remains)
  • CI on this PR

🤖 Generated with Claude Code

InfinityZero3000 and others added 2 commits August 7, 2026 13:30
…and chat UX improvements

Three workstreams from this session, all verified via independent code review
and full test suites (backend, ai-service, Flutter):

Onboarding personalization
- Persist goal/interest collected at onboarding (previously silently dropped
  before reaching the backend) on User, thread through to ai-service's
  learner_profile via the existing /internal/learner-state/batch-get pull and
  LearnerStateProfile.state_epoch cache-invalidation mechanism — no new
  invalidation plumbing needed.
- Fix version-drift between cache_utils.py's hard-gate schema version and
  dependencies.py's certificate system; add content-hash-based KG mutation
  detection (kg_service_v3.py).

Cold-start latency fix (ai-service)
- RetrievalServiceV3 (graph analytics + concept embeddings) and the JIT
  GLiNER model were built lazily on whichever live request hit them first —
  measured at 169.5-478s on the real production KG. Now warmed as a
  background task at boot (non-blocking, so Docker's HEALTHCHECK
  start-period isn't at risk), with locking so a racing live request awaits
  the same in-flight build instead of duplicating it.
- Cap betweenness-centrality sampling and skip community detection above a
  node-count ceiling to keep graph_analytics.py bounded on the real KG size.
- Fix diagnose_node's Groq-fallback path (an exception from the local
  gateway used to skip the fallback entirely) and its too-small max_tokens
  causing truncated JSON.

Lexi chat UX
- TTS now defaults to the app-wide Sound setting until the user explicitly
  overrides it in-chat.
- Grammar/vocabulary corrections highlight inline on the user's own message
  bubble (which contains the literal wrong text) instead of only being
  visible in a separate "View notes" sheet.
- After a correction, Lexi can offer a one-tap practice follow-up tied to
  the specific concept the mistake traced to (not a generic weak-spot scan).
- Fixed a real data-loss bug: UserVocabularyModel silently dropped the
  word text the backend already sent, so "already saved" state in
  News/YouTube/Book reader always reset after an app restart.
- A new session can reference what the learner talked about last time via
  a short recap pulled into the system prompt.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ardening

- Only invalidate the wallet cache when a WalletCRUD transaction actually
  commits (commit=True) — previously it invalidated on every call even when
  the caller owned the outer transaction and could still roll it back,
  leaving a stale cache miss race. Callers using commit=False are
  responsible for invalidating after their own commit.
- claim_daily_reward now also invalidates the wallet cache (gems are
  awarded there but the cache was never busted).
- Lock the streak row (with_for_update) before a read-modify-write update to
  close a concurrent-update race window.
- safe_http.resolve_pinned_ip: is_global alone still admits multicast
  ranges (224.0.0.0/4, ff00::/8) as a "public" address — DNS-rebinding
  hardening gap. Now excludes them explicitly.
- Add scheduled Celery tasks (content_prefetch_schedule.py) for periodic
  news/YouTube/podcast content prefetch, wired into celery_app's beat
  schedule.
- Add test coverage for the PDF-based vocabulary/course bulk-import
  endpoints (admin_courses._extract_pdf_text and its two routes).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
lexilingo-admin Ignored Ignored Aug 7, 2026 7:03am
lexilingo-app Ignored Ignored Aug 7, 2026 7:03am

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

PR-Agent failed to apply 'local' repo settings

The configuration file needs to be a valid TOML, please fix it.


Error message:
Cannot declare ('config',) twice (at line 61, column 8)

Configuration content:
[config]
# Use Google Gemini API
model = "google/gemini-2.5-pro"
fallback_models = ["google/gemini-2.5-flash"]

[pr_reviewer]
# Enable/disable features
require_focused_review = true
require_score_review = true
require_tests_review = true
require_security_review = true
require_estimate_effort_to_review = true

# Review settings
num_code_suggestions = 5
inline_code_comments = true
auto_review = true
remove_previous_review_comment = true

# Language and tone
extra_instructions = """
- Focus on code quality, security, and best practices
- Check for proper error handling
- Verify Clean Architecture principles
- Ensure proper test coverage
- Review API design and RESTful conventions
- Check for potential performance issues
- Verify proper logging and monitoring
"""

[pr_code_suggestions]
# Code improvement suggestions
num_code_suggestions = 5
extra_instructions = """
- Suggest improvements for code readability
- Recommend better naming conventions
- Propose performance optimizations
- Suggest security enhancements
"""

[pr_description]
# Auto-generate PR description
publish_description = true
add_original_user_description = true
extra_instructions = """
- Summarize main changes
- List affected components
- Note breaking changes
- Include testing notes
"""

[pr_questions]
# Auto-generate clarifying questions
num_questions = 3
extra_instructions = """
- Ask about design decisions
- Question potential edge cases
- Clarify implementation choices
"""

[config]
# Model configuration (uncomment to customize)
# model = "gpt-4-turbo-preview"
# model = "anthropic/claude-3-5-sonnet-20241022"
# fallback_models = ["gpt-3.5-turbo"]

# Git provider
git_provider = "github"

# Review triggers
pr_commands = [
    "/review",
    "/describe",
    "/improve",
    "/ask",
    "/update_changelog",
]

.pr_agent.toml had git_provider/pr_commands as bare keys after the last
named table ([pr_questions]) — in TOML those get attributed to whatever
section preceded them, not the root. PR-Agent's config loader then failed
to merge them back into [config] ("Cannot declare ('config',) twice"),
breaking PR-Agent on every PR. Moved both into [config] where they belong.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@InfinityZero3000
InfinityZero3000 merged commit e30b8ab into dev Aug 7, 2026
11 checks passed
@InfinityZero3000
InfinityZero3000 deleted the codex/product-expansion-dev-ready branch August 7, 2026 09:29
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