์ฐ๋ฆฌ๋ ํจ๊ป ์ฝ๋์ ์์ด๋์ด๋ฅผ ๋๋๋ฉฐ ๋ ๋์ ๋ฐ์ดํฐ ํ๊ฒฝ์ ๋ง๋ค๊ธฐ ์ํ ์คํ์์ค ์ฌ์ ์ ๋ ๋ฉ๋๋ค. ๐๐ก
A document-learning, read-only SQL analytics agent. Feed it your company's docs โ it learns your business context โ it keeps a separate set of definitions per team โ it answers questions over an incomplete database โ it remembers every definition and conversation.
๐ ํ๋ก์ ํธ ์ ์ฒด ๊ทธ๋ฆผ(๋จ์ผ SSOT): docs/PROJECT.md ยท ์ปจํธ๋ฆฌ๋ทฐํฐ ํ๋ ๊ฐ์ด๋: docs/ARCHITECTURE.md
This is the v4.1 rebuild (๋ฐฐ๊ฒฝ/์ค๊ณ ์๋: docs/discord_first_redesign_v4_1.md).
Where most text-to-SQL projects compete on "generate better SQL," Lang2SQL
competes on everything around the query: business-context learning, per-team
semantics, robustness to messy databases, and memory. Discord is the Phase 1
interface, not the identity โ Slack/Web are adapters on the same core.
| Pillar | What it is |
|---|---|
| โ Business-context learning | Documents are the source of truth. Drop in a doc โ the agent extracts metric/dimension/rule candidates โ you confirm โ they land in the semantic layer. |
| โก Two-axis robustness | (2a) DB robustness โ works even when columns lack descriptions (auto-enrichment, v1.5). (2b) Semantic robustness โ teams hold different definitions of the same term without conflict. This axis is the product/research identity. |
| โข Hermes memory | Conversations, facts, and preferences persist instead of resetting each session. |
| โฃ Multi-interface | Phase 1 Discord today; Slack/Web are future adapters. No platform lock-in. |
V1 ships the simplest single implementation of each extension point, but the abstraction (port) is already in place, so v1.5/v2 plug in a new implementation without touching existing code โ like a standard wall outlet where you swap the appliance, not the wiring.
Four โ
extension patterns sit behind core/ports/:
| โ | Pattern | Port | Grows by |
|---|---|---|---|
| โ | Safety pipeline | ports/safety.py |
adding one layer class to the line (zero run_sql changes) |
| โก | Memory service | ports/memory.py |
swapping any of 3 axes โ Store / Recall / Extractor โ independently |
| โข | Ingestion pipeline | ports/ingestion.py |
a Source ร Extractor matrix |
| โฃ | Semantic federation | ports/semantic_scope.py |
git-like per-team scope branches |
Everything outside tenancy/concierge.py depends only on these Protocols, so the
concrete classes (OpenAI, Postgres, SQLite) are swappable at the seams.
Requires Python โฅ 3.10 and uv.
uv sync # create .venv and install deps.venv/bin/python bench/ecommerce_demo.pyShows the federation money-shot (one term, two team definitions, no conflict) and
the safety gate (DROP/INSERT blocked, SELECT passes). See bench/README.md.
.venv/bin/lang2sql "list the tables"The CLI assembles a real HarnessContext and runs one turn through the agent
loop. With OPENAI_API_KEY set it calls gpt-4.1-mini; otherwise it uses the
offline FakeLLM.
export DISCORD_BOT_TOKEN=... # required
export OPENAI_API_KEY=... # optional; offline FakeLLM if unset
export LANG2SQL_SECRET_KEY=... # optional; Fernet key for secret encryption
.venv/bin/lang2sql-botThe bot exits loudly if DISCORD_BOT_TOKEN is unset. Full setup and hosting:
docs/DEPLOY.md. Copy .env.example to start.
Does:
- 3-scope semantic federation (org / team / user) โ ๋์ผ ์ฉ์ด์ ์ฌ๋ฌ ๋ ์ด์ด ์ ์๊ฐ
์กด์ฌํ๋ฉด ํ์ฌ ์ฑ๋ ์ ์๋ฅผ โ
๋ก ํ์ํ๊ณ ์ ์ฒด ์ฃผ์
; LLM์ด ์ปจํ
์คํธ๋ก ํ๋จ.
term_customregisters definitions per scope (KV-backed);kind(metric/table/rule/dimension) ยทapplies_toยทtagsํ๋ ์ง์. - Safety pipeline with the V1 layers (whitelist + timeout), gating every query.
- Agent loop with nine tools:
run_sql,explore_schema,enrich_schema,term_custom,org_setup,ingest_doc,confirm_ingest,remember,ask_user. - Memory service (in-memory store + inject-all recall + manual
/remember). - Discord frontend (bot, commands, session router, render).
- Encrypted-at-rest secrets (Fernet) and SQLite-backed persistence.
Does NOT yet:
- Execute against a real database.
PostgresExploreris a V1 stub with cannedorders/usersschema and sample rows; real psycopg execution is v1.5. - Reason without a key. Without
OPENAI_API_KEY, theFakeLLMreturns deterministic canned tool cycles โ useful for wiring tests, not for answers. - AST-precise SQL validation, function blocklists, cost gating,
/semantic diff//semantic promote, keyword/vector recall, automatic fact extraction, URL/Notion ingestion โ all scoped to v1.5+. - Persist across restarts by default: the V1
SqliteStoredefaults to in-memory; point it at a file for durability.
Current status: V1 complete โ
enrich_schemaand OKF bundle export are V1.5 features already shipped; next target is AST validation, SQLite file-mode default, and keyword recall.
| Area | V1 | V1.5 | V2 | V2.5 |
|---|---|---|---|---|
| Safety | whitelist + timeout | + AST validation, function blocklist, auto LIMIT, metadata enrichment, rate limit | + cost gate (EXPLAIN), per-engine pipelines | โ |
| Memory | in-memory + inject-all + manual | SQLite store + keyword recall + auto-extract | + vector recall + conflict resolution | PostgreSQL + hybrid recall + confidence |
| Ingestion | file upload + LLM extract | + URL fetch + DDL parsing | + Notion/Confluence + hybrid | + GitHub/Drive + chunked RAG |
| Federation | 3-scope resolution, /semantic show |
/semantic diff, /semantic promote, conflict alerts |
git sync (semantic-as-code) | branch fork/merge UI, per-scope audit |
| Interface | Discord | (Anthropic/NIM eval) | Slack | Web |
See docs/discord_first_redesign_v4_1.md
for the full architecture write-up.
์ฒ์ ๋ณด์๋ ๋ถ์ docs/ARCHITECTURE.md โ ๋๋ ํ ๋ฆฌยท๋ ์ด์ด ์ฑ
์, ํ ๋ฉ์์ง์ lifecycle, ์ด๋๋ฅผ ์์ ํ๋ฉด ์ข์์ง ๊ฐ ํ๊ณณ์ ์ ๋ฆฌ๋ผ ์์ต๋๋ค.
git clone https://github.com/CausalInferenceLab/lang2sql.git
cd lang2sql
uv sync
.venv/bin/pytest -q # 12 safety regressions + full suite must pass- ์ ๊ธฐ๋ฅ์๋ ํ
์คํธ ์์ฑ (
tests/test_<layer>.py) - PR์
master๋ธ๋์น ๋์, ์ปค๋ฐ ๋ฉ์์ง์feat:/fix:/docs:prefix ์ฌ์ฉ - ๋ฒ๊ทธ/๊ธฐ๋ฅ ์์ฒญ์ ์ด์๋ก
Lang2SQL์ ๊ฐ์ง์ฐ๊ตฌ์์ ์ธ๊ณผ์ถ๋ก ํ์์ ๊ฐ๋ฐ ์ค์ธ ํ๋ก์ ํธ์ ๋๋ค. Licensed under the MIT License. ์ปค๋ฎค๋ํฐ: Discord.
๊ฐ์ง์ฐ๊ตฌ์๋ ๋จธ์ ๋ฌ๋๊ณผ AI ๊ธฐ์ ๋ฐ์ ์ ์ค์ ์ ๋ ๋น์๋ฆฌ ์กฐ์ง์ ๋๋ค. ๊ณต์ , ๋๊ธฐ๋ถ์ฌ, ๊ทธ๋ฆฌ๊ณ ํ์ ์ ๊ธฐ์จ์ด๋ผ๋ ํต์ฌ ๊ฐ์น๋ฅผ ๋ฐํ์ผ๋ก ์ํฅ๋ ฅ ์๋ ์คํ์์ค ํ๋ก์ ํธ๋ฅผ ๋ง๋ค์ด๊ฐ๋๋ค.
์ ์ธ๊ณ 5,000๋ช ์ด์์ ์ฐ๊ตฌ์๋ค๊ณผ ํจ๊ป, ์ฐ๋ฆฌ๋ AI ์ง์์ ๋ฏผ์ฃผํ์ ์ด๋ฆฐ ํ์ ์ ํตํ ํ์ ์ด์ง์ ์ ๋ ํ๊ณ ์์ต๋๋ค.
์ปค๋ฎค๋ํฐ: ๐ฌ Discord