Skip to content

feat: multi-server query execution, user config (furlab.jsonc), and SettingsCommand#60

Merged
liphvf merged 17 commits intomainfrom
qualityaain
Apr 13, 2026
Merged

feat: multi-server query execution, user config (furlab.jsonc), and SettingsCommand#60
liphvf merged 17 commits intomainfrom
qualityaain

Conversation

@liphvf
Copy link
Copy Markdown
Owner

@liphvf liphvf commented Apr 13, 2026

Summary

  • New user config system (furlab.jsonc): replaces appsettings.json with a user-managed config file under %LOCALAPPDATA%\FurLab. Introduces IUserConfigService, ServerConfigEntry, UserConfig, UserDefaults, and legacy migration via TryLoadLegacyConfig.
  • QueryCommand rewrite: native multi-server execution with Parallel.ForEachAsync, auto-database discovery via Npgsql (no psql binary required), inline query support (-c), destructive query detection with confirmation prompt, Polly retry with exponential backoff, and consolidated/per-server CSV export via extracted CsvExporter.
  • SettingsCommand: new settings db-servers subcommands (ls, add, rm, test) for managing server configurations interactively or via flags.
  • SqlQueryAnalyzer: regex-based detection of destructive SQL keywords with CTE support. Known limitation (multiple CTEs) documented and covered by tests.
  • Program.cs: EnableDefaultExceptionHandler = false so exceptions from handlers propagate to a structured try/catch with 14 clauses, semantic exit codes, and AnsiConsole formatted messages — no raw stack traces shown to users.
  • Cleanup: removed FurLab.CodeAnalysis project, appsettings.json/appsettings.example.json, dead --database (singular) option, and all Environment.Exit calls from business logic.

Test coverage

140 tests passing (2 skipped — Windows-only platform tests):

  • UserConfigServiceTests — 15 tests including 4 for TryLoadLegacyConfig
  • SqlQueryAnalyzerTests — 24 tests including CTE edge cases and known-limitation documentation
  • CsvExportTests — 8 tests against CsvExporter directly (no logic duplication)
  • QueryCommandTests — 11 tests including 9 UnescapeInlineQuery edge cases

liphvf added 17 commits April 11, 2026 00:39
- Add FurLab.runsettings for MSTest parallelization
- Update .gitignore for CODE_REVIEW.md
- Document required MSTest attributes in CLAUDE.md
- Archive SQL injection fix openspec change set
Also add missing System.Linq using to test files where needed.
Adiciona atributos DisplayName e Description nos métodos de teste para
melhor descritividade e organização. Remove testes redundantes e
consolida verificações onde aplicável. Melhora a clareza dos nomes dos
métodos de teste conforme as diretrizes do projeto.
…ion and interactive selection

- Introduced `furlab.jsonc` for user-specific server configurations, replacing `appsettings.json`.
- Added interactive server selection for `query run` command, allowing multiple server selection.
- Implemented `-c` parameter for inline query execution, mutually exclusive with `-i`.
- Added guard rails for destructive queries with regex detection and user confirmation.
- Enabled configurable parallel execution of queries across multiple servers with failure tolerance.
- Introduced new `settings db-servers` command for managing server configurations (CRUD operations).
- Implemented auto-discovery of databases with configurable exclusion patterns.
- Enhanced CSV output to include metadata such as Server, Database, ExecutedAt, Status, RowCount, and Error.
- Updated documentation and specifications to reflect new features and changes.
- Added UserConfigService for managing user configurations in furlab.jsonc.
- Introduced models for ServerConfigEntry and UserDefaults.
- Implemented JSONC parsing with comment stripping and schema validation.
- Created SqlQueryAnalyzer to detect potentially destructive SQL queries.
- Added QueryType enum to classify SQL queries as Safe or Destructive.
- Integrated Polly for automatic retries on transient failures.
- Refactored DockerService error messages to English.
- Added SettingsCommand for managing database server configurations.
- Updated Program.cs to register new services and commands.
…, ensuring errors are logged in the terminal and not in the CSV
…port

- Updated QUERY_COMMAND.md to reflect new command usage and execution flow for multi-server queries.
- Simplified command options and clarified CSV output formats.
- Added examples for using connection strings and handling multiple databases.
- Enhanced the task list in query-run-multi-server/tasks.md with completed tests for query analysis and server configuration.
- Introduced CsvExportTests to validate CSV output formats and data integrity.
- Added SqlQueryAnalyzerTests to ensure correct classification of SQL query types.
- Implemented UserConfigServiceTests to verify configuration loading and server management functionalities.
- Created a new example configuration file (furlab.example.jsonc) with detailed comments for user guidance.
… and user feedback

- Updated QueryCommand to throw exceptions instead of using AnsiConsole for error messages, enhancing error handling.
- Added detailed exception messages for invalid options and file paths in QueryCommand.
- Refactored SettingsCommand to throw exceptions for required parameters and existing server names, improving clarity.
- Changed user prompts and messages in SettingsCommand to English for consistency.
- Enhanced error handling in Program.cs to provide clearer feedback for various exceptions.
- Updated SqlQueryAnalyzer to document limitations regarding CTE parsing.
- Migrated CSV writing logic to CsvExporter for better code organization.
- Added unit tests for edge cases in UnescapeInlineQuery and SqlQueryAnalyzer.
- Implemented legacy configuration loading in UserConfigService with tests for various scenarios.
@liphvf liphvf merged commit 12d1c0c into main Apr 13, 2026
1 check passed
@liphvf liphvf deleted the qualityaain branch April 13, 2026 01:25
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.

1 participant