Skip to content

AI Assistant — Production Readiness Audit

FieldValue
Date2026-08-21
StatusGo — remediations merged; staging smoke + Central key + scheduler still required before Marketplace traffic
ScopeBillable Marketplace module ai catalog 1.1.0 + packs ai-credits-1k / 5k / 20k
Branchfeature/ai-tools-depth-ask-elosync
CompanionAI deployment · Architecture · Credits · Tools · API · User guide

PRs (open): Backend / Frontend / Docs on feature/ai-tools-depth-ask-elosync


Executive summary

EloSync AI is a billable Marketplace SKU ($29/mo, $290/yr), not default-included. Phase 1 ships Gateway orchestration over laravel/ai, dual-balance credit wallet, BYOK + Central keys, Ask EloSync panel, Lead Copilot, and write confirmation for create_task.

Catalog 1.1.0 adds Projects / Opportunities / Invoices read tools, Ask EloSync starter chips, numeric deep-link ids, and citation URL allowlisting (isSafeRedirectPath).

Go / No-Go: Go. Credit-integrity hardenings (wallet row lock, pre-provider credit ceiling, request-path ensurePeriod), ai.manage enforcement on Settings AI, and dedicated throttle:ai remain in place. Complete staging smoke and Central AI key + scheduler setup before production Marketplace opt-in.

GateResult
Catalog billable ai / $29 / $290 / not default-includedPass (version 1.1.0)
Packs depend on ai; grant on activatePass
Migrate-only register + permissions (2026_08_21_010000010300)Pass
Gateway sole orchestration; module:ai + can:ai.*Pass
Encrypted / masked ai_api_key (Central + tenant)Pass
Tenant isolation (BelongsToTenant + conversation ownership)Pass
Write confirmation (ai.confirm + pending actions)Pass
Dual wallet burn order (included → prepaid) + HTTP 402Pass
Wallet row lock + pre-provider credit reservePasslockForUpdate + ceiling gate
Lazy ensurePeriod() on request pathPass — chat, copilot, credits summary
ai.manage enforced on Settings AIPass — API + UI
AI-specific rate limitsPassthrottle:ai (30/min)
Pest AI suitePass — Feature + Unit coverage including remediations
Playwright test:e2e:aiPass — 6/6 serial (2026-08-21 local)
Deploy / upgrade docsPass — this page + Upgrade

Locked-decision matrix

DecisionBackendFrontendDocs
Packaging billable ai + credit packsPassPassPass
Platform credits vs BYOK (BYOK does not burn EloSync credits)PassPassPass
Dual wallet; burn included firstPassPass (badge)Pass
Write tools require confirmationPassPassPass
Phase-1 tools: Leads + Tasks (+ create_task)PassPassPass
1.1.0 read tools: Projects + Opportunities + InvoicesPassPass (starters)Pass
Citation hrefs same-app only (isSafeRedirectPath)PassPassPass
UUID conversation / message IDsPassPass (string IDs)Pass
No chatbot bolt-on / parallel authPassPassPass

Findings

Closed must-fix (Conditional Go → Go)

IDSeverityFindingResolution
F1HighPre-call gate only checked available < 1; burn after LLMPre-provider credit ceiling from prompt estimate + ai_max_output_tokens + tool buffer; agent maxTokens() capped; burn still uses actual tokens
F2Highburn() lacked row locklockForUpdate() on wallet (and purchase ledger check) inside grant/burn/rollover transactions
F3HighensurePeriod() never calledWired on chat, Lead Copilot, and GET /ai/credits
F4Mediumai.manage unusedSettings AI update/test require ai.manage; UI tab gated by module + ai.manage

1.1.0 tools depth (this delivery)

IDSeverityFindingResolution
R5HighAsk EloSync citations trusted model url (open redirect / phishing)ClosedresolveAiReferenceHref uses isSafeRedirectPath; unsafe urls fall back to numeric entity paths; no external AI anchors
L1LowNo positive availableFor entitlement tests for new toolsClosed — positive + module-absent registry Pest cases
L2LowProject tool happy paths skip installing projects in PestClosedinstallOptionalCrmModules(..., ['projects']) on project tool tests
L3LowStarter chips gate on module only, not *.viewClosed — starters require module + view permission; citations suppress unentitled modules

