Enterprise Security & AI Trust Architecture
Enterprise teams adopting AI for production database governance ask three decisive questions: 1) How do you guarantee schema and production data never leak to LLMs? 2) How do you guarantee AI is strictly non-intrusive? 3) How do you prevent AI hallucinations from blocking valid releases or generating broken SQL?
Yearning v4 enforces every guarantee in Go runtime code rather than prompt wishes.
1. Zero-Leak AI Privacy (Dual-Track Isolation)
Cloud OpenAI-Compatible Track (default)
- Literal & Comment Stripping: Dialect lexers (
TiDB Parser/pg_query_go) strip every business literal and comment before LLM dispatch, replacing values with typed placeholders (:val_str_1,:val_int_1). - Per-Request In-Memory Identifier Anonymization:
RunMapper+TurnValueMapperrewrite real schemas, tables, and columns intoschema_1,table_1,column_1. Mapping tables exist strictly in per-HTTP-request server memory and are freed immediately upon request exit; they are never persisted, logged, cached, or returned to browsers. - Policy & Knowledge Anonymization: Custom review skills and table-scoped knowledge entries (
{{ref:table:["schema","table"]}}) compile through the same anonymizer so policy prose never leaks real object names. - Fail-Closed Zero-Leak Assertion (
AssertZeroLeak/AssertNoLeak): Any residual sensitive token, secret (password=,sk-, DSN), or unmapped literal aborts the outbound request immediately (2005/6003) without ever falling back to plaintext. - Zero Row Sampling: Read-only probes inspect schema metadata, indexes, and safe execution plans only; business table rows are never queried or sampled.
- Audited Restoration (
R014): Stored evidence stays anonymized; only authorized participants (submitter, frozen approvers/executors) see real names restored in the UI with areview.identifier_displayedaudit record.
Self-Hosted Internal Track (san) & Cross-Profile Isolation
- Deploy self-hosted vLLM/Ollama (
SAN-2B,SAN-4B,SQL-Audit-Nano) on private RFC1918 LANs protected byaddrguardSSRF checks so zero bytes leave your corporate network. - Mixed primary/fallback provider chains isolate
PrivacyContractHashDefaultvs.PrivacyContractHashSANand rebuild payloads per target endpoint from raw source, guaranteeing raw payloads prepared for localsanendpoints never fall back to clouddefaultproviders.
2. Strictly Non-Intrusive AI
- AI Precheck: Calls 5 read-only metadata tools only; produces structured findings only; cannot approve, execute, or bypass the Submission Gate.
- Database AI Assistant: Never executes any SQL (not even
SELECTorEXPLAIN). Generated drafts carrydraft_id + revision + sql_hmacand must pass formal AI Precheck (StartEphemeralRun) and multi-stage Approval (SubmitOrderV2). - SQL Performance Diagnostics: Reuses read-only
query/reviewpools exclusively (never falls back toexecutioncredentials), never installs extensions, never modifies DB parameters or resets counters, and never runsEXPLAIN ANALYZEon production. - Frozen Governance (
admin_is_not_business_override): Submitted orders freeze stages, approvers, executors, SQL hash, and review snapshots; even built-inadmincannot override or execute on behalf of frozen actors.
3. Anti-Hallucination Guardrails
- Three-Tier Finding Governance: Violations of enabled rules/knowledge (
policy_finding) and runtime-proven invalid statements (proven_invalid_execution) deterministically block asCritical(2008), whereas open-ended LLM suggestions (agent_observation) are capped atMediumso model hallucinations can never block valid deployments on their own. - Fail-Closed
partialGate: Missing or truncated catalog metadata locks precheck inpartialstatus instead of letting the LLM guess "safe". - Plan Fact Verification (
ValidateNoHallucinatedPlanFacts): Verifies that tables, indexes, and plan facts cited by AI reports originate from actual read-only tool outputs. - Strict JSON Schema + Dialect AST Verification: Precheck output must validate against strict JSON schemas (
2009); AI Assistant SQL must pass dialect AST parsing, authorized object bounds, and typed placeholder verification (6004), and must ask clarifying questions instead of inventing values for missingNOT NULLcolumns.
4. Platform Defense-in-Depth
- 6-Purpose AES-256-GCM AEAD Keyring + AAD Binding: Every ciphertext binds
deployment_id + table + primary_key + column + purposeinto AAD;keyring.jsonrequires0400/0440permissions. - Least-Privilege Roles: Separated read-only vs. execution credentials on target DBs with TLS verification and
identity_fingerprint; mandatory 3-role PostgreSQL separation in production (yearning_app,yearning_migrator,yearning_retention). - Hardened Auth, Transport & Runtime: Argon2id password hashes, 5-attempt admin lockout with local TTY-only reset (
./yearning --reset-admin-password), mandatoryLDAPS/StartTLSand OIDC PKCE (S256), double-submit CSRF,addrguardanti-SSRF, watermarked audited SQL Reveal (username + timestamp + trace_id), 90-day append-only audit logs, and non-root read-only Distroless containers.