Skip to content

Fix AI integration readiness and initialization - #12

Merged
codoom1 merged 1 commit into
mainfrom
agent/fix-ai-readiness
Jul 24, 2026
Merged

Fix AI integration readiness and initialization#12
codoom1 merged 1 commit into
mainfrom
agent/fix-ai-readiness

Conversation

@codoom1

@codoom1 codoom1 commented Jul 24, 2026

Copy link
Copy Markdown
Owner

What changed

  • Replaced the misleading environment-only “configured” status with an overall readiness check that includes durable AI usage storage.
  • Added an admin-only, explicitly confirmed action to initialize only the missing ai_usage_events table and indexes.
  • Added clear database readiness indicators and setup guidance to Admin → AI Integration.
  • Improved the chatbot error so administrators know exactly where to complete setup.
  • Added coverage for missing storage, initialization, confirmation, readiness reporting, and chatbot failure behavior.

Root cause

The admin page reported “configured” whenever the AI toggle and OpenAI key existed. Every authenticated assistant request also writes to ai_usage_events; when that table had not been created in production, quota tracking failed before OpenAI was called.

User impact

After deployment, the AI Integration page reports true end-to-end readiness. If storage is missing, an administrator can initialize it once from the page without needing a Vercel shell or exposing the PostgreSQL connection string.

Safety

The initialization endpoint is authenticated, administrator-only, POST-only, requires an explicit JSON confirmation, and creates only the AI usage table with checkfirst=True. It does not alter or delete existing application data.

Validation

  • python -m pytest -q tests/ — 123 passed
  • Focused AI/admin tests — 36 passed
  • Strict Python undefined-name/syntax lint — passed
  • git diff --check — passed

@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
statistical-model-suggester Ready Ready Preview, Comment Jul 24, 2026 11:25pm

@codoom1
codoom1 marked this pull request as ready for review July 24, 2026 23:41
Copilot AI review requested due to automatic review settings July 24, 2026 23:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codoom1
codoom1 merged commit 3b36806 into main Jul 24, 2026
7 checks passed
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.

2 participants