Open / ops (ops checklist — not code blockers)

IDSeverityFindingOwner
O1No dedicated throttleClosed (throttle:ai)Eng
O2MediumCentral ai_api_key must be set before platform mode works; seed leaves key nullOps
O3MediumSync chat on request worker — long LLM calls need adequate PHP/FPM timeoutsOps
O4MediumCompanion CI Quality Gates must pass on PRsEng
O5LowArchitecture doc previously said ai_credit_ledgers (actual table ai_credit_ledger)Docs (fixed)

Remediated during delivery / e2e

IDSeverityFindingResolution
R1HighGateway Gate::authorize without Auth context failed PestAuthorize via $user->can / Gate::forUser
R2MediumFrontend typed conversation IDs as numberUUID string types + panel state
R3MediumPlaywright tab name: 'AI' matched MailExact tab name matching
R4MediumBillable module stayed pending after Marketplace purchaseE2E entitleAiModule activate path

Deploy order

  1. Backend — migrate through 2026_08_21_150423 (catalog 1.1.0); confirm scheduler runs ai:rollover-monthly-credits
  2. Central Settings → AI — enable platform AI; set encrypted ai_api_key + models
  3. Frontend — SPA with Ask EloSync starters, safe citations, Settings AI (ai.manage), Lead Copilot, Central usage
  4. Docs — including this readiness page
  5. Staging smoke before production Marketplace opt-in

Suggested merge order: Backend → Frontend → Docs.


Pre-flight checklist

#CheckOwnerPass?
1Migrations 2026_08_21_010000010300 and 150423 (ai 1.1.0) applied (no production db:seed)Ops
2Catalog rows ai, ai-credits-1k, ai-credits-5k, ai-credits-20k published; ai billable 1.1.0Ops
3Permissions ai.use, ai.manage, ai.confirm granted to default admin/manager mapsOps
4Scheduler includes ai:rollover-monthly-credits (daily, withoutOverlapping, onOneServer)Ops
5Central AI: ai_enabled, ai_allow_platform / ai_allow_byok, provider + ai_api_key, models, credits knobsOps
6Stable APP_KEY (decrypts stored API keys)Ops
7FPM/proxy timeouts tolerate sync LLM callsOps
8Marketplace purchase → pending → payment/activate before entitlementsOps
9Pest AI suite green in CIEng
10Playwright npm run test:e2e:ai greenQA
11F1–F4 remediations shipped in 1.0.1; read-tool depth + Ask EloSync starters in 1.1.0Eng

Staging smoke (human)

  1. Central → Settings → AI → set key → Test AI connection
  2. Marketplace → install AI → activate (payment path or local activate)
  3. Confirm credit badge / wallet after activation (prorated included if mid-month)
  4. Settings → AI (ai.manage) → validation → save platform mode
  5. Ask EloSync → starter chips (entitled modules) → send / graceful provider error
  6. Ask overdue projects / pipeline summary / overdue invoices (when modules entitled)
  7. Confirm citation chips never navigate off-app (unsafe model urls ignored)
  8. Exhaust / zero wallet → expect 402 / clear UI error on platform mode
  9. Lead detail → AI Copilot → Summarize / Next action / Draft (preview only)
  10. Prompt a write (create_task) → pending action → confirm with ai.confirm / cancel
  11. Optional: buy credit pack → prepaid balance increases; ledger idempotent on replay

Rollback

LayerAction
FrontendRedeploy previous SPA (hides Ask EloSync / AI settings when module absent)
Backend codeRedeploy previous release; keep additive migrations
Module disableMarketplace cancel / deactivate ai (packs require ai)
SchemaDo not roll back AI migrations without a data plan

Monitoring

  • Central AI usage page + ai_usage_events
  • Platform audit events: ai.chat_completed, ai.lead_copilot
  • HTTP 402 rate (credit exhaustion)
  • Scheduler heartbeat for ai:rollover-monthly-credits
  • Provider/API errors in application logs (Nightwatch follows default exception capture)

Sign-off

RoleNameDateDecision
Eng☐ Ready
QA☐ Ready
Ops☐ Ready

Release decision: Go — merge companions after CI green. Complete staging smoke and Central AI key + scheduler setup before production Marketplace traffic.

Official documentation for the EloSync SaaS Platform.