Files
sql-server-query-ai/kb/SQLite schema.md
T
ahmed mohammedandClaude Opus 4.7 8b42a0931c docs: karpathy-pattern wiki built from the spec, plan, design contract and decisions ledger
kb/ is its own wiki root: 34 pages across 7 categories, index.md catalog, log.md, AGENTS.md schema layer, and raw/ holding copies of README, the spec, the 13-task plan, the design master and the SDD ledger.

Every page cross-references 3 to 6 others and all 107 wikilinks resolve except two [["list"]] artefacts inside JSON snippets in the copied plan.

Kept separate from the repository root on purpose: its generated graph lands in kb/.ua/ instead of overwriting the code graph.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-22 12:14:05 +03:00

875 B

SQLite schema

lib/db.ts uses node:sqlite — no ORM, no driver, no native build. Four tables:

  • users — id, unique email, salt:hash scrypt password, created_at
  • sessions — hashed token, user id, expiry
  • settings — one row per user: analyst base URL, model, sealed key, extra JSON, Jev key, Jev model, email, onboarded
  • analyses — id, user id, title, raw XML, oul, verdict JSON, status, error, timestamps

patchAnalysis only accepts keys from a PATCHABLE whitelist, because building SET clauses straight from object keys is how an object key becomes SQL.

The saveSettings upsert uses COALESCE(NULLIF(excluded.analyst_key, ''), settings.analyst_key) so that a form submitting a blank secret keeps the stored one. Blank means "unchanged", never "clear".

Related: Lazy database open, Analysis row lifecycle, Credential vault.