feat(dsql): add dsql_lint tool integration for SQL compatibility validation#157
Conversation
anwesham-lab
left a comment
There was a problem hiding this comment.
Why is there no eval harness? We should definitely add functional evals? Also this change seems like it is intrinsically blocked on the MCP server changes propagating first, no?
|
Addressed both points: Eval harness: Added
MCP server dependency: Yea it should be a joint PR in the MCP repo. The skill-author workflow says:
I was confused as your previous comment asked to make the changes here, so I thought you wanted to see the scope of the steering prior to making further changes. So the delivery to This agent-plugins PR is step 1 — iterate on the skill content with better tooling. Once this merges, the MCP repo PR bundles everything together. |
Updated Eval Results — Behavioral With-Skill vs BaselineReplaced the previous tool-only validation with proper behavioral evals. Spawned subagents with and without the skill, compared outputs. Summary
Baseline Failures (consistent across both evals)
The iron law holdsThe agent fails without this skill change — it hallucinates incorrect DSQL constraints from training data. The skill eliminates this by routing through Full results: |
…dation Add dsql-lint as a deterministic validation tool the agent invokes before executing externally-sourced SQL. Enables migration support for customers coming from PostgreSQL, MySQL, or ORMs (Django, Rails, Prisma, TypeORM). Changes: - Add references/dsql-lint.md: tool API, fix statuses, usage patterns, ORM integration, unfixable error resolution - Update SKILL.md: add dsql_lint to MCP Tools section, update Workflows 2/6/7 with lint validation steps, add Workflow 9 (Validate & Migrate SQL to DSQL) - Update frontmatter: add lint/ORM trigger phrases and tags The dsql_lint MCP tool (shipping separately in awslabs/mcp) validates SQL and optionally auto-fixes issues, returning structured diagnostics the agent acts on. The skill teaches the agent when and how to use it.
- MD029: Restart ordered list numbering after section breaks - MD032: Add blank lines before lists after bold headings
Move AWS Knowledge limits table reference to development-guide.md (already documented there). Condense Quick Start to 3 lines. Trim workflow descriptions to routing-only — detail lives in reference files. validate-size.py: 276 lines, status 'good' validate-references.py: 0 broken links, 0 new orphans
- Restore destructive workflow warning in Workflow 6 - Re-introduce RFC language (MUST, MAY) in Quick Start - Use active voice: 'Use get_schema', 'Use transact', 'Use readonly_query' - Restore 'one DDL per transaction, multiple DML may share' framing - Remove 'lint' from tags (not sufficient alone to trigger skill) - Remove TOC from dsql-lint.md (file is short, TOC adds no value)
Run dprint fmt to align table columns per repo formatting rules.
- Add tools/evals/databases-on-aws/dsql/dsql_lint_evals.json with 4 functional evals covering: pg_dump migration, Django ORM migration, clean SQL validation, and MySQL with unfixable issues - Add availability note to dsql-lint.md: fall back to manual validation using existing DDL rules when the MCP tool is not yet available The evals test that the agent calls dsql_lint before executing SQL, presents warnings to the user, and handles unfixable errors correctly.
The dsql_lint tool and the skill that references it will ship together in the same MCP repo PR. There is no availability gap — the fallback note was based on a wrong assumption about PR splitting.
Run dsql_lint_evals.json against local MCP server with dsql_lint tool. All 4 evals pass — tool correctly identifies compatibility issues, produces fixed SQL, and reports unfixable errors for manual resolution. Key findings: - Eval 103 (MySQL syntax): dsql-lint uses a PostgreSQL parser, so MySQL-specific syntax (SET, ENGINE, PARTITION BY) triggers a parse error rather than individual rules. Agent falls back to mysql-migrations reference for these cases.
…seline comparison Run evals as subagent behavioral tests: one agent with the skill loaded (uses dsql_lint), one baseline without (relies on model knowledge). Key findings: - Baseline hallucinates JSON→JSONB (DSQL rejects JSONB as column type) - Baseline misses CREATE INDEX ASYNC requirement - Baseline doesn't split multi-DDL transactions - Skill-guided agent uses dsql_lint for deterministic validation, produces correct output on all three failure points The iron law holds: the agent fails without this skill change.
843e540 to
588c8f1
Compare
- Restore hardcoded limits table (critical for performance, not all are in dev guide, link to DSQL docs prevents stale numbers) - Merge Workflow 9 into Workflow 7 as 'Validate and Migrate to DSQL' (reduces line count, single entry point for all migration sources) - Trim redundant triggers from description (lint SQL covers dsql-lint, migrate to DSQL covers ORM migration DSQL) 290 lines, mise run build passes.
Code reviewReviewed via 14 parallel subagents (CLAUDE.md-adherence, shallow-bug, git-history, past-PR-comments, comments-compliance, silent-failure-hunter, comment-analyzer, code-simplifier, pr-test-analyzer, type-design-analyzer, code-reviewer, commit/PR-description audit, simplify, security-review). Each finding was independently scored 0-100 for confidence; listing only items at 60+. The PR body and the 0.1.3 dsql_lint results are otherwise solid, and the with-skill vs. baseline comparison for evals 100-101 is high-quality evidence. Tracker (18 findings, confidence >= 60)
Findings1. PR body "Paired PR" section says the tool ships in a separate 2. PR body line-count claim is stale. Actual file is 290 lines: agent-plugins/plugins/databases-on-aws/skills/dsql/SKILL.md Lines 288 to 290 in c07d2a6 3. Quick Start step 3 says "multiple DML statements MAY share a transaction" and omits the 3,000-row cap, loosening invariants asserted elsewhere in the skill ( agent-plugins/plugins/databases-on-aws/skills/dsql/SKILL.md Lines 183 to 185 in c07d2a6 4. PR body advertises "Workflow 9 (new): General migration from any source", but the diff only renames Workflow 7 to "Validate and Migrate to DSQL". agent-plugins/plugins/databases-on-aws/skills/dsql/SKILL.md Lines 241 to 245 in c07d2a6 5. Eval results file documents only evals 100-101; evals 102 and 103 are declared in 6. Workflow 7 advertises "any source (PostgreSQL, MySQL, ORM-generated)" but agent-plugins/plugins/databases-on-aws/skills/dsql/SKILL.md Lines 243 to 245 in c07d2a6 7. 8. 9. Model metadata is stale — current Opus family is 4.7, not 4.6: 10. ORM migration usage pattern collapses agent-plugins/plugins/databases-on-aws/skills/dsql/references/dsql-lint.md Lines 104 to 106 in c07d2a6 11. Eval 103 prompt declares only agent-plugins/tools/evals/databases-on-aws/dsql/dsql_lint_evals.json Lines 40 to 42 in c07d2a6 12. Workflow step 3 and the ORM pattern instruct the agent to silently substitute alternative implementations for 13. agent-plugins/plugins/databases-on-aws/skills/dsql/SKILL.md Lines 127 to 139 in c07d2a6 14. No eval frames the prompt as "execute this SQL" and asserts that the agent lints first. Evals 100-101 ask for compatibility checks; eval 102 explicitly says "do not execute yet" (user-gated). The iron-law MUST rule ("MUST run 15. Frontmatter description still advertises "MySQL-to-DSQL migration", yet Workflow 7 (the only remaining MySQL path) drops all references to agent-plugins/plugins/databases-on-aws/skills/dsql/SKILL.md Lines 2 to 4 in c07d2a6 16. SKILL.md carries an explicit fallback for 17. Unresolved review thread (3204355704): reviewer asked to drop agent-plugins/plugins/databases-on-aws/skills/dsql/SKILL.md Lines 2 to 6 in c07d2a6 18. The Handling Unfixable Errors table enumerates 11 distinct rules; only eval 103 gestures at one ( agent-plugins/plugins/databases-on-aws/skills/dsql/references/dsql-lint.md Lines 114 to 130 in c07d2a6 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Per review: 'SQL compatibility validation' is sufficient without naming the tool. Remove 'via dsql-lint' and 'lint SQL for DSQL' trigger — 'migrate to DSQL' already covers the use case.
5bf1a0e to
6fed1df
Compare
Correctness: - #3: Restore 3k-row cap in Quick Start step 3 - #6: Add PostgreSQL parser caveat to Workflow 7 (MySQL syntax → parse error → fallback) - #10: Fix ORM pattern to present fixed_with_warning to user (not auto-accept) - #12: Unfixable rewrites MUST present to user before substituting Docs accuracy: - #7: Rails: use db:schema:dump with schema_format = :sql (6.1+) - #8: Prisma: add required --from-empty --to-schema-datamodel flags - SQLAlchemy: use CreateTable(table).compile(engine) instead of metadata.create_all(echo=True) which executes DDL Error handling: - #16: Add Error Handling section for dsql_lint failures (MCP unavailable, parse error, timeout) with user-confirmation gates - Add dsql_lint-unavailable entry to SKILL.md Error Scenarios Evals: - #5: Add evals 102/103 to results MD with detail sections - #9: Fix model metadata (remove specific version; clarify manual grading) - #11: Add missing category_id column to eval 103 prompt - Tighten eval expectations to reference concrete tool outputs (rule names, summary fields) - Replace emoji markers with PASS/FAIL/PARTIAL to fix dprint table alignment - Bump recorded dsql-lint version to 0.1.4 Self-review fixes (17 sub-agent review rounds): - Document accurate fix_result.status enum: fixed | fixed_with_warning | unfixable (tool emits status='unfixable' explicitly; earlier doc incorrectly implied absence) - Scope Unfixable Errors table to truly-unfixable rules only (set_transaction, truncate, create_table_as, add_column_constraint, index_expression, index_partial, unsupported_alter_table_op); note that temp_table, inherits, index_using, transaction_isolation are fixed/fixed_with_warning - Fix transaction_isolation vs set_transaction rule-id confusion - Promote reference-load gate from SHOULD to MUST with tightened trigger - Workflow 2: explicit lint gate for async index DDL (step 5) - Workflow 6: lint every generated DDL in Table Recreation Pattern - Workflow 7: cross-check MySQL source against type-mapping.md even on clean lint (ENGINE=, SET() pass silently through PostgreSQL parser) - Document 1M-char SQL limit and 30s server timeout - Require user confirmation before destructive DDL (DROP/RENAME/TRUNCATE), MCP-unavailable fallback, parse_error manual rewrite, and timeout split-retry paths - Forbid executing fixed_sql while any unfixable diagnostic remains (re-lint until clean) - Add user override semantics for "just run it" requests - Remove redundant Usage Patterns, Exit Codes, and Additional Resources sections Already fixed in previous commit: - #17: dsql-lint removed from description (93e9c7b) PR body items (1, 2, 4) will be updated separately.
6fed1df to
cf4fe70
Compare
…slation (awslabs#3423) Mirror the merged agent-plugins skill content (awslabs/agent-plugins#157) to the MCP repo standalone skill and Kiro Power. Skill (skills/dsql-skill/): - Update SKILL.md: add dsql_lint to MCP Tools, update Workflows 2/6, rename Workflow 7 to 'Validate and Migrate to DSQL' - Add references/dsql-lint.md: tool API, workflow steps, ORM guidance, unfixable error resolution, error handling - Sync all 5 alias SKILL.md files Kiro Power (kiro_power/): - Update POWER.md: add dsql-lint steering entry, add dsql_lint tool, update Workflows 2/6/7 - Add steering/dsql-lint.md (same content as references/) Paired with awslabs/agent-plugins#157 (canonical source, merged) and awslabs#3350 (server tool, merged).
Summary
Integrates
dsql-lintas a deterministic SQL validation tool into the DSQL skill. The agent invokesdsql_lintbefore executing externally-sourced SQL to catch DSQL compatibility issues and auto-fix them where possible.Changes
references/dsql-lint.md(new) — Tool API reference with accuratefix_result.statusenum (fixed|fixed_with_warning|unfixable), schema notes (1M-char limit, 30s timeout,statement_previewfield), workflow steps with user-confirmation gates, ORM integration guidance, unfixable error resolution, and error handling for MCP unavailability, parse errors, and timeouts.SKILL.md— Adddsql_lintto MCP Tools section, update Workflows 2/6/7 with lint validation steps, rename Workflow 7 to "Validate and Migrate to DSQL" (covers PostgreSQL, MySQL fallback with silent-pass cross-check, ORM sources), adddsql_lintunavailable entry to Error Scenarios, MUST-load gate forreferences/dsql-lint.md, update frontmatter description (add "SQL compatibility validation") and addormtag.What this enables
The
dsql_lintMCP tool (merged in awslabs/mcp#3350) validates SQL and optionally auto-fixes issues. The skill teaches the agent when and how to use it:mysql-migrations/type-mapping.mdeven on clean lint (ENGINE=,SET()pass silently through the PostgreSQL parser).Validation
validate-references.py: 0 broken links, 0 new orphansvalidate-size.py: 298 lines (under 300 limit)mise run build: all checks passEval Results
Behavioral with-skill vs baseline comparison (full results in
tools/evals/databases-on-aws/dsql/dsql_lint_eval_results.md):parse_error; agent falls back to mysql-migrationsMirror PR
The
dsql_linttool itself shipped in awslabs/mcp#3350 (merged). The skill-side mirror toawslabs/mcpwill follow after this PR merges (per multi-target sync workflow).By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.