# Production Readiness Review

Repository: [Ashutosh102/RecallIQ](https://github.com/Ashutosh102/RecallIQ), MIT. The README identifies it as built with Lovable.
Commit: `af423c91f366551b001e4e6f76cda3039b881488` (clean local checkout). The repository's last commit at this reviewed snapshot is dated 12 July 2025.
Reviewed: 10 November 2026.
Scope: React/Vite browser app, Supabase Auth/Postgres RLS/storage and nine Deno edge functions; Razorpay, Resend, Groq, OCR.space and AssemblyAI trust boundaries. Read-only source review. The application and its dependencies were never run or installed; the live deployment was not accessed.

## Candidate accounting

| Measure | Count |
| --- | ---: |
| Scanner rules run | 49 |
| Files scanned | 133 |
| Scanner-reported skipped files | 0 |
| Raw candidates | 181 |
| Confirmed candidates | 11 |
| Dropped candidates | 166 |
| Needs runtime evidence (unresolved candidates) | 4 |
| Grouped scanner-confirmed root causes | 3 |
| Manual confirmed additions | 13 |
| Total confirmed root causes | 16 |
| Published root causes | 12 |
| Withheld root causes | 4 |

181 = 11 + 166 + 4. Candidate counts and grouped findings count different things. Nine timeout candidates become one finding; the other confirmed candidates concern pagination and environment ignore rules. Manual review contributes nine further published findings and four withheld findings. The scanner's default severity is not a final judgment.

## Findings withheld for private disclosure to the author

- 1 access-control finding withheld for private disclosure to the author — Critical.
- 1 access-control finding withheld for private disclosure to the author — High.
- 1 payment finding withheld for private disclosure to the author — High.
- 1 access-control finding withheld for private disclosure to the author — High.

The repository advertises a live deployment. Withheld entries include only count, area and severity here; details remain in a separate local private disclosure document. The author has not been contacted. Code-level findings do not establish the state of the live service.

## Ranked fixes

Priority uses severity × likelihood × blast radius (each 1–4): Critical >=36, High 18–35, Medium 6–17, Low 1–5. Ties follow workflow impact. Public ranks exclude the withheld entries. F01 concerns duplication of private content into operational logs (severity 2); F02 concerns core paid workflow failure (severity 3). Scores are review judgments rather than measured probabilities or CVSS.

### 1 · High · Memory-derived AI content is copied into function logs (F01)

- Area: Errors & observability.
- Evidence: [supabase/functions/ai-enhance-memory/index.ts:111](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/supabase/functions/ai-enhance-memory/index.ts#L111).
- Why it breaks in production: The enhancement handler logs the raw model response and parsed content, plus a description fragment. Search and insights handlers also log query or model output. Personal memory content can therefore be duplicated into operational logs with separate access and retention settings. This is a logging exposure, not a demonstrated public read path.
- Scores: 2 × 4 × 3 = 24.
- Confidence and assumptions: High confidence: the raw-response log call is unconditional on the successful provider path; actual log retention and staff access are unknown.
- Fix: Remove content-bearing logs. Record request IDs, stage, elapsed time and provider status instead. Set retention and restrict access to any existing logs containing memory content.
- Verify: Submit a synthetic memory containing a unique harmless marker in staging. Successful and failed requests produce useful diagnostics without that marker in logs. Not run.
- Status after recheck: open. No target-code changes or runtime verification were performed.

### 2 · High · A failed memory save keeps the credit deduction (F02)

- Area: Data integrity.
- Evidence: [src/hooks/useMemoriesWithCredits.ts:18](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/src/hooks/useMemoriesWithCredits.ts#L18).
- Why it breaks in production: AddMemory calls addMemoryWithCredits. The hook awaits deductCredits before attempting the memory insert in a separate request. A failed insert enters a catch that tells the user credits were deducted; there is no compensation. Retrying can charge again without creating the first memory.
- Scores: 3 × 3 × 2 = 18.
- Confidence and assumptions: High confidence: the debit and memory insert are separate awaited calls, and the failure branch explicitly retains the debit.
- Fix: Combine the database insert and credit ledger mutation into one server transaction with an operation ID. Include attachment completion or a durable recovery state where needed.
- Verify: Fail the memory insert after an eligible debit. Persisted credits remain unchanged and a retry saves exactly one memory with one debit. Not run.
- Status after recheck: open. No target-code changes or runtime verification were performed.

### 3 · High · AI work has no application spend reservation (F05)

- Area: Rate limits & abuse.
- Evidence: [supabase/functions/ai-generate-insights/index.ts:17](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/supabase/functions/ai-generate-insights/index.ts#L17).
- Why it breaks in production: The insights handler maps the supplied memory collection into a prompt and calls the provider. Output max_tokens is set, but input collection size, simultaneous work and total application spend have no reservation or budget in this code path. Even ordinary repeated use can consume a shared provider quota. Gateway/provider controls may reduce exposure.
- Scores: 2 × 3 × 3 = 18.
- Confidence and assumptions: High confidence that code-local controls are absent; external quotas and current pricing are unknown. This is not a claim about unauthenticated reachability.
- Fix: Bound request bytes and memory count. Reserve per-user and global provider budget atomically before work; release or settle the reservation after completion.
- Verify: In staging, issue concurrent eligible requests near a small test budget. Total reserved/spent work stays within the cap and excess work is rejected before provider calls. Not run.
- Status after recheck: open. No target-code changes or runtime verification were performed.

### 4 · Medium · Nine external fetches have no cancellation deadline (F03)

- Area: Resilience.
- Evidence: [supabase/functions/ai-generate-insights/index.ts:50](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/supabase/functions/ai-generate-insights/index.ts#L50).
- Why it breaks in production: The scanner matched nine fetch calls across chat, order creation, OCR and audio processing. Each handler was read: none passes an abort signal. A hung upstream occupies the handler until an external platform limit; maxAttempts in transcription does not bound a single pending fetch.
- Scores: 2 × 3 × 2 = 12.
- Confidence and assumptions: High confidence: all nine matched fetch options were inspected; platform shutdown limits are external and do not supply a controlled cancellation path.
- Fix: Set per-attempt AbortSignal deadlines within a total request budget. Handle cancellation and retry only safe transient operations within that budget.
- Verify: Use a staging upstream that accepts a connection and never replies. Every path exits inside its declared budget and records a retryable failure. Not run.
- Status after recheck: open. No target-code changes or runtime verification were performed.

### 5 · Medium · The memories list has no pagination (F04)

- Area: Queries & performance.
- Evidence: [src/hooks/useMemories.ts:34](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/src/hooks/useMemories.ts#L34).
- Why it breaks in production: fetchMemories requests every visible row and column, ordered by date, without a cursor or range. Dashboard filters and search consume the full client array. Large histories increase transfer/render work; a configured API row ceiling can silently make that array incomplete. Owner RLS exists; this is a collection-size issue.
- Scores: 2 × 3 × 2 = 12.
- Confidence and assumptions: High confidence: the query and its full-array callers lack pagination; actual row counts and the configured API ceiling are unknown.
- Fix: Fetch bounded pages with a stable date/id cursor, select only display fields, and move collection-wide search/filtering to bounded server queries.
- Verify: Load a fixture larger than the API row ceiling. All pages remain reachable and the first screen fetches a bounded payload. Not run.
- Status after recheck: open. No target-code changes or runtime verification were performed.

### 6 · Medium · Transcription waits and polls inside the request (F06)

- Area: Resilience.
- Evidence: [supabase/functions/process-audio-transcription/index.ts:81](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/supabase/functions/process-audio-transcription/index.ts#L81).
- Why it breaks in production: The handler retains the upload/transcription workflow while polling up to 60 times with five-second sleeps, plus fetch duration. A long job can outlast the request/runtime and leave provider work running without a durable local continuation.
- Scores: 2 × 3 × 2 = 12.
- Confidence and assumptions: High confidence: the polling loop and sleeps execute inside the request; the deployed runtime limit and provider job durations are unknown.
- Fix: Persist the provider job ID and attachment status, return a job response, and use a bounded retryable worker or authenticated completion callback.
- Verify: Submit a slow staging job and restart the worker. The request returns promptly and one durable job eventually reaches completed or failed. Not run.
- Status after recheck: open. No target-code changes or runtime verification were performed.

### 7 · Medium · The AI search error handler uses out-of-scope variables (F07)

- Area: Errors & observability.
- Evidence: [supabase/functions/ai-search-memories/index.ts:130](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/supabase/functions/ai-search-memories/index.ts#L130).
- Why it breaks in production: query and memories are const bindings inside try. The sibling catch references them when the upstream fails. Those bindings are outside the catch scope, so the intended fallback throws instead of returning its JSON error response.
- Scores: 2 × 3 × 2 = 12.
- Confidence and assumptions: High confidence: the try-block const bindings are lexically unavailable to its sibling catch; the target TypeScript was not compiled.
- Fix: Keep validated fallback inputs in outer scope, or return a controlled error without fallback. Validate shape before invoking any fallback.
- Verify: Force a provider 503 and malformed request separately. The handler returns controlled JSON with the intended status; no secondary ReferenceError occurs. Not run.
- Status after recheck: open. No target-code changes or runtime verification were performed.

### 8 · Medium · Processing failure tries to consume the body twice (F08)

- Area: Errors & observability.
- Evidence: [supabase/functions/process-image-ocr/index.ts:122](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/supabase/functions/process-image-ocr/index.ts#L122).
- Why it breaks in production: OCR already consumed req.json() at line 18. Its catch tries req.json() again before updating failed status; the consumed stream rejects and the inner catch only logs. Audio transcription repeats this pattern at line 157. Attachments can remain pending after processing fails.
- Scores: 2 × 3 × 2 = 12.
- Confidence and assumptions: High confidence: both request bodies are consumed before the recovery branch attempts to read them again.
- Fix: Parse once and retain the validated attachment ID outside try. Update failure state using that value; handle the update result and define a retry path.
- Verify: Make OCR and audio providers fail after body parsing. The attachment reaches failed once, the client receives an error, and retry can proceed. Not run.
- Status after recheck: open. No target-code changes or runtime verification were performed.

### 9 · Medium · A local search fallback is reported as paid AI success (F09)

- Area: Errors & observability.
- Evidence: [src/hooks/useAISearchWithCredits.ts:30](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/src/hooks/useAISearchWithCredits.ts#L30).
- Why it breaks in production: The credit hook calls aiService.searchMemories after deducting credits. That service catches an invocation failure at src/lib/ai.ts:95 and resolves basic text results. The hook therefore shows AI Search successful and retains the debit although AI processing failed.
- Scores: 2 × 3 × 2 = 12.
- Confidence and assumptions: High confidence: the client service resolves its local fallback while the caller treats every resolved result as AI success.
- Fix: Return a discriminated result for AI versus local fallback. Settle the AI charge only on the paid success path, with durable compensation for failed requests.
- Verify: Fail the edge invocation. The UI explicitly labels local search, shows no AI-success toast, and persisted AI credits are unchanged. Not run.
- Status after recheck: open. No target-code changes or runtime verification were performed.

### 10 · Medium · The payment demo does not supply automated regression coverage (F11)

- Area: Tests that matter.
- Evidence: [package.json:6](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/package.json#L6).
- Why it breaks in production: The package scripts have build/lint/preview but no test command. The sole tests/razorpay-test.html is an interactive form that invokes functions and displays results; it has no executable assertions for persisted state, failure recovery or repeated delivery. Its existence does not establish payment/auth test coverage.
- Scores: 1 × 3 × 3 = 9.
- Confidence and assumptions: High confidence in the checked-in coverage gap; private or external CI suites may exist and were not available.
- Fix: Add assertion-based integration tests for two-user access, failed writes, payment retries, concurrent credit changes and migration replay. Keep credentials and live services out of fixtures.
- Verify: Run the new suite against disposable staging state; deliberately remove a guard in an authorized test branch and confirm the corresponding regression fails. Not run.
- Status after recheck: open. No target-code changes or runtime verification were performed.

### 11 · Medium · Search starts one attachment query per memory (F10)

- Area: Queries & performance.
- Evidence: [src/lib/ai.ts:61](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/src/lib/ai.ts#L61).
- Why it breaks in production: searchMemories uses Promise.all over the full memory array and executes an attachment query for each item before the AI call. Query count and concurrent requests grow linearly with history size. Errors returned as SDK result.error are also not examined in this loop.
- Scores: 2 × 4 × 1 = 8.
- Confidence and assumptions: High confidence: one SDK query is created per mapped memory; latency and rate-limit behavior need representative load data.
- Fix: Batch attachment retrieval for a bounded page of owned memory IDs, group results locally, and inspect returned errors. Bound concurrency for any remaining fan-out.
- Verify: Record database request counts for 1, 10 and 100 memories. Retrieval uses a bounded number of batched requests rather than one per memory. Not run.
- Status after recheck: open. No target-code changes or runtime verification were performed.

### 12 · Low · Environment files are not explicitly ignored (F12)

- Area: Secrets & client bundles.
- Evidence: [.gitignore:1](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/.gitignore#L1).
- Why it breaks in production: The ignore file excludes *.local, build outputs and logs. It does not exclude .env or .env.production. A future local environment file with credentials could be staged accidentally. This finding does not claim a credential was leaked.
- Scores: 1 × 3 × 1 = 3.
- Confidence and assumptions: High confidence: the complete ignore file was read; tracked credential exposure and Git history were not inspected.
- Fix: Ignore .env and .env.* while allowing a value-free example file. Check tracked filenames separately and rotate only if an authorized credential review confirms exposure.
- Verify: Create dummy environment filenames in a temporary checkout; git check-ignore identifies each intended private file while a sanitized example remains trackable. Not run.
- Status after recheck: open. No target-code changes or runtime verification were performed.

## Dropped and unresolved candidates

All 181 candidate dispositions are recorded locally in triage.md. The following examples show why raw matches do not equal findings:

- [src/components/InteractiveGlobe.tsx:25](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/src/components/InteractiveGlobe.tsx#L25): Math.random() sets decorative globe coordinates, not a security identifier; both globe matches were dropped.
- [supabase/functions/ai-generate-insights/index.ts:6](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/supabase/functions/ai-generate-insights/index.ts#L6): The floating-dependency rule matched a CORS wildcard, not an import or version. All nine such CORS matches were dropped.
- [supabase/migrations/20250615075552-406bef98-45fc-43b7-a16a-d2a848bc4bd9.sql:24](https://github.com/Ashutosh102/RecallIQ/blob/af423c91f366551b001e4e6f76cda3039b881488/supabase/migrations/20250615075552-406bef98-45fc-43b7-a16a-d2a848bc4bd9.sql#L24): The permissive OTP table policy is explicitly dropped by the later 20250622155025 migration. Reviewing the final migration chain avoids reporting a superseded policy.

Three UI auth-rate-limit matches need deployed Supabase/gateway configuration. The attachment select-star match needs realistic per-memory row volume. These four unresolved candidates are not confirmed defects. The npm lockfile contributes 139 dropped candidates (138 range matches and one size match); its ranges are metadata beside pinned package entries. This scanner behavior is documented here; the pack was not changed.

## Operational checks still needed

All verify steps above are proposals, not executed tests. Inspect deployed policies/function grants privately with the author; do not probe the live app. Validate OTP expiry/attempt enforcement, provider quotas, storage URL renewal and owner isolation in authorized staging. The source contains expiry and failed-attempt checks, so this report does not assert that OTPs never expire or that attempts are unlimited.

No restore drill, release rollback, production query plan, dependency advisory scan or alert delivery was tested. There are indexes in the migrations; no missing-index claim is made without volume/query-plan evidence. The browser Supabase key identifies the anon role, which is not evidence of a privileged credential leak. No secret values are published.

Coverage excludes Git history, environment files, token-named files, ignored dependency/build folders, deployed bundles and actual external-service settings. Scanner skips are a count from its own walk, not proof that every possible runtime artifact was inspected. All nine edge handlers and nine migrations were read; the manual payment test and entrypoint callers were inspected without execution. Dependency advisory status remains unknown.

This review describes the pinned source snapshot. It does not certify the app safe or establish current live behavior.
