Skip to content

fix(aadi): log why the analysis limits are unavailable - #23

Merged
gaffercode merged 1 commit into
mainfrom
claude/project-thread-i421f5
Nov 22, 2026
Merged

gaffercode merged 1 commit into
mainfrom
claude/project-thread-i421f5

Conversation

@gaffercode

Copy link
Copy Markdown
Owner

Requested by Gaffercode · project thread

What changed

  • src/lib/aadi/limits.ts: every LIMITS_UNAVAILABLE refusal now logs a safe diagnostic code: NO_STORE, NO_PRINCIPAL, the Postgres SQLSTATE (e.g. 42P01 missing table, 42501 missing grant, 28P01 bad password) or the Node network code (ENOTFOUND, ECONNREFUSED, ETIMEDOUT). Same for the usage and settle failure logs. The error message is never logged, since it can name the host or role.
  • docs/data.md: new section mapping each code to its fix, plus a read-only SQL check for the tables the limits need.
  • tests/aadi-limits.test.ts: covers the new codes and that no message text leaks.

Why

Beta users get "Pencatat batas pemakaian belum tersedia" on every analysis. The readiness probe reports ready: true (it only checks that SENTRAPEDIA_DATABASE_URL and the quota are set), so the store must be failing at query time. Before this change the log line was a bare {"stage":"admit"} and the cause was invisible. The most likely cause (unverified, no access to server logs or the production database) is that migration 0003_analysis_limits.sql (and possibly 0004/0005) was never applied to the production Neon branch.

The guard still fails closed: no analysis runs without a count. No behaviour change for users.

Verification

  • npx vitest run: 86 files, 826 passed, 23 skipped.
  • npx tsc --noEmit: exit 0.
  • npx eslint on the changed files: exit 0.
  • npm run test:system: 70 passed, 0 failed.
  • Not run: apps/site tests and lint (untouched), test:aadi (Python engine, untouched), Postgres-backed tests (need a test database).

Generated by Claude Code

Every LIMITS_UNAVAILABLE refusal was logged as a bare {"stage":"admit"}
(or not at all when the store or principal was missing), so an operator
could not tell a missing migration from a wrong password or a network
fault. The refusal now logs a safe diagnostic code: NO_STORE,
NO_PRINCIPAL, the Postgres SQLSTATE, or the Node network code. The error
message is never logged, since it can name the host or role.

The guard still fails closed: no analysis runs without a count.
docs/data.md maps each code to its fix and gives a read-only SQL check
for the tables the limits need.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ta9C9ipVdnjJbVts5P9wk
@vercel

vercel Bot commented Nov 22, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
sentrapedia Ready Ready Preview Nov 22, 2026 2:33am UTC

Request Review

@gaffercode gaffercode self-assigned this Nov 22, 2026
@gaffercode
gaffercode marked this pull request as ready for review November 22, 2026 02:39
@gaffercode
gaffercode merged commit c008926 into main Nov 22, 2026
4 checks passed
@gaffercode
gaffercode deleted the claude/project-thread-i421f5 branch November 22, 2026 02:39
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