Repository navigation
Description
Context
ARCHITECTURE §5.4 (docs/design/ARCHITECTURE.md:1079-1119) declares 5 Tauri commands with specific signatures: ai_generate_sql, ai_explain_query, ai_optimize_query, ai_chat, ai_status. Audit finding F3 in docs/audits/ai.md.
Problem
The implementation (src-tauri/src/commands/ai.rs) has only ai_chat, ai_get_status (different name), ai_set_config, ai_cancel, ai_approve_permission. Three of the five documented commands do not exist on disk (grep -n "ai_generate_sql\|ai_explain_query\|ai_optimize_query" src-tauri/src/commands/ai.rs returns no matches). Worse: ai_chat per the doc accepts history: Vec<ChatMessage> and context: Option<SchemaContext> — neither is wired through (commands/ai.rs:18-50 takes only message, conversation_id, mode, connection_id, database); the SDK's internal session memory is the only thing carrying state. The frontend works around this by QueryToolbar.tsx:297-336 ("AI Explain" / "AI Optimize") and ResultsGrid.tsx:477-505 ("Fix with AI") interpolating the SQL into the user message text — this works but doesn't match the architecture. FR-6.1.1 (NL→SQL), FR-6.2.1 (explain), FR-6.2.2 (optimize) acceptance criteria imply typed command paths that don't exist.
Files
- docs/design/ARCHITECTURE.md:1079-1119 (declared signatures)
- src-tauri/src/commands/ai.rs (actual; 5 commands)
- src-tauri/src/lib.rs:213-223 (registered handlers)
- src/components/editor/QueryToolbar.tsx:297-336
- src/components/grid/ResultsGrid.tsx:477-505
Repro
Static analysis: grep -rn "ai_generate_sql\|ai_explain_query\|ai_optimize_query" src-tauri/src/ returns nothing outside the test files.
Expected
Either the three missing commands are implemented as proper Tauri commands with typed signatures, or ARCHITECTURE §5.4 is amended to reflect the actual ai_chat-only surface and the corresponding FRs are updated.
Proposed fix
Scope M. (a) Implement the missing commands calling dedicated SDK sessions with custom system prompts returning typed OptimizationSuggestion etc., OR (b) update ARCHITECTURE §5.4 to drop the unused signatures. Extend ai_chat signature with history and context per the doc even if SDK-side empty. Update FR-6.1.1, FR-6.2.1, FR-6.2.2 accordingly.
Acceptance
grep -n "ai_generate_sql\|ai_explain_query\|ai_optimize_query" src-tauri/src/commands/ai.rs returns matches (option a), or ARCHITECTURE §5.4 + corresponding FRs are amended (option b). The frontend either routes through the new commands or continues to use ai_chat and the architecture doc reflects that.
Needs human verify
no
Activity
EVWorth commentedon Sep 12, 2026
Closing as obsolete rather than fixed: this describes the implementation that ADR-011 replaces.
The AI feature is being rebuilt around a decision made in #673 — SQLPilot does not call a model. It exposes the database, under its own policy, to whatever harness the user already runs and pays for. The
mas-aicrate, its Copilot SDK session, its system prompt and its tool guards are all going.What that does to this issue specifically: those three commands are going away along with the rest of
mas-ai; ARCHITECTURE §5.4 goes with them. The command surface check already flags anything documented and unregistered, so the drift cannot come back quietly.The design is in docs/design/AI_INTEGRATION.md and ADR-011. If any part of this issue survives the redesign in a form I have missed, reopen it — I would rather re-argue it than lose it